| Name | Size | Mode | Actions |
|---|---|---|---|
| tests/ | - | 0755 | rm |
| api.ts | 47508 | 0644 | editdlrm |
| checks.ts | 37301 | 0644 | editdlrm |
| config.ts | 472 | 0644 | editdlrm |
| core.ts | 4756 | 0644 | editdlrm |
| doc.ts | 1192 | 0644 | editdlrm |
| errors.ts | 13154 | 0644 | editdlrm |
| function.ts | 6285 | 0644 | editdlrm |
| index.ts | 499 | 0644 | editdlrm |
| json-schema.ts | 3709 | 0644 | editdlrm |
| parse.ts | 3822 | 0644 | editdlrm |
| regexes.ts | 6953 | 0644 | editdlrm |
| registries.ts | 2850 | 0644 | editdlrm |
| schemas.ts | 118421 | 0644 | editdlrm |
| standard-schema.ts | 2327 | 0644 | editdlrm |
| to-json-schema.ts | 32423 | 0644 | editdlrm |
| util.ts | 22813 | 0644 | editdlrm |
| versions.ts | 83 | 0644 | editdlrm |
| zsf.ts | 6677 | 0644 | editdlrm |
/opt/canhelp/node_modules/zod/src/v4/core/registries.ts (2850B)
; // tuple
}
) => $replace(
schema: S,
..._meta: undefined extends Meta ? [$replace?] : [$replace]
): this {
const meta: any = _meta[0];
this._map.set(schema, meta!);
if (meta && typeof meta === "object" && "id" in meta) {
if (this._idmap.has(meta.id!)) {
throw new Error(`ID ${meta.id} already exists in the registry`);
}
this._idmap.set(meta.id!, schema);
}
return this as any;
}
clear(): this {
this._map = new Map();
this._idmap = new Map();
return this;
}
remove(schema: Schema): this {
const meta: any = this._map.get(schema);
if (meta && typeof meta === "object" && "id" in meta) {
this._idmap.delete(meta.id!);
}
this._map.delete(schema);
return this;
}
get(schema: S): $replace | undefined {
// return this._map.get(schema) as any;
// inherit metadata
const p = schema._zod.parent as Schema;
if (p) {
const pm: any = { ...(this.get(p) ?? {}) };
delete pm.id; // do not inherit id
return { ...pm, ...this._map.get(schema) } as any;
}
return this._map.get(schema) as any;
}
has(schema: Schema): boolean {
return this._map.has(schema);
}
}
export interface JSONSchemaMeta {
id?: string | undefined;
title?: string | undefined;
description?: string | undefined;
deprecated?: boolean | undefined;
[k: string]: unknown;
}
export interface GlobalMeta extends JSONSchemaMeta {}
// registries
export function registry