- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
var _a;
|
|
export const $output = Symbol("ZodOutput");
|
|
export const $input = Symbol("ZodInput");
|
|
export class $ZodRegistry {
|
|
constructor() {
|
|
this._map = new WeakMap();
|
|
this._idmap = new Map();
|
|
}
|
|
add(schema, ..._meta) {
|
|
const meta = _meta[0];
|
|
this._map.set(schema, meta);
|
|
if (meta && typeof meta === "object" && "id" in meta) {
|
|
this._idmap.set(meta.id, schema);
|
|
}
|
|
return this;
|
|
}
|
|
clear() {
|
|
this._map = new WeakMap();
|
|
this._idmap = new Map();
|
|
return this;
|
|
}
|
|
remove(schema) {
|
|
const meta = 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) {
|
|
// return this._map.get(schema) as any;
|
|
// inherit metadata
|
|
const p = schema._zod.parent;
|
|
if (p) {
|
|
const pm = { ...(this.get(p) ?? {}) };
|
|
delete pm.id; // do not inherit id
|
|
const f = { ...pm, ...this._map.get(schema) };
|
|
return Object.keys(f).length ? f : undefined;
|
|
}
|
|
return this._map.get(schema);
|
|
}
|
|
has(schema) {
|
|
return this._map.has(schema);
|
|
}
|
|
}
|
|
// registries
|
|
export function registry() {
|
|
return new $ZodRegistry();
|
|
}
|
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
export const globalRegistry = globalThis.__zod_globalRegistry;
|