zod-nest 0.0.0-alpha.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +200 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { JSONSchema, $ZodTypes } from 'zod/v4/core';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
/** OpenAPI 3.1 `$ref` prefix for entries in `components.schemas`. */
|
|
5
|
+
declare const COMPONENTS_SCHEMAS_PREFIX = "#/components/schemas/";
|
|
6
|
+
/** OpenAPI extension key zod-nest uses to surface engine errors inside emitted schemas. */
|
|
7
|
+
declare const ZOD_NEST_ERROR_EXTENSION = "x-zod-nest-error";
|
|
8
|
+
/** Value of `x-zod-nest-error` when a registry id is claimed by more than one schema. */
|
|
9
|
+
declare const ZOD_NEST_ERROR_DUPLICATE_ID = "duplicate-id";
|
|
10
|
+
|
|
11
|
+
type SchemaObject = JSONSchema.BaseSchema;
|
|
12
|
+
|
|
13
|
+
interface OverrideContext {
|
|
14
|
+
zodSchema: $ZodTypes;
|
|
15
|
+
jsonSchema: SchemaObject;
|
|
16
|
+
path: (string | number)[];
|
|
17
|
+
}
|
|
18
|
+
type Override = (ctx: OverrideContext) => void;
|
|
19
|
+
|
|
20
|
+
interface ZodNestRegistry {
|
|
21
|
+
readonly zodRegistry: typeof z.globalRegistry;
|
|
22
|
+
register(schema: z.ZodType, id: string): void;
|
|
23
|
+
hasCollision(id: string): boolean;
|
|
24
|
+
getCollisions(): ReadonlyMap<string, ReadonlySet<z.ZodType>>;
|
|
25
|
+
}
|
|
26
|
+
declare const createRegistry: () => ZodNestRegistry;
|
|
27
|
+
|
|
28
|
+
interface ToOpenApiOptions {
|
|
29
|
+
io: 'input' | 'output';
|
|
30
|
+
registry: ZodNestRegistry;
|
|
31
|
+
override?: Override;
|
|
32
|
+
strict?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface ToOpenApiResult {
|
|
35
|
+
schema: SchemaObject;
|
|
36
|
+
refs: Map<string, SchemaObject>;
|
|
37
|
+
}
|
|
38
|
+
declare const toOpenApi: (schema: z.ZodType, opts: ToOpenApiOptions) => ToOpenApiResult;
|
|
39
|
+
|
|
40
|
+
declare class ZodNestError extends Error {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
43
|
+
declare class ZodNestUnrepresentableError extends ZodNestError {
|
|
44
|
+
readonly path: ReadonlyArray<string | number>;
|
|
45
|
+
readonly zodType: string;
|
|
46
|
+
constructor(path: ReadonlyArray<string | number>, zodType: string);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { COMPONENTS_SCHEMAS_PREFIX, type Override, type OverrideContext, type SchemaObject, type ToOpenApiOptions, type ToOpenApiResult, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION, ZodNestError, type ZodNestRegistry, ZodNestUnrepresentableError, createRegistry, toOpenApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { JSONSchema, $ZodTypes } from 'zod/v4/core';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
/** OpenAPI 3.1 `$ref` prefix for entries in `components.schemas`. */
|
|
5
|
+
declare const COMPONENTS_SCHEMAS_PREFIX = "#/components/schemas/";
|
|
6
|
+
/** OpenAPI extension key zod-nest uses to surface engine errors inside emitted schemas. */
|
|
7
|
+
declare const ZOD_NEST_ERROR_EXTENSION = "x-zod-nest-error";
|
|
8
|
+
/** Value of `x-zod-nest-error` when a registry id is claimed by more than one schema. */
|
|
9
|
+
declare const ZOD_NEST_ERROR_DUPLICATE_ID = "duplicate-id";
|
|
10
|
+
|
|
11
|
+
type SchemaObject = JSONSchema.BaseSchema;
|
|
12
|
+
|
|
13
|
+
interface OverrideContext {
|
|
14
|
+
zodSchema: $ZodTypes;
|
|
15
|
+
jsonSchema: SchemaObject;
|
|
16
|
+
path: (string | number)[];
|
|
17
|
+
}
|
|
18
|
+
type Override = (ctx: OverrideContext) => void;
|
|
19
|
+
|
|
20
|
+
interface ZodNestRegistry {
|
|
21
|
+
readonly zodRegistry: typeof z.globalRegistry;
|
|
22
|
+
register(schema: z.ZodType, id: string): void;
|
|
23
|
+
hasCollision(id: string): boolean;
|
|
24
|
+
getCollisions(): ReadonlyMap<string, ReadonlySet<z.ZodType>>;
|
|
25
|
+
}
|
|
26
|
+
declare const createRegistry: () => ZodNestRegistry;
|
|
27
|
+
|
|
28
|
+
interface ToOpenApiOptions {
|
|
29
|
+
io: 'input' | 'output';
|
|
30
|
+
registry: ZodNestRegistry;
|
|
31
|
+
override?: Override;
|
|
32
|
+
strict?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface ToOpenApiResult {
|
|
35
|
+
schema: SchemaObject;
|
|
36
|
+
refs: Map<string, SchemaObject>;
|
|
37
|
+
}
|
|
38
|
+
declare const toOpenApi: (schema: z.ZodType, opts: ToOpenApiOptions) => ToOpenApiResult;
|
|
39
|
+
|
|
40
|
+
declare class ZodNestError extends Error {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
43
|
+
declare class ZodNestUnrepresentableError extends ZodNestError {
|
|
44
|
+
readonly path: ReadonlyArray<string | number>;
|
|
45
|
+
readonly zodType: string;
|
|
46
|
+
constructor(path: ReadonlyArray<string | number>, zodType: string);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { COMPONENTS_SCHEMAS_PREFIX, type Override, type OverrideContext, type SchemaObject, type ToOpenApiOptions, type ToOpenApiResult, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION, ZodNestError, type ZodNestRegistry, ZodNestUnrepresentableError, createRegistry, toOpenApi };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,204 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/schema/constants.ts
|
|
6
|
+
var COMPONENTS_SCHEMAS_PREFIX = "#/components/schemas/";
|
|
7
|
+
var ZOD_NEST_ERROR_EXTENSION = "x-zod-nest-error";
|
|
8
|
+
var ZOD_NEST_ERROR_DUPLICATE_ID = "duplicate-id";
|
|
9
|
+
|
|
10
|
+
// src/schema/errors.ts
|
|
11
|
+
var ZodNestError = class extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "ZodNestError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var ZodNestUnrepresentableError = class extends ZodNestError {
|
|
18
|
+
path;
|
|
19
|
+
zodType;
|
|
20
|
+
constructor(path, zodType) {
|
|
21
|
+
super(
|
|
22
|
+
`Unrepresentable Zod schema \`${zodType}\` at ${formatPath(path)}: no override produced a JSON Schema body. Set strict: false to emit \`{}\` instead, or supply an \`override\` that handles this Zod type.`
|
|
23
|
+
);
|
|
24
|
+
this.name = "ZodNestUnrepresentableError";
|
|
25
|
+
this.path = path;
|
|
26
|
+
this.zodType = zodType;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var formatPath = (path) => {
|
|
30
|
+
if (path.length === 0) {
|
|
31
|
+
return "<root>";
|
|
32
|
+
}
|
|
33
|
+
return "/" + path.map(String).join("/");
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/schema/override.ts
|
|
37
|
+
var builtInOverride = ({ zodSchema, jsonSchema }) => {
|
|
38
|
+
const type = zodSchema._zod.def.type;
|
|
39
|
+
if (type === "bigint") {
|
|
40
|
+
jsonSchema.type = "integer";
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (type === "date") {
|
|
44
|
+
jsonSchema.type = "string";
|
|
45
|
+
jsonSchema.format = "date-time";
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var STRICT_REQUIRES_OVERRIDE = /* @__PURE__ */ new Set([
|
|
50
|
+
"bigint",
|
|
51
|
+
"date",
|
|
52
|
+
"symbol",
|
|
53
|
+
"undefined",
|
|
54
|
+
"void",
|
|
55
|
+
"map",
|
|
56
|
+
"set",
|
|
57
|
+
"transform",
|
|
58
|
+
"nan",
|
|
59
|
+
"custom"
|
|
60
|
+
]);
|
|
61
|
+
var isStrictlyUnrepresentable = (jsonSchema, zodSchema) => {
|
|
62
|
+
if (!STRICT_REQUIRES_OVERRIDE.has(zodSchema._zod.def.type)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return Object.keys(jsonSchema).length === 0;
|
|
66
|
+
};
|
|
67
|
+
var combine = (...overrides) => {
|
|
68
|
+
const list = [];
|
|
69
|
+
for (const candidate of overrides) {
|
|
70
|
+
if (typeof candidate !== "function") {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
list.push(candidate);
|
|
74
|
+
}
|
|
75
|
+
if (list.length === 0) {
|
|
76
|
+
return () => void 0;
|
|
77
|
+
}
|
|
78
|
+
return (ctx) => {
|
|
79
|
+
for (const o of list) {
|
|
80
|
+
o(ctx);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/schema/post-process.ts
|
|
86
|
+
var DEFS_PREFIX = "#/$defs/";
|
|
87
|
+
var rewriteRefs = (node, selfRef) => {
|
|
88
|
+
if (Array.isArray(node)) {
|
|
89
|
+
for (const item of node) {
|
|
90
|
+
rewriteRefs(item, selfRef);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (node === null || typeof node !== "object") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const obj = node;
|
|
98
|
+
const ref = obj.$ref;
|
|
99
|
+
if (typeof ref === "string" && ref.startsWith(DEFS_PREFIX)) {
|
|
100
|
+
obj.$ref = COMPONENTS_SCHEMAS_PREFIX + ref.slice(DEFS_PREFIX.length);
|
|
101
|
+
} else if (ref === "#" && selfRef !== void 0) {
|
|
102
|
+
obj.$ref = selfRef;
|
|
103
|
+
}
|
|
104
|
+
for (const value of Object.values(obj)) {
|
|
105
|
+
rewriteRefs(value, selfRef);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var postProcess = (raw) => {
|
|
109
|
+
const refs = /* @__PURE__ */ new Map();
|
|
110
|
+
const rawDefs = raw.$defs;
|
|
111
|
+
if (rawDefs !== void 0) {
|
|
112
|
+
for (const [id, body] of Object.entries(rawDefs)) {
|
|
113
|
+
refs.set(id, body);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const root = { ...raw };
|
|
117
|
+
delete root.$schema;
|
|
118
|
+
delete root.$defs;
|
|
119
|
+
rewriteRefs(root, void 0);
|
|
120
|
+
for (const [id, body] of refs) {
|
|
121
|
+
rewriteRefs(body, `${COMPONENTS_SCHEMAS_PREFIX}${id}`);
|
|
122
|
+
}
|
|
123
|
+
return { schema: root, refs };
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/schema/engine.ts
|
|
127
|
+
var toOpenApi = (schema, opts) => {
|
|
128
|
+
const strict = opts.strict ?? true;
|
|
129
|
+
const merged = combine(builtInOverride, opts.override);
|
|
130
|
+
const unrepresentableHits = [];
|
|
131
|
+
const wrapped = (ctx) => {
|
|
132
|
+
merged(ctx);
|
|
133
|
+
if (!strict || !isStrictlyUnrepresentable(ctx.jsonSchema, ctx.zodSchema)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
unrepresentableHits.push({
|
|
137
|
+
path: [...ctx.path],
|
|
138
|
+
zodType: ctx.zodSchema._zod.def.type
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const raw = zod.z.toJSONSchema(schema, {
|
|
142
|
+
target: "draft-2020-12",
|
|
143
|
+
io: opts.io,
|
|
144
|
+
unrepresentable: "any",
|
|
145
|
+
metadata: opts.registry.zodRegistry,
|
|
146
|
+
override: wrapped,
|
|
147
|
+
cycles: "ref",
|
|
148
|
+
reused: "inline"
|
|
149
|
+
});
|
|
150
|
+
const firstHit = unrepresentableHits[0];
|
|
151
|
+
if (firstHit !== void 0) {
|
|
152
|
+
throw new ZodNestUnrepresentableError(firstHit.path, firstHit.zodType);
|
|
153
|
+
}
|
|
154
|
+
const result = postProcess(raw);
|
|
155
|
+
for (const [id] of opts.registry.getCollisions()) {
|
|
156
|
+
if (!result.refs.has(id)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
result.refs.set(id, {
|
|
160
|
+
description: `ERROR: duplicate zod-nest id <${id}>`,
|
|
161
|
+
[ZOD_NEST_ERROR_EXTENSION]: ZOD_NEST_ERROR_DUPLICATE_ID
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
166
|
+
var createRegistry = () => {
|
|
167
|
+
const seen = /* @__PURE__ */ new Map();
|
|
168
|
+
return {
|
|
169
|
+
zodRegistry: zod.z.globalRegistry,
|
|
170
|
+
register: (schema, id) => {
|
|
171
|
+
zod.z.globalRegistry.add(schema, { id });
|
|
172
|
+
let set = seen.get(id);
|
|
173
|
+
if (set === void 0) {
|
|
174
|
+
set = /* @__PURE__ */ new Set();
|
|
175
|
+
seen.set(id, set);
|
|
176
|
+
}
|
|
177
|
+
set.add(schema);
|
|
178
|
+
},
|
|
179
|
+
hasCollision: (id) => {
|
|
180
|
+
const set = seen.get(id);
|
|
181
|
+
return set !== void 0 && set.size > 1;
|
|
182
|
+
},
|
|
183
|
+
getCollisions: () => {
|
|
184
|
+
const out = /* @__PURE__ */ new Map();
|
|
185
|
+
for (const [id, set] of seen) {
|
|
186
|
+
if (set.size <= 1) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
out.set(id, set);
|
|
190
|
+
}
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
exports.COMPONENTS_SCHEMAS_PREFIX = COMPONENTS_SCHEMAS_PREFIX;
|
|
197
|
+
exports.ZOD_NEST_ERROR_DUPLICATE_ID = ZOD_NEST_ERROR_DUPLICATE_ID;
|
|
198
|
+
exports.ZOD_NEST_ERROR_EXTENSION = ZOD_NEST_ERROR_EXTENSION;
|
|
199
|
+
exports.ZodNestError = ZodNestError;
|
|
200
|
+
exports.ZodNestUnrepresentableError = ZodNestUnrepresentableError;
|
|
201
|
+
exports.createRegistry = createRegistry;
|
|
202
|
+
exports.toOpenApi = toOpenApi;
|
|
3
203
|
//# sourceMappingURL=index.js.map
|
|
4
204
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/schema/constants.ts","../src/schema/errors.ts","../src/schema/override.ts","../src/schema/post-process.ts","../src/schema/engine.ts","../src/schema/registry.ts"],"names":["z"],"mappings":";;;;;AACO,IAAM,yBAAA,GAA4B;AAGlC,IAAM,wBAAA,GAA2B;AAGjC,IAAM,2BAAA,GAA8B;;;ACPpC,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEO,IAAM,2BAAA,GAAN,cAA0C,YAAA,CAAa;AAAA,EACnD,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CAAY,MAAsC,OAAA,EAAiB;AACjE,IAAA,KAAA;AAAA,MACE,CAAA,6BAAA,EAAgC,OAAO,CAAA,MAAA,EAAS,UAAA,CAAW,IAAI,CAAC,CAAA,0IAAA;AAAA,KAGlE;AACA,IAAA,IAAA,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ACH;AAEA,EAAA,OAAO,MAAA;AACT;AC/DO,IAAM,iBAAiB,MAAuB;AACnD,EAAA,MAAM,IAAA,uBAAW,GAAA,EAA4B;AAE7C,EAAA,OAAO;AAAA,IACL,aAAaA,KAAAA,CAAE,cAAA;AAAA,IACf,QAAA,EAAU,CAAC,MAAA,EAAQ,EAAA,KAAO;AACxB,MAAAA,MAAE,cAAA,CAAe,GAAA,CAAI,MAAA,EAAQ,EAAE,IAAI,CAAA;AACnC,MAAA,IAAI,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,EAAE,CAAA;AACrB,MAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,QAAA,GAAA,uBAAU,GAAA,EAAe;AACzB,QAAA,IAAA,CAAK,GAAA,CAAI,IAAI,GAAG,CAAA;AAAA,MAClB;AACA,MAAA,GAAA,CAAI,IAAI,MAAM,CAAA;AAAA,IAChB,CAAA;AAAA,IACA,YAAA,EAAc,CAAC,EAAA,KAAO;AACpB,MAAA,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,EAAE,CAAA;AACvB,MAAA,OAAO,GAAA,KAAQ,MAAA,IAAa,GAAA,CAAI,IAAA,GAAO,CAAA;AAAA,IACzC,CAAA;AAAA,IACA,eAAe,MAAM;AACnB,MAAA,MAAM,GAAA,uBAAU,GAAA,EAA4B;AAC5C,MAAA,KAAA,MAAW,CAAC,EAAA,EAAI,GAAG,CAAA,IAAK,IAAA,EAAM;AAC5B,QAAA,IAAI,GAAA,CAAI,QAAQ,CAAA,EAAG;AACjB,UAAA;AAAA,QACF;AACA,QAAA,GAAA,CAAI,GAAA,CAAI,IAAI,GAAG,CAAA;AAAA,MACjB;AACA,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/** OpenAPI 3.1 `$ref` prefix for entries in `components.schemas`. */\nexport const COMPONENTS_SCHEMAS_PREFIX = '#/components/schemas/';\n\n/** OpenAPI extension key zod-nest uses to surface engine errors inside emitted schemas. */\nexport const ZOD_NEST_ERROR_EXTENSION = 'x-zod-nest-error';\n\n/** Value of `x-zod-nest-error` when a registry id is claimed by more than one schema. */\nexport const ZOD_NEST_ERROR_DUPLICATE_ID = 'duplicate-id';\n","export class ZodNestError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ZodNestError';\n }\n}\n\nexport class ZodNestUnrepresentableError extends ZodNestError {\n readonly path: ReadonlyArray<string | number>;\n readonly zodType: string;\n\n constructor(path: ReadonlyArray<string | number>, zodType: string) {\n super(\n `Unrepresentable Zod schema \\`${zodType}\\` at ${formatPath(path)}: no override produced ` +\n `a JSON Schema body. Set strict: false to emit \\`{}\\` instead, or supply an \\`override\\` ` +\n `that handles this Zod type.`,\n );\n this.name = 'ZodNestUnrepresentableError';\n this.path = path;\n this.zodType = zodType;\n }\n}\n\nconst formatPath = (path: ReadonlyArray<string | number>): string => {\n if (path.length === 0) {\n return '<root>';\n }\n return '/' + path.map(String).join('/');\n};\n","import type { $ZodTypes } from 'zod/v4/core';\nimport type { SchemaObject } from './openapi.types.js';\n\nexport interface OverrideContext {\n zodSchema: $ZodTypes;\n jsonSchema: SchemaObject;\n path: (string | number)[];\n}\n\nexport type Override = (ctx: OverrideContext) => void;\n\nexport const builtInOverride: Override = ({ zodSchema, jsonSchema }) => {\n const type = zodSchema._zod.def.type;\n if (type === 'bigint') {\n jsonSchema.type = 'integer';\n return;\n }\n if (type === 'date') {\n jsonSchema.type = 'string';\n jsonSchema.format = 'date-time';\n return;\n }\n};\n\nconst STRICT_REQUIRES_OVERRIDE: ReadonlySet<string> = new Set([\n 'bigint',\n 'date',\n 'symbol',\n 'undefined',\n 'void',\n 'map',\n 'set',\n 'transform',\n 'nan',\n 'custom',\n]);\n\nexport const isStrictlyUnrepresentable = (\n jsonSchema: SchemaObject,\n zodSchema: $ZodTypes,\n): boolean => {\n if (!STRICT_REQUIRES_OVERRIDE.has(zodSchema._zod.def.type)) {\n return false;\n }\n return Object.keys(jsonSchema).length === 0;\n};\n\nexport const combine = (...overrides: ReadonlyArray<Override | undefined>): Override => {\n const list: Override[] = [];\n for (const candidate of overrides) {\n if (typeof candidate !== 'function') {\n continue;\n }\n list.push(candidate);\n }\n if (list.length === 0) {\n return () => undefined;\n }\n return (ctx) => {\n for (const o of list) {\n o(ctx);\n }\n };\n};\n","import type { SchemaObject } from './openapi.types.js';\n\nimport { COMPONENTS_SCHEMAS_PREFIX } from './constants.js';\n\nexport interface PostProcessResult {\n schema: SchemaObject;\n refs: Map<string, SchemaObject>;\n}\n\nconst DEFS_PREFIX = '#/$defs/';\n\nconst rewriteRefs = (node: unknown, selfRef: string | undefined): void => {\n if (Array.isArray(node)) {\n for (const item of node) {\n rewriteRefs(item, selfRef);\n }\n return;\n }\n if (node === null || typeof node !== 'object') {\n return;\n }\n const obj = node as Record<string, unknown>;\n const ref = obj.$ref;\n if (typeof ref === 'string' && ref.startsWith(DEFS_PREFIX)) {\n obj.$ref = COMPONENTS_SCHEMAS_PREFIX + ref.slice(DEFS_PREFIX.length);\n } else if (ref === '#' && selfRef !== undefined) {\n // Zod emits '#' for cycle refs back to the document root. When we lift a\n // named schema into its own components.schemas entry, '#' should resolve\n // to that entry's own URI.\n obj.$ref = selfRef;\n }\n for (const value of Object.values(obj)) {\n rewriteRefs(value, selfRef);\n }\n};\n\nexport const postProcess = (raw: SchemaObject): PostProcessResult => {\n const refs = new Map<string, SchemaObject>();\n const rawDefs = raw.$defs;\n if (rawDefs !== undefined) {\n for (const [id, body] of Object.entries(rawDefs)) {\n refs.set(id, body);\n }\n }\n\n const root: SchemaObject = { ...raw };\n delete root.$schema;\n delete root.$defs;\n\n // Root has no own self-uri at the 2a level. If the root is a bare `$ref` to a\n // lifted named schema (the common case when input itself has `.meta({ id })`),\n // we'll have already rewritten it to '#/components/schemas/<id>'.\n rewriteRefs(root, undefined);\n\n for (const [id, body] of refs) {\n rewriteRefs(body, `${COMPONENTS_SCHEMAS_PREFIX}${id}`);\n }\n\n return { schema: root, refs };\n};\n","import { z } from 'zod';\n\nimport type { SchemaObject } from './openapi.types.js';\nimport type { Override } from './override.js';\nimport type { ZodNestRegistry } from './registry.js';\n\nimport { ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION } from './constants.js';\nimport { ZodNestUnrepresentableError } from './errors.js';\nimport { builtInOverride, combine, isStrictlyUnrepresentable } from './override.js';\nimport { postProcess } from './post-process.js';\n\nexport interface ToOpenApiOptions {\n io: 'input' | 'output';\n registry: ZodNestRegistry;\n override?: Override;\n strict?: boolean;\n}\n\nexport interface ToOpenApiResult {\n schema: SchemaObject;\n refs: Map<string, SchemaObject>;\n}\n\ninterface UnrepresentableHit {\n path: (string | number)[];\n zodType: string;\n}\n\nexport const toOpenApi = (schema: z.ZodType, opts: ToOpenApiOptions): ToOpenApiResult => {\n const strict = opts.strict ?? true;\n const merged = combine(builtInOverride, opts.override);\n const unrepresentableHits: UnrepresentableHit[] = [];\n\n const wrapped: Override = (ctx) => {\n merged(ctx);\n if (!strict || !isStrictlyUnrepresentable(ctx.jsonSchema, ctx.zodSchema)) {\n return;\n }\n unrepresentableHits.push({\n path: [...ctx.path],\n zodType: ctx.zodSchema._zod.def.type,\n });\n };\n\n const raw = z.toJSONSchema(schema, {\n target: 'draft-2020-12',\n io: opts.io,\n unrepresentable: 'any',\n metadata: opts.registry.zodRegistry,\n override: wrapped,\n cycles: 'ref',\n reused: 'inline',\n });\n\n const firstHit = unrepresentableHits[0];\n if (firstHit !== undefined) {\n throw new ZodNestUnrepresentableError(firstHit.path, firstHit.zodType);\n }\n\n const result = postProcess(raw);\n\n for (const [id] of opts.registry.getCollisions()) {\n if (!result.refs.has(id)) {\n continue;\n }\n result.refs.set(id, {\n description: `ERROR: duplicate zod-nest id <${id}>`,\n [ZOD_NEST_ERROR_EXTENSION]: ZOD_NEST_ERROR_DUPLICATE_ID,\n });\n }\n\n return result;\n};\n","import { z } from 'zod';\n\nexport interface ZodNestRegistry {\n readonly zodRegistry: typeof z.globalRegistry;\n register(schema: z.ZodType, id: string): void;\n hasCollision(id: string): boolean;\n getCollisions(): ReadonlyMap<string, ReadonlySet<z.ZodType>>;\n}\n\nexport const createRegistry = (): ZodNestRegistry => {\n const seen = new Map<string, Set<z.ZodType>>();\n\n return {\n zodRegistry: z.globalRegistry,\n register: (schema, id) => {\n z.globalRegistry.add(schema, { id });\n let set = seen.get(id);\n if (set === undefined) {\n set = new Set<z.ZodType>();\n seen.set(id, set);\n }\n set.add(schema);\n },\n hasCollision: (id) => {\n const set = seen.get(id);\n return set !== undefined && set.size > 1;\n },\n getCollisions: () => {\n const out = new Map<string, Set<z.ZodType>>();\n for (const [id, set] of seen) {\n if (set.size <= 1) {\n continue;\n }\n out.set(id, set);\n }\n return out;\n },\n };\n};\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,196 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
|
|
3
|
+
// src/schema/constants.ts
|
|
4
|
+
var COMPONENTS_SCHEMAS_PREFIX = "#/components/schemas/";
|
|
5
|
+
var ZOD_NEST_ERROR_EXTENSION = "x-zod-nest-error";
|
|
6
|
+
var ZOD_NEST_ERROR_DUPLICATE_ID = "duplicate-id";
|
|
7
|
+
|
|
8
|
+
// src/schema/errors.ts
|
|
9
|
+
var ZodNestError = class extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "ZodNestError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var ZodNestUnrepresentableError = class extends ZodNestError {
|
|
16
|
+
path;
|
|
17
|
+
zodType;
|
|
18
|
+
constructor(path, zodType) {
|
|
19
|
+
super(
|
|
20
|
+
`Unrepresentable Zod schema \`${zodType}\` at ${formatPath(path)}: no override produced a JSON Schema body. Set strict: false to emit \`{}\` instead, or supply an \`override\` that handles this Zod type.`
|
|
21
|
+
);
|
|
22
|
+
this.name = "ZodNestUnrepresentableError";
|
|
23
|
+
this.path = path;
|
|
24
|
+
this.zodType = zodType;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var formatPath = (path) => {
|
|
28
|
+
if (path.length === 0) {
|
|
29
|
+
return "<root>";
|
|
30
|
+
}
|
|
31
|
+
return "/" + path.map(String).join("/");
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/schema/override.ts
|
|
35
|
+
var builtInOverride = ({ zodSchema, jsonSchema }) => {
|
|
36
|
+
const type = zodSchema._zod.def.type;
|
|
37
|
+
if (type === "bigint") {
|
|
38
|
+
jsonSchema.type = "integer";
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (type === "date") {
|
|
42
|
+
jsonSchema.type = "string";
|
|
43
|
+
jsonSchema.format = "date-time";
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var STRICT_REQUIRES_OVERRIDE = /* @__PURE__ */ new Set([
|
|
48
|
+
"bigint",
|
|
49
|
+
"date",
|
|
50
|
+
"symbol",
|
|
51
|
+
"undefined",
|
|
52
|
+
"void",
|
|
53
|
+
"map",
|
|
54
|
+
"set",
|
|
55
|
+
"transform",
|
|
56
|
+
"nan",
|
|
57
|
+
"custom"
|
|
58
|
+
]);
|
|
59
|
+
var isStrictlyUnrepresentable = (jsonSchema, zodSchema) => {
|
|
60
|
+
if (!STRICT_REQUIRES_OVERRIDE.has(zodSchema._zod.def.type)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return Object.keys(jsonSchema).length === 0;
|
|
64
|
+
};
|
|
65
|
+
var combine = (...overrides) => {
|
|
66
|
+
const list = [];
|
|
67
|
+
for (const candidate of overrides) {
|
|
68
|
+
if (typeof candidate !== "function") {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
list.push(candidate);
|
|
72
|
+
}
|
|
73
|
+
if (list.length === 0) {
|
|
74
|
+
return () => void 0;
|
|
75
|
+
}
|
|
76
|
+
return (ctx) => {
|
|
77
|
+
for (const o of list) {
|
|
78
|
+
o(ctx);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// src/schema/post-process.ts
|
|
84
|
+
var DEFS_PREFIX = "#/$defs/";
|
|
85
|
+
var rewriteRefs = (node, selfRef) => {
|
|
86
|
+
if (Array.isArray(node)) {
|
|
87
|
+
for (const item of node) {
|
|
88
|
+
rewriteRefs(item, selfRef);
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (node === null || typeof node !== "object") {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const obj = node;
|
|
96
|
+
const ref = obj.$ref;
|
|
97
|
+
if (typeof ref === "string" && ref.startsWith(DEFS_PREFIX)) {
|
|
98
|
+
obj.$ref = COMPONENTS_SCHEMAS_PREFIX + ref.slice(DEFS_PREFIX.length);
|
|
99
|
+
} else if (ref === "#" && selfRef !== void 0) {
|
|
100
|
+
obj.$ref = selfRef;
|
|
101
|
+
}
|
|
102
|
+
for (const value of Object.values(obj)) {
|
|
103
|
+
rewriteRefs(value, selfRef);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var postProcess = (raw) => {
|
|
107
|
+
const refs = /* @__PURE__ */ new Map();
|
|
108
|
+
const rawDefs = raw.$defs;
|
|
109
|
+
if (rawDefs !== void 0) {
|
|
110
|
+
for (const [id, body] of Object.entries(rawDefs)) {
|
|
111
|
+
refs.set(id, body);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const root = { ...raw };
|
|
115
|
+
delete root.$schema;
|
|
116
|
+
delete root.$defs;
|
|
117
|
+
rewriteRefs(root, void 0);
|
|
118
|
+
for (const [id, body] of refs) {
|
|
119
|
+
rewriteRefs(body, `${COMPONENTS_SCHEMAS_PREFIX}${id}`);
|
|
120
|
+
}
|
|
121
|
+
return { schema: root, refs };
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/schema/engine.ts
|
|
125
|
+
var toOpenApi = (schema, opts) => {
|
|
126
|
+
const strict = opts.strict ?? true;
|
|
127
|
+
const merged = combine(builtInOverride, opts.override);
|
|
128
|
+
const unrepresentableHits = [];
|
|
129
|
+
const wrapped = (ctx) => {
|
|
130
|
+
merged(ctx);
|
|
131
|
+
if (!strict || !isStrictlyUnrepresentable(ctx.jsonSchema, ctx.zodSchema)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
unrepresentableHits.push({
|
|
135
|
+
path: [...ctx.path],
|
|
136
|
+
zodType: ctx.zodSchema._zod.def.type
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const raw = z.toJSONSchema(schema, {
|
|
140
|
+
target: "draft-2020-12",
|
|
141
|
+
io: opts.io,
|
|
142
|
+
unrepresentable: "any",
|
|
143
|
+
metadata: opts.registry.zodRegistry,
|
|
144
|
+
override: wrapped,
|
|
145
|
+
cycles: "ref",
|
|
146
|
+
reused: "inline"
|
|
147
|
+
});
|
|
148
|
+
const firstHit = unrepresentableHits[0];
|
|
149
|
+
if (firstHit !== void 0) {
|
|
150
|
+
throw new ZodNestUnrepresentableError(firstHit.path, firstHit.zodType);
|
|
151
|
+
}
|
|
152
|
+
const result = postProcess(raw);
|
|
153
|
+
for (const [id] of opts.registry.getCollisions()) {
|
|
154
|
+
if (!result.refs.has(id)) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
result.refs.set(id, {
|
|
158
|
+
description: `ERROR: duplicate zod-nest id <${id}>`,
|
|
159
|
+
[ZOD_NEST_ERROR_EXTENSION]: ZOD_NEST_ERROR_DUPLICATE_ID
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
var createRegistry = () => {
|
|
165
|
+
const seen = /* @__PURE__ */ new Map();
|
|
166
|
+
return {
|
|
167
|
+
zodRegistry: z.globalRegistry,
|
|
168
|
+
register: (schema, id) => {
|
|
169
|
+
z.globalRegistry.add(schema, { id });
|
|
170
|
+
let set = seen.get(id);
|
|
171
|
+
if (set === void 0) {
|
|
172
|
+
set = /* @__PURE__ */ new Set();
|
|
173
|
+
seen.set(id, set);
|
|
174
|
+
}
|
|
175
|
+
set.add(schema);
|
|
176
|
+
},
|
|
177
|
+
hasCollision: (id) => {
|
|
178
|
+
const set = seen.get(id);
|
|
179
|
+
return set !== void 0 && set.size > 1;
|
|
180
|
+
},
|
|
181
|
+
getCollisions: () => {
|
|
182
|
+
const out = /* @__PURE__ */ new Map();
|
|
183
|
+
for (const [id, set] of seen) {
|
|
184
|
+
if (set.size <= 1) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
out.set(id, set);
|
|
188
|
+
}
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export { COMPONENTS_SCHEMAS_PREFIX, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION, ZodNestError, ZodNestUnrepresentableError, createRegistry, toOpenApi };
|
|
2
195
|
//# sourceMappingURL=index.mjs.map
|
|
3
196
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
1
|
+
{"version":3,"sources":["../src/schema/constants.ts","../src/schema/errors.ts","../src/schema/override.ts","../src/schema/post-process.ts","../src/schema/engine.ts","../src/schema/registry.ts"],"names":["z"],"mappings":";;;AACO,IAAM,yBAAA,GAA4B;AAGlC,IAAM,wBAAA,GAA2B;AAGjC,IAAM,2BAAA,GAA8B;;;ACPpC,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EACtC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EACd;AACF;AAEO,IAAM,2BAAA,GAAN,cAA0C,YAAA,CAAa;AAAA,EACnD,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A,MACjB;AACA,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["/** OpenAPI 3.1 `$ref` prefix for entries in `components.schemas`. */\nexport const COMPONENTS_SCHEMAS_PREFIX = '#/components/schemas/';\n\n/** OpenAPI extension key zod-nest uses to surface engine errors inside emitted schemas. */\nexport const ZOD_NEST_ERROR_EXTENSION = 'x-zod-nest-error';\n\n/** Value of `x-zod-nest-error` when a registry id is claimed by more than one schema. */\nexport const ZOD_NEST_ERROR_DUPLICATE_ID = 'duplicate-id';\n","export class ZodNestError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ZodNestError';\n }\n}\n\nexport class ZodNestUnrepresentableError extends ZodNestError {\n readonly path: ReadonlyArray<string | number>;\n readonly zodType: string;\n\n constructor(path: ReadonlyArray<string | number>, zodType: string) {\n super(\n `Unrepresentable Zod schema \\`${zodType}\\` at ${formatPath(path)}: no override produced ` +\n `a JSON Schema body. Set strict: false to emit \\`{}\\` instead, or supply an \\`override\\` ` +\n `that handles this Zod type.`,\n );\n this.name = 'ZodNestUnrepresentableError';\n this.path = path;\n this.zodType = zodType;\n }\n}\n\nconst formatPath = (path: ReadonlyArray<string | number>): string => {\n if (path.length === 0) {\n return '<root>';\n }\n return '/' + path.map(String).join('/');\n};\n","import type { $ZodTypes } from 'zod/v4/core';\nimport type { SchemaObject } from './openapi.types.js';\n\nexport interface OverrideContext {\n zodSchema: $ZodTypes;\n jsonSchema: SchemaObject;\n path: (string | number)[];\n}\n\nexport type Override = (ctx: OverrideContext) => void;\n\nexport const builtInOverride: Override = ({ zodSchema, jsonSchema }) => {\n const type = zodSchema._zod.def.type;\n if (type === 'bigint') {\n jsonSchema.type = 'integer';\n return;\n }\n if (type === 'date') {\n jsonSchema.type = 'string';\n jsonSchema.format = 'date-time';\n return;\n }\n};\n\nconst STRICT_REQUIRES_OVERRIDE: ReadonlySet<string> = new Set([\n 'bigint',\n 'date',\n 'symbol',\n 'undefined',\n 'void',\n 'map',\n 'set',\n 'transform',\n 'nan',\n 'custom',\n]);\n\nexport const isStrictlyUnrepresentable = (\n jsonSchema: SchemaObject,\n zodSchema: $ZodTypes,\n): boolean => {\n if (!STRICT_REQUIRES_OVERRIDE.has(zodSchema._zod.def.type)) {\n return false;\n }\n return Object.keys(jsonSchema).length === 0;\n};\n\nexport const combine = (...overrides: ReadonlyArray<Override | undefined>): Override => {\n const list: Override[] = [];\n for (const candidate of overrides) {\n if (typeof candidate !== 'function') {\n continue;\n }\n list.push(candidate);\n }\n if (list.length === 0) {\n return () => undefined;\n }\n return (ctx) => {\n for (const o of list) {\n o(ctx);\n }\n };\n};\n","import type { SchemaObject } from './openapi.types.js';\n\nimport { COMPONENTS_SCHEMAS_PREFIX } from './constants.js';\n\nexport interface PostProcessResult {\n schema: SchemaObject;\n refs: Map<string, SchemaObject>;\n}\n\nconst DEFS_PREFIX = '#/$defs/';\n\nconst rewriteRefs = (node: unknown, selfRef: string | undefined): void => {\n if (Array.isArray(node)) {\n for (const item of node) {\n rewriteRefs(item, selfRef);\n }\n return;\n }\n if (node === null || typeof node !== 'object') {\n return;\n }\n const obj = node as Record<string, unknown>;\n const ref = obj.$ref;\n if (typeof ref === 'string' && ref.startsWith(DEFS_PREFIX)) {\n obj.$ref = COMPONENTS_SCHEMAS_PREFIX + ref.slice(DEFS_PREFIX.length);\n } else if (ref === '#' && selfRef !== undefined) {\n // Zod emits '#' for cycle refs back to the document root. When we lift a\n // named schema into its own components.schemas entry, '#' should resolve\n // to that entry's own URI.\n obj.$ref = selfRef;\n }\n for (const value of Object.values(obj)) {\n rewriteRefs(value, selfRef);\n }\n};\n\nexport const postProcess = (raw: SchemaObject): PostProcessResult => {\n const refs = new Map<string, SchemaObject>();\n const rawDefs = raw.$defs;\n if (rawDefs !== undefined) {\n for (const [id, body] of Object.entries(rawDefs)) {\n refs.set(id, body);\n }\n }\n\n const root: SchemaObject = { ...raw };\n delete root.$schema;\n delete root.$defs;\n\n // Root has no own self-uri at the 2a level. If the root is a bare `$ref` to a\n // lifted named schema (the common case when input itself has `.meta({ id })`),\n // we'll have already rewritten it to '#/components/schemas/<id>'.\n rewriteRefs(root, undefined);\n\n for (const [id, body] of refs) {\n rewriteRefs(body, `${COMPONENTS_SCHEMAS_PREFIX}${id}`);\n }\n\n return { schema: root, refs };\n};\n","import { z } from 'zod';\n\nimport type { SchemaObject } from './openapi.types.js';\nimport type { Override } from './override.js';\nimport type { ZodNestRegistry } from './registry.js';\n\nimport { ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION } from './constants.js';\nimport { ZodNestUnrepresentableError } from './errors.js';\nimport { builtInOverride, combine, isStrictlyUnrepresentable } from './override.js';\nimport { postProcess } from './post-process.js';\n\nexport interface ToOpenApiOptions {\n io: 'input' | 'output';\n registry: ZodNestRegistry;\n override?: Override;\n strict?: boolean;\n}\n\nexport interface ToOpenApiResult {\n schema: SchemaObject;\n refs: Map<string, SchemaObject>;\n}\n\ninterface UnrepresentableHit {\n path: (string | number)[];\n zodType: string;\n}\n\nexport const toOpenApi = (schema: z.ZodType, opts: ToOpenApiOptions): ToOpenApiResult => {\n const strict = opts.strict ?? true;\n const merged = combine(builtInOverride, opts.override);\n const unrepresentableHits: UnrepresentableHit[] = [];\n\n const wrapped: Override = (ctx) => {\n merged(ctx);\n if (!strict || !isStrictlyUnrepresentable(ctx.jsonSchema, ctx.zodSchema)) {\n return;\n }\n unrepresentableHits.push({\n path: [...ctx.path],\n zodType: ctx.zodSchema._zod.def.type,\n });\n };\n\n const raw = z.toJSONSchema(schema, {\n target: 'draft-2020-12',\n io: opts.io,\n unrepresentable: 'any',\n metadata: opts.registry.zodRegistry,\n override: wrapped,\n cycles: 'ref',\n reused: 'inline',\n });\n\n const firstHit = unrepresentableHits[0];\n if (firstHit !== undefined) {\n throw new ZodNestUnrepresentableError(firstHit.path, firstHit.zodType);\n }\n\n const result = postProcess(raw);\n\n for (const [id] of opts.registry.getCollisions()) {\n if (!result.refs.has(id)) {\n continue;\n }\n result.refs.set(id, {\n description: `ERROR: duplicate zod-nest id <${id}>`,\n [ZOD_NEST_ERROR_EXTENSION]: ZOD_NEST_ERROR_DUPLICATE_ID,\n });\n }\n\n return result;\n};\n","import { z } from 'zod';\n\nexport interface ZodNestRegistry {\n readonly zodRegistry: typeof z.globalRegistry;\n register(schema: z.ZodType, id: string): void;\n hasCollision(id: string): boolean;\n getCollisions(): ReadonlyMap<string, ReadonlySet<z.ZodType>>;\n}\n\nexport const createRegistry = (): ZodNestRegistry => {\n const seen = new Map<string, Set<z.ZodType>>();\n\n return {\n zodRegistry: z.globalRegistry,\n register: (schema, id) => {\n z.globalRegistry.add(schema, { id });\n let set = seen.get(id);\n if (set === undefined) {\n set = new Set<z.ZodType>();\n seen.set(id, set);\n }\n set.add(schema);\n },\n hasCollision: (id) => {\n const set = seen.get(id);\n return set !== undefined && set.size > 1;\n },\n getCollisions: () => {\n const out = new Map<string, Set<z.ZodType>>();\n for (const [id, set] of seen) {\n if (set.size <= 1) {\n continue;\n }\n out.set(id, set);\n }\n return out;\n },\n };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Modern Zod v4-only NestJS + OpenAPI 3.1 integration. Successor to nestjs-zod.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rodrigo Azevedo",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typescript"
|
|
23
23
|
],
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
25
|
+
"node": ">=22"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"main": "./dist/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@nestjs/core": ">=10",
|
|
65
65
|
"@nestjs/swagger": ">=8",
|
|
66
66
|
"rxjs": ">=7",
|
|
67
|
-
"zod": ">=4.
|
|
67
|
+
"zod": ">=4.4.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
|
|
@@ -72,11 +72,12 @@
|
|
|
72
72
|
"@nestjs/core": "^11.0.0",
|
|
73
73
|
"@nestjs/swagger": "^11.0.0",
|
|
74
74
|
"@semantic-release/changelog": "^6.0.3",
|
|
75
|
+
"@semantic-release/exec": "^7.0.3",
|
|
75
76
|
"@semantic-release/git": "^10.0.1",
|
|
76
77
|
"@semantic-release/github": "^11.0.0",
|
|
77
78
|
"@semantic-release/npm": "^12.0.0",
|
|
78
79
|
"@types/jest": "^29.5.14",
|
|
79
|
-
"@types/node": "^
|
|
80
|
+
"@types/node": "^22.10.0",
|
|
80
81
|
"eslint": "^9.16.0",
|
|
81
82
|
"eslint-config-prettier": "^9.1.0",
|
|
82
83
|
"eslint-plugin-jest": "^28.10.0",
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
"tsup": "^8.3.5",
|
|
96
97
|
"typescript": "^5.7.2",
|
|
97
98
|
"typescript-eslint": "^8.18.0",
|
|
98
|
-
"zod": "^4.
|
|
99
|
+
"zod": "^4.4.0"
|
|
99
100
|
},
|
|
100
101
|
"lint-staged": {
|
|
101
102
|
"*.ts": [
|