dune-react 0.0.32 → 0.0.33
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/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 +3 -2
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { process } from "./to-json-schema.js";
|
|
2
|
+
import { getEnumValues } from "./util.js";
|
|
3
|
+
const formatMap = {
|
|
4
|
+
guid: "uuid",
|
|
5
|
+
url: "uri",
|
|
6
|
+
datetime: "date-time",
|
|
7
|
+
json_string: "json-string",
|
|
8
|
+
regex: ""
|
|
9
|
+
// do not set
|
|
10
|
+
};
|
|
11
|
+
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
12
|
+
const json = _json;
|
|
13
|
+
json.type = "string";
|
|
14
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
15
|
+
if (typeof minimum === "number")
|
|
16
|
+
json.minLength = minimum;
|
|
17
|
+
if (typeof maximum === "number")
|
|
18
|
+
json.maxLength = maximum;
|
|
19
|
+
if (format) {
|
|
20
|
+
json.format = formatMap[format] ?? format;
|
|
21
|
+
if (json.format === "")
|
|
22
|
+
delete json.format;
|
|
23
|
+
if (format === "time") {
|
|
24
|
+
delete json.format;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (contentEncoding)
|
|
28
|
+
json.contentEncoding = contentEncoding;
|
|
29
|
+
if (patterns && patterns.size > 0) {
|
|
30
|
+
const regexes = [...patterns];
|
|
31
|
+
if (regexes.length === 1)
|
|
32
|
+
json.pattern = regexes[0].source;
|
|
33
|
+
else if (regexes.length > 1) {
|
|
34
|
+
json.allOf = [
|
|
35
|
+
...regexes.map((regex) => ({
|
|
36
|
+
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
37
|
+
pattern: regex.source
|
|
38
|
+
}))
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
44
|
+
const json = _json;
|
|
45
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
46
|
+
if (typeof format === "string" && format.includes("int"))
|
|
47
|
+
json.type = "integer";
|
|
48
|
+
else
|
|
49
|
+
json.type = "number";
|
|
50
|
+
if (typeof exclusiveMinimum === "number") {
|
|
51
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
52
|
+
json.minimum = exclusiveMinimum;
|
|
53
|
+
json.exclusiveMinimum = true;
|
|
54
|
+
} else {
|
|
55
|
+
json.exclusiveMinimum = exclusiveMinimum;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (typeof minimum === "number") {
|
|
59
|
+
json.minimum = minimum;
|
|
60
|
+
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
61
|
+
if (exclusiveMinimum >= minimum)
|
|
62
|
+
delete json.minimum;
|
|
63
|
+
else
|
|
64
|
+
delete json.exclusiveMinimum;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (typeof exclusiveMaximum === "number") {
|
|
68
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
69
|
+
json.maximum = exclusiveMaximum;
|
|
70
|
+
json.exclusiveMaximum = true;
|
|
71
|
+
} else {
|
|
72
|
+
json.exclusiveMaximum = exclusiveMaximum;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (typeof maximum === "number") {
|
|
76
|
+
json.maximum = maximum;
|
|
77
|
+
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
78
|
+
if (exclusiveMaximum <= maximum)
|
|
79
|
+
delete json.maximum;
|
|
80
|
+
else
|
|
81
|
+
delete json.exclusiveMaximum;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (typeof multipleOf === "number")
|
|
85
|
+
json.multipleOf = multipleOf;
|
|
86
|
+
};
|
|
87
|
+
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
88
|
+
json.not = {};
|
|
89
|
+
};
|
|
90
|
+
const anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
91
|
+
};
|
|
92
|
+
const unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
93
|
+
};
|
|
94
|
+
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
95
|
+
const def = schema._zod.def;
|
|
96
|
+
const values = getEnumValues(def.entries);
|
|
97
|
+
if (values.every((v) => typeof v === "number"))
|
|
98
|
+
json.type = "number";
|
|
99
|
+
if (values.every((v) => typeof v === "string"))
|
|
100
|
+
json.type = "string";
|
|
101
|
+
json.enum = values;
|
|
102
|
+
};
|
|
103
|
+
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
104
|
+
if (ctx.unrepresentable === "throw") {
|
|
105
|
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
109
|
+
if (ctx.unrepresentable === "throw") {
|
|
110
|
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
114
|
+
const json = _json;
|
|
115
|
+
const def = schema._zod.def;
|
|
116
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
117
|
+
if (typeof minimum === "number")
|
|
118
|
+
json.minItems = minimum;
|
|
119
|
+
if (typeof maximum === "number")
|
|
120
|
+
json.maxItems = maximum;
|
|
121
|
+
json.type = "array";
|
|
122
|
+
json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
|
|
123
|
+
};
|
|
124
|
+
const objectProcessor = (schema, ctx, _json, params) => {
|
|
125
|
+
var _a;
|
|
126
|
+
const json = _json;
|
|
127
|
+
const def = schema._zod.def;
|
|
128
|
+
json.type = "object";
|
|
129
|
+
json.properties = {};
|
|
130
|
+
const shape = def.shape;
|
|
131
|
+
for (const key in shape) {
|
|
132
|
+
json.properties[key] = process(shape[key], ctx, {
|
|
133
|
+
...params,
|
|
134
|
+
path: [...params.path, "properties", key]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const allKeys = new Set(Object.keys(shape));
|
|
138
|
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
139
|
+
const v = def.shape[key]._zod;
|
|
140
|
+
if (ctx.io === "input") {
|
|
141
|
+
return v.optin === void 0;
|
|
142
|
+
} else {
|
|
143
|
+
return v.optout === void 0;
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
146
|
+
if (requiredKeys.size > 0) {
|
|
147
|
+
json.required = Array.from(requiredKeys);
|
|
148
|
+
}
|
|
149
|
+
if (((_a = def.catchall) == null ? void 0 : _a._zod.def.type) === "never") {
|
|
150
|
+
json.additionalProperties = false;
|
|
151
|
+
} else if (!def.catchall) {
|
|
152
|
+
if (ctx.io === "output")
|
|
153
|
+
json.additionalProperties = false;
|
|
154
|
+
} else if (def.catchall) {
|
|
155
|
+
json.additionalProperties = process(def.catchall, ctx, {
|
|
156
|
+
...params,
|
|
157
|
+
path: [...params.path, "additionalProperties"]
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const unionProcessor = (schema, ctx, json, params) => {
|
|
162
|
+
const def = schema._zod.def;
|
|
163
|
+
const isExclusive = def.inclusive === false;
|
|
164
|
+
const options = def.options.map((x, i) => process(x, ctx, {
|
|
165
|
+
...params,
|
|
166
|
+
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
167
|
+
}));
|
|
168
|
+
if (isExclusive) {
|
|
169
|
+
json.oneOf = options;
|
|
170
|
+
} else {
|
|
171
|
+
json.anyOf = options;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
175
|
+
const def = schema._zod.def;
|
|
176
|
+
const a = process(def.left, ctx, {
|
|
177
|
+
...params,
|
|
178
|
+
path: [...params.path, "allOf", 0]
|
|
179
|
+
});
|
|
180
|
+
const b = process(def.right, ctx, {
|
|
181
|
+
...params,
|
|
182
|
+
path: [...params.path, "allOf", 1]
|
|
183
|
+
});
|
|
184
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
185
|
+
const allOf = [
|
|
186
|
+
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
187
|
+
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
188
|
+
];
|
|
189
|
+
json.allOf = allOf;
|
|
190
|
+
};
|
|
191
|
+
const recordProcessor = (schema, ctx, _json, params) => {
|
|
192
|
+
const json = _json;
|
|
193
|
+
const def = schema._zod.def;
|
|
194
|
+
json.type = "object";
|
|
195
|
+
const keyType = def.keyType;
|
|
196
|
+
const keyBag = keyType._zod.bag;
|
|
197
|
+
const patterns = keyBag == null ? void 0 : keyBag.patterns;
|
|
198
|
+
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
199
|
+
const valueSchema = process(def.valueType, ctx, {
|
|
200
|
+
...params,
|
|
201
|
+
path: [...params.path, "patternProperties", "*"]
|
|
202
|
+
});
|
|
203
|
+
json.patternProperties = {};
|
|
204
|
+
for (const pattern of patterns) {
|
|
205
|
+
json.patternProperties[pattern.source] = valueSchema;
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
209
|
+
json.propertyNames = process(def.keyType, ctx, {
|
|
210
|
+
...params,
|
|
211
|
+
path: [...params.path, "propertyNames"]
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
json.additionalProperties = process(def.valueType, ctx, {
|
|
215
|
+
...params,
|
|
216
|
+
path: [...params.path, "additionalProperties"]
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const keyValues = keyType._zod.values;
|
|
220
|
+
if (keyValues) {
|
|
221
|
+
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
222
|
+
if (validKeyValues.length > 0) {
|
|
223
|
+
json.required = validKeyValues;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const nullableProcessor = (schema, ctx, json, params) => {
|
|
228
|
+
const def = schema._zod.def;
|
|
229
|
+
const inner = process(def.innerType, ctx, params);
|
|
230
|
+
const seen = ctx.seen.get(schema);
|
|
231
|
+
if (ctx.target === "openapi-3.0") {
|
|
232
|
+
seen.ref = def.innerType;
|
|
233
|
+
json.nullable = true;
|
|
234
|
+
} else {
|
|
235
|
+
json.anyOf = [inner, { type: "null" }];
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
239
|
+
const def = schema._zod.def;
|
|
240
|
+
process(def.innerType, ctx, params);
|
|
241
|
+
const seen = ctx.seen.get(schema);
|
|
242
|
+
seen.ref = def.innerType;
|
|
243
|
+
};
|
|
244
|
+
const defaultProcessor = (schema, ctx, json, params) => {
|
|
245
|
+
const def = schema._zod.def;
|
|
246
|
+
process(def.innerType, ctx, params);
|
|
247
|
+
const seen = ctx.seen.get(schema);
|
|
248
|
+
seen.ref = def.innerType;
|
|
249
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
250
|
+
};
|
|
251
|
+
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
252
|
+
const def = schema._zod.def;
|
|
253
|
+
process(def.innerType, ctx, params);
|
|
254
|
+
const seen = ctx.seen.get(schema);
|
|
255
|
+
seen.ref = def.innerType;
|
|
256
|
+
if (ctx.io === "input")
|
|
257
|
+
json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
258
|
+
};
|
|
259
|
+
const catchProcessor = (schema, ctx, json, params) => {
|
|
260
|
+
const def = schema._zod.def;
|
|
261
|
+
process(def.innerType, ctx, params);
|
|
262
|
+
const seen = ctx.seen.get(schema);
|
|
263
|
+
seen.ref = def.innerType;
|
|
264
|
+
let catchValue;
|
|
265
|
+
try {
|
|
266
|
+
catchValue = def.catchValue(void 0);
|
|
267
|
+
} catch {
|
|
268
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
269
|
+
}
|
|
270
|
+
json.default = catchValue;
|
|
271
|
+
};
|
|
272
|
+
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
273
|
+
const def = schema._zod.def;
|
|
274
|
+
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
275
|
+
process(innerType, ctx, params);
|
|
276
|
+
const seen = ctx.seen.get(schema);
|
|
277
|
+
seen.ref = innerType;
|
|
278
|
+
};
|
|
279
|
+
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
280
|
+
const def = schema._zod.def;
|
|
281
|
+
process(def.innerType, ctx, params);
|
|
282
|
+
const seen = ctx.seen.get(schema);
|
|
283
|
+
seen.ref = def.innerType;
|
|
284
|
+
json.readOnly = true;
|
|
285
|
+
};
|
|
286
|
+
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
287
|
+
const def = schema._zod.def;
|
|
288
|
+
process(def.innerType, ctx, params);
|
|
289
|
+
const seen = ctx.seen.get(schema);
|
|
290
|
+
seen.ref = def.innerType;
|
|
291
|
+
};
|
|
292
|
+
export {
|
|
293
|
+
anyProcessor,
|
|
294
|
+
arrayProcessor,
|
|
295
|
+
catchProcessor,
|
|
296
|
+
customProcessor,
|
|
297
|
+
defaultProcessor,
|
|
298
|
+
enumProcessor,
|
|
299
|
+
intersectionProcessor,
|
|
300
|
+
neverProcessor,
|
|
301
|
+
nonoptionalProcessor,
|
|
302
|
+
nullableProcessor,
|
|
303
|
+
numberProcessor,
|
|
304
|
+
objectProcessor,
|
|
305
|
+
optionalProcessor,
|
|
306
|
+
pipeProcessor,
|
|
307
|
+
prefaultProcessor,
|
|
308
|
+
readonlyProcessor,
|
|
309
|
+
recordProcessor,
|
|
310
|
+
stringProcessor,
|
|
311
|
+
transformProcessor,
|
|
312
|
+
unionProcessor,
|
|
313
|
+
unknownProcessor
|
|
314
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { $ZodAsyncError, config } from "./core.js";
|
|
2
|
+
import { $ZodError, $ZodRealError } from "./errors.js";
|
|
3
|
+
import { finalizeIssue, captureStackTrace } from "./util.js";
|
|
4
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
5
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
6
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
7
|
+
if (result instanceof Promise) {
|
|
8
|
+
throw new $ZodAsyncError();
|
|
9
|
+
}
|
|
10
|
+
if (result.issues.length) {
|
|
11
|
+
const e = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
12
|
+
captureStackTrace(e, _params == null ? void 0 : _params.callee);
|
|
13
|
+
throw e;
|
|
14
|
+
}
|
|
15
|
+
return result.value;
|
|
16
|
+
};
|
|
17
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
18
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
19
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
20
|
+
if (result instanceof Promise)
|
|
21
|
+
result = await result;
|
|
22
|
+
if (result.issues.length) {
|
|
23
|
+
const e = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
24
|
+
captureStackTrace(e, params == null ? void 0 : params.callee);
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
27
|
+
return result.value;
|
|
28
|
+
};
|
|
29
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
30
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
31
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
32
|
+
if (result instanceof Promise) {
|
|
33
|
+
throw new $ZodAsyncError();
|
|
34
|
+
}
|
|
35
|
+
return result.issues.length ? {
|
|
36
|
+
success: false,
|
|
37
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
38
|
+
} : { success: true, data: result.value };
|
|
39
|
+
};
|
|
40
|
+
const safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
41
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
42
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
43
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
44
|
+
if (result instanceof Promise)
|
|
45
|
+
result = await result;
|
|
46
|
+
return result.issues.length ? {
|
|
47
|
+
success: false,
|
|
48
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
49
|
+
} : { success: true, data: result.value };
|
|
50
|
+
};
|
|
51
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
52
|
+
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
53
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
54
|
+
return _parse(_Err)(schema, value, ctx);
|
|
55
|
+
};
|
|
56
|
+
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
57
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
58
|
+
};
|
|
59
|
+
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
60
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
61
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
62
|
+
};
|
|
63
|
+
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
64
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
65
|
+
};
|
|
66
|
+
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
67
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
68
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
69
|
+
};
|
|
70
|
+
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
71
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
72
|
+
};
|
|
73
|
+
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
74
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
75
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
76
|
+
};
|
|
77
|
+
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
78
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
_decode,
|
|
82
|
+
_decodeAsync,
|
|
83
|
+
_encode,
|
|
84
|
+
_encodeAsync,
|
|
85
|
+
_parse,
|
|
86
|
+
_parseAsync,
|
|
87
|
+
_safeDecode,
|
|
88
|
+
_safeDecodeAsync,
|
|
89
|
+
_safeEncode,
|
|
90
|
+
_safeEncodeAsync,
|
|
91
|
+
_safeParse,
|
|
92
|
+
_safeParseAsync,
|
|
93
|
+
safeParse,
|
|
94
|
+
safeParseAsync
|
|
95
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const cuid = /^[cC][^\s-]{8,}$/;
|
|
2
|
+
const cuid2 = /^[0-9a-z]+$/;
|
|
3
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
4
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
|
5
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
6
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
7
|
+
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
8
|
+
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
9
|
+
const uuid = (version) => {
|
|
10
|
+
if (!version)
|
|
11
|
+
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
12
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
13
|
+
};
|
|
14
|
+
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
15
|
+
const _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
16
|
+
function emoji() {
|
|
17
|
+
return new RegExp(_emoji, "u");
|
|
18
|
+
}
|
|
19
|
+
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
20
|
+
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
21
|
+
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
22
|
+
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
23
|
+
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
24
|
+
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
25
|
+
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
26
|
+
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
27
|
+
const date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
28
|
+
function timeSource(args) {
|
|
29
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
30
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
31
|
+
return regex;
|
|
32
|
+
}
|
|
33
|
+
function time(args) {
|
|
34
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
35
|
+
}
|
|
36
|
+
function datetime(args) {
|
|
37
|
+
const time2 = timeSource({ precision: args.precision });
|
|
38
|
+
const opts = ["Z"];
|
|
39
|
+
if (args.local)
|
|
40
|
+
opts.push("");
|
|
41
|
+
if (args.offset)
|
|
42
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
43
|
+
const timeRegex = `${time2}(?:${opts.join("|")})`;
|
|
44
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
45
|
+
}
|
|
46
|
+
const string = (params) => {
|
|
47
|
+
const regex = params ? `[\\s\\S]{${(params == null ? void 0 : params.minimum) ?? 0},${(params == null ? void 0 : params.maximum) ?? ""}}` : `[\\s\\S]*`;
|
|
48
|
+
return new RegExp(`^${regex}$`);
|
|
49
|
+
};
|
|
50
|
+
const integer = /^-?\d+$/;
|
|
51
|
+
const number = /^-?\d+(?:\.\d+)?$/;
|
|
52
|
+
const lowercase = /^[^A-Z]*$/;
|
|
53
|
+
const uppercase = /^[^a-z]*$/;
|
|
54
|
+
export {
|
|
55
|
+
base64,
|
|
56
|
+
base64url,
|
|
57
|
+
cidrv4,
|
|
58
|
+
cidrv6,
|
|
59
|
+
cuid,
|
|
60
|
+
cuid2,
|
|
61
|
+
date,
|
|
62
|
+
datetime,
|
|
63
|
+
duration,
|
|
64
|
+
e164,
|
|
65
|
+
email,
|
|
66
|
+
emoji,
|
|
67
|
+
guid,
|
|
68
|
+
integer,
|
|
69
|
+
ipv4,
|
|
70
|
+
ipv6,
|
|
71
|
+
ksuid,
|
|
72
|
+
lowercase,
|
|
73
|
+
nanoid,
|
|
74
|
+
number,
|
|
75
|
+
string,
|
|
76
|
+
time,
|
|
77
|
+
ulid,
|
|
78
|
+
uppercase,
|
|
79
|
+
uuid,
|
|
80
|
+
xid
|
|
81
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
class $ZodRegistry {
|
|
3
|
+
constructor() {
|
|
4
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
6
|
+
}
|
|
7
|
+
add(schema, ..._meta) {
|
|
8
|
+
const meta = _meta[0];
|
|
9
|
+
this._map.set(schema, meta);
|
|
10
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
11
|
+
this._idmap.set(meta.id, schema);
|
|
12
|
+
}
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
clear() {
|
|
16
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
remove(schema) {
|
|
21
|
+
const meta = this._map.get(schema);
|
|
22
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
23
|
+
this._idmap.delete(meta.id);
|
|
24
|
+
}
|
|
25
|
+
this._map.delete(schema);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
get(schema) {
|
|
29
|
+
const p = schema._zod.parent;
|
|
30
|
+
if (p) {
|
|
31
|
+
const pm = { ...this.get(p) ?? {} };
|
|
32
|
+
delete pm.id;
|
|
33
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
34
|
+
return Object.keys(f).length ? f : void 0;
|
|
35
|
+
}
|
|
36
|
+
return this._map.get(schema);
|
|
37
|
+
}
|
|
38
|
+
has(schema) {
|
|
39
|
+
return this._map.has(schema);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function registry() {
|
|
43
|
+
return new $ZodRegistry();
|
|
44
|
+
}
|
|
45
|
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
46
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
47
|
+
export {
|
|
48
|
+
$ZodRegistry,
|
|
49
|
+
globalRegistry,
|
|
50
|
+
registry
|
|
51
|
+
};
|