zod-nest 3.0.1 → 3.0.2
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.js +30 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -41,6 +41,18 @@ var readId = /* @__PURE__ */ __name((schema) => {
|
|
|
41
41
|
const id = meta.id;
|
|
42
42
|
return typeof id === "string" ? id : void 0;
|
|
43
43
|
}, "readId");
|
|
44
|
+
var resolveLazyTarget = /* @__PURE__ */ __name((getter) => {
|
|
45
|
+
try {
|
|
46
|
+
return [
|
|
47
|
+
getter()
|
|
48
|
+
];
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error instanceof ReferenceError) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}, "resolveLazyTarget");
|
|
44
56
|
var collectChildren = /* @__PURE__ */ __name((schema) => {
|
|
45
57
|
const def = schema._zod.def;
|
|
46
58
|
if (def.type === "object") {
|
|
@@ -95,9 +107,7 @@ var collectChildren = /* @__PURE__ */ __name((schema) => {
|
|
|
95
107
|
];
|
|
96
108
|
}
|
|
97
109
|
if (def.type === "lazy") {
|
|
98
|
-
return
|
|
99
|
-
def.getter()
|
|
100
|
-
];
|
|
110
|
+
return resolveLazyTarget(() => def.getter());
|
|
101
111
|
}
|
|
102
112
|
if (INNER_TYPE_WRAPPERS.has(def.type)) {
|
|
103
113
|
return [
|
|
@@ -140,6 +150,7 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
140
150
|
const seen = /* @__PURE__ */ new Map();
|
|
141
151
|
const forceExposed = /* @__PURE__ */ new Set();
|
|
142
152
|
const anonymous = /* @__PURE__ */ new Set();
|
|
153
|
+
const pendingRoots = [];
|
|
143
154
|
const recordOnce = /* @__PURE__ */ __name((schema, id) => {
|
|
144
155
|
let set = seen.get(id);
|
|
145
156
|
if (set === void 0) {
|
|
@@ -152,6 +163,13 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
152
163
|
set.add(schema);
|
|
153
164
|
return true;
|
|
154
165
|
}, "recordOnce");
|
|
166
|
+
const flushPendingDiscovery = /* @__PURE__ */ __name(() => {
|
|
167
|
+
for (const root of pendingRoots.splice(0)) {
|
|
168
|
+
for (const [child, childId] of discoverDependents(root)) {
|
|
169
|
+
recordOnce(child, childId);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, "flushPendingDiscovery");
|
|
155
173
|
return {
|
|
156
174
|
zodRegistry: zod.z.globalRegistry,
|
|
157
175
|
register: /* @__PURE__ */ __name((schema, id, flags) => {
|
|
@@ -177,15 +195,15 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
177
195
|
if (!recordOnce(schema, id)) {
|
|
178
196
|
return;
|
|
179
197
|
}
|
|
180
|
-
|
|
181
|
-
recordOnce(child, childId);
|
|
182
|
-
}
|
|
198
|
+
pendingRoots.push(schema);
|
|
183
199
|
}, "register"),
|
|
184
200
|
hasCollision: /* @__PURE__ */ __name((id) => {
|
|
201
|
+
flushPendingDiscovery();
|
|
185
202
|
const set = seen.get(id);
|
|
186
203
|
return set !== void 0 && set.size > 1;
|
|
187
204
|
}, "hasCollision"),
|
|
188
205
|
getCollisions: /* @__PURE__ */ __name(() => {
|
|
206
|
+
flushPendingDiscovery();
|
|
189
207
|
const out = /* @__PURE__ */ new Map();
|
|
190
208
|
for (const [id, set] of seen) {
|
|
191
209
|
if (set.size <= 1) {
|
|
@@ -195,9 +213,12 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
195
213
|
}
|
|
196
214
|
return out;
|
|
197
215
|
}, "getCollisions"),
|
|
198
|
-
ids: /* @__PURE__ */ __name(() =>
|
|
199
|
-
|
|
200
|
-
|
|
216
|
+
ids: /* @__PURE__ */ __name(() => {
|
|
217
|
+
flushPendingDiscovery();
|
|
218
|
+
return [
|
|
219
|
+
...seen.keys()
|
|
220
|
+
];
|
|
221
|
+
}, "ids"),
|
|
201
222
|
forceExposedIds: /* @__PURE__ */ __name(() => [
|
|
202
223
|
...forceExposed
|
|
203
224
|
], "forceExposedIds"),
|