@temporary-name/zod 1.9.3-alpha.7a1c61b78fb0f837e48e1c2f179b32b842462035 → 1.9.3-alpha.7af249c626ccabe97d83025ab05ba3fbad2321c8
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 +728 -76
- package/dist/index.d.ts +728 -76
- package/dist/index.mjs +1460 -896
- package/package.json +6 -16
- package/dist/zod4/index.d.mts +0 -314
- package/dist/zod4/index.d.ts +0 -314
- package/dist/zod4/index.mjs +0 -743
package/dist/index.mjs
CHANGED
|
@@ -1,955 +1,1519 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import escapeStringRegexp from 'escape-string-regexp';
|
|
1
|
+
import * as core from 'zod/v4/core';
|
|
2
|
+
import { $ZodError, util, _overwrite, _regex, _includes, _startsWith, _endsWith, _minLength, _maxLength, _length, _lowercase, _uppercase, _trim, _normalize, _toLowerCase, _toUpperCase, _gt, _gte, _lt, _lte, _multipleOf } from 'zod/v4/core';
|
|
3
|
+
export { core };
|
|
4
|
+
export { _endsWith as endsWith, _gt as gt, _gte as gte, _includes as includes, _length as length, _lowercase as lowercase, _lt as lt, _lte as lte, _maxLength as maxLength, _maxSize as maxSize, _mime as mime, _minLength as minLength, _minSize as minSize, _multipleOf as multipleOf, _negative as negative, _nonnegative as nonnegative, _nonpositive as nonpositive, _normalize as normalize, _overwrite as overwrite, _positive as positive, _property as property, _regex as regex, _size as size, _startsWith as startsWith, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _trim as trim, _uppercase as uppercase } from 'zod/v4/core';
|
|
5
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const initializer = (inst, issues) => {
|
|
8
|
+
$ZodError.init(inst, issues);
|
|
9
|
+
inst.name = "ZodError";
|
|
10
|
+
Object.defineProperties(inst, {
|
|
11
|
+
format: {
|
|
12
|
+
value: (mapper) => core.formatError(inst, mapper)
|
|
13
|
+
// enumerable: false,
|
|
14
|
+
},
|
|
15
|
+
flatten: {
|
|
16
|
+
value: (mapper) => core.flattenError(inst, mapper)
|
|
17
|
+
// enumerable: false,
|
|
18
|
+
},
|
|
19
|
+
addIssue: {
|
|
20
|
+
value: (issue) => {
|
|
21
|
+
inst.issues.push(issue);
|
|
22
|
+
inst.message = JSON.stringify(inst.issues, core.util.jsonStringifyReplacer, 2);
|
|
23
|
+
}
|
|
24
|
+
// enumerable: false,
|
|
25
|
+
},
|
|
26
|
+
addIssues: {
|
|
27
|
+
value: (issues2) => {
|
|
28
|
+
inst.issues.push(...issues2);
|
|
29
|
+
inst.message = JSON.stringify(inst.issues, core.util.jsonStringifyReplacer, 2);
|
|
30
|
+
}
|
|
31
|
+
// enumerable: false,
|
|
32
|
+
},
|
|
33
|
+
isEmpty: {
|
|
34
|
+
get() {
|
|
35
|
+
return inst.issues.length === 0;
|
|
36
|
+
}
|
|
37
|
+
// enumerable: false,
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const ZodError = core.$constructor("ZodError", initializer);
|
|
42
|
+
const ZodRealError = core.$constructor("ZodError", initializer, {
|
|
43
|
+
Parent: Error
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const parse = /* @__PURE__ */ core._parse(ZodRealError);
|
|
47
|
+
const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);
|
|
48
|
+
const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);
|
|
49
|
+
const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
|
|
50
|
+
const encode = /* @__PURE__ */ core._encode(ZodRealError);
|
|
51
|
+
const decode = /* @__PURE__ */ core._decode(ZodRealError);
|
|
52
|
+
const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);
|
|
53
|
+
const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);
|
|
54
|
+
const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);
|
|
55
|
+
const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
|
|
56
|
+
const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
|
|
57
|
+
const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
|
|
58
|
+
|
|
59
|
+
const ZodISODateTime = /* @__PURE__ */ core.$constructor(
|
|
60
|
+
"ZodISODateTime",
|
|
61
|
+
(inst, def) => {
|
|
62
|
+
const coreInit = core.$ZodISODateTime.init;
|
|
63
|
+
coreInit(inst, def);
|
|
64
|
+
ZodStringFormat.init(inst, def);
|
|
14
65
|
}
|
|
15
|
-
|
|
16
|
-
|
|
66
|
+
);
|
|
67
|
+
function datetime(params) {
|
|
68
|
+
return core._isoDateTime(ZodISODateTime, params);
|
|
69
|
+
}
|
|
70
|
+
const ZodISODate = /* @__PURE__ */ core.$constructor(
|
|
71
|
+
"ZodISODate",
|
|
72
|
+
(inst, def) => {
|
|
73
|
+
const coreInit = core.$ZodISODate.init;
|
|
74
|
+
coreInit(inst, def);
|
|
75
|
+
ZodStringFormat.init(inst, def);
|
|
17
76
|
}
|
|
18
|
-
|
|
19
|
-
|
|
77
|
+
);
|
|
78
|
+
function date$1(params) {
|
|
79
|
+
return core._isoDate(ZodISODate, params);
|
|
80
|
+
}
|
|
81
|
+
const ZodISOTime = /* @__PURE__ */ core.$constructor(
|
|
82
|
+
"ZodISOTime",
|
|
83
|
+
(inst, def) => {
|
|
84
|
+
const coreInit = core.$ZodISOTime.init;
|
|
85
|
+
coreInit(inst, def);
|
|
86
|
+
ZodStringFormat.init(inst, def);
|
|
20
87
|
}
|
|
21
|
-
|
|
88
|
+
);
|
|
89
|
+
function time(params) {
|
|
90
|
+
return core._isoTime(ZodISOTime, params);
|
|
22
91
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
92
|
+
const ZodISODuration = /* @__PURE__ */ core.$constructor(
|
|
93
|
+
"ZodISODuration",
|
|
94
|
+
(inst, def) => {
|
|
95
|
+
const coreInit = core.$ZodISODuration.init;
|
|
96
|
+
coreInit(inst, def);
|
|
97
|
+
ZodStringFormat.init(inst, def);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
function duration(params) {
|
|
101
|
+
return core._isoDuration(ZodISODuration, params);
|
|
31
102
|
}
|
|
32
103
|
|
|
33
|
-
const
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
function getCustomZodDef(def) {
|
|
38
|
-
return def[CUSTOM_ZOD_DEF_SYMBOL];
|
|
39
|
-
}
|
|
40
|
-
function composeParams(defaultMessage, params) {
|
|
41
|
-
return (val) => {
|
|
42
|
-
const message = defaultMessage(val);
|
|
43
|
-
if (!params) {
|
|
44
|
-
return {
|
|
45
|
-
message
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (typeof params === "function") {
|
|
49
|
-
return {
|
|
50
|
-
message,
|
|
51
|
-
...params(val)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (typeof params === "object") {
|
|
55
|
-
return {
|
|
56
|
-
message,
|
|
57
|
-
...params
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
message: params
|
|
62
|
-
};
|
|
63
|
-
};
|
|
104
|
+
const gatingContext = new AsyncLocalStorage();
|
|
105
|
+
function isGateIssueRaw(issue) {
|
|
106
|
+
return issue.code === "invalid_type" && issue.expected === "never" && issue.inst instanceof ZodGate;
|
|
64
107
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const schema = custom(
|
|
68
|
-
(val) => val instanceof Blob,
|
|
69
|
-
composeParams(
|
|
70
|
-
() => "Input is not a blob",
|
|
71
|
-
params
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
|
-
setCustomZodDef(schema._def, { type: "blob" });
|
|
75
|
-
return schema;
|
|
108
|
+
function isGateIssue(issue) {
|
|
109
|
+
return issue.code === "invalid_type" && issue.expected === "never" && issue.path?.length === 0;
|
|
76
110
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
composeParams(
|
|
93
|
-
(val) => `Expected a file of type ${mimeType} but got a file of type ${val.type || "unknown"}`,
|
|
94
|
-
params2
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
setCustomZodDef(refinedSchema._def, { type: "file", mimeType });
|
|
98
|
-
return refinedSchema;
|
|
111
|
+
const ZodGate = /* @__PURE__ */ core.$constructor("ZodGate", (inst, def) => {
|
|
112
|
+
const coreInit = core.$ZodOptional.init;
|
|
113
|
+
coreInit(inst, def);
|
|
114
|
+
KrustyType.init(inst, def);
|
|
115
|
+
inst._zod.parse = (payload, ctx) => {
|
|
116
|
+
const gateEnabled = gatingContext.getStore()?.(def.gateName);
|
|
117
|
+
if (gateEnabled) {
|
|
118
|
+
return def.innerType._zod.run(payload, ctx);
|
|
119
|
+
} else if (payload.value !== void 0) {
|
|
120
|
+
payload.issues.push({
|
|
121
|
+
expected: "never",
|
|
122
|
+
code: "invalid_type",
|
|
123
|
+
input: payload.value,
|
|
124
|
+
inst
|
|
125
|
+
});
|
|
99
126
|
}
|
|
127
|
+
return payload;
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
function gate(innerType, gateName) {
|
|
131
|
+
return new ZodGate({
|
|
132
|
+
type: "optional",
|
|
133
|
+
innerType,
|
|
134
|
+
gateName
|
|
100
135
|
});
|
|
101
136
|
}
|
|
102
137
|
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
() =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return schema;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function url(params) {
|
|
116
|
-
const schema = custom(
|
|
117
|
-
(val) => val instanceof URL,
|
|
118
|
-
composeParams(
|
|
119
|
-
() => "Input is not a URL",
|
|
120
|
-
params
|
|
121
|
-
)
|
|
122
|
-
);
|
|
123
|
-
setCustomZodDef(schema._def, { type: "url" });
|
|
124
|
-
return schema;
|
|
138
|
+
function handleGating(payload) {
|
|
139
|
+
for (let i = 0; i < payload.issues.length; i++) {
|
|
140
|
+
const issue = payload.issues[i];
|
|
141
|
+
if (issue?.code === "invalid_union") {
|
|
142
|
+
const newErrors = issue.errors.filter((innerIssues) => !innerIssues.some(isGateIssue));
|
|
143
|
+
issue.errors.splice(0, Infinity, ...newErrors);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return payload;
|
|
125
147
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
148
|
+
const ZodUnion = /* @__PURE__ */ core.$constructor(
|
|
149
|
+
"ZodUnion",
|
|
150
|
+
(inst, def) => {
|
|
151
|
+
const coreInit = core.$ZodUnion.init;
|
|
152
|
+
coreInit(inst, def);
|
|
153
|
+
KrustyType.init(inst, def);
|
|
154
|
+
inst.options = def.options;
|
|
155
|
+
const origParse = inst._zod.parse;
|
|
156
|
+
inst._zod.parse = (payload, ctx) => {
|
|
157
|
+
const res = origParse(payload, ctx);
|
|
158
|
+
if (res instanceof Promise) {
|
|
159
|
+
return res.then((r) => handleGating(r));
|
|
160
|
+
} else {
|
|
161
|
+
return handleGating(res);
|
|
134
162
|
}
|
|
135
|
-
|
|
136
|
-
return options2.next({ ...options2, input: coercedInput });
|
|
137
|
-
});
|
|
163
|
+
};
|
|
138
164
|
}
|
|
165
|
+
);
|
|
166
|
+
function union(options, params) {
|
|
167
|
+
return new ZodUnion({
|
|
168
|
+
type: "union",
|
|
169
|
+
options,
|
|
170
|
+
...util.normalizeParams(params)
|
|
171
|
+
});
|
|
139
172
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
const ZodDiscriminatedUnion = /* @__PURE__ */ core.$constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
174
|
+
ZodUnion.init(inst, def);
|
|
175
|
+
const coreInit = core.$ZodDiscriminatedUnion.init;
|
|
176
|
+
coreInit(inst, def);
|
|
177
|
+
});
|
|
178
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
179
|
+
return new ZodDiscriminatedUnion({
|
|
180
|
+
type: "union",
|
|
181
|
+
options,
|
|
182
|
+
discriminator,
|
|
183
|
+
...util.normalizeParams(params)
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function handlePropertyResult(result, final, key, input) {
|
|
188
|
+
if (result.issues.length) {
|
|
189
|
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
155
190
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (typeof value === "string") {
|
|
160
|
-
return safeToNumber(value);
|
|
161
|
-
}
|
|
162
|
-
return value;
|
|
191
|
+
if (result.value === void 0) {
|
|
192
|
+
if (key in input) {
|
|
193
|
+
final.value[key] = void 0;
|
|
163
194
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
} else {
|
|
196
|
+
final.value[key] = result.value;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const ZodObject = /* @__PURE__ */ core.$constructor(
|
|
200
|
+
"ZodObject",
|
|
201
|
+
(inst, def) => {
|
|
202
|
+
const coreInit = core.$ZodObjectJIT.init;
|
|
203
|
+
coreInit(inst, def);
|
|
204
|
+
KrustyType.init(inst, def);
|
|
205
|
+
util.defineLazy(inst, "shape", () => {
|
|
206
|
+
return def.shape;
|
|
207
|
+
});
|
|
208
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
209
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
210
|
+
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
211
|
+
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
212
|
+
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
213
|
+
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
|
|
214
|
+
inst.extend = (incoming) => {
|
|
215
|
+
return util.extend(inst, incoming);
|
|
216
|
+
};
|
|
217
|
+
inst.safeExtend = (incoming) => {
|
|
218
|
+
return util.safeExtend(inst, incoming);
|
|
219
|
+
};
|
|
220
|
+
inst.merge = (other) => util.merge(inst, other);
|
|
221
|
+
inst.pick = (mask) => util.pick(inst, mask);
|
|
222
|
+
inst.omit = (mask) => util.omit(inst, mask);
|
|
223
|
+
inst.partial = (...args) => util.partial(ZodOptional, inst, args[0]);
|
|
224
|
+
inst.required = (...args) => util.required(ZodNonOptional, inst, args[0]);
|
|
225
|
+
function handleGating(input, payload, ctx) {
|
|
226
|
+
const _catchall = def.catchall?._zod;
|
|
227
|
+
const t = _catchall?.def.type;
|
|
228
|
+
let newIssues = null;
|
|
229
|
+
const proms = [];
|
|
230
|
+
const newUnrecognizedKeys = [];
|
|
231
|
+
for (let i = 0; i < payload.issues.length; i++) {
|
|
232
|
+
const issue = payload.issues[i];
|
|
233
|
+
if (!isGateIssueRaw(issue)) {
|
|
234
|
+
continue;
|
|
192
235
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
236
|
+
newIssues ??= [...payload.issues];
|
|
237
|
+
newIssues[i] = null;
|
|
238
|
+
const key = issue.path[0];
|
|
239
|
+
if (!_catchall) {
|
|
240
|
+
delete payload.value[key];
|
|
241
|
+
} else if (t === "never") {
|
|
242
|
+
newUnrecognizedKeys.push(key);
|
|
243
|
+
} else {
|
|
244
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
245
|
+
if (r instanceof Promise) {
|
|
246
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
247
|
+
} else {
|
|
248
|
+
handlePropertyResult(r, payload, key, input);
|
|
205
249
|
}
|
|
206
250
|
}
|
|
207
251
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
case ZodFirstPartyTypeKind.ZodObject: {
|
|
211
|
-
const schema_ = schema;
|
|
212
|
-
if (isObject(value)) {
|
|
213
|
-
const newObj = {};
|
|
214
|
-
const keys = /* @__PURE__ */ new Set([...Object.keys(value), ...Object.keys(schema_.shape)]);
|
|
215
|
-
for (const k of keys) {
|
|
216
|
-
newObj[k] = zodCoerceInternal(schema_.shape[k] ?? schema_._def.catchall, value[k]);
|
|
217
|
-
}
|
|
218
|
-
return newObj;
|
|
219
|
-
}
|
|
220
|
-
return value;
|
|
221
|
-
}
|
|
222
|
-
case ZodFirstPartyTypeKind.ZodRecord: {
|
|
223
|
-
const schema_ = schema;
|
|
224
|
-
if (isObject(value)) {
|
|
225
|
-
const newObj = {};
|
|
226
|
-
for (const [k, v] of Object.entries(value)) {
|
|
227
|
-
const key = zodCoerceInternal(schema_._def.keyType, k);
|
|
228
|
-
const val = zodCoerceInternal(schema_._def.valueType, v);
|
|
229
|
-
newObj[key] = val;
|
|
230
|
-
}
|
|
231
|
-
return newObj;
|
|
232
|
-
}
|
|
233
|
-
return value;
|
|
234
|
-
}
|
|
235
|
-
case ZodFirstPartyTypeKind.ZodArray: {
|
|
236
|
-
const schema_ = schema;
|
|
237
|
-
if (Array.isArray(value)) {
|
|
238
|
-
return value.map((v) => zodCoerceInternal(schema_._def.type, v));
|
|
239
|
-
}
|
|
240
|
-
return value;
|
|
241
|
-
}
|
|
242
|
-
case ZodFirstPartyTypeKind.ZodTuple: {
|
|
243
|
-
const schema_ = schema;
|
|
244
|
-
if (Array.isArray(value)) {
|
|
245
|
-
return value.map((v, i) => {
|
|
246
|
-
const s = schema_._def.items[i] ?? schema_._def.rest;
|
|
247
|
-
return s ? zodCoerceInternal(s, v) : v;
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
return value;
|
|
251
|
-
}
|
|
252
|
-
case ZodFirstPartyTypeKind.ZodSet: {
|
|
253
|
-
const schema_ = schema;
|
|
254
|
-
if (Array.isArray(value)) {
|
|
255
|
-
return new Set(value.map((v) => zodCoerceInternal(schema_._def.valueType, v)));
|
|
252
|
+
if (newIssues) {
|
|
253
|
+
payload.issues = newIssues.filter(Boolean);
|
|
256
254
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const schema_ = schema;
|
|
261
|
-
if (Array.isArray(value) && value.every((i) => Array.isArray(i) && i.length === 2)) {
|
|
262
|
-
return new Map(
|
|
263
|
-
value.map(([k, v]) => [
|
|
264
|
-
zodCoerceInternal(schema_._def.keyType, k),
|
|
265
|
-
zodCoerceInternal(schema_._def.valueType, v)
|
|
266
|
-
])
|
|
255
|
+
if (newUnrecognizedKeys.length > 0) {
|
|
256
|
+
const missingKeyIssue = payload.issues.find(
|
|
257
|
+
(issue) => issue.code === "unrecognized_keys" && !issue.path
|
|
267
258
|
);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const results = [];
|
|
278
|
-
for (const s of schema_._def.options) {
|
|
279
|
-
const newValue = zodCoerceInternal(s, value);
|
|
280
|
-
const result = schema_.safeParse(newValue);
|
|
281
|
-
if (result.success) {
|
|
282
|
-
return newValue;
|
|
259
|
+
if (missingKeyIssue) {
|
|
260
|
+
missingKeyIssue.keys.push(...newUnrecognizedKeys);
|
|
261
|
+
} else {
|
|
262
|
+
payload.issues.push({
|
|
263
|
+
code: "unrecognized_keys",
|
|
264
|
+
keys: newUnrecognizedKeys,
|
|
265
|
+
input,
|
|
266
|
+
inst
|
|
267
|
+
});
|
|
283
268
|
}
|
|
284
|
-
results.push([newValue, result.error.issues.length]);
|
|
285
|
-
}
|
|
286
|
-
if (results.length === 0) {
|
|
287
|
-
return value;
|
|
288
|
-
}
|
|
289
|
-
return results.sort((a, b) => a[1] - b[1])[0][0];
|
|
290
|
-
}
|
|
291
|
-
case ZodFirstPartyTypeKind.ZodIntersection: {
|
|
292
|
-
const schema_ = schema;
|
|
293
|
-
return zodCoerceInternal(schema_._def.right, zodCoerceInternal(schema_._def.left, value));
|
|
294
|
-
}
|
|
295
|
-
case ZodFirstPartyTypeKind.ZodReadonly: {
|
|
296
|
-
const schema_ = schema;
|
|
297
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
298
|
-
}
|
|
299
|
-
case ZodFirstPartyTypeKind.ZodPipeline: {
|
|
300
|
-
const schema_ = schema;
|
|
301
|
-
return zodCoerceInternal(schema_._def.in, value);
|
|
302
|
-
}
|
|
303
|
-
case ZodFirstPartyTypeKind.ZodEffects: {
|
|
304
|
-
const schema_ = schema;
|
|
305
|
-
return zodCoerceInternal(schema_._def.schema, value);
|
|
306
|
-
}
|
|
307
|
-
case ZodFirstPartyTypeKind.ZodBranded: {
|
|
308
|
-
const schema_ = schema;
|
|
309
|
-
return zodCoerceInternal(schema_._def.type, value);
|
|
310
|
-
}
|
|
311
|
-
case ZodFirstPartyTypeKind.ZodCatch: {
|
|
312
|
-
const schema_ = schema;
|
|
313
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
314
|
-
}
|
|
315
|
-
case ZodFirstPartyTypeKind.ZodDefault: {
|
|
316
|
-
const schema_ = schema;
|
|
317
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
318
|
-
}
|
|
319
|
-
case ZodFirstPartyTypeKind.ZodNullable: {
|
|
320
|
-
if (value === null) {
|
|
321
|
-
return null;
|
|
322
269
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (value === void 0) {
|
|
328
|
-
return void 0;
|
|
270
|
+
if (proms.length > 0) {
|
|
271
|
+
return Promise.all(proms).then(() => payload);
|
|
272
|
+
} else {
|
|
273
|
+
return payload;
|
|
329
274
|
}
|
|
330
|
-
const schema_ = schema;
|
|
331
|
-
return zodCoerceInternal(schema_._def.innerType, value);
|
|
332
275
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
276
|
+
const origParse = inst._zod.parse;
|
|
277
|
+
inst._zod.parse = (payload, ctx) => {
|
|
278
|
+
const input = payload.value;
|
|
279
|
+
const res = origParse(payload, ctx);
|
|
280
|
+
if (res instanceof Promise) {
|
|
281
|
+
return res.then((r) => handleGating(input, r, ctx));
|
|
282
|
+
} else {
|
|
283
|
+
return handleGating(input, res, ctx);
|
|
337
284
|
}
|
|
338
|
-
|
|
339
|
-
}
|
|
285
|
+
};
|
|
340
286
|
}
|
|
341
|
-
|
|
287
|
+
);
|
|
288
|
+
function object(shape, params) {
|
|
289
|
+
const def = {
|
|
290
|
+
type: "object",
|
|
291
|
+
shape: shape ?? {},
|
|
292
|
+
...util.normalizeParams(params)
|
|
293
|
+
};
|
|
294
|
+
return new ZodObject(def);
|
|
342
295
|
}
|
|
343
|
-
function
|
|
344
|
-
return
|
|
296
|
+
function strictObject(shape, params) {
|
|
297
|
+
return new ZodObject({
|
|
298
|
+
type: "object",
|
|
299
|
+
shape,
|
|
300
|
+
catchall: never(),
|
|
301
|
+
...util.normalizeParams(params)
|
|
302
|
+
});
|
|
345
303
|
}
|
|
346
|
-
function
|
|
347
|
-
|
|
348
|
-
|
|
304
|
+
function looseObject(shape, params) {
|
|
305
|
+
return new ZodObject({
|
|
306
|
+
type: "object",
|
|
307
|
+
shape,
|
|
308
|
+
catchall: unknown(),
|
|
309
|
+
...util.normalizeParams(params)
|
|
310
|
+
});
|
|
349
311
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
312
|
+
|
|
313
|
+
const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
314
|
+
"KrustyType",
|
|
315
|
+
(inst, def) => {
|
|
316
|
+
const coreInit = core.$ZodType.init;
|
|
317
|
+
coreInit(inst, def);
|
|
318
|
+
inst.def = def;
|
|
319
|
+
inst.type = def.type;
|
|
320
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
321
|
+
inst.check = (...checks2) => {
|
|
322
|
+
return inst.clone(
|
|
323
|
+
util.mergeDefs(def, {
|
|
324
|
+
checks: [
|
|
325
|
+
...def.checks ?? [],
|
|
326
|
+
...checks2.map(
|
|
327
|
+
(ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch
|
|
328
|
+
)
|
|
329
|
+
]
|
|
330
|
+
})
|
|
331
|
+
);
|
|
332
|
+
};
|
|
333
|
+
inst.clone = (def2, params) => core.clone(inst, def2, params);
|
|
334
|
+
inst.brand = () => inst;
|
|
335
|
+
inst.register = ((reg, meta) => {
|
|
336
|
+
reg.add(inst, meta);
|
|
337
|
+
return inst;
|
|
338
|
+
});
|
|
339
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
340
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
341
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
342
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
343
|
+
inst.spa = inst.safeParseAsync;
|
|
344
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
345
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
346
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
347
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
348
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
349
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
350
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
351
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
352
|
+
inst.refine = (check2, params) => inst.check(refine(check2, params));
|
|
353
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
354
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
355
|
+
inst.gate = (gateName) => gate(inst, gateName);
|
|
356
|
+
inst.optional = () => optional(inst);
|
|
357
|
+
inst.nullable = () => nullable(inst);
|
|
358
|
+
inst.nullish = () => optional(nullable(inst));
|
|
359
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
360
|
+
inst.array = () => array(inst);
|
|
361
|
+
inst.or = (arg) => union([inst, arg]);
|
|
362
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
363
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
364
|
+
inst.default = (def2) => _default(inst, def2);
|
|
365
|
+
inst.prefault = (def2) => prefault(inst, def2);
|
|
366
|
+
return inst;
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
const _ZodString = /* @__PURE__ */ core.$constructor(
|
|
370
|
+
"_ZodString",
|
|
371
|
+
(inst, def) => {
|
|
372
|
+
const coreInit = core.$ZodString.init;
|
|
373
|
+
coreInit(inst, def);
|
|
374
|
+
KrustyType.init(inst, def);
|
|
375
|
+
const bag = inst._zod.bag;
|
|
376
|
+
inst.format = bag.format ?? null;
|
|
377
|
+
inst.minLength = bag.minimum ?? null;
|
|
378
|
+
inst.maxLength = bag.maximum ?? null;
|
|
379
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
380
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
381
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
382
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
383
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
384
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
385
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
386
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
387
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
388
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
389
|
+
inst.trim = () => inst.check(_trim());
|
|
390
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
391
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
392
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
354
393
|
}
|
|
355
|
-
|
|
356
|
-
|
|
394
|
+
);
|
|
395
|
+
const ZodString = /* @__PURE__ */ core.$constructor(
|
|
396
|
+
"ZodString",
|
|
397
|
+
(inst, def) => {
|
|
398
|
+
const coreInit = core.$ZodString.init;
|
|
399
|
+
coreInit(inst, def);
|
|
400
|
+
_ZodString.init(inst, def);
|
|
401
|
+
inst.email = (params) => inst.check(core._email(ZodEmail, params));
|
|
402
|
+
inst.url = (params) => inst.check(core._url(ZodURL, params));
|
|
403
|
+
inst.jwt = (params) => inst.check(core._jwt(ZodJWT, params));
|
|
404
|
+
inst.emoji = (params) => inst.check(core._emoji(ZodEmoji, params));
|
|
405
|
+
inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
|
|
406
|
+
inst.uuid = (params) => inst.check(core._uuid(ZodUUID, params));
|
|
407
|
+
inst.uuidv4 = (params) => inst.check(core._uuidv4(ZodUUID, params));
|
|
408
|
+
inst.uuidv6 = (params) => inst.check(core._uuidv6(ZodUUID, params));
|
|
409
|
+
inst.uuidv7 = (params) => inst.check(core._uuidv7(ZodUUID, params));
|
|
410
|
+
inst.nanoid = (params) => inst.check(core._nanoid(ZodNanoID, params));
|
|
411
|
+
inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
|
|
412
|
+
inst.cuid = (params) => inst.check(core._cuid(ZodCUID, params));
|
|
413
|
+
inst.cuid2 = (params) => inst.check(core._cuid2(ZodCUID2, params));
|
|
414
|
+
inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));
|
|
415
|
+
inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));
|
|
416
|
+
inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));
|
|
417
|
+
inst.xid = (params) => inst.check(core._xid(ZodXID, params));
|
|
418
|
+
inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));
|
|
419
|
+
inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
|
|
420
|
+
inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
|
|
421
|
+
inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
|
|
422
|
+
inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));
|
|
423
|
+
inst.e164 = (params) => inst.check(core._e164(ZodE164, params));
|
|
424
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
425
|
+
inst.date = (params) => inst.check(date$1(params));
|
|
426
|
+
inst.time = (params) => inst.check(time(params));
|
|
427
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
357
428
|
}
|
|
358
|
-
|
|
429
|
+
);
|
|
430
|
+
function string(params) {
|
|
431
|
+
return core._string(ZodString, params);
|
|
359
432
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
433
|
+
const ZodStringFormat = /* @__PURE__ */ core.$constructor(
|
|
434
|
+
"ZodStringFormat",
|
|
435
|
+
(inst, def) => {
|
|
436
|
+
const coreInit = core.$ZodStringFormat.init;
|
|
437
|
+
coreInit(inst, def);
|
|
438
|
+
_ZodString.init(inst, def);
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
const ZodEmail = /* @__PURE__ */ core.$constructor(
|
|
442
|
+
"ZodEmail",
|
|
443
|
+
(inst, def) => {
|
|
444
|
+
const coreInit = core.$ZodEmail.init;
|
|
445
|
+
coreInit(inst, def);
|
|
446
|
+
ZodStringFormat.init(inst, def);
|
|
367
447
|
}
|
|
368
|
-
|
|
448
|
+
);
|
|
449
|
+
function email(params) {
|
|
450
|
+
return core._email(ZodEmail, params);
|
|
451
|
+
}
|
|
452
|
+
const ZodGUID = /* @__PURE__ */ core.$constructor("ZodGUID", (inst, def) => {
|
|
453
|
+
const coreInit = core.$ZodGUID.init;
|
|
454
|
+
coreInit(inst, def);
|
|
455
|
+
ZodStringFormat.init(inst, def);
|
|
456
|
+
});
|
|
457
|
+
function guid(params) {
|
|
458
|
+
return core._guid(ZodGUID, params);
|
|
459
|
+
}
|
|
460
|
+
const ZodUUID = /* @__PURE__ */ core.$constructor("ZodUUID", (inst, def) => {
|
|
461
|
+
const coreInit = core.$ZodUUID.init;
|
|
462
|
+
coreInit(inst, def);
|
|
463
|
+
ZodStringFormat.init(inst, def);
|
|
464
|
+
});
|
|
465
|
+
function uuid(params) {
|
|
466
|
+
return core._uuid(ZodUUID, params);
|
|
467
|
+
}
|
|
468
|
+
function uuidv4(params) {
|
|
469
|
+
return core._uuidv4(ZodUUID, params);
|
|
470
|
+
}
|
|
471
|
+
function uuidv6(params) {
|
|
472
|
+
return core._uuidv6(ZodUUID, params);
|
|
369
473
|
}
|
|
370
|
-
function
|
|
371
|
-
return
|
|
474
|
+
function uuidv7(params) {
|
|
475
|
+
return core._uuidv7(ZodUUID, params);
|
|
372
476
|
}
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
477
|
+
const ZodURL = /* @__PURE__ */ core.$constructor("ZodURL", (inst, def) => {
|
|
478
|
+
const coreInit = core.$ZodURL.init;
|
|
479
|
+
coreInit(inst, def);
|
|
480
|
+
ZodStringFormat.init(inst, def);
|
|
481
|
+
});
|
|
482
|
+
function url(params) {
|
|
483
|
+
return core._url(ZodURL, params);
|
|
484
|
+
}
|
|
485
|
+
function httpUrl(params) {
|
|
486
|
+
return core._url(ZodURL, {
|
|
487
|
+
protocol: /^https?$/,
|
|
488
|
+
hostname: core.regexes.domain,
|
|
489
|
+
...util.normalizeParams(params)
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
const ZodEmoji = /* @__PURE__ */ core.$constructor(
|
|
493
|
+
"ZodEmoji",
|
|
494
|
+
(inst, def) => {
|
|
495
|
+
const coreInit = core.$ZodEmoji.init;
|
|
496
|
+
coreInit(inst, def);
|
|
497
|
+
ZodStringFormat.init(inst, def);
|
|
377
498
|
}
|
|
378
|
-
|
|
499
|
+
);
|
|
500
|
+
function emoji(params) {
|
|
501
|
+
return core._emoji(ZodEmoji, params);
|
|
379
502
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
503
|
+
const ZodNanoID = /* @__PURE__ */ core.$constructor(
|
|
504
|
+
"ZodNanoID",
|
|
505
|
+
(inst, def) => {
|
|
506
|
+
const coreInit = core.$ZodNanoID.init;
|
|
507
|
+
coreInit(inst, def);
|
|
508
|
+
ZodStringFormat.init(inst, def);
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
function nanoid(params) {
|
|
512
|
+
return core._nanoid(ZodNanoID, params);
|
|
513
|
+
}
|
|
514
|
+
const ZodCUID = /* @__PURE__ */ core.$constructor("ZodCUID", (inst, def) => {
|
|
515
|
+
const coreInit = core.$ZodCUID.init;
|
|
516
|
+
coreInit(inst, def);
|
|
517
|
+
ZodStringFormat.init(inst, def);
|
|
518
|
+
});
|
|
519
|
+
function cuid(params) {
|
|
520
|
+
return core._cuid(ZodCUID, params);
|
|
521
|
+
}
|
|
522
|
+
const ZodCUID2 = /* @__PURE__ */ core.$constructor(
|
|
523
|
+
"ZodCUID2",
|
|
524
|
+
(inst, def) => {
|
|
525
|
+
const coreInit = core.$ZodCUID2.init;
|
|
526
|
+
coreInit(inst, def);
|
|
527
|
+
ZodStringFormat.init(inst, def);
|
|
528
|
+
}
|
|
529
|
+
);
|
|
530
|
+
function cuid2(params) {
|
|
531
|
+
return core._cuid2(ZodCUID2, params);
|
|
532
|
+
}
|
|
533
|
+
const ZodULID = /* @__PURE__ */ core.$constructor("ZodULID", (inst, def) => {
|
|
534
|
+
const coreInit = core.$ZodULID.init;
|
|
535
|
+
coreInit(inst, def);
|
|
536
|
+
ZodStringFormat.init(inst, def);
|
|
537
|
+
});
|
|
538
|
+
function ulid(params) {
|
|
539
|
+
return core._ulid(ZodULID, params);
|
|
540
|
+
}
|
|
541
|
+
const ZodXID = /* @__PURE__ */ core.$constructor("ZodXID", (inst, def) => {
|
|
542
|
+
const coreInit = core.$ZodXID.init;
|
|
543
|
+
coreInit(inst, def);
|
|
544
|
+
ZodStringFormat.init(inst, def);
|
|
545
|
+
});
|
|
546
|
+
function xid(params) {
|
|
547
|
+
return core._xid(ZodXID, params);
|
|
548
|
+
}
|
|
549
|
+
const ZodKSUID = /* @__PURE__ */ core.$constructor(
|
|
550
|
+
"ZodKSUID",
|
|
551
|
+
(inst, def) => {
|
|
552
|
+
const coreInit = core.$ZodKSUID.init;
|
|
553
|
+
coreInit(inst, def);
|
|
554
|
+
ZodStringFormat.init(inst, def);
|
|
555
|
+
}
|
|
556
|
+
);
|
|
557
|
+
function ksuid(params) {
|
|
558
|
+
return core._ksuid(ZodKSUID, params);
|
|
559
|
+
}
|
|
560
|
+
const ZodIPv4 = /* @__PURE__ */ core.$constructor("ZodIPv4", (inst, def) => {
|
|
561
|
+
const coreInit = core.$ZodIPv4.init;
|
|
562
|
+
coreInit(inst, def);
|
|
563
|
+
ZodStringFormat.init(inst, def);
|
|
564
|
+
});
|
|
565
|
+
function ipv4(params) {
|
|
566
|
+
return core._ipv4(ZodIPv4, params);
|
|
567
|
+
}
|
|
568
|
+
const ZodIPv6 = /* @__PURE__ */ core.$constructor("ZodIPv6", (inst, def) => {
|
|
569
|
+
const coreInit = core.$ZodIPv6.init;
|
|
570
|
+
coreInit(inst, def);
|
|
571
|
+
ZodStringFormat.init(inst, def);
|
|
572
|
+
});
|
|
573
|
+
function ipv6(params) {
|
|
574
|
+
return core._ipv6(ZodIPv6, params);
|
|
575
|
+
}
|
|
576
|
+
const ZodCIDRv4 = /* @__PURE__ */ core.$constructor(
|
|
577
|
+
"ZodCIDRv4",
|
|
578
|
+
(inst, def) => {
|
|
579
|
+
const coreInit = core.$ZodCIDRv4.init;
|
|
580
|
+
coreInit(inst, def);
|
|
581
|
+
ZodStringFormat.init(inst, def);
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
function cidrv4(params) {
|
|
585
|
+
return core._cidrv4(ZodCIDRv4, params);
|
|
586
|
+
}
|
|
587
|
+
const ZodCIDRv6 = /* @__PURE__ */ core.$constructor(
|
|
588
|
+
"ZodCIDRv6",
|
|
589
|
+
(inst, def) => {
|
|
590
|
+
const coreInit = core.$ZodCIDRv6.init;
|
|
591
|
+
coreInit(inst, def);
|
|
592
|
+
ZodStringFormat.init(inst, def);
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
function cidrv6(params) {
|
|
596
|
+
return core._cidrv6(ZodCIDRv6, params);
|
|
597
|
+
}
|
|
598
|
+
const ZodBase64 = /* @__PURE__ */ core.$constructor(
|
|
599
|
+
"ZodBase64",
|
|
600
|
+
(inst, def) => {
|
|
601
|
+
const coreInit = core.$ZodBase64.init;
|
|
602
|
+
coreInit(inst, def);
|
|
603
|
+
ZodStringFormat.init(inst, def);
|
|
604
|
+
}
|
|
605
|
+
);
|
|
606
|
+
function base64(params) {
|
|
607
|
+
return core._base64(ZodBase64, params);
|
|
608
|
+
}
|
|
609
|
+
const ZodBase64URL = /* @__PURE__ */ core.$constructor(
|
|
610
|
+
"ZodBase64URL",
|
|
611
|
+
(inst, def) => {
|
|
612
|
+
const coreInit = core.$ZodBase64URL.init;
|
|
613
|
+
coreInit(inst, def);
|
|
614
|
+
ZodStringFormat.init(inst, def);
|
|
615
|
+
}
|
|
616
|
+
);
|
|
617
|
+
function base64url(params) {
|
|
618
|
+
return core._base64url(ZodBase64URL, params);
|
|
619
|
+
}
|
|
620
|
+
const ZodE164 = /* @__PURE__ */ core.$constructor("ZodE164", (inst, def) => {
|
|
621
|
+
const coreInit = core.$ZodE164.init;
|
|
622
|
+
coreInit(inst, def);
|
|
623
|
+
ZodStringFormat.init(inst, def);
|
|
624
|
+
});
|
|
625
|
+
function e164(params) {
|
|
626
|
+
return core._e164(ZodE164, params);
|
|
627
|
+
}
|
|
628
|
+
const ZodJWT = /* @__PURE__ */ core.$constructor("ZodJWT", (inst, def) => {
|
|
629
|
+
const coreInit = core.$ZodJWT.init;
|
|
630
|
+
coreInit(inst, def);
|
|
631
|
+
ZodStringFormat.init(inst, def);
|
|
632
|
+
});
|
|
633
|
+
function jwt(params) {
|
|
634
|
+
return core._jwt(ZodJWT, params);
|
|
635
|
+
}
|
|
636
|
+
const ZodCustomStringFormat = /* @__PURE__ */ core.$constructor("ZodCustomStringFormat", (inst, def) => {
|
|
637
|
+
const coreInit = core.$ZodCustomStringFormat.init;
|
|
638
|
+
coreInit(inst, def);
|
|
639
|
+
ZodStringFormat.init(inst, def);
|
|
640
|
+
});
|
|
641
|
+
function stringFormat(format, fnOrRegex, _params = {}) {
|
|
642
|
+
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
643
|
+
}
|
|
644
|
+
function hostname(_params) {
|
|
645
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
646
|
+
}
|
|
647
|
+
function hex(_params) {
|
|
648
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
649
|
+
}
|
|
650
|
+
function hash(alg, params) {
|
|
651
|
+
const enc = params?.enc ?? "hex";
|
|
652
|
+
const format = `${alg}_${enc}`;
|
|
653
|
+
const regex = core.regexes[format];
|
|
654
|
+
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
|
|
655
|
+
return core._stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
656
|
+
}
|
|
657
|
+
const ZodNumber = /* @__PURE__ */ core.$constructor(
|
|
658
|
+
"ZodNumber",
|
|
659
|
+
(inst, def) => {
|
|
660
|
+
const coreInit = core.$ZodNumber.init;
|
|
661
|
+
coreInit(inst, def);
|
|
662
|
+
KrustyType.init(inst, def);
|
|
663
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
664
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
665
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
666
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
667
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
668
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
669
|
+
inst.int = (params) => inst.check(int(params));
|
|
670
|
+
inst.safe = (params) => inst.check(int(params));
|
|
671
|
+
inst.positive = (params) => inst.check(_gt(0, params));
|
|
672
|
+
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
673
|
+
inst.negative = (params) => inst.check(_lt(0, params));
|
|
674
|
+
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
675
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
676
|
+
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
677
|
+
inst.finite = () => inst;
|
|
678
|
+
const bag = inst._zod.bag;
|
|
679
|
+
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
680
|
+
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
681
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
682
|
+
inst.isFinite = true;
|
|
683
|
+
inst.format = bag.format ?? null;
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
function number(params) {
|
|
687
|
+
return core._number(ZodNumber, params);
|
|
688
|
+
}
|
|
689
|
+
const ZodNumberFormat = /* @__PURE__ */ core.$constructor(
|
|
690
|
+
"ZodNumberFormat",
|
|
691
|
+
(inst, def) => {
|
|
692
|
+
const coreInit = core.$ZodNumberFormat.init;
|
|
693
|
+
coreInit(inst, def);
|
|
694
|
+
ZodNumber.init(inst, def);
|
|
695
|
+
}
|
|
696
|
+
);
|
|
697
|
+
function int(params) {
|
|
698
|
+
return core._int(ZodNumberFormat, params);
|
|
699
|
+
}
|
|
700
|
+
function float32(params) {
|
|
701
|
+
return core._float32(ZodNumberFormat, params);
|
|
702
|
+
}
|
|
703
|
+
function float64(params) {
|
|
704
|
+
return core._float64(ZodNumberFormat, params);
|
|
705
|
+
}
|
|
706
|
+
function int32(params) {
|
|
707
|
+
return core._int32(ZodNumberFormat, params);
|
|
708
|
+
}
|
|
709
|
+
function uint32(params) {
|
|
710
|
+
return core._uint32(ZodNumberFormat, params);
|
|
711
|
+
}
|
|
712
|
+
const ZodBoolean = /* @__PURE__ */ core.$constructor(
|
|
713
|
+
"ZodBoolean",
|
|
714
|
+
(inst, def) => {
|
|
715
|
+
const coreInit = core.$ZodBoolean.init;
|
|
716
|
+
coreInit(inst, def);
|
|
717
|
+
KrustyType.init(inst, def);
|
|
718
|
+
}
|
|
719
|
+
);
|
|
720
|
+
function boolean(params) {
|
|
721
|
+
return core._boolean(ZodBoolean, params);
|
|
722
|
+
}
|
|
723
|
+
const ZodBigInt = /* @__PURE__ */ core.$constructor(
|
|
724
|
+
"ZodBigInt",
|
|
725
|
+
(inst, def) => {
|
|
726
|
+
const coreInit = core.$ZodBigInt.init;
|
|
727
|
+
coreInit(inst, def);
|
|
728
|
+
KrustyType.init(inst, def);
|
|
729
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
730
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
731
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
732
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
733
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
734
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
735
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
736
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
737
|
+
inst.positive = (params) => inst.check(_gt(BigInt(0), params));
|
|
738
|
+
inst.negative = (params) => inst.check(_lt(BigInt(0), params));
|
|
739
|
+
inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
|
|
740
|
+
inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
|
|
741
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
742
|
+
const bag = inst._zod.bag;
|
|
743
|
+
inst.minValue = bag.minimum ?? null;
|
|
744
|
+
inst.maxValue = bag.maximum ?? null;
|
|
745
|
+
inst.format = bag.format ?? null;
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
function bigint(params) {
|
|
749
|
+
return core._bigint(ZodBigInt, params);
|
|
750
|
+
}
|
|
751
|
+
const ZodBigIntFormat = /* @__PURE__ */ core.$constructor(
|
|
752
|
+
"ZodBigIntFormat",
|
|
753
|
+
(inst, def) => {
|
|
754
|
+
const coreInit = core.$ZodBigIntFormat.init;
|
|
755
|
+
coreInit(inst, def);
|
|
756
|
+
ZodBigInt.init(inst, def);
|
|
757
|
+
}
|
|
758
|
+
);
|
|
759
|
+
function int64(params) {
|
|
760
|
+
return core._int64(ZodBigIntFormat, params);
|
|
761
|
+
}
|
|
762
|
+
function uint64(params) {
|
|
763
|
+
return core._uint64(ZodBigIntFormat, params);
|
|
764
|
+
}
|
|
765
|
+
const ZodSymbol = /* @__PURE__ */ core.$constructor(
|
|
766
|
+
"ZodSymbol",
|
|
767
|
+
(inst, def) => {
|
|
768
|
+
const coreInit = core.$ZodSymbol.init;
|
|
769
|
+
coreInit(inst, def);
|
|
770
|
+
KrustyType.init(inst, def);
|
|
771
|
+
}
|
|
772
|
+
);
|
|
773
|
+
function symbol(params) {
|
|
774
|
+
return core._symbol(ZodSymbol, params);
|
|
775
|
+
}
|
|
776
|
+
const ZodUndefined = /* @__PURE__ */ core.$constructor(
|
|
777
|
+
"ZodUndefined",
|
|
778
|
+
(inst, def) => {
|
|
779
|
+
const coreInit = core.$ZodUndefined.init;
|
|
780
|
+
coreInit(inst, def);
|
|
781
|
+
KrustyType.init(inst, def);
|
|
782
|
+
}
|
|
783
|
+
);
|
|
784
|
+
function _undefined(params) {
|
|
785
|
+
return core._undefined(ZodUndefined, params);
|
|
786
|
+
}
|
|
787
|
+
const ZodNull = /* @__PURE__ */ core.$constructor("ZodNull", (inst, def) => {
|
|
788
|
+
const coreInit = core.$ZodNull.init;
|
|
789
|
+
coreInit(inst, def);
|
|
790
|
+
KrustyType.init(inst, def);
|
|
791
|
+
});
|
|
792
|
+
function _null(params) {
|
|
793
|
+
return core._null(ZodNull, params);
|
|
794
|
+
}
|
|
795
|
+
const ZodAny = /* @__PURE__ */ core.$constructor("ZodAny", (inst, def) => {
|
|
796
|
+
const coreInit = core.$ZodAny.init;
|
|
797
|
+
coreInit(inst, def);
|
|
798
|
+
KrustyType.init(inst, def);
|
|
799
|
+
});
|
|
800
|
+
function any() {
|
|
801
|
+
return core._any(ZodAny);
|
|
802
|
+
}
|
|
803
|
+
const ZodUnknown = /* @__PURE__ */ core.$constructor(
|
|
804
|
+
"ZodUnknown",
|
|
805
|
+
(inst, def) => {
|
|
806
|
+
const coreInit = core.$ZodUnknown.init;
|
|
807
|
+
coreInit(inst, def);
|
|
808
|
+
KrustyType.init(inst, def);
|
|
809
|
+
}
|
|
810
|
+
);
|
|
811
|
+
function unknown() {
|
|
812
|
+
return core._unknown(ZodUnknown);
|
|
813
|
+
}
|
|
814
|
+
const ZodNever = /* @__PURE__ */ core.$constructor(
|
|
815
|
+
"ZodNever",
|
|
816
|
+
(inst, def) => {
|
|
817
|
+
const coreInit = core.$ZodNever.init;
|
|
818
|
+
coreInit(inst, def);
|
|
819
|
+
KrustyType.init(inst, def);
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
function never(params) {
|
|
823
|
+
return core._never(ZodNever, params);
|
|
824
|
+
}
|
|
825
|
+
const ZodVoid = /* @__PURE__ */ core.$constructor("ZodVoid", (inst, def) => {
|
|
826
|
+
const coreInit = core.$ZodVoid.init;
|
|
827
|
+
coreInit(inst, def);
|
|
828
|
+
KrustyType.init(inst, def);
|
|
829
|
+
});
|
|
830
|
+
function _void(params) {
|
|
831
|
+
return core._void(ZodVoid, params);
|
|
832
|
+
}
|
|
833
|
+
const ZodDate = /* @__PURE__ */ core.$constructor("ZodDate", (inst, def) => {
|
|
834
|
+
const coreInit = core.$ZodDate.init;
|
|
835
|
+
coreInit(inst, def);
|
|
836
|
+
KrustyType.init(inst, def);
|
|
837
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
838
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
839
|
+
const c = inst._zod.bag;
|
|
840
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
841
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
842
|
+
});
|
|
843
|
+
function date(params) {
|
|
844
|
+
return core._date(ZodDate, params);
|
|
845
|
+
}
|
|
846
|
+
const ZodArray = /* @__PURE__ */ core.$constructor(
|
|
847
|
+
"ZodArray",
|
|
848
|
+
(inst, def) => {
|
|
849
|
+
const coreInit = core.$ZodArray.init;
|
|
850
|
+
coreInit(inst, def);
|
|
851
|
+
KrustyType.init(inst, def);
|
|
852
|
+
inst.element = def.element;
|
|
853
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
854
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
855
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
856
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
857
|
+
inst.unwrap = () => inst.element;
|
|
858
|
+
}
|
|
859
|
+
);
|
|
860
|
+
function array(element, params) {
|
|
861
|
+
return core._array(ZodArray, element, params);
|
|
862
|
+
}
|
|
863
|
+
function keyof(schema) {
|
|
864
|
+
const shape = schema._zod.def.shape;
|
|
865
|
+
return _enum(Object.keys(shape));
|
|
866
|
+
}
|
|
867
|
+
const ZodIntersection = /* @__PURE__ */ core.$constructor(
|
|
868
|
+
"ZodIntersection",
|
|
869
|
+
(inst, def) => {
|
|
870
|
+
const coreInit = core.$ZodIntersection.init;
|
|
871
|
+
coreInit(inst, def);
|
|
872
|
+
KrustyType.init(inst, def);
|
|
873
|
+
}
|
|
874
|
+
);
|
|
875
|
+
function intersection(left, right) {
|
|
876
|
+
return new ZodIntersection({
|
|
877
|
+
type: "intersection",
|
|
878
|
+
left,
|
|
879
|
+
right
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
const ZodTuple = /* @__PURE__ */ core.$constructor(
|
|
883
|
+
"ZodTuple",
|
|
884
|
+
(inst, def) => {
|
|
885
|
+
const coreInit = core.$ZodTuple.init;
|
|
886
|
+
coreInit(inst, def);
|
|
887
|
+
KrustyType.init(inst, def);
|
|
888
|
+
inst.rest = (rest) => inst.clone({
|
|
889
|
+
...inst._zod.def,
|
|
890
|
+
rest
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
);
|
|
894
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
895
|
+
const hasRest = _paramsOrRest instanceof core.$ZodType;
|
|
896
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
897
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
898
|
+
return new ZodTuple({
|
|
899
|
+
type: "tuple",
|
|
900
|
+
items,
|
|
901
|
+
rest,
|
|
902
|
+
...util.normalizeParams(params)
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
const ZodRecord = /* @__PURE__ */ core.$constructor(
|
|
906
|
+
"ZodRecord",
|
|
907
|
+
(inst, def) => {
|
|
908
|
+
const coreInit = core.$ZodRecord.init;
|
|
909
|
+
coreInit(inst, def);
|
|
910
|
+
KrustyType.init(inst, def);
|
|
911
|
+
inst.keyType = def.keyType;
|
|
912
|
+
inst.valueType = def.valueType;
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
function record(keyType, valueType, params) {
|
|
916
|
+
return new ZodRecord({
|
|
917
|
+
type: "record",
|
|
918
|
+
keyType,
|
|
919
|
+
valueType,
|
|
920
|
+
...util.normalizeParams(params)
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
function partialRecord(keyType, valueType, params) {
|
|
924
|
+
const k = core.clone(keyType);
|
|
925
|
+
k._zod.values = void 0;
|
|
926
|
+
return new ZodRecord({
|
|
927
|
+
type: "record",
|
|
928
|
+
keyType: k,
|
|
929
|
+
valueType,
|
|
930
|
+
...util.normalizeParams(params)
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
const ZodMap = /* @__PURE__ */ core.$constructor("ZodMap", (inst, def) => {
|
|
934
|
+
const coreInit = core.$ZodMap.init;
|
|
935
|
+
coreInit(inst, def);
|
|
936
|
+
KrustyType.init(inst, def);
|
|
937
|
+
inst.keyType = def.keyType;
|
|
938
|
+
inst.valueType = def.valueType;
|
|
939
|
+
});
|
|
940
|
+
function map(keyType, valueType, params) {
|
|
941
|
+
return new ZodMap({
|
|
942
|
+
type: "map",
|
|
943
|
+
keyType,
|
|
944
|
+
valueType,
|
|
945
|
+
...util.normalizeParams(params)
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
const ZodSet = /* @__PURE__ */ core.$constructor("ZodSet", (inst, def) => {
|
|
949
|
+
const coreInit = core.$ZodSet.init;
|
|
950
|
+
coreInit(inst, def);
|
|
951
|
+
KrustyType.init(inst, def);
|
|
952
|
+
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
953
|
+
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
954
|
+
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
955
|
+
inst.size = (...args) => inst.check(core._size(...args));
|
|
956
|
+
});
|
|
957
|
+
function set(valueType, params) {
|
|
958
|
+
return new ZodSet({
|
|
959
|
+
type: "set",
|
|
960
|
+
valueType,
|
|
961
|
+
...util.normalizeParams(params)
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
const ZodEnum = /* @__PURE__ */ core.$constructor("ZodEnum", (inst, def) => {
|
|
965
|
+
const coreInit = core.$ZodEnum.init;
|
|
966
|
+
coreInit(inst, def);
|
|
967
|
+
KrustyType.init(inst, def);
|
|
968
|
+
inst.enum = def.entries;
|
|
969
|
+
inst.options = Object.values(def.entries);
|
|
970
|
+
const keys = new Set(Object.keys(def.entries));
|
|
971
|
+
inst.extract = (values, params) => {
|
|
972
|
+
const newEntries = {};
|
|
973
|
+
for (const value of values) {
|
|
974
|
+
if (keys.has(value)) {
|
|
975
|
+
newEntries[value] = def.entries[value];
|
|
976
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
432
977
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
978
|
+
return new ZodEnum({
|
|
979
|
+
...def,
|
|
980
|
+
checks: [],
|
|
981
|
+
...util.normalizeParams(params),
|
|
982
|
+
entries: newEntries
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
inst.exclude = (values, params) => {
|
|
986
|
+
const newEntries = { ...def.entries };
|
|
987
|
+
for (const value of values) {
|
|
988
|
+
if (keys.has(value)) {
|
|
989
|
+
delete newEntries[value];
|
|
990
|
+
} else throw new Error(`Key ${value} not found in enum`);
|
|
436
991
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
break;
|
|
472
|
-
case "includes":
|
|
473
|
-
json.pattern = escapeStringRegexp(check.value);
|
|
474
|
-
break;
|
|
475
|
-
case "startsWith":
|
|
476
|
-
json.pattern = `^${escapeStringRegexp(check.value)}`;
|
|
477
|
-
break;
|
|
478
|
-
case "endsWith":
|
|
479
|
-
json.pattern = `${escapeStringRegexp(check.value)}$`;
|
|
480
|
-
break;
|
|
481
|
-
case "emoji":
|
|
482
|
-
json.pattern = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
483
|
-
break;
|
|
484
|
-
case "nanoid":
|
|
485
|
-
json.pattern = "^[a-zA-Z0-9_-]{21}$";
|
|
486
|
-
break;
|
|
487
|
-
case "cuid2":
|
|
488
|
-
json.pattern = "^[0-9a-z]+$";
|
|
489
|
-
break;
|
|
490
|
-
case "ulid":
|
|
491
|
-
json.pattern = "^[0-9A-HJKMNP-TV-Z]{26}$";
|
|
492
|
-
break;
|
|
493
|
-
case "datetime":
|
|
494
|
-
json.format = JSONSchemaFormat.DateTime;
|
|
495
|
-
break;
|
|
496
|
-
case "date":
|
|
497
|
-
json.format = JSONSchemaFormat.Date;
|
|
498
|
-
break;
|
|
499
|
-
case "time":
|
|
500
|
-
json.format = JSONSchemaFormat.Time;
|
|
501
|
-
break;
|
|
502
|
-
case "duration":
|
|
503
|
-
json.format = JSONSchemaFormat.Duration;
|
|
504
|
-
break;
|
|
505
|
-
case "ip": {
|
|
506
|
-
if (check.version === "v4") {
|
|
507
|
-
json.format = JSONSchemaFormat.IPv4;
|
|
508
|
-
} else if (check.version === "v6") {
|
|
509
|
-
json.format = JSONSchemaFormat.IPv6;
|
|
510
|
-
} else {
|
|
511
|
-
json.anyOf = [{ format: JSONSchemaFormat.IPv4 }, { format: JSONSchemaFormat.IPv6 }];
|
|
512
|
-
}
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
case "jwt":
|
|
516
|
-
json.pattern = "^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$";
|
|
517
|
-
break;
|
|
518
|
-
case "base64url":
|
|
519
|
-
json.pattern = "^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$";
|
|
520
|
-
break;
|
|
521
|
-
default: {
|
|
522
|
-
check.kind;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return [true, json];
|
|
527
|
-
}
|
|
528
|
-
case ZodFirstPartyTypeKind.ZodNumber: {
|
|
529
|
-
const schema_ = schema;
|
|
530
|
-
const json = { type: "number" };
|
|
531
|
-
for (const check of schema_._def.checks) {
|
|
532
|
-
switch (check.kind) {
|
|
533
|
-
case "int":
|
|
534
|
-
json.type = "integer";
|
|
535
|
-
break;
|
|
536
|
-
case "min":
|
|
537
|
-
json.minimum = check.value;
|
|
538
|
-
break;
|
|
539
|
-
case "max":
|
|
540
|
-
json.maximum = check.value;
|
|
541
|
-
break;
|
|
542
|
-
case "multipleOf":
|
|
543
|
-
json.multipleOf = check.value;
|
|
544
|
-
break;
|
|
545
|
-
default: {
|
|
546
|
-
check.kind;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return [true, json];
|
|
551
|
-
}
|
|
552
|
-
case ZodFirstPartyTypeKind.ZodBigInt: {
|
|
553
|
-
const json = {
|
|
554
|
-
type: "string",
|
|
555
|
-
pattern: "^-?[0-9]+$",
|
|
556
|
-
"x-native-type": JsonSchemaXNativeType.BigInt
|
|
557
|
-
};
|
|
558
|
-
return [true, json];
|
|
559
|
-
}
|
|
560
|
-
case ZodFirstPartyTypeKind.ZodNaN: {
|
|
561
|
-
return options.strategy === "input" ? [true, this.unsupportedJsonSchema] : [true, { type: "null" }];
|
|
562
|
-
}
|
|
563
|
-
case ZodFirstPartyTypeKind.ZodBoolean: {
|
|
564
|
-
return [true, { type: "boolean" }];
|
|
565
|
-
}
|
|
566
|
-
case ZodFirstPartyTypeKind.ZodDate: {
|
|
567
|
-
const schema2 = {
|
|
568
|
-
type: "string",
|
|
569
|
-
format: JSONSchemaFormat.DateTime,
|
|
570
|
-
"x-native-type": JsonSchemaXNativeType.Date
|
|
571
|
-
};
|
|
572
|
-
return [true, schema2];
|
|
573
|
-
}
|
|
574
|
-
case ZodFirstPartyTypeKind.ZodNull: {
|
|
575
|
-
return [true, { type: "null" }];
|
|
576
|
-
}
|
|
577
|
-
case ZodFirstPartyTypeKind.ZodLiteral: {
|
|
578
|
-
const schema_ = schema;
|
|
579
|
-
if (schema_._def.value === void 0) {
|
|
580
|
-
return [false, this.unsupportedJsonSchema];
|
|
581
|
-
}
|
|
582
|
-
return [true, { const: schema_._def.value }];
|
|
583
|
-
}
|
|
584
|
-
case ZodFirstPartyTypeKind.ZodVoid:
|
|
585
|
-
case ZodFirstPartyTypeKind.ZodUndefined: {
|
|
586
|
-
return [false, this.unsupportedJsonSchema];
|
|
587
|
-
}
|
|
588
|
-
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
589
|
-
case ZodFirstPartyTypeKind.ZodAny: {
|
|
590
|
-
return [false, this.anyJsonSchema];
|
|
591
|
-
}
|
|
592
|
-
case ZodFirstPartyTypeKind.ZodEnum: {
|
|
593
|
-
const schema_ = schema;
|
|
594
|
-
return [true, { enum: schema_._def.values }];
|
|
595
|
-
}
|
|
596
|
-
case ZodFirstPartyTypeKind.ZodNativeEnum: {
|
|
597
|
-
const schema_ = schema;
|
|
598
|
-
return [true, { enum: Object.values(schema_._def.values) }];
|
|
599
|
-
}
|
|
600
|
-
case ZodFirstPartyTypeKind.ZodArray: {
|
|
601
|
-
const schema_ = schema;
|
|
602
|
-
const def2 = schema_._def;
|
|
603
|
-
const json = { type: "array" };
|
|
604
|
-
const [itemRequired, itemJson] = this.convert(
|
|
605
|
-
def2.type,
|
|
606
|
-
options,
|
|
607
|
-
lazyDepth,
|
|
608
|
-
false,
|
|
609
|
-
false,
|
|
610
|
-
structureDepth + 1
|
|
611
|
-
);
|
|
612
|
-
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
|
613
|
-
if (def2.exactLength) {
|
|
614
|
-
json.maxItems = def2.exactLength.value;
|
|
615
|
-
json.minItems = def2.exactLength.value;
|
|
616
|
-
}
|
|
617
|
-
if (def2.minLength) {
|
|
618
|
-
json.minItems = def2.minLength.value;
|
|
619
|
-
}
|
|
620
|
-
if (def2.maxLength) {
|
|
621
|
-
json.maxItems = def2.maxLength.value;
|
|
992
|
+
return new ZodEnum({
|
|
993
|
+
...def,
|
|
994
|
+
checks: [],
|
|
995
|
+
...util.normalizeParams(params),
|
|
996
|
+
entries: newEntries
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
});
|
|
1000
|
+
function _enum(values, params) {
|
|
1001
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1002
|
+
return new ZodEnum({
|
|
1003
|
+
type: "enum",
|
|
1004
|
+
entries,
|
|
1005
|
+
...util.normalizeParams(params)
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
function nativeEnum(entries, params) {
|
|
1009
|
+
return new ZodEnum({
|
|
1010
|
+
type: "enum",
|
|
1011
|
+
entries,
|
|
1012
|
+
...util.normalizeParams(params)
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
const ZodLiteral = /* @__PURE__ */ core.$constructor(
|
|
1016
|
+
"ZodLiteral",
|
|
1017
|
+
(inst, def) => {
|
|
1018
|
+
const coreInit = core.$ZodLiteral.init;
|
|
1019
|
+
coreInit(inst, def);
|
|
1020
|
+
KrustyType.init(inst, def);
|
|
1021
|
+
inst.values = new Set(def.values);
|
|
1022
|
+
Object.defineProperty(inst, "value", {
|
|
1023
|
+
get() {
|
|
1024
|
+
if (def.values.length > 1) {
|
|
1025
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
622
1026
|
}
|
|
623
|
-
return [
|
|
1027
|
+
return def.values[0];
|
|
624
1028
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
);
|
|
1032
|
+
function literal(value, params) {
|
|
1033
|
+
return new ZodLiteral({
|
|
1034
|
+
type: "literal",
|
|
1035
|
+
values: Array.isArray(value) ? value : [value],
|
|
1036
|
+
...util.normalizeParams(params)
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
const ZodFile = /* @__PURE__ */ core.$constructor("ZodFile", (inst, def) => {
|
|
1040
|
+
const coreInit = core.$ZodFile.init;
|
|
1041
|
+
coreInit(inst, def);
|
|
1042
|
+
KrustyType.init(inst, def);
|
|
1043
|
+
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
1044
|
+
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
1045
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
1046
|
+
});
|
|
1047
|
+
function file(params) {
|
|
1048
|
+
return core._file(ZodFile, params);
|
|
1049
|
+
}
|
|
1050
|
+
const ZodTransform = /* @__PURE__ */ core.$constructor(
|
|
1051
|
+
"ZodTransform",
|
|
1052
|
+
(inst, def) => {
|
|
1053
|
+
const coreInit = core.$ZodTransform.init;
|
|
1054
|
+
coreInit(inst, def);
|
|
1055
|
+
KrustyType.init(inst, def);
|
|
1056
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1057
|
+
if (_ctx.direction === "backward") {
|
|
1058
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
655
1059
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
const properties = {};
|
|
660
|
-
const required = [];
|
|
661
|
-
for (const [key, value] of Object.entries(schema_.shape)) {
|
|
662
|
-
const [itemRequired, itemJson] = this.convert(
|
|
663
|
-
value,
|
|
664
|
-
options,
|
|
665
|
-
lazyDepth,
|
|
666
|
-
false,
|
|
667
|
-
false,
|
|
668
|
-
structureDepth + 1
|
|
669
|
-
);
|
|
670
|
-
properties[key] = itemJson;
|
|
671
|
-
if (itemRequired) {
|
|
672
|
-
required.push(key);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
if (Object.keys(properties).length) {
|
|
676
|
-
json.properties = properties;
|
|
677
|
-
}
|
|
678
|
-
if (required.length) {
|
|
679
|
-
json.required = required;
|
|
680
|
-
}
|
|
681
|
-
const catchAllTypeName = this.#getZodTypeName(schema_._def.catchall._def);
|
|
682
|
-
if (catchAllTypeName === ZodFirstPartyTypeKind.ZodNever) {
|
|
683
|
-
if (schema_._def.unknownKeys === "strict") {
|
|
684
|
-
json.additionalProperties = false;
|
|
685
|
-
}
|
|
1060
|
+
payload.addIssue = (issue) => {
|
|
1061
|
+
if (typeof issue === "string") {
|
|
1062
|
+
payload.issues.push(util.issue(issue, payload.value, def));
|
|
686
1063
|
} else {
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
structureDepth + 1
|
|
694
|
-
);
|
|
695
|
-
json.additionalProperties = addJson;
|
|
696
|
-
}
|
|
697
|
-
return [true, json];
|
|
698
|
-
}
|
|
699
|
-
case ZodFirstPartyTypeKind.ZodRecord: {
|
|
700
|
-
const schema_ = schema;
|
|
701
|
-
const json = { type: "object" };
|
|
702
|
-
const [__, keyJson] = this.convert(
|
|
703
|
-
schema_._def.keyType,
|
|
704
|
-
options,
|
|
705
|
-
lazyDepth,
|
|
706
|
-
false,
|
|
707
|
-
false,
|
|
708
|
-
structureDepth + 1
|
|
709
|
-
);
|
|
710
|
-
if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
|
|
711
|
-
json.propertyNames = keyJson;
|
|
712
|
-
}
|
|
713
|
-
const [_, itemJson] = this.convert(
|
|
714
|
-
schema_._def.valueType,
|
|
715
|
-
options,
|
|
716
|
-
lazyDepth,
|
|
717
|
-
false,
|
|
718
|
-
false,
|
|
719
|
-
structureDepth + 1
|
|
720
|
-
);
|
|
721
|
-
json.additionalProperties = itemJson;
|
|
722
|
-
return [true, json];
|
|
723
|
-
}
|
|
724
|
-
case ZodFirstPartyTypeKind.ZodSet: {
|
|
725
|
-
const schema_ = schema;
|
|
726
|
-
const json = {
|
|
727
|
-
type: "array",
|
|
728
|
-
uniqueItems: true,
|
|
729
|
-
"x-native-type": JsonSchemaXNativeType.Set
|
|
730
|
-
};
|
|
731
|
-
const [itemRequired, itemJson] = this.convert(
|
|
732
|
-
schema_._def.valueType,
|
|
733
|
-
options,
|
|
734
|
-
lazyDepth,
|
|
735
|
-
false,
|
|
736
|
-
false,
|
|
737
|
-
structureDepth + 1
|
|
738
|
-
);
|
|
739
|
-
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
|
740
|
-
return [true, json];
|
|
741
|
-
}
|
|
742
|
-
case ZodFirstPartyTypeKind.ZodMap: {
|
|
743
|
-
const schema_ = schema;
|
|
744
|
-
const [keyRequired, keyJson] = this.convert(
|
|
745
|
-
schema_._def.keyType,
|
|
746
|
-
options,
|
|
747
|
-
lazyDepth,
|
|
748
|
-
false,
|
|
749
|
-
false,
|
|
750
|
-
structureDepth + 1
|
|
751
|
-
);
|
|
752
|
-
const [valueRequired, valueJson] = this.convert(
|
|
753
|
-
schema_._def.valueType,
|
|
754
|
-
options,
|
|
755
|
-
lazyDepth,
|
|
756
|
-
false,
|
|
757
|
-
false,
|
|
758
|
-
structureDepth + 1
|
|
759
|
-
);
|
|
760
|
-
const json = {
|
|
761
|
-
type: "array",
|
|
762
|
-
items: {
|
|
763
|
-
type: "array",
|
|
764
|
-
prefixItems: [
|
|
765
|
-
this.#toArrayItemJsonSchema(keyRequired, keyJson, options.strategy),
|
|
766
|
-
this.#toArrayItemJsonSchema(valueRequired, valueJson, options.strategy)
|
|
767
|
-
],
|
|
768
|
-
maxItems: 2,
|
|
769
|
-
minItems: 2
|
|
770
|
-
},
|
|
771
|
-
"x-native-type": JsonSchemaXNativeType.Map
|
|
772
|
-
};
|
|
773
|
-
return [true, json];
|
|
774
|
-
}
|
|
775
|
-
case ZodFirstPartyTypeKind.ZodUnion:
|
|
776
|
-
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
|
777
|
-
const schema_ = schema;
|
|
778
|
-
const anyOf = [];
|
|
779
|
-
let required = true;
|
|
780
|
-
for (const item of schema_._def.options) {
|
|
781
|
-
const [itemRequired, itemJson] = this.convert(
|
|
782
|
-
item,
|
|
783
|
-
options,
|
|
784
|
-
lazyDepth,
|
|
785
|
-
false,
|
|
786
|
-
false,
|
|
787
|
-
structureDepth
|
|
788
|
-
);
|
|
789
|
-
if (!itemRequired) {
|
|
790
|
-
required = false;
|
|
791
|
-
if (itemJson !== this.unsupportedJsonSchema) {
|
|
792
|
-
anyOf.push(itemJson);
|
|
793
|
-
}
|
|
794
|
-
} else {
|
|
795
|
-
anyOf.push(itemJson);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
if (anyOf.length === 1) {
|
|
799
|
-
return [required, anyOf[0]];
|
|
800
|
-
}
|
|
801
|
-
return [required, { anyOf }];
|
|
802
|
-
}
|
|
803
|
-
case ZodFirstPartyTypeKind.ZodIntersection: {
|
|
804
|
-
const schema_ = schema;
|
|
805
|
-
const allOf = [];
|
|
806
|
-
let required = false;
|
|
807
|
-
for (const item of [schema_._def.left, schema_._def.right]) {
|
|
808
|
-
const [itemRequired, itemJson] = this.convert(
|
|
809
|
-
item,
|
|
810
|
-
options,
|
|
811
|
-
lazyDepth,
|
|
812
|
-
false,
|
|
813
|
-
false,
|
|
814
|
-
structureDepth
|
|
815
|
-
);
|
|
816
|
-
allOf.push(itemJson);
|
|
817
|
-
if (itemRequired) {
|
|
818
|
-
required = true;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
return [required, { allOf }];
|
|
822
|
-
}
|
|
823
|
-
case ZodFirstPartyTypeKind.ZodLazy: {
|
|
824
|
-
const currentLazyDepth = lazyDepth + 1;
|
|
825
|
-
if (currentLazyDepth > this.maxLazyDepth) {
|
|
826
|
-
return [false, this.anyJsonSchema];
|
|
827
|
-
}
|
|
828
|
-
const schema_ = schema;
|
|
829
|
-
return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
|
|
830
|
-
}
|
|
831
|
-
case ZodFirstPartyTypeKind.ZodOptional: {
|
|
832
|
-
const schema_ = schema;
|
|
833
|
-
const [_, inner] = this.convert(
|
|
834
|
-
schema_._def.innerType,
|
|
835
|
-
options,
|
|
836
|
-
lazyDepth,
|
|
837
|
-
false,
|
|
838
|
-
false,
|
|
839
|
-
structureDepth
|
|
840
|
-
);
|
|
841
|
-
return [false, inner];
|
|
842
|
-
}
|
|
843
|
-
case ZodFirstPartyTypeKind.ZodReadonly: {
|
|
844
|
-
const schema_ = schema;
|
|
845
|
-
const [required, json] = this.convert(
|
|
846
|
-
schema_._def.innerType,
|
|
847
|
-
options,
|
|
848
|
-
lazyDepth,
|
|
849
|
-
false,
|
|
850
|
-
false,
|
|
851
|
-
structureDepth
|
|
852
|
-
);
|
|
853
|
-
return [required, { ...json, readOnly: true }];
|
|
854
|
-
}
|
|
855
|
-
case ZodFirstPartyTypeKind.ZodDefault: {
|
|
856
|
-
const schema_ = schema;
|
|
857
|
-
const [_, json] = this.convert(
|
|
858
|
-
schema_._def.innerType,
|
|
859
|
-
options,
|
|
860
|
-
lazyDepth,
|
|
861
|
-
false,
|
|
862
|
-
false,
|
|
863
|
-
structureDepth
|
|
864
|
-
);
|
|
865
|
-
return [false, { default: schema_._def.defaultValue(), ...json }];
|
|
866
|
-
}
|
|
867
|
-
case ZodFirstPartyTypeKind.ZodEffects: {
|
|
868
|
-
const schema_ = schema;
|
|
869
|
-
if (schema_._def.effect.type === "transform" && options.strategy === "output") {
|
|
870
|
-
return [false, this.anyJsonSchema];
|
|
1064
|
+
const _issue = issue;
|
|
1065
|
+
if (_issue.fatal) _issue.continue = false;
|
|
1066
|
+
_issue.code ??= "custom";
|
|
1067
|
+
_issue.input ??= payload.value;
|
|
1068
|
+
_issue.inst ??= inst;
|
|
1069
|
+
payload.issues.push(util.issue(_issue));
|
|
871
1070
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
const schema_ = schema;
|
|
880
|
-
return this.convert(schema_._def.type, options, lazyDepth, false, false, structureDepth);
|
|
881
|
-
}
|
|
882
|
-
case ZodFirstPartyTypeKind.ZodPipeline: {
|
|
883
|
-
const schema_ = schema;
|
|
884
|
-
return this.convert(
|
|
885
|
-
options.strategy === "input" ? schema_._def.in : schema_._def.out,
|
|
886
|
-
options,
|
|
887
|
-
lazyDepth,
|
|
888
|
-
false,
|
|
889
|
-
false,
|
|
890
|
-
structureDepth
|
|
891
|
-
);
|
|
892
|
-
}
|
|
893
|
-
case ZodFirstPartyTypeKind.ZodNullable: {
|
|
894
|
-
const schema_ = schema;
|
|
895
|
-
const [required, json] = this.convert(
|
|
896
|
-
schema_._def.innerType,
|
|
897
|
-
options,
|
|
898
|
-
lazyDepth,
|
|
899
|
-
false,
|
|
900
|
-
false,
|
|
901
|
-
structureDepth
|
|
902
|
-
);
|
|
903
|
-
return [required, { anyOf: [json, { type: "null" }] }];
|
|
1071
|
+
};
|
|
1072
|
+
const output = def.transform(payload.value, payload);
|
|
1073
|
+
if (output instanceof Promise) {
|
|
1074
|
+
return output.then((output2) => {
|
|
1075
|
+
payload.value = output2;
|
|
1076
|
+
return payload;
|
|
1077
|
+
});
|
|
904
1078
|
}
|
|
905
|
-
|
|
906
|
-
|
|
1079
|
+
payload.value = output;
|
|
1080
|
+
return payload;
|
|
1081
|
+
};
|
|
907
1082
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1083
|
+
);
|
|
1084
|
+
function transform(fn) {
|
|
1085
|
+
return new ZodTransform({
|
|
1086
|
+
type: "transform",
|
|
1087
|
+
transform: fn
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
const ZodOptional = /* @__PURE__ */ core.$constructor(
|
|
1091
|
+
"ZodOptional",
|
|
1092
|
+
(inst, def) => {
|
|
1093
|
+
const coreInit = core.$ZodOptional.init;
|
|
1094
|
+
coreInit(inst, def);
|
|
1095
|
+
KrustyType.init(inst, def);
|
|
1096
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1097
|
+
}
|
|
1098
|
+
);
|
|
1099
|
+
function optional(innerType) {
|
|
1100
|
+
return new ZodOptional({
|
|
1101
|
+
type: "optional",
|
|
1102
|
+
innerType
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
const ZodNullable = /* @__PURE__ */ core.$constructor(
|
|
1106
|
+
"ZodNullable",
|
|
1107
|
+
(inst, def) => {
|
|
1108
|
+
const coreInit = core.$ZodNullable.init;
|
|
1109
|
+
coreInit(inst, def);
|
|
1110
|
+
KrustyType.init(inst, def);
|
|
1111
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1112
|
+
}
|
|
1113
|
+
);
|
|
1114
|
+
function nullable(innerType) {
|
|
1115
|
+
return new ZodNullable({
|
|
1116
|
+
type: "nullable",
|
|
1117
|
+
innerType
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
function nullish(innerType) {
|
|
1121
|
+
return optional(nullable(innerType));
|
|
1122
|
+
}
|
|
1123
|
+
const ZodDefault = /* @__PURE__ */ core.$constructor(
|
|
1124
|
+
"ZodDefault",
|
|
1125
|
+
(inst, def) => {
|
|
1126
|
+
const coreInit = core.$ZodDefault.init;
|
|
1127
|
+
coreInit(inst, def);
|
|
1128
|
+
KrustyType.init(inst, def);
|
|
1129
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1130
|
+
inst.removeDefault = inst.unwrap;
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
1133
|
+
function _default(innerType, defaultValue) {
|
|
1134
|
+
return new ZodDefault({
|
|
1135
|
+
type: "default",
|
|
1136
|
+
innerType,
|
|
1137
|
+
get defaultValue() {
|
|
1138
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
912
1139
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
format: JSONSchemaFormat.URI,
|
|
931
|
-
"x-native-type": JsonSchemaXNativeType.Url
|
|
932
|
-
};
|
|
933
|
-
}
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
const ZodPrefault = /* @__PURE__ */ core.$constructor(
|
|
1143
|
+
"ZodPrefault",
|
|
1144
|
+
(inst, def) => {
|
|
1145
|
+
const coreInit = core.$ZodPrefault.init;
|
|
1146
|
+
coreInit(inst, def);
|
|
1147
|
+
KrustyType.init(inst, def);
|
|
1148
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1149
|
+
}
|
|
1150
|
+
);
|
|
1151
|
+
function prefault(innerType, defaultValue) {
|
|
1152
|
+
return new ZodPrefault({
|
|
1153
|
+
type: "prefault",
|
|
1154
|
+
innerType,
|
|
1155
|
+
get defaultValue() {
|
|
1156
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
934
1157
|
}
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
const ZodNonOptional = /* @__PURE__ */ core.$constructor(
|
|
1161
|
+
"ZodNonOptional",
|
|
1162
|
+
(inst, def) => {
|
|
1163
|
+
const coreInit = core.$ZodNonOptional.init;
|
|
1164
|
+
coreInit(inst, def);
|
|
1165
|
+
KrustyType.init(inst, def);
|
|
1166
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
935
1167
|
}
|
|
936
|
-
|
|
937
|
-
|
|
1168
|
+
);
|
|
1169
|
+
function nonoptional(innerType, params) {
|
|
1170
|
+
return new ZodNonOptional({
|
|
1171
|
+
type: "nonoptional",
|
|
1172
|
+
innerType,
|
|
1173
|
+
...util.normalizeParams(params)
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
const ZodSuccess = /* @__PURE__ */ core.$constructor(
|
|
1177
|
+
"ZodSuccess",
|
|
1178
|
+
(inst, def) => {
|
|
1179
|
+
const coreInit = core.$ZodSuccess.init;
|
|
1180
|
+
coreInit(inst, def);
|
|
1181
|
+
KrustyType.init(inst, def);
|
|
1182
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
938
1183
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1184
|
+
);
|
|
1185
|
+
function success(innerType) {
|
|
1186
|
+
return new ZodSuccess({
|
|
1187
|
+
type: "success",
|
|
1188
|
+
innerType
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
const ZodCatch = /* @__PURE__ */ core.$constructor(
|
|
1192
|
+
"ZodCatch",
|
|
1193
|
+
(inst, def) => {
|
|
1194
|
+
const coreInit = core.$ZodCatch.init;
|
|
1195
|
+
coreInit(inst, def);
|
|
1196
|
+
KrustyType.init(inst, def);
|
|
1197
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1198
|
+
inst.removeCatch = inst.unwrap;
|
|
1199
|
+
}
|
|
1200
|
+
);
|
|
1201
|
+
function _catch(innerType, catchValue) {
|
|
1202
|
+
return new ZodCatch({
|
|
1203
|
+
type: "catch",
|
|
1204
|
+
innerType,
|
|
1205
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
const ZodNaN = /* @__PURE__ */ core.$constructor("ZodNaN", (inst, def) => {
|
|
1209
|
+
const coreInit = core.$ZodNaN.init;
|
|
1210
|
+
coreInit(inst, def);
|
|
1211
|
+
KrustyType.init(inst, def);
|
|
1212
|
+
});
|
|
1213
|
+
function nan(params) {
|
|
1214
|
+
return core._nan(ZodNaN, params);
|
|
1215
|
+
}
|
|
1216
|
+
const ZodPipe = /* @__PURE__ */ core.$constructor("ZodPipe", (inst, def) => {
|
|
1217
|
+
const coreInit = core.$ZodPipe.init;
|
|
1218
|
+
coreInit(inst, def);
|
|
1219
|
+
KrustyType.init(inst, def);
|
|
1220
|
+
inst.in = def.in;
|
|
1221
|
+
inst.out = def.out;
|
|
1222
|
+
});
|
|
1223
|
+
function pipe(in_, out) {
|
|
1224
|
+
return new ZodPipe({
|
|
1225
|
+
type: "pipe",
|
|
1226
|
+
in: in_,
|
|
1227
|
+
out
|
|
1228
|
+
// ...util.normalizeParams(params),
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
const ZodCodec = /* @__PURE__ */ core.$constructor(
|
|
1232
|
+
"ZodCodec",
|
|
1233
|
+
(inst, def) => {
|
|
1234
|
+
ZodPipe.init(inst, def);
|
|
1235
|
+
const coreInit = core.$ZodCodec.init;
|
|
1236
|
+
coreInit(inst, def);
|
|
1237
|
+
}
|
|
1238
|
+
);
|
|
1239
|
+
function codec(in_, out, params) {
|
|
1240
|
+
return new ZodCodec({
|
|
1241
|
+
type: "pipe",
|
|
1242
|
+
in: in_,
|
|
1243
|
+
out,
|
|
1244
|
+
transform: params.decode,
|
|
1245
|
+
reverseTransform: params.encode
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
const ZodReadonly = /* @__PURE__ */ core.$constructor(
|
|
1249
|
+
"ZodReadonly",
|
|
1250
|
+
(inst, def) => {
|
|
1251
|
+
const coreInit = core.$ZodReadonly.init;
|
|
1252
|
+
coreInit(inst, def);
|
|
1253
|
+
KrustyType.init(inst, def);
|
|
1254
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1255
|
+
}
|
|
1256
|
+
);
|
|
1257
|
+
function readonly(innerType) {
|
|
1258
|
+
return new ZodReadonly({
|
|
1259
|
+
type: "readonly",
|
|
1260
|
+
innerType
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
const ZodTemplateLiteral = /* @__PURE__ */ core.$constructor(
|
|
1264
|
+
"ZodTemplateLiteral",
|
|
1265
|
+
(inst, def) => {
|
|
1266
|
+
const coreInit = core.$ZodTemplateLiteral.init;
|
|
1267
|
+
coreInit(inst, def);
|
|
1268
|
+
KrustyType.init(inst, def);
|
|
944
1269
|
}
|
|
1270
|
+
);
|
|
1271
|
+
function templateLiteral(parts, params) {
|
|
1272
|
+
return new ZodTemplateLiteral({
|
|
1273
|
+
type: "template_literal",
|
|
1274
|
+
parts,
|
|
1275
|
+
...util.normalizeParams(params)
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
const ZodLazy = /* @__PURE__ */ core.$constructor("ZodLazy", (inst, def) => {
|
|
1279
|
+
const coreInit = core.$ZodLazy.init;
|
|
1280
|
+
coreInit(inst, def);
|
|
1281
|
+
KrustyType.init(inst, def);
|
|
1282
|
+
inst.unwrap = () => inst._zod.def.getter();
|
|
1283
|
+
});
|
|
1284
|
+
function lazy(getter) {
|
|
1285
|
+
return new ZodLazy({
|
|
1286
|
+
type: "lazy",
|
|
1287
|
+
getter
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
const ZodPromise = /* @__PURE__ */ core.$constructor(
|
|
1291
|
+
"ZodPromise",
|
|
1292
|
+
(inst, def) => {
|
|
1293
|
+
const coreInit = core.$ZodPromise.init;
|
|
1294
|
+
coreInit(inst, def);
|
|
1295
|
+
KrustyType.init(inst, def);
|
|
1296
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1297
|
+
}
|
|
1298
|
+
);
|
|
1299
|
+
function promise(innerType) {
|
|
1300
|
+
return new ZodPromise({
|
|
1301
|
+
type: "promise",
|
|
1302
|
+
innerType
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
const ZodFunction = /* @__PURE__ */ core.$constructor(
|
|
1306
|
+
"ZodFunction",
|
|
1307
|
+
(inst, def) => {
|
|
1308
|
+
const coreInit = core.$ZodFunction.init;
|
|
1309
|
+
coreInit(inst, def);
|
|
1310
|
+
KrustyType.init(inst, def);
|
|
1311
|
+
}
|
|
1312
|
+
);
|
|
1313
|
+
function _function(params) {
|
|
1314
|
+
return new ZodFunction({
|
|
1315
|
+
type: "function",
|
|
1316
|
+
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
|
|
1317
|
+
output: params?.output ?? unknown()
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
const ZodCustom = /* @__PURE__ */ core.$constructor(
|
|
1321
|
+
"ZodCustom",
|
|
1322
|
+
(inst, def) => {
|
|
1323
|
+
const coreInit = core.$ZodCustom.init;
|
|
1324
|
+
coreInit(inst, def);
|
|
1325
|
+
KrustyType.init(inst, def);
|
|
1326
|
+
}
|
|
1327
|
+
);
|
|
1328
|
+
function check(fn) {
|
|
1329
|
+
const ch = new core.$ZodCheck({
|
|
1330
|
+
check: "custom"
|
|
1331
|
+
// ...util.normalizeParams(params),
|
|
1332
|
+
});
|
|
1333
|
+
ch._zod.check = fn;
|
|
1334
|
+
return ch;
|
|
1335
|
+
}
|
|
1336
|
+
function custom(fn, _params) {
|
|
1337
|
+
return core._custom(ZodCustom, fn ?? (() => true), _params);
|
|
1338
|
+
}
|
|
1339
|
+
function refine(fn, _params = {}) {
|
|
1340
|
+
return core._refine(ZodCustom, fn, _params);
|
|
1341
|
+
}
|
|
1342
|
+
function superRefine(fn) {
|
|
1343
|
+
return core._superRefine(fn);
|
|
1344
|
+
}
|
|
1345
|
+
function _instanceof(cls, params = {
|
|
1346
|
+
error: `Input not instance of ${cls.name}`
|
|
1347
|
+
}) {
|
|
1348
|
+
const inst = new ZodCustom({
|
|
1349
|
+
type: "custom",
|
|
1350
|
+
check: "custom",
|
|
1351
|
+
fn: (data) => data instanceof cls,
|
|
1352
|
+
abort: true,
|
|
1353
|
+
...util.normalizeParams(params)
|
|
1354
|
+
});
|
|
1355
|
+
inst._zod.bag.Class = cls;
|
|
1356
|
+
return inst;
|
|
1357
|
+
}
|
|
1358
|
+
const stringbool = (...args) => core._stringbool(
|
|
1359
|
+
{
|
|
1360
|
+
Codec: ZodCodec,
|
|
1361
|
+
Boolean: ZodBoolean,
|
|
1362
|
+
String: ZodString
|
|
1363
|
+
},
|
|
1364
|
+
...args
|
|
1365
|
+
);
|
|
1366
|
+
function json(params) {
|
|
1367
|
+
const jsonSchema = lazy(() => {
|
|
1368
|
+
return union([
|
|
1369
|
+
string(params),
|
|
1370
|
+
number(),
|
|
1371
|
+
boolean(),
|
|
1372
|
+
_null(),
|
|
1373
|
+
array(jsonSchema),
|
|
1374
|
+
record(string(), jsonSchema)
|
|
1375
|
+
]);
|
|
1376
|
+
});
|
|
1377
|
+
return jsonSchema;
|
|
1378
|
+
}
|
|
1379
|
+
function preprocess(fn, schema) {
|
|
1380
|
+
return pipe(transform(fn), schema);
|
|
945
1381
|
}
|
|
946
1382
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
1383
|
+
class SchemaClass {
|
|
1384
|
+
string(params) {
|
|
1385
|
+
return string(params);
|
|
1386
|
+
}
|
|
1387
|
+
number(params) {
|
|
1388
|
+
return number(params);
|
|
1389
|
+
}
|
|
1390
|
+
int(params) {
|
|
1391
|
+
return this.number().int(params);
|
|
1392
|
+
}
|
|
1393
|
+
boolean(params) {
|
|
1394
|
+
return boolean(params);
|
|
1395
|
+
}
|
|
1396
|
+
null(params) {
|
|
1397
|
+
return _null(params);
|
|
1398
|
+
}
|
|
1399
|
+
array(element, params) {
|
|
1400
|
+
return array(element, params);
|
|
1401
|
+
}
|
|
1402
|
+
record(keyType, valueType, params) {
|
|
1403
|
+
return record(keyType, valueType, params);
|
|
1404
|
+
}
|
|
1405
|
+
union(options, params) {
|
|
1406
|
+
return union(options, params);
|
|
1407
|
+
}
|
|
1408
|
+
discriminatedUnion(discriminator, options, params) {
|
|
1409
|
+
return discriminatedUnion(discriminator, options, params);
|
|
1410
|
+
}
|
|
1411
|
+
object(shape, params) {
|
|
1412
|
+
return object(shape, params);
|
|
1413
|
+
}
|
|
1414
|
+
// TODO: make this a codec?
|
|
1415
|
+
date(params) {
|
|
1416
|
+
return date(params);
|
|
1417
|
+
}
|
|
1418
|
+
any() {
|
|
1419
|
+
return any();
|
|
1420
|
+
}
|
|
1421
|
+
unknown() {
|
|
1422
|
+
return unknown();
|
|
1423
|
+
}
|
|
1424
|
+
never(params) {
|
|
1425
|
+
return never(params);
|
|
1426
|
+
}
|
|
1427
|
+
lazy(getter) {
|
|
1428
|
+
return lazy(getter);
|
|
1429
|
+
}
|
|
1430
|
+
json(params) {
|
|
1431
|
+
return json(params);
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* TODO: def need to expose
|
|
1435
|
+
* file
|
|
1436
|
+
* literal
|
|
1437
|
+
* nativeEnum
|
|
1438
|
+
*/
|
|
1439
|
+
/**
|
|
1440
|
+
* TODO: decide how to handle non-serializeable values
|
|
1441
|
+
* TODO: decide what types to expose
|
|
1442
|
+
* function
|
|
1443
|
+
* promise
|
|
1444
|
+
* readonly
|
|
1445
|
+
* nan
|
|
1446
|
+
* success
|
|
1447
|
+
* set
|
|
1448
|
+
* map
|
|
1449
|
+
* partialRecord
|
|
1450
|
+
* tuple
|
|
1451
|
+
* intersection
|
|
1452
|
+
* keyof
|
|
1453
|
+
* symbol
|
|
1454
|
+
* bigint
|
|
1455
|
+
* blob
|
|
1456
|
+
*/
|
|
1457
|
+
/**
|
|
1458
|
+
* TODO: decide what non-chained format helpers to expose
|
|
1459
|
+
* -- OBJECT
|
|
1460
|
+
* strictObject
|
|
1461
|
+
* looseObject
|
|
1462
|
+
* -- STRING
|
|
1463
|
+
* url
|
|
1464
|
+
* regexp
|
|
1465
|
+
* email
|
|
1466
|
+
* guid
|
|
1467
|
+
* uuid
|
|
1468
|
+
* uuidv4
|
|
1469
|
+
* uuidv6
|
|
1470
|
+
* uuidv7
|
|
1471
|
+
* url
|
|
1472
|
+
* httpUrl
|
|
1473
|
+
* emoji
|
|
1474
|
+
* nanoid
|
|
1475
|
+
* cuid
|
|
1476
|
+
* cuid2
|
|
1477
|
+
* ulid
|
|
1478
|
+
* xid
|
|
1479
|
+
* ksuid
|
|
1480
|
+
* jwt
|
|
1481
|
+
* hostname
|
|
1482
|
+
* hex
|
|
1483
|
+
* hash
|
|
1484
|
+
* ipv4
|
|
1485
|
+
* ipv6
|
|
1486
|
+
* cidrv4
|
|
1487
|
+
* cidrv6
|
|
1488
|
+
* base64
|
|
1489
|
+
* base64url
|
|
1490
|
+
* e164
|
|
1491
|
+
* -- NUMBER
|
|
1492
|
+
* float32
|
|
1493
|
+
* float64
|
|
1494
|
+
* int32
|
|
1495
|
+
* uint32
|
|
1496
|
+
* int64
|
|
1497
|
+
* uint64
|
|
1498
|
+
*/
|
|
1499
|
+
/**
|
|
1500
|
+
* TODO: decide what other helper methods to expose
|
|
1501
|
+
* preprocess
|
|
1502
|
+
* refine
|
|
1503
|
+
* superRefine
|
|
1504
|
+
* custom
|
|
1505
|
+
* check
|
|
1506
|
+
* codec
|
|
1507
|
+
* pipe
|
|
1508
|
+
* nonoptional
|
|
1509
|
+
* prefault
|
|
1510
|
+
* default
|
|
1511
|
+
* nullish
|
|
1512
|
+
* nullable
|
|
1513
|
+
* optional
|
|
1514
|
+
* transform
|
|
1515
|
+
* stringFormat
|
|
1516
|
+
*/
|
|
1517
|
+
}
|
|
954
1518
|
|
|
955
|
-
export {
|
|
1519
|
+
export { KrustyType, SchemaClass, ZodAny, ZodArray, ZodBase64, ZodBase64URL, ZodBigInt, ZodBigIntFormat, ZodBoolean, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCodec, ZodCustom, ZodCustomStringFormat, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodError, ZodFile, ZodFunction, ZodGUID, ZodGate, ZodIPv4, ZodIPv6, ZodIntersection, ZodJWT, ZodKSUID, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNanoID, ZodNever, ZodNonOptional, ZodNull, ZodNullable, ZodNumber, ZodNumberFormat, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodPromise, ZodReadonly, ZodRealError, ZodRecord, ZodSet, ZodString, ZodStringFormat, ZodSuccess, ZodSymbol, ZodTemplateLiteral, ZodTransform, ZodTuple, ZodULID, ZodURL, ZodUUID, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, ZodXID, _ZodString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, preprocess, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|