dune-react 0.0.32 → 0.0.34
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/components/puck-block/footer-sections/centered-minimal-footer/index.d.ts +11 -0
- package/dist/components/puck-block/footer-sections/centered-minimal-footer/index.js +1 -0
- package/dist/components/puck-block/footer-sections/compact-newsletter-footer/index.d.ts +11 -0
- package/dist/components/puck-block/footer-sections/contact-links-footer/index.d.ts +11 -0
- package/dist/components/puck-block/footer-sections/contact-links-footer/index.js +1 -1
- package/dist/components/puck-block/footer-sections/cta-links-footer/index.d.ts +11 -0
- package/dist/components/puck-block/footer-sections/cta-links-footer/index.js +1 -1
- package/dist/components/puck-block/footer-sections/links-newsletter-footer/index.d.ts +11 -0
- package/dist/components/puck-block/footer-sections/newsletter-links-footer/index.d.ts +11 -0
- package/dist/components/puck-block/footer-sections/newsletter-top-links-footer/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/centered-navbar/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/centered-navbar/index.js +1 -0
- package/dist/components/puck-block/header-sections/drawer-navbar/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/drawer-navbar/index.js +1 -1
- package/dist/components/puck-block/header-sections/floating-bordered-navbar/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/floating-bordered-navbar/index.js +1 -1
- package/dist/components/puck-block/header-sections/fullscreen-overlay-navbar/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/fullscreen-overlay-navbar/index.js +1 -1
- package/dist/components/puck-block/header-sections/mega-menu-navbar/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/mega-menu-navbar/index.js +1 -1
- package/dist/components/puck-block/header-sections/standard-navbar/index.d.ts +11 -0
- package/dist/components/puck-block/header-sections/standard-navbar/index.js +1 -0
- package/dist/components/puck-block/hero-sections/tab-hero/component.js +1 -0
- package/dist/components/puck-block/hero-sections/tab-hero/index.d.ts +3 -6
- package/dist/components/puck-block/hero-sections/tab-hero/index.js +2 -7
- package/dist/components/puck-block/pricing-sections/pricing-comparison-table/component.js +13 -0
- package/dist/components/puck-block/pricing-sections/split-pricing/component.js +2 -1
- package/dist/components/puck-block/registry.generated.d.ts +102 -6
- package/dist/components/puck-core/core/props/index.js +0 -7
- package/dist/components/puck-core/core/puck-fields-to-zod.d.ts +40 -0
- package/dist/components/puck-core/core/puck-fields-to-zod.js +113 -0
- package/dist/components/puck-core/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/iso.js +43 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/parse.js +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/schemas.js +665 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js +569 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js +410 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js +74 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js +37 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js +72 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js +314 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js +95 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/regexes.js +81 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js +51 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js +1345 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js +362 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js +430 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js +8 -0
- package/package.json +11 -6
|
@@ -0,0 +1,1345 @@
|
|
|
1
|
+
import { $ZodCheckStringFormat, $ZodCheckNumberFormat, $ZodCheck } from "./checks.js";
|
|
2
|
+
import { $constructor, globalConfig, $ZodAsyncError, $ZodEncodeError, config } from "./core.js";
|
|
3
|
+
import { Doc } from "./doc.js";
|
|
4
|
+
import { safeParse, safeParseAsync } from "./parse.js";
|
|
5
|
+
import { number, string, datetime, date, time, duration, email, guid, uuid, emoji, nanoid, cuid, cuid2, ulid, xid, ksuid, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, e164 } from "./regexes.js";
|
|
6
|
+
import { allowsEval, cached, esc, isObject, isPlainObject, prefixIssues, finalizeIssue, getEnumValues, propertyKeyTypes, escapeRegex, defineLazy, cleanRegex, aborted, optionalKeys, issue } from "./util.js";
|
|
7
|
+
import { clone } from "./util.js";
|
|
8
|
+
import { version } from "./versions.js";
|
|
9
|
+
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
10
|
+
var _a2;
|
|
11
|
+
var _a;
|
|
12
|
+
inst ?? (inst = {});
|
|
13
|
+
inst._zod.def = def;
|
|
14
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
15
|
+
inst._zod.version = version;
|
|
16
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
17
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
18
|
+
checks.unshift(inst);
|
|
19
|
+
}
|
|
20
|
+
for (const ch of checks) {
|
|
21
|
+
for (const fn of ch._zod.onattach) {
|
|
22
|
+
fn(inst);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (checks.length === 0) {
|
|
26
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
27
|
+
(_a2 = inst._zod.deferred) == null ? void 0 : _a2.push(() => {
|
|
28
|
+
inst._zod.run = inst._zod.parse;
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
const runChecks = (payload, checks2, ctx) => {
|
|
32
|
+
let isAborted = aborted(payload);
|
|
33
|
+
let asyncResult;
|
|
34
|
+
for (const ch of checks2) {
|
|
35
|
+
if (ch._zod.def.when) {
|
|
36
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
37
|
+
if (!shouldRun)
|
|
38
|
+
continue;
|
|
39
|
+
} else if (isAborted) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const currLen = payload.issues.length;
|
|
43
|
+
const _ = ch._zod.check(payload);
|
|
44
|
+
if (_ instanceof Promise && (ctx == null ? void 0 : ctx.async) === false) {
|
|
45
|
+
throw new $ZodAsyncError();
|
|
46
|
+
}
|
|
47
|
+
if (asyncResult || _ instanceof Promise) {
|
|
48
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
49
|
+
await _;
|
|
50
|
+
const nextLen = payload.issues.length;
|
|
51
|
+
if (nextLen === currLen)
|
|
52
|
+
return;
|
|
53
|
+
if (!isAborted)
|
|
54
|
+
isAborted = aborted(payload, currLen);
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
const nextLen = payload.issues.length;
|
|
58
|
+
if (nextLen === currLen)
|
|
59
|
+
continue;
|
|
60
|
+
if (!isAborted)
|
|
61
|
+
isAborted = aborted(payload, currLen);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (asyncResult) {
|
|
65
|
+
return asyncResult.then(() => {
|
|
66
|
+
return payload;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return payload;
|
|
70
|
+
};
|
|
71
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
72
|
+
if (aborted(canary)) {
|
|
73
|
+
canary.aborted = true;
|
|
74
|
+
return canary;
|
|
75
|
+
}
|
|
76
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
77
|
+
if (checkResult instanceof Promise) {
|
|
78
|
+
if (ctx.async === false)
|
|
79
|
+
throw new $ZodAsyncError();
|
|
80
|
+
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
|
|
81
|
+
}
|
|
82
|
+
return inst._zod.parse(checkResult, ctx);
|
|
83
|
+
};
|
|
84
|
+
inst._zod.run = (payload, ctx) => {
|
|
85
|
+
if (ctx.skipChecks) {
|
|
86
|
+
return inst._zod.parse(payload, ctx);
|
|
87
|
+
}
|
|
88
|
+
if (ctx.direction === "backward") {
|
|
89
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
90
|
+
if (canary instanceof Promise) {
|
|
91
|
+
return canary.then((canary2) => {
|
|
92
|
+
return handleCanaryResult(canary2, payload, ctx);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
96
|
+
}
|
|
97
|
+
const result = inst._zod.parse(payload, ctx);
|
|
98
|
+
if (result instanceof Promise) {
|
|
99
|
+
if (ctx.async === false)
|
|
100
|
+
throw new $ZodAsyncError();
|
|
101
|
+
return result.then((result2) => runChecks(result2, checks, ctx));
|
|
102
|
+
}
|
|
103
|
+
return runChecks(result, checks, ctx);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
defineLazy(inst, "~standard", () => ({
|
|
107
|
+
validate: (value) => {
|
|
108
|
+
var _a3;
|
|
109
|
+
try {
|
|
110
|
+
const r = safeParse(inst, value);
|
|
111
|
+
return r.success ? { value: r.data } : { issues: (_a3 = r.error) == null ? void 0 : _a3.issues };
|
|
112
|
+
} catch (_) {
|
|
113
|
+
return safeParseAsync(inst, value).then((r) => {
|
|
114
|
+
var _a4;
|
|
115
|
+
return r.success ? { value: r.data } : { issues: (_a4 = r.error) == null ? void 0 : _a4.issues };
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
vendor: "zod",
|
|
120
|
+
version: 1
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
124
|
+
var _a;
|
|
125
|
+
$ZodType.init(inst, def);
|
|
126
|
+
inst._zod.pattern = [...((_a = inst == null ? void 0 : inst._zod.bag) == null ? void 0 : _a.patterns) ?? []].pop() ?? string(inst._zod.bag);
|
|
127
|
+
inst._zod.parse = (payload, _) => {
|
|
128
|
+
if (def.coerce)
|
|
129
|
+
try {
|
|
130
|
+
payload.value = String(payload.value);
|
|
131
|
+
} catch (_2) {
|
|
132
|
+
}
|
|
133
|
+
if (typeof payload.value === "string")
|
|
134
|
+
return payload;
|
|
135
|
+
payload.issues.push({
|
|
136
|
+
expected: "string",
|
|
137
|
+
code: "invalid_type",
|
|
138
|
+
input: payload.value,
|
|
139
|
+
inst
|
|
140
|
+
});
|
|
141
|
+
return payload;
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
145
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
146
|
+
$ZodString.init(inst, def);
|
|
147
|
+
});
|
|
148
|
+
const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
149
|
+
def.pattern ?? (def.pattern = guid);
|
|
150
|
+
$ZodStringFormat.init(inst, def);
|
|
151
|
+
});
|
|
152
|
+
const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
153
|
+
if (def.version) {
|
|
154
|
+
const versionMap = {
|
|
155
|
+
v1: 1,
|
|
156
|
+
v2: 2,
|
|
157
|
+
v3: 3,
|
|
158
|
+
v4: 4,
|
|
159
|
+
v5: 5,
|
|
160
|
+
v6: 6,
|
|
161
|
+
v7: 7,
|
|
162
|
+
v8: 8
|
|
163
|
+
};
|
|
164
|
+
const v = versionMap[def.version];
|
|
165
|
+
if (v === void 0)
|
|
166
|
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
167
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
168
|
+
} else
|
|
169
|
+
def.pattern ?? (def.pattern = uuid());
|
|
170
|
+
$ZodStringFormat.init(inst, def);
|
|
171
|
+
});
|
|
172
|
+
const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
173
|
+
def.pattern ?? (def.pattern = email);
|
|
174
|
+
$ZodStringFormat.init(inst, def);
|
|
175
|
+
});
|
|
176
|
+
const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
177
|
+
$ZodStringFormat.init(inst, def);
|
|
178
|
+
inst._zod.check = (payload) => {
|
|
179
|
+
try {
|
|
180
|
+
const trimmed = payload.value.trim();
|
|
181
|
+
const url = new URL(trimmed);
|
|
182
|
+
if (def.hostname) {
|
|
183
|
+
def.hostname.lastIndex = 0;
|
|
184
|
+
if (!def.hostname.test(url.hostname)) {
|
|
185
|
+
payload.issues.push({
|
|
186
|
+
code: "invalid_format",
|
|
187
|
+
format: "url",
|
|
188
|
+
note: "Invalid hostname",
|
|
189
|
+
pattern: def.hostname.source,
|
|
190
|
+
input: payload.value,
|
|
191
|
+
inst,
|
|
192
|
+
continue: !def.abort
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (def.protocol) {
|
|
197
|
+
def.protocol.lastIndex = 0;
|
|
198
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
|
199
|
+
payload.issues.push({
|
|
200
|
+
code: "invalid_format",
|
|
201
|
+
format: "url",
|
|
202
|
+
note: "Invalid protocol",
|
|
203
|
+
pattern: def.protocol.source,
|
|
204
|
+
input: payload.value,
|
|
205
|
+
inst,
|
|
206
|
+
continue: !def.abort
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (def.normalize) {
|
|
211
|
+
payload.value = url.href;
|
|
212
|
+
} else {
|
|
213
|
+
payload.value = trimmed;
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
} catch (_) {
|
|
217
|
+
payload.issues.push({
|
|
218
|
+
code: "invalid_format",
|
|
219
|
+
format: "url",
|
|
220
|
+
input: payload.value,
|
|
221
|
+
inst,
|
|
222
|
+
continue: !def.abort
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
228
|
+
def.pattern ?? (def.pattern = emoji());
|
|
229
|
+
$ZodStringFormat.init(inst, def);
|
|
230
|
+
});
|
|
231
|
+
const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
232
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
233
|
+
$ZodStringFormat.init(inst, def);
|
|
234
|
+
});
|
|
235
|
+
const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
236
|
+
def.pattern ?? (def.pattern = cuid);
|
|
237
|
+
$ZodStringFormat.init(inst, def);
|
|
238
|
+
});
|
|
239
|
+
const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
240
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
241
|
+
$ZodStringFormat.init(inst, def);
|
|
242
|
+
});
|
|
243
|
+
const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
244
|
+
def.pattern ?? (def.pattern = ulid);
|
|
245
|
+
$ZodStringFormat.init(inst, def);
|
|
246
|
+
});
|
|
247
|
+
const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
248
|
+
def.pattern ?? (def.pattern = xid);
|
|
249
|
+
$ZodStringFormat.init(inst, def);
|
|
250
|
+
});
|
|
251
|
+
const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
252
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
253
|
+
$ZodStringFormat.init(inst, def);
|
|
254
|
+
});
|
|
255
|
+
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
256
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
257
|
+
$ZodStringFormat.init(inst, def);
|
|
258
|
+
});
|
|
259
|
+
const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
260
|
+
def.pattern ?? (def.pattern = date);
|
|
261
|
+
$ZodStringFormat.init(inst, def);
|
|
262
|
+
});
|
|
263
|
+
const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
264
|
+
def.pattern ?? (def.pattern = time(def));
|
|
265
|
+
$ZodStringFormat.init(inst, def);
|
|
266
|
+
});
|
|
267
|
+
const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
268
|
+
def.pattern ?? (def.pattern = duration);
|
|
269
|
+
$ZodStringFormat.init(inst, def);
|
|
270
|
+
});
|
|
271
|
+
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
272
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
273
|
+
$ZodStringFormat.init(inst, def);
|
|
274
|
+
inst._zod.bag.format = `ipv4`;
|
|
275
|
+
});
|
|
276
|
+
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
277
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
278
|
+
$ZodStringFormat.init(inst, def);
|
|
279
|
+
inst._zod.bag.format = `ipv6`;
|
|
280
|
+
inst._zod.check = (payload) => {
|
|
281
|
+
try {
|
|
282
|
+
new URL(`http://[${payload.value}]`);
|
|
283
|
+
} catch {
|
|
284
|
+
payload.issues.push({
|
|
285
|
+
code: "invalid_format",
|
|
286
|
+
format: "ipv6",
|
|
287
|
+
input: payload.value,
|
|
288
|
+
inst,
|
|
289
|
+
continue: !def.abort
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
});
|
|
294
|
+
const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
295
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
296
|
+
$ZodStringFormat.init(inst, def);
|
|
297
|
+
});
|
|
298
|
+
const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
299
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
300
|
+
$ZodStringFormat.init(inst, def);
|
|
301
|
+
inst._zod.check = (payload) => {
|
|
302
|
+
const parts = payload.value.split("/");
|
|
303
|
+
try {
|
|
304
|
+
if (parts.length !== 2)
|
|
305
|
+
throw new Error();
|
|
306
|
+
const [address, prefix] = parts;
|
|
307
|
+
if (!prefix)
|
|
308
|
+
throw new Error();
|
|
309
|
+
const prefixNum = Number(prefix);
|
|
310
|
+
if (`${prefixNum}` !== prefix)
|
|
311
|
+
throw new Error();
|
|
312
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
313
|
+
throw new Error();
|
|
314
|
+
new URL(`http://[${address}]`);
|
|
315
|
+
} catch {
|
|
316
|
+
payload.issues.push({
|
|
317
|
+
code: "invalid_format",
|
|
318
|
+
format: "cidrv6",
|
|
319
|
+
input: payload.value,
|
|
320
|
+
inst,
|
|
321
|
+
continue: !def.abort
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
function isValidBase64(data) {
|
|
327
|
+
if (data === "")
|
|
328
|
+
return true;
|
|
329
|
+
if (data.length % 4 !== 0)
|
|
330
|
+
return false;
|
|
331
|
+
try {
|
|
332
|
+
atob(data);
|
|
333
|
+
return true;
|
|
334
|
+
} catch {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
339
|
+
def.pattern ?? (def.pattern = base64);
|
|
340
|
+
$ZodStringFormat.init(inst, def);
|
|
341
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
342
|
+
inst._zod.check = (payload) => {
|
|
343
|
+
if (isValidBase64(payload.value))
|
|
344
|
+
return;
|
|
345
|
+
payload.issues.push({
|
|
346
|
+
code: "invalid_format",
|
|
347
|
+
format: "base64",
|
|
348
|
+
input: payload.value,
|
|
349
|
+
inst,
|
|
350
|
+
continue: !def.abort
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
});
|
|
354
|
+
function isValidBase64URL(data) {
|
|
355
|
+
if (!base64url.test(data))
|
|
356
|
+
return false;
|
|
357
|
+
const base642 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
358
|
+
const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
|
|
359
|
+
return isValidBase64(padded);
|
|
360
|
+
}
|
|
361
|
+
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
362
|
+
def.pattern ?? (def.pattern = base64url);
|
|
363
|
+
$ZodStringFormat.init(inst, def);
|
|
364
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
365
|
+
inst._zod.check = (payload) => {
|
|
366
|
+
if (isValidBase64URL(payload.value))
|
|
367
|
+
return;
|
|
368
|
+
payload.issues.push({
|
|
369
|
+
code: "invalid_format",
|
|
370
|
+
format: "base64url",
|
|
371
|
+
input: payload.value,
|
|
372
|
+
inst,
|
|
373
|
+
continue: !def.abort
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
378
|
+
def.pattern ?? (def.pattern = e164);
|
|
379
|
+
$ZodStringFormat.init(inst, def);
|
|
380
|
+
});
|
|
381
|
+
function isValidJWT(token, algorithm = null) {
|
|
382
|
+
try {
|
|
383
|
+
const tokensParts = token.split(".");
|
|
384
|
+
if (tokensParts.length !== 3)
|
|
385
|
+
return false;
|
|
386
|
+
const [header] = tokensParts;
|
|
387
|
+
if (!header)
|
|
388
|
+
return false;
|
|
389
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
390
|
+
if ("typ" in parsedHeader && (parsedHeader == null ? void 0 : parsedHeader.typ) !== "JWT")
|
|
391
|
+
return false;
|
|
392
|
+
if (!parsedHeader.alg)
|
|
393
|
+
return false;
|
|
394
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
|
395
|
+
return false;
|
|
396
|
+
return true;
|
|
397
|
+
} catch {
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
402
|
+
$ZodStringFormat.init(inst, def);
|
|
403
|
+
inst._zod.check = (payload) => {
|
|
404
|
+
if (isValidJWT(payload.value, def.alg))
|
|
405
|
+
return;
|
|
406
|
+
payload.issues.push({
|
|
407
|
+
code: "invalid_format",
|
|
408
|
+
format: "jwt",
|
|
409
|
+
input: payload.value,
|
|
410
|
+
inst,
|
|
411
|
+
continue: !def.abort
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
});
|
|
415
|
+
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
416
|
+
$ZodType.init(inst, def);
|
|
417
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number;
|
|
418
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
419
|
+
if (def.coerce)
|
|
420
|
+
try {
|
|
421
|
+
payload.value = Number(payload.value);
|
|
422
|
+
} catch (_) {
|
|
423
|
+
}
|
|
424
|
+
const input = payload.value;
|
|
425
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
426
|
+
return payload;
|
|
427
|
+
}
|
|
428
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
429
|
+
payload.issues.push({
|
|
430
|
+
expected: "number",
|
|
431
|
+
code: "invalid_type",
|
|
432
|
+
input,
|
|
433
|
+
inst,
|
|
434
|
+
...received ? { received } : {}
|
|
435
|
+
});
|
|
436
|
+
return payload;
|
|
437
|
+
};
|
|
438
|
+
});
|
|
439
|
+
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
440
|
+
$ZodCheckNumberFormat.init(inst, def);
|
|
441
|
+
$ZodNumber.init(inst, def);
|
|
442
|
+
});
|
|
443
|
+
const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
444
|
+
$ZodType.init(inst, def);
|
|
445
|
+
inst._zod.parse = (payload) => payload;
|
|
446
|
+
});
|
|
447
|
+
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
448
|
+
$ZodType.init(inst, def);
|
|
449
|
+
inst._zod.parse = (payload) => payload;
|
|
450
|
+
});
|
|
451
|
+
const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
452
|
+
$ZodType.init(inst, def);
|
|
453
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
454
|
+
payload.issues.push({
|
|
455
|
+
expected: "never",
|
|
456
|
+
code: "invalid_type",
|
|
457
|
+
input: payload.value,
|
|
458
|
+
inst
|
|
459
|
+
});
|
|
460
|
+
return payload;
|
|
461
|
+
};
|
|
462
|
+
});
|
|
463
|
+
function handleArrayResult(result, final, index) {
|
|
464
|
+
if (result.issues.length) {
|
|
465
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
466
|
+
}
|
|
467
|
+
final.value[index] = result.value;
|
|
468
|
+
}
|
|
469
|
+
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
470
|
+
$ZodType.init(inst, def);
|
|
471
|
+
inst._zod.parse = (payload, ctx) => {
|
|
472
|
+
const input = payload.value;
|
|
473
|
+
if (!Array.isArray(input)) {
|
|
474
|
+
payload.issues.push({
|
|
475
|
+
expected: "array",
|
|
476
|
+
code: "invalid_type",
|
|
477
|
+
input,
|
|
478
|
+
inst
|
|
479
|
+
});
|
|
480
|
+
return payload;
|
|
481
|
+
}
|
|
482
|
+
payload.value = Array(input.length);
|
|
483
|
+
const proms = [];
|
|
484
|
+
for (let i = 0; i < input.length; i++) {
|
|
485
|
+
const item = input[i];
|
|
486
|
+
const result = def.element._zod.run({
|
|
487
|
+
value: item,
|
|
488
|
+
issues: []
|
|
489
|
+
}, ctx);
|
|
490
|
+
if (result instanceof Promise) {
|
|
491
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
492
|
+
} else {
|
|
493
|
+
handleArrayResult(result, payload, i);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (proms.length) {
|
|
497
|
+
return Promise.all(proms).then(() => payload);
|
|
498
|
+
}
|
|
499
|
+
return payload;
|
|
500
|
+
};
|
|
501
|
+
});
|
|
502
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
503
|
+
if (result.issues.length) {
|
|
504
|
+
if (isOptionalOut && !(key in input)) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
508
|
+
}
|
|
509
|
+
if (result.value === void 0) {
|
|
510
|
+
if (key in input) {
|
|
511
|
+
final.value[key] = void 0;
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
final.value[key] = result.value;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function normalizeDef(def) {
|
|
518
|
+
var _a, _b, _c, _d;
|
|
519
|
+
const keys = Object.keys(def.shape);
|
|
520
|
+
for (const k of keys) {
|
|
521
|
+
if (!((_d = (_c = (_b = (_a = def.shape) == null ? void 0 : _a[k]) == null ? void 0 : _b._zod) == null ? void 0 : _c.traits) == null ? void 0 : _d.has("$ZodType"))) {
|
|
522
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
const okeys = optionalKeys(def.shape);
|
|
526
|
+
return {
|
|
527
|
+
...def,
|
|
528
|
+
keys,
|
|
529
|
+
keySet: new Set(keys),
|
|
530
|
+
numKeys: keys.length,
|
|
531
|
+
optionalKeys: new Set(okeys)
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
535
|
+
const unrecognized = [];
|
|
536
|
+
const keySet = def.keySet;
|
|
537
|
+
const _catchall = def.catchall._zod;
|
|
538
|
+
const t = _catchall.def.type;
|
|
539
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
540
|
+
for (const key in input) {
|
|
541
|
+
if (keySet.has(key))
|
|
542
|
+
continue;
|
|
543
|
+
if (t === "never") {
|
|
544
|
+
unrecognized.push(key);
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
548
|
+
if (r instanceof Promise) {
|
|
549
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
550
|
+
} else {
|
|
551
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (unrecognized.length) {
|
|
555
|
+
payload.issues.push({
|
|
556
|
+
code: "unrecognized_keys",
|
|
557
|
+
keys: unrecognized,
|
|
558
|
+
input,
|
|
559
|
+
inst
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
if (!proms.length)
|
|
563
|
+
return payload;
|
|
564
|
+
return Promise.all(proms).then(() => {
|
|
565
|
+
return payload;
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
569
|
+
$ZodType.init(inst, def);
|
|
570
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
571
|
+
if (!(desc == null ? void 0 : desc.get)) {
|
|
572
|
+
const sh = def.shape;
|
|
573
|
+
Object.defineProperty(def, "shape", {
|
|
574
|
+
get: () => {
|
|
575
|
+
const newSh = { ...sh };
|
|
576
|
+
Object.defineProperty(def, "shape", {
|
|
577
|
+
value: newSh
|
|
578
|
+
});
|
|
579
|
+
return newSh;
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
584
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
585
|
+
const shape = def.shape;
|
|
586
|
+
const propValues = {};
|
|
587
|
+
for (const key in shape) {
|
|
588
|
+
const field = shape[key]._zod;
|
|
589
|
+
if (field.values) {
|
|
590
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
591
|
+
for (const v of field.values)
|
|
592
|
+
propValues[key].add(v);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return propValues;
|
|
596
|
+
});
|
|
597
|
+
const isObject$1 = isObject;
|
|
598
|
+
const catchall = def.catchall;
|
|
599
|
+
let value;
|
|
600
|
+
inst._zod.parse = (payload, ctx) => {
|
|
601
|
+
value ?? (value = _normalized.value);
|
|
602
|
+
const input = payload.value;
|
|
603
|
+
if (!isObject$1(input)) {
|
|
604
|
+
payload.issues.push({
|
|
605
|
+
expected: "object",
|
|
606
|
+
code: "invalid_type",
|
|
607
|
+
input,
|
|
608
|
+
inst
|
|
609
|
+
});
|
|
610
|
+
return payload;
|
|
611
|
+
}
|
|
612
|
+
payload.value = {};
|
|
613
|
+
const proms = [];
|
|
614
|
+
const shape = value.shape;
|
|
615
|
+
for (const key of value.keys) {
|
|
616
|
+
const el = shape[key];
|
|
617
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
618
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
619
|
+
if (r instanceof Promise) {
|
|
620
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
621
|
+
} else {
|
|
622
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
if (!catchall) {
|
|
626
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
627
|
+
}
|
|
628
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
629
|
+
};
|
|
630
|
+
});
|
|
631
|
+
const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
632
|
+
$ZodObject.init(inst, def);
|
|
633
|
+
const superParse = inst._zod.parse;
|
|
634
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
635
|
+
const generateFastpass = (shape) => {
|
|
636
|
+
var _a;
|
|
637
|
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
638
|
+
const normalized = _normalized.value;
|
|
639
|
+
const parseStr = (key) => {
|
|
640
|
+
const k = esc(key);
|
|
641
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
642
|
+
};
|
|
643
|
+
doc.write(`const input = payload.value;`);
|
|
644
|
+
const ids = /* @__PURE__ */ Object.create(null);
|
|
645
|
+
let counter = 0;
|
|
646
|
+
for (const key of normalized.keys) {
|
|
647
|
+
ids[key] = `key_${counter++}`;
|
|
648
|
+
}
|
|
649
|
+
doc.write(`const newResult = {};`);
|
|
650
|
+
for (const key of normalized.keys) {
|
|
651
|
+
const id = ids[key];
|
|
652
|
+
const k = esc(key);
|
|
653
|
+
const schema = shape[key];
|
|
654
|
+
const isOptionalOut = ((_a = schema == null ? void 0 : schema._zod) == null ? void 0 : _a.optout) === "optional";
|
|
655
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
656
|
+
if (isOptionalOut) {
|
|
657
|
+
doc.write(`
|
|
658
|
+
if (${id}.issues.length) {
|
|
659
|
+
if (${k} in input) {
|
|
660
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
661
|
+
...iss,
|
|
662
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
663
|
+
})));
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (${id}.value === undefined) {
|
|
668
|
+
if (${k} in input) {
|
|
669
|
+
newResult[${k}] = undefined;
|
|
670
|
+
}
|
|
671
|
+
} else {
|
|
672
|
+
newResult[${k}] = ${id}.value;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
`);
|
|
676
|
+
} else {
|
|
677
|
+
doc.write(`
|
|
678
|
+
if (${id}.issues.length) {
|
|
679
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
680
|
+
...iss,
|
|
681
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
682
|
+
})));
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (${id}.value === undefined) {
|
|
686
|
+
if (${k} in input) {
|
|
687
|
+
newResult[${k}] = undefined;
|
|
688
|
+
}
|
|
689
|
+
} else {
|
|
690
|
+
newResult[${k}] = ${id}.value;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
`);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
doc.write(`payload.value = newResult;`);
|
|
697
|
+
doc.write(`return payload;`);
|
|
698
|
+
const fn = doc.compile();
|
|
699
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
700
|
+
};
|
|
701
|
+
let fastpass;
|
|
702
|
+
const isObject$1 = isObject;
|
|
703
|
+
const jit = !globalConfig.jitless;
|
|
704
|
+
const allowsEval$1 = allowsEval;
|
|
705
|
+
const fastEnabled = jit && allowsEval$1.value;
|
|
706
|
+
const catchall = def.catchall;
|
|
707
|
+
let value;
|
|
708
|
+
inst._zod.parse = (payload, ctx) => {
|
|
709
|
+
value ?? (value = _normalized.value);
|
|
710
|
+
const input = payload.value;
|
|
711
|
+
if (!isObject$1(input)) {
|
|
712
|
+
payload.issues.push({
|
|
713
|
+
expected: "object",
|
|
714
|
+
code: "invalid_type",
|
|
715
|
+
input,
|
|
716
|
+
inst
|
|
717
|
+
});
|
|
718
|
+
return payload;
|
|
719
|
+
}
|
|
720
|
+
if (jit && fastEnabled && (ctx == null ? void 0 : ctx.async) === false && ctx.jitless !== true) {
|
|
721
|
+
if (!fastpass)
|
|
722
|
+
fastpass = generateFastpass(def.shape);
|
|
723
|
+
payload = fastpass(payload, ctx);
|
|
724
|
+
if (!catchall)
|
|
725
|
+
return payload;
|
|
726
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
727
|
+
}
|
|
728
|
+
return superParse(payload, ctx);
|
|
729
|
+
};
|
|
730
|
+
});
|
|
731
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
732
|
+
for (const result of results) {
|
|
733
|
+
if (result.issues.length === 0) {
|
|
734
|
+
final.value = result.value;
|
|
735
|
+
return final;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
739
|
+
if (nonaborted.length === 1) {
|
|
740
|
+
final.value = nonaborted[0].value;
|
|
741
|
+
return nonaborted[0];
|
|
742
|
+
}
|
|
743
|
+
final.issues.push({
|
|
744
|
+
code: "invalid_union",
|
|
745
|
+
input: final.value,
|
|
746
|
+
inst,
|
|
747
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
748
|
+
});
|
|
749
|
+
return final;
|
|
750
|
+
}
|
|
751
|
+
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
752
|
+
$ZodType.init(inst, def);
|
|
753
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
754
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
755
|
+
defineLazy(inst._zod, "values", () => {
|
|
756
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
757
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
758
|
+
}
|
|
759
|
+
return void 0;
|
|
760
|
+
});
|
|
761
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
762
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
763
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
764
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
765
|
+
}
|
|
766
|
+
return void 0;
|
|
767
|
+
});
|
|
768
|
+
const single = def.options.length === 1;
|
|
769
|
+
const first = def.options[0]._zod.run;
|
|
770
|
+
inst._zod.parse = (payload, ctx) => {
|
|
771
|
+
if (single) {
|
|
772
|
+
return first(payload, ctx);
|
|
773
|
+
}
|
|
774
|
+
let async = false;
|
|
775
|
+
const results = [];
|
|
776
|
+
for (const option of def.options) {
|
|
777
|
+
const result = option._zod.run({
|
|
778
|
+
value: payload.value,
|
|
779
|
+
issues: []
|
|
780
|
+
}, ctx);
|
|
781
|
+
if (result instanceof Promise) {
|
|
782
|
+
results.push(result);
|
|
783
|
+
async = true;
|
|
784
|
+
} else {
|
|
785
|
+
if (result.issues.length === 0)
|
|
786
|
+
return result;
|
|
787
|
+
results.push(result);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (!async)
|
|
791
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
792
|
+
return Promise.all(results).then((results2) => {
|
|
793
|
+
return handleUnionResults(results2, payload, inst, ctx);
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
});
|
|
797
|
+
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
798
|
+
$ZodType.init(inst, def);
|
|
799
|
+
inst._zod.parse = (payload, ctx) => {
|
|
800
|
+
const input = payload.value;
|
|
801
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
802
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
803
|
+
const async = left instanceof Promise || right instanceof Promise;
|
|
804
|
+
if (async) {
|
|
805
|
+
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
806
|
+
return handleIntersectionResults(payload, left2, right2);
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
return handleIntersectionResults(payload, left, right);
|
|
810
|
+
};
|
|
811
|
+
});
|
|
812
|
+
function mergeValues(a, b) {
|
|
813
|
+
if (a === b) {
|
|
814
|
+
return { valid: true, data: a };
|
|
815
|
+
}
|
|
816
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
817
|
+
return { valid: true, data: a };
|
|
818
|
+
}
|
|
819
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
820
|
+
const bKeys = Object.keys(b);
|
|
821
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
822
|
+
const newObj = { ...a, ...b };
|
|
823
|
+
for (const key of sharedKeys) {
|
|
824
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
825
|
+
if (!sharedValue.valid) {
|
|
826
|
+
return {
|
|
827
|
+
valid: false,
|
|
828
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
newObj[key] = sharedValue.data;
|
|
832
|
+
}
|
|
833
|
+
return { valid: true, data: newObj };
|
|
834
|
+
}
|
|
835
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
836
|
+
if (a.length !== b.length) {
|
|
837
|
+
return { valid: false, mergeErrorPath: [] };
|
|
838
|
+
}
|
|
839
|
+
const newArray = [];
|
|
840
|
+
for (let index = 0; index < a.length; index++) {
|
|
841
|
+
const itemA = a[index];
|
|
842
|
+
const itemB = b[index];
|
|
843
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
844
|
+
if (!sharedValue.valid) {
|
|
845
|
+
return {
|
|
846
|
+
valid: false,
|
|
847
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
newArray.push(sharedValue.data);
|
|
851
|
+
}
|
|
852
|
+
return { valid: true, data: newArray };
|
|
853
|
+
}
|
|
854
|
+
return { valid: false, mergeErrorPath: [] };
|
|
855
|
+
}
|
|
856
|
+
function handleIntersectionResults(result, left, right) {
|
|
857
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
858
|
+
let unrecIssue;
|
|
859
|
+
for (const iss of left.issues) {
|
|
860
|
+
if (iss.code === "unrecognized_keys") {
|
|
861
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
862
|
+
for (const k of iss.keys) {
|
|
863
|
+
if (!unrecKeys.has(k))
|
|
864
|
+
unrecKeys.set(k, {});
|
|
865
|
+
unrecKeys.get(k).l = true;
|
|
866
|
+
}
|
|
867
|
+
} else {
|
|
868
|
+
result.issues.push(iss);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
for (const iss of right.issues) {
|
|
872
|
+
if (iss.code === "unrecognized_keys") {
|
|
873
|
+
for (const k of iss.keys) {
|
|
874
|
+
if (!unrecKeys.has(k))
|
|
875
|
+
unrecKeys.set(k, {});
|
|
876
|
+
unrecKeys.get(k).r = true;
|
|
877
|
+
}
|
|
878
|
+
} else {
|
|
879
|
+
result.issues.push(iss);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
883
|
+
if (bothKeys.length && unrecIssue) {
|
|
884
|
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
885
|
+
}
|
|
886
|
+
if (aborted(result))
|
|
887
|
+
return result;
|
|
888
|
+
const merged = mergeValues(left.value, right.value);
|
|
889
|
+
if (!merged.valid) {
|
|
890
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
891
|
+
}
|
|
892
|
+
result.value = merged.data;
|
|
893
|
+
return result;
|
|
894
|
+
}
|
|
895
|
+
const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
896
|
+
$ZodType.init(inst, def);
|
|
897
|
+
inst._zod.parse = (payload, ctx) => {
|
|
898
|
+
const input = payload.value;
|
|
899
|
+
if (!isPlainObject(input)) {
|
|
900
|
+
payload.issues.push({
|
|
901
|
+
expected: "record",
|
|
902
|
+
code: "invalid_type",
|
|
903
|
+
input,
|
|
904
|
+
inst
|
|
905
|
+
});
|
|
906
|
+
return payload;
|
|
907
|
+
}
|
|
908
|
+
const proms = [];
|
|
909
|
+
const values = def.keyType._zod.values;
|
|
910
|
+
if (values) {
|
|
911
|
+
payload.value = {};
|
|
912
|
+
const recordKeys = /* @__PURE__ */ new Set();
|
|
913
|
+
for (const key of values) {
|
|
914
|
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
915
|
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
916
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
917
|
+
if (result instanceof Promise) {
|
|
918
|
+
proms.push(result.then((result2) => {
|
|
919
|
+
if (result2.issues.length) {
|
|
920
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
921
|
+
}
|
|
922
|
+
payload.value[key] = result2.value;
|
|
923
|
+
}));
|
|
924
|
+
} else {
|
|
925
|
+
if (result.issues.length) {
|
|
926
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
927
|
+
}
|
|
928
|
+
payload.value[key] = result.value;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
let unrecognized;
|
|
933
|
+
for (const key in input) {
|
|
934
|
+
if (!recordKeys.has(key)) {
|
|
935
|
+
unrecognized = unrecognized ?? [];
|
|
936
|
+
unrecognized.push(key);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
940
|
+
payload.issues.push({
|
|
941
|
+
code: "unrecognized_keys",
|
|
942
|
+
input,
|
|
943
|
+
inst,
|
|
944
|
+
keys: unrecognized
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
} else {
|
|
948
|
+
payload.value = {};
|
|
949
|
+
for (const key of Reflect.ownKeys(input)) {
|
|
950
|
+
if (key === "__proto__")
|
|
951
|
+
continue;
|
|
952
|
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
953
|
+
if (keyResult instanceof Promise) {
|
|
954
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
955
|
+
}
|
|
956
|
+
const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
|
|
957
|
+
if (checkNumericKey) {
|
|
958
|
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
959
|
+
if (retryResult instanceof Promise) {
|
|
960
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
961
|
+
}
|
|
962
|
+
if (retryResult.issues.length === 0) {
|
|
963
|
+
keyResult = retryResult;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
if (keyResult.issues.length) {
|
|
967
|
+
if (def.mode === "loose") {
|
|
968
|
+
payload.value[key] = input[key];
|
|
969
|
+
} else {
|
|
970
|
+
payload.issues.push({
|
|
971
|
+
code: "invalid_key",
|
|
972
|
+
origin: "record",
|
|
973
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
974
|
+
input: key,
|
|
975
|
+
path: [key],
|
|
976
|
+
inst
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
continue;
|
|
980
|
+
}
|
|
981
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
982
|
+
if (result instanceof Promise) {
|
|
983
|
+
proms.push(result.then((result2) => {
|
|
984
|
+
if (result2.issues.length) {
|
|
985
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
986
|
+
}
|
|
987
|
+
payload.value[keyResult.value] = result2.value;
|
|
988
|
+
}));
|
|
989
|
+
} else {
|
|
990
|
+
if (result.issues.length) {
|
|
991
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
992
|
+
}
|
|
993
|
+
payload.value[keyResult.value] = result.value;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
if (proms.length) {
|
|
998
|
+
return Promise.all(proms).then(() => payload);
|
|
999
|
+
}
|
|
1000
|
+
return payload;
|
|
1001
|
+
};
|
|
1002
|
+
});
|
|
1003
|
+
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1004
|
+
$ZodType.init(inst, def);
|
|
1005
|
+
const values = getEnumValues(def.entries);
|
|
1006
|
+
const valuesSet = new Set(values);
|
|
1007
|
+
inst._zod.values = valuesSet;
|
|
1008
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1009
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1010
|
+
const input = payload.value;
|
|
1011
|
+
if (valuesSet.has(input)) {
|
|
1012
|
+
return payload;
|
|
1013
|
+
}
|
|
1014
|
+
payload.issues.push({
|
|
1015
|
+
code: "invalid_value",
|
|
1016
|
+
values,
|
|
1017
|
+
input,
|
|
1018
|
+
inst
|
|
1019
|
+
});
|
|
1020
|
+
return payload;
|
|
1021
|
+
};
|
|
1022
|
+
});
|
|
1023
|
+
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1024
|
+
$ZodType.init(inst, def);
|
|
1025
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1026
|
+
if (ctx.direction === "backward") {
|
|
1027
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
1028
|
+
}
|
|
1029
|
+
const _out = def.transform(payload.value, payload);
|
|
1030
|
+
if (ctx.async) {
|
|
1031
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1032
|
+
return output.then((output2) => {
|
|
1033
|
+
payload.value = output2;
|
|
1034
|
+
return payload;
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
if (_out instanceof Promise) {
|
|
1038
|
+
throw new $ZodAsyncError();
|
|
1039
|
+
}
|
|
1040
|
+
payload.value = _out;
|
|
1041
|
+
return payload;
|
|
1042
|
+
};
|
|
1043
|
+
});
|
|
1044
|
+
function handleOptionalResult(result, input) {
|
|
1045
|
+
if (result.issues.length && input === void 0) {
|
|
1046
|
+
return { issues: [], value: void 0 };
|
|
1047
|
+
}
|
|
1048
|
+
return result;
|
|
1049
|
+
}
|
|
1050
|
+
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1051
|
+
$ZodType.init(inst, def);
|
|
1052
|
+
inst._zod.optin = "optional";
|
|
1053
|
+
inst._zod.optout = "optional";
|
|
1054
|
+
defineLazy(inst._zod, "values", () => {
|
|
1055
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1056
|
+
});
|
|
1057
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1058
|
+
const pattern = def.innerType._zod.pattern;
|
|
1059
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1060
|
+
});
|
|
1061
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1062
|
+
if (def.innerType._zod.optin === "optional") {
|
|
1063
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1064
|
+
if (result instanceof Promise)
|
|
1065
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1066
|
+
return handleOptionalResult(result, payload.value);
|
|
1067
|
+
}
|
|
1068
|
+
if (payload.value === void 0) {
|
|
1069
|
+
return payload;
|
|
1070
|
+
}
|
|
1071
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1072
|
+
};
|
|
1073
|
+
});
|
|
1074
|
+
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
1075
|
+
$ZodOptional.init(inst, def);
|
|
1076
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1077
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
1078
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1079
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1080
|
+
};
|
|
1081
|
+
});
|
|
1082
|
+
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1083
|
+
$ZodType.init(inst, def);
|
|
1084
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1085
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1086
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1087
|
+
const pattern = def.innerType._zod.pattern;
|
|
1088
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1089
|
+
});
|
|
1090
|
+
defineLazy(inst._zod, "values", () => {
|
|
1091
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1092
|
+
});
|
|
1093
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1094
|
+
if (payload.value === null)
|
|
1095
|
+
return payload;
|
|
1096
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1097
|
+
};
|
|
1098
|
+
});
|
|
1099
|
+
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1100
|
+
$ZodType.init(inst, def);
|
|
1101
|
+
inst._zod.optin = "optional";
|
|
1102
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1103
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1104
|
+
if (ctx.direction === "backward") {
|
|
1105
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1106
|
+
}
|
|
1107
|
+
if (payload.value === void 0) {
|
|
1108
|
+
payload.value = def.defaultValue;
|
|
1109
|
+
return payload;
|
|
1110
|
+
}
|
|
1111
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1112
|
+
if (result instanceof Promise) {
|
|
1113
|
+
return result.then((result2) => handleDefaultResult(result2, def));
|
|
1114
|
+
}
|
|
1115
|
+
return handleDefaultResult(result, def);
|
|
1116
|
+
};
|
|
1117
|
+
});
|
|
1118
|
+
function handleDefaultResult(payload, def) {
|
|
1119
|
+
if (payload.value === void 0) {
|
|
1120
|
+
payload.value = def.defaultValue;
|
|
1121
|
+
}
|
|
1122
|
+
return payload;
|
|
1123
|
+
}
|
|
1124
|
+
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1125
|
+
$ZodType.init(inst, def);
|
|
1126
|
+
inst._zod.optin = "optional";
|
|
1127
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1128
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1129
|
+
if (ctx.direction === "backward") {
|
|
1130
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1131
|
+
}
|
|
1132
|
+
if (payload.value === void 0) {
|
|
1133
|
+
payload.value = def.defaultValue;
|
|
1134
|
+
}
|
|
1135
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1136
|
+
};
|
|
1137
|
+
});
|
|
1138
|
+
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1139
|
+
$ZodType.init(inst, def);
|
|
1140
|
+
defineLazy(inst._zod, "values", () => {
|
|
1141
|
+
const v = def.innerType._zod.values;
|
|
1142
|
+
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
1143
|
+
});
|
|
1144
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1145
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1146
|
+
if (result instanceof Promise) {
|
|
1147
|
+
return result.then((result2) => handleNonOptionalResult(result2, inst));
|
|
1148
|
+
}
|
|
1149
|
+
return handleNonOptionalResult(result, inst);
|
|
1150
|
+
};
|
|
1151
|
+
});
|
|
1152
|
+
function handleNonOptionalResult(payload, inst) {
|
|
1153
|
+
if (!payload.issues.length && payload.value === void 0) {
|
|
1154
|
+
payload.issues.push({
|
|
1155
|
+
code: "invalid_type",
|
|
1156
|
+
expected: "nonoptional",
|
|
1157
|
+
input: payload.value,
|
|
1158
|
+
inst
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
return payload;
|
|
1162
|
+
}
|
|
1163
|
+
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
1164
|
+
$ZodType.init(inst, def);
|
|
1165
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1166
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1167
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1168
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1169
|
+
if (ctx.direction === "backward") {
|
|
1170
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1171
|
+
}
|
|
1172
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1173
|
+
if (result instanceof Promise) {
|
|
1174
|
+
return result.then((result2) => {
|
|
1175
|
+
payload.value = result2.value;
|
|
1176
|
+
if (result2.issues.length) {
|
|
1177
|
+
payload.value = def.catchValue({
|
|
1178
|
+
...payload,
|
|
1179
|
+
error: {
|
|
1180
|
+
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
1181
|
+
},
|
|
1182
|
+
input: payload.value
|
|
1183
|
+
});
|
|
1184
|
+
payload.issues = [];
|
|
1185
|
+
}
|
|
1186
|
+
return payload;
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
payload.value = result.value;
|
|
1190
|
+
if (result.issues.length) {
|
|
1191
|
+
payload.value = def.catchValue({
|
|
1192
|
+
...payload,
|
|
1193
|
+
error: {
|
|
1194
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
1195
|
+
},
|
|
1196
|
+
input: payload.value
|
|
1197
|
+
});
|
|
1198
|
+
payload.issues = [];
|
|
1199
|
+
}
|
|
1200
|
+
return payload;
|
|
1201
|
+
};
|
|
1202
|
+
});
|
|
1203
|
+
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
1204
|
+
$ZodType.init(inst, def);
|
|
1205
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1206
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1207
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1208
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1209
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1210
|
+
if (ctx.direction === "backward") {
|
|
1211
|
+
const right = def.out._zod.run(payload, ctx);
|
|
1212
|
+
if (right instanceof Promise) {
|
|
1213
|
+
return right.then((right2) => handlePipeResult(right2, def.in, ctx));
|
|
1214
|
+
}
|
|
1215
|
+
return handlePipeResult(right, def.in, ctx);
|
|
1216
|
+
}
|
|
1217
|
+
const left = def.in._zod.run(payload, ctx);
|
|
1218
|
+
if (left instanceof Promise) {
|
|
1219
|
+
return left.then((left2) => handlePipeResult(left2, def.out, ctx));
|
|
1220
|
+
}
|
|
1221
|
+
return handlePipeResult(left, def.out, ctx);
|
|
1222
|
+
};
|
|
1223
|
+
});
|
|
1224
|
+
function handlePipeResult(left, next, ctx) {
|
|
1225
|
+
if (left.issues.length) {
|
|
1226
|
+
left.aborted = true;
|
|
1227
|
+
return left;
|
|
1228
|
+
}
|
|
1229
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1230
|
+
}
|
|
1231
|
+
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
1232
|
+
$ZodType.init(inst, def);
|
|
1233
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1234
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1235
|
+
defineLazy(inst._zod, "optin", () => {
|
|
1236
|
+
var _a, _b;
|
|
1237
|
+
return (_b = (_a = def.innerType) == null ? void 0 : _a._zod) == null ? void 0 : _b.optin;
|
|
1238
|
+
});
|
|
1239
|
+
defineLazy(inst._zod, "optout", () => {
|
|
1240
|
+
var _a, _b;
|
|
1241
|
+
return (_b = (_a = def.innerType) == null ? void 0 : _a._zod) == null ? void 0 : _b.optout;
|
|
1242
|
+
});
|
|
1243
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1244
|
+
if (ctx.direction === "backward") {
|
|
1245
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1246
|
+
}
|
|
1247
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1248
|
+
if (result instanceof Promise) {
|
|
1249
|
+
return result.then(handleReadonlyResult);
|
|
1250
|
+
}
|
|
1251
|
+
return handleReadonlyResult(result);
|
|
1252
|
+
};
|
|
1253
|
+
});
|
|
1254
|
+
function handleReadonlyResult(payload) {
|
|
1255
|
+
payload.value = Object.freeze(payload.value);
|
|
1256
|
+
return payload;
|
|
1257
|
+
}
|
|
1258
|
+
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
1259
|
+
$ZodCheck.init(inst, def);
|
|
1260
|
+
$ZodType.init(inst, def);
|
|
1261
|
+
inst._zod.parse = (payload, _) => {
|
|
1262
|
+
return payload;
|
|
1263
|
+
};
|
|
1264
|
+
inst._zod.check = (payload) => {
|
|
1265
|
+
const input = payload.value;
|
|
1266
|
+
const r = def.fn(input);
|
|
1267
|
+
if (r instanceof Promise) {
|
|
1268
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
1269
|
+
}
|
|
1270
|
+
handleRefineResult(r, payload, input, inst);
|
|
1271
|
+
return;
|
|
1272
|
+
};
|
|
1273
|
+
});
|
|
1274
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
1275
|
+
if (!result) {
|
|
1276
|
+
const _iss = {
|
|
1277
|
+
code: "custom",
|
|
1278
|
+
input,
|
|
1279
|
+
inst,
|
|
1280
|
+
// incorporates params.error into issue reporting
|
|
1281
|
+
path: [...inst._zod.def.path ?? []],
|
|
1282
|
+
// incorporates params.error into issue reporting
|
|
1283
|
+
continue: !inst._zod.def.abort
|
|
1284
|
+
// params: inst._zod.def.params,
|
|
1285
|
+
};
|
|
1286
|
+
if (inst._zod.def.params)
|
|
1287
|
+
_iss.params = inst._zod.def.params;
|
|
1288
|
+
payload.issues.push(issue(_iss));
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
export {
|
|
1292
|
+
$ZodAny,
|
|
1293
|
+
$ZodArray,
|
|
1294
|
+
$ZodBase64,
|
|
1295
|
+
$ZodBase64URL,
|
|
1296
|
+
$ZodCIDRv4,
|
|
1297
|
+
$ZodCIDRv6,
|
|
1298
|
+
$ZodCUID,
|
|
1299
|
+
$ZodCUID2,
|
|
1300
|
+
$ZodCatch,
|
|
1301
|
+
$ZodCustom,
|
|
1302
|
+
$ZodDefault,
|
|
1303
|
+
$ZodE164,
|
|
1304
|
+
$ZodEmail,
|
|
1305
|
+
$ZodEmoji,
|
|
1306
|
+
$ZodEnum,
|
|
1307
|
+
$ZodExactOptional,
|
|
1308
|
+
$ZodGUID,
|
|
1309
|
+
$ZodIPv4,
|
|
1310
|
+
$ZodIPv6,
|
|
1311
|
+
$ZodISODate,
|
|
1312
|
+
$ZodISODateTime,
|
|
1313
|
+
$ZodISODuration,
|
|
1314
|
+
$ZodISOTime,
|
|
1315
|
+
$ZodIntersection,
|
|
1316
|
+
$ZodJWT,
|
|
1317
|
+
$ZodKSUID,
|
|
1318
|
+
$ZodNanoID,
|
|
1319
|
+
$ZodNever,
|
|
1320
|
+
$ZodNonOptional,
|
|
1321
|
+
$ZodNullable,
|
|
1322
|
+
$ZodNumber,
|
|
1323
|
+
$ZodNumberFormat,
|
|
1324
|
+
$ZodObject,
|
|
1325
|
+
$ZodObjectJIT,
|
|
1326
|
+
$ZodOptional,
|
|
1327
|
+
$ZodPipe,
|
|
1328
|
+
$ZodPrefault,
|
|
1329
|
+
$ZodReadonly,
|
|
1330
|
+
$ZodRecord,
|
|
1331
|
+
$ZodString,
|
|
1332
|
+
$ZodStringFormat,
|
|
1333
|
+
$ZodTransform,
|
|
1334
|
+
$ZodType,
|
|
1335
|
+
$ZodULID,
|
|
1336
|
+
$ZodURL,
|
|
1337
|
+
$ZodUUID,
|
|
1338
|
+
$ZodUnion,
|
|
1339
|
+
$ZodUnknown,
|
|
1340
|
+
$ZodXID,
|
|
1341
|
+
clone,
|
|
1342
|
+
isValidBase64,
|
|
1343
|
+
isValidBase64URL,
|
|
1344
|
+
isValidJWT
|
|
1345
|
+
};
|