baobox 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -0
- package/dist/compile/bun-fast-path.d.ts +14 -0
- package/dist/compile/bun-fast-path.d.ts.map +1 -0
- package/dist/compile/emit.d.ts +5 -0
- package/dist/compile/emit.d.ts.map +1 -0
- package/dist/compile/index.d.ts +57 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +4711 -0
- package/dist/compile/index.js.map +65 -0
- package/dist/error/catalog-types.d.ts +30 -0
- package/dist/error/catalog-types.d.ts.map +1 -0
- package/dist/error/collector/advanced.d.ts +5 -0
- package/dist/error/collector/advanced.d.ts.map +1 -0
- package/dist/error/collector/collections-basic.d.ts +5 -0
- package/dist/error/collector/collections-basic.d.ts.map +1 -0
- package/dist/error/collector/collections-derived.d.ts +5 -0
- package/dist/error/collector/collections-derived.d.ts.map +1 -0
- package/dist/error/collector/collections-parameters.d.ts +5 -0
- package/dist/error/collector/collections-parameters.d.ts.map +1 -0
- package/dist/error/collector/collections.d.ts +5 -0
- package/dist/error/collector/collections.d.ts.map +1 -0
- package/dist/error/collector/primitives.d.ts +5 -0
- package/dist/error/collector/primitives.d.ts.map +1 -0
- package/dist/error/collector/shared.d.ts +6 -0
- package/dist/error/collector/shared.d.ts.map +1 -0
- package/dist/error/collector.d.ts +5 -0
- package/dist/error/collector.d.ts.map +1 -0
- package/dist/error/errors.d.ts +23 -0
- package/dist/error/errors.d.ts.map +1 -0
- package/dist/error/index.d.ts +11 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/index.js +3163 -0
- package/dist/error/index.js.map +53 -0
- package/dist/error/locales/de.d.ts +3 -0
- package/dist/error/locales/de.d.ts.map +1 -0
- package/dist/error/locales/en.d.ts +3 -0
- package/dist/error/locales/en.d.ts.map +1 -0
- package/dist/error/locales/es.d.ts +3 -0
- package/dist/error/locales/es.d.ts.map +1 -0
- package/dist/error/locales/fr.d.ts +3 -0
- package/dist/error/locales/fr.d.ts.map +1 -0
- package/dist/error/locales/ja.d.ts +3 -0
- package/dist/error/locales/ja.d.ts.map +1 -0
- package/dist/error/locales/ko.d.ts +3 -0
- package/dist/error/locales/ko.d.ts.map +1 -0
- package/dist/error/locales/pt.d.ts +3 -0
- package/dist/error/locales/pt.d.ts.map +1 -0
- package/dist/error/locales/shared.d.ts +4 -0
- package/dist/error/locales/shared.d.ts.map +1 -0
- package/dist/error/locales/zh.d.ts +4 -0
- package/dist/error/locales/zh.d.ts.map +1 -0
- package/dist/error/messages.d.ts +7 -0
- package/dist/error/messages.d.ts.map +1 -0
- package/dist/format/format.d.ts +61 -0
- package/dist/format/format.d.ts.map +1 -0
- package/dist/format/index.d.ts +5 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +1475 -0
- package/dist/format/index.js.map +29 -0
- package/dist/guard/guard.d.ts +73 -0
- package/dist/guard/guard.d.ts.map +1 -0
- package/dist/guard/index.d.ts +7 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +342 -0
- package/dist/guard/index.js.map +11 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8938 -0
- package/dist/index.js.map +104 -0
- package/dist/locale/index.d.ts +124 -0
- package/dist/locale/index.d.ts.map +1 -0
- package/dist/locale/index.js +564 -0
- package/dist/locale/index.js.map +20 -0
- package/dist/schema/build.d.ts +32 -0
- package/dist/schema/build.d.ts.map +1 -0
- package/dist/schema/check.d.ts +6 -0
- package/dist/schema/check.d.ts.map +1 -0
- package/dist/schema/compile.d.ts +16 -0
- package/dist/schema/compile.d.ts.map +1 -0
- package/dist/schema/core-keywords.d.ts +8 -0
- package/dist/schema/core-keywords.d.ts.map +1 -0
- package/dist/schema/core.d.ts +3 -0
- package/dist/schema/core.d.ts.map +1 -0
- package/dist/schema/emitter-advanced.d.ts +6 -0
- package/dist/schema/emitter-advanced.d.ts.map +1 -0
- package/dist/schema/emitter-base.d.ts +8 -0
- package/dist/schema/emitter-base.d.ts.map +1 -0
- package/dist/schema/emitter-derived.d.ts +5 -0
- package/dist/schema/emitter-derived.d.ts.map +1 -0
- package/dist/schema/emitter-reference.d.ts +5 -0
- package/dist/schema/emitter-reference.d.ts.map +1 -0
- package/dist/schema/emitter-types.d.ts +5 -0
- package/dist/schema/emitter-types.d.ts.map +1 -0
- package/dist/schema/emitter-wrapper.d.ts +5 -0
- package/dist/schema/emitter-wrapper.d.ts.map +1 -0
- package/dist/schema/emitter.d.ts +52 -0
- package/dist/schema/emitter.d.ts.map +1 -0
- package/dist/schema/engine.d.ts +61 -0
- package/dist/schema/engine.d.ts.map +1 -0
- package/dist/schema/error-collector.d.ts +4 -0
- package/dist/schema/error-collector.d.ts.map +1 -0
- package/dist/schema/errors.d.ts +7 -0
- package/dist/schema/errors.d.ts.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +3661 -0
- package/dist/schema/index.js.map +50 -0
- package/dist/schema/parse.d.ts +14 -0
- package/dist/schema/parse.d.ts.map +1 -0
- package/dist/schema/pointer.d.ts +13 -0
- package/dist/schema/pointer.d.ts.map +1 -0
- package/dist/schema/predicates.d.ts +62 -0
- package/dist/schema/predicates.d.ts.map +1 -0
- package/dist/schema/resolve.d.ts +6 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/schema/runtime-keywords.d.ts +136 -0
- package/dist/schema/runtime-keywords.d.ts.map +1 -0
- package/dist/schema/schema.d.ts +14 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/shared.d.ts +61 -0
- package/dist/schema/shared.d.ts.map +1 -0
- package/dist/script/generic.d.ts +3 -0
- package/dist/script/generic.d.ts.map +1 -0
- package/dist/script/index.d.ts +7 -0
- package/dist/script/index.d.ts.map +1 -0
- package/dist/script/index.js +3948 -0
- package/dist/script/index.js.map +55 -0
- package/dist/script/literals.d.ts +5 -0
- package/dist/script/literals.d.ts.map +1 -0
- package/dist/script/shared.d.ts +15 -0
- package/dist/script/shared.d.ts.map +1 -0
- package/dist/shared/bytes.d.ts +9 -0
- package/dist/shared/bytes.d.ts.map +1 -0
- package/dist/shared/format-constants.d.ts +16 -0
- package/dist/shared/format-constants.d.ts.map +1 -0
- package/dist/shared/format-validators.d.ts +13 -0
- package/dist/shared/format-validators.d.ts.map +1 -0
- package/dist/shared/locale.d.ts +43 -0
- package/dist/shared/locale.d.ts.map +1 -0
- package/dist/shared/object-utils.d.ts +21 -0
- package/dist/shared/object-utils.d.ts.map +1 -0
- package/dist/shared/regex-json.d.ts +5 -0
- package/dist/shared/regex-json.d.ts.map +1 -0
- package/dist/shared/registries.d.ts +41 -0
- package/dist/shared/registries.d.ts.map +1 -0
- package/dist/shared/runtime-context.d.ts +109 -0
- package/dist/shared/runtime-context.d.ts.map +1 -0
- package/dist/shared/runtime-guards.d.ts +7 -0
- package/dist/shared/runtime-guards.d.ts.map +1 -0
- package/dist/shared/schema-access.d.ts +34 -0
- package/dist/shared/schema-access.d.ts.map +1 -0
- package/dist/shared/utils.d.ts +9 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/dist/shared/utils.js +1321 -0
- package/dist/shared/utils.js.map +27 -0
- package/dist/standard/index.d.ts +51 -0
- package/dist/standard/index.d.ts.map +1 -0
- package/dist/standard/index.js +4551 -0
- package/dist/standard/index.js.map +66 -0
- package/dist/system/index.d.ts +5 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +1632 -0
- package/dist/system/index.js.map +33 -0
- package/dist/system/system.d.ts +154 -0
- package/dist/system/system.d.ts.map +1 -0
- package/dist/type/actions.d.ts +48 -0
- package/dist/type/actions.d.ts.map +1 -0
- package/dist/type/base-types.d.ts +5 -0
- package/dist/type/base-types.d.ts.map +1 -0
- package/dist/type/codec-builtins.d.ts +9 -0
- package/dist/type/codec-builtins.d.ts.map +1 -0
- package/dist/type/combinator-core.d.ts +26 -0
- package/dist/type/combinator-core.d.ts.map +1 -0
- package/dist/type/combinator-functions.d.ts +16 -0
- package/dist/type/combinator-functions.d.ts.map +1 -0
- package/dist/type/combinator-objects.d.ts +30 -0
- package/dist/type/combinator-objects.d.ts.map +1 -0
- package/dist/type/combinators.d.ts +4 -0
- package/dist/type/combinators.d.ts.map +1 -0
- package/dist/type/composite-types.d.ts +39 -0
- package/dist/type/composite-types.d.ts.map +1 -0
- package/dist/type/containers-types.d.ts +47 -0
- package/dist/type/containers-types.d.ts.map +1 -0
- package/dist/type/containers.d.ts +7 -0
- package/dist/type/containers.d.ts.map +1 -0
- package/dist/type/extends.d.ts +32 -0
- package/dist/type/extends.d.ts.map +1 -0
- package/dist/type/extensions.d.ts +86 -0
- package/dist/type/extensions.d.ts.map +1 -0
- package/dist/type/guards.d.ts +78 -0
- package/dist/type/guards.d.ts.map +1 -0
- package/dist/type/index.d.ts +29 -0
- package/dist/type/index.d.ts.map +1 -0
- package/dist/type/index.js +4049 -0
- package/dist/type/index.js.map +51 -0
- package/dist/type/instantiation.d.ts +10 -0
- package/dist/type/instantiation.d.ts.map +1 -0
- package/dist/type/kind.d.ts +76 -0
- package/dist/type/kind.d.ts.map +1 -0
- package/dist/type/narrow-types.d.ts +23 -0
- package/dist/type/narrow-types.d.ts.map +1 -0
- package/dist/type/primitives-types.d.ts +103 -0
- package/dist/type/primitives-types.d.ts.map +1 -0
- package/dist/type/primitives.d.ts +81 -0
- package/dist/type/primitives.d.ts.map +1 -0
- package/dist/type/root-constants.d.ts +65 -0
- package/dist/type/root-constants.d.ts.map +1 -0
- package/dist/type/root-cyclic.d.ts +12 -0
- package/dist/type/root-cyclic.d.ts.map +1 -0
- package/dist/type/root-deferred.d.ts +39 -0
- package/dist/type/root-deferred.d.ts.map +1 -0
- package/dist/type/root-guards.d.ts +15 -0
- package/dist/type/root-guards.d.ts.map +1 -0
- package/dist/type/root-helpers.d.ts +28 -0
- package/dist/type/root-helpers.d.ts.map +1 -0
- package/dist/type/root-instantiate.d.ts +33 -0
- package/dist/type/root-instantiate.d.ts.map +1 -0
- package/dist/type/root-shared.d.ts +14 -0
- package/dist/type/root-shared.d.ts.map +1 -0
- package/dist/type/root-template.d.ts +15 -0
- package/dist/type/root-template.d.ts.map +1 -0
- package/dist/type/schema.d.ts +10 -0
- package/dist/type/schema.d.ts.map +1 -0
- package/dist/type/static-const-types.d.ts +25 -0
- package/dist/type/static-const-types.d.ts.map +1 -0
- package/dist/type/static-shared-types.d.ts +17 -0
- package/dist/type/static-shared-types.d.ts.map +1 -0
- package/dist/type/static-types.d.ts +39 -0
- package/dist/type/static-types.d.ts.map +1 -0
- package/dist/type/string-action-types.d.ts +24 -0
- package/dist/type/string-action-types.d.ts.map +1 -0
- package/dist/type/transform-types.d.ts +54 -0
- package/dist/type/transform-types.d.ts.map +1 -0
- package/dist/type/uint8array-codec.d.ts +8 -0
- package/dist/type/uint8array-codec.d.ts.map +1 -0
- package/dist/type/wrapper-types.d.ts +71 -0
- package/dist/type/wrapper-types.d.ts.map +1 -0
- package/dist/typebox.d.ts +3 -0
- package/dist/typebox.d.ts.map +1 -0
- package/dist/typebox.js +4767 -0
- package/dist/typebox.js.map +55 -0
- package/dist/value/assert.d.ts +8 -0
- package/dist/value/assert.d.ts.map +1 -0
- package/dist/value/check-collections-derived.d.ts +6 -0
- package/dist/value/check-collections-derived.d.ts.map +1 -0
- package/dist/value/check-collections.d.ts +5 -0
- package/dist/value/check-collections.d.ts.map +1 -0
- package/dist/value/check-extensions.d.ts +3 -0
- package/dist/value/check-extensions.d.ts.map +1 -0
- package/dist/value/check-primitives.d.ts +4 -0
- package/dist/value/check-primitives.d.ts.map +1 -0
- package/dist/value/check.d.ts +13 -0
- package/dist/value/check.d.ts.map +1 -0
- package/dist/value/clean.d.ts +4 -0
- package/dist/value/clean.d.ts.map +1 -0
- package/dist/value/clone.d.ts +3 -0
- package/dist/value/clone.d.ts.map +1 -0
- package/dist/value/convert.d.ts +4 -0
- package/dist/value/convert.d.ts.map +1 -0
- package/dist/value/create.d.ts +4 -0
- package/dist/value/create.d.ts.map +1 -0
- package/dist/value/decode.d.ts +4 -0
- package/dist/value/decode.d.ts.map +1 -0
- package/dist/value/default.d.ts +4 -0
- package/dist/value/default.d.ts.map +1 -0
- package/dist/value/diff.d.ts +9 -0
- package/dist/value/diff.d.ts.map +1 -0
- package/dist/value/encode.d.ts +4 -0
- package/dist/value/encode.d.ts.map +1 -0
- package/dist/value/equal.d.ts +3 -0
- package/dist/value/equal.d.ts.map +1 -0
- package/dist/value/has-codec.d.ts +3 -0
- package/dist/value/has-codec.d.ts.map +1 -0
- package/dist/value/hash.d.ts +3 -0
- package/dist/value/hash.d.ts.map +1 -0
- package/dist/value/index.d.ts +145 -0
- package/dist/value/index.d.ts.map +1 -0
- package/dist/value/index.js +4702 -0
- package/dist/value/index.js.map +71 -0
- package/dist/value/mutate.d.ts +3 -0
- package/dist/value/mutate.d.ts.map +1 -0
- package/dist/value/parse.d.ts +13 -0
- package/dist/value/parse.d.ts.map +1 -0
- package/dist/value/patch.d.ts +4 -0
- package/dist/value/patch.d.ts.map +1 -0
- package/dist/value/pipeline.d.ts +6 -0
- package/dist/value/pipeline.d.ts.map +1 -0
- package/dist/value/pointer.d.ts +8 -0
- package/dist/value/pointer.d.ts.map +1 -0
- package/dist/value/repair.d.ts +5 -0
- package/dist/value/repair.d.ts.map +1 -0
- package/dist/value/result.d.ts +10 -0
- package/dist/value/result.d.ts.map +1 -0
- package/docs/locale-packs.md +78 -0
- package/docs/package-contract.md +89 -0
- package/docs/parity-and-extensions.md +56 -0
- package/docs/script-module-registries.md +107 -0
- package/docs/workflows.md +154 -0
- package/package.json +117 -0
package/dist/typebox.js
ADDED
|
@@ -0,0 +1,4767 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/error/locales/shared.ts
|
|
18
|
+
function formatList(values) {
|
|
19
|
+
return values === undefined ? "" : values.join(", ");
|
|
20
|
+
}
|
|
21
|
+
function labelFor(params, fallback) {
|
|
22
|
+
return params.label ?? fallback;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/error/locales/de.ts
|
|
26
|
+
var deDECatalog = {
|
|
27
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Erwartet: ${params.expected ?? "Wert"}` : `Erwartet: ${params.expected ?? "Wert"}, erhalten: ${params.actual}`,
|
|
28
|
+
MIN_LENGTH: (params) => `${labelFor(params, "Der Wert")} muss mindestens ${params.minimum} sein`,
|
|
29
|
+
MAX_LENGTH: (params) => `${labelFor(params, "Der Wert")} darf h\xF6chstens ${params.maximum} sein`,
|
|
30
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "Der Wert")} muss einem von folgenden Mustern entsprechen: ${formatList(params.patterns)}` : `${labelFor(params, "Der Wert")} muss dem Muster ${params.pattern} entsprechen`,
|
|
31
|
+
FORMAT: (params) => `${labelFor(params, "Der Wert")} muss dem Format ${params.format} entsprechen`,
|
|
32
|
+
MINIMUM: (params) => `${labelFor(params, "Der Wert")} muss >= ${params.minimum} sein`,
|
|
33
|
+
MAXIMUM: (params) => `${labelFor(params, "Der Wert")} muss <= ${params.maximum} sein`,
|
|
34
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "Der Wert")} muss > ${params.minimum} sein`,
|
|
35
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "Der Wert")} muss < ${params.maximum} sein`,
|
|
36
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "Der Wert")} muss ein Vielfaches von ${params.divisor} sein`,
|
|
37
|
+
INVALID_CONST: (params) => `Erwartet: ${params.expectedValue}`,
|
|
38
|
+
MIN_ITEMS: (params) => `${labelFor(params, "Das Array")} muss mindestens ${params.minimum} Elemente enthalten`,
|
|
39
|
+
MAX_ITEMS: (params) => `${labelFor(params, "Das Array")} darf h\xF6chstens ${params.maximum} Elemente enthalten`,
|
|
40
|
+
UNIQUE_ITEMS: (params) => `Die Elemente von ${labelFor(params, "diesem Array")} m\xFCssen eindeutig sein`,
|
|
41
|
+
CONTAINS: (params) => `${labelFor(params, "Das Array")} muss mindestens ein passendes Element enthalten`,
|
|
42
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "Das Array")} muss mindestens ${params.minimum} passende Elemente enthalten`,
|
|
43
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "Das Array")} darf h\xF6chstens ${params.maximum} passende Elemente enthalten`,
|
|
44
|
+
MISSING_REQUIRED: (params) => `Erforderliche Eigenschaft "${params.property}" fehlt`,
|
|
45
|
+
ADDITIONAL_PROPERTY: (params) => `Unerwartete Eigenschaft "${params.property}"`,
|
|
46
|
+
ADDITIONAL_ITEMS: (params) => `Unerwartetes Element an Index ${params.count}`,
|
|
47
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "Das Objekt")} muss mindestens ${params.minimum} Eigenschaften haben`,
|
|
48
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "Das Objekt")} darf h\xF6chstens ${params.maximum} Eigenschaften haben`,
|
|
49
|
+
INVALID_KEY: (params) => `Ung\xFCltiger Schl\xFCssel "${params.key}"`,
|
|
50
|
+
UNION: () => "Der Wert passt zu keiner Union-Variante",
|
|
51
|
+
ENUM: (params) => `Der Wert muss einer von folgenden sein: ${formatList(params.values)}`,
|
|
52
|
+
UNRESOLVED_REF: () => "Nicht aufgel\xF6ste Schema-Referenz",
|
|
53
|
+
EXCLUDE: () => "Der Wert entspricht einem ausgeschlossenen Schema",
|
|
54
|
+
EXTRACT: () => "Der Wert entspricht nicht dem extrahierten Schema",
|
|
55
|
+
NEVER: () => "Der Wert ist nicht erlaubt",
|
|
56
|
+
NOT: () => "Der Wert entspricht einem negierten Schema",
|
|
57
|
+
KEYOF: (params) => `Der Wert muss einer von folgenden sein: ${formatList(params.values)}`,
|
|
58
|
+
CONDITIONAL: () => "Der Wert passt zu keinem bedingten Zweig",
|
|
59
|
+
INDEX: () => "Der Wert passt zu keinem indexierten Schema",
|
|
60
|
+
IDENTIFIER: () => "G\xFCltiger Bezeichner erwartet",
|
|
61
|
+
BASE: () => "Basisvalidierung fehlgeschlagen",
|
|
62
|
+
REFINE: (params) => params.customMessage ?? "Verfeinerung fehlgeschlagen",
|
|
63
|
+
CALL: () => "Aufrufschema konnte nicht instanziiert werden",
|
|
64
|
+
PARAMETERS_LENGTH: (params) => `${params.count} Parameter erwartet`,
|
|
65
|
+
CUSTOM_TYPE: (params) => `Validierung des benutzerdefinierten Typs "${params.kind}" fehlgeschlagen`
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/error/locales/en.ts
|
|
69
|
+
var enUSCatalog = {
|
|
70
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Expected ${params.expected ?? "value"}` : `Expected ${params.expected ?? "value"}, got ${params.actual}`,
|
|
71
|
+
MIN_LENGTH: (params) => `${labelFor(params, "Value")} must be at least ${params.minimum}`,
|
|
72
|
+
MAX_LENGTH: (params) => `${labelFor(params, "Value")} must be at most ${params.maximum}`,
|
|
73
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "Value")} must match one of: ${formatList(params.patterns)}` : `${labelFor(params, "Value")} must match pattern ${params.pattern}`,
|
|
74
|
+
FORMAT: (params) => `${labelFor(params, "Value")} must match format ${params.format}`,
|
|
75
|
+
MINIMUM: (params) => `${labelFor(params, "Value")} must be >= ${params.minimum}`,
|
|
76
|
+
MAXIMUM: (params) => `${labelFor(params, "Value")} must be <= ${params.maximum}`,
|
|
77
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "Value")} must be > ${params.minimum}`,
|
|
78
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "Value")} must be < ${params.maximum}`,
|
|
79
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "Value")} must be a multiple of ${params.divisor}`,
|
|
80
|
+
INVALID_CONST: (params) => `Expected ${params.expectedValue}`,
|
|
81
|
+
MIN_ITEMS: (params) => `${labelFor(params, "Array")} must have at least ${params.minimum} items`,
|
|
82
|
+
MAX_ITEMS: (params) => `${labelFor(params, "Array")} must have at most ${params.maximum} items`,
|
|
83
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "Array")} items must be unique`,
|
|
84
|
+
CONTAINS: (params) => `${labelFor(params, "Array")} must contain at least one matching item`,
|
|
85
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "Array")} must contain at least ${params.minimum} matching items`,
|
|
86
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "Array")} must contain at most ${params.maximum} matching items`,
|
|
87
|
+
MISSING_REQUIRED: (params) => `Missing required property "${params.property}"`,
|
|
88
|
+
ADDITIONAL_PROPERTY: (params) => `Unexpected property "${params.property}"`,
|
|
89
|
+
ADDITIONAL_ITEMS: (params) => `Unexpected item at index ${params.count}`,
|
|
90
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "Object")} must have at least ${params.minimum} properties`,
|
|
91
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "Object")} must have at most ${params.maximum} properties`,
|
|
92
|
+
INVALID_KEY: (params) => `Invalid record key "${params.key}"`,
|
|
93
|
+
UNION: () => "Value does not match any union variant",
|
|
94
|
+
ENUM: (params) => `Value must be one of: ${formatList(params.values)}`,
|
|
95
|
+
UNRESOLVED_REF: () => "Unresolved schema reference",
|
|
96
|
+
EXCLUDE: () => "Value matched an excluded schema",
|
|
97
|
+
EXTRACT: () => "Value did not match the extracted schema",
|
|
98
|
+
NEVER: () => "Value is not allowed",
|
|
99
|
+
NOT: () => "Value matches a negated schema",
|
|
100
|
+
KEYOF: (params) => `Value must be one of: ${formatList(params.values)}`,
|
|
101
|
+
CONDITIONAL: () => "Value does not match any conditional branch",
|
|
102
|
+
INDEX: () => "Value does not match any indexed schema",
|
|
103
|
+
IDENTIFIER: () => "Expected valid identifier string",
|
|
104
|
+
BASE: () => "Base validation failed",
|
|
105
|
+
REFINE: (params) => params.customMessage ?? "Refinement failed",
|
|
106
|
+
CALL: () => "Unable to instantiate call schema",
|
|
107
|
+
PARAMETERS_LENGTH: (params) => `Expected ${params.count} parameters`,
|
|
108
|
+
CUSTOM_TYPE: (params) => `Custom type validation failed for kind "${params.kind}"`
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/error/locales/es.ts
|
|
112
|
+
var esESCatalog = {
|
|
113
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Se esperaba ${params.expected ?? "un valor"}` : `Se esperaba ${params.expected ?? "un valor"}, se recibi\xF3 ${params.actual}`,
|
|
114
|
+
MIN_LENGTH: (params) => `${labelFor(params, "El valor")} debe ser al menos ${params.minimum}`,
|
|
115
|
+
MAX_LENGTH: (params) => `${labelFor(params, "El valor")} debe ser como m\xE1ximo ${params.maximum}`,
|
|
116
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "El valor")} debe coincidir con uno de: ${formatList(params.patterns)}` : `${labelFor(params, "El valor")} debe coincidir con el patr\xF3n ${params.pattern}`,
|
|
117
|
+
FORMAT: (params) => `${labelFor(params, "El valor")} debe coincidir con el formato ${params.format}`,
|
|
118
|
+
MINIMUM: (params) => `${labelFor(params, "El valor")} debe ser >= ${params.minimum}`,
|
|
119
|
+
MAXIMUM: (params) => `${labelFor(params, "El valor")} debe ser <= ${params.maximum}`,
|
|
120
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "El valor")} debe ser > ${params.minimum}`,
|
|
121
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "El valor")} debe ser < ${params.maximum}`,
|
|
122
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "El valor")} debe ser m\xFAltiplo de ${params.divisor}`,
|
|
123
|
+
INVALID_CONST: (params) => `Se esperaba ${params.expectedValue}`,
|
|
124
|
+
MIN_ITEMS: (params) => `${labelFor(params, "El arreglo")} debe tener al menos ${params.minimum} elementos`,
|
|
125
|
+
MAX_ITEMS: (params) => `${labelFor(params, "El arreglo")} debe tener como m\xE1ximo ${params.maximum} elementos`,
|
|
126
|
+
UNIQUE_ITEMS: (params) => `Los elementos de ${labelFor(params, "este arreglo")} deben ser \xFAnicos`,
|
|
127
|
+
CONTAINS: (params) => `${labelFor(params, "El arreglo")} debe contener al menos un elemento coincidente`,
|
|
128
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "El arreglo")} debe contener al menos ${params.minimum} elementos coincidentes`,
|
|
129
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "El arreglo")} debe contener como m\xE1ximo ${params.maximum} elementos coincidentes`,
|
|
130
|
+
MISSING_REQUIRED: (params) => `Falta la propiedad requerida "${params.property}"`,
|
|
131
|
+
ADDITIONAL_PROPERTY: (params) => `Propiedad inesperada "${params.property}"`,
|
|
132
|
+
ADDITIONAL_ITEMS: (params) => `Elemento inesperado en el \xEDndice ${params.count}`,
|
|
133
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "El objeto")} debe tener al menos ${params.minimum} propiedades`,
|
|
134
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "El objeto")} debe tener como m\xE1ximo ${params.maximum} propiedades`,
|
|
135
|
+
INVALID_KEY: (params) => `Clave de registro no v\xE1lida "${params.key}"`,
|
|
136
|
+
UNION: () => "El valor no coincide con ninguna variante de la uni\xF3n",
|
|
137
|
+
ENUM: (params) => `El valor debe ser uno de: ${formatList(params.values)}`,
|
|
138
|
+
UNRESOLVED_REF: () => "Referencia de esquema no resuelta",
|
|
139
|
+
EXCLUDE: () => "El valor coincidi\xF3 con un esquema excluido",
|
|
140
|
+
EXTRACT: () => "El valor no coincidi\xF3 con el esquema extra\xEDdo",
|
|
141
|
+
NEVER: () => "El valor no est\xE1 permitido",
|
|
142
|
+
NOT: () => "El valor coincide con un esquema negado",
|
|
143
|
+
KEYOF: (params) => `El valor debe ser uno de: ${formatList(params.values)}`,
|
|
144
|
+
CONDITIONAL: () => "El valor no coincide con ninguna rama condicional",
|
|
145
|
+
INDEX: () => "El valor no coincide con ning\xFAn esquema indexado",
|
|
146
|
+
IDENTIFIER: () => "Se esperaba una cadena identificadora v\xE1lida",
|
|
147
|
+
BASE: () => "La validaci\xF3n base fall\xF3",
|
|
148
|
+
REFINE: (params) => params.customMessage ?? "La validaci\xF3n refinada fall\xF3",
|
|
149
|
+
CALL: () => "No se pudo instanciar el esquema de llamada",
|
|
150
|
+
PARAMETERS_LENGTH: (params) => `Se esperaban ${params.count} par\xE1metros`,
|
|
151
|
+
CUSTOM_TYPE: (params) => `La validaci\xF3n del tipo personalizado "${params.kind}" fall\xF3`
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/error/locales/fr.ts
|
|
155
|
+
var frFRCatalog = {
|
|
156
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Valeur attendue: ${params.expected ?? "valeur"}` : `Valeur attendue: ${params.expected ?? "valeur"}, re\xE7u: ${params.actual}`,
|
|
157
|
+
MIN_LENGTH: (params) => `${labelFor(params, "La valeur")} doit \xEAtre au moins ${params.minimum}`,
|
|
158
|
+
MAX_LENGTH: (params) => `${labelFor(params, "La valeur")} doit \xEAtre au plus ${params.maximum}`,
|
|
159
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "La valeur")} doit correspondre \xE0 l'un de: ${formatList(params.patterns)}` : `${labelFor(params, "La valeur")} doit correspondre au motif ${params.pattern}`,
|
|
160
|
+
FORMAT: (params) => `${labelFor(params, "La valeur")} doit respecter le format ${params.format}`,
|
|
161
|
+
MINIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre >= ${params.minimum}`,
|
|
162
|
+
MAXIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre <= ${params.maximum}`,
|
|
163
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre > ${params.minimum}`,
|
|
164
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "La valeur")} doit \xEAtre < ${params.maximum}`,
|
|
165
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "La valeur")} doit \xEAtre un multiple de ${params.divisor}`,
|
|
166
|
+
INVALID_CONST: (params) => `Valeur attendue: ${params.expectedValue}`,
|
|
167
|
+
MIN_ITEMS: (params) => `${labelFor(params, "Le tableau")} doit contenir au moins ${params.minimum} \xE9l\xE9ments`,
|
|
168
|
+
MAX_ITEMS: (params) => `${labelFor(params, "Le tableau")} doit contenir au plus ${params.maximum} \xE9l\xE9ments`,
|
|
169
|
+
UNIQUE_ITEMS: (params) => `Les \xE9l\xE9ments de ${labelFor(params, "ce tableau")} doivent \xEAtre uniques`,
|
|
170
|
+
CONTAINS: (params) => `${labelFor(params, "Le tableau")} doit contenir au moins un \xE9l\xE9ment correspondant`,
|
|
171
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "Le tableau")} doit contenir au moins ${params.minimum} \xE9l\xE9ments correspondants`,
|
|
172
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "Le tableau")} doit contenir au plus ${params.maximum} \xE9l\xE9ments correspondants`,
|
|
173
|
+
MISSING_REQUIRED: (params) => `Propri\xE9t\xE9 requise manquante "${params.property}"`,
|
|
174
|
+
ADDITIONAL_PROPERTY: (params) => `Propri\xE9t\xE9 inattendue "${params.property}"`,
|
|
175
|
+
ADDITIONAL_ITEMS: (params) => `\xC9l\xE9ment inattendu \xE0 l'index ${params.count}`,
|
|
176
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "L\u2019objet")} doit avoir au moins ${params.minimum} propri\xE9t\xE9s`,
|
|
177
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "L\u2019objet")} doit avoir au plus ${params.maximum} propri\xE9t\xE9s`,
|
|
178
|
+
INVALID_KEY: (params) => `Cl\xE9 d\u2019enregistrement invalide "${params.key}"`,
|
|
179
|
+
UNION: () => "La valeur ne correspond \xE0 aucune variante de l\u2019union",
|
|
180
|
+
ENUM: (params) => `La valeur doit \xEAtre l\u2019une de: ${formatList(params.values)}`,
|
|
181
|
+
UNRESOLVED_REF: () => "R\xE9f\xE9rence de sch\xE9ma non r\xE9solue",
|
|
182
|
+
EXCLUDE: () => "La valeur correspond \xE0 un sch\xE9ma exclu",
|
|
183
|
+
EXTRACT: () => "La valeur ne correspond pas au sch\xE9ma extrait",
|
|
184
|
+
NEVER: () => "La valeur n\u2019est pas autoris\xE9e",
|
|
185
|
+
NOT: () => "La valeur correspond \xE0 un sch\xE9ma n\xE9gatif",
|
|
186
|
+
KEYOF: (params) => `La valeur doit \xEAtre l\u2019une de: ${formatList(params.values)}`,
|
|
187
|
+
CONDITIONAL: () => "La valeur ne correspond \xE0 aucune branche conditionnelle",
|
|
188
|
+
INDEX: () => "La valeur ne correspond \xE0 aucun sch\xE9ma index\xE9",
|
|
189
|
+
IDENTIFIER: () => "Identifiant attendu valide",
|
|
190
|
+
BASE: () => "La validation de base a \xE9chou\xE9",
|
|
191
|
+
REFINE: (params) => params.customMessage ?? "Le raffinement a \xE9chou\xE9",
|
|
192
|
+
CALL: () => "Impossible d\u2019instancier le sch\xE9ma d\u2019appel",
|
|
193
|
+
PARAMETERS_LENGTH: (params) => `${params.count} param\xE8tres attendus`,
|
|
194
|
+
CUSTOM_TYPE: (params) => `La validation du type personnalis\xE9 "${params.kind}" a \xE9chou\xE9`
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/error/locales/ja.ts
|
|
198
|
+
var jaJPCatalog = {
|
|
199
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `${params.expected ?? "\u5024"}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059` : `${params.expected ?? "\u5024"}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u5B9F\u969B\u306E\u578B: ${params.actual}`,
|
|
200
|
+
MIN_LENGTH: (params) => `${labelFor(params, "\u5024")}\u306F\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
201
|
+
MAX_LENGTH: (params) => `${labelFor(params, "\u5024")}\u306F\u6700\u5927\u3067${params.maximum}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
202
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\u5024")}\u306F\u6B21\u306E\u3044\u305A\u308C\u304B\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: ${formatList(params.patterns)}` : `${labelFor(params, "\u5024")}\u306F\u30D1\u30BF\u30FC\u30F3${params.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
203
|
+
FORMAT: (params) => `${labelFor(params, "\u5024")}\u306F\u5F62\u5F0F${params.format}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
204
|
+
MINIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.minimum}\u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
205
|
+
MAXIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.maximum}\u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
206
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.minimum}\u3088\u308A\u5927\u304D\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
207
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "\u5024")}\u306F${params.maximum}\u3088\u308A\u5C0F\u3055\u3044\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
208
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "\u5024")}\u306F${params.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
209
|
+
INVALID_CONST: (params) => `${params.expectedValue}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
210
|
+
MIN_ITEMS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u500B\u306E\u9805\u76EE\u304C\u5FC5\u8981\u3067\u3059`,
|
|
211
|
+
MAX_ITEMS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u6700\u5927${params.maximum}\u500B\u306E\u9805\u76EE\u307E\u3067\u8A31\u53EF\u3055\u308C\u307E\u3059`,
|
|
212
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "\u914D\u5217")}\u306E\u9805\u76EE\u306F\u4E00\u610F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
213
|
+
CONTAINS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u4E00\u81F4\u3059\u308B\u9805\u76EE\u304C\u5C11\u306A\u304F\u3068\u30821\u3064\u5FC5\u8981\u3067\u3059`,
|
|
214
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u4E00\u81F4\u3059\u308B\u9805\u76EE\u304C\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u500B\u5FC5\u8981\u3067\u3059`,
|
|
215
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "\u914D\u5217")}\u306B\u306F\u4E00\u81F4\u3059\u308B\u9805\u76EE\u3092\u6700\u5927${params.maximum}\u500B\u307E\u3067\u542B\u3081\u3089\u308C\u307E\u3059`,
|
|
216
|
+
MISSING_REQUIRED: (params) => `\u5FC5\u9808\u30D7\u30ED\u30D1\u30C6\u30A3"${params.property}"\u304C\u3042\u308A\u307E\u305B\u3093`,
|
|
217
|
+
ADDITIONAL_PROPERTY: (params) => `\u4E88\u671F\u3057\u306A\u3044\u30D7\u30ED\u30D1\u30C6\u30A3"${params.property}"\u3067\u3059`,
|
|
218
|
+
ADDITIONAL_ITEMS: (params) => `\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9${params.count}\u306B\u4E88\u671F\u3057\u306A\u3044\u9805\u76EE\u304C\u3042\u308A\u307E\u3059`,
|
|
219
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8")}\u306B\u306F\u5C11\u306A\u304F\u3068\u3082${params.minimum}\u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u5FC5\u8981\u3067\u3059`,
|
|
220
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8")}\u306B\u306F\u6700\u5927${params.maximum}\u500B\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u307E\u3067\u8A31\u53EF\u3055\u308C\u307E\u3059`,
|
|
221
|
+
INVALID_KEY: (params) => `\u7121\u52B9\u306A\u30EC\u30B3\u30FC\u30C9\u30AD\u30FC"${params.key}"\u3067\u3059`,
|
|
222
|
+
UNION: () => "\u5024\u304C\u3069\u306E\u30E6\u30CB\u30AA\u30F3\u5206\u5C90\u306B\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
223
|
+
ENUM: (params) => `\u5024\u306F\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: ${formatList(params.values)}`,
|
|
224
|
+
UNRESOLVED_REF: () => "\u89E3\u6C7A\u3067\u304D\u306A\u3044\u30B9\u30AD\u30FC\u30DE\u53C2\u7167\u3067\u3059",
|
|
225
|
+
EXCLUDE: () => "\u5024\u304C\u9664\u5916\u3055\u308C\u305F\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3057\u307E\u3057\u305F",
|
|
226
|
+
EXTRACT: () => "\u5024\u304C\u62BD\u51FA\u3055\u308C\u305F\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
227
|
+
NEVER: () => "\u5024\u306F\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093",
|
|
228
|
+
NOT: () => "\u5024\u304C\u5426\u5B9A\u30B9\u30AD\u30FC\u30DE\u306B\u4E00\u81F4\u3057\u3066\u3044\u307E\u3059",
|
|
229
|
+
KEYOF: (params) => `\u5024\u306F\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: ${formatList(params.values)}`,
|
|
230
|
+
CONDITIONAL: () => "\u5024\u304C\u3069\u306E\u6761\u4EF6\u5206\u5C90\u306B\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
231
|
+
INDEX: () => "\u5024\u304C\u3069\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u5019\u88DC\u30B9\u30AD\u30FC\u30DE\u306B\u3082\u4E00\u81F4\u3057\u307E\u305B\u3093",
|
|
232
|
+
IDENTIFIER: () => "\u6709\u52B9\u306A\u8B58\u5225\u5B50\u6587\u5B57\u5217\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
|
|
233
|
+
BASE: () => "\u57FA\u672C\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
234
|
+
REFINE: (params) => params.customMessage ?? "\u8FFD\u52A0\u6761\u4EF6\u306E\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F",
|
|
235
|
+
CALL: () => "\u547C\u3073\u51FA\u3057\u30B9\u30AD\u30FC\u30DE\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093",
|
|
236
|
+
PARAMETERS_LENGTH: (params) => `\u30D1\u30E9\u30E1\u30FC\u30BF\u306F${params.count}\u500B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`,
|
|
237
|
+
CUSTOM_TYPE: (params) => `\u30AB\u30B9\u30BF\u30E0\u578B"${params.kind}"\u306E\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F`
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// src/error/locales/ko.ts
|
|
241
|
+
var koKRCatalog = {
|
|
242
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `${params.expected ?? "\uAC12"}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4` : `${params.expected ?? "\uAC12"}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4. \uD604\uC7AC \uAC12 \uC720\uD615: ${params.actual}`,
|
|
243
|
+
MIN_LENGTH: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) \uCD5C\uC18C ${params.minimum}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
244
|
+
MAX_LENGTH: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) \uCD5C\uB300 ${params.maximum}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
245
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\uAC12")}\uC740(\uB294) \uB2E4\uC74C \uC911 \uD558\uB098\uC640 \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4: ${formatList(params.patterns)}` : `${labelFor(params, "\uAC12")}\uC740(\uB294) \uD328\uD134 ${params.pattern}\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`,
|
|
246
|
+
FORMAT: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.format} \uD615\uC2DD\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
247
|
+
MINIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.minimum} \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
248
|
+
MAXIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.maximum} \uC774\uD558\uC5EC\uC57C \uD569\uB2C8\uB2E4`,
|
|
249
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.minimum}\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4`,
|
|
250
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.maximum}\uBCF4\uB2E4 \uC791\uC544\uC57C \uD569\uB2C8\uB2E4`,
|
|
251
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "\uAC12")}\uC740(\uB294) ${params.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`,
|
|
252
|
+
INVALID_CONST: (params) => `${params.expectedValue}\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
253
|
+
MIN_ITEMS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC740(\uB294) \uCD5C\uC18C ${params.minimum}\uAC1C \uD56D\uBAA9\uC774 \uD544\uC694\uD569\uB2C8\uB2E4`,
|
|
254
|
+
MAX_ITEMS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC740(\uB294) \uCD5C\uB300 ${params.maximum}\uAC1C \uD56D\uBAA9\uB9CC \uD5C8\uC6A9\uB429\uB2C8\uB2E4`,
|
|
255
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "\uBC30\uC5F4")} \uD56D\uBAA9\uC740 \uACE0\uC720\uD574\uC57C \uD569\uB2C8\uB2E4`,
|
|
256
|
+
CONTAINS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC5D0 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uD558\uB098 \uC774\uC0C1 \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
257
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC5D0 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uCD5C\uC18C ${params.minimum}\uAC1C \uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4`,
|
|
258
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "\uBC30\uC5F4")}\uC5D0 \uC77C\uCE58\uD558\uB294 \uD56D\uBAA9\uC774 \uCD5C\uB300 ${params.maximum}\uAC1C\uAE4C\uC9C0\uB9CC \uD5C8\uC6A9\uB429\uB2C8\uB2E4`,
|
|
259
|
+
MISSING_REQUIRED: (params) => `\uD544\uC218 \uC18D\uC131 "${params.property}"\uC774(\uAC00) \uC5C6\uC2B5\uB2C8\uB2E4`,
|
|
260
|
+
ADDITIONAL_PROPERTY: (params) => `\uC608\uC0C1\uD558\uC9C0 \uBABB\uD55C \uC18D\uC131 "${params.property}"\uC785\uB2C8\uB2E4`,
|
|
261
|
+
ADDITIONAL_ITEMS: (params) => `\uC778\uB371\uC2A4 ${params.count}\uC758 \uD56D\uBAA9\uC740 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4`,
|
|
262
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\uAC1D\uCCB4")}\uC5D0\uB294 \uCD5C\uC18C ${params.minimum}\uAC1C\uC758 \uC18D\uC131\uC774 \uD544\uC694\uD569\uB2C8\uB2E4`,
|
|
263
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\uAC1D\uCCB4")}\uC5D0\uB294 \uCD5C\uB300 ${params.maximum}\uAC1C\uC758 \uC18D\uC131\uB9CC \uD5C8\uC6A9\uB429\uB2C8\uB2E4`,
|
|
264
|
+
INVALID_KEY: (params) => `\uB808\uCF54\uB4DC \uD0A4 "${params.key}"\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4`,
|
|
265
|
+
UNION: () => "\uAC12\uC774 \uC5B4\uB5A4 \uC720\uB2C8\uC5B8 \uBD84\uAE30\uC640\uB3C4 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
266
|
+
ENUM: (params) => `\uAC12\uC740 \uB2E4\uC74C \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${formatList(params.values)}`,
|
|
267
|
+
UNRESOLVED_REF: () => "\uC2A4\uD0A4\uB9C8 \uCC38\uC870\uB97C \uD655\uC778\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
|
|
268
|
+
EXCLUDE: () => "\uAC12\uC774 \uC81C\uC678\uB41C \uC2A4\uD0A4\uB9C8\uC640 \uC77C\uCE58\uD588\uC2B5\uB2C8\uB2E4",
|
|
269
|
+
EXTRACT: () => "\uAC12\uC774 \uCD94\uCD9C\uB41C \uC2A4\uD0A4\uB9C8\uC640 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
270
|
+
NEVER: () => "\uAC12\uC774 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
271
|
+
NOT: () => "\uAC12\uC774 \uBD80\uC815 \uC2A4\uD0A4\uB9C8\uC640 \uC77C\uCE58\uD569\uB2C8\uB2E4",
|
|
272
|
+
KEYOF: (params) => `\uAC12\uC740 \uB2E4\uC74C \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${formatList(params.values)}`,
|
|
273
|
+
CONDITIONAL: () => "\uAC12\uC774 \uC5B4\uB5A4 \uC870\uAC74 \uBD84\uAE30\uC640\uB3C4 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
274
|
+
INDEX: () => "\uAC12\uC774 \uC5B4\uB5A4 \uC778\uB371\uC2A4 \uD6C4\uBCF4 \uC2A4\uD0A4\uB9C8\uC640\uB3C4 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4",
|
|
275
|
+
IDENTIFIER: () => "\uC62C\uBC14\uB978 \uC2DD\uBCC4\uC790 \uBB38\uC790\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4",
|
|
276
|
+
BASE: () => "\uAE30\uBCF8 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4",
|
|
277
|
+
REFINE: (params) => params.customMessage ?? "\uC138\uBD80 \uC870\uAC74 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4",
|
|
278
|
+
CALL: () => "\uD638\uCD9C \uC2A4\uD0A4\uB9C8\uB97C \uC778\uC2A4\uD134\uC2A4\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4",
|
|
279
|
+
PARAMETERS_LENGTH: (params) => `\uB9E4\uAC1C\uBCC0\uC218\uB294 ${params.count}\uAC1C\uC5EC\uC57C \uD569\uB2C8\uB2E4`,
|
|
280
|
+
CUSTOM_TYPE: (params) => `\uC0AC\uC6A9\uC790 \uC815\uC758 \uD0C0\uC785 "${params.kind}" \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4`
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/error/locales/pt.ts
|
|
284
|
+
var ptBRCatalog = {
|
|
285
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `Esperado ${params.expected ?? "valor"}` : `Esperado ${params.expected ?? "valor"}, recebido ${params.actual}`,
|
|
286
|
+
MIN_LENGTH: (params) => `${labelFor(params, "O valor")} deve ser no m\xEDnimo ${params.minimum}`,
|
|
287
|
+
MAX_LENGTH: (params) => `${labelFor(params, "O valor")} deve ser no m\xE1ximo ${params.maximum}`,
|
|
288
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "O valor")} deve corresponder a um destes padr\xF5es: ${formatList(params.patterns)}` : `${labelFor(params, "O valor")} deve corresponder ao padr\xE3o ${params.pattern}`,
|
|
289
|
+
FORMAT: (params) => `${labelFor(params, "O valor")} deve corresponder ao formato ${params.format}`,
|
|
290
|
+
MINIMUM: (params) => `${labelFor(params, "O valor")} deve ser >= ${params.minimum}`,
|
|
291
|
+
MAXIMUM: (params) => `${labelFor(params, "O valor")} deve ser <= ${params.maximum}`,
|
|
292
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "O valor")} deve ser > ${params.minimum}`,
|
|
293
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "O valor")} deve ser < ${params.maximum}`,
|
|
294
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "O valor")} deve ser m\xFAltiplo de ${params.divisor}`,
|
|
295
|
+
INVALID_CONST: (params) => `Esperado ${params.expectedValue}`,
|
|
296
|
+
MIN_ITEMS: (params) => `${labelFor(params, "O array")} deve ter pelo menos ${params.minimum} itens`,
|
|
297
|
+
MAX_ITEMS: (params) => `${labelFor(params, "O array")} deve ter no m\xE1ximo ${params.maximum} itens`,
|
|
298
|
+
UNIQUE_ITEMS: (params) => `Os itens de ${labelFor(params, "este array")} devem ser \xFAnicos`,
|
|
299
|
+
CONTAINS: (params) => `${labelFor(params, "O array")} deve conter ao menos um item correspondente`,
|
|
300
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "O array")} deve conter pelo menos ${params.minimum} itens correspondentes`,
|
|
301
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "O array")} deve conter no m\xE1ximo ${params.maximum} itens correspondentes`,
|
|
302
|
+
MISSING_REQUIRED: (params) => `Propriedade obrigat\xF3ria ausente "${params.property}"`,
|
|
303
|
+
ADDITIONAL_PROPERTY: (params) => `Propriedade inesperada "${params.property}"`,
|
|
304
|
+
ADDITIONAL_ITEMS: (params) => `Item inesperado no \xEDndice ${params.count}`,
|
|
305
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "O objeto")} deve ter pelo menos ${params.minimum} propriedades`,
|
|
306
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "O objeto")} deve ter no m\xE1ximo ${params.maximum} propriedades`,
|
|
307
|
+
INVALID_KEY: (params) => `Chave inv\xE1lida "${params.key}"`,
|
|
308
|
+
UNION: () => "O valor n\xE3o corresponde a nenhuma variante da uni\xE3o",
|
|
309
|
+
ENUM: (params) => `O valor deve ser um destes: ${formatList(params.values)}`,
|
|
310
|
+
UNRESOLVED_REF: () => "Refer\xEAncia de esquema n\xE3o resolvida",
|
|
311
|
+
EXCLUDE: () => "O valor correspondeu a um esquema exclu\xEDdo",
|
|
312
|
+
EXTRACT: () => "O valor n\xE3o correspondeu ao esquema extra\xEDdo",
|
|
313
|
+
NEVER: () => "O valor n\xE3o \xE9 permitido",
|
|
314
|
+
NOT: () => "O valor corresponde a um esquema negado",
|
|
315
|
+
KEYOF: (params) => `O valor deve ser um destes: ${formatList(params.values)}`,
|
|
316
|
+
CONDITIONAL: () => "O valor n\xE3o corresponde a nenhum ramo condicional",
|
|
317
|
+
INDEX: () => "O valor n\xE3o corresponde a nenhum esquema indexado",
|
|
318
|
+
IDENTIFIER: () => "Era esperado um identificador v\xE1lido",
|
|
319
|
+
BASE: () => "A valida\xE7\xE3o base falhou",
|
|
320
|
+
REFINE: (params) => params.customMessage ?? "A valida\xE7\xE3o refinada falhou",
|
|
321
|
+
CALL: () => "N\xE3o foi poss\xEDvel instanciar o esquema de chamada",
|
|
322
|
+
PARAMETERS_LENGTH: (params) => `Esperados ${params.count} par\xE2metros`,
|
|
323
|
+
CUSTOM_TYPE: (params) => `A valida\xE7\xE3o do tipo personalizado "${params.kind}" falhou`
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// src/error/locales/zh.ts
|
|
327
|
+
var zhHansCatalog = {
|
|
328
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `\u5E94\u4E3A${params.expected ?? "\u503C"}` : `\u5E94\u4E3A${params.expected ?? "\u503C"}\uFF0C\u5B9E\u9645\u7C7B\u578B\u4E3A${params.actual}`,
|
|
329
|
+
MIN_LENGTH: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B\u81F3\u5C11\u4E3A${params.minimum}`,
|
|
330
|
+
MAX_LENGTH: (params) => `${labelFor(params, "\u503C")}\u6700\u591A\u53EA\u80FD\u4E3A${params.maximum}`,
|
|
331
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\u503C")}\u5FC5\u987B\u5339\u914D\u4EE5\u4E0B\u4E4B\u4E00\uFF1A${formatList(params.patterns)}` : `${labelFor(params, "\u503C")}\u5FC5\u987B\u5339\u914D\u6A21\u5F0F${params.pattern}`,
|
|
332
|
+
FORMAT: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B\u5339\u914D\u683C\u5F0F${params.format}`,
|
|
333
|
+
MINIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B >= ${params.minimum}`,
|
|
334
|
+
MAXIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B <= ${params.maximum}`,
|
|
335
|
+
EXCLUSIVE_MINIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B > ${params.minimum}`,
|
|
336
|
+
EXCLUSIVE_MAXIMUM: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B < ${params.maximum}`,
|
|
337
|
+
MULTIPLE_OF: (params) => `${labelFor(params, "\u503C")}\u5FC5\u987B\u662F${params.divisor}\u7684\u500D\u6570`,
|
|
338
|
+
INVALID_CONST: (params) => `\u5E94\u4E3A${params.expectedValue}`,
|
|
339
|
+
MIN_ITEMS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u81F3\u5C11\u9700\u8981${params.minimum}\u4E2A\u9879\u76EE`,
|
|
340
|
+
MAX_ITEMS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u6700\u591A\u53EA\u80FD\u6709${params.maximum}\u4E2A\u9879\u76EE`,
|
|
341
|
+
UNIQUE_ITEMS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u4E2D\u7684\u9879\u76EE\u5FC5\u987B\u552F\u4E00`,
|
|
342
|
+
CONTAINS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u81F3\u5C11\u8981\u5305\u542B\u4E00\u4E2A\u5339\u914D\u9879\u76EE`,
|
|
343
|
+
MIN_CONTAINS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u81F3\u5C11\u8981\u5305\u542B${params.minimum}\u4E2A\u5339\u914D\u9879\u76EE`,
|
|
344
|
+
MAX_CONTAINS: (params) => `${labelFor(params, "\u6570\u7EC4")}\u6700\u591A\u53EA\u80FD\u5305\u542B${params.maximum}\u4E2A\u5339\u914D\u9879\u76EE`,
|
|
345
|
+
MISSING_REQUIRED: (params) => `\u7F3A\u5C11\u5FC5\u586B\u5C5E\u6027"${params.property}"`,
|
|
346
|
+
ADDITIONAL_PROPERTY: (params) => `\u5B58\u5728\u672A\u9884\u671F\u7684\u5C5E\u6027"${params.property}"`,
|
|
347
|
+
ADDITIONAL_ITEMS: (params) => `\u7D22\u5F15${params.count}\u5904\u5B58\u5728\u672A\u9884\u671F\u7684\u9879\u76EE`,
|
|
348
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\u5BF9\u8C61")}\u81F3\u5C11\u9700\u8981${params.minimum}\u4E2A\u5C5E\u6027`,
|
|
349
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\u5BF9\u8C61")}\u6700\u591A\u53EA\u80FD\u6709${params.maximum}\u4E2A\u5C5E\u6027`,
|
|
350
|
+
INVALID_KEY: (params) => `\u65E0\u6548\u7684\u8BB0\u5F55\u952E"${params.key}"`,
|
|
351
|
+
UNION: () => "\u503C\u4E0D\u7B26\u5408\u4EFB\u4F55\u8054\u5408\u5206\u652F",
|
|
352
|
+
ENUM: (params) => `\u503C\u5FC5\u987B\u662F\u4EE5\u4E0B\u4E4B\u4E00\uFF1A${formatList(params.values)}`,
|
|
353
|
+
UNRESOLVED_REF: () => "\u65E0\u6CD5\u89E3\u6790\u7684\u6A21\u5F0F\u5F15\u7528",
|
|
354
|
+
EXCLUDE: () => "\u503C\u5339\u914D\u4E86\u88AB\u6392\u9664\u7684\u6A21\u5F0F",
|
|
355
|
+
EXTRACT: () => "\u503C\u4E0D\u5339\u914D\u63D0\u53D6\u540E\u7684\u6A21\u5F0F",
|
|
356
|
+
NEVER: () => "\u4E0D\u5141\u8BB8\u8BE5\u503C",
|
|
357
|
+
NOT: () => "\u503C\u5339\u914D\u4E86\u5426\u5B9A\u6A21\u5F0F",
|
|
358
|
+
KEYOF: (params) => `\u503C\u5FC5\u987B\u662F\u4EE5\u4E0B\u4E4B\u4E00\uFF1A${formatList(params.values)}`,
|
|
359
|
+
CONDITIONAL: () => "\u503C\u4E0D\u5339\u914D\u4EFB\u4F55\u6761\u4EF6\u5206\u652F",
|
|
360
|
+
INDEX: () => "\u503C\u4E0D\u5339\u914D\u4EFB\u4F55\u7D22\u5F15\u6A21\u5F0F",
|
|
361
|
+
IDENTIFIER: () => "\u5FC5\u987B\u662F\u6709\u6548\u7684\u6807\u8BC6\u7B26\u5B57\u7B26\u4E32",
|
|
362
|
+
BASE: () => "\u57FA\u7840\u9A8C\u8BC1\u5931\u8D25",
|
|
363
|
+
REFINE: (params) => params.customMessage ?? "\u7EC6\u5316\u9A8C\u8BC1\u5931\u8D25",
|
|
364
|
+
CALL: () => "\u65E0\u6CD5\u5B9E\u4F8B\u5316\u8C03\u7528\u6A21\u5F0F",
|
|
365
|
+
PARAMETERS_LENGTH: (params) => `\u53C2\u6570\u6570\u91CF\u5FC5\u987B\u4E3A${params.count}`,
|
|
366
|
+
CUSTOM_TYPE: (params) => `\u81EA\u5B9A\u4E49\u7C7B\u578B"${params.kind}"\u9A8C\u8BC1\u5931\u8D25`
|
|
367
|
+
};
|
|
368
|
+
var zhHantCatalog = {
|
|
369
|
+
...zhHansCatalog,
|
|
370
|
+
INVALID_TYPE: (params) => params.actual === undefined ? `\u61C9\u70BA${params.expected ?? "\u503C"}` : `\u61C9\u70BA${params.expected ?? "\u503C"}\uFF0C\u5BE6\u969B\u985E\u578B\u70BA${params.actual}`,
|
|
371
|
+
PATTERN: (params) => params.patterns !== undefined ? `${labelFor(params, "\u503C")}\u5FC5\u9808\u7B26\u5408\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00\uFF1A${formatList(params.patterns)}` : `${labelFor(params, "\u503C")}\u5FC5\u9808\u7B26\u5408\u6A21\u5F0F${params.pattern}`,
|
|
372
|
+
MISSING_REQUIRED: (params) => `\u7F3A\u5C11\u5FC5\u8981\u5C6C\u6027"${params.property}"`,
|
|
373
|
+
ADDITIONAL_PROPERTY: (params) => `\u5B58\u5728\u672A\u9810\u671F\u7684\u5C6C\u6027"${params.property}"`,
|
|
374
|
+
ADDITIONAL_ITEMS: (params) => `\u7D22\u5F15${params.count}\u8655\u5B58\u5728\u672A\u9810\u671F\u7684\u9805\u76EE`,
|
|
375
|
+
MIN_PROPERTIES: (params) => `${labelFor(params, "\u7269\u4EF6")}\u81F3\u5C11\u9700\u8981${params.minimum}\u500B\u5C6C\u6027`,
|
|
376
|
+
MAX_PROPERTIES: (params) => `${labelFor(params, "\u7269\u4EF6")}\u6700\u591A\u53EA\u80FD\u6709${params.maximum}\u500B\u5C6C\u6027`,
|
|
377
|
+
INVALID_KEY: (params) => `\u7121\u6548\u7684\u8A18\u9304\u9375"${params.key}"`,
|
|
378
|
+
UNRESOLVED_REF: () => "\u7121\u6CD5\u89E3\u6790\u7684\u7D50\u69CB\u53C3\u7167",
|
|
379
|
+
EXCLUDE: () => "\u503C\u7B26\u5408\u88AB\u6392\u9664\u7684\u7D50\u69CB",
|
|
380
|
+
EXTRACT: () => "\u503C\u4E0D\u7B26\u5408\u63D0\u53D6\u5F8C\u7684\u7D50\u69CB",
|
|
381
|
+
NEVER: () => "\u4E0D\u5141\u8A31\u6B64\u503C",
|
|
382
|
+
CONDITIONAL: () => "\u503C\u4E0D\u7B26\u5408\u4EFB\u4F55\u689D\u4EF6\u5206\u652F",
|
|
383
|
+
INDEX: () => "\u503C\u4E0D\u7B26\u5408\u4EFB\u4F55\u7D22\u5F15\u7D50\u69CB",
|
|
384
|
+
IDENTIFIER: () => "\u5FC5\u9808\u662F\u6709\u6548\u7684\u8B58\u5225\u5B57\u4E32",
|
|
385
|
+
BASE: () => "\u57FA\u790E\u9A57\u8B49\u5931\u6557",
|
|
386
|
+
REFINE: (params) => params.customMessage ?? "\u7D30\u5316\u9A57\u8B49\u5931\u6557",
|
|
387
|
+
CALL: () => "\u7121\u6CD5\u5BE6\u4F8B\u5316\u547C\u53EB\u7D50\u69CB",
|
|
388
|
+
PARAMETERS_LENGTH: (params) => `\u53C3\u6578\u6578\u91CF\u5FC5\u9808\u70BA${params.count}`,
|
|
389
|
+
CUSTOM_TYPE: (params) => `\u81EA\u8A02\u985E\u578B"${params.kind}"\u9A57\u8B49\u5931\u6557`
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// src/shared/locale.ts
|
|
393
|
+
var LocaleCodes = {
|
|
394
|
+
ar_001: "ar_001",
|
|
395
|
+
bn_BD: "bn_BD",
|
|
396
|
+
cs_CZ: "cs_CZ",
|
|
397
|
+
de_DE: "de_DE",
|
|
398
|
+
el_GR: "el_GR",
|
|
399
|
+
en_US: "en_US",
|
|
400
|
+
es_419: "es_419",
|
|
401
|
+
es_AR: "es_AR",
|
|
402
|
+
es_ES: "es_ES",
|
|
403
|
+
es_MX: "es_MX",
|
|
404
|
+
fa_IR: "fa_IR",
|
|
405
|
+
fil_PH: "fil_PH",
|
|
406
|
+
fr_CA: "fr_CA",
|
|
407
|
+
fr_FR: "fr_FR",
|
|
408
|
+
ha_NG: "ha_NG",
|
|
409
|
+
hi_IN: "hi_IN",
|
|
410
|
+
hu_HU: "hu_HU",
|
|
411
|
+
id_ID: "id_ID",
|
|
412
|
+
it_IT: "it_IT",
|
|
413
|
+
ja_JP: "ja_JP",
|
|
414
|
+
ko_KR: "ko_KR",
|
|
415
|
+
ms_MY: "ms_MY",
|
|
416
|
+
nl_NL: "nl_NL",
|
|
417
|
+
pl_PL: "pl_PL",
|
|
418
|
+
pt_BR: "pt_BR",
|
|
419
|
+
pt_PT: "pt_PT",
|
|
420
|
+
ro_RO: "ro_RO",
|
|
421
|
+
ru_RU: "ru_RU",
|
|
422
|
+
sv_SE: "sv_SE",
|
|
423
|
+
sw_TZ: "sw_TZ",
|
|
424
|
+
th_TH: "th_TH",
|
|
425
|
+
tr_TR: "tr_TR",
|
|
426
|
+
uk_UA: "uk_UA",
|
|
427
|
+
ur_PK: "ur_PK",
|
|
428
|
+
vi_VN: "vi_VN",
|
|
429
|
+
yo_NG: "yo_NG",
|
|
430
|
+
zh_Hans: "zh_Hans",
|
|
431
|
+
zh_Hant: "zh_Hant"
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// src/locale/index.ts
|
|
435
|
+
var ar_001 = enUSCatalog;
|
|
436
|
+
var bn_BD = enUSCatalog;
|
|
437
|
+
var cs_CZ = enUSCatalog;
|
|
438
|
+
var de_DE = deDECatalog;
|
|
439
|
+
var el_GR = enUSCatalog;
|
|
440
|
+
var en_US = enUSCatalog;
|
|
441
|
+
var es_419 = esESCatalog;
|
|
442
|
+
var es_AR = esESCatalog;
|
|
443
|
+
var es_ES = esESCatalog;
|
|
444
|
+
var es_MX = esESCatalog;
|
|
445
|
+
var fa_IR = enUSCatalog;
|
|
446
|
+
var fil_PH = enUSCatalog;
|
|
447
|
+
var fr_CA = frFRCatalog;
|
|
448
|
+
var fr_FR = frFRCatalog;
|
|
449
|
+
var ha_NG = enUSCatalog;
|
|
450
|
+
var hi_IN = enUSCatalog;
|
|
451
|
+
var hu_HU = enUSCatalog;
|
|
452
|
+
var id_ID = enUSCatalog;
|
|
453
|
+
var it_IT = enUSCatalog;
|
|
454
|
+
var ja_JP = jaJPCatalog;
|
|
455
|
+
var ko_KR = koKRCatalog;
|
|
456
|
+
var ms_MY = enUSCatalog;
|
|
457
|
+
var nl_NL = enUSCatalog;
|
|
458
|
+
var pl_PL = enUSCatalog;
|
|
459
|
+
var pt_BR = ptBRCatalog;
|
|
460
|
+
var pt_PT = ptBRCatalog;
|
|
461
|
+
var ro_RO = enUSCatalog;
|
|
462
|
+
var ru_RU = enUSCatalog;
|
|
463
|
+
var sv_SE = enUSCatalog;
|
|
464
|
+
var sw_TZ = enUSCatalog;
|
|
465
|
+
var th_TH = enUSCatalog;
|
|
466
|
+
var tr_TR = enUSCatalog;
|
|
467
|
+
var uk_UA = enUSCatalog;
|
|
468
|
+
var ur_PK = enUSCatalog;
|
|
469
|
+
var vi_VN = enUSCatalog;
|
|
470
|
+
var yo_NG = enUSCatalog;
|
|
471
|
+
var zh_Hans = zhHansCatalog;
|
|
472
|
+
var zh_Hant = zhHantCatalog;
|
|
473
|
+
var OfficialLocaleCatalogs = {
|
|
474
|
+
[LocaleCodes.ar_001]: ar_001,
|
|
475
|
+
[LocaleCodes.bn_BD]: bn_BD,
|
|
476
|
+
[LocaleCodes.cs_CZ]: cs_CZ,
|
|
477
|
+
[LocaleCodes.de_DE]: de_DE,
|
|
478
|
+
[LocaleCodes.el_GR]: el_GR,
|
|
479
|
+
[LocaleCodes.en_US]: en_US,
|
|
480
|
+
[LocaleCodes.es_419]: es_419,
|
|
481
|
+
[LocaleCodes.es_AR]: es_AR,
|
|
482
|
+
[LocaleCodes.es_ES]: es_ES,
|
|
483
|
+
[LocaleCodes.es_MX]: es_MX,
|
|
484
|
+
[LocaleCodes.fa_IR]: fa_IR,
|
|
485
|
+
[LocaleCodes.fil_PH]: fil_PH,
|
|
486
|
+
[LocaleCodes.fr_CA]: fr_CA,
|
|
487
|
+
[LocaleCodes.fr_FR]: fr_FR,
|
|
488
|
+
[LocaleCodes.ha_NG]: ha_NG,
|
|
489
|
+
[LocaleCodes.hi_IN]: hi_IN,
|
|
490
|
+
[LocaleCodes.hu_HU]: hu_HU,
|
|
491
|
+
[LocaleCodes.id_ID]: id_ID,
|
|
492
|
+
[LocaleCodes.it_IT]: it_IT,
|
|
493
|
+
[LocaleCodes.ja_JP]: ja_JP,
|
|
494
|
+
[LocaleCodes.ko_KR]: ko_KR,
|
|
495
|
+
[LocaleCodes.ms_MY]: ms_MY,
|
|
496
|
+
[LocaleCodes.nl_NL]: nl_NL,
|
|
497
|
+
[LocaleCodes.pl_PL]: pl_PL,
|
|
498
|
+
[LocaleCodes.pt_BR]: pt_BR,
|
|
499
|
+
[LocaleCodes.pt_PT]: pt_PT,
|
|
500
|
+
[LocaleCodes.ro_RO]: ro_RO,
|
|
501
|
+
[LocaleCodes.ru_RU]: ru_RU,
|
|
502
|
+
[LocaleCodes.sv_SE]: sv_SE,
|
|
503
|
+
[LocaleCodes.sw_TZ]: sw_TZ,
|
|
504
|
+
[LocaleCodes.th_TH]: th_TH,
|
|
505
|
+
[LocaleCodes.tr_TR]: tr_TR,
|
|
506
|
+
[LocaleCodes.uk_UA]: uk_UA,
|
|
507
|
+
[LocaleCodes.ur_PK]: ur_PK,
|
|
508
|
+
[LocaleCodes.vi_VN]: vi_VN,
|
|
509
|
+
[LocaleCodes.yo_NG]: yo_NG,
|
|
510
|
+
[LocaleCodes.zh_Hans]: zh_Hans,
|
|
511
|
+
[LocaleCodes.zh_Hant]: zh_Hant
|
|
512
|
+
};
|
|
513
|
+
function LocaleCatalogEntries() {
|
|
514
|
+
return Object.values(LocaleCodes).map((locale) => [locale, OfficialLocaleCatalogs[locale]]);
|
|
515
|
+
}
|
|
516
|
+
var LocalePacks = OfficialLocaleCatalogs;
|
|
517
|
+
var locale_default = LocalePacks;
|
|
518
|
+
|
|
519
|
+
// src/shared/object-utils.ts
|
|
520
|
+
function deriveObjectSchema(object, options = {}) {
|
|
521
|
+
const pickSet = options.pickKeys ? new Set(options.pickKeys) : undefined;
|
|
522
|
+
const omitSet = options.omitKeys ? new Set(options.omitKeys) : undefined;
|
|
523
|
+
const originalOptional = new Set((object.optional ?? []).map(String));
|
|
524
|
+
const originalRequired = new Set((object.required ?? []).map(String));
|
|
525
|
+
const originalProperties = object.properties;
|
|
526
|
+
const properties = {};
|
|
527
|
+
for (const [key, schema] of Object.entries(originalProperties)) {
|
|
528
|
+
if (pickSet && !pickSet.has(key))
|
|
529
|
+
continue;
|
|
530
|
+
if (omitSet && omitSet.has(key))
|
|
531
|
+
continue;
|
|
532
|
+
properties[key] = schema;
|
|
533
|
+
}
|
|
534
|
+
const keys = Object.keys(properties);
|
|
535
|
+
const required = options.requiredMode === "all" ? keys : options.requiredMode === "none" ? [] : keys.filter((key) => originalRequired.has(key));
|
|
536
|
+
const optional = keys.filter((key) => originalOptional.has(key) && !required.includes(key));
|
|
537
|
+
return {
|
|
538
|
+
"~kind": "Object",
|
|
539
|
+
properties,
|
|
540
|
+
...required.length > 0 ? { required } : {},
|
|
541
|
+
...optional.length > 0 ? { optional } : {},
|
|
542
|
+
...object.patternProperties !== undefined ? { patternProperties: object.patternProperties } : {},
|
|
543
|
+
...options.additionalProperties !== undefined ? { additionalProperties: options.additionalProperties } : object.additionalProperties !== undefined ? { additionalProperties: object.additionalProperties } : {}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function getPatternPropertySchemas(patternProperties, key) {
|
|
547
|
+
if (!patternProperties)
|
|
548
|
+
return [];
|
|
549
|
+
const matches = [];
|
|
550
|
+
for (const [pattern, schema] of Object.entries(patternProperties)) {
|
|
551
|
+
if (new RegExp(pattern).test(key)) {
|
|
552
|
+
matches.push(schema);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return matches;
|
|
556
|
+
}
|
|
557
|
+
function deriveIndexSchemas(object, keySchema, checkFn) {
|
|
558
|
+
const candidates = [];
|
|
559
|
+
const properties = object.properties;
|
|
560
|
+
for (const [key, schema] of Object.entries(properties)) {
|
|
561
|
+
if (checkFn(keySchema, key)) {
|
|
562
|
+
candidates.push(schema);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return candidates;
|
|
566
|
+
}
|
|
567
|
+
function deriveIndexSchemasForEmission(object, keySchema) {
|
|
568
|
+
const candidates = [];
|
|
569
|
+
const properties = object.properties;
|
|
570
|
+
const keySchemaRecord = keySchema;
|
|
571
|
+
for (const [key, schema] of Object.entries(properties)) {
|
|
572
|
+
const keyValidationSchema = {
|
|
573
|
+
"~kind": "String",
|
|
574
|
+
...typeof keySchemaRecord.format === "string" ? { format: keySchemaRecord.format } : {},
|
|
575
|
+
...typeof keySchemaRecord.pattern === "string" ? { pattern: keySchemaRecord.pattern } : {}
|
|
576
|
+
};
|
|
577
|
+
if (keySchemaRecord["~kind"] === "String" ? stringMatchesKeySchema(keyValidationSchema, key) : true) {
|
|
578
|
+
candidates.push(schema);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return candidates;
|
|
582
|
+
}
|
|
583
|
+
function stringMatchesKeySchema(schema, value) {
|
|
584
|
+
return schema.pattern === undefined || new RegExp(schema.pattern).test(value);
|
|
585
|
+
}
|
|
586
|
+
function transformStringLiteralValue(kind, value) {
|
|
587
|
+
switch (kind) {
|
|
588
|
+
case "Capitalize":
|
|
589
|
+
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
590
|
+
case "Lowercase":
|
|
591
|
+
return value.toLowerCase();
|
|
592
|
+
case "Uppercase":
|
|
593
|
+
return value.toUpperCase();
|
|
594
|
+
case "Uncapitalize":
|
|
595
|
+
return value.length === 0 ? value : value.charAt(0).toLowerCase() + value.slice(1);
|
|
596
|
+
default:
|
|
597
|
+
return value;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function resolveStringActionSchema(schema) {
|
|
601
|
+
const value = schema;
|
|
602
|
+
const kind = value["~kind"];
|
|
603
|
+
if (kind !== "Capitalize" && kind !== "Lowercase" && kind !== "Uppercase" && kind !== "Uncapitalize") {
|
|
604
|
+
return schema;
|
|
605
|
+
}
|
|
606
|
+
const item = value["item"];
|
|
607
|
+
if (typeof item !== "object" || item === null) {
|
|
608
|
+
return schema;
|
|
609
|
+
}
|
|
610
|
+
const target = item;
|
|
611
|
+
const targetKind = target["~kind"];
|
|
612
|
+
if (targetKind === "Literal" && typeof target["const"] === "string") {
|
|
613
|
+
return { "~kind": "Literal", const: transformStringLiteralValue(String(kind), target["const"]) };
|
|
614
|
+
}
|
|
615
|
+
if (targetKind === "Enum" && Array.isArray(target["values"]) && target["values"].every((entry) => typeof entry === "string")) {
|
|
616
|
+
return {
|
|
617
|
+
"~kind": "Enum",
|
|
618
|
+
values: target["values"].map((entry) => transformStringLiteralValue(String(kind), entry))
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
return item;
|
|
622
|
+
}
|
|
623
|
+
// src/shared/runtime-guards.ts
|
|
624
|
+
function isPromiseLike(value) {
|
|
625
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
|
|
626
|
+
}
|
|
627
|
+
function isIteratorLike(value) {
|
|
628
|
+
return typeof value === "object" && value !== null && "next" in value && typeof value.next === "function" && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
629
|
+
}
|
|
630
|
+
function isAsyncIteratorLike(value) {
|
|
631
|
+
return typeof value === "object" && value !== null && "next" in value && typeof value.next === "function" && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
632
|
+
}
|
|
633
|
+
// src/shared/format-constants.ts
|
|
634
|
+
var EMAIL_RE = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
635
|
+
var URI_RE = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
636
|
+
var HOSTNAME_RE = /^(?!-)[a-zA-Z0-9-]{0,63}(?<!-)(.(?!-)[a-zA-Z0-9-]{0,63}(?<!-))*$/;
|
|
637
|
+
var IPV4_RE = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
638
|
+
var IPV6_RE = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){1,6}::$/;
|
|
639
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
640
|
+
var ISO_DATE_RE = /^\d{4}-(0[1-9]|1[0-2])-([0-2]\d|3[01])$/;
|
|
641
|
+
var ISO_DT_RE = /^\d{4}-(0[1-9]|1[0-2])-([0-2]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-][01]\d:[0-5]\d)$/;
|
|
642
|
+
var ISO_TIME_RE = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?$/;
|
|
643
|
+
var ISO_DUR_RE = /^P(?:\d+Y)?(?:\d+M)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+S)?)?$/;
|
|
644
|
+
var BASE64_RE = /^[a-zA-Z0-9+/]*={0,2}$/;
|
|
645
|
+
var HEX_RE = /^[0-9a-fA-F]+$/;
|
|
646
|
+
var HEXCLR_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
647
|
+
var LUHN_DIGITS_RE = /^\d{13,19}$/;
|
|
648
|
+
var KNOWN_FORMATS = new Set([
|
|
649
|
+
"email",
|
|
650
|
+
"uri",
|
|
651
|
+
"hostname",
|
|
652
|
+
"ip",
|
|
653
|
+
"ipv4",
|
|
654
|
+
"ipv6",
|
|
655
|
+
"uuid",
|
|
656
|
+
"date",
|
|
657
|
+
"datetime",
|
|
658
|
+
"time",
|
|
659
|
+
"duration",
|
|
660
|
+
"base64",
|
|
661
|
+
"hex",
|
|
662
|
+
"hexcolor",
|
|
663
|
+
"creditcard",
|
|
664
|
+
"regex",
|
|
665
|
+
"uint8array",
|
|
666
|
+
"json"
|
|
667
|
+
]);
|
|
668
|
+
// src/shared/regex-json.ts
|
|
669
|
+
function isAsciiDigit(value) {
|
|
670
|
+
return value >= "0" && value <= "9";
|
|
671
|
+
}
|
|
672
|
+
function consumeRegexQuantifier(pattern, start) {
|
|
673
|
+
let index = start;
|
|
674
|
+
const first = pattern[index];
|
|
675
|
+
if (first === undefined || !isAsciiDigit(first)) {
|
|
676
|
+
return -1;
|
|
677
|
+
}
|
|
678
|
+
while (index < pattern.length) {
|
|
679
|
+
const character = pattern[index];
|
|
680
|
+
if (character === undefined || !isAsciiDigit(character)) {
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
index += 1;
|
|
684
|
+
}
|
|
685
|
+
if (pattern[index] === ",") {
|
|
686
|
+
index += 1;
|
|
687
|
+
while (index < pattern.length) {
|
|
688
|
+
const character = pattern[index];
|
|
689
|
+
if (character === undefined || !isAsciiDigit(character)) {
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
index += 1;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return pattern[index] === "}" ? index : -1;
|
|
696
|
+
}
|
|
697
|
+
function isValidRegex(value) {
|
|
698
|
+
let escaped = false;
|
|
699
|
+
let inCharacterClass = false;
|
|
700
|
+
let groupDepth = 0;
|
|
701
|
+
let hasToken = false;
|
|
702
|
+
let groupPrefixAllowed = false;
|
|
703
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
704
|
+
const character = value[index];
|
|
705
|
+
if (character === undefined)
|
|
706
|
+
return false;
|
|
707
|
+
if (escaped) {
|
|
708
|
+
escaped = false;
|
|
709
|
+
hasToken = true;
|
|
710
|
+
groupPrefixAllowed = false;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (character === "\\") {
|
|
714
|
+
escaped = true;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
if (inCharacterClass) {
|
|
718
|
+
if (character === "]") {
|
|
719
|
+
inCharacterClass = false;
|
|
720
|
+
hasToken = true;
|
|
721
|
+
}
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
if (groupPrefixAllowed && character === "?") {
|
|
725
|
+
groupPrefixAllowed = false;
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
groupPrefixAllowed = false;
|
|
729
|
+
switch (character) {
|
|
730
|
+
case "[":
|
|
731
|
+
inCharacterClass = true;
|
|
732
|
+
hasToken = true;
|
|
733
|
+
break;
|
|
734
|
+
case "(":
|
|
735
|
+
groupDepth += 1;
|
|
736
|
+
hasToken = false;
|
|
737
|
+
groupPrefixAllowed = true;
|
|
738
|
+
break;
|
|
739
|
+
case ")":
|
|
740
|
+
if (groupDepth === 0)
|
|
741
|
+
return false;
|
|
742
|
+
groupDepth -= 1;
|
|
743
|
+
hasToken = true;
|
|
744
|
+
break;
|
|
745
|
+
case "{": {
|
|
746
|
+
if (!hasToken)
|
|
747
|
+
return false;
|
|
748
|
+
const quantifierEnd = consumeRegexQuantifier(value, index + 1);
|
|
749
|
+
if (quantifierEnd < 0)
|
|
750
|
+
return false;
|
|
751
|
+
index = quantifierEnd;
|
|
752
|
+
hasToken = true;
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
case "*":
|
|
756
|
+
case "+":
|
|
757
|
+
case "?":
|
|
758
|
+
if (!hasToken)
|
|
759
|
+
return false;
|
|
760
|
+
hasToken = true;
|
|
761
|
+
break;
|
|
762
|
+
case "]":
|
|
763
|
+
case "}":
|
|
764
|
+
return false;
|
|
765
|
+
case "|":
|
|
766
|
+
hasToken = false;
|
|
767
|
+
break;
|
|
768
|
+
default:
|
|
769
|
+
hasToken = true;
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return !escaped && !inCharacterClass && groupDepth === 0;
|
|
774
|
+
}
|
|
775
|
+
function skipWhitespace(state) {
|
|
776
|
+
while (state.index < state.text.length) {
|
|
777
|
+
const character = state.text[state.index];
|
|
778
|
+
if (character !== " " && character !== `
|
|
779
|
+
` && character !== "\r" && character !== "\t") {
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
state.index += 1;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function consumeLiteral(state, literal) {
|
|
786
|
+
if (state.text.slice(state.index, state.index + literal.length) !== literal) {
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
state.index += literal.length;
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
function parseString(state) {
|
|
793
|
+
if (state.text[state.index] !== '"')
|
|
794
|
+
return false;
|
|
795
|
+
state.index += 1;
|
|
796
|
+
while (state.index < state.text.length) {
|
|
797
|
+
const character = state.text[state.index];
|
|
798
|
+
if (character === undefined)
|
|
799
|
+
return false;
|
|
800
|
+
if (character === '"') {
|
|
801
|
+
state.index += 1;
|
|
802
|
+
return true;
|
|
803
|
+
}
|
|
804
|
+
if (character === "\\") {
|
|
805
|
+
const escape = state.text[state.index + 1];
|
|
806
|
+
if (escape === undefined)
|
|
807
|
+
return false;
|
|
808
|
+
if (escape === "u") {
|
|
809
|
+
for (let offset = 2;offset < 6; offset += 1) {
|
|
810
|
+
const hex = state.text[state.index + offset];
|
|
811
|
+
if (hex === undefined || !/[0-9a-fA-F]/.test(hex))
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
state.index += 6;
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
if (!'"\\/bfnrt'.includes(escape))
|
|
818
|
+
return false;
|
|
819
|
+
state.index += 2;
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
if (character < " ")
|
|
823
|
+
return false;
|
|
824
|
+
state.index += 1;
|
|
825
|
+
}
|
|
826
|
+
return false;
|
|
827
|
+
}
|
|
828
|
+
function parseNumber(state) {
|
|
829
|
+
const start = state.index;
|
|
830
|
+
if (state.text[state.index] === "-") {
|
|
831
|
+
state.index += 1;
|
|
832
|
+
}
|
|
833
|
+
const firstDigit = state.text[state.index];
|
|
834
|
+
if (firstDigit === undefined || !isAsciiDigit(firstDigit))
|
|
835
|
+
return false;
|
|
836
|
+
if (firstDigit === "0") {
|
|
837
|
+
state.index += 1;
|
|
838
|
+
} else {
|
|
839
|
+
while (state.index < state.text.length) {
|
|
840
|
+
const digit = state.text[state.index];
|
|
841
|
+
if (digit === undefined || !isAsciiDigit(digit))
|
|
842
|
+
break;
|
|
843
|
+
state.index += 1;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (state.text[state.index] === ".") {
|
|
847
|
+
state.index += 1;
|
|
848
|
+
const fractionDigit = state.text[state.index];
|
|
849
|
+
if (fractionDigit === undefined || !isAsciiDigit(fractionDigit))
|
|
850
|
+
return false;
|
|
851
|
+
while (state.index < state.text.length) {
|
|
852
|
+
const digit = state.text[state.index];
|
|
853
|
+
if (digit === undefined || !isAsciiDigit(digit))
|
|
854
|
+
break;
|
|
855
|
+
state.index += 1;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
const exponent = state.text[state.index];
|
|
859
|
+
if (exponent === "e" || exponent === "E") {
|
|
860
|
+
state.index += 1;
|
|
861
|
+
const sign = state.text[state.index];
|
|
862
|
+
if (sign === "+" || sign === "-")
|
|
863
|
+
state.index += 1;
|
|
864
|
+
const exponentDigit = state.text[state.index];
|
|
865
|
+
if (exponentDigit === undefined || !isAsciiDigit(exponentDigit))
|
|
866
|
+
return false;
|
|
867
|
+
while (state.index < state.text.length) {
|
|
868
|
+
const digit = state.text[state.index];
|
|
869
|
+
if (digit === undefined || !isAsciiDigit(digit))
|
|
870
|
+
break;
|
|
871
|
+
state.index += 1;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return state.index > start;
|
|
875
|
+
}
|
|
876
|
+
function parseArray(state) {
|
|
877
|
+
if (state.text[state.index] !== "[")
|
|
878
|
+
return false;
|
|
879
|
+
state.index += 1;
|
|
880
|
+
skipWhitespace(state);
|
|
881
|
+
if (state.text[state.index] === "]") {
|
|
882
|
+
state.index += 1;
|
|
883
|
+
return true;
|
|
884
|
+
}
|
|
885
|
+
while (state.index < state.text.length) {
|
|
886
|
+
if (!parseValue(state))
|
|
887
|
+
return false;
|
|
888
|
+
skipWhitespace(state);
|
|
889
|
+
const separator = state.text[state.index];
|
|
890
|
+
if (separator === ",") {
|
|
891
|
+
state.index += 1;
|
|
892
|
+
skipWhitespace(state);
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
if (separator === "]") {
|
|
896
|
+
state.index += 1;
|
|
897
|
+
return true;
|
|
898
|
+
}
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
function parseObject(state) {
|
|
904
|
+
if (state.text[state.index] !== "{")
|
|
905
|
+
return false;
|
|
906
|
+
state.index += 1;
|
|
907
|
+
skipWhitespace(state);
|
|
908
|
+
if (state.text[state.index] === "}") {
|
|
909
|
+
state.index += 1;
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
while (state.index < state.text.length) {
|
|
913
|
+
if (!parseString(state))
|
|
914
|
+
return false;
|
|
915
|
+
skipWhitespace(state);
|
|
916
|
+
if (state.text[state.index] !== ":")
|
|
917
|
+
return false;
|
|
918
|
+
state.index += 1;
|
|
919
|
+
if (!parseValue(state))
|
|
920
|
+
return false;
|
|
921
|
+
skipWhitespace(state);
|
|
922
|
+
const separator = state.text[state.index];
|
|
923
|
+
if (separator === ",") {
|
|
924
|
+
state.index += 1;
|
|
925
|
+
skipWhitespace(state);
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
if (separator === "}") {
|
|
929
|
+
state.index += 1;
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
return false;
|
|
933
|
+
}
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
function parseValue(state) {
|
|
937
|
+
skipWhitespace(state);
|
|
938
|
+
const character = state.text[state.index];
|
|
939
|
+
switch (character) {
|
|
940
|
+
case '"':
|
|
941
|
+
return parseString(state);
|
|
942
|
+
case "{":
|
|
943
|
+
return parseObject(state);
|
|
944
|
+
case "[":
|
|
945
|
+
return parseArray(state);
|
|
946
|
+
case "t":
|
|
947
|
+
return consumeLiteral(state, "true");
|
|
948
|
+
case "f":
|
|
949
|
+
return consumeLiteral(state, "false");
|
|
950
|
+
case "n":
|
|
951
|
+
return consumeLiteral(state, "null");
|
|
952
|
+
default:
|
|
953
|
+
return character === "-" || character !== undefined && isAsciiDigit(character) ? parseNumber(state) : false;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
function isValidJson(value) {
|
|
957
|
+
const state = { index: 0, text: value };
|
|
958
|
+
if (!parseValue(state))
|
|
959
|
+
return false;
|
|
960
|
+
skipWhitespace(state);
|
|
961
|
+
return state.index === state.text.length;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// src/shared/runtime-context.ts
|
|
965
|
+
var builtinLocaleCatalogEntries = LocaleCatalogEntries();
|
|
966
|
+
var defaultTypePolicy = {
|
|
967
|
+
AllowNaN: false,
|
|
968
|
+
AllowArrayObject: false,
|
|
969
|
+
AllowNullVoid: true
|
|
970
|
+
};
|
|
971
|
+
var defaultSettings = {
|
|
972
|
+
correctiveParse: false
|
|
973
|
+
};
|
|
974
|
+
var runtimeContextCounter = 0;
|
|
975
|
+
function cloneEntries(entries) {
|
|
976
|
+
return Array.from(entries, ([key, value]) => [key, value]);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
class RuntimeContext {
|
|
980
|
+
id = ++runtimeContextCounter;
|
|
981
|
+
revision = 0;
|
|
982
|
+
activeLocale;
|
|
983
|
+
formatValidators = new Map;
|
|
984
|
+
localeCatalogs = new Map;
|
|
985
|
+
settings;
|
|
986
|
+
typeValidators = new Map;
|
|
987
|
+
typePolicy;
|
|
988
|
+
FormatRegistry = {
|
|
989
|
+
Clear: () => {
|
|
990
|
+
this.formatValidators.clear();
|
|
991
|
+
this.touch();
|
|
992
|
+
},
|
|
993
|
+
Delete: (name) => {
|
|
994
|
+
const deleted = this.formatValidators.delete(name);
|
|
995
|
+
if (deleted) {
|
|
996
|
+
this.touch();
|
|
997
|
+
}
|
|
998
|
+
return deleted;
|
|
999
|
+
},
|
|
1000
|
+
Entries: () => Array.from(this.formatValidators.entries()),
|
|
1001
|
+
Get: (name) => this.formatValidators.get(name),
|
|
1002
|
+
Has: (name) => this.formatValidators.has(name),
|
|
1003
|
+
Set: (name, validator) => {
|
|
1004
|
+
this.formatValidators.set(name, validator);
|
|
1005
|
+
this.touch();
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
Locale = {
|
|
1009
|
+
...LocaleCodes,
|
|
1010
|
+
Entries: () => Array.from(this.localeCatalogs.entries()),
|
|
1011
|
+
Get: () => this.activeLocale,
|
|
1012
|
+
GetCatalog: (locale = this.activeLocale) => this.localeCatalogs.get(locale) ?? this.localeCatalogs.get(LocaleCodes.en_US) ?? enUSCatalog,
|
|
1013
|
+
Has: (locale) => this.localeCatalogs.has(locale),
|
|
1014
|
+
Register: (locale, catalog) => {
|
|
1015
|
+
this.localeCatalogs.set(locale, catalog);
|
|
1016
|
+
this.touch();
|
|
1017
|
+
},
|
|
1018
|
+
Reset: () => {
|
|
1019
|
+
this.activeLocale = LocaleCodes.en_US;
|
|
1020
|
+
this.touch();
|
|
1021
|
+
},
|
|
1022
|
+
Set: (locale) => {
|
|
1023
|
+
this.activeLocale = locale;
|
|
1024
|
+
this.touch();
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
Settings = {
|
|
1028
|
+
Get: () => this.settings,
|
|
1029
|
+
Reset: () => {
|
|
1030
|
+
this.settings = { ...defaultSettings };
|
|
1031
|
+
this.touch();
|
|
1032
|
+
},
|
|
1033
|
+
Set: (options) => {
|
|
1034
|
+
this.settings = { ...this.settings, ...options };
|
|
1035
|
+
this.touch();
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
TypeRegistry = {
|
|
1039
|
+
Clear: () => {
|
|
1040
|
+
this.typeValidators.clear();
|
|
1041
|
+
this.touch();
|
|
1042
|
+
},
|
|
1043
|
+
Delete: (kind) => {
|
|
1044
|
+
const deleted = this.typeValidators.delete(kind);
|
|
1045
|
+
if (deleted) {
|
|
1046
|
+
this.touch();
|
|
1047
|
+
}
|
|
1048
|
+
return deleted;
|
|
1049
|
+
},
|
|
1050
|
+
Entries: () => Array.from(this.typeValidators.entries()),
|
|
1051
|
+
Get: (kind) => this.typeValidators.get(kind),
|
|
1052
|
+
Has: (kind) => this.typeValidators.has(kind),
|
|
1053
|
+
Set: (kind, validator) => {
|
|
1054
|
+
this.typeValidators.set(kind, validator);
|
|
1055
|
+
this.touch();
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
TypeSystemPolicy = {
|
|
1059
|
+
Get: () => this.typePolicy,
|
|
1060
|
+
Reset: () => {
|
|
1061
|
+
this.typePolicy = { ...defaultTypePolicy };
|
|
1062
|
+
this.touch();
|
|
1063
|
+
},
|
|
1064
|
+
Set: (options) => {
|
|
1065
|
+
this.typePolicy = { ...this.typePolicy, ...options };
|
|
1066
|
+
this.touch();
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
constructor(options = {}) {
|
|
1070
|
+
this.activeLocale = options.locale ?? LocaleCodes.en_US;
|
|
1071
|
+
this.settings = { ...defaultSettings, ...options.settings };
|
|
1072
|
+
this.typePolicy = { ...defaultTypePolicy, ...options.typePolicy };
|
|
1073
|
+
for (const [locale, catalog] of builtinLocaleCatalogEntries) {
|
|
1074
|
+
this.localeCatalogs.set(locale, catalog);
|
|
1075
|
+
}
|
|
1076
|
+
for (const [locale, catalog] of options.localeCatalogs ?? []) {
|
|
1077
|
+
this.localeCatalogs.set(locale, catalog);
|
|
1078
|
+
}
|
|
1079
|
+
for (const [name, validator] of options.formats ?? []) {
|
|
1080
|
+
this.formatValidators.set(name, validator);
|
|
1081
|
+
}
|
|
1082
|
+
for (const [kind, validator] of options.types ?? []) {
|
|
1083
|
+
this.typeValidators.set(kind, validator);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
Clone(options = {}) {
|
|
1087
|
+
return new RuntimeContext({
|
|
1088
|
+
formats: [...cloneEntries(this.formatValidators.entries()), ...options.formats ?? []],
|
|
1089
|
+
locale: options.locale ?? this.activeLocale,
|
|
1090
|
+
localeCatalogs: [...cloneEntries(this.localeCatalogs.entries()), ...options.localeCatalogs ?? []],
|
|
1091
|
+
settings: { ...this.settings, ...options.settings },
|
|
1092
|
+
typePolicy: { ...this.typePolicy, ...options.typePolicy },
|
|
1093
|
+
types: [...cloneEntries(this.typeValidators.entries()), ...options.types ?? []]
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
CacheKey(namespace = "runtime") {
|
|
1097
|
+
return `${namespace}:${this.id}:${this.revision}`;
|
|
1098
|
+
}
|
|
1099
|
+
touch() {
|
|
1100
|
+
this.revision += 1;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
var defaultRuntimeContext = new RuntimeContext;
|
|
1104
|
+
function CreateRuntimeContext(options = {}) {
|
|
1105
|
+
return new RuntimeContext(options);
|
|
1106
|
+
}
|
|
1107
|
+
function getDefaultRuntimeContext() {
|
|
1108
|
+
return defaultRuntimeContext;
|
|
1109
|
+
}
|
|
1110
|
+
function resolveRuntimeContext(context) {
|
|
1111
|
+
if (context instanceof RuntimeContext) {
|
|
1112
|
+
return context;
|
|
1113
|
+
}
|
|
1114
|
+
return context?.context ?? defaultRuntimeContext;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// src/shared/format-validators.ts
|
|
1118
|
+
function luhnCheck(digits) {
|
|
1119
|
+
if (!LUHN_DIGITS_RE.test(digits))
|
|
1120
|
+
return false;
|
|
1121
|
+
let sum = 0;
|
|
1122
|
+
let alternate = false;
|
|
1123
|
+
for (let index = digits.length - 1;index >= 0; index -= 1) {
|
|
1124
|
+
let digit = Number.parseInt(digits.charAt(index), 10);
|
|
1125
|
+
if (alternate) {
|
|
1126
|
+
digit *= 2;
|
|
1127
|
+
if (digit > 9)
|
|
1128
|
+
digit -= 9;
|
|
1129
|
+
}
|
|
1130
|
+
sum += digit;
|
|
1131
|
+
alternate = !alternate;
|
|
1132
|
+
}
|
|
1133
|
+
return sum % 10 === 0;
|
|
1134
|
+
}
|
|
1135
|
+
function isValidISODate(value) {
|
|
1136
|
+
const parts = value.split("-").map(Number);
|
|
1137
|
+
const year = parts[0];
|
|
1138
|
+
const month = parts[1];
|
|
1139
|
+
const day = parts[2];
|
|
1140
|
+
if (year === undefined || month === undefined || day === undefined)
|
|
1141
|
+
return false;
|
|
1142
|
+
const date = new globalThis.Date(year, month - 1, day);
|
|
1143
|
+
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
|
1144
|
+
}
|
|
1145
|
+
function validateFormat(value, format, context) {
|
|
1146
|
+
const runtimeContext = resolveRuntimeContext(context);
|
|
1147
|
+
const custom = runtimeContext.FormatRegistry.Get(format);
|
|
1148
|
+
if (custom !== undefined)
|
|
1149
|
+
return custom(value);
|
|
1150
|
+
switch (format) {
|
|
1151
|
+
case "email":
|
|
1152
|
+
return EMAIL_RE.test(value);
|
|
1153
|
+
case "uri":
|
|
1154
|
+
return URI_RE.test(value);
|
|
1155
|
+
case "ip":
|
|
1156
|
+
return IPV4_RE.test(value) || IPV6_RE.test(value);
|
|
1157
|
+
case "hostname":
|
|
1158
|
+
return HOSTNAME_RE.test(value);
|
|
1159
|
+
case "ipv4":
|
|
1160
|
+
return IPV4_RE.test(value);
|
|
1161
|
+
case "ipv6":
|
|
1162
|
+
return IPV6_RE.test(value);
|
|
1163
|
+
case "uuid":
|
|
1164
|
+
return UUID_RE.test(value);
|
|
1165
|
+
case "date":
|
|
1166
|
+
return ISO_DATE_RE.test(value) && isValidISODate(value);
|
|
1167
|
+
case "datetime":
|
|
1168
|
+
return ISO_DT_RE.test(value);
|
|
1169
|
+
case "time":
|
|
1170
|
+
return ISO_TIME_RE.test(value);
|
|
1171
|
+
case "duration":
|
|
1172
|
+
return ISO_DUR_RE.test(value);
|
|
1173
|
+
case "base64":
|
|
1174
|
+
return BASE64_RE.test(value);
|
|
1175
|
+
case "hex":
|
|
1176
|
+
return HEX_RE.test(value);
|
|
1177
|
+
case "hexcolor":
|
|
1178
|
+
return HEXCLR_RE.test(value);
|
|
1179
|
+
case "creditcard":
|
|
1180
|
+
return luhnCheck(value.replace(/\D/g, ""));
|
|
1181
|
+
case "regex":
|
|
1182
|
+
return isValidRegex(value);
|
|
1183
|
+
case "json":
|
|
1184
|
+
return isValidJson(value);
|
|
1185
|
+
case "uint8array":
|
|
1186
|
+
return BASE64_RE.test(value);
|
|
1187
|
+
default:
|
|
1188
|
+
return true;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
function checkStringConstraints(schema, value, context) {
|
|
1192
|
+
if (schema.minLength !== undefined && value.length < schema.minLength)
|
|
1193
|
+
return false;
|
|
1194
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength)
|
|
1195
|
+
return false;
|
|
1196
|
+
if (schema.pattern !== undefined) {
|
|
1197
|
+
const regex = new RegExp(schema.pattern);
|
|
1198
|
+
if (!regex.test(value))
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
return schema.format === undefined || validateFormat(value, schema.format, context);
|
|
1202
|
+
}
|
|
1203
|
+
function checkNumberConstraints(schema, value) {
|
|
1204
|
+
if (schema.minimum !== undefined && value < schema.minimum)
|
|
1205
|
+
return false;
|
|
1206
|
+
if (schema.maximum !== undefined && value > schema.maximum)
|
|
1207
|
+
return false;
|
|
1208
|
+
if (schema.exclusiveMinimum !== undefined && value <= schema.exclusiveMinimum)
|
|
1209
|
+
return false;
|
|
1210
|
+
if (schema.exclusiveMaximum !== undefined && value >= schema.exclusiveMaximum)
|
|
1211
|
+
return false;
|
|
1212
|
+
return schema.multipleOf === undefined || value % schema.multipleOf === 0;
|
|
1213
|
+
}
|
|
1214
|
+
// src/shared/registries.ts
|
|
1215
|
+
var FormatRegistry = {
|
|
1216
|
+
Clear() {
|
|
1217
|
+
getDefaultRuntimeContext().FormatRegistry.Clear();
|
|
1218
|
+
},
|
|
1219
|
+
Delete(name) {
|
|
1220
|
+
return getDefaultRuntimeContext().FormatRegistry.Delete(name);
|
|
1221
|
+
},
|
|
1222
|
+
Entries() {
|
|
1223
|
+
return getDefaultRuntimeContext().FormatRegistry.Entries();
|
|
1224
|
+
},
|
|
1225
|
+
Get(name) {
|
|
1226
|
+
return getDefaultRuntimeContext().FormatRegistry.Get(name);
|
|
1227
|
+
},
|
|
1228
|
+
Has(name) {
|
|
1229
|
+
return getDefaultRuntimeContext().FormatRegistry.Has(name);
|
|
1230
|
+
},
|
|
1231
|
+
Set(name, validator) {
|
|
1232
|
+
getDefaultRuntimeContext().FormatRegistry.Set(name, validator);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
var TypeRegistry = {
|
|
1236
|
+
Clear() {
|
|
1237
|
+
getDefaultRuntimeContext().TypeRegistry.Clear();
|
|
1238
|
+
},
|
|
1239
|
+
Delete(kind) {
|
|
1240
|
+
return getDefaultRuntimeContext().TypeRegistry.Delete(kind);
|
|
1241
|
+
},
|
|
1242
|
+
Entries() {
|
|
1243
|
+
return getDefaultRuntimeContext().TypeRegistry.Entries();
|
|
1244
|
+
},
|
|
1245
|
+
Get(kind) {
|
|
1246
|
+
return getDefaultRuntimeContext().TypeRegistry.Get(kind);
|
|
1247
|
+
},
|
|
1248
|
+
Has(kind) {
|
|
1249
|
+
return getDefaultRuntimeContext().TypeRegistry.Has(kind);
|
|
1250
|
+
},
|
|
1251
|
+
Set(kind, validator) {
|
|
1252
|
+
getDefaultRuntimeContext().TypeRegistry.Set(kind, validator);
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
var TypeSystemPolicy = {
|
|
1256
|
+
Get() {
|
|
1257
|
+
return getDefaultRuntimeContext().TypeSystemPolicy.Get();
|
|
1258
|
+
},
|
|
1259
|
+
Reset() {
|
|
1260
|
+
getDefaultRuntimeContext().TypeSystemPolicy.Reset();
|
|
1261
|
+
},
|
|
1262
|
+
Set(options) {
|
|
1263
|
+
getDefaultRuntimeContext().TypeSystemPolicy.Set(options);
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
var Settings = {
|
|
1267
|
+
Get() {
|
|
1268
|
+
return getDefaultRuntimeContext().Settings.Get();
|
|
1269
|
+
},
|
|
1270
|
+
Reset() {
|
|
1271
|
+
getDefaultRuntimeContext().Settings.Reset();
|
|
1272
|
+
},
|
|
1273
|
+
Set(options) {
|
|
1274
|
+
getDefaultRuntimeContext().Settings.Set(options);
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
// src/type/combinator-core.ts
|
|
1278
|
+
function Union(variants, options) {
|
|
1279
|
+
return { "~kind": "Union", variants, ...options };
|
|
1280
|
+
}
|
|
1281
|
+
function Intersect(variants, options) {
|
|
1282
|
+
return { "~kind": "Intersect", variants, ...options };
|
|
1283
|
+
}
|
|
1284
|
+
function Evaluate(schema) {
|
|
1285
|
+
if (schema["~kind"] === "Object") {
|
|
1286
|
+
return schema;
|
|
1287
|
+
}
|
|
1288
|
+
const properties = {};
|
|
1289
|
+
const required = new Set;
|
|
1290
|
+
const optional = new Set;
|
|
1291
|
+
const patternProperties = {};
|
|
1292
|
+
let additionalProperties;
|
|
1293
|
+
for (const variant of schema.variants) {
|
|
1294
|
+
Object.assign(properties, variant.properties);
|
|
1295
|
+
for (const key of variant.required ?? [])
|
|
1296
|
+
required.add(String(key));
|
|
1297
|
+
for (const key of variant.optional ?? [])
|
|
1298
|
+
optional.add(String(key));
|
|
1299
|
+
Object.assign(patternProperties, variant.patternProperties);
|
|
1300
|
+
if (variant.additionalProperties === false) {
|
|
1301
|
+
additionalProperties = false;
|
|
1302
|
+
} else if (additionalProperties !== false && variant.additionalProperties !== undefined) {
|
|
1303
|
+
additionalProperties = variant.additionalProperties;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
for (const key of optional) {
|
|
1307
|
+
required.delete(key);
|
|
1308
|
+
}
|
|
1309
|
+
return {
|
|
1310
|
+
"~kind": "Object",
|
|
1311
|
+
properties,
|
|
1312
|
+
...required.size > 0 ? { required: [...required] } : {},
|
|
1313
|
+
...optional.size > 0 ? { optional: [...optional] } : {},
|
|
1314
|
+
...Object.keys(patternProperties).length > 0 ? { patternProperties } : {},
|
|
1315
|
+
...additionalProperties !== undefined ? { additionalProperties } : {}
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
function Optional(item, options) {
|
|
1319
|
+
return { "~kind": "Optional", item, ...options };
|
|
1320
|
+
}
|
|
1321
|
+
function Readonly(item, options) {
|
|
1322
|
+
return { "~kind": "Readonly", item, ...options };
|
|
1323
|
+
}
|
|
1324
|
+
function Enum(values, options) {
|
|
1325
|
+
return { "~kind": "Enum", values, ...options };
|
|
1326
|
+
}
|
|
1327
|
+
function Ref(name, options) {
|
|
1328
|
+
return { "~kind": "Ref", name, ...options };
|
|
1329
|
+
}
|
|
1330
|
+
function Recursive(name, build, options) {
|
|
1331
|
+
const self = Ref(name);
|
|
1332
|
+
const schema = build(self);
|
|
1333
|
+
return { "~kind": "Recursive", name, schema, ...options };
|
|
1334
|
+
}
|
|
1335
|
+
function Variant(discriminator, variants, options) {
|
|
1336
|
+
return Union(variants, { discriminator, ...options });
|
|
1337
|
+
}
|
|
1338
|
+
// src/type/combinator-objects.ts
|
|
1339
|
+
function Exclude(left, right, options) {
|
|
1340
|
+
return { "~kind": "Exclude", left, right, ...options };
|
|
1341
|
+
}
|
|
1342
|
+
function Extract(left, right, options) {
|
|
1343
|
+
return { "~kind": "Extract", left, right, ...options };
|
|
1344
|
+
}
|
|
1345
|
+
function KeyOf(object, options) {
|
|
1346
|
+
return { "~kind": "KeyOf", object, ...options };
|
|
1347
|
+
}
|
|
1348
|
+
function Partial(object, options) {
|
|
1349
|
+
return { "~kind": "Partial", object, ...options };
|
|
1350
|
+
}
|
|
1351
|
+
function Required(object, options) {
|
|
1352
|
+
return { "~kind": "Required", object, ...options };
|
|
1353
|
+
}
|
|
1354
|
+
function Pick(object, keys, options) {
|
|
1355
|
+
return { "~kind": "Pick", object, keys, ...options };
|
|
1356
|
+
}
|
|
1357
|
+
function Omit(object, keys, options) {
|
|
1358
|
+
return { "~kind": "Omit", object, keys, ...options };
|
|
1359
|
+
}
|
|
1360
|
+
function Not(schema, options) {
|
|
1361
|
+
return { "~kind": "Not", schema, ...options };
|
|
1362
|
+
}
|
|
1363
|
+
function IfThenElse(condition, then, elseSchema, options) {
|
|
1364
|
+
return {
|
|
1365
|
+
"~kind": "IfThenElse",
|
|
1366
|
+
if: condition,
|
|
1367
|
+
then,
|
|
1368
|
+
else: elseSchema,
|
|
1369
|
+
...options
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
function Unsafe(schema, options) {
|
|
1373
|
+
return {
|
|
1374
|
+
"~kind": "Unsafe",
|
|
1375
|
+
schema,
|
|
1376
|
+
type: undefined,
|
|
1377
|
+
...options
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function Index(object, key, options) {
|
|
1381
|
+
return {
|
|
1382
|
+
"~kind": "Index",
|
|
1383
|
+
object,
|
|
1384
|
+
key: key ?? { "~kind": "String" },
|
|
1385
|
+
...options
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
function Mapped(object, transform, options) {
|
|
1389
|
+
return { "~kind": "Mapped", object, ...transform ? { transform } : {}, ...options };
|
|
1390
|
+
}
|
|
1391
|
+
function Conditional(check, union, defaultSchema, options) {
|
|
1392
|
+
return {
|
|
1393
|
+
"~kind": "Conditional",
|
|
1394
|
+
check,
|
|
1395
|
+
union,
|
|
1396
|
+
default: defaultSchema,
|
|
1397
|
+
...options
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
// src/type/combinator-functions.ts
|
|
1401
|
+
function Awaited(promise) {
|
|
1402
|
+
return { "~kind": "Awaited", promise };
|
|
1403
|
+
}
|
|
1404
|
+
function ReturnType(fn) {
|
|
1405
|
+
return { "~kind": "ReturnType", function: fn };
|
|
1406
|
+
}
|
|
1407
|
+
function Parameters(fn) {
|
|
1408
|
+
return { "~kind": "Parameters", function: fn };
|
|
1409
|
+
}
|
|
1410
|
+
function InstanceType(ctor) {
|
|
1411
|
+
return { "~kind": "InstanceType", constructor: ctor };
|
|
1412
|
+
}
|
|
1413
|
+
function ConstructorParameters(ctor) {
|
|
1414
|
+
return { "~kind": "ConstructorParameters", constructor: ctor };
|
|
1415
|
+
}
|
|
1416
|
+
function Module(definitions) {
|
|
1417
|
+
const mod = { "~kind": "Module", definitions };
|
|
1418
|
+
return {
|
|
1419
|
+
...mod,
|
|
1420
|
+
Import(name) {
|
|
1421
|
+
return { "~kind": "Ref", name };
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
// src/type/containers.ts
|
|
1426
|
+
function Array2(item, options) {
|
|
1427
|
+
return {
|
|
1428
|
+
"~kind": "Array",
|
|
1429
|
+
items: item,
|
|
1430
|
+
...options
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
function Object2(properties, options) {
|
|
1434
|
+
return {
|
|
1435
|
+
"~kind": "Object",
|
|
1436
|
+
properties,
|
|
1437
|
+
...options
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
function Tuple(items, options) {
|
|
1441
|
+
const expandedItems = ExpandTupleRest(items);
|
|
1442
|
+
return {
|
|
1443
|
+
"~kind": "Tuple",
|
|
1444
|
+
items: expandedItems,
|
|
1445
|
+
minItems: options?.minItems ?? expandedItems.length,
|
|
1446
|
+
maxItems: options?.maxItems ?? (options?.additionalItems === true ? undefined : expandedItems.length),
|
|
1447
|
+
additionalItems: options?.additionalItems ?? false,
|
|
1448
|
+
...options
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
function Record(key, value, options) {
|
|
1452
|
+
return {
|
|
1453
|
+
"~kind": "Record",
|
|
1454
|
+
key,
|
|
1455
|
+
value,
|
|
1456
|
+
...options
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
// src/value/clone.ts
|
|
1461
|
+
function cloneValue(value) {
|
|
1462
|
+
return globalThis.structuredClone(value);
|
|
1463
|
+
}
|
|
1464
|
+
function Clone(value) {
|
|
1465
|
+
return cloneValue(value);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/type/actions.ts
|
|
1469
|
+
function hasKind(value, kind) {
|
|
1470
|
+
return value["~kind"] === kind;
|
|
1471
|
+
}
|
|
1472
|
+
function ExpandTupleRest(items) {
|
|
1473
|
+
const expanded = [];
|
|
1474
|
+
for (const item of items) {
|
|
1475
|
+
if (hasKind(item, "Rest")) {
|
|
1476
|
+
const rest = item;
|
|
1477
|
+
if (hasKind(rest.items, "Tuple")) {
|
|
1478
|
+
expanded.push(...rest.items.items);
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
expanded.push(item);
|
|
1483
|
+
}
|
|
1484
|
+
return expanded;
|
|
1485
|
+
}
|
|
1486
|
+
function Rest(item) {
|
|
1487
|
+
return { "~kind": "Rest", type: "rest", items: item };
|
|
1488
|
+
}
|
|
1489
|
+
function Composite(objects) {
|
|
1490
|
+
return Evaluate(Intersect(objects));
|
|
1491
|
+
}
|
|
1492
|
+
function Clone2(schema) {
|
|
1493
|
+
return Clone(schema);
|
|
1494
|
+
}
|
|
1495
|
+
function Capitalize(item) {
|
|
1496
|
+
return { "~kind": "Capitalize", item };
|
|
1497
|
+
}
|
|
1498
|
+
function Lowercase(item) {
|
|
1499
|
+
return { "~kind": "Lowercase", item };
|
|
1500
|
+
}
|
|
1501
|
+
function Uppercase(item) {
|
|
1502
|
+
return { "~kind": "Uppercase", item };
|
|
1503
|
+
}
|
|
1504
|
+
function Uncapitalize(item) {
|
|
1505
|
+
return { "~kind": "Uncapitalize", item };
|
|
1506
|
+
}
|
|
1507
|
+
function Interface(heritage, properties, options) {
|
|
1508
|
+
return {
|
|
1509
|
+
...Evaluate(Intersect([...heritage, Object2(properties)])),
|
|
1510
|
+
...options
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function NonNullable(type, options) {
|
|
1514
|
+
return Exclude(type, Union([Null(), Undefined()]), options);
|
|
1515
|
+
}
|
|
1516
|
+
function Options(type, options) {
|
|
1517
|
+
return {
|
|
1518
|
+
...type,
|
|
1519
|
+
...options
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
function ReadonlyType(type, options) {
|
|
1523
|
+
return Readonly(type, options);
|
|
1524
|
+
}
|
|
1525
|
+
function Identifier(name) {
|
|
1526
|
+
return {
|
|
1527
|
+
"~kind": "Identifier",
|
|
1528
|
+
type: "identifier",
|
|
1529
|
+
name
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
function Parameter(name, extends_, equals) {
|
|
1533
|
+
const constraint = extends_ ?? Unknown();
|
|
1534
|
+
const fallback = equals ?? constraint;
|
|
1535
|
+
return {
|
|
1536
|
+
"~kind": "Parameter",
|
|
1537
|
+
name,
|
|
1538
|
+
extends: constraint,
|
|
1539
|
+
equals: fallback
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
function This(options) {
|
|
1543
|
+
return {
|
|
1544
|
+
"~kind": "This",
|
|
1545
|
+
$ref: "#",
|
|
1546
|
+
...options
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
function Import(module, name) {
|
|
1550
|
+
const definition = module.definitions[name];
|
|
1551
|
+
if (definition === undefined) {
|
|
1552
|
+
throw new Error(`Unknown module definition: ${name}`);
|
|
1553
|
+
}
|
|
1554
|
+
return definition;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// src/type/primitives.ts
|
|
1558
|
+
function String2(options) {
|
|
1559
|
+
return { "~kind": "String", ...options };
|
|
1560
|
+
}
|
|
1561
|
+
function Number2(options) {
|
|
1562
|
+
return { "~kind": "Number", ...options };
|
|
1563
|
+
}
|
|
1564
|
+
function Integer(options) {
|
|
1565
|
+
return { "~kind": "Integer", ...options };
|
|
1566
|
+
}
|
|
1567
|
+
function Boolean(options) {
|
|
1568
|
+
return { "~kind": "Boolean", ...options };
|
|
1569
|
+
}
|
|
1570
|
+
function Null(options) {
|
|
1571
|
+
return { "~kind": "Null", ...options };
|
|
1572
|
+
}
|
|
1573
|
+
function Literal(value, options) {
|
|
1574
|
+
return { "~kind": "Literal", const: value, ...options };
|
|
1575
|
+
}
|
|
1576
|
+
function Void(options) {
|
|
1577
|
+
return { "~kind": "Void", ...options };
|
|
1578
|
+
}
|
|
1579
|
+
function Undefined(options) {
|
|
1580
|
+
return { "~kind": "Undefined", ...options };
|
|
1581
|
+
}
|
|
1582
|
+
function Unknown(options) {
|
|
1583
|
+
return { "~kind": "Unknown", ...options };
|
|
1584
|
+
}
|
|
1585
|
+
function Any(options) {
|
|
1586
|
+
return { "~kind": "Any", ...options };
|
|
1587
|
+
}
|
|
1588
|
+
function Never(options) {
|
|
1589
|
+
return { "~kind": "Never", ...options };
|
|
1590
|
+
}
|
|
1591
|
+
function BigInt(options) {
|
|
1592
|
+
return { "~kind": "BigInt", ...options };
|
|
1593
|
+
}
|
|
1594
|
+
function Date(options) {
|
|
1595
|
+
return { "~kind": "Date", ...options };
|
|
1596
|
+
}
|
|
1597
|
+
function DateFormat(options) {
|
|
1598
|
+
return String2({ format: "date", ...options });
|
|
1599
|
+
}
|
|
1600
|
+
function Uuid(options) {
|
|
1601
|
+
return String2({ format: "uuid", ...options });
|
|
1602
|
+
}
|
|
1603
|
+
function Email(options) {
|
|
1604
|
+
return String2({ format: "email", ...options });
|
|
1605
|
+
}
|
|
1606
|
+
function Uri(options) {
|
|
1607
|
+
return String2({ format: "uri", ...options });
|
|
1608
|
+
}
|
|
1609
|
+
function Hostname(options) {
|
|
1610
|
+
return String2({ format: "hostname", ...options });
|
|
1611
|
+
}
|
|
1612
|
+
function Ip(options) {
|
|
1613
|
+
return String2({ format: "ip", ...options });
|
|
1614
|
+
}
|
|
1615
|
+
function Base64(options) {
|
|
1616
|
+
return String2({ format: "base64", ...options });
|
|
1617
|
+
}
|
|
1618
|
+
function Hex(options) {
|
|
1619
|
+
return String2({ format: "hex", ...options });
|
|
1620
|
+
}
|
|
1621
|
+
function HexColor(options) {
|
|
1622
|
+
return String2({ format: "hexcolor", ...options });
|
|
1623
|
+
}
|
|
1624
|
+
function DateTime(options) {
|
|
1625
|
+
return String2({ format: "datetime", ...options });
|
|
1626
|
+
}
|
|
1627
|
+
function Time(options) {
|
|
1628
|
+
return String2({ format: "time", ...options });
|
|
1629
|
+
}
|
|
1630
|
+
function Duration(options) {
|
|
1631
|
+
return String2({ format: "duration", ...options });
|
|
1632
|
+
}
|
|
1633
|
+
function Json(options) {
|
|
1634
|
+
return String2({ format: "json", ...options });
|
|
1635
|
+
}
|
|
1636
|
+
function CreditCard(options) {
|
|
1637
|
+
return String2({ format: "creditcard", ...options });
|
|
1638
|
+
}
|
|
1639
|
+
function Uint8Array2(options) {
|
|
1640
|
+
return { "~kind": "Uint8Array", ...options };
|
|
1641
|
+
}
|
|
1642
|
+
function RegExpInstance(options) {
|
|
1643
|
+
return { "~kind": "RegExpInstance", ...options };
|
|
1644
|
+
}
|
|
1645
|
+
function RegExp2(options) {
|
|
1646
|
+
return String2({ format: "regex", ...options });
|
|
1647
|
+
}
|
|
1648
|
+
function Symbol2(options) {
|
|
1649
|
+
return { "~kind": "Symbol", ...options };
|
|
1650
|
+
}
|
|
1651
|
+
function TemplateLiteral(patterns, options) {
|
|
1652
|
+
return { "~kind": "TemplateLiteral", patterns, ...options };
|
|
1653
|
+
}
|
|
1654
|
+
function Function(parameters, returns, options) {
|
|
1655
|
+
const resolvedParameters = ExpandTupleRest(parameters ?? []);
|
|
1656
|
+
const resolvedReturns = returns ?? Any();
|
|
1657
|
+
return {
|
|
1658
|
+
"~kind": "Function",
|
|
1659
|
+
parameters: resolvedParameters,
|
|
1660
|
+
returns: resolvedReturns,
|
|
1661
|
+
...options
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
function Constructor(parameters, returns, options) {
|
|
1665
|
+
const resolvedParameters = ExpandTupleRest(parameters ?? []);
|
|
1666
|
+
const resolvedReturns = returns ?? Any();
|
|
1667
|
+
return {
|
|
1668
|
+
"~kind": "Constructor",
|
|
1669
|
+
parameters: resolvedParameters,
|
|
1670
|
+
returns: resolvedReturns,
|
|
1671
|
+
...options
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
function Promise2(item, options) {
|
|
1675
|
+
return { "~kind": "Promise", item, ...options };
|
|
1676
|
+
}
|
|
1677
|
+
function Iterator(item, options) {
|
|
1678
|
+
return { "~kind": "Iterator", item, ...options };
|
|
1679
|
+
}
|
|
1680
|
+
function AsyncIterator(item, options) {
|
|
1681
|
+
return { "~kind": "AsyncIterator", item, ...options };
|
|
1682
|
+
}
|
|
1683
|
+
function Decode(inner, decode) {
|
|
1684
|
+
return { "~kind": "Decode", inner, decode };
|
|
1685
|
+
}
|
|
1686
|
+
function Encode(inner, encode) {
|
|
1687
|
+
return { "~kind": "Encode", inner, encode };
|
|
1688
|
+
}
|
|
1689
|
+
// src/type/instantiation.ts
|
|
1690
|
+
function getString(value) {
|
|
1691
|
+
return typeof value === "string" ? value : undefined;
|
|
1692
|
+
}
|
|
1693
|
+
function getSchema(value) {
|
|
1694
|
+
if (typeof value !== "object" || value === null) {
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
return typeof value["~kind"] === "string" ? value : undefined;
|
|
1698
|
+
}
|
|
1699
|
+
function getSchemaArray(value) {
|
|
1700
|
+
return Array.isArray(value) ? value.flatMap((entry) => getSchema(entry) ? [entry] : []) : [];
|
|
1701
|
+
}
|
|
1702
|
+
function getParameterSchema(schema) {
|
|
1703
|
+
const value = schema;
|
|
1704
|
+
return {
|
|
1705
|
+
name: getString(value["name"]) ?? "",
|
|
1706
|
+
equals: getSchema(value["equals"]) ?? schema
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
function getInferSchema(schema) {
|
|
1710
|
+
const value = schema;
|
|
1711
|
+
return {
|
|
1712
|
+
name: getString(value["name"]) ?? "",
|
|
1713
|
+
extends: getSchema(value["extends"]) ?? schema
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
function getGenericSchema(schema) {
|
|
1717
|
+
const value = schema;
|
|
1718
|
+
const parameters = Array.isArray(value["parameters"]) ? value["parameters"].flatMap((entry) => {
|
|
1719
|
+
if (typeof entry !== "object" || entry === null)
|
|
1720
|
+
return [];
|
|
1721
|
+
const candidate = entry;
|
|
1722
|
+
return candidate["~kind"] === "Parameter" ? [entry] : [];
|
|
1723
|
+
}) : [];
|
|
1724
|
+
return {
|
|
1725
|
+
parameters,
|
|
1726
|
+
expression: getSchema(value["expression"]) ?? schema
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
function getCallSchema(schema) {
|
|
1730
|
+
const value = schema;
|
|
1731
|
+
return {
|
|
1732
|
+
target: getSchema(value["target"]) ?? schema,
|
|
1733
|
+
arguments: getSchemaArray(value["arguments"])
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
function getCyclicSchema(schema) {
|
|
1737
|
+
const value = schema;
|
|
1738
|
+
const defsSource = value["$defs"];
|
|
1739
|
+
const defs = typeof defsSource === "object" && defsSource !== null ? Object.fromEntries(Object.entries(defsSource).flatMap(([key, entry]) => {
|
|
1740
|
+
const nextSchema = getSchema(entry);
|
|
1741
|
+
return nextSchema ? [[key, nextSchema]] : [];
|
|
1742
|
+
})) : {};
|
|
1743
|
+
return {
|
|
1744
|
+
$defs: defs,
|
|
1745
|
+
$ref: getString(value["$ref"]) ?? ""
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
function bindParameterContext(parameters, arguments_) {
|
|
1749
|
+
const context = {};
|
|
1750
|
+
for (let index = 0;index < parameters.length; index += 1) {
|
|
1751
|
+
const parameter = parameters[index];
|
|
1752
|
+
const name = parameter.name;
|
|
1753
|
+
const argument = arguments_[index] ?? parameter.equals;
|
|
1754
|
+
context[name] = argument;
|
|
1755
|
+
}
|
|
1756
|
+
return context;
|
|
1757
|
+
}
|
|
1758
|
+
function getObjectSchema(schema) {
|
|
1759
|
+
const value = schema;
|
|
1760
|
+
const propertiesSource = value["properties"];
|
|
1761
|
+
const patternPropertiesSource = value["patternProperties"];
|
|
1762
|
+
const requiredSource = value["required"];
|
|
1763
|
+
const optionalSource = value["optional"];
|
|
1764
|
+
return {
|
|
1765
|
+
...schema,
|
|
1766
|
+
"~kind": "Object",
|
|
1767
|
+
properties: typeof propertiesSource === "object" && propertiesSource !== null ? propertiesSource : {},
|
|
1768
|
+
...typeof patternPropertiesSource === "object" && patternPropertiesSource !== null ? { patternProperties: patternPropertiesSource } : {},
|
|
1769
|
+
...Array.isArray(requiredSource) ? { required: requiredSource.filter((entry) => typeof entry === "string") } : {},
|
|
1770
|
+
...Array.isArray(optionalSource) ? { optional: optionalSource.filter((entry) => typeof entry === "string") } : {}
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
function instantiateObject(context, schema) {
|
|
1774
|
+
const objectSchema = getObjectSchema(schema);
|
|
1775
|
+
const properties = {};
|
|
1776
|
+
for (const [key, value] of Object.entries(objectSchema.properties)) {
|
|
1777
|
+
properties[key] = Instantiate(context, value);
|
|
1778
|
+
}
|
|
1779
|
+
const patternProperties = objectSchema.patternProperties === undefined ? undefined : Object.fromEntries(Object.entries(objectSchema.patternProperties).map(([key, value]) => [key, Instantiate(context, value)]));
|
|
1780
|
+
return {
|
|
1781
|
+
...objectSchema,
|
|
1782
|
+
properties,
|
|
1783
|
+
...patternProperties !== undefined ? { patternProperties } : {},
|
|
1784
|
+
...typeof objectSchema.additionalProperties === "object" && objectSchema.additionalProperties !== null ? { additionalProperties: Instantiate(context, objectSchema.additionalProperties) } : {}
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
function Instantiate(context, schema) {
|
|
1788
|
+
const value = schema;
|
|
1789
|
+
const kind = value["~kind"];
|
|
1790
|
+
switch (kind) {
|
|
1791
|
+
case "Parameter": {
|
|
1792
|
+
const parameter = getParameterSchema(schema);
|
|
1793
|
+
return context[parameter.name] ?? parameter.equals;
|
|
1794
|
+
}
|
|
1795
|
+
case "Infer": {
|
|
1796
|
+
const infer = getInferSchema(schema);
|
|
1797
|
+
return context[infer.name] ?? infer.extends;
|
|
1798
|
+
}
|
|
1799
|
+
case "This":
|
|
1800
|
+
return schema;
|
|
1801
|
+
case "Ref": {
|
|
1802
|
+
const name = value["name"];
|
|
1803
|
+
return typeof name === "string" && context[name] !== undefined ? context[name] : schema;
|
|
1804
|
+
}
|
|
1805
|
+
case "Array":
|
|
1806
|
+
return { ...schema, items: Instantiate(context, value["items"]) };
|
|
1807
|
+
case "Object":
|
|
1808
|
+
return instantiateObject(context, schema);
|
|
1809
|
+
case "Tuple":
|
|
1810
|
+
return { ...schema, items: value["items"].map((item) => Instantiate(context, item)) };
|
|
1811
|
+
case "Record":
|
|
1812
|
+
return {
|
|
1813
|
+
...schema,
|
|
1814
|
+
key: Instantiate(context, value["key"]),
|
|
1815
|
+
value: Instantiate(context, value["value"])
|
|
1816
|
+
};
|
|
1817
|
+
case "Union":
|
|
1818
|
+
case "Intersect":
|
|
1819
|
+
return { ...schema, variants: value["variants"].map((item) => Instantiate(context, item)) };
|
|
1820
|
+
case "Optional":
|
|
1821
|
+
case "Readonly":
|
|
1822
|
+
case "Capitalize":
|
|
1823
|
+
case "Lowercase":
|
|
1824
|
+
case "Uppercase":
|
|
1825
|
+
case "Uncapitalize":
|
|
1826
|
+
case "Awaited":
|
|
1827
|
+
return { ...schema, item: Instantiate(context, value["item"]) };
|
|
1828
|
+
case "Immutable":
|
|
1829
|
+
case "Refine":
|
|
1830
|
+
return { ...schema, item: Instantiate(context, value["item"]) };
|
|
1831
|
+
case "Codec":
|
|
1832
|
+
return { ...schema, inner: Instantiate(context, value["inner"]) };
|
|
1833
|
+
case "Exclude":
|
|
1834
|
+
case "Extract":
|
|
1835
|
+
return {
|
|
1836
|
+
...schema,
|
|
1837
|
+
left: Instantiate(context, value["left"]),
|
|
1838
|
+
right: Instantiate(context, value["right"])
|
|
1839
|
+
};
|
|
1840
|
+
case "Not":
|
|
1841
|
+
return { ...schema, schema: Instantiate(context, value["schema"]) };
|
|
1842
|
+
case "IfThenElse":
|
|
1843
|
+
return {
|
|
1844
|
+
...schema,
|
|
1845
|
+
if: Instantiate(context, value["if"]),
|
|
1846
|
+
then: Instantiate(context, value["then"]),
|
|
1847
|
+
else: Instantiate(context, value["else"])
|
|
1848
|
+
};
|
|
1849
|
+
case "Index":
|
|
1850
|
+
return {
|
|
1851
|
+
...schema,
|
|
1852
|
+
object: Instantiate(context, value["object"]),
|
|
1853
|
+
key: Instantiate(context, value["key"])
|
|
1854
|
+
};
|
|
1855
|
+
case "Mapped":
|
|
1856
|
+
return { ...schema, object: Instantiate(context, value["object"]) };
|
|
1857
|
+
case "Conditional":
|
|
1858
|
+
return {
|
|
1859
|
+
...schema,
|
|
1860
|
+
check: Instantiate(context, value["check"]),
|
|
1861
|
+
union: value["union"].map((item) => Instantiate(context, item)),
|
|
1862
|
+
...value["default"] !== undefined ? { default: Instantiate(context, value["default"]) } : {}
|
|
1863
|
+
};
|
|
1864
|
+
case "Function":
|
|
1865
|
+
case "Constructor":
|
|
1866
|
+
return {
|
|
1867
|
+
...schema,
|
|
1868
|
+
parameters: value["parameters"].map((item) => Instantiate(context, item)),
|
|
1869
|
+
returns: Instantiate(context, value["returns"])
|
|
1870
|
+
};
|
|
1871
|
+
case "Promise":
|
|
1872
|
+
case "Iterator":
|
|
1873
|
+
case "AsyncIterator":
|
|
1874
|
+
case "Rest":
|
|
1875
|
+
return { ...schema, item: Instantiate(context, value["item"]), items: Instantiate(context, value["items"] ?? value["item"]) };
|
|
1876
|
+
case "Decode":
|
|
1877
|
+
return { ...schema, inner: Instantiate(context, value["inner"]) };
|
|
1878
|
+
case "Encode":
|
|
1879
|
+
return { ...schema, inner: Instantiate(context, value["inner"]) };
|
|
1880
|
+
case "ReturnType":
|
|
1881
|
+
case "Parameters":
|
|
1882
|
+
return { ...schema, function: Instantiate(context, value["function"]) };
|
|
1883
|
+
case "InstanceType":
|
|
1884
|
+
case "ConstructorParameters":
|
|
1885
|
+
return { ...schema, constructor: Instantiate(context, value["constructor"]) };
|
|
1886
|
+
case "Generic": {
|
|
1887
|
+
const generic = getGenericSchema(schema);
|
|
1888
|
+
return {
|
|
1889
|
+
...generic,
|
|
1890
|
+
parameters: generic.parameters,
|
|
1891
|
+
expression: Instantiate(context, generic.expression)
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
case "Call": {
|
|
1895
|
+
const call = getCallSchema(schema);
|
|
1896
|
+
const target = Instantiate(context, call.target);
|
|
1897
|
+
const arguments_ = call.arguments.map((item) => Instantiate(context, item));
|
|
1898
|
+
const targetValue = target;
|
|
1899
|
+
if (targetValue["~kind"] === "Generic") {
|
|
1900
|
+
const generic = getGenericSchema(target);
|
|
1901
|
+
const nextContext = bindParameterContext(generic.parameters, arguments_);
|
|
1902
|
+
return Instantiate({ ...context, ...nextContext }, generic.expression);
|
|
1903
|
+
}
|
|
1904
|
+
return {
|
|
1905
|
+
"~kind": "Call",
|
|
1906
|
+
target,
|
|
1907
|
+
arguments: arguments_
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
case "Cyclic": {
|
|
1911
|
+
const cyclic = getCyclicSchema(schema);
|
|
1912
|
+
const defs = Object.fromEntries(Object.entries(cyclic.$defs).map(([key, value2]) => [key, Instantiate(context, value2)]));
|
|
1913
|
+
return {
|
|
1914
|
+
...cyclic,
|
|
1915
|
+
$defs: defs
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
default:
|
|
1919
|
+
return schema;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// src/type/extensions.ts
|
|
1924
|
+
class EncodeBuilder {
|
|
1925
|
+
type;
|
|
1926
|
+
decode;
|
|
1927
|
+
constructor(type, decode) {
|
|
1928
|
+
this.type = type;
|
|
1929
|
+
this.decode = decode;
|
|
1930
|
+
}
|
|
1931
|
+
Encode(callback) {
|
|
1932
|
+
return {
|
|
1933
|
+
"~kind": "Codec",
|
|
1934
|
+
inner: this.type,
|
|
1935
|
+
codec: {
|
|
1936
|
+
decode: this.decode,
|
|
1937
|
+
encode: callback
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
class DecodeBuilder {
|
|
1944
|
+
type;
|
|
1945
|
+
constructor(type) {
|
|
1946
|
+
this.type = type;
|
|
1947
|
+
}
|
|
1948
|
+
Decode(callback) {
|
|
1949
|
+
return new EncodeBuilder(this.type, callback);
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
function Codec(type) {
|
|
1953
|
+
return new DecodeBuilder(type);
|
|
1954
|
+
}
|
|
1955
|
+
function IsCodec(value) {
|
|
1956
|
+
if (typeof value !== "object" || value === null) {
|
|
1957
|
+
return false;
|
|
1958
|
+
}
|
|
1959
|
+
const schema = value;
|
|
1960
|
+
return schema["~kind"] === "Codec" && typeof schema.codec === "object" && schema.codec !== null && typeof schema.codec.decode === "function" && typeof schema.codec.encode === "function";
|
|
1961
|
+
}
|
|
1962
|
+
function Immutable(type) {
|
|
1963
|
+
return {
|
|
1964
|
+
"~kind": "Immutable",
|
|
1965
|
+
item: type
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
function IsImmutable(value) {
|
|
1969
|
+
return typeof value === "object" && value !== null && (value["~kind"] === "Immutable" || value["~immutable"] === true);
|
|
1970
|
+
}
|
|
1971
|
+
function Refine(type, refine, message = "error") {
|
|
1972
|
+
return {
|
|
1973
|
+
"~kind": "Refine",
|
|
1974
|
+
item: type,
|
|
1975
|
+
"~refine": [{ refine, message }]
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1978
|
+
function IsRefine(value) {
|
|
1979
|
+
return typeof value === "object" && value !== null && (value["~kind"] === "Refine" || Array.isArray(value["~refine"]));
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
class Base {
|
|
1983
|
+
"~kind" = "Base";
|
|
1984
|
+
Check(value) {
|
|
1985
|
+
return true;
|
|
1986
|
+
}
|
|
1987
|
+
Errors(_value) {
|
|
1988
|
+
return [];
|
|
1989
|
+
}
|
|
1990
|
+
Convert(value) {
|
|
1991
|
+
return value;
|
|
1992
|
+
}
|
|
1993
|
+
Clean(value) {
|
|
1994
|
+
return value;
|
|
1995
|
+
}
|
|
1996
|
+
Default(value) {
|
|
1997
|
+
return value;
|
|
1998
|
+
}
|
|
1999
|
+
Create() {
|
|
2000
|
+
throw new Error("Create not implemented");
|
|
2001
|
+
}
|
|
2002
|
+
Clone() {
|
|
2003
|
+
return this;
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
function IsBase(value) {
|
|
2007
|
+
return value instanceof Base || typeof value === "object" && value !== null && value["~kind"] === "Base";
|
|
2008
|
+
}
|
|
2009
|
+
function Call(target, arguments_) {
|
|
2010
|
+
const targetValue = target;
|
|
2011
|
+
if (targetValue["~kind"] === "Generic") {
|
|
2012
|
+
const parameters = targetValue.parameters ?? [];
|
|
2013
|
+
const expression = targetValue.expression;
|
|
2014
|
+
if (expression !== undefined) {
|
|
2015
|
+
const context = bindParameterContext(parameters, arguments_);
|
|
2016
|
+
return Instantiate(context, expression);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
return {
|
|
2020
|
+
"~kind": "Call",
|
|
2021
|
+
target,
|
|
2022
|
+
arguments: arguments_
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
function IsCall(value) {
|
|
2026
|
+
return typeof value === "object" && value !== null && value["~kind"] === "Call";
|
|
2027
|
+
}
|
|
2028
|
+
function Cyclic($defs, $ref, options = {}) {
|
|
2029
|
+
return {
|
|
2030
|
+
"~kind": "Cyclic",
|
|
2031
|
+
$defs,
|
|
2032
|
+
$ref,
|
|
2033
|
+
...options
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
function IsCyclic(value) {
|
|
2037
|
+
return typeof value === "object" && value !== null && value["~kind"] === "Cyclic";
|
|
2038
|
+
}
|
|
2039
|
+
function Generic(parameters, expression) {
|
|
2040
|
+
return {
|
|
2041
|
+
"~kind": "Generic",
|
|
2042
|
+
type: "generic",
|
|
2043
|
+
parameters,
|
|
2044
|
+
expression
|
|
2045
|
+
};
|
|
2046
|
+
}
|
|
2047
|
+
function IsGeneric(value) {
|
|
2048
|
+
return typeof value === "object" && value !== null && value["~kind"] === "Generic";
|
|
2049
|
+
}
|
|
2050
|
+
function Infer(name, extends_) {
|
|
2051
|
+
return {
|
|
2052
|
+
"~kind": "Infer",
|
|
2053
|
+
type: "infer",
|
|
2054
|
+
name,
|
|
2055
|
+
extends: extends_ ?? Unknown()
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
function IsInfer(value) {
|
|
2059
|
+
return typeof value === "object" && value !== null && value["~kind"] === "Infer";
|
|
2060
|
+
}
|
|
2061
|
+
// src/shared/schema-access.ts
|
|
2062
|
+
function isRecord(value) {
|
|
2063
|
+
return typeof value === "object" && value !== null;
|
|
2064
|
+
}
|
|
2065
|
+
function isSchemaValue(value) {
|
|
2066
|
+
return isRecord(value) && typeof value["~kind"] === "string";
|
|
2067
|
+
}
|
|
2068
|
+
function schemaNode(schema) {
|
|
2069
|
+
return schema;
|
|
2070
|
+
}
|
|
2071
|
+
function schemaKind(schema) {
|
|
2072
|
+
const kind = schemaNode(schema)["~kind"];
|
|
2073
|
+
return typeof kind === "string" ? kind : undefined;
|
|
2074
|
+
}
|
|
2075
|
+
function schemaUnknownField(schema, field) {
|
|
2076
|
+
return schemaNode(schema)[field];
|
|
2077
|
+
}
|
|
2078
|
+
function schemaStringField(schema, field) {
|
|
2079
|
+
const value = schemaUnknownField(schema, field);
|
|
2080
|
+
return typeof value === "string" ? value : undefined;
|
|
2081
|
+
}
|
|
2082
|
+
function schemaNumberField(schema, field) {
|
|
2083
|
+
const value = schemaUnknownField(schema, field);
|
|
2084
|
+
return typeof value === "number" ? value : undefined;
|
|
2085
|
+
}
|
|
2086
|
+
function schemaBigIntField(schema, field) {
|
|
2087
|
+
const value = schemaUnknownField(schema, field);
|
|
2088
|
+
return typeof value === "bigint" ? value : undefined;
|
|
2089
|
+
}
|
|
2090
|
+
function schemaBooleanField(schema, field) {
|
|
2091
|
+
const value = schemaUnknownField(schema, field);
|
|
2092
|
+
return typeof value === "boolean" ? value : undefined;
|
|
2093
|
+
}
|
|
2094
|
+
function schemaStringListField(schema, field) {
|
|
2095
|
+
const value = schemaUnknownField(schema, field);
|
|
2096
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string") ? value : [];
|
|
2097
|
+
}
|
|
2098
|
+
function schemaSchemaField(schema, field) {
|
|
2099
|
+
const value = schemaUnknownField(schema, field);
|
|
2100
|
+
return isSchemaValue(value) ? value : undefined;
|
|
2101
|
+
}
|
|
2102
|
+
function schemaSchemaListField(schema, field) {
|
|
2103
|
+
const value = schemaUnknownField(schema, field);
|
|
2104
|
+
return Array.isArray(value) && value.every(isSchemaValue) ? value : [];
|
|
2105
|
+
}
|
|
2106
|
+
function schemaSchemaMapField(schema, field) {
|
|
2107
|
+
const value = schemaUnknownField(schema, field);
|
|
2108
|
+
if (!isRecord(value)) {
|
|
2109
|
+
return {};
|
|
2110
|
+
}
|
|
2111
|
+
return Object.values(value).every(isSchemaValue) ? value : {};
|
|
2112
|
+
}
|
|
2113
|
+
function schemaBooleanOrSchemaField(schema, field) {
|
|
2114
|
+
const value = schemaUnknownField(schema, field);
|
|
2115
|
+
if (typeof value === "boolean" || value === undefined) {
|
|
2116
|
+
return value;
|
|
2117
|
+
}
|
|
2118
|
+
return isSchemaValue(value) ? value : undefined;
|
|
2119
|
+
}
|
|
2120
|
+
function schemaCallbackField(schema, field) {
|
|
2121
|
+
const value = schemaUnknownField(schema, field);
|
|
2122
|
+
return typeof value === "function" ? value : undefined;
|
|
2123
|
+
}
|
|
2124
|
+
function schemaItem(schema) {
|
|
2125
|
+
return schemaSchemaField(schema, "item");
|
|
2126
|
+
}
|
|
2127
|
+
function schemaInner(schema) {
|
|
2128
|
+
return schemaSchemaField(schema, "inner");
|
|
2129
|
+
}
|
|
2130
|
+
function schemaItemOrInner(schema) {
|
|
2131
|
+
return schemaItem(schema) ?? schemaInner(schema);
|
|
2132
|
+
}
|
|
2133
|
+
function schemaVariants(schema) {
|
|
2134
|
+
return schemaSchemaListField(schema, "variants");
|
|
2135
|
+
}
|
|
2136
|
+
function schemaProperties(schema) {
|
|
2137
|
+
return schemaSchemaMapField(schema, "properties");
|
|
2138
|
+
}
|
|
2139
|
+
function schemaDefinitions(schema) {
|
|
2140
|
+
return schemaSchemaMapField(schema, "$defs");
|
|
2141
|
+
}
|
|
2142
|
+
function schemaPatternProperties(schema) {
|
|
2143
|
+
return schemaSchemaMapField(schema, "patternProperties");
|
|
2144
|
+
}
|
|
2145
|
+
function schemaRequiredKeys(schema) {
|
|
2146
|
+
return schemaStringListField(schema, "required");
|
|
2147
|
+
}
|
|
2148
|
+
function schemaOptionalKeys(schema) {
|
|
2149
|
+
return schemaStringListField(schema, "optional");
|
|
2150
|
+
}
|
|
2151
|
+
function schemaConst(schema) {
|
|
2152
|
+
return schemaUnknownField(schema, "const");
|
|
2153
|
+
}
|
|
2154
|
+
function schemaPatterns(schema) {
|
|
2155
|
+
return schemaStringListField(schema, "patterns");
|
|
2156
|
+
}
|
|
2157
|
+
function schemaRefinements(schema) {
|
|
2158
|
+
const value = schemaUnknownField(schema, "~refine");
|
|
2159
|
+
return Array.isArray(value) ? value.filter((entry) => isRecord(entry) && typeof entry.refine === "function" && (entry.message === undefined || typeof entry.message === "string")) : [];
|
|
2160
|
+
}
|
|
2161
|
+
function schemaPath(path) {
|
|
2162
|
+
return path.join(".") || "/";
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// src/type/extends.ts
|
|
2166
|
+
function extendsUnion(inferred) {
|
|
2167
|
+
return { "~kind": "ExtendsUnion", inferred };
|
|
2168
|
+
}
|
|
2169
|
+
function extendsTrue(inferred) {
|
|
2170
|
+
return { "~kind": "ExtendsTrue", inferred };
|
|
2171
|
+
}
|
|
2172
|
+
function extendsFalse() {
|
|
2173
|
+
return { "~kind": "ExtendsFalse" };
|
|
2174
|
+
}
|
|
2175
|
+
function isExtendsTrueLike(value) {
|
|
2176
|
+
return value["~kind"] === "ExtendsTrue" || value["~kind"] === "ExtendsUnion";
|
|
2177
|
+
}
|
|
2178
|
+
function mergeInferred(left, right) {
|
|
2179
|
+
return { ...left, ...right };
|
|
2180
|
+
}
|
|
2181
|
+
function extendsObject(inferred, left, right) {
|
|
2182
|
+
const leftProps = left.properties;
|
|
2183
|
+
const rightProps = right.properties;
|
|
2184
|
+
let result = extendsTrue(inferred);
|
|
2185
|
+
for (const [key, rightSchema] of Object.entries(rightProps)) {
|
|
2186
|
+
const leftSchema = leftProps[key];
|
|
2187
|
+
if (leftSchema === undefined) {
|
|
2188
|
+
return extendsFalse();
|
|
2189
|
+
}
|
|
2190
|
+
result = extendsSchemas(result.inferred, leftSchema, rightSchema);
|
|
2191
|
+
if (!isExtendsTrueLike(result)) {
|
|
2192
|
+
return result;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
return result;
|
|
2196
|
+
}
|
|
2197
|
+
function extendsLiteral(left, right) {
|
|
2198
|
+
const leftValue = schemaConst(left);
|
|
2199
|
+
const rightKind = schemaKind(right);
|
|
2200
|
+
if (rightKind === "Literal") {
|
|
2201
|
+
return leftValue === schemaConst(right);
|
|
2202
|
+
}
|
|
2203
|
+
if (rightKind === "String")
|
|
2204
|
+
return typeof leftValue === "string";
|
|
2205
|
+
if (rightKind === "Number" || rightKind === "Integer")
|
|
2206
|
+
return typeof leftValue === "number";
|
|
2207
|
+
if (rightKind === "Boolean")
|
|
2208
|
+
return typeof leftValue === "boolean";
|
|
2209
|
+
return false;
|
|
2210
|
+
}
|
|
2211
|
+
function extendsSameKind(inferred, left, right) {
|
|
2212
|
+
const kind = schemaKind(left);
|
|
2213
|
+
if (kind === "Object") {
|
|
2214
|
+
return extendsObject(inferred, left, right);
|
|
2215
|
+
}
|
|
2216
|
+
return extendsTrue(inferred);
|
|
2217
|
+
}
|
|
2218
|
+
function inferFromSchema(inferred, left, right) {
|
|
2219
|
+
if (schemaKind(right) === "Infer") {
|
|
2220
|
+
const infer = right;
|
|
2221
|
+
return extendsSchemas(mergeInferred(inferred, { [infer.name]: left }), left, infer.extends);
|
|
2222
|
+
}
|
|
2223
|
+
return extendsSchemas(inferred, left, right);
|
|
2224
|
+
}
|
|
2225
|
+
function extendsSchemas(inferred, left, right) {
|
|
2226
|
+
const leftKind = schemaKind(left);
|
|
2227
|
+
const rightKind = schemaKind(right);
|
|
2228
|
+
if (rightKind === "Union") {
|
|
2229
|
+
let sawUnion = false;
|
|
2230
|
+
for (const variant of schemaVariants(right)) {
|
|
2231
|
+
const result = inferFromSchema(inferred, left, variant);
|
|
2232
|
+
if (result["~kind"] === "ExtendsTrue")
|
|
2233
|
+
return result;
|
|
2234
|
+
if (result["~kind"] === "ExtendsUnion")
|
|
2235
|
+
sawUnion = true;
|
|
2236
|
+
}
|
|
2237
|
+
return sawUnion ? extendsUnion(inferred) : extendsFalse();
|
|
2238
|
+
}
|
|
2239
|
+
if (leftKind === "Union") {
|
|
2240
|
+
let result = extendsTrue(inferred);
|
|
2241
|
+
for (const variant of schemaVariants(left)) {
|
|
2242
|
+
result = extendsSchemas(result.inferred, variant, right);
|
|
2243
|
+
if (!isExtendsTrueLike(result))
|
|
2244
|
+
return result;
|
|
2245
|
+
}
|
|
2246
|
+
return result;
|
|
2247
|
+
}
|
|
2248
|
+
if (leftKind === "Literal") {
|
|
2249
|
+
return extendsLiteral(left, right) ? extendsTrue(inferred) : extendsFalse();
|
|
2250
|
+
}
|
|
2251
|
+
if (rightKind === "Unknown" || rightKind === "Any")
|
|
2252
|
+
return extendsTrue(inferred);
|
|
2253
|
+
if (leftKind === rightKind)
|
|
2254
|
+
return extendsSameKind(inferred, left, right);
|
|
2255
|
+
if (leftKind === "Integer" && rightKind === "Number")
|
|
2256
|
+
return extendsTrue(inferred);
|
|
2257
|
+
return extendsFalse();
|
|
2258
|
+
}
|
|
2259
|
+
function Extends(arg0, arg1, arg2) {
|
|
2260
|
+
if (arg2 === undefined) {
|
|
2261
|
+
return extendsSchemas({}, arg0, arg1);
|
|
2262
|
+
}
|
|
2263
|
+
return extendsSchemas(arg0, arg1, arg2);
|
|
2264
|
+
}
|
|
2265
|
+
var ExtendsResult = {
|
|
2266
|
+
Union: extendsUnion,
|
|
2267
|
+
True: extendsTrue,
|
|
2268
|
+
False: extendsFalse,
|
|
2269
|
+
IsExtendsUnion(value) {
|
|
2270
|
+
return value["~kind"] === "ExtendsUnion";
|
|
2271
|
+
},
|
|
2272
|
+
IsExtendsTrue(value) {
|
|
2273
|
+
return value["~kind"] === "ExtendsTrue";
|
|
2274
|
+
},
|
|
2275
|
+
IsExtendsFalse(value) {
|
|
2276
|
+
return value["~kind"] === "ExtendsFalse";
|
|
2277
|
+
},
|
|
2278
|
+
IsExtendsTrueLike: isExtendsTrueLike
|
|
2279
|
+
};
|
|
2280
|
+
// src/type/guards.ts
|
|
2281
|
+
var exports_guards = {};
|
|
2282
|
+
__export(exports_guards, {
|
|
2283
|
+
IsVoid: () => IsVoid,
|
|
2284
|
+
IsUppercase: () => IsUppercase,
|
|
2285
|
+
IsUnsafe: () => IsUnsafe,
|
|
2286
|
+
IsUnknown: () => IsUnknown,
|
|
2287
|
+
IsUnion: () => IsUnion,
|
|
2288
|
+
IsUndefined: () => IsUndefined,
|
|
2289
|
+
IsUncapitalize: () => IsUncapitalize,
|
|
2290
|
+
IsUint8Array: () => IsUint8Array,
|
|
2291
|
+
IsTuple: () => IsTuple,
|
|
2292
|
+
IsThis: () => IsThis,
|
|
2293
|
+
IsTemplateLiteral: () => IsTemplateLiteral,
|
|
2294
|
+
IsSymbol: () => IsSymbol,
|
|
2295
|
+
IsString: () => IsString,
|
|
2296
|
+
IsSchema: () => IsSchema,
|
|
2297
|
+
IsReturnType: () => IsReturnType,
|
|
2298
|
+
IsRest: () => IsRest,
|
|
2299
|
+
IsRequired: () => IsRequired,
|
|
2300
|
+
IsRegExpInstance: () => IsRegExpInstance,
|
|
2301
|
+
IsRefine: () => IsRefine2,
|
|
2302
|
+
IsRef: () => IsRef,
|
|
2303
|
+
IsRecursive: () => IsRecursive,
|
|
2304
|
+
IsRecord: () => IsRecord,
|
|
2305
|
+
IsReadonlyType: () => IsReadonlyType,
|
|
2306
|
+
IsReadonly: () => IsReadonly,
|
|
2307
|
+
IsPromise: () => IsPromise,
|
|
2308
|
+
IsPick: () => IsPick,
|
|
2309
|
+
IsPartial: () => IsPartial,
|
|
2310
|
+
IsParameters: () => IsParameters,
|
|
2311
|
+
IsParameter: () => IsParameter,
|
|
2312
|
+
IsOptions: () => IsOptions,
|
|
2313
|
+
IsOptional: () => IsOptional,
|
|
2314
|
+
IsOmit: () => IsOmit,
|
|
2315
|
+
IsObject: () => IsObject,
|
|
2316
|
+
IsNumber: () => IsNumber,
|
|
2317
|
+
IsNull: () => IsNull,
|
|
2318
|
+
IsNot: () => IsNot,
|
|
2319
|
+
IsNonNullable: () => IsNonNullable,
|
|
2320
|
+
IsNever: () => IsNever,
|
|
2321
|
+
IsModule: () => IsModule,
|
|
2322
|
+
IsMapped: () => IsMapped,
|
|
2323
|
+
IsLowercase: () => IsLowercase,
|
|
2324
|
+
IsLiteral: () => IsLiteral,
|
|
2325
|
+
IsKind: () => IsKind,
|
|
2326
|
+
IsKeyOf: () => IsKeyOf,
|
|
2327
|
+
IsIterator: () => IsIterator,
|
|
2328
|
+
IsIntersect: () => IsIntersect,
|
|
2329
|
+
IsInterface: () => IsInterface,
|
|
2330
|
+
IsInteger: () => IsInteger,
|
|
2331
|
+
IsInstanceType: () => IsInstanceType,
|
|
2332
|
+
IsInfer: () => IsInfer2,
|
|
2333
|
+
IsIndex: () => IsIndex,
|
|
2334
|
+
IsImmutable: () => IsImmutable2,
|
|
2335
|
+
IsIfThenElse: () => IsIfThenElse,
|
|
2336
|
+
IsIdentifier: () => IsIdentifier,
|
|
2337
|
+
IsGeneric: () => IsGeneric2,
|
|
2338
|
+
IsFunction: () => IsFunction,
|
|
2339
|
+
IsExtract: () => IsExtract,
|
|
2340
|
+
IsExclude: () => IsExclude,
|
|
2341
|
+
IsEnum: () => IsEnum,
|
|
2342
|
+
IsEncode: () => IsEncode,
|
|
2343
|
+
IsDecode: () => IsDecode,
|
|
2344
|
+
IsDate: () => IsDate,
|
|
2345
|
+
IsCyclic: () => IsCyclic2,
|
|
2346
|
+
IsConstructorParameters: () => IsConstructorParameters,
|
|
2347
|
+
IsConstructor: () => IsConstructor,
|
|
2348
|
+
IsConditional: () => IsConditional,
|
|
2349
|
+
IsCodec: () => IsCodec2,
|
|
2350
|
+
IsCapitalize: () => IsCapitalize,
|
|
2351
|
+
IsCall: () => IsCall2,
|
|
2352
|
+
IsBoolean: () => IsBoolean,
|
|
2353
|
+
IsBigInt: () => IsBigInt,
|
|
2354
|
+
IsBase: () => IsBase2,
|
|
2355
|
+
IsAwaited: () => IsAwaited,
|
|
2356
|
+
IsAsyncIterator: () => IsAsyncIterator,
|
|
2357
|
+
IsArray: () => IsArray,
|
|
2358
|
+
IsAny: () => IsAny
|
|
2359
|
+
});
|
|
2360
|
+
function isKind(schema, kind) {
|
|
2361
|
+
return schema["~kind"] === kind;
|
|
2362
|
+
}
|
|
2363
|
+
function hasFlag(schema, flag) {
|
|
2364
|
+
return typeof schema === "object" && schema !== null && flag in schema;
|
|
2365
|
+
}
|
|
2366
|
+
function IsSchema(schema) {
|
|
2367
|
+
return typeof schema === "object" && schema !== null && "~kind" in schema;
|
|
2368
|
+
}
|
|
2369
|
+
function IsKind(schema, kind) {
|
|
2370
|
+
return isKind(schema, kind);
|
|
2371
|
+
}
|
|
2372
|
+
function IsString(schema) {
|
|
2373
|
+
return isKind(schema, "String");
|
|
2374
|
+
}
|
|
2375
|
+
function IsNumber(schema) {
|
|
2376
|
+
return isKind(schema, "Number");
|
|
2377
|
+
}
|
|
2378
|
+
function IsInteger(schema) {
|
|
2379
|
+
return isKind(schema, "Integer");
|
|
2380
|
+
}
|
|
2381
|
+
function IsBoolean(schema) {
|
|
2382
|
+
return isKind(schema, "Boolean");
|
|
2383
|
+
}
|
|
2384
|
+
function IsNull(schema) {
|
|
2385
|
+
return isKind(schema, "Null");
|
|
2386
|
+
}
|
|
2387
|
+
function IsLiteral(schema) {
|
|
2388
|
+
return isKind(schema, "Literal");
|
|
2389
|
+
}
|
|
2390
|
+
function IsVoid(schema) {
|
|
2391
|
+
return isKind(schema, "Void");
|
|
2392
|
+
}
|
|
2393
|
+
function IsUndefined(schema) {
|
|
2394
|
+
return isKind(schema, "Undefined");
|
|
2395
|
+
}
|
|
2396
|
+
function IsUnknown(schema) {
|
|
2397
|
+
return isKind(schema, "Unknown");
|
|
2398
|
+
}
|
|
2399
|
+
function IsAny(schema) {
|
|
2400
|
+
return isKind(schema, "Any");
|
|
2401
|
+
}
|
|
2402
|
+
function IsNever(schema) {
|
|
2403
|
+
return isKind(schema, "Never");
|
|
2404
|
+
}
|
|
2405
|
+
function IsBigInt(schema) {
|
|
2406
|
+
return isKind(schema, "BigInt");
|
|
2407
|
+
}
|
|
2408
|
+
function IsDate(schema) {
|
|
2409
|
+
return isKind(schema, "Date");
|
|
2410
|
+
}
|
|
2411
|
+
function IsArray(schema) {
|
|
2412
|
+
return isKind(schema, "Array");
|
|
2413
|
+
}
|
|
2414
|
+
function IsObject(schema) {
|
|
2415
|
+
return isKind(schema, "Object");
|
|
2416
|
+
}
|
|
2417
|
+
function IsTuple(schema) {
|
|
2418
|
+
return isKind(schema, "Tuple");
|
|
2419
|
+
}
|
|
2420
|
+
function IsRecord(schema) {
|
|
2421
|
+
return isKind(schema, "Record");
|
|
2422
|
+
}
|
|
2423
|
+
function IsUnion(schema) {
|
|
2424
|
+
return isKind(schema, "Union");
|
|
2425
|
+
}
|
|
2426
|
+
function IsIntersect(schema) {
|
|
2427
|
+
return isKind(schema, "Intersect");
|
|
2428
|
+
}
|
|
2429
|
+
function IsOptional(schema) {
|
|
2430
|
+
return isKind(schema, "Optional") || hasFlag(schema, "~optional");
|
|
2431
|
+
}
|
|
2432
|
+
function IsReadonly(schema) {
|
|
2433
|
+
return isKind(schema, "Readonly") || hasFlag(schema, "~readonly");
|
|
2434
|
+
}
|
|
2435
|
+
function IsEnum(schema) {
|
|
2436
|
+
return isKind(schema, "Enum");
|
|
2437
|
+
}
|
|
2438
|
+
function IsRef(schema) {
|
|
2439
|
+
return isKind(schema, "Ref");
|
|
2440
|
+
}
|
|
2441
|
+
function IsRecursive(schema) {
|
|
2442
|
+
return isKind(schema, "Recursive");
|
|
2443
|
+
}
|
|
2444
|
+
function IsExclude(schema) {
|
|
2445
|
+
return isKind(schema, "Exclude");
|
|
2446
|
+
}
|
|
2447
|
+
function IsExtract(schema) {
|
|
2448
|
+
return isKind(schema, "Extract");
|
|
2449
|
+
}
|
|
2450
|
+
function IsKeyOf(schema) {
|
|
2451
|
+
return isKind(schema, "KeyOf");
|
|
2452
|
+
}
|
|
2453
|
+
function IsPartial(schema) {
|
|
2454
|
+
return isKind(schema, "Partial");
|
|
2455
|
+
}
|
|
2456
|
+
function IsRequired(schema) {
|
|
2457
|
+
return isKind(schema, "Required");
|
|
2458
|
+
}
|
|
2459
|
+
function IsPick(schema) {
|
|
2460
|
+
return isKind(schema, "Pick");
|
|
2461
|
+
}
|
|
2462
|
+
function IsOmit(schema) {
|
|
2463
|
+
return isKind(schema, "Omit");
|
|
2464
|
+
}
|
|
2465
|
+
function IsNot(schema) {
|
|
2466
|
+
return isKind(schema, "Not");
|
|
2467
|
+
}
|
|
2468
|
+
function IsIfThenElse(schema) {
|
|
2469
|
+
return isKind(schema, "IfThenElse");
|
|
2470
|
+
}
|
|
2471
|
+
function IsUnsafe(schema) {
|
|
2472
|
+
return isKind(schema, "Unsafe");
|
|
2473
|
+
}
|
|
2474
|
+
function IsTemplateLiteral(schema) {
|
|
2475
|
+
return isKind(schema, "TemplateLiteral");
|
|
2476
|
+
}
|
|
2477
|
+
function IsIndex(schema) {
|
|
2478
|
+
return isKind(schema, "Index");
|
|
2479
|
+
}
|
|
2480
|
+
function IsMapped(schema) {
|
|
2481
|
+
return isKind(schema, "Mapped");
|
|
2482
|
+
}
|
|
2483
|
+
function IsConditional(schema) {
|
|
2484
|
+
return isKind(schema, "Conditional");
|
|
2485
|
+
}
|
|
2486
|
+
function IsFunction(schema) {
|
|
2487
|
+
return isKind(schema, "Function");
|
|
2488
|
+
}
|
|
2489
|
+
function IsConstructor(schema) {
|
|
2490
|
+
return isKind(schema, "Constructor");
|
|
2491
|
+
}
|
|
2492
|
+
function IsPromise(schema) {
|
|
2493
|
+
return isKind(schema, "Promise");
|
|
2494
|
+
}
|
|
2495
|
+
function IsIterator(schema) {
|
|
2496
|
+
return isKind(schema, "Iterator");
|
|
2497
|
+
}
|
|
2498
|
+
function IsAsyncIterator(schema) {
|
|
2499
|
+
return isKind(schema, "AsyncIterator");
|
|
2500
|
+
}
|
|
2501
|
+
function IsSymbol(schema) {
|
|
2502
|
+
return isKind(schema, "Symbol");
|
|
2503
|
+
}
|
|
2504
|
+
function IsUint8Array(schema) {
|
|
2505
|
+
return isKind(schema, "Uint8Array");
|
|
2506
|
+
}
|
|
2507
|
+
function IsRegExpInstance(schema) {
|
|
2508
|
+
return isKind(schema, "RegExpInstance");
|
|
2509
|
+
}
|
|
2510
|
+
function IsDecode(schema) {
|
|
2511
|
+
return isKind(schema, "Decode");
|
|
2512
|
+
}
|
|
2513
|
+
function IsEncode(schema) {
|
|
2514
|
+
return isKind(schema, "Encode");
|
|
2515
|
+
}
|
|
2516
|
+
function IsAwaited(schema) {
|
|
2517
|
+
return isKind(schema, "Awaited");
|
|
2518
|
+
}
|
|
2519
|
+
function IsReturnType(schema) {
|
|
2520
|
+
return isKind(schema, "ReturnType");
|
|
2521
|
+
}
|
|
2522
|
+
function IsParameters(schema) {
|
|
2523
|
+
return isKind(schema, "Parameters");
|
|
2524
|
+
}
|
|
2525
|
+
function IsInstanceType(schema) {
|
|
2526
|
+
return isKind(schema, "InstanceType");
|
|
2527
|
+
}
|
|
2528
|
+
function IsConstructorParameters(schema) {
|
|
2529
|
+
return isKind(schema, "ConstructorParameters");
|
|
2530
|
+
}
|
|
2531
|
+
function IsModule(schema) {
|
|
2532
|
+
return isKind(schema, "Module");
|
|
2533
|
+
}
|
|
2534
|
+
function IsRest(schema) {
|
|
2535
|
+
return isKind(schema, "Rest");
|
|
2536
|
+
}
|
|
2537
|
+
function IsCapitalize(schema) {
|
|
2538
|
+
return isKind(schema, "Capitalize");
|
|
2539
|
+
}
|
|
2540
|
+
function IsLowercase(schema) {
|
|
2541
|
+
return isKind(schema, "Lowercase");
|
|
2542
|
+
}
|
|
2543
|
+
function IsUppercase(schema) {
|
|
2544
|
+
return isKind(schema, "Uppercase");
|
|
2545
|
+
}
|
|
2546
|
+
function IsUncapitalize(schema) {
|
|
2547
|
+
return isKind(schema, "Uncapitalize");
|
|
2548
|
+
}
|
|
2549
|
+
function IsInterface(schema) {
|
|
2550
|
+
return IsIntersect(schema);
|
|
2551
|
+
}
|
|
2552
|
+
function IsNonNullable(schema) {
|
|
2553
|
+
return IsExclude(schema);
|
|
2554
|
+
}
|
|
2555
|
+
function IsOptions(schema) {
|
|
2556
|
+
return IsSchema(schema);
|
|
2557
|
+
}
|
|
2558
|
+
function IsReadonlyType(schema) {
|
|
2559
|
+
return IsReadonly(schema);
|
|
2560
|
+
}
|
|
2561
|
+
function IsIdentifier(schema) {
|
|
2562
|
+
return isKind(schema, "Identifier");
|
|
2563
|
+
}
|
|
2564
|
+
function IsParameter(schema) {
|
|
2565
|
+
return isKind(schema, "Parameter");
|
|
2566
|
+
}
|
|
2567
|
+
function IsThis(schema) {
|
|
2568
|
+
return isKind(schema, "This");
|
|
2569
|
+
}
|
|
2570
|
+
function IsCodec2(schema) {
|
|
2571
|
+
return isKind(schema, "Codec");
|
|
2572
|
+
}
|
|
2573
|
+
function IsImmutable2(schema) {
|
|
2574
|
+
return isKind(schema, "Immutable") || hasFlag(schema, "~immutable");
|
|
2575
|
+
}
|
|
2576
|
+
function IsRefine2(schema) {
|
|
2577
|
+
return isKind(schema, "Refine") || hasFlag(schema, "~refine");
|
|
2578
|
+
}
|
|
2579
|
+
function IsBase2(schema) {
|
|
2580
|
+
return isKind(schema, "Base");
|
|
2581
|
+
}
|
|
2582
|
+
function IsCall2(schema) {
|
|
2583
|
+
return isKind(schema, "Call");
|
|
2584
|
+
}
|
|
2585
|
+
function IsCyclic2(schema) {
|
|
2586
|
+
return isKind(schema, "Cyclic");
|
|
2587
|
+
}
|
|
2588
|
+
function IsGeneric2(schema) {
|
|
2589
|
+
return isKind(schema, "Generic");
|
|
2590
|
+
}
|
|
2591
|
+
function IsInfer2(schema) {
|
|
2592
|
+
return isKind(schema, "Infer");
|
|
2593
|
+
}
|
|
2594
|
+
// src/type/kind.ts
|
|
2595
|
+
var StringKind = "String";
|
|
2596
|
+
var NumberKind = "Number";
|
|
2597
|
+
var IntegerKind = "Integer";
|
|
2598
|
+
var BooleanKind = "Boolean";
|
|
2599
|
+
var NullKind = "Null";
|
|
2600
|
+
var LiteralKind = "Literal";
|
|
2601
|
+
var ArrayKind = "Array";
|
|
2602
|
+
var ObjectKind = "Object";
|
|
2603
|
+
var TupleKind = "Tuple";
|
|
2604
|
+
var RecordKind = "Record";
|
|
2605
|
+
var UnionKind = "Union";
|
|
2606
|
+
var IntersectKind = "Intersect";
|
|
2607
|
+
var OptionalKind = "Optional";
|
|
2608
|
+
var ReadonlyKind = "Readonly";
|
|
2609
|
+
var EnumKind = "Enum";
|
|
2610
|
+
var RefKind = "Ref";
|
|
2611
|
+
var PartialKind = "Partial";
|
|
2612
|
+
var RequiredKind = "Required";
|
|
2613
|
+
var PickKind = "Pick";
|
|
2614
|
+
var OmitKind = "Omit";
|
|
2615
|
+
var KeyOfKind = "KeyOf";
|
|
2616
|
+
var ExcludeKind = "Exclude";
|
|
2617
|
+
var ExtractKind = "Extract";
|
|
2618
|
+
var TemplateLiteralKind = "TemplateLiteral";
|
|
2619
|
+
var UnsafeKind = "Unsafe";
|
|
2620
|
+
var VoidKind = "Void";
|
|
2621
|
+
var UndefinedKind = "Undefined";
|
|
2622
|
+
var UnknownKind = "Unknown";
|
|
2623
|
+
var AnyKind = "Any";
|
|
2624
|
+
var NeverKind = "Never";
|
|
2625
|
+
var SelfKind = "Self";
|
|
2626
|
+
var PromiseKind = "Promise";
|
|
2627
|
+
var IteratorKind = "Iterator";
|
|
2628
|
+
var AsyncIteratorKind = "AsyncIterator";
|
|
2629
|
+
var UuidKind = "UUID";
|
|
2630
|
+
var EmailKind = "Email";
|
|
2631
|
+
var HostnameKind = "Hostname";
|
|
2632
|
+
var UriKind = "Uri";
|
|
2633
|
+
var Base64Kind = "Base64";
|
|
2634
|
+
var HexKind = "Hex";
|
|
2635
|
+
var HexColorKind = "HexColor";
|
|
2636
|
+
var IpKind = "Ip";
|
|
2637
|
+
var CreditCardKind = "CreditCard";
|
|
2638
|
+
var DateFormatKind = "DateFormat";
|
|
2639
|
+
var DateTimeKind = "DateTime";
|
|
2640
|
+
var TimeKind = "Time";
|
|
2641
|
+
var DurationKind = "Duration";
|
|
2642
|
+
var JsonKind = "Json";
|
|
2643
|
+
var Uint8ArrayKind = "Uint8Array";
|
|
2644
|
+
var RegExpKind = "RegExp";
|
|
2645
|
+
var FunctionKind = "Function";
|
|
2646
|
+
var ConstructorKind = "Constructor";
|
|
2647
|
+
var SymbolKind = "Symbol";
|
|
2648
|
+
var TemplateElementKind = "TemplateElement";
|
|
2649
|
+
var NotKind = "Not";
|
|
2650
|
+
var IfThenElseKind = "IfThenElse";
|
|
2651
|
+
var IndexKind = "Index";
|
|
2652
|
+
var MappedKind = "Mapped";
|
|
2653
|
+
var ConditionalKind = "Conditional";
|
|
2654
|
+
var RestKind = "Rest";
|
|
2655
|
+
var CapitalizeKind = "Capitalize";
|
|
2656
|
+
var LowercaseKind = "Lowercase";
|
|
2657
|
+
var UppercaseKind = "Uppercase";
|
|
2658
|
+
var UncapitalizeKind = "Uncapitalize";
|
|
2659
|
+
var BigIntKind = "BigInt";
|
|
2660
|
+
var DateKind = "Date";
|
|
2661
|
+
var DecodeKind = "Decode";
|
|
2662
|
+
var EncodeKind = "Encode";
|
|
2663
|
+
var RecursiveKind = "Recursive";
|
|
2664
|
+
var ModuleKind = "Module";
|
|
2665
|
+
var AwaitedKind = "Awaited";
|
|
2666
|
+
var ReturnTypeKind = "ReturnType";
|
|
2667
|
+
var ParametersKind = "Parameters";
|
|
2668
|
+
var InstanceTypeKind = "InstanceType";
|
|
2669
|
+
var ConstructorParametersKind = "ConstructorParameters";
|
|
2670
|
+
// src/type/root-shared.ts
|
|
2671
|
+
function isObjectValue(value) {
|
|
2672
|
+
return typeof value === "object" && value !== null;
|
|
2673
|
+
}
|
|
2674
|
+
function isSchemaLike(value) {
|
|
2675
|
+
return isObjectValue(value) && typeof value["~kind"] === "string";
|
|
2676
|
+
}
|
|
2677
|
+
function getKind(schema) {
|
|
2678
|
+
const kind = schema["~kind"];
|
|
2679
|
+
return typeof kind === "string" ? kind : undefined;
|
|
2680
|
+
}
|
|
2681
|
+
function discardKeys(value, keys) {
|
|
2682
|
+
const result = { ...value };
|
|
2683
|
+
for (const key of keys) {
|
|
2684
|
+
delete result[key];
|
|
2685
|
+
}
|
|
2686
|
+
return result;
|
|
2687
|
+
}
|
|
2688
|
+
function mergeOptions(schema, options = {}) {
|
|
2689
|
+
return { ...schema, ...options };
|
|
2690
|
+
}
|
|
2691
|
+
function isLiteralValue(value) {
|
|
2692
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint";
|
|
2693
|
+
}
|
|
2694
|
+
function getLiteralConst(schema) {
|
|
2695
|
+
if (getKind(schema) !== "Literal") {
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
const value = schema.const;
|
|
2699
|
+
return isLiteralValue(value) ? value : undefined;
|
|
2700
|
+
}
|
|
2701
|
+
function escapePattern(value) {
|
|
2702
|
+
return value.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
|
|
2703
|
+
}
|
|
2704
|
+
function stripAnchors(pattern) {
|
|
2705
|
+
return pattern.startsWith("^") && pattern.endsWith("$") ? pattern.slice(1, -1) : pattern;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
// src/type/root-constants.ts
|
|
2709
|
+
var BigIntPattern = "-?(?:0|[1-9][0-9]*)n";
|
|
2710
|
+
var IntegerPattern = "-?(?:0|[1-9][0-9]*)";
|
|
2711
|
+
var NumberPattern = "-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";
|
|
2712
|
+
var StringPattern = ".*";
|
|
2713
|
+
var NeverPattern = "(?!)";
|
|
2714
|
+
var IntegerKey = `^${IntegerPattern}$`;
|
|
2715
|
+
var NumberKey = `^${NumberPattern}$`;
|
|
2716
|
+
var StringKey = `^${StringPattern}$`;
|
|
2717
|
+
var ResultEqual = "equal";
|
|
2718
|
+
var ResultDisjoint = "disjoint";
|
|
2719
|
+
var ResultLeftInside = "left-inside";
|
|
2720
|
+
var ResultRightInside = "right-inside";
|
|
2721
|
+
function schemaOptions(type, keys) {
|
|
2722
|
+
return discardKeys(type, keys);
|
|
2723
|
+
}
|
|
2724
|
+
function ArrayOptions(type) {
|
|
2725
|
+
return schemaOptions(type, ["~kind", "items"]);
|
|
2726
|
+
}
|
|
2727
|
+
function AsyncIteratorOptions(type) {
|
|
2728
|
+
return schemaOptions(type, ["~kind", "item"]);
|
|
2729
|
+
}
|
|
2730
|
+
function ConstructorOptions(type) {
|
|
2731
|
+
return schemaOptions(type, ["~kind", "parameters", "returns"]);
|
|
2732
|
+
}
|
|
2733
|
+
function FunctionOptions(type) {
|
|
2734
|
+
return schemaOptions(type, ["~kind", "parameters", "returns"]);
|
|
2735
|
+
}
|
|
2736
|
+
function IntersectOptions(type) {
|
|
2737
|
+
return schemaOptions(type, ["~kind", "variants"]);
|
|
2738
|
+
}
|
|
2739
|
+
function IteratorOptions(type) {
|
|
2740
|
+
return schemaOptions(type, ["~kind", "item"]);
|
|
2741
|
+
}
|
|
2742
|
+
function ObjectOptions(type) {
|
|
2743
|
+
return schemaOptions(type, ["~kind", "properties"]);
|
|
2744
|
+
}
|
|
2745
|
+
function PromiseOptions(type) {
|
|
2746
|
+
return schemaOptions(type, ["~kind", "item"]);
|
|
2747
|
+
}
|
|
2748
|
+
function RecordOptions(type) {
|
|
2749
|
+
return schemaOptions(type, ["~kind", "key", "value"]);
|
|
2750
|
+
}
|
|
2751
|
+
function TupleOptions(type) {
|
|
2752
|
+
return schemaOptions(type, ["~kind", "items", "minItems", "maxItems", "additionalItems"]);
|
|
2753
|
+
}
|
|
2754
|
+
function UnionOptions(type) {
|
|
2755
|
+
return schemaOptions(type, ["~kind", "variants"]);
|
|
2756
|
+
}
|
|
2757
|
+
function CyclicOptions(type) {
|
|
2758
|
+
return schemaOptions(type, ["~kind", "$defs", "$ref"]);
|
|
2759
|
+
}
|
|
2760
|
+
function isOptionalSchema(schema) {
|
|
2761
|
+
return getKind(schema) === "Optional" || isObjectValue(schema) && schema["~optional"] === true;
|
|
2762
|
+
}
|
|
2763
|
+
function RequiredArray(properties) {
|
|
2764
|
+
return Object.keys(properties).filter((key) => !isOptionalSchema(properties[key]));
|
|
2765
|
+
}
|
|
2766
|
+
function PropertyKeys(properties) {
|
|
2767
|
+
return Object.keys(properties);
|
|
2768
|
+
}
|
|
2769
|
+
function PropertyValues(properties) {
|
|
2770
|
+
return Object.values(properties);
|
|
2771
|
+
}
|
|
2772
|
+
function OptionalAddAction(type) {
|
|
2773
|
+
return { "~kind": "OptionalAddAction", type };
|
|
2774
|
+
}
|
|
2775
|
+
function OptionalRemoveAction(type) {
|
|
2776
|
+
return { "~kind": "OptionalRemoveAction", type };
|
|
2777
|
+
}
|
|
2778
|
+
function ReadonlyAddAction(type) {
|
|
2779
|
+
return { "~kind": "ReadonlyAddAction", type };
|
|
2780
|
+
}
|
|
2781
|
+
function ReadonlyRemoveAction(type) {
|
|
2782
|
+
return { "~kind": "ReadonlyRemoveAction", type };
|
|
2783
|
+
}
|
|
2784
|
+
function removeModifier(type, key) {
|
|
2785
|
+
return discardKeys(type, [key]);
|
|
2786
|
+
}
|
|
2787
|
+
function OptionalAdd(type) {
|
|
2788
|
+
return { ...type, "~optional": true };
|
|
2789
|
+
}
|
|
2790
|
+
function OptionalRemove(type) {
|
|
2791
|
+
return removeModifier(type, "~optional");
|
|
2792
|
+
}
|
|
2793
|
+
function ReadonlyAdd(type) {
|
|
2794
|
+
return { ...type, "~readonly": true };
|
|
2795
|
+
}
|
|
2796
|
+
function ReadonlyRemove(type) {
|
|
2797
|
+
return removeModifier(type, "~readonly");
|
|
2798
|
+
}
|
|
2799
|
+
function ImmutableAdd(type) {
|
|
2800
|
+
return { ...type, "~immutable": true };
|
|
2801
|
+
}
|
|
2802
|
+
function ImmutableRemove(type) {
|
|
2803
|
+
return removeModifier(type, "~immutable");
|
|
2804
|
+
}
|
|
2805
|
+
function RefineAdd(type, refinement) {
|
|
2806
|
+
const existing = isObjectValue(type) && Array.isArray(type["~refine"]) ? type["~refine"] : [];
|
|
2807
|
+
return { ...type, "~refine": [...existing, refinement] };
|
|
2808
|
+
}
|
|
2809
|
+
// src/type/root-deferred.ts
|
|
2810
|
+
function Deferred(action, parameters, options = {}) {
|
|
2811
|
+
return { "~kind": "Deferred", action, parameters, options };
|
|
2812
|
+
}
|
|
2813
|
+
var AwaitedDeferred = (type, options = {}) => Deferred("Awaited", [type], options);
|
|
2814
|
+
var CapitalizeDeferred = (type, options = {}) => Deferred("Capitalize", [type], options);
|
|
2815
|
+
var ConditionalDeferred = (left, right, trueType, falseType, options = {}) => Deferred("Conditional", [left, right, trueType, falseType], options);
|
|
2816
|
+
var ConstructorParametersDeferred = (type, options = {}) => Deferred("ConstructorParameters", [type], options);
|
|
2817
|
+
var EvaluateDeferred = (type, options = {}) => Deferred("Evaluate", [type], options);
|
|
2818
|
+
var ExcludeDeferred = (left, right, options = {}) => Deferred("Exclude", [left, right], options);
|
|
2819
|
+
var ExtractDeferred = (left, right, options = {}) => Deferred("Extract", [left, right], options);
|
|
2820
|
+
var IndexDeferred = (type, indexer, options = {}) => Deferred("Index", [type, indexer], options);
|
|
2821
|
+
var InstanceTypeDeferred = (type, options = {}) => Deferred("InstanceType", [type], options);
|
|
2822
|
+
var InterfaceDeferred = (heritage, properties, options = {}) => Deferred("Interface", [heritage, properties], options);
|
|
2823
|
+
var KeyOfDeferred = (type, options = {}) => Deferred("KeyOf", [type], options);
|
|
2824
|
+
var LowercaseDeferred = (type, options = {}) => Deferred("Lowercase", [type], options);
|
|
2825
|
+
var MappedDeferred = (identifier, key, asType, property, options = {}) => Deferred("Mapped", [identifier, key, asType, property], options);
|
|
2826
|
+
var ModuleDeferred = (definitions, options = {}) => Deferred("Module", [definitions], options);
|
|
2827
|
+
var NonNullableDeferred = (type, options = {}) => Deferred("NonNullable", [type], options);
|
|
2828
|
+
var OmitDeferred = (type, indexer, options = {}) => Deferred("Omit", [type, indexer], options);
|
|
2829
|
+
var OptionsDeferred = (type, options) => Deferred("Options", [type, options], {});
|
|
2830
|
+
var ParametersDeferred = (type, options = {}) => Deferred("Parameters", [type], options);
|
|
2831
|
+
var PartialDeferred = (type, options = {}) => Deferred("Partial", [type], options);
|
|
2832
|
+
var PickDeferred = (type, indexer, options = {}) => Deferred("Pick", [type, indexer], options);
|
|
2833
|
+
var ReadonlyTypeDeferred = (type, options = {}) => Deferred("ReadonlyType", [type], options);
|
|
2834
|
+
var RecordDeferred = (key, value, options = {}) => Deferred("Record", [key, value], options);
|
|
2835
|
+
var RequiredDeferred = (type, options = {}) => Deferred("Required", [type], options);
|
|
2836
|
+
var ReturnTypeDeferred = (type, options = {}) => Deferred("ReturnType", [type], options);
|
|
2837
|
+
var TemplateLiteralDeferred = (types, options = {}) => Deferred("TemplateLiteral", [types], options);
|
|
2838
|
+
var UncapitalizeDeferred = (type, options = {}) => Deferred("Uncapitalize", [type], options);
|
|
2839
|
+
var UppercaseDeferred = (type, options = {}) => Deferred("Uppercase", [type], options);
|
|
2840
|
+
function IsDeferred(value) {
|
|
2841
|
+
return isObjectValue(value) && value["~kind"] === "Deferred" && typeof value.action === "string" && Array.isArray(value.parameters) && isObjectValue(value.options);
|
|
2842
|
+
}
|
|
2843
|
+
function IsInterfaceDeferred(value) {
|
|
2844
|
+
if (!IsDeferred(value) || value.action !== "Interface") {
|
|
2845
|
+
return false;
|
|
2846
|
+
}
|
|
2847
|
+
const [heritage, properties] = value.parameters;
|
|
2848
|
+
return Array.isArray(heritage) && heritage.every((entry) => isSchemaLike(entry)) && isObjectValue(properties) && Object.values(properties).every((entry) => isSchemaLike(entry));
|
|
2849
|
+
}
|
|
2850
|
+
// src/type/root-guards.ts
|
|
2851
|
+
function hasActionKind(value, kind) {
|
|
2852
|
+
return isObjectValue(value) && value["~kind"] === kind && isSchemaLike(value.type);
|
|
2853
|
+
}
|
|
2854
|
+
function IsLiteralValue(value) {
|
|
2855
|
+
return isLiteralValue(value);
|
|
2856
|
+
}
|
|
2857
|
+
function IsLiteralBigInt(value) {
|
|
2858
|
+
return isObjectValue(value) && value["~kind"] === "Literal" && typeof value.const === "bigint";
|
|
2859
|
+
}
|
|
2860
|
+
function IsLiteralBoolean(value) {
|
|
2861
|
+
return isObjectValue(value) && value["~kind"] === "Literal" && typeof value.const === "boolean";
|
|
2862
|
+
}
|
|
2863
|
+
function IsLiteralNumber(value) {
|
|
2864
|
+
return isObjectValue(value) && value["~kind"] === "Literal" && typeof value.const === "number";
|
|
2865
|
+
}
|
|
2866
|
+
function IsLiteralString(value) {
|
|
2867
|
+
return isObjectValue(value) && value["~kind"] === "Literal" && typeof value.const === "string";
|
|
2868
|
+
}
|
|
2869
|
+
function isFiniteTemplateType(type) {
|
|
2870
|
+
if (getKind(type) === "Literal") {
|
|
2871
|
+
return true;
|
|
2872
|
+
}
|
|
2873
|
+
if (getKind(type) === "Union") {
|
|
2874
|
+
const variants = type.variants;
|
|
2875
|
+
return variants.length > 0 && variants.every((variant) => isFiniteTemplateType(variant));
|
|
2876
|
+
}
|
|
2877
|
+
return false;
|
|
2878
|
+
}
|
|
2879
|
+
function IsTemplateLiteralFinite(types) {
|
|
2880
|
+
return types.length > 0 && types.every((type) => isFiniteTemplateType(type));
|
|
2881
|
+
}
|
|
2882
|
+
function IsTemplateLiteralPattern(pattern) {
|
|
2883
|
+
const inner = stripAnchors(pattern);
|
|
2884
|
+
return pattern === StringPattern || pattern === NumberPattern || pattern === IntegerPattern || pattern === BigIntPattern || pattern === NeverPattern || pattern.startsWith("^") && pattern.endsWith("$") || inner.includes("|");
|
|
2885
|
+
}
|
|
2886
|
+
function IsTypeScriptEnumLike(value) {
|
|
2887
|
+
if (!isObjectValue(value) || Array.isArray(value)) {
|
|
2888
|
+
return false;
|
|
2889
|
+
}
|
|
2890
|
+
return Object.keys(value).every((key) => {
|
|
2891
|
+
const entry = value[key];
|
|
2892
|
+
return typeof entry === "string" || typeof entry === "number";
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
function IsOptionalAddAction(value) {
|
|
2896
|
+
return hasActionKind(value, "OptionalAddAction");
|
|
2897
|
+
}
|
|
2898
|
+
function IsOptionalRemoveAction(value) {
|
|
2899
|
+
return hasActionKind(value, "OptionalRemoveAction");
|
|
2900
|
+
}
|
|
2901
|
+
function IsReadonlyAddAction(value) {
|
|
2902
|
+
return hasActionKind(value, "ReadonlyAddAction");
|
|
2903
|
+
}
|
|
2904
|
+
function IsReadonlyRemoveAction(value) {
|
|
2905
|
+
return hasActionKind(value, "ReadonlyRemoveAction");
|
|
2906
|
+
}
|
|
2907
|
+
// src/type/root-helpers.ts
|
|
2908
|
+
class InvalidLiteralValue extends Error {
|
|
2909
|
+
value;
|
|
2910
|
+
constructor(value) {
|
|
2911
|
+
super("Invalid Literal value");
|
|
2912
|
+
this.value = value;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
function LiteralTypeName(value) {
|
|
2916
|
+
if (typeof value === "bigint")
|
|
2917
|
+
return "bigint";
|
|
2918
|
+
if (typeof value === "boolean")
|
|
2919
|
+
return "boolean";
|
|
2920
|
+
if (typeof value === "number")
|
|
2921
|
+
return "number";
|
|
2922
|
+
if (typeof value === "string")
|
|
2923
|
+
return "string";
|
|
2924
|
+
throw new InvalidLiteralValue(value);
|
|
2925
|
+
}
|
|
2926
|
+
function literalSchema(value) {
|
|
2927
|
+
return { "~kind": "Literal", const: value };
|
|
2928
|
+
}
|
|
2929
|
+
function ConvertToIntegerKey(value) {
|
|
2930
|
+
const normal = `${value}`;
|
|
2931
|
+
return /^(?:0|[1-9][0-9]*)$/.test(normal) ? globalThis.Number.parseInt(normal, 10) : value;
|
|
2932
|
+
}
|
|
2933
|
+
function KeysToIndexer(keys) {
|
|
2934
|
+
const literals = keys.filter((key) => isLiteralValue(key)).map((key) => literalSchema(key));
|
|
2935
|
+
return EvaluateUnionFast(literals);
|
|
2936
|
+
}
|
|
2937
|
+
function EnumValuesToVariants(values) {
|
|
2938
|
+
return values.flatMap((value) => {
|
|
2939
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
2940
|
+
return [literalSchema(value)];
|
|
2941
|
+
}
|
|
2942
|
+
return [];
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
function EnumValuesToUnion(values) {
|
|
2946
|
+
return EvaluateUnionFast(EnumValuesToVariants(values));
|
|
2947
|
+
}
|
|
2948
|
+
function EnumToUnion(type) {
|
|
2949
|
+
const schema = type;
|
|
2950
|
+
const values = Array.isArray(schema.values) ? schema.values : Array.isArray(schema.enum) ? schema.enum : [];
|
|
2951
|
+
return EnumValuesToUnion(values);
|
|
2952
|
+
}
|
|
2953
|
+
function TypeScriptEnumToEnumValues(type) {
|
|
2954
|
+
return Object.keys(type).filter((key) => globalThis.Number.isNaN(globalThis.Number(key))).map((key) => type[key]);
|
|
2955
|
+
}
|
|
2956
|
+
function Compare(left, right) {
|
|
2957
|
+
const leftExtendsRight = Extends(left, right);
|
|
2958
|
+
const rightExtendsLeft = Extends(right, left);
|
|
2959
|
+
return ExtendsResult.IsExtendsTrueLike(leftExtendsRight) && ExtendsResult.IsExtendsTrueLike(rightExtendsLeft) ? ResultEqual : ExtendsResult.IsExtendsTrueLike(leftExtendsRight) && ExtendsResult.IsExtendsFalse(rightExtendsLeft) ? ResultLeftInside : ExtendsResult.IsExtendsFalse(leftExtendsRight) && ExtendsResult.IsExtendsTrueLike(rightExtendsLeft) ? ResultRightInside : ResultDisjoint;
|
|
2960
|
+
}
|
|
2961
|
+
function Flatten(types) {
|
|
2962
|
+
return types.flatMap((type) => getKind(type) === "Union" ? Flatten(type.variants) : [type]);
|
|
2963
|
+
}
|
|
2964
|
+
function Narrow(left, right) {
|
|
2965
|
+
const result = Compare(left, right);
|
|
2966
|
+
return result === ResultLeftInside ? left : result === ResultRightInside || result === ResultEqual ? right : Never();
|
|
2967
|
+
}
|
|
2968
|
+
function broadenFilter(type, types) {
|
|
2969
|
+
return types.filter((candidate) => Compare(type, candidate) !== ResultRightInside);
|
|
2970
|
+
}
|
|
2971
|
+
function isBroadestType(type, types) {
|
|
2972
|
+
return !types.some((candidate) => {
|
|
2973
|
+
const result = Compare(type, candidate);
|
|
2974
|
+
return result === ResultLeftInside || result === ResultEqual;
|
|
2975
|
+
});
|
|
2976
|
+
}
|
|
2977
|
+
function broadenType(type, types) {
|
|
2978
|
+
const evaluated = EvaluateType(type);
|
|
2979
|
+
return getKind(evaluated) === "Any" ? [evaluated] : isBroadestType(evaluated, types) ? [...broadenFilter(evaluated, types), evaluated] : [...types];
|
|
2980
|
+
}
|
|
2981
|
+
function Broaden(types) {
|
|
2982
|
+
const broadened = types.reduce((result, type) => {
|
|
2983
|
+
if (getKind(type) === "Object") {
|
|
2984
|
+
return [...result, type];
|
|
2985
|
+
}
|
|
2986
|
+
if (getKind(type) === "Never") {
|
|
2987
|
+
return result;
|
|
2988
|
+
}
|
|
2989
|
+
return broadenType(type, result);
|
|
2990
|
+
}, []);
|
|
2991
|
+
const flattened = Flatten(broadened);
|
|
2992
|
+
return flattened.length === 0 ? Never() : flattened.length === 1 ? flattened[0] : Union(flattened);
|
|
2993
|
+
}
|
|
2994
|
+
function isObjectLike(type) {
|
|
2995
|
+
const kind = getKind(type);
|
|
2996
|
+
return kind === "Object" || kind === "Tuple";
|
|
2997
|
+
}
|
|
2998
|
+
function distributeOperation(left, right) {
|
|
2999
|
+
const evaluatedLeft = EvaluateType(left);
|
|
3000
|
+
const evaluatedRight = EvaluateType(right);
|
|
3001
|
+
if (getKind(evaluatedLeft) === "Union" || getKind(evaluatedRight) === "Union") {
|
|
3002
|
+
return EvaluateIntersect([evaluatedLeft, evaluatedRight]);
|
|
3003
|
+
}
|
|
3004
|
+
if (isObjectLike(evaluatedLeft) && isObjectLike(evaluatedRight)) {
|
|
3005
|
+
return Composite([CollapseToObject(evaluatedLeft), CollapseToObject(evaluatedRight)]);
|
|
3006
|
+
}
|
|
3007
|
+
if (isObjectLike(evaluatedLeft))
|
|
3008
|
+
return evaluatedLeft;
|
|
3009
|
+
if (isObjectLike(evaluatedRight))
|
|
3010
|
+
return evaluatedRight;
|
|
3011
|
+
return Narrow(evaluatedLeft, evaluatedRight);
|
|
3012
|
+
}
|
|
3013
|
+
function distributeType(type, types, result = []) {
|
|
3014
|
+
const [left, ...right] = types;
|
|
3015
|
+
return left !== undefined ? distributeType(type, right, [...result, distributeOperation(type, left)]) : result.length === 0 ? [type] : result;
|
|
3016
|
+
}
|
|
3017
|
+
function distributeUnion(types, distribution, result = []) {
|
|
3018
|
+
const [left, ...right] = types;
|
|
3019
|
+
return left !== undefined ? distributeUnion(right, distribution, [...result, ...Distribute([left], distribution)]) : result;
|
|
3020
|
+
}
|
|
3021
|
+
function Distribute(types, result = []) {
|
|
3022
|
+
const [left, ...right] = types;
|
|
3023
|
+
if (left === undefined) {
|
|
3024
|
+
return [...result];
|
|
3025
|
+
}
|
|
3026
|
+
return getKind(left) === "Union" ? Distribute(right, distributeUnion(left.variants, result)) : Distribute(right, distributeType(left, result));
|
|
3027
|
+
}
|
|
3028
|
+
function EvaluateIntersect(types) {
|
|
3029
|
+
return Broaden(Distribute(types));
|
|
3030
|
+
}
|
|
3031
|
+
function EvaluateUnion(types) {
|
|
3032
|
+
return Broaden(types);
|
|
3033
|
+
}
|
|
3034
|
+
function EvaluateType(type) {
|
|
3035
|
+
return getKind(type) === "Intersect" ? EvaluateIntersect(type.variants) : getKind(type) === "Union" ? EvaluateUnion(type.variants) : type;
|
|
3036
|
+
}
|
|
3037
|
+
function EvaluateUnionFast(types) {
|
|
3038
|
+
return types.length === 0 ? Never() : types.length === 1 ? types[0] : Union([...types]);
|
|
3039
|
+
}
|
|
3040
|
+
function CollapseToObject(type) {
|
|
3041
|
+
if (getKind(type) === "Object") {
|
|
3042
|
+
return type;
|
|
3043
|
+
}
|
|
3044
|
+
if (getKind(type) === "Intersect") {
|
|
3045
|
+
const variants = type.variants.filter((variant) => getKind(variant) === "Object");
|
|
3046
|
+
return variants.length > 0 ? Evaluate(Intersect(variants)) : Object2({});
|
|
3047
|
+
}
|
|
3048
|
+
return Object2({});
|
|
3049
|
+
}
|
|
3050
|
+
function _Function_(parameters, returnType, options = {}) {
|
|
3051
|
+
return { "~kind": "Function", parameters, returns: returnType, ...options };
|
|
3052
|
+
}
|
|
3053
|
+
function _Object_(properties, options = {}) {
|
|
3054
|
+
const required = RequiredArray(properties);
|
|
3055
|
+
const optional = Object.keys(properties).filter((key) => !required.includes(key));
|
|
3056
|
+
return Object2(properties, {
|
|
3057
|
+
...options,
|
|
3058
|
+
...required.length > 0 ? { required } : {},
|
|
3059
|
+
...optional.length > 0 ? { optional } : {}
|
|
3060
|
+
});
|
|
3061
|
+
}
|
|
3062
|
+
function CallConstruct(target, arguments_) {
|
|
3063
|
+
return { "~kind": "Call", target, arguments: arguments_ };
|
|
3064
|
+
}
|
|
3065
|
+
function KeyOfAction(type) {
|
|
3066
|
+
switch (getKind(type)) {
|
|
3067
|
+
case "Any":
|
|
3068
|
+
return Union([Number2(), String2(), Symbol2()]);
|
|
3069
|
+
case "Array":
|
|
3070
|
+
return Number2();
|
|
3071
|
+
case "Object": {
|
|
3072
|
+
const keys = Object.keys(type.properties).map((key) => ConvertToIntegerKey(key));
|
|
3073
|
+
return EvaluateUnionFast(keys.map((key) => literalSchema(key)));
|
|
3074
|
+
}
|
|
3075
|
+
case "Record":
|
|
3076
|
+
return type.key;
|
|
3077
|
+
case "Tuple": {
|
|
3078
|
+
const variants = type.items.map((_, index) => literalSchema(index));
|
|
3079
|
+
return EvaluateUnionFast(variants);
|
|
3080
|
+
}
|
|
3081
|
+
default:
|
|
3082
|
+
return Never();
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
// src/type/root-template.ts
|
|
3086
|
+
function parseTemplateExpression(expression) {
|
|
3087
|
+
const trimmed = expression.trim();
|
|
3088
|
+
if (trimmed.includes("|")) {
|
|
3089
|
+
return Union(trimmed.split("|").map((entry) => parseTemplateExpression(entry)));
|
|
3090
|
+
}
|
|
3091
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
3092
|
+
return Literal(trimmed.slice(1, -1));
|
|
3093
|
+
}
|
|
3094
|
+
if (trimmed === "string")
|
|
3095
|
+
return String2();
|
|
3096
|
+
if (trimmed === "number")
|
|
3097
|
+
return Number2();
|
|
3098
|
+
if (trimmed === "integer")
|
|
3099
|
+
return Integer();
|
|
3100
|
+
if (trimmed === "bigint")
|
|
3101
|
+
return BigInt();
|
|
3102
|
+
if (trimmed === "true")
|
|
3103
|
+
return Literal(true);
|
|
3104
|
+
if (trimmed === "false")
|
|
3105
|
+
return Literal(false);
|
|
3106
|
+
if (/^-?\d+$/.test(trimmed))
|
|
3107
|
+
return Literal(globalThis.Number.parseInt(trimmed, 10));
|
|
3108
|
+
if (/^-?\d+\.\d+$/.test(trimmed))
|
|
3109
|
+
return Literal(globalThis.Number.parseFloat(trimmed));
|
|
3110
|
+
return Ref(trimmed);
|
|
3111
|
+
}
|
|
3112
|
+
function TemplateLiteralCreate(pattern) {
|
|
3113
|
+
return TemplateLiteral([pattern]);
|
|
3114
|
+
}
|
|
3115
|
+
function ParseTemplateIntoTypes(template) {
|
|
3116
|
+
const result = [];
|
|
3117
|
+
let index = 0;
|
|
3118
|
+
let current = "";
|
|
3119
|
+
while (index < template.length) {
|
|
3120
|
+
const character = template[index];
|
|
3121
|
+
if (character === "$" && template[index + 1] === "{") {
|
|
3122
|
+
if (current.length > 0) {
|
|
3123
|
+
result.push(Literal(current));
|
|
3124
|
+
current = "";
|
|
3125
|
+
}
|
|
3126
|
+
let depth = 1;
|
|
3127
|
+
let cursor = index + 2;
|
|
3128
|
+
while (cursor < template.length && depth > 0) {
|
|
3129
|
+
const inner = template[cursor];
|
|
3130
|
+
if (inner === "{")
|
|
3131
|
+
depth += 1;
|
|
3132
|
+
if (inner === "}")
|
|
3133
|
+
depth -= 1;
|
|
3134
|
+
cursor += 1;
|
|
3135
|
+
}
|
|
3136
|
+
result.push(parseTemplateExpression(template.slice(index + 2, cursor - 1)));
|
|
3137
|
+
index = cursor;
|
|
3138
|
+
continue;
|
|
3139
|
+
}
|
|
3140
|
+
current += character;
|
|
3141
|
+
index += 1;
|
|
3142
|
+
}
|
|
3143
|
+
if (current.length > 0 || result.length === 0) {
|
|
3144
|
+
result.push(Literal(current));
|
|
3145
|
+
}
|
|
3146
|
+
return result;
|
|
3147
|
+
}
|
|
3148
|
+
function encodeUnionPattern(variants) {
|
|
3149
|
+
return `(${variants.map((variant) => encodeTypePattern(variant)).join("|")})`;
|
|
3150
|
+
}
|
|
3151
|
+
function encodeTypePattern(type) {
|
|
3152
|
+
const literal = getLiteralConst(type);
|
|
3153
|
+
if (literal !== undefined) {
|
|
3154
|
+
return escapePattern(globalThis.String(literal));
|
|
3155
|
+
}
|
|
3156
|
+
switch (getKind(type)) {
|
|
3157
|
+
case "String":
|
|
3158
|
+
return StringPattern;
|
|
3159
|
+
case "Number":
|
|
3160
|
+
return NumberPattern;
|
|
3161
|
+
case "Integer":
|
|
3162
|
+
return IntegerPattern;
|
|
3163
|
+
case "BigInt":
|
|
3164
|
+
return BigIntPattern;
|
|
3165
|
+
case "Boolean":
|
|
3166
|
+
return "(false|true)";
|
|
3167
|
+
case "Enum":
|
|
3168
|
+
return encodeUnionPattern(type.values.map((value) => Literal(value)));
|
|
3169
|
+
case "Union":
|
|
3170
|
+
return encodeUnionPattern(type.variants);
|
|
3171
|
+
case "TemplateLiteral": {
|
|
3172
|
+
const patterns = type.patterns.map((pattern) => stripAnchors(pattern));
|
|
3173
|
+
return patterns.length === 1 ? patterns[0] : `(${patterns.join("|")})`;
|
|
3174
|
+
}
|
|
3175
|
+
default:
|
|
3176
|
+
return NeverPattern;
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
function TemplateLiteralEncode(types) {
|
|
3180
|
+
return TemplateLiteralCreate(`^${types.map((type) => encodeTypePattern(type)).join("")}$`);
|
|
3181
|
+
}
|
|
3182
|
+
function decodeLiteralPattern(pattern) {
|
|
3183
|
+
if (pattern.length === 0 || /[()[\]{}+*?]/.test(pattern) || pattern.includes("|")) {
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
return pattern.replace(/\\(.)/g, "$1");
|
|
3187
|
+
}
|
|
3188
|
+
function decodeAlternationPattern(pattern) {
|
|
3189
|
+
const match = /^\(([^()]+)\)$/.exec(pattern);
|
|
3190
|
+
if (!match) {
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
const parts = match[1].split("|").map((entry) => decodeLiteralPattern(entry));
|
|
3194
|
+
return parts.every((entry) => entry !== undefined) ? parts : undefined;
|
|
3195
|
+
}
|
|
3196
|
+
function TemplateLiteralDecodeUnsafe(pattern) {
|
|
3197
|
+
const inner = stripAnchors(pattern);
|
|
3198
|
+
if (inner === StringPattern)
|
|
3199
|
+
return String2();
|
|
3200
|
+
if (inner === NumberPattern)
|
|
3201
|
+
return Number2();
|
|
3202
|
+
if (inner === IntegerPattern)
|
|
3203
|
+
return Integer();
|
|
3204
|
+
if (inner === BigIntPattern)
|
|
3205
|
+
return BigInt();
|
|
3206
|
+
if (inner === "(false|true)")
|
|
3207
|
+
return Union([Literal("false"), Literal("true")]);
|
|
3208
|
+
const alternates = decodeAlternationPattern(inner);
|
|
3209
|
+
if (alternates) {
|
|
3210
|
+
return Union(alternates.map((value) => Literal(value)));
|
|
3211
|
+
}
|
|
3212
|
+
const literal = decodeLiteralPattern(inner);
|
|
3213
|
+
if (literal !== undefined) {
|
|
3214
|
+
return Literal(literal);
|
|
3215
|
+
}
|
|
3216
|
+
return TemplateLiteralCreate(pattern);
|
|
3217
|
+
}
|
|
3218
|
+
function TemplateLiteralDecode(pattern) {
|
|
3219
|
+
const decoded = TemplateLiteralDecodeUnsafe(pattern);
|
|
3220
|
+
return getKind(decoded) === "TemplateLiteral" ? String2() : decoded;
|
|
3221
|
+
}
|
|
3222
|
+
function ParsePatternIntoTypes(pattern) {
|
|
3223
|
+
const decoded = TemplateLiteralDecodeUnsafe(pattern);
|
|
3224
|
+
return getKind(decoded) === "Union" ? decoded.variants : [decoded];
|
|
3225
|
+
}
|
|
3226
|
+
function TemplateLiteralFromTypes(types) {
|
|
3227
|
+
return TemplateLiteralEncode(types);
|
|
3228
|
+
}
|
|
3229
|
+
function TemplateLiteralFromString(template) {
|
|
3230
|
+
return TemplateLiteralFromTypes(ParseTemplateIntoTypes(template));
|
|
3231
|
+
}
|
|
3232
|
+
function RecordConstruct(key, value, options = {}) {
|
|
3233
|
+
return Record(key, value, options);
|
|
3234
|
+
}
|
|
3235
|
+
function RecordFromPattern(keyPattern, value) {
|
|
3236
|
+
return RecordConstruct(TemplateLiteralDecode(keyPattern), value);
|
|
3237
|
+
}
|
|
3238
|
+
function RecordPattern(type) {
|
|
3239
|
+
const key = type.key;
|
|
3240
|
+
const literal = getLiteralConst(key);
|
|
3241
|
+
if (literal !== undefined) {
|
|
3242
|
+
return `^${escapePattern(globalThis.String(literal))}$`;
|
|
3243
|
+
}
|
|
3244
|
+
switch (getKind(key)) {
|
|
3245
|
+
case "String":
|
|
3246
|
+
return StringKey;
|
|
3247
|
+
case "Number":
|
|
3248
|
+
return NumberKey;
|
|
3249
|
+
case "Integer":
|
|
3250
|
+
return IntegerKey;
|
|
3251
|
+
case "Enum":
|
|
3252
|
+
return `^(${key.values.map((value) => escapePattern(value)).join("|")})$`;
|
|
3253
|
+
case "TemplateLiteral": {
|
|
3254
|
+
const patterns = key.patterns;
|
|
3255
|
+
return patterns.length === 1 ? patterns[0] : `^(${patterns.map((pattern) => stripAnchors(pattern)).join("|")})$`;
|
|
3256
|
+
}
|
|
3257
|
+
default:
|
|
3258
|
+
return StringKey;
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
function RecordKey(type) {
|
|
3262
|
+
return type.key;
|
|
3263
|
+
}
|
|
3264
|
+
function RecordValue(type) {
|
|
3265
|
+
return type.value;
|
|
3266
|
+
}
|
|
3267
|
+
// src/type/root-cyclic.ts
|
|
3268
|
+
function getRefName(schema) {
|
|
3269
|
+
const value = schema;
|
|
3270
|
+
return typeof value.name === "string" ? value.name : typeof value.$ref === "string" ? value.$ref : undefined;
|
|
3271
|
+
}
|
|
3272
|
+
function resolve(defs, ref) {
|
|
3273
|
+
const target = defs[ref];
|
|
3274
|
+
if (target === undefined) {
|
|
3275
|
+
return Never();
|
|
3276
|
+
}
|
|
3277
|
+
const nextRef = getKind(target) === "Ref" ? getRefName(target) : undefined;
|
|
3278
|
+
return typeof nextRef === "string" ? resolve(defs, nextRef) : target;
|
|
3279
|
+
}
|
|
3280
|
+
function CyclicTarget(defs, ref) {
|
|
3281
|
+
return resolve(defs, ref);
|
|
3282
|
+
}
|
|
3283
|
+
function fromProperties(properties, mapper, seed) {
|
|
3284
|
+
return Object.values(properties).reduce((result, type) => mapper(type, result), seed);
|
|
3285
|
+
}
|
|
3286
|
+
function dependencyWalk(context, type, result) {
|
|
3287
|
+
const ref = getKind(type) === "Ref" ? getRefName(type) : undefined;
|
|
3288
|
+
if (typeof ref === "string") {
|
|
3289
|
+
if (result.includes(ref) || context[ref] === undefined) {
|
|
3290
|
+
return result;
|
|
3291
|
+
}
|
|
3292
|
+
return dependencyWalk(context, context[ref], [...result, ref]);
|
|
3293
|
+
}
|
|
3294
|
+
switch (getKind(type)) {
|
|
3295
|
+
case "Array":
|
|
3296
|
+
case "Promise":
|
|
3297
|
+
case "Iterator":
|
|
3298
|
+
case "AsyncIterator":
|
|
3299
|
+
case "Rest":
|
|
3300
|
+
return dependencyWalk(context, type.item, result);
|
|
3301
|
+
case "Function":
|
|
3302
|
+
case "Constructor": {
|
|
3303
|
+
const schema = type;
|
|
3304
|
+
return schema.parameters.reduce((next, entry) => dependencyWalk(context, entry, next), dependencyWalk(context, schema.returns, result));
|
|
3305
|
+
}
|
|
3306
|
+
case "Object":
|
|
3307
|
+
return fromProperties(type.properties, (entry, next) => dependencyWalk(context, entry, next), result);
|
|
3308
|
+
case "Union":
|
|
3309
|
+
case "Intersect":
|
|
3310
|
+
return type.variants.reduce((next, entry) => dependencyWalk(context, entry, next), result);
|
|
3311
|
+
case "Tuple":
|
|
3312
|
+
return type.items.reduce((next, entry) => dependencyWalk(context, entry, next), result);
|
|
3313
|
+
case "Record":
|
|
3314
|
+
return dependencyWalk(context, RecordValue(type), result);
|
|
3315
|
+
default:
|
|
3316
|
+
return result;
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
function CyclicDependencies(context, key, type) {
|
|
3320
|
+
return dependencyWalk(context, type, [key]);
|
|
3321
|
+
}
|
|
3322
|
+
function checkWalk(stack, context, type) {
|
|
3323
|
+
const ref = getKind(type) === "Ref" ? getRefName(type) : undefined;
|
|
3324
|
+
if (typeof ref === "string") {
|
|
3325
|
+
return stack.includes(ref) ? true : context[ref] !== undefined && checkWalk([...stack, ref], context, context[ref]);
|
|
3326
|
+
}
|
|
3327
|
+
switch (getKind(type)) {
|
|
3328
|
+
case "Array":
|
|
3329
|
+
case "Promise":
|
|
3330
|
+
case "Iterator":
|
|
3331
|
+
case "AsyncIterator":
|
|
3332
|
+
case "Rest":
|
|
3333
|
+
return checkWalk(stack, context, type.item);
|
|
3334
|
+
case "Function":
|
|
3335
|
+
case "Constructor": {
|
|
3336
|
+
const schema = type;
|
|
3337
|
+
return schema.parameters.some((entry) => checkWalk(stack, context, entry)) || checkWalk(stack, context, schema.returns);
|
|
3338
|
+
}
|
|
3339
|
+
case "Object":
|
|
3340
|
+
return Object.values(type.properties).some((entry) => checkWalk(stack, context, entry));
|
|
3341
|
+
case "Union":
|
|
3342
|
+
case "Intersect":
|
|
3343
|
+
return type.variants.some((entry) => checkWalk(stack, context, entry));
|
|
3344
|
+
case "Tuple":
|
|
3345
|
+
return type.items.some((entry) => checkWalk(stack, context, entry));
|
|
3346
|
+
case "Record":
|
|
3347
|
+
return checkWalk(stack, context, RecordValue(type));
|
|
3348
|
+
default:
|
|
3349
|
+
return false;
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
function CyclicCheck(stack, context, type) {
|
|
3353
|
+
return checkWalk(stack, context, type);
|
|
3354
|
+
}
|
|
3355
|
+
function CyclicCandidates(context) {
|
|
3356
|
+
return Object.keys(context).filter((key) => CyclicCheck([key], context, context[key]));
|
|
3357
|
+
}
|
|
3358
|
+
function extendsWalk(type) {
|
|
3359
|
+
const ref = getKind(type) === "Ref" ? getRefName(type) : undefined;
|
|
3360
|
+
if (typeof ref === "string") {
|
|
3361
|
+
return Any();
|
|
3362
|
+
}
|
|
3363
|
+
switch (getKind(type)) {
|
|
3364
|
+
case "Array":
|
|
3365
|
+
return { ...type, items: extendsWalk(type.items) };
|
|
3366
|
+
case "Promise":
|
|
3367
|
+
case "Iterator":
|
|
3368
|
+
case "AsyncIterator":
|
|
3369
|
+
case "Rest":
|
|
3370
|
+
return { ...type, item: extendsWalk(type.item) };
|
|
3371
|
+
case "Function":
|
|
3372
|
+
case "Constructor": {
|
|
3373
|
+
const schema = type;
|
|
3374
|
+
return _Function_(schema.parameters.map((entry) => extendsWalk(entry)), extendsWalk(schema.returns));
|
|
3375
|
+
}
|
|
3376
|
+
case "Object": {
|
|
3377
|
+
const properties = Object.fromEntries(Object.entries(type.properties).map(([key, value]) => [key, extendsWalk(value)]));
|
|
3378
|
+
return _Object_(properties);
|
|
3379
|
+
}
|
|
3380
|
+
case "Union":
|
|
3381
|
+
case "Intersect":
|
|
3382
|
+
return { ...type, variants: type.variants.map((entry) => extendsWalk(entry)) };
|
|
3383
|
+
case "Tuple":
|
|
3384
|
+
return { ...type, items: type.items.map((entry) => extendsWalk(entry)) };
|
|
3385
|
+
case "Record":
|
|
3386
|
+
return { ...type, key: RecordKey(type), value: extendsWalk(RecordValue(type)) };
|
|
3387
|
+
default:
|
|
3388
|
+
return type;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
function CyclicExtends(type) {
|
|
3392
|
+
const target = type.$defs[type.$ref];
|
|
3393
|
+
return target === undefined ? Any() : extendsWalk(target);
|
|
3394
|
+
}
|
|
3395
|
+
function InstantiateCyclic(context, ref, type) {
|
|
3396
|
+
const dependencies = CyclicDependencies(context, ref, type);
|
|
3397
|
+
const definitions = Object.fromEntries(Object.entries(context).filter(([key]) => dependencies.includes(key)));
|
|
3398
|
+
return Cyclic(definitions, ref);
|
|
3399
|
+
}
|
|
3400
|
+
// src/type/root-instantiate.ts
|
|
3401
|
+
function extractLiteralKeys(indexer) {
|
|
3402
|
+
if (getKind(indexer) === "Literal") {
|
|
3403
|
+
const literal = getLiteralConst(indexer);
|
|
3404
|
+
return literal === undefined ? [] : [String(literal)];
|
|
3405
|
+
}
|
|
3406
|
+
if (getKind(indexer) === "Union") {
|
|
3407
|
+
return indexer.variants.flatMap((variant) => extractLiteralKeys(variant));
|
|
3408
|
+
}
|
|
3409
|
+
return [];
|
|
3410
|
+
}
|
|
3411
|
+
function instantiateType(context, type) {
|
|
3412
|
+
return Instantiate(context, type);
|
|
3413
|
+
}
|
|
3414
|
+
function instantiateObject2(context, type) {
|
|
3415
|
+
const resolved = instantiateType(context, type);
|
|
3416
|
+
return getKind(resolved) === "Object" ? resolved : undefined;
|
|
3417
|
+
}
|
|
3418
|
+
function filterUnionVariants(context, left, right, includeMatches) {
|
|
3419
|
+
const resolvedLeft = instantiateType(context, left);
|
|
3420
|
+
const resolvedRight = instantiateType(context, right);
|
|
3421
|
+
if (getKind(resolvedLeft) === "Union") {
|
|
3422
|
+
const variants = resolvedLeft.variants.filter((variant) => {
|
|
3423
|
+
const matches2 = ExtendsResult.IsExtendsTrueLike(Extends(context, variant, resolvedRight));
|
|
3424
|
+
return includeMatches ? matches2 : !matches2;
|
|
3425
|
+
});
|
|
3426
|
+
return variants.length === 0 ? Never() : variants.length === 1 ? variants[0] : Union(variants);
|
|
3427
|
+
}
|
|
3428
|
+
const matches = ExtendsResult.IsExtendsTrueLike(Extends(context, resolvedLeft, resolvedRight));
|
|
3429
|
+
return includeMatches ? matches ? resolvedLeft : Never() : matches ? Never() : resolvedLeft;
|
|
3430
|
+
}
|
|
3431
|
+
function AwaitedInstantiate(context, _state, type, options = {}) {
|
|
3432
|
+
const resolved = instantiateType(context, type);
|
|
3433
|
+
const unwrapped = getKind(resolved) === "Promise" ? AwaitedInstantiate(context, _state, resolved.item, options) : resolved;
|
|
3434
|
+
return mergeOptions(unwrapped, options);
|
|
3435
|
+
}
|
|
3436
|
+
function CapitalizeInstantiate(context, _state, type, options = {}) {
|
|
3437
|
+
return getKind(type) === "Ref" && getKind(instantiateType(context, type)) === "Ref" ? CapitalizeDeferred(type, options) : mergeOptions({ "~kind": "Capitalize", item: instantiateType(context, type) }, options);
|
|
3438
|
+
}
|
|
3439
|
+
function ConditionalInstantiate(context, _state, left, right, trueType, falseType, options = {}) {
|
|
3440
|
+
return getKind(left) === "Ref" && context[left.name ?? ""] === undefined ? ConditionalDeferred(left, right, trueType, falseType, options) : mergeOptions(instantiateType(context, ExtendsResult.IsExtendsTrueLike(Extends(context, instantiateType(context, left), instantiateType(context, right))) ? trueType : falseType), options);
|
|
3441
|
+
}
|
|
3442
|
+
function ConstructorParametersInstantiate(context, _state, type, options = {}) {
|
|
3443
|
+
const resolved = instantiateType(context, type);
|
|
3444
|
+
return getKind(resolved) === "Constructor" ? mergeOptions(Tuple(resolved.parameters), options) : ConstructorParametersDeferred(type, options);
|
|
3445
|
+
}
|
|
3446
|
+
function EvaluateInstantiate(context, _state, type, options = {}) {
|
|
3447
|
+
return mergeOptions(EvaluateType(instantiateType(context, type)), options);
|
|
3448
|
+
}
|
|
3449
|
+
function ExcludeInstantiate(context, _state, left, right, options = {}) {
|
|
3450
|
+
return getKind(left) === "Ref" && context[left.name ?? ""] === undefined ? ExcludeDeferred(left, right, options) : mergeOptions(filterUnionVariants(context, left, right, false), options);
|
|
3451
|
+
}
|
|
3452
|
+
function ExtractInstantiate(context, _state, left, right, options = {}) {
|
|
3453
|
+
return getKind(left) === "Ref" && context[left.name ?? ""] === undefined ? ExtractDeferred(left, right, options) : mergeOptions(filterUnionVariants(context, left, right, true), options);
|
|
3454
|
+
}
|
|
3455
|
+
function IndexInstantiate(context, _state, type, indexer, options = {}) {
|
|
3456
|
+
const object = instantiateObject2(context, type);
|
|
3457
|
+
if (!object) {
|
|
3458
|
+
return IndexDeferred(type, indexer, options);
|
|
3459
|
+
}
|
|
3460
|
+
const keys = extractLiteralKeys(instantiateType(context, indexer));
|
|
3461
|
+
const variants = keys.flatMap((key) => object.properties[key] ? [instantiateType(context, object.properties[key])] : []);
|
|
3462
|
+
return mergeOptions(variants.length === 0 ? Index(object, instantiateType(context, indexer)) : variants.length === 1 ? variants[0] : Union(variants), options);
|
|
3463
|
+
}
|
|
3464
|
+
function InstanceTypeImmediate(context, _state, type, options = {}) {
|
|
3465
|
+
const resolved = instantiateType(context, type);
|
|
3466
|
+
return getKind(resolved) === "Constructor" ? mergeOptions(resolved.returns, options) : mergeOptions(Never(), options);
|
|
3467
|
+
}
|
|
3468
|
+
function InstanceTypeInstantiate(context, state, type, options = {}) {
|
|
3469
|
+
const resolved = instantiateType(context, type);
|
|
3470
|
+
return getKind(resolved) === "Constructor" ? InstanceTypeImmediate(context, state, resolved, options) : InstanceTypeDeferred(type, options);
|
|
3471
|
+
}
|
|
3472
|
+
function InterfaceInstantiate(context, _state, heritage, properties, options = {}) {
|
|
3473
|
+
const nextHeritage = heritage.map((entry) => instantiateType(context, entry));
|
|
3474
|
+
const nextProperties = Object.fromEntries(Object.entries(properties).map(([key, value]) => [key, instantiateType(context, value)]));
|
|
3475
|
+
return mergeOptions(Interface(nextHeritage, nextProperties, options), options);
|
|
3476
|
+
}
|
|
3477
|
+
function KeyOfImmediate(context, _state, type, options = {}) {
|
|
3478
|
+
return mergeOptions(KeyOfAction(instantiateType(context, type)), options);
|
|
3479
|
+
}
|
|
3480
|
+
function KeyOfInstantiate(context, state, type, options = {}) {
|
|
3481
|
+
return getKind(type) === "Ref" && context[type.name ?? ""] === undefined ? KeyOfDeferred(type, options) : KeyOfImmediate(context, state, type, options);
|
|
3482
|
+
}
|
|
3483
|
+
function LowercaseInstantiate(context, _state, type, options = {}) {
|
|
3484
|
+
return getKind(type) === "Ref" && context[type.name ?? ""] === undefined ? LowercaseDeferred(type, options) : mergeOptions({ "~kind": "Lowercase", item: instantiateType(context, type) }, options);
|
|
3485
|
+
}
|
|
3486
|
+
function MappedInstantiate(context, _state, identifier, key, _asType, property, options = {}) {
|
|
3487
|
+
const keys = extractLiteralKeys(instantiateType(context, key));
|
|
3488
|
+
if (keys.length === 0) {
|
|
3489
|
+
return MappedDeferred(identifier, key, _asType, property, options);
|
|
3490
|
+
}
|
|
3491
|
+
const name = getKind(identifier) === "Identifier" ? identifier.name : "K";
|
|
3492
|
+
const properties = Object.fromEntries(keys.map((keyName) => [keyName, instantiateType({ ...context, [name]: { "~kind": "Literal", const: keyName } }, property)]));
|
|
3493
|
+
return mergeOptions({ "~kind": "Object", properties }, options);
|
|
3494
|
+
}
|
|
3495
|
+
function ModuleInstantiate(context, _state, definitions, options = {}) {
|
|
3496
|
+
const instantiated = Object.fromEntries(Object.entries(definitions).map(([key, value]) => [key, instantiateType(context, value)]));
|
|
3497
|
+
return mergeOptions({ "~kind": "Module", definitions: instantiated }, options);
|
|
3498
|
+
}
|
|
3499
|
+
function NonNullableInstantiate(context, state, type, options = {}) {
|
|
3500
|
+
const resolved = instantiateType(context, type);
|
|
3501
|
+
return getKind(type) === "Ref" && context[type.name ?? ""] === undefined ? NonNullableDeferred(type, options) : mergeOptions(ExcludeInstantiate(context, state, resolved, Union([Null(), Undefined()]), options), options);
|
|
3502
|
+
}
|
|
3503
|
+
function OmitInstantiate(context, _state, type, indexer, options = {}) {
|
|
3504
|
+
const object = instantiateObject2(context, type);
|
|
3505
|
+
if (!object) {
|
|
3506
|
+
return OmitDeferred(type, indexer, options);
|
|
3507
|
+
}
|
|
3508
|
+
const keys = extractLiteralKeys(instantiateType(context, indexer));
|
|
3509
|
+
return mergeOptions(deriveObjectSchema(object, { omitKeys: keys }), options);
|
|
3510
|
+
}
|
|
3511
|
+
function OptionsInstantiate(context, _state, type, options) {
|
|
3512
|
+
return mergeOptions(Options(instantiateType(context, type), options), options);
|
|
3513
|
+
}
|
|
3514
|
+
function ParametersInstantiate(context, _state, type, options = {}) {
|
|
3515
|
+
const resolved = instantiateType(context, type);
|
|
3516
|
+
return getKind(resolved) === "Function" ? mergeOptions(Tuple(resolved.parameters), options) : ParametersDeferred(type, options);
|
|
3517
|
+
}
|
|
3518
|
+
function PartialInstantiate(context, _state, type, options = {}) {
|
|
3519
|
+
const object = instantiateObject2(context, type);
|
|
3520
|
+
return object ? mergeOptions(deriveObjectSchema(object, { requiredMode: "none" }), options) : PartialDeferred(type, options);
|
|
3521
|
+
}
|
|
3522
|
+
function PickInstantiate(context, _state, type, indexer, options = {}) {
|
|
3523
|
+
const object = instantiateObject2(context, type);
|
|
3524
|
+
if (!object) {
|
|
3525
|
+
return PickDeferred(type, indexer, options);
|
|
3526
|
+
}
|
|
3527
|
+
const keys = extractLiteralKeys(instantiateType(context, indexer));
|
|
3528
|
+
return mergeOptions(deriveObjectSchema(object, { pickKeys: keys }), options);
|
|
3529
|
+
}
|
|
3530
|
+
function ReadonlyTypeInstantiate(context, _state, type, options = {}) {
|
|
3531
|
+
return getKind(type) === "Ref" && context[type.name ?? ""] === undefined ? ReadonlyTypeDeferred(type, options) : mergeOptions(ReadonlyType(instantiateType(context, type), options), options);
|
|
3532
|
+
}
|
|
3533
|
+
function RecordInstantiate(context, _state, key, value, options = {}) {
|
|
3534
|
+
return mergeOptions({ "~kind": "Record", key: instantiateType(context, key), value: instantiateType(context, value) }, options);
|
|
3535
|
+
}
|
|
3536
|
+
function RefInstantiate(context, _state, type, ref) {
|
|
3537
|
+
return context[ref] ?? type;
|
|
3538
|
+
}
|
|
3539
|
+
function RequiredInstantiate(context, _state, type, options = {}) {
|
|
3540
|
+
const object = instantiateObject2(context, type);
|
|
3541
|
+
return object ? mergeOptions(deriveObjectSchema(object, { requiredMode: "all" }), options) : RequiredDeferred(type, options);
|
|
3542
|
+
}
|
|
3543
|
+
function ReturnTypeInstantiate(context, _state, type, options = {}) {
|
|
3544
|
+
const resolved = instantiateType(context, type);
|
|
3545
|
+
return getKind(resolved) === "Function" ? mergeOptions(resolved.returns, options) : ReturnTypeDeferred(type, options);
|
|
3546
|
+
}
|
|
3547
|
+
function TemplateLiteralInstantiate(context, _state, types, options = {}) {
|
|
3548
|
+
return mergeOptions(TemplateLiteralFromTypes(types.map((type) => instantiateType(context, type))), options);
|
|
3549
|
+
}
|
|
3550
|
+
function UncapitalizeInstantiate(context, _state, type, options = {}) {
|
|
3551
|
+
return getKind(type) === "Ref" && context[type.name ?? ""] === undefined ? UncapitalizeDeferred(type, options) : mergeOptions({ "~kind": "Uncapitalize", item: instantiateType(context, type) }, options);
|
|
3552
|
+
}
|
|
3553
|
+
function UppercaseInstantiate(context, _state, type, options = {}) {
|
|
3554
|
+
return getKind(type) === "Ref" && context[type.name ?? ""] === undefined ? UppercaseDeferred(type, options) : mergeOptions({ "~kind": "Uppercase", item: instantiateType(context, type) }, options);
|
|
3555
|
+
}
|
|
3556
|
+
// src/shared/bytes.ts
|
|
3557
|
+
import { dlopen, ptr } from "bun:ffi";
|
|
3558
|
+
var libcPath = process.platform === "darwin" ? "/usr/lib/libSystem.B.dylib" : process.platform === "linux" ? "libc.so.6" : process.platform === "win32" ? "msvcrt.dll" : "";
|
|
3559
|
+
var memcmp = libcPath === "" ? undefined : dlopen(libcPath, {
|
|
3560
|
+
memcmp: {
|
|
3561
|
+
args: ["ptr", "ptr", "usize"],
|
|
3562
|
+
returns: "i32"
|
|
3563
|
+
}
|
|
3564
|
+
}).symbols.memcmp;
|
|
3565
|
+
function encodeUint8ArrayBase64(value) {
|
|
3566
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength).toString("base64");
|
|
3567
|
+
}
|
|
3568
|
+
function decodeUint8ArrayBase64(value) {
|
|
3569
|
+
const bunWithBase64 = Bun;
|
|
3570
|
+
if (typeof bunWithBase64.base64ToBytes === "function") {
|
|
3571
|
+
return bunWithBase64.base64ToBytes(value);
|
|
3572
|
+
}
|
|
3573
|
+
return new Uint8Array(Buffer.from(value, "base64"));
|
|
3574
|
+
}
|
|
3575
|
+
function getBase64DecodedByteLength(value) {
|
|
3576
|
+
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
3577
|
+
return value.length / 4 * 3 - padding;
|
|
3578
|
+
}
|
|
3579
|
+
function areUint8ArraysEqual(left, right) {
|
|
3580
|
+
if (left.byteLength !== right.byteLength) {
|
|
3581
|
+
return false;
|
|
3582
|
+
}
|
|
3583
|
+
if (left.byteLength === 0) {
|
|
3584
|
+
return true;
|
|
3585
|
+
}
|
|
3586
|
+
if (memcmp !== undefined) {
|
|
3587
|
+
return memcmp(ptr(left), ptr(right), left.byteLength) === 0;
|
|
3588
|
+
}
|
|
3589
|
+
for (let index = 0;index < left.length; index += 1) {
|
|
3590
|
+
if (left[index] !== right[index]) {
|
|
3591
|
+
return false;
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
return true;
|
|
3595
|
+
}
|
|
3596
|
+
function isUint8ArrayWithinBounds(value, minByteLength, maxByteLength) {
|
|
3597
|
+
if (minByteLength !== undefined && value.byteLength < minByteLength)
|
|
3598
|
+
return false;
|
|
3599
|
+
return maxByteLength === undefined || value.byteLength <= maxByteLength;
|
|
3600
|
+
}
|
|
3601
|
+
function isUint8ArrayBase64String(value, minByteLength, maxByteLength, constBytes, constBase64) {
|
|
3602
|
+
if (typeof value !== "string" || !validateFormat(value, "base64")) {
|
|
3603
|
+
return false;
|
|
3604
|
+
}
|
|
3605
|
+
if (!isUint8ArrayWithinBounds({ byteLength: getBase64DecodedByteLength(value) }, minByteLength, maxByteLength)) {
|
|
3606
|
+
return false;
|
|
3607
|
+
}
|
|
3608
|
+
return constBytes === undefined ? true : value === (constBase64 ?? encodeUint8ArrayBase64(constBytes));
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
// src/type/uint8array-codec.ts
|
|
3612
|
+
function Uint8ArrayCodec(options = {}) {
|
|
3613
|
+
const constBase64 = options.constBytes === undefined ? undefined : encodeUint8ArrayBase64(options.constBytes);
|
|
3614
|
+
const codec = Codec(String2({
|
|
3615
|
+
format: "base64",
|
|
3616
|
+
...options.title === undefined ? {} : { title: options.title },
|
|
3617
|
+
...options.description === undefined ? {} : { description: options.description }
|
|
3618
|
+
})).Decode((input) => decodeUint8ArrayBase64(input)).Encode((input) => encodeUint8ArrayBase64(input));
|
|
3619
|
+
return {
|
|
3620
|
+
...Refine(codec, (input) => isUint8ArrayBase64String(input, options.minByteLength, options.maxByteLength, options.constBytes, constBase64), "Expected a base64-encoded Uint8Array value"),
|
|
3621
|
+
"~uint8arrayCodec": true,
|
|
3622
|
+
...options.minByteLength === undefined ? {} : { minByteLength: options.minByteLength },
|
|
3623
|
+
...options.maxByteLength === undefined ? {} : { maxByteLength: options.maxByteLength },
|
|
3624
|
+
...options.constBytes === undefined ? {} : { constBytes: options.constBytes },
|
|
3625
|
+
...constBase64 === undefined ? {} : { constBase64 }
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
// src/type/codec-builtins.ts
|
|
3629
|
+
var bigintPattern = "^-?(0|[1-9][0-9]*)$";
|
|
3630
|
+
function BigIntCodec() {
|
|
3631
|
+
return Codec(String2({ pattern: bigintPattern })).Decode((input) => globalThis.BigInt(input)).Encode((input) => input.toString());
|
|
3632
|
+
}
|
|
3633
|
+
function DateCodec() {
|
|
3634
|
+
return Codec(String2({ format: "datetime" })).Decode((input) => new globalThis.Date(input)).Encode((input) => input.toISOString());
|
|
3635
|
+
}
|
|
3636
|
+
function URLCodec() {
|
|
3637
|
+
return Codec(String2({ format: "uri" })).Decode((input) => new URL(input)).Encode((input) => input.toString());
|
|
3638
|
+
}
|
|
3639
|
+
// src/script/shared.ts
|
|
3640
|
+
function parseIdentifier(input) {
|
|
3641
|
+
const match = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(input);
|
|
3642
|
+
return match ? match[0] : null;
|
|
3643
|
+
}
|
|
3644
|
+
function resolveType(name, defs) {
|
|
3645
|
+
const definition = defs[name];
|
|
3646
|
+
switch (name) {
|
|
3647
|
+
case "string":
|
|
3648
|
+
return String2();
|
|
3649
|
+
case "number":
|
|
3650
|
+
return Number2();
|
|
3651
|
+
case "integer":
|
|
3652
|
+
return Integer();
|
|
3653
|
+
case "boolean":
|
|
3654
|
+
return Boolean();
|
|
3655
|
+
case "null":
|
|
3656
|
+
return Null();
|
|
3657
|
+
case "undefined":
|
|
3658
|
+
return Undefined();
|
|
3659
|
+
case "void":
|
|
3660
|
+
return Void();
|
|
3661
|
+
case "unknown":
|
|
3662
|
+
return Unknown();
|
|
3663
|
+
case "any":
|
|
3664
|
+
return Any();
|
|
3665
|
+
case "never":
|
|
3666
|
+
return Never();
|
|
3667
|
+
case "bigint":
|
|
3668
|
+
return BigInt();
|
|
3669
|
+
case "symbol":
|
|
3670
|
+
return Symbol2();
|
|
3671
|
+
case "Date":
|
|
3672
|
+
return Date();
|
|
3673
|
+
case "Uint8Array":
|
|
3674
|
+
return Uint8Array2();
|
|
3675
|
+
default:
|
|
3676
|
+
return definition ?? Ref(name);
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
function findMatchingParen(input) {
|
|
3680
|
+
return findMatching(input, "(", ")");
|
|
3681
|
+
}
|
|
3682
|
+
function findMatchingBrace(input) {
|
|
3683
|
+
return findMatching(input, "{", "}");
|
|
3684
|
+
}
|
|
3685
|
+
function findMatchingBracket(input) {
|
|
3686
|
+
return findMatching(input, "[", "]");
|
|
3687
|
+
}
|
|
3688
|
+
function findMatchingAngle(input) {
|
|
3689
|
+
return findMatching(input, "<", ">");
|
|
3690
|
+
}
|
|
3691
|
+
function findMatching(input, open, close) {
|
|
3692
|
+
let depth = 0;
|
|
3693
|
+
let index = 0;
|
|
3694
|
+
while (index < input.length) {
|
|
3695
|
+
const character = input[index];
|
|
3696
|
+
if (character === open)
|
|
3697
|
+
depth += 1;
|
|
3698
|
+
if (character === close) {
|
|
3699
|
+
depth -= 1;
|
|
3700
|
+
if (depth === 0) {
|
|
3701
|
+
return input.slice(1, index);
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
index += 1;
|
|
3705
|
+
}
|
|
3706
|
+
return input.slice(1);
|
|
3707
|
+
}
|
|
3708
|
+
function splitTopLevel(input, delimiter) {
|
|
3709
|
+
const result = [];
|
|
3710
|
+
let depth = 0;
|
|
3711
|
+
let current = "";
|
|
3712
|
+
for (const character of input) {
|
|
3713
|
+
if (character === "(" || character === "{" || character === "[" || character === "<")
|
|
3714
|
+
depth += 1;
|
|
3715
|
+
if (character === ")" || character === "}" || character === "]" || character === ">")
|
|
3716
|
+
depth -= 1;
|
|
3717
|
+
if (character === delimiter && depth === 0) {
|
|
3718
|
+
result.push(current);
|
|
3719
|
+
current = "";
|
|
3720
|
+
continue;
|
|
3721
|
+
}
|
|
3722
|
+
current += character;
|
|
3723
|
+
}
|
|
3724
|
+
if (current.trim().length > 0) {
|
|
3725
|
+
result.push(current);
|
|
3726
|
+
}
|
|
3727
|
+
return result;
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
// src/script/generic.ts
|
|
3731
|
+
function isObjectSchema(schema) {
|
|
3732
|
+
return schema["~kind"] === "Object";
|
|
3733
|
+
}
|
|
3734
|
+
function getLiteralString(schema) {
|
|
3735
|
+
if (schema["~kind"] !== "Literal") {
|
|
3736
|
+
return "";
|
|
3737
|
+
}
|
|
3738
|
+
const literal = schema;
|
|
3739
|
+
return typeof literal.const === "string" ? literal.const : "";
|
|
3740
|
+
}
|
|
3741
|
+
function parseGeneric(name, rest, defs, parseScript) {
|
|
3742
|
+
const argumentSource = findMatchingAngle(rest);
|
|
3743
|
+
const arguments_ = splitTopLevel(argumentSource, ",").map((entry) => parseScript(entry.trim(), defs));
|
|
3744
|
+
const afterArguments = rest.slice(argumentSource.length + 2).trim();
|
|
3745
|
+
switch (name) {
|
|
3746
|
+
case "Array":
|
|
3747
|
+
return { schema: Array2(arguments_[0] ?? Unknown()), rest: afterArguments };
|
|
3748
|
+
case "Record":
|
|
3749
|
+
return {
|
|
3750
|
+
schema: Record(arguments_[0] ?? String2(), arguments_[1] ?? Unknown()),
|
|
3751
|
+
rest: afterArguments
|
|
3752
|
+
};
|
|
3753
|
+
case "Partial": {
|
|
3754
|
+
const object = arguments_[0];
|
|
3755
|
+
return {
|
|
3756
|
+
schema: object !== undefined && isObjectSchema(object) ? Partial(object) : object ?? Unknown(),
|
|
3757
|
+
rest: afterArguments
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3760
|
+
case "Required": {
|
|
3761
|
+
const object = arguments_[0];
|
|
3762
|
+
return {
|
|
3763
|
+
schema: object !== undefined && isObjectSchema(object) ? Required(object) : object ?? Unknown(),
|
|
3764
|
+
rest: afterArguments
|
|
3765
|
+
};
|
|
3766
|
+
}
|
|
3767
|
+
case "Pick": {
|
|
3768
|
+
const object = arguments_[0];
|
|
3769
|
+
const keys = arguments_.slice(1).map(getLiteralString);
|
|
3770
|
+
return {
|
|
3771
|
+
schema: object !== undefined && isObjectSchema(object) ? Pick(object, keys) : object ?? Unknown(),
|
|
3772
|
+
rest: afterArguments
|
|
3773
|
+
};
|
|
3774
|
+
}
|
|
3775
|
+
case "Omit": {
|
|
3776
|
+
const object = arguments_[0];
|
|
3777
|
+
const keys = arguments_.slice(1).map(getLiteralString);
|
|
3778
|
+
return {
|
|
3779
|
+
schema: object !== undefined && isObjectSchema(object) ? Omit(object, keys) : object ?? Unknown(),
|
|
3780
|
+
rest: afterArguments
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
case "Promise":
|
|
3784
|
+
return { schema: Promise2(arguments_[0] ?? Unknown()), rest: afterArguments };
|
|
3785
|
+
case "Iterator":
|
|
3786
|
+
return { schema: Iterator(arguments_[0] ?? Unknown()), rest: afterArguments };
|
|
3787
|
+
case "AsyncIterator":
|
|
3788
|
+
return { schema: AsyncIterator(arguments_[0] ?? Unknown()), rest: afterArguments };
|
|
3789
|
+
case "Exclude":
|
|
3790
|
+
return { schema: Exclude(arguments_[0] ?? Unknown(), arguments_[1] ?? Unknown()), rest: afterArguments };
|
|
3791
|
+
case "Extract":
|
|
3792
|
+
return { schema: Extract(arguments_[0] ?? Unknown(), arguments_[1] ?? Unknown()), rest: afterArguments };
|
|
3793
|
+
default:
|
|
3794
|
+
return { schema: resolveType(name, defs), rest: afterArguments };
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3798
|
+
// src/script/literals.ts
|
|
3799
|
+
function parseObjectLiteral(input, defs, parseScript) {
|
|
3800
|
+
const body = findMatchingBrace(input);
|
|
3801
|
+
const entries = splitTopLevel(body, ";").filter((entry) => entry.trim().length > 0);
|
|
3802
|
+
const properties = {};
|
|
3803
|
+
const required = [];
|
|
3804
|
+
const optional = [];
|
|
3805
|
+
for (const entry of entries) {
|
|
3806
|
+
const trimmed = entry.trim();
|
|
3807
|
+
const optionalMatch = /^(\w+)\?\s*:\s*(.+)$/.exec(trimmed);
|
|
3808
|
+
if (optionalMatch) {
|
|
3809
|
+
const key2 = optionalMatch[1];
|
|
3810
|
+
const typeText2 = optionalMatch[2].trim();
|
|
3811
|
+
properties[key2] = parseScript(typeText2, defs);
|
|
3812
|
+
optional.push(key2);
|
|
3813
|
+
continue;
|
|
3814
|
+
}
|
|
3815
|
+
const requiredMatch = /^(\w+)\s*:\s*(.+)$/.exec(trimmed);
|
|
3816
|
+
if (!requiredMatch) {
|
|
3817
|
+
continue;
|
|
3818
|
+
}
|
|
3819
|
+
const key = requiredMatch[1];
|
|
3820
|
+
const typeText = requiredMatch[2].trim();
|
|
3821
|
+
properties[key] = parseScript(typeText, defs);
|
|
3822
|
+
required.push(key);
|
|
3823
|
+
}
|
|
3824
|
+
const objectOptions = {
|
|
3825
|
+
...required.length > 0 ? { required } : {},
|
|
3826
|
+
...optional.length > 0 ? { optional } : {}
|
|
3827
|
+
};
|
|
3828
|
+
return {
|
|
3829
|
+
schema: Object2(properties, objectOptions),
|
|
3830
|
+
rest: input.slice(body.length + 2).trim()
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
function parseTupleLiteral(input, defs, parseScript) {
|
|
3834
|
+
const body = findMatchingBracket(input);
|
|
3835
|
+
const elements = splitTopLevel(body, ",").filter((entry) => entry.trim().length > 0);
|
|
3836
|
+
const items = elements.map((entry) => parseScript(entry.trim(), defs));
|
|
3837
|
+
return {
|
|
3838
|
+
schema: Tuple(items),
|
|
3839
|
+
rest: input.slice(body.length + 2).trim()
|
|
3840
|
+
};
|
|
3841
|
+
}
|
|
3842
|
+
function parseStringLiteral(input) {
|
|
3843
|
+
const quote = input.charAt(0);
|
|
3844
|
+
let index = 1;
|
|
3845
|
+
while (index < input.length && input[index] !== quote) {
|
|
3846
|
+
if (input[index] === "\\") {
|
|
3847
|
+
index += 1;
|
|
3848
|
+
}
|
|
3849
|
+
index += 1;
|
|
3850
|
+
}
|
|
3851
|
+
return {
|
|
3852
|
+
schema: Literal(input.slice(1, index)),
|
|
3853
|
+
rest: input.slice(index + 1).trim()
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3857
|
+
// src/script/index.ts
|
|
3858
|
+
function Script(input) {
|
|
3859
|
+
return parseScript(input.trim(), {});
|
|
3860
|
+
}
|
|
3861
|
+
function ScriptWithDefinitions(input, definitions) {
|
|
3862
|
+
return parseScript(input.trim(), definitions);
|
|
3863
|
+
}
|
|
3864
|
+
function parseScript(input, defs) {
|
|
3865
|
+
return parseUnionOrIntersect(input, defs).schema;
|
|
3866
|
+
}
|
|
3867
|
+
function parseUnionOrIntersect(input, defs) {
|
|
3868
|
+
const left = parsePrimary(input, defs);
|
|
3869
|
+
let rest = left.rest.trim();
|
|
3870
|
+
if (rest.startsWith("|")) {
|
|
3871
|
+
const variants = [left.schema];
|
|
3872
|
+
while (rest.startsWith("|")) {
|
|
3873
|
+
rest = rest.slice(1).trim();
|
|
3874
|
+
const next = parsePrimary(rest, defs);
|
|
3875
|
+
variants.push(next.schema);
|
|
3876
|
+
rest = next.rest.trim();
|
|
3877
|
+
}
|
|
3878
|
+
return { schema: Union(variants), rest };
|
|
3879
|
+
}
|
|
3880
|
+
if (rest.startsWith("&")) {
|
|
3881
|
+
const variants = [left.schema];
|
|
3882
|
+
while (rest.startsWith("&")) {
|
|
3883
|
+
rest = rest.slice(1).trim();
|
|
3884
|
+
const next = parsePrimary(rest, defs);
|
|
3885
|
+
variants.push(next.schema);
|
|
3886
|
+
rest = next.rest.trim();
|
|
3887
|
+
}
|
|
3888
|
+
return { schema: Intersect(variants), rest };
|
|
3889
|
+
}
|
|
3890
|
+
return left;
|
|
3891
|
+
}
|
|
3892
|
+
function parsePrimary(input, defs) {
|
|
3893
|
+
let result = parseAtom(input, defs);
|
|
3894
|
+
let rest = result.rest.trim();
|
|
3895
|
+
while (rest.startsWith("[]")) {
|
|
3896
|
+
result = { schema: Array2(result.schema), rest: rest.slice(2).trim() };
|
|
3897
|
+
rest = result.rest;
|
|
3898
|
+
}
|
|
3899
|
+
return result;
|
|
3900
|
+
}
|
|
3901
|
+
function parseAtom(input, defs) {
|
|
3902
|
+
if (input.startsWith("(")) {
|
|
3903
|
+
const inner = findMatchingParen(input);
|
|
3904
|
+
return {
|
|
3905
|
+
schema: parseScript(inner, defs),
|
|
3906
|
+
rest: input.slice(inner.length + 2).trim()
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
if (input.startsWith("{")) {
|
|
3910
|
+
return parseObjectLiteral(input, defs, parseScript);
|
|
3911
|
+
}
|
|
3912
|
+
if (input.startsWith("[")) {
|
|
3913
|
+
return parseTupleLiteral(input, defs, parseScript);
|
|
3914
|
+
}
|
|
3915
|
+
if (input.startsWith('"') || input.startsWith("'")) {
|
|
3916
|
+
return parseStringLiteral(input);
|
|
3917
|
+
}
|
|
3918
|
+
const numericMatch = /^(-?\d+(?:\.\d+)?)/.exec(input);
|
|
3919
|
+
if (numericMatch) {
|
|
3920
|
+
const literal = numericMatch[1];
|
|
3921
|
+
return {
|
|
3922
|
+
schema: Literal(Number.parseFloat(literal)),
|
|
3923
|
+
rest: input.slice(literal.length).trim()
|
|
3924
|
+
};
|
|
3925
|
+
}
|
|
3926
|
+
if (input.startsWith("true")) {
|
|
3927
|
+
return { schema: Literal(true), rest: input.slice(4).trim() };
|
|
3928
|
+
}
|
|
3929
|
+
if (input.startsWith("false")) {
|
|
3930
|
+
return { schema: Literal(false), rest: input.slice(5).trim() };
|
|
3931
|
+
}
|
|
3932
|
+
const identifier = parseIdentifier(input);
|
|
3933
|
+
if (!identifier) {
|
|
3934
|
+
return { schema: Unknown(), rest: input };
|
|
3935
|
+
}
|
|
3936
|
+
const rest = input.slice(identifier.length).trim();
|
|
3937
|
+
if (rest.startsWith("<")) {
|
|
3938
|
+
return parseGeneric(identifier, rest, defs, parseScript);
|
|
3939
|
+
}
|
|
3940
|
+
return { schema: resolveType(identifier, defs), rest };
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
// src/typebox.ts
|
|
3944
|
+
var exports_typebox = {};
|
|
3945
|
+
__export(exports_typebox, {
|
|
3946
|
+
_Object_: () => _Object_,
|
|
3947
|
+
_Function_: () => _Function_,
|
|
3948
|
+
VoidKind: () => VoidKind,
|
|
3949
|
+
Void: () => Void,
|
|
3950
|
+
Variant: () => Variant,
|
|
3951
|
+
UuidKind: () => UuidKind,
|
|
3952
|
+
Uuid: () => Uuid,
|
|
3953
|
+
UriKind: () => UriKind,
|
|
3954
|
+
Uri: () => Uri,
|
|
3955
|
+
UppercaseKind: () => UppercaseKind,
|
|
3956
|
+
UppercaseInstantiate: () => UppercaseInstantiate,
|
|
3957
|
+
UppercaseDeferred: () => UppercaseDeferred,
|
|
3958
|
+
Uppercase: () => Uppercase,
|
|
3959
|
+
UnsafeKind: () => UnsafeKind,
|
|
3960
|
+
Unsafe: () => Unsafe,
|
|
3961
|
+
UnknownKind: () => UnknownKind,
|
|
3962
|
+
Unknown: () => Unknown,
|
|
3963
|
+
UnionOptions: () => UnionOptions,
|
|
3964
|
+
UnionKind: () => UnionKind,
|
|
3965
|
+
Union: () => Union,
|
|
3966
|
+
UndefinedKind: () => UndefinedKind,
|
|
3967
|
+
Undefined: () => Undefined,
|
|
3968
|
+
UncapitalizeKind: () => UncapitalizeKind,
|
|
3969
|
+
UncapitalizeInstantiate: () => UncapitalizeInstantiate,
|
|
3970
|
+
UncapitalizeDeferred: () => UncapitalizeDeferred,
|
|
3971
|
+
Uncapitalize: () => Uncapitalize,
|
|
3972
|
+
Uint8ArrayKind: () => Uint8ArrayKind,
|
|
3973
|
+
Uint8ArrayCodec: () => Uint8ArrayCodec,
|
|
3974
|
+
Uint8Array: () => Uint8Array2,
|
|
3975
|
+
URLCodec: () => URLCodec,
|
|
3976
|
+
TypeScriptEnumToEnumValues: () => TypeScriptEnumToEnumValues,
|
|
3977
|
+
TupleOptions: () => TupleOptions,
|
|
3978
|
+
TupleKind: () => TupleKind,
|
|
3979
|
+
Tuple: () => Tuple,
|
|
3980
|
+
TimeKind: () => TimeKind,
|
|
3981
|
+
Time: () => Time,
|
|
3982
|
+
This: () => This,
|
|
3983
|
+
TemplateLiteralKind: () => TemplateLiteralKind,
|
|
3984
|
+
TemplateLiteralInstantiate: () => TemplateLiteralInstantiate,
|
|
3985
|
+
TemplateLiteralFromTypes: () => TemplateLiteralFromTypes,
|
|
3986
|
+
TemplateLiteralFromString: () => TemplateLiteralFromString,
|
|
3987
|
+
TemplateLiteralEncode: () => TemplateLiteralEncode,
|
|
3988
|
+
TemplateLiteralDeferred: () => TemplateLiteralDeferred,
|
|
3989
|
+
TemplateLiteralDecodeUnsafe: () => TemplateLiteralDecodeUnsafe,
|
|
3990
|
+
TemplateLiteralDecode: () => TemplateLiteralDecode,
|
|
3991
|
+
TemplateLiteralCreate: () => TemplateLiteralCreate,
|
|
3992
|
+
TemplateLiteral: () => TemplateLiteral,
|
|
3993
|
+
TemplateElementKind: () => TemplateElementKind,
|
|
3994
|
+
SymbolKind: () => SymbolKind,
|
|
3995
|
+
Symbol: () => Symbol2,
|
|
3996
|
+
StringPattern: () => StringPattern,
|
|
3997
|
+
StringKind: () => StringKind,
|
|
3998
|
+
StringKey: () => StringKey,
|
|
3999
|
+
String: () => String2,
|
|
4000
|
+
SelfKind: () => SelfKind,
|
|
4001
|
+
ScriptWithDefinitions: () => ScriptWithDefinitions,
|
|
4002
|
+
Script: () => Script,
|
|
4003
|
+
ReturnTypeKind: () => ReturnTypeKind,
|
|
4004
|
+
ReturnTypeInstantiate: () => ReturnTypeInstantiate,
|
|
4005
|
+
ReturnTypeDeferred: () => ReturnTypeDeferred,
|
|
4006
|
+
ReturnType: () => ReturnType,
|
|
4007
|
+
ResultRightInside: () => ResultRightInside,
|
|
4008
|
+
ResultLeftInside: () => ResultLeftInside,
|
|
4009
|
+
ResultEqual: () => ResultEqual,
|
|
4010
|
+
ResultDisjoint: () => ResultDisjoint,
|
|
4011
|
+
RestKind: () => RestKind,
|
|
4012
|
+
Rest: () => Rest,
|
|
4013
|
+
RequiredKind: () => RequiredKind,
|
|
4014
|
+
RequiredInstantiate: () => RequiredInstantiate,
|
|
4015
|
+
RequiredDeferred: () => RequiredDeferred,
|
|
4016
|
+
RequiredArray: () => RequiredArray,
|
|
4017
|
+
Required: () => Required,
|
|
4018
|
+
RegExpKind: () => RegExpKind,
|
|
4019
|
+
RegExpInstance: () => RegExpInstance,
|
|
4020
|
+
RegExp: () => RegExp2,
|
|
4021
|
+
RefineAdd: () => RefineAdd,
|
|
4022
|
+
Refine: () => Refine,
|
|
4023
|
+
RefKind: () => RefKind,
|
|
4024
|
+
RefInstantiate: () => RefInstantiate,
|
|
4025
|
+
Ref: () => Ref,
|
|
4026
|
+
RecursiveKind: () => RecursiveKind,
|
|
4027
|
+
Recursive: () => Recursive,
|
|
4028
|
+
RecordValue: () => RecordValue,
|
|
4029
|
+
RecordPattern: () => RecordPattern,
|
|
4030
|
+
RecordOptions: () => RecordOptions,
|
|
4031
|
+
RecordKind: () => RecordKind,
|
|
4032
|
+
RecordKeyAsPattern: () => RecordPattern,
|
|
4033
|
+
RecordKey: () => RecordKey,
|
|
4034
|
+
RecordInstantiate: () => RecordInstantiate,
|
|
4035
|
+
RecordFromPattern: () => RecordFromPattern,
|
|
4036
|
+
RecordDeferred: () => RecordDeferred,
|
|
4037
|
+
RecordConstruct: () => RecordConstruct,
|
|
4038
|
+
Record: () => Record,
|
|
4039
|
+
ReadonlyTypeInstantiate: () => ReadonlyTypeInstantiate,
|
|
4040
|
+
ReadonlyTypeDeferred: () => ReadonlyTypeDeferred,
|
|
4041
|
+
ReadonlyType: () => ReadonlyType,
|
|
4042
|
+
ReadonlyRemoveAction: () => ReadonlyRemoveAction,
|
|
4043
|
+
ReadonlyRemove: () => ReadonlyRemove,
|
|
4044
|
+
ReadonlyKind: () => ReadonlyKind,
|
|
4045
|
+
ReadonlyAddAction: () => ReadonlyAddAction,
|
|
4046
|
+
ReadonlyAdd: () => ReadonlyAdd,
|
|
4047
|
+
Readonly: () => Readonly,
|
|
4048
|
+
PropertyValues: () => PropertyValues,
|
|
4049
|
+
PropertyKeys: () => PropertyKeys,
|
|
4050
|
+
PromiseOptions: () => PromiseOptions,
|
|
4051
|
+
PromiseKind: () => PromiseKind,
|
|
4052
|
+
Promise: () => Promise2,
|
|
4053
|
+
PickKind: () => PickKind,
|
|
4054
|
+
PickInstantiate: () => PickInstantiate,
|
|
4055
|
+
PickDeferred: () => PickDeferred,
|
|
4056
|
+
Pick: () => Pick,
|
|
4057
|
+
PartialKind: () => PartialKind,
|
|
4058
|
+
PartialInstantiate: () => PartialInstantiate,
|
|
4059
|
+
PartialDeferred: () => PartialDeferred,
|
|
4060
|
+
Partial: () => Partial,
|
|
4061
|
+
ParseTemplateIntoTypes: () => ParseTemplateIntoTypes,
|
|
4062
|
+
ParsePatternIntoTypes: () => ParsePatternIntoTypes,
|
|
4063
|
+
ParametersKind: () => ParametersKind,
|
|
4064
|
+
ParametersInstantiate: () => ParametersInstantiate,
|
|
4065
|
+
ParametersDeferred: () => ParametersDeferred,
|
|
4066
|
+
Parameters: () => Parameters,
|
|
4067
|
+
Parameter: () => Parameter,
|
|
4068
|
+
OptionsInstantiate: () => OptionsInstantiate,
|
|
4069
|
+
OptionsDeferred: () => OptionsDeferred,
|
|
4070
|
+
Options: () => Options,
|
|
4071
|
+
OptionalRemoveAction: () => OptionalRemoveAction,
|
|
4072
|
+
OptionalRemove: () => OptionalRemove,
|
|
4073
|
+
OptionalKind: () => OptionalKind,
|
|
4074
|
+
OptionalAddAction: () => OptionalAddAction,
|
|
4075
|
+
OptionalAdd: () => OptionalAdd,
|
|
4076
|
+
Optional: () => Optional,
|
|
4077
|
+
OmitKind: () => OmitKind,
|
|
4078
|
+
OmitInstantiate: () => OmitInstantiate,
|
|
4079
|
+
OmitDeferred: () => OmitDeferred,
|
|
4080
|
+
Omit: () => Omit,
|
|
4081
|
+
ObjectOptions: () => ObjectOptions,
|
|
4082
|
+
ObjectKind: () => ObjectKind,
|
|
4083
|
+
Object: () => Object2,
|
|
4084
|
+
NumberPattern: () => NumberPattern,
|
|
4085
|
+
NumberKind: () => NumberKind,
|
|
4086
|
+
NumberKey: () => NumberKey,
|
|
4087
|
+
Number: () => Number2,
|
|
4088
|
+
NullKind: () => NullKind,
|
|
4089
|
+
Null: () => Null,
|
|
4090
|
+
NotKind: () => NotKind,
|
|
4091
|
+
Not: () => Not,
|
|
4092
|
+
NonNullableInstantiate: () => NonNullableInstantiate,
|
|
4093
|
+
NonNullableDeferred: () => NonNullableDeferred,
|
|
4094
|
+
NonNullable: () => NonNullable,
|
|
4095
|
+
NeverPattern: () => NeverPattern,
|
|
4096
|
+
NeverKind: () => NeverKind,
|
|
4097
|
+
Never: () => Never,
|
|
4098
|
+
Narrow: () => Narrow,
|
|
4099
|
+
ModuleKind: () => ModuleKind,
|
|
4100
|
+
ModuleInstantiate: () => ModuleInstantiate,
|
|
4101
|
+
ModuleDeferred: () => ModuleDeferred,
|
|
4102
|
+
Module: () => Module,
|
|
4103
|
+
MappedKind: () => MappedKind,
|
|
4104
|
+
MappedInstantiate: () => MappedInstantiate,
|
|
4105
|
+
MappedDeferred: () => MappedDeferred,
|
|
4106
|
+
Mapped: () => Mapped,
|
|
4107
|
+
LowercaseKind: () => LowercaseKind,
|
|
4108
|
+
LowercaseInstantiate: () => LowercaseInstantiate,
|
|
4109
|
+
LowercaseDeferred: () => LowercaseDeferred,
|
|
4110
|
+
Lowercase: () => Lowercase,
|
|
4111
|
+
LiteralTypeName: () => LiteralTypeName,
|
|
4112
|
+
LiteralKind: () => LiteralKind,
|
|
4113
|
+
Literal: () => Literal,
|
|
4114
|
+
KeysToIndexer: () => KeysToIndexer,
|
|
4115
|
+
KeyOfKind: () => KeyOfKind,
|
|
4116
|
+
KeyOfInstantiate: () => KeyOfInstantiate,
|
|
4117
|
+
KeyOfImmediate: () => KeyOfImmediate,
|
|
4118
|
+
KeyOfDeferred: () => KeyOfDeferred,
|
|
4119
|
+
KeyOfAction: () => KeyOfAction,
|
|
4120
|
+
KeyOf: () => KeyOf,
|
|
4121
|
+
JsonKind: () => JsonKind,
|
|
4122
|
+
Json: () => Json,
|
|
4123
|
+
IteratorOptions: () => IteratorOptions,
|
|
4124
|
+
IteratorKind: () => IteratorKind,
|
|
4125
|
+
Iterator: () => Iterator,
|
|
4126
|
+
IsVoid: () => IsVoid,
|
|
4127
|
+
IsUppercase: () => IsUppercase,
|
|
4128
|
+
IsUnsafe: () => IsUnsafe,
|
|
4129
|
+
IsUnknown: () => IsUnknown,
|
|
4130
|
+
IsUnion: () => IsUnion,
|
|
4131
|
+
IsUndefined: () => IsUndefined,
|
|
4132
|
+
IsUncapitalize: () => IsUncapitalize,
|
|
4133
|
+
IsUint8Array: () => IsUint8Array,
|
|
4134
|
+
IsTypeScriptEnumLike: () => IsTypeScriptEnumLike,
|
|
4135
|
+
IsTuple: () => IsTuple,
|
|
4136
|
+
IsThis: () => IsThis,
|
|
4137
|
+
IsTemplateLiteralPattern: () => IsTemplateLiteralPattern,
|
|
4138
|
+
IsTemplateLiteralFinite: () => IsTemplateLiteralFinite,
|
|
4139
|
+
IsTemplateLiteral: () => IsTemplateLiteral,
|
|
4140
|
+
IsSymbol: () => IsSymbol,
|
|
4141
|
+
IsString: () => IsString,
|
|
4142
|
+
IsSchema: () => IsSchema,
|
|
4143
|
+
IsReturnType: () => IsReturnType,
|
|
4144
|
+
IsRest: () => IsRest,
|
|
4145
|
+
IsRequired: () => IsRequired,
|
|
4146
|
+
IsRegExpInstance: () => IsRegExpInstance,
|
|
4147
|
+
IsRefine: () => IsRefine,
|
|
4148
|
+
IsRef: () => IsRef,
|
|
4149
|
+
IsRecursive: () => IsRecursive,
|
|
4150
|
+
IsRecord: () => IsRecord,
|
|
4151
|
+
IsReadonlyType: () => IsReadonlyType,
|
|
4152
|
+
IsReadonlyRemoveAction: () => IsReadonlyRemoveAction,
|
|
4153
|
+
IsReadonlyAddAction: () => IsReadonlyAddAction,
|
|
4154
|
+
IsReadonly: () => IsReadonly,
|
|
4155
|
+
IsPromise: () => IsPromise,
|
|
4156
|
+
IsPick: () => IsPick,
|
|
4157
|
+
IsPartial: () => IsPartial,
|
|
4158
|
+
IsParameters: () => IsParameters,
|
|
4159
|
+
IsParameter: () => IsParameter,
|
|
4160
|
+
IsOptions: () => IsOptions,
|
|
4161
|
+
IsOptionalRemoveAction: () => IsOptionalRemoveAction,
|
|
4162
|
+
IsOptionalAddAction: () => IsOptionalAddAction,
|
|
4163
|
+
IsOptional: () => IsOptional,
|
|
4164
|
+
IsOmit: () => IsOmit,
|
|
4165
|
+
IsObject: () => IsObject,
|
|
4166
|
+
IsNumber: () => IsNumber,
|
|
4167
|
+
IsNull: () => IsNull,
|
|
4168
|
+
IsNot: () => IsNot,
|
|
4169
|
+
IsNonNullable: () => IsNonNullable,
|
|
4170
|
+
IsNever: () => IsNever,
|
|
4171
|
+
IsModule: () => IsModule,
|
|
4172
|
+
IsMapped: () => IsMapped,
|
|
4173
|
+
IsLowercase: () => IsLowercase,
|
|
4174
|
+
IsLiteralValue: () => IsLiteralValue,
|
|
4175
|
+
IsLiteralString: () => IsLiteralString,
|
|
4176
|
+
IsLiteralNumber: () => IsLiteralNumber,
|
|
4177
|
+
IsLiteralBoolean: () => IsLiteralBoolean,
|
|
4178
|
+
IsLiteralBigInt: () => IsLiteralBigInt,
|
|
4179
|
+
IsLiteral: () => IsLiteral,
|
|
4180
|
+
IsKind: () => IsKind,
|
|
4181
|
+
IsKeyOf: () => IsKeyOf,
|
|
4182
|
+
IsIterator: () => IsIterator,
|
|
4183
|
+
IsIntersect: () => IsIntersect,
|
|
4184
|
+
IsInterfaceDeferred: () => IsInterfaceDeferred,
|
|
4185
|
+
IsInterface: () => IsInterface,
|
|
4186
|
+
IsInteger: () => IsInteger,
|
|
4187
|
+
IsInstanceType: () => IsInstanceType,
|
|
4188
|
+
IsInfer: () => IsInfer,
|
|
4189
|
+
IsIndex: () => IsIndex,
|
|
4190
|
+
IsImmutable: () => IsImmutable,
|
|
4191
|
+
IsIfThenElse: () => IsIfThenElse,
|
|
4192
|
+
IsIdentifier: () => IsIdentifier,
|
|
4193
|
+
IsGeneric: () => IsGeneric,
|
|
4194
|
+
IsFunction: () => IsFunction,
|
|
4195
|
+
IsExtract: () => IsExtract,
|
|
4196
|
+
IsExclude: () => IsExclude,
|
|
4197
|
+
IsEnum: () => IsEnum,
|
|
4198
|
+
IsEncode: () => IsEncode,
|
|
4199
|
+
IsDeferred: () => IsDeferred,
|
|
4200
|
+
IsDecode: () => IsDecode,
|
|
4201
|
+
IsDate: () => IsDate,
|
|
4202
|
+
IsCyclic: () => IsCyclic,
|
|
4203
|
+
IsConstructorParameters: () => IsConstructorParameters,
|
|
4204
|
+
IsConstructor: () => IsConstructor,
|
|
4205
|
+
IsConditional: () => IsConditional,
|
|
4206
|
+
IsCodec: () => IsCodec,
|
|
4207
|
+
IsCapitalize: () => IsCapitalize,
|
|
4208
|
+
IsCall: () => IsCall,
|
|
4209
|
+
IsBoolean: () => IsBoolean,
|
|
4210
|
+
IsBigInt: () => IsBigInt,
|
|
4211
|
+
IsBase: () => IsBase,
|
|
4212
|
+
IsAwaited: () => IsAwaited,
|
|
4213
|
+
IsAsyncIterator: () => IsAsyncIterator,
|
|
4214
|
+
IsArray: () => IsArray,
|
|
4215
|
+
IsAny: () => IsAny,
|
|
4216
|
+
IpKind: () => IpKind,
|
|
4217
|
+
Ip: () => Ip,
|
|
4218
|
+
InvalidLiteralValue: () => InvalidLiteralValue,
|
|
4219
|
+
IntersectOptions: () => IntersectOptions,
|
|
4220
|
+
IntersectKind: () => IntersectKind,
|
|
4221
|
+
Intersect: () => Intersect,
|
|
4222
|
+
InterfaceInstantiate: () => InterfaceInstantiate,
|
|
4223
|
+
InterfaceDeferred: () => InterfaceDeferred,
|
|
4224
|
+
Interface: () => Interface,
|
|
4225
|
+
IntegerPattern: () => IntegerPattern,
|
|
4226
|
+
IntegerKind: () => IntegerKind,
|
|
4227
|
+
IntegerKey: () => IntegerKey,
|
|
4228
|
+
Integer: () => Integer,
|
|
4229
|
+
InstantiateCyclic: () => InstantiateCyclic,
|
|
4230
|
+
Instantiate: () => Instantiate,
|
|
4231
|
+
InstanceTypeKind: () => InstanceTypeKind,
|
|
4232
|
+
InstanceTypeInstantiate: () => InstanceTypeInstantiate,
|
|
4233
|
+
InstanceTypeImmediate: () => InstanceTypeImmediate,
|
|
4234
|
+
InstanceTypeDeferred: () => InstanceTypeDeferred,
|
|
4235
|
+
InstanceType: () => InstanceType,
|
|
4236
|
+
Infer: () => Infer,
|
|
4237
|
+
IndexKind: () => IndexKind,
|
|
4238
|
+
IndexInstantiate: () => IndexInstantiate,
|
|
4239
|
+
IndexDeferred: () => IndexDeferred,
|
|
4240
|
+
Index: () => Index,
|
|
4241
|
+
Import: () => Import,
|
|
4242
|
+
ImmutableRemove: () => ImmutableRemove,
|
|
4243
|
+
ImmutableAdd: () => ImmutableAdd,
|
|
4244
|
+
Immutable: () => Immutable,
|
|
4245
|
+
IfThenElseKind: () => IfThenElseKind,
|
|
4246
|
+
IfThenElse: () => IfThenElse,
|
|
4247
|
+
Identifier: () => Identifier,
|
|
4248
|
+
HostnameKind: () => HostnameKind,
|
|
4249
|
+
Hostname: () => Hostname,
|
|
4250
|
+
HexKind: () => HexKind,
|
|
4251
|
+
HexColorKind: () => HexColorKind,
|
|
4252
|
+
HexColor: () => HexColor,
|
|
4253
|
+
Hex: () => Hex,
|
|
4254
|
+
Generic: () => Generic,
|
|
4255
|
+
FunctionOptions: () => FunctionOptions,
|
|
4256
|
+
FunctionKind: () => FunctionKind,
|
|
4257
|
+
Function: () => Function,
|
|
4258
|
+
Flatten: () => Flatten,
|
|
4259
|
+
ExtractKind: () => ExtractKind,
|
|
4260
|
+
ExtractInstantiate: () => ExtractInstantiate,
|
|
4261
|
+
ExtractDeferred: () => ExtractDeferred,
|
|
4262
|
+
Extract: () => Extract,
|
|
4263
|
+
ExtendsResult: () => ExtendsResult,
|
|
4264
|
+
Extends: () => Extends,
|
|
4265
|
+
ExcludeKind: () => ExcludeKind,
|
|
4266
|
+
ExcludeInstantiate: () => ExcludeInstantiate,
|
|
4267
|
+
ExcludeDeferred: () => ExcludeDeferred,
|
|
4268
|
+
Exclude: () => Exclude,
|
|
4269
|
+
EvaluateUnionFast: () => EvaluateUnionFast,
|
|
4270
|
+
EvaluateUnion: () => EvaluateUnion,
|
|
4271
|
+
EvaluateType: () => EvaluateType,
|
|
4272
|
+
EvaluateIntersect: () => EvaluateIntersect,
|
|
4273
|
+
EvaluateInstantiate: () => EvaluateInstantiate,
|
|
4274
|
+
EvaluateDeferred: () => EvaluateDeferred,
|
|
4275
|
+
Evaluate: () => Evaluate,
|
|
4276
|
+
EnumValuesToVariants: () => EnumValuesToVariants,
|
|
4277
|
+
EnumValuesToUnion: () => EnumValuesToUnion,
|
|
4278
|
+
EnumToUnion: () => EnumToUnion,
|
|
4279
|
+
EnumKind: () => EnumKind,
|
|
4280
|
+
Enum: () => Enum,
|
|
4281
|
+
EncodeKind: () => EncodeKind,
|
|
4282
|
+
EncodeBuilder: () => EncodeBuilder,
|
|
4283
|
+
Encode: () => Encode,
|
|
4284
|
+
EmailKind: () => EmailKind,
|
|
4285
|
+
Email: () => Email,
|
|
4286
|
+
DurationKind: () => DurationKind,
|
|
4287
|
+
Duration: () => Duration,
|
|
4288
|
+
Distribute: () => Distribute,
|
|
4289
|
+
Deferred: () => Deferred,
|
|
4290
|
+
DecodeKind: () => DecodeKind,
|
|
4291
|
+
DecodeBuilder: () => DecodeBuilder,
|
|
4292
|
+
Decode: () => Decode,
|
|
4293
|
+
DateTimeKind: () => DateTimeKind,
|
|
4294
|
+
DateTime: () => DateTime,
|
|
4295
|
+
DateKind: () => DateKind,
|
|
4296
|
+
DateFormatKind: () => DateFormatKind,
|
|
4297
|
+
DateFormat: () => DateFormat,
|
|
4298
|
+
DateCodec: () => DateCodec,
|
|
4299
|
+
Date: () => Date,
|
|
4300
|
+
CyclicTarget: () => CyclicTarget,
|
|
4301
|
+
CyclicOptions: () => CyclicOptions,
|
|
4302
|
+
CyclicExtends: () => CyclicExtends,
|
|
4303
|
+
CyclicDependencies: () => CyclicDependencies,
|
|
4304
|
+
CyclicCheck: () => CyclicCheck,
|
|
4305
|
+
CyclicCandidates: () => CyclicCandidates,
|
|
4306
|
+
Cyclic: () => Cyclic,
|
|
4307
|
+
CreditCardKind: () => CreditCardKind,
|
|
4308
|
+
CreditCard: () => CreditCard,
|
|
4309
|
+
ConvertToIntegerKey: () => ConvertToIntegerKey,
|
|
4310
|
+
ConstructorParametersKind: () => ConstructorParametersKind,
|
|
4311
|
+
ConstructorParametersInstantiate: () => ConstructorParametersInstantiate,
|
|
4312
|
+
ConstructorParametersDeferred: () => ConstructorParametersDeferred,
|
|
4313
|
+
ConstructorParameters: () => ConstructorParameters,
|
|
4314
|
+
ConstructorOptions: () => ConstructorOptions,
|
|
4315
|
+
ConstructorKind: () => ConstructorKind,
|
|
4316
|
+
Constructor: () => Constructor,
|
|
4317
|
+
ConditionalKind: () => ConditionalKind,
|
|
4318
|
+
ConditionalInstantiate: () => ConditionalInstantiate,
|
|
4319
|
+
ConditionalDeferred: () => ConditionalDeferred,
|
|
4320
|
+
Conditional: () => Conditional,
|
|
4321
|
+
Composite: () => Composite,
|
|
4322
|
+
Compare: () => Compare,
|
|
4323
|
+
CollapseToObject: () => CollapseToObject,
|
|
4324
|
+
Codec: () => Codec,
|
|
4325
|
+
Clone: () => Clone2,
|
|
4326
|
+
CapitalizeKind: () => CapitalizeKind,
|
|
4327
|
+
CapitalizeInstantiate: () => CapitalizeInstantiate,
|
|
4328
|
+
CapitalizeDeferred: () => CapitalizeDeferred,
|
|
4329
|
+
Capitalize: () => Capitalize,
|
|
4330
|
+
CallConstruct: () => CallConstruct,
|
|
4331
|
+
Call: () => Call,
|
|
4332
|
+
Broaden: () => Broaden,
|
|
4333
|
+
BooleanKind: () => BooleanKind,
|
|
4334
|
+
Boolean: () => Boolean,
|
|
4335
|
+
BigIntPattern: () => BigIntPattern,
|
|
4336
|
+
BigIntKind: () => BigIntKind,
|
|
4337
|
+
BigIntCodec: () => BigIntCodec,
|
|
4338
|
+
BigInt: () => BigInt,
|
|
4339
|
+
Base64Kind: () => Base64Kind,
|
|
4340
|
+
Base64: () => Base64,
|
|
4341
|
+
Base: () => Base,
|
|
4342
|
+
AwaitedKind: () => AwaitedKind,
|
|
4343
|
+
AwaitedInstantiate: () => AwaitedInstantiate,
|
|
4344
|
+
AwaitedDeferred: () => AwaitedDeferred,
|
|
4345
|
+
Awaited: () => Awaited,
|
|
4346
|
+
AsyncIteratorOptions: () => AsyncIteratorOptions,
|
|
4347
|
+
AsyncIteratorKind: () => AsyncIteratorKind,
|
|
4348
|
+
AsyncIterator: () => AsyncIterator,
|
|
4349
|
+
ArrayOptions: () => ArrayOptions,
|
|
4350
|
+
ArrayKind: () => ArrayKind,
|
|
4351
|
+
Array: () => Array2,
|
|
4352
|
+
AnyKind: () => AnyKind,
|
|
4353
|
+
Any: () => Any
|
|
4354
|
+
});
|
|
4355
|
+
export {
|
|
4356
|
+
_Object_,
|
|
4357
|
+
_Function_,
|
|
4358
|
+
VoidKind,
|
|
4359
|
+
Void,
|
|
4360
|
+
Variant,
|
|
4361
|
+
UuidKind,
|
|
4362
|
+
Uuid,
|
|
4363
|
+
UriKind,
|
|
4364
|
+
Uri,
|
|
4365
|
+
UppercaseKind,
|
|
4366
|
+
UppercaseInstantiate,
|
|
4367
|
+
UppercaseDeferred,
|
|
4368
|
+
Uppercase,
|
|
4369
|
+
UnsafeKind,
|
|
4370
|
+
Unsafe,
|
|
4371
|
+
UnknownKind,
|
|
4372
|
+
Unknown,
|
|
4373
|
+
UnionOptions,
|
|
4374
|
+
UnionKind,
|
|
4375
|
+
Union,
|
|
4376
|
+
UndefinedKind,
|
|
4377
|
+
Undefined,
|
|
4378
|
+
UncapitalizeKind,
|
|
4379
|
+
UncapitalizeInstantiate,
|
|
4380
|
+
UncapitalizeDeferred,
|
|
4381
|
+
Uncapitalize,
|
|
4382
|
+
Uint8ArrayKind,
|
|
4383
|
+
Uint8ArrayCodec,
|
|
4384
|
+
Uint8Array2 as Uint8Array,
|
|
4385
|
+
URLCodec,
|
|
4386
|
+
TypeScriptEnumToEnumValues,
|
|
4387
|
+
TupleOptions,
|
|
4388
|
+
TupleKind,
|
|
4389
|
+
Tuple,
|
|
4390
|
+
TimeKind,
|
|
4391
|
+
Time,
|
|
4392
|
+
This,
|
|
4393
|
+
TemplateLiteralKind,
|
|
4394
|
+
TemplateLiteralInstantiate,
|
|
4395
|
+
TemplateLiteralFromTypes,
|
|
4396
|
+
TemplateLiteralFromString,
|
|
4397
|
+
TemplateLiteralEncode,
|
|
4398
|
+
TemplateLiteralDeferred,
|
|
4399
|
+
TemplateLiteralDecodeUnsafe,
|
|
4400
|
+
TemplateLiteralDecode,
|
|
4401
|
+
TemplateLiteralCreate,
|
|
4402
|
+
TemplateLiteral,
|
|
4403
|
+
TemplateElementKind,
|
|
4404
|
+
SymbolKind,
|
|
4405
|
+
Symbol2 as Symbol,
|
|
4406
|
+
StringPattern,
|
|
4407
|
+
StringKind,
|
|
4408
|
+
StringKey,
|
|
4409
|
+
String2 as String,
|
|
4410
|
+
SelfKind,
|
|
4411
|
+
ScriptWithDefinitions,
|
|
4412
|
+
Script,
|
|
4413
|
+
ReturnTypeKind,
|
|
4414
|
+
ReturnTypeInstantiate,
|
|
4415
|
+
ReturnTypeDeferred,
|
|
4416
|
+
ReturnType,
|
|
4417
|
+
ResultRightInside,
|
|
4418
|
+
ResultLeftInside,
|
|
4419
|
+
ResultEqual,
|
|
4420
|
+
ResultDisjoint,
|
|
4421
|
+
RestKind,
|
|
4422
|
+
Rest,
|
|
4423
|
+
RequiredKind,
|
|
4424
|
+
RequiredInstantiate,
|
|
4425
|
+
RequiredDeferred,
|
|
4426
|
+
RequiredArray,
|
|
4427
|
+
Required,
|
|
4428
|
+
RegExpKind,
|
|
4429
|
+
RegExpInstance,
|
|
4430
|
+
RegExp2 as RegExp,
|
|
4431
|
+
RefineAdd,
|
|
4432
|
+
Refine,
|
|
4433
|
+
RefKind,
|
|
4434
|
+
RefInstantiate,
|
|
4435
|
+
Ref,
|
|
4436
|
+
RecursiveKind,
|
|
4437
|
+
Recursive,
|
|
4438
|
+
RecordValue,
|
|
4439
|
+
RecordPattern,
|
|
4440
|
+
RecordOptions,
|
|
4441
|
+
RecordKind,
|
|
4442
|
+
RecordPattern as RecordKeyAsPattern,
|
|
4443
|
+
RecordKey,
|
|
4444
|
+
RecordInstantiate,
|
|
4445
|
+
RecordFromPattern,
|
|
4446
|
+
RecordDeferred,
|
|
4447
|
+
RecordConstruct,
|
|
4448
|
+
Record,
|
|
4449
|
+
ReadonlyTypeInstantiate,
|
|
4450
|
+
ReadonlyTypeDeferred,
|
|
4451
|
+
ReadonlyType,
|
|
4452
|
+
ReadonlyRemoveAction,
|
|
4453
|
+
ReadonlyRemove,
|
|
4454
|
+
ReadonlyKind,
|
|
4455
|
+
ReadonlyAddAction,
|
|
4456
|
+
ReadonlyAdd,
|
|
4457
|
+
Readonly,
|
|
4458
|
+
PropertyValues,
|
|
4459
|
+
PropertyKeys,
|
|
4460
|
+
PromiseOptions,
|
|
4461
|
+
PromiseKind,
|
|
4462
|
+
Promise2 as Promise,
|
|
4463
|
+
PickKind,
|
|
4464
|
+
PickInstantiate,
|
|
4465
|
+
PickDeferred,
|
|
4466
|
+
Pick,
|
|
4467
|
+
PartialKind,
|
|
4468
|
+
PartialInstantiate,
|
|
4469
|
+
PartialDeferred,
|
|
4470
|
+
Partial,
|
|
4471
|
+
ParseTemplateIntoTypes,
|
|
4472
|
+
ParsePatternIntoTypes,
|
|
4473
|
+
ParametersKind,
|
|
4474
|
+
ParametersInstantiate,
|
|
4475
|
+
ParametersDeferred,
|
|
4476
|
+
Parameters,
|
|
4477
|
+
Parameter,
|
|
4478
|
+
OptionsInstantiate,
|
|
4479
|
+
OptionsDeferred,
|
|
4480
|
+
Options,
|
|
4481
|
+
OptionalRemoveAction,
|
|
4482
|
+
OptionalRemove,
|
|
4483
|
+
OptionalKind,
|
|
4484
|
+
OptionalAddAction,
|
|
4485
|
+
OptionalAdd,
|
|
4486
|
+
Optional,
|
|
4487
|
+
OmitKind,
|
|
4488
|
+
OmitInstantiate,
|
|
4489
|
+
OmitDeferred,
|
|
4490
|
+
Omit,
|
|
4491
|
+
ObjectOptions,
|
|
4492
|
+
ObjectKind,
|
|
4493
|
+
Object2 as Object,
|
|
4494
|
+
NumberPattern,
|
|
4495
|
+
NumberKind,
|
|
4496
|
+
NumberKey,
|
|
4497
|
+
Number2 as Number,
|
|
4498
|
+
NullKind,
|
|
4499
|
+
Null,
|
|
4500
|
+
NotKind,
|
|
4501
|
+
Not,
|
|
4502
|
+
NonNullableInstantiate,
|
|
4503
|
+
NonNullableDeferred,
|
|
4504
|
+
NonNullable,
|
|
4505
|
+
NeverPattern,
|
|
4506
|
+
NeverKind,
|
|
4507
|
+
Never,
|
|
4508
|
+
Narrow,
|
|
4509
|
+
ModuleKind,
|
|
4510
|
+
ModuleInstantiate,
|
|
4511
|
+
ModuleDeferred,
|
|
4512
|
+
Module,
|
|
4513
|
+
MappedKind,
|
|
4514
|
+
MappedInstantiate,
|
|
4515
|
+
MappedDeferred,
|
|
4516
|
+
Mapped,
|
|
4517
|
+
LowercaseKind,
|
|
4518
|
+
LowercaseInstantiate,
|
|
4519
|
+
LowercaseDeferred,
|
|
4520
|
+
Lowercase,
|
|
4521
|
+
LiteralTypeName,
|
|
4522
|
+
LiteralKind,
|
|
4523
|
+
Literal,
|
|
4524
|
+
KeysToIndexer,
|
|
4525
|
+
KeyOfKind,
|
|
4526
|
+
KeyOfInstantiate,
|
|
4527
|
+
KeyOfImmediate,
|
|
4528
|
+
KeyOfDeferred,
|
|
4529
|
+
KeyOfAction,
|
|
4530
|
+
KeyOf,
|
|
4531
|
+
JsonKind,
|
|
4532
|
+
Json,
|
|
4533
|
+
IteratorOptions,
|
|
4534
|
+
IteratorKind,
|
|
4535
|
+
Iterator,
|
|
4536
|
+
IsVoid,
|
|
4537
|
+
IsUppercase,
|
|
4538
|
+
IsUnsafe,
|
|
4539
|
+
IsUnknown,
|
|
4540
|
+
IsUnion,
|
|
4541
|
+
IsUndefined,
|
|
4542
|
+
IsUncapitalize,
|
|
4543
|
+
IsUint8Array,
|
|
4544
|
+
IsTypeScriptEnumLike,
|
|
4545
|
+
IsTuple,
|
|
4546
|
+
IsThis,
|
|
4547
|
+
IsTemplateLiteralPattern,
|
|
4548
|
+
IsTemplateLiteralFinite,
|
|
4549
|
+
IsTemplateLiteral,
|
|
4550
|
+
IsSymbol,
|
|
4551
|
+
IsString,
|
|
4552
|
+
IsSchema,
|
|
4553
|
+
IsReturnType,
|
|
4554
|
+
IsRest,
|
|
4555
|
+
IsRequired,
|
|
4556
|
+
IsRegExpInstance,
|
|
4557
|
+
IsRefine,
|
|
4558
|
+
IsRef,
|
|
4559
|
+
IsRecursive,
|
|
4560
|
+
IsRecord,
|
|
4561
|
+
IsReadonlyType,
|
|
4562
|
+
IsReadonlyRemoveAction,
|
|
4563
|
+
IsReadonlyAddAction,
|
|
4564
|
+
IsReadonly,
|
|
4565
|
+
IsPromise,
|
|
4566
|
+
IsPick,
|
|
4567
|
+
IsPartial,
|
|
4568
|
+
IsParameters,
|
|
4569
|
+
IsParameter,
|
|
4570
|
+
IsOptions,
|
|
4571
|
+
IsOptionalRemoveAction,
|
|
4572
|
+
IsOptionalAddAction,
|
|
4573
|
+
IsOptional,
|
|
4574
|
+
IsOmit,
|
|
4575
|
+
IsObject,
|
|
4576
|
+
IsNumber,
|
|
4577
|
+
IsNull,
|
|
4578
|
+
IsNot,
|
|
4579
|
+
IsNonNullable,
|
|
4580
|
+
IsNever,
|
|
4581
|
+
IsModule,
|
|
4582
|
+
IsMapped,
|
|
4583
|
+
IsLowercase,
|
|
4584
|
+
IsLiteralValue,
|
|
4585
|
+
IsLiteralString,
|
|
4586
|
+
IsLiteralNumber,
|
|
4587
|
+
IsLiteralBoolean,
|
|
4588
|
+
IsLiteralBigInt,
|
|
4589
|
+
IsLiteral,
|
|
4590
|
+
IsKind,
|
|
4591
|
+
IsKeyOf,
|
|
4592
|
+
IsIterator,
|
|
4593
|
+
IsIntersect,
|
|
4594
|
+
IsInterfaceDeferred,
|
|
4595
|
+
IsInterface,
|
|
4596
|
+
IsInteger,
|
|
4597
|
+
IsInstanceType,
|
|
4598
|
+
IsInfer,
|
|
4599
|
+
IsIndex,
|
|
4600
|
+
IsImmutable,
|
|
4601
|
+
IsIfThenElse,
|
|
4602
|
+
IsIdentifier,
|
|
4603
|
+
IsGeneric,
|
|
4604
|
+
IsFunction,
|
|
4605
|
+
IsExtract,
|
|
4606
|
+
IsExclude,
|
|
4607
|
+
IsEnum,
|
|
4608
|
+
IsEncode,
|
|
4609
|
+
IsDeferred,
|
|
4610
|
+
IsDecode,
|
|
4611
|
+
IsDate,
|
|
4612
|
+
IsCyclic,
|
|
4613
|
+
IsConstructorParameters,
|
|
4614
|
+
IsConstructor,
|
|
4615
|
+
IsConditional,
|
|
4616
|
+
IsCodec,
|
|
4617
|
+
IsCapitalize,
|
|
4618
|
+
IsCall,
|
|
4619
|
+
IsBoolean,
|
|
4620
|
+
IsBigInt,
|
|
4621
|
+
IsBase,
|
|
4622
|
+
IsAwaited,
|
|
4623
|
+
IsAsyncIterator,
|
|
4624
|
+
IsArray,
|
|
4625
|
+
IsAny,
|
|
4626
|
+
IpKind,
|
|
4627
|
+
Ip,
|
|
4628
|
+
InvalidLiteralValue,
|
|
4629
|
+
IntersectOptions,
|
|
4630
|
+
IntersectKind,
|
|
4631
|
+
Intersect,
|
|
4632
|
+
InterfaceInstantiate,
|
|
4633
|
+
InterfaceDeferred,
|
|
4634
|
+
Interface,
|
|
4635
|
+
IntegerPattern,
|
|
4636
|
+
IntegerKind,
|
|
4637
|
+
IntegerKey,
|
|
4638
|
+
Integer,
|
|
4639
|
+
InstantiateCyclic,
|
|
4640
|
+
Instantiate,
|
|
4641
|
+
InstanceTypeKind,
|
|
4642
|
+
InstanceTypeInstantiate,
|
|
4643
|
+
InstanceTypeImmediate,
|
|
4644
|
+
InstanceTypeDeferred,
|
|
4645
|
+
InstanceType,
|
|
4646
|
+
Infer,
|
|
4647
|
+
IndexKind,
|
|
4648
|
+
IndexInstantiate,
|
|
4649
|
+
IndexDeferred,
|
|
4650
|
+
Index,
|
|
4651
|
+
Import,
|
|
4652
|
+
ImmutableRemove,
|
|
4653
|
+
ImmutableAdd,
|
|
4654
|
+
Immutable,
|
|
4655
|
+
IfThenElseKind,
|
|
4656
|
+
IfThenElse,
|
|
4657
|
+
Identifier,
|
|
4658
|
+
HostnameKind,
|
|
4659
|
+
Hostname,
|
|
4660
|
+
HexKind,
|
|
4661
|
+
HexColorKind,
|
|
4662
|
+
HexColor,
|
|
4663
|
+
Hex,
|
|
4664
|
+
Generic,
|
|
4665
|
+
FunctionOptions,
|
|
4666
|
+
FunctionKind,
|
|
4667
|
+
Function,
|
|
4668
|
+
Flatten,
|
|
4669
|
+
ExtractKind,
|
|
4670
|
+
ExtractInstantiate,
|
|
4671
|
+
ExtractDeferred,
|
|
4672
|
+
Extract,
|
|
4673
|
+
ExtendsResult,
|
|
4674
|
+
Extends,
|
|
4675
|
+
ExcludeKind,
|
|
4676
|
+
ExcludeInstantiate,
|
|
4677
|
+
ExcludeDeferred,
|
|
4678
|
+
Exclude,
|
|
4679
|
+
EvaluateUnionFast,
|
|
4680
|
+
EvaluateUnion,
|
|
4681
|
+
EvaluateType,
|
|
4682
|
+
EvaluateIntersect,
|
|
4683
|
+
EvaluateInstantiate,
|
|
4684
|
+
EvaluateDeferred,
|
|
4685
|
+
Evaluate,
|
|
4686
|
+
EnumValuesToVariants,
|
|
4687
|
+
EnumValuesToUnion,
|
|
4688
|
+
EnumToUnion,
|
|
4689
|
+
EnumKind,
|
|
4690
|
+
Enum,
|
|
4691
|
+
EncodeKind,
|
|
4692
|
+
EncodeBuilder,
|
|
4693
|
+
Encode,
|
|
4694
|
+
EmailKind,
|
|
4695
|
+
Email,
|
|
4696
|
+
DurationKind,
|
|
4697
|
+
Duration,
|
|
4698
|
+
Distribute,
|
|
4699
|
+
Deferred,
|
|
4700
|
+
DecodeKind,
|
|
4701
|
+
DecodeBuilder,
|
|
4702
|
+
Decode,
|
|
4703
|
+
DateTimeKind,
|
|
4704
|
+
DateTime,
|
|
4705
|
+
DateKind,
|
|
4706
|
+
DateFormatKind,
|
|
4707
|
+
DateFormat,
|
|
4708
|
+
DateCodec,
|
|
4709
|
+
Date,
|
|
4710
|
+
CyclicTarget,
|
|
4711
|
+
CyclicOptions,
|
|
4712
|
+
CyclicExtends,
|
|
4713
|
+
CyclicDependencies,
|
|
4714
|
+
CyclicCheck,
|
|
4715
|
+
CyclicCandidates,
|
|
4716
|
+
Cyclic,
|
|
4717
|
+
CreditCardKind,
|
|
4718
|
+
CreditCard,
|
|
4719
|
+
ConvertToIntegerKey,
|
|
4720
|
+
ConstructorParametersKind,
|
|
4721
|
+
ConstructorParametersInstantiate,
|
|
4722
|
+
ConstructorParametersDeferred,
|
|
4723
|
+
ConstructorParameters,
|
|
4724
|
+
ConstructorOptions,
|
|
4725
|
+
ConstructorKind,
|
|
4726
|
+
Constructor,
|
|
4727
|
+
ConditionalKind,
|
|
4728
|
+
ConditionalInstantiate,
|
|
4729
|
+
ConditionalDeferred,
|
|
4730
|
+
Conditional,
|
|
4731
|
+
Composite,
|
|
4732
|
+
Compare,
|
|
4733
|
+
CollapseToObject,
|
|
4734
|
+
Codec,
|
|
4735
|
+
Clone2 as Clone,
|
|
4736
|
+
CapitalizeKind,
|
|
4737
|
+
CapitalizeInstantiate,
|
|
4738
|
+
CapitalizeDeferred,
|
|
4739
|
+
Capitalize,
|
|
4740
|
+
CallConstruct,
|
|
4741
|
+
Call,
|
|
4742
|
+
Broaden,
|
|
4743
|
+
BooleanKind,
|
|
4744
|
+
Boolean,
|
|
4745
|
+
BigIntPattern,
|
|
4746
|
+
BigIntKind,
|
|
4747
|
+
BigIntCodec,
|
|
4748
|
+
BigInt,
|
|
4749
|
+
Base64Kind,
|
|
4750
|
+
Base64,
|
|
4751
|
+
Base,
|
|
4752
|
+
AwaitedKind,
|
|
4753
|
+
AwaitedInstantiate,
|
|
4754
|
+
AwaitedDeferred,
|
|
4755
|
+
Awaited,
|
|
4756
|
+
AsyncIteratorOptions,
|
|
4757
|
+
AsyncIteratorKind,
|
|
4758
|
+
AsyncIterator,
|
|
4759
|
+
ArrayOptions,
|
|
4760
|
+
ArrayKind,
|
|
4761
|
+
Array2 as Array,
|
|
4762
|
+
AnyKind,
|
|
4763
|
+
Any
|
|
4764
|
+
};
|
|
4765
|
+
|
|
4766
|
+
//# debugId=5A7E3CC9B970AD7064756E2164756E21
|
|
4767
|
+
//# sourceMappingURL=typebox.js.map
|