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.mjs
CHANGED
|
@@ -35,6 +35,18 @@ var readId = /* @__PURE__ */ __name((schema) => {
|
|
|
35
35
|
const id = meta.id;
|
|
36
36
|
return typeof id === "string" ? id : void 0;
|
|
37
37
|
}, "readId");
|
|
38
|
+
var resolveLazyTarget = /* @__PURE__ */ __name((getter) => {
|
|
39
|
+
try {
|
|
40
|
+
return [
|
|
41
|
+
getter()
|
|
42
|
+
];
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error instanceof ReferenceError) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}, "resolveLazyTarget");
|
|
38
50
|
var collectChildren = /* @__PURE__ */ __name((schema) => {
|
|
39
51
|
const def = schema._zod.def;
|
|
40
52
|
if (def.type === "object") {
|
|
@@ -89,9 +101,7 @@ var collectChildren = /* @__PURE__ */ __name((schema) => {
|
|
|
89
101
|
];
|
|
90
102
|
}
|
|
91
103
|
if (def.type === "lazy") {
|
|
92
|
-
return
|
|
93
|
-
def.getter()
|
|
94
|
-
];
|
|
104
|
+
return resolveLazyTarget(() => def.getter());
|
|
95
105
|
}
|
|
96
106
|
if (INNER_TYPE_WRAPPERS.has(def.type)) {
|
|
97
107
|
return [
|
|
@@ -134,6 +144,7 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
134
144
|
const seen = /* @__PURE__ */ new Map();
|
|
135
145
|
const forceExposed = /* @__PURE__ */ new Set();
|
|
136
146
|
const anonymous = /* @__PURE__ */ new Set();
|
|
147
|
+
const pendingRoots = [];
|
|
137
148
|
const recordOnce = /* @__PURE__ */ __name((schema, id) => {
|
|
138
149
|
let set = seen.get(id);
|
|
139
150
|
if (set === void 0) {
|
|
@@ -146,6 +157,13 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
146
157
|
set.add(schema);
|
|
147
158
|
return true;
|
|
148
159
|
}, "recordOnce");
|
|
160
|
+
const flushPendingDiscovery = /* @__PURE__ */ __name(() => {
|
|
161
|
+
for (const root of pendingRoots.splice(0)) {
|
|
162
|
+
for (const [child, childId] of discoverDependents(root)) {
|
|
163
|
+
recordOnce(child, childId);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, "flushPendingDiscovery");
|
|
149
167
|
return {
|
|
150
168
|
zodRegistry: z.globalRegistry,
|
|
151
169
|
register: /* @__PURE__ */ __name((schema, id, flags) => {
|
|
@@ -171,15 +189,15 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
171
189
|
if (!recordOnce(schema, id)) {
|
|
172
190
|
return;
|
|
173
191
|
}
|
|
174
|
-
|
|
175
|
-
recordOnce(child, childId);
|
|
176
|
-
}
|
|
192
|
+
pendingRoots.push(schema);
|
|
177
193
|
}, "register"),
|
|
178
194
|
hasCollision: /* @__PURE__ */ __name((id) => {
|
|
195
|
+
flushPendingDiscovery();
|
|
179
196
|
const set = seen.get(id);
|
|
180
197
|
return set !== void 0 && set.size > 1;
|
|
181
198
|
}, "hasCollision"),
|
|
182
199
|
getCollisions: /* @__PURE__ */ __name(() => {
|
|
200
|
+
flushPendingDiscovery();
|
|
183
201
|
const out = /* @__PURE__ */ new Map();
|
|
184
202
|
for (const [id, set] of seen) {
|
|
185
203
|
if (set.size <= 1) {
|
|
@@ -189,9 +207,12 @@ var createRegistry = /* @__PURE__ */ __name(() => {
|
|
|
189
207
|
}
|
|
190
208
|
return out;
|
|
191
209
|
}, "getCollisions"),
|
|
192
|
-
ids: /* @__PURE__ */ __name(() =>
|
|
193
|
-
|
|
194
|
-
|
|
210
|
+
ids: /* @__PURE__ */ __name(() => {
|
|
211
|
+
flushPendingDiscovery();
|
|
212
|
+
return [
|
|
213
|
+
...seen.keys()
|
|
214
|
+
];
|
|
215
|
+
}, "ids"),
|
|
195
216
|
forceExposedIds: /* @__PURE__ */ __name(() => [
|
|
196
217
|
...forceExposed
|
|
197
218
|
], "forceExposedIds"),
|