zod-nest 3.0.0 → 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/README.md +2 -11
- package/dist/index.js +56 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -20
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"),
|
|
@@ -1057,13 +1078,22 @@ var normalizeZodNestOptions = /* @__PURE__ */ __name((opts) => {
|
|
|
1057
1078
|
// src/pipes/validation.pipe.ts
|
|
1058
1079
|
function _ts_decorate(decorators, target, key, desc) {
|
|
1059
1080
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1060
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1061
|
-
|
|
1081
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1082
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1083
|
+
} else {
|
|
1084
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1085
|
+
if (d = decorators[i]) {
|
|
1086
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1062
1090
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1063
1091
|
}
|
|
1064
1092
|
__name(_ts_decorate, "_ts_decorate");
|
|
1065
|
-
function _ts_metadata(
|
|
1066
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1093
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1094
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1095
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1096
|
+
}
|
|
1067
1097
|
}
|
|
1068
1098
|
__name(_ts_metadata, "_ts_metadata");
|
|
1069
1099
|
function _ts_param(paramIndex, decorator) {
|
|
@@ -1722,13 +1752,22 @@ var ZodCookies = /* @__PURE__ */ __name((schema, options) => {
|
|
|
1722
1752
|
}, "ZodCookies");
|
|
1723
1753
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
1724
1754
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1725
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1726
|
-
|
|
1755
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1756
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1757
|
+
} else {
|
|
1758
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1759
|
+
if (d = decorators[i]) {
|
|
1760
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1727
1764
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1728
1765
|
}
|
|
1729
1766
|
__name(_ts_decorate2, "_ts_decorate");
|
|
1730
|
-
function _ts_metadata2(
|
|
1731
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1767
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
1768
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1769
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1770
|
+
}
|
|
1732
1771
|
}
|
|
1733
1772
|
__name(_ts_metadata2, "_ts_metadata");
|
|
1734
1773
|
function _ts_param2(paramIndex, decorator) {
|