@es-joy/jsoe 0.28.0 → 0.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +8 -0
- package/badges/coverage-badge.svg +1 -1
- package/badges/tests-badge.svg +1 -1
- package/dist/deepEqual.d.ts +3 -0
- package/dist/deepEqual.d.ts.map +1 -0
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/search/queryTree.d.ts +180 -0
- package/dist/search/queryTree.d.ts.map +1 -0
- package/dist/search/queryTreeBuilders.d.ts +156 -0
- package/dist/search/queryTreeBuilders.d.ts.map +1 -0
- package/dist/search/searchDispatch.d.ts +77 -0
- package/dist/search/searchDispatch.d.ts.map +1 -0
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/rawTypesonEditor.d.ts.map +1 -1
- package/docs/proposals/search-plan.md +166 -0
- package/package.json +22 -9
- package/pnpm-workspace.yaml +31 -30
- package/src/formats/schema.js +8 -14
- package/src/fundamentalTypes/arrayType.js +14 -22
- package/src/fundamentalTypes/blobType.js +16 -16
- package/src/fundamentalTypes/fileType.js +13 -13
- package/src/fundamentalTypes/regexpType.js +1 -1
- package/src/fundamentalTypes/stringType.js +5 -0
- package/src/subTypes/blobHTMLType.js +1 -1
- package/src/superTypes/dommatrixType.js +1 -1
- package/src/superTypes/errorsSpecialType.js +1 -1
- package/src/typeChoices.js +1 -3
- package/src/types.js +0 -6
- package/src/utils/media.js +3 -3
- package/src/utils/rawTypesonEditor.js +12 -2
- package/tsconfig.json +1 -1
- package/vendor/jamilih/dist/jml.mjs +898 -25
- package/vendor/zod/classic/checks.d.ts +1 -1
- package/vendor/zod/classic/checks.js +1 -1
- package/vendor/zod/classic/schemas.d.ts +2 -6
- package/vendor/zod/classic/schemas.js +9 -13
- package/vendor/zod/core/api.d.ts +8 -4
- package/vendor/zod/core/api.js +11 -23
- package/vendor/zod/core/checks.d.ts +16 -0
- package/vendor/zod/core/checks.js +31 -0
- package/vendor/zod/core/compile.js +20 -24
- package/vendor/zod/core/core.js +1 -1
- package/vendor/zod/core/json-schema-processors.d.ts +0 -1
- package/vendor/zod/core/json-schema-processors.js +8 -43
- package/vendor/zod/core/memoizer.js +2 -5
- package/vendor/zod/core/regexes.d.ts +1 -0
- package/vendor/zod/core/regexes.js +2 -0
- package/vendor/zod/core/schemas.d.ts +8 -23
- package/vendor/zod/core/schemas.js +39 -80
- package/vendor/zod/core/to-json-schema.d.ts +0 -3
- package/vendor/zod/core/to-json-schema.js +1 -1
- package/vendor/zod/core/util.js +0 -4
- package/vendor/zod/core/versions.js +1 -1
- package/vendor/zod/core/visit.js +0 -12
- package/vendor/zod/locales/ar.js +1 -0
- package/vendor/zod/locales/az.js +1 -0
- package/vendor/zod/locales/be.js +1 -0
- package/vendor/zod/locales/bg.js +1 -0
- package/vendor/zod/locales/bn.js +1 -0
- package/vendor/zod/locales/ca.js +1 -0
- package/vendor/zod/locales/ckb.js +1 -0
- package/vendor/zod/locales/cs.js +1 -0
- package/vendor/zod/locales/da.js +1 -0
- package/vendor/zod/locales/de.js +1 -0
- package/vendor/zod/locales/el.js +1 -0
- package/vendor/zod/locales/en.js +1 -0
- package/vendor/zod/locales/eo.js +1 -0
- package/vendor/zod/locales/es.js +1 -0
- package/vendor/zod/locales/fa.js +1 -0
- package/vendor/zod/locales/fi.js +1 -0
- package/vendor/zod/locales/fr-CA.js +1 -0
- package/vendor/zod/locales/fr.js +1 -0
- package/vendor/zod/locales/gu.js +1 -0
- package/vendor/zod/locales/he.js +1 -0
- package/vendor/zod/locales/hi.js +1 -0
- package/vendor/zod/locales/hr.js +1 -0
- package/vendor/zod/locales/hu.js +1 -0
- package/vendor/zod/locales/hy.js +1 -0
- package/vendor/zod/locales/id.js +1 -0
- package/vendor/zod/locales/is.js +1 -0
- package/vendor/zod/locales/it.js +1 -0
- package/vendor/zod/locales/ja.js +1 -0
- package/vendor/zod/locales/ka.js +1 -0
- package/vendor/zod/locales/km.js +1 -0
- package/vendor/zod/locales/kn.js +1 -0
- package/vendor/zod/locales/ko.js +1 -0
- package/vendor/zod/locales/lt.js +1 -0
- package/vendor/zod/locales/mk.js +1 -0
- package/vendor/zod/locales/ms.js +1 -0
- package/vendor/zod/locales/ne.js +1 -0
- package/vendor/zod/locales/nl.js +1 -0
- package/vendor/zod/locales/nn.js +1 -0
- package/vendor/zod/locales/no.js +1 -0
- package/vendor/zod/locales/ota.js +1 -0
- package/vendor/zod/locales/pl.js +1 -0
- package/vendor/zod/locales/ps.js +1 -0
- package/vendor/zod/locales/pt-BR.js +1 -0
- package/vendor/zod/locales/pt.js +1 -0
- package/vendor/zod/locales/ro.js +1 -0
- package/vendor/zod/locales/ru.js +1 -0
- package/vendor/zod/locales/sk.js +1 -0
- package/vendor/zod/locales/sl.js +1 -0
- package/vendor/zod/locales/sv.js +1 -0
- package/vendor/zod/locales/ta.js +1 -0
- package/vendor/zod/locales/tg.js +1 -0
- package/vendor/zod/locales/th.js +1 -0
- package/vendor/zod/locales/tk.js +1 -0
- package/vendor/zod/locales/tr.js +1 -0
- package/vendor/zod/locales/uk.js +1 -0
- package/vendor/zod/locales/ur.js +1 -0
- package/vendor/zod/locales/uz.js +1 -0
- package/vendor/zod/locales/vi.js +1 -0
- package/vendor/zod/locales/yo.js +1 -0
- package/vendor/zod/locales/zh-CN.js +1 -0
- package/vendor/zod/locales/zh-TW.js +1 -0
- package/vendor/zod/mini/checks.d.ts +1 -1
- package/vendor/zod/mini/checks.js +1 -1
- package/vendor/zod/mini/schemas.d.ts +2 -5
- package/vendor/zod/mini/schemas.js +9 -11
- package/vendor/zodexy/dist/esm/index.js +4 -33
- package/vendor/zodexy/dist/schema.zodexy.json +1 -17
|
@@ -209,15 +209,37 @@ export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def
|
|
|
209
209
|
});
|
|
210
210
|
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
211
211
|
export const URL_BAD_FORMAT = 1;
|
|
212
|
-
/** The URL
|
|
212
|
+
/** The URL parser rejected the input. */
|
|
213
213
|
export const URL_UNPARSEABLE = 2;
|
|
214
|
-
|
|
214
|
+
export function canParseURL(input) {
|
|
215
|
+
try {
|
|
216
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
217
|
+
return URL.canParse(input);
|
|
218
|
+
new URL(input);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export function validateURL(trimmed, def) {
|
|
226
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
227
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
228
|
+
}
|
|
229
|
+
return parseURLObject(trimmed, def);
|
|
230
|
+
}
|
|
231
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
215
232
|
export function parseURLObject(trimmed, def) {
|
|
216
233
|
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
217
234
|
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
218
235
|
return URL_BAD_FORMAT;
|
|
219
236
|
}
|
|
220
237
|
try {
|
|
238
|
+
if (typeof URL !== "undefined") {
|
|
239
|
+
const URLStatic = URL;
|
|
240
|
+
if (typeof URLStatic.parse === "function")
|
|
241
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
242
|
+
}
|
|
221
243
|
// @ts-ignore
|
|
222
244
|
return new URL(trimmed);
|
|
223
245
|
}
|
|
@@ -244,7 +266,7 @@ export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) =>
|
|
|
244
266
|
try {
|
|
245
267
|
// Trim whitespace from input
|
|
246
268
|
const trimmed = payload.value.trim();
|
|
247
|
-
const url =
|
|
269
|
+
const url = validateURL(trimmed, def);
|
|
248
270
|
if (url === URL_BAD_FORMAT) {
|
|
249
271
|
payload.issues.push({
|
|
250
272
|
code: "invalid_format",
|
|
@@ -266,6 +288,10 @@ export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) =>
|
|
|
266
288
|
});
|
|
267
289
|
return;
|
|
268
290
|
}
|
|
291
|
+
if (url === true) {
|
|
292
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
269
295
|
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
270
296
|
payload.issues.push({
|
|
271
297
|
code: "invalid_format",
|
|
@@ -363,14 +389,7 @@ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
|
363
389
|
export function isValidIPv6(value) {
|
|
364
390
|
if (!ipv6Alphabet.test(value))
|
|
365
391
|
return false;
|
|
366
|
-
|
|
367
|
-
// @ts-ignore
|
|
368
|
-
new URL(`http://[${value}]`);
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
catch {
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
392
|
+
return canParseURL(`http://[${value}]`);
|
|
374
393
|
}
|
|
375
394
|
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
|
376
395
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
@@ -869,7 +888,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
|
869
888
|
return;
|
|
870
889
|
}
|
|
871
890
|
if (result.value === undefined) {
|
|
872
|
-
if (isPresent) {
|
|
891
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
873
892
|
final.value[key] = undefined;
|
|
874
893
|
}
|
|
875
894
|
}
|
|
@@ -1124,16 +1143,17 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
1124
1143
|
doc.write(`
|
|
1125
1144
|
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1126
1145
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1146
|
+
`);
|
|
1147
|
+
if (optin === "defaulted") {
|
|
1148
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
1149
|
+
}
|
|
1150
|
+
else {
|
|
1151
|
+
doc.write(`
|
|
1152
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1133
1153
|
newResult[${k}] = ${id}.value;
|
|
1134
1154
|
}
|
|
1135
|
-
|
|
1136
1155
|
`);
|
|
1156
|
+
}
|
|
1137
1157
|
}
|
|
1138
1158
|
}
|
|
1139
1159
|
doc.write(`payload.value = newResult;`);
|
|
@@ -2584,64 +2604,3 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
2584
2604
|
payload.issues.push(util.issue(_iss));
|
|
2585
2605
|
}
|
|
2586
2606
|
}
|
|
2587
|
-
// asserts in place: the child result's value is discarded, matching z.property(), because a nested object or array schema rebuilds its output even when nothing transformed
|
|
2588
|
-
function handlePropertiesResult(result, payload, key) {
|
|
2589
|
-
if (result.issues.length) {
|
|
2590
|
-
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
|
-
export const $ZodProperties = /*@__PURE__*/ core.$constructor("$ZodProperties", (inst, def) => {
|
|
2594
|
-
// $ZodType.init prepends an instance that already carries the $ZodCheck trait to its own `checks`, which would run the shape a second time and cost the parse context. Initializing the check trait after it keeps the schema role in `parse`, where the context arrives.
|
|
2595
|
-
$ZodType.init(inst, def);
|
|
2596
|
-
checks.$ZodCheck.init(inst, def);
|
|
2597
|
-
const memo = core.globalConfig.memoizer;
|
|
2598
|
-
memo?.attach(inst);
|
|
2599
|
-
// key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema
|
|
2600
|
-
let entries;
|
|
2601
|
-
const runShape = (payload, ctx) => {
|
|
2602
|
-
entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
2603
|
-
const input = payload.value;
|
|
2604
|
-
let proms;
|
|
2605
|
-
for (const [key, schema] of entries) {
|
|
2606
|
-
const result = schema._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2607
|
-
if (result instanceof Promise) {
|
|
2608
|
-
proms ?? (proms = []);
|
|
2609
|
-
proms.push(result.then((result) => handlePropertiesResult(result, payload, key)));
|
|
2610
|
-
}
|
|
2611
|
-
else {
|
|
2612
|
-
handlePropertiesResult(result, payload, key);
|
|
2613
|
-
}
|
|
2614
|
-
}
|
|
2615
|
-
if (proms)
|
|
2616
|
-
return Promise.all(proms).then(() => undefined);
|
|
2617
|
-
return undefined;
|
|
2618
|
-
};
|
|
2619
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2620
|
-
const input = payload.value;
|
|
2621
|
-
// as a schema this is the type gate, and it infers an object shape, so a primitive is a type error. A function passes: its properties read like any other object's, and z.instanceof allows one.
|
|
2622
|
-
if (input === null || (typeof input !== "object" && typeof input !== "function")) {
|
|
2623
|
-
payload.issues.push({ expected: "object", code: "invalid_type", input, inst });
|
|
2624
|
-
return payload;
|
|
2625
|
-
}
|
|
2626
|
-
// both sides declare the shape's input type, so the assertion runs forward in either direction; encoding the children backward would reject the very type this schema claims to take
|
|
2627
|
-
if (ctx.direction === "backward")
|
|
2628
|
-
ctx = { ...ctx, direction: "forward" };
|
|
2629
|
-
// the input is its own output here, so it registers as its own memo entry: a cycle re-entering this node hits the bucket instead of recursing forever
|
|
2630
|
-
if (memo)
|
|
2631
|
-
memo.alloc(inst, payload, input, ctx);
|
|
2632
|
-
const result = runShape(payload, ctx);
|
|
2633
|
-
return result instanceof Promise ? result.then(() => payload) : payload;
|
|
2634
|
-
};
|
|
2635
|
-
// as a check the base schema already typed the value, so this only asserts the properties — which read on a primitive too, matching z.property() on a string's length. It gets no context of its own, so a cycle through a spread schema is not tracked.
|
|
2636
|
-
inst._zod.check = (payload) => {
|
|
2637
|
-
if (payload.value == null) {
|
|
2638
|
-
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
2639
|
-
return undefined;
|
|
2640
|
-
}
|
|
2641
|
-
return runShape(payload, {});
|
|
2642
|
-
};
|
|
2643
|
-
}, {
|
|
2644
|
-
*[Symbol.iterator]() {
|
|
2645
|
-
yield this;
|
|
2646
|
-
},
|
|
2647
|
-
});
|
|
@@ -137,9 +137,6 @@ export declare function processSchema<T extends schemas.$ZodType>(schema: T, ctx
|
|
|
137
137
|
export { processSchema as process };
|
|
138
138
|
export declare function extractDefs<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): void;
|
|
139
139
|
export declare function finalize<T extends schemas.$ZodType>(ctx: ToJSONSchemaContext, schema: T): ZodStandardJSONSchemaPayload<T>;
|
|
140
|
-
export declare function isTransforming(_schema: schemas.$ZodType, _ctx?: {
|
|
141
|
-
seen: Set<schemas.$ZodType>;
|
|
142
|
-
}): boolean;
|
|
143
140
|
export type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;
|
|
144
141
|
export interface ZodStandardJSONSchemaPayload<T> extends JSONSchema.BaseSchema {
|
|
145
142
|
"~standard": ZodStandardSchemaWithJSON<T>;
|
|
@@ -572,7 +572,7 @@ export function finalize(ctx, schema) {
|
|
|
572
572
|
throw new Error("Error converting schema to JSON.");
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
|
-
|
|
575
|
+
function isTransforming(_schema, _ctx) {
|
|
576
576
|
const ctx = _ctx ?? { seen: new Set() };
|
|
577
577
|
if (ctx.seen.has(_schema))
|
|
578
578
|
return false;
|
package/vendor/zod/core/util.js
CHANGED
|
@@ -725,10 +725,6 @@ export function members(proto, table) {
|
|
|
725
725
|
else
|
|
726
726
|
defineBound(proto, key, desc.value);
|
|
727
727
|
}
|
|
728
|
-
// for..in sees no symbol keys, so well-known members like Symbol.iterator install here
|
|
729
|
-
for (const sym of Object.getOwnPropertySymbols(table)) {
|
|
730
|
-
defineBound(proto, sym, table[sym]);
|
|
731
|
-
}
|
|
732
728
|
}
|
|
733
729
|
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
|
|
734
730
|
export function own(inst, key, value, enumerable = true) {
|
package/vendor/zod/core/visit.js
CHANGED
|
@@ -135,18 +135,6 @@ export function visit(schema, fnOrHandlers) {
|
|
|
135
135
|
const { _cachedInner, ...rest } = def;
|
|
136
136
|
return clone(s, { ...rest, getter: () => run(original()) });
|
|
137
137
|
}
|
|
138
|
-
case "properties": {
|
|
139
|
-
const oldShape = def.shape;
|
|
140
|
-
let changed = false;
|
|
141
|
-
const newShape = {};
|
|
142
|
-
for (const k of Reflect.ownKeys(oldShape)) {
|
|
143
|
-
const mapped = run(oldShape[k]);
|
|
144
|
-
if (mapped !== oldShape[k])
|
|
145
|
-
changed = true;
|
|
146
|
-
newShape[k] = mapped;
|
|
147
|
-
}
|
|
148
|
-
return changed ? clone(s, { ...def, shape: newShape }) : s;
|
|
149
|
-
}
|
|
150
138
|
// A leaf by choice: `parts` are regex fragments, not data positions.
|
|
151
139
|
case "template_literal":
|
|
152
140
|
// Leaves.
|
package/vendor/zod/locales/ar.js
CHANGED
package/vendor/zod/locales/az.js
CHANGED
package/vendor/zod/locales/be.js
CHANGED
package/vendor/zod/locales/bg.js
CHANGED
package/vendor/zod/locales/bn.js
CHANGED
package/vendor/zod/locales/ca.js
CHANGED
package/vendor/zod/locales/cs.js
CHANGED
package/vendor/zod/locales/da.js
CHANGED
package/vendor/zod/locales/de.js
CHANGED
package/vendor/zod/locales/el.js
CHANGED
package/vendor/zod/locales/en.js
CHANGED
package/vendor/zod/locales/eo.js
CHANGED
package/vendor/zod/locales/es.js
CHANGED
package/vendor/zod/locales/fa.js
CHANGED
package/vendor/zod/locales/fi.js
CHANGED
package/vendor/zod/locales/fr.js
CHANGED
package/vendor/zod/locales/gu.js
CHANGED
package/vendor/zod/locales/he.js
CHANGED
|
@@ -78,6 +78,7 @@ const error = () => {
|
|
|
78
78
|
json_string: { label: "מחרוזת JSON", gender: "f" },
|
|
79
79
|
e164: { label: "מספר E.164", gender: "m" },
|
|
80
80
|
credit_card: { label: "מספר כרטיס אשראי", gender: "m" },
|
|
81
|
+
currency_code: { label: "קוד מטבע", gender: "m" },
|
|
81
82
|
iban: { label: "IBAN", gender: "m" },
|
|
82
83
|
jwt: { label: "JWT", gender: "m" },
|
|
83
84
|
template_literal: { label: "קלט", gender: "m" },
|
package/vendor/zod/locales/hi.js
CHANGED
package/vendor/zod/locales/hr.js
CHANGED
package/vendor/zod/locales/hu.js
CHANGED
package/vendor/zod/locales/hy.js
CHANGED
package/vendor/zod/locales/id.js
CHANGED
package/vendor/zod/locales/is.js
CHANGED
package/vendor/zod/locales/it.js
CHANGED
package/vendor/zod/locales/ja.js
CHANGED
package/vendor/zod/locales/ka.js
CHANGED
package/vendor/zod/locales/km.js
CHANGED
package/vendor/zod/locales/kn.js
CHANGED
package/vendor/zod/locales/ko.js
CHANGED
package/vendor/zod/locales/lt.js
CHANGED
package/vendor/zod/locales/mk.js
CHANGED
package/vendor/zod/locales/ms.js
CHANGED
package/vendor/zod/locales/ne.js
CHANGED
package/vendor/zod/locales/nl.js
CHANGED
package/vendor/zod/locales/nn.js
CHANGED
package/vendor/zod/locales/no.js
CHANGED
package/vendor/zod/locales/pl.js
CHANGED
package/vendor/zod/locales/ps.js
CHANGED
package/vendor/zod/locales/pt.js
CHANGED