clanka 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentExecutor.d.ts.map +1 -1
- package/dist/AgentExecutor.js +1 -1
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.d.ts +2 -0
- package/dist/AgentExecutor.test.d.ts.map +1 -0
- package/dist/AgentExecutor.test.js +87 -0
- package/dist/AgentExecutor.test.js.map +1 -0
- package/dist/AgentSkills.test.js +1 -0
- package/dist/AgentSkills.test.js.map +1 -1
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +2 -1
- package/dist/AgentTools.js.map +1 -1
- package/dist/Compaction.test.js +1 -0
- package/dist/Compaction.test.js.map +1 -1
- package/dist/bin/{Effect-BCeySOy1.mjs → Effect-BEUn4I5E.mjs} +339 -288
- package/dist/bin/Effect-BEUn4I5E.mjs.map +1 -0
- package/dist/bin/{McpClient-DP4jlaD1.mjs → McpClient-C0FVuDj2.mjs} +218 -62
- package/dist/bin/McpClient-C0FVuDj2.mjs.map +1 -0
- package/dist/bin/{OutputFormatter-Ch8yFytV.mjs → OutputFormatter-DffD5oxX.mjs} +8 -8
- package/dist/bin/OutputFormatter-DffD5oxX.mjs.map +1 -0
- package/dist/bin/{Schema-C9JQ5hI0.mjs → Schema-CjUGw2Xh.mjs} +480 -384
- package/dist/bin/Schema-CjUGw2Xh.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-BJGnYhFt.mjs → SemanticSearch-CFB73IPb.mjs} +321 -268
- package/dist/bin/SemanticSearch-CFB73IPb.mjs.map +1 -0
- package/dist/bin/{Stream-CgH3SuLu.mjs → Stream-Cu6P7ZHo.mjs} +180 -172
- package/dist/bin/Stream-Cu6P7ZHo.mjs.map +1 -0
- package/dist/bin/cli.mjs +306 -259
- package/dist/bin/cli.mjs.map +1 -1
- package/package.json +20 -20
- package/src/AgentExecutor.test.ts +133 -0
- package/src/AgentExecutor.ts +1 -2
- package/src/AgentSkills.test.ts +1 -0
- package/src/AgentTools.ts +2 -1
- package/src/Compaction.test.ts +1 -0
- package/dist/bin/Effect-BCeySOy1.mjs.map +0 -1
- package/dist/bin/McpClient-DP4jlaD1.mjs.map +0 -1
- package/dist/bin/OutputFormatter-Ch8yFytV.mjs.map +0 -1
- package/dist/bin/Schema-C9JQ5hI0.mjs.map +0 -1
- package/dist/bin/SemanticSearch-BJGnYhFt.mjs.map +0 -1
- package/dist/bin/Stream-CgH3SuLu.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $a as
|
|
2
|
-
//#region node_modules/.pnpm/effect@
|
|
1
|
+
import { $a as liftThrowable, Ao as assignProperties, As as memoize, Bi as fromIterable$1, Bn as fromReasons, Bo as formatJson, Br as isSuccess, Ca as toSeconds, Co as TaggedError$2, Ds as dual, F as failCauseSync, Fi as empty$2, Fn as die$1, Fr as fail$3, Fs as pipeArguments, Gn as isFailReason, H as fnUntracedEager, Ha as flatten, Hi as isArrayNonEmpty, Ho as formatPropertyKey, Hr as void_$1, Ht as succeed$3, Io as NodeInspectSymbol, Ir as failCause, It as runSyncExit, Ji as map$3, Jn as makeDieReason, Jo as array, Kn as isReason, Ko as equals, L as flatMap, M as exit, Mo as getStackTraceLimit, N as fail$2, Ni as append, No as setStackTraceLimit, Ns as Class$2, Po as BaseProto, Ps as Prototype, Qa as isSome, Qo as string$1, R as flatMapEager, Ro as format$1, Rr as isExit, Si as resolveConcurrency, So as PipeInspectableProto, Ua as fromNullOr, Ur as ClockRef, Ut as succeedNone, Vo as formatPath, Vr as succeed$2, Wi as isReadonlyArrayNonEmpty, Wn as isCause, Wt as suspend, Xa as isNone, Xn as makeInterruptReason, Xo as hash, Xr as currentTimeMillis$1, Xt as tryPromise, Y as fromResult, Yn as makeFailReason, Yo as combine, Za as isOption, Zn as map$5, Zo as number$1, Zr as effectIsExit, Zt as try_, _a as millis, _o as make$8, _s as isString, ao as some, as as isFunction, ba as negativeInfinity, bs as isUnknown, ca as match$1, co as Date$3, ct as mapBothEager, do as isGreaterThan$1, dt as mapErrorEager, eo as map$4, es as symbol, fa as fromInputUnsafe, fo as isGreaterThanOrEqualTo$1, go as Tuple$1, gs as isPropertyKey, ha as isFinite$2, ho as make$9, hs as isObjectKeyword, in as void_$2, is as isError, jo as assignProperty$1, js as memoizeIdempotent, k as die, kn as IllegalArgumentError, ks as identity, la as succeed$1, lo as Number$4, ls as isNotNullish, lt as mapEager, m as catchCause, ma as isDuration, mi as iterateEager, mo as isLessThanOrEqualTo$1, ms as isObject, no as none, ns as isBigInt, pa as infinity, pi as iterateConcurrent, po as isLessThan$1, ps as isNumber, qa as getOrNull, qi as makeEquivalence$3, qo as symbol$1, ra as getOrThrow, rs as isBoolean, so as BigInt$4, ss as isNever$1, ta as fail$1, to as match, ts as hasProperty, uo as String$4, us as isNotUndefined, vi as map$2, vo as strictEqual, vs as isTagged, wo as args, xa as seconds, xo as Error$3, ya as nanos, yi as monotonicTimeNanos$1, za as filter, zo as formatDate } from "./Effect-BEUn4I5E.mjs";
|
|
2
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Tuple.js
|
|
3
3
|
const makeEquivalence$2 = Tuple$1;
|
|
4
4
|
//#endregion
|
|
5
|
-
//#region node_modules/.pnpm/effect@
|
|
5
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Record.js
|
|
6
6
|
const has = dual(2, (self, key) => Object.hasOwn(self, key));
|
|
7
7
|
const map$1 = dual(2, (self, f) => {
|
|
8
8
|
const out = { ...self };
|
|
@@ -20,7 +20,7 @@ const makeEquivalence$1 = (equivalence) => {
|
|
|
20
20
|
return (self, that) => is(self, that) && is(that, self);
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region node_modules/.pnpm/effect@
|
|
23
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Data.js
|
|
24
24
|
const Class$1 = class extends Class$2 {
|
|
25
25
|
constructor(props) {
|
|
26
26
|
super();
|
|
@@ -51,17 +51,18 @@ function taggedMatch() {
|
|
|
51
51
|
const Error$2 = Error$3;
|
|
52
52
|
const TaggedError$1 = TaggedError$2;
|
|
53
53
|
//#endregion
|
|
54
|
-
//#region node_modules/.pnpm/effect@
|
|
54
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/encoding/EncodingError.js
|
|
55
55
|
const EncodingErrorTypeId = "~effect/encoding/EncodingError";
|
|
56
56
|
var EncodingError = class extends TaggedError$1("EncodingError") {
|
|
57
57
|
[EncodingErrorTypeId] = EncodingErrorTypeId;
|
|
58
58
|
};
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region node_modules/.pnpm/effect@
|
|
60
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Clock.js
|
|
61
61
|
const Clock = ClockRef;
|
|
62
62
|
const currentTimeMillis = currentTimeMillis$1;
|
|
63
|
+
const monotonicTimeNanos = monotonicTimeNanos$1;
|
|
63
64
|
//#endregion
|
|
64
|
-
//#region node_modules/.pnpm/effect@
|
|
65
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/dateTime.js
|
|
65
66
|
const TypeId$9 = "~effect/DateTime";
|
|
66
67
|
const TimeZoneTypeId = "~effect/DateTime/TimeZone";
|
|
67
68
|
const Proto$3 = {
|
|
@@ -189,7 +190,7 @@ const toDate = (self) => {
|
|
|
189
190
|
const parts = self.zone.format.formatToParts(self.epochMilliseconds).filter((_) => _.type !== "literal");
|
|
190
191
|
const date = new Date(0);
|
|
191
192
|
date.setUTCFullYear(Number(parts[2].value), Number(parts[0].value) - 1, Number(parts[1].value));
|
|
192
|
-
date.setUTCHours(Number(parts[3].value), Number(parts[4].value), Number(parts[5].value), Number(parts[6].value));
|
|
193
|
+
date.setUTCHours(Number(parts[3].value), Number(parts[4].value), Number(parts[5].value), parts[6]?.type === "fractionalSecond" ? Number(parts[6].value) : (self.epochMilliseconds % 1e3 + 1e3) % 1e3);
|
|
193
194
|
self.adjustedEpochMilliseconds = date.getTime();
|
|
194
195
|
return date;
|
|
195
196
|
};
|
|
@@ -232,7 +233,7 @@ const formatIsoOffset = (self) => {
|
|
|
232
233
|
};
|
|
233
234
|
const formatIsoZoned = (self) => self.zone._tag === "Offset" ? formatIsoOffset(self) : `${formatIsoOffset(self)}[${self.zone.id}]`;
|
|
234
235
|
//#endregion
|
|
235
|
-
//#region node_modules/.pnpm/effect@
|
|
236
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/redacted.js
|
|
236
237
|
const redactedRegistry = new WeakMap();
|
|
237
238
|
const value$1 = (self) => {
|
|
238
239
|
if (redactedRegistry.has(self)) return redactedRegistry.get(self);
|
|
@@ -240,7 +241,7 @@ const value$1 = (self) => {
|
|
|
240
241
|
};
|
|
241
242
|
const stringOrRedacted = (val) => typeof val === "string" ? val : value$1(val);
|
|
242
243
|
//#endregion
|
|
243
|
-
//#region node_modules/.pnpm/effect@
|
|
244
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Redacted.js
|
|
244
245
|
const TypeId$8 = "~effect/Redacted";
|
|
245
246
|
const isRedacted = (u) => hasProperty(u, TypeId$8);
|
|
246
247
|
const make$6 = (value, options) => {
|
|
@@ -269,7 +270,7 @@ const Proto$2 = {
|
|
|
269
270
|
const value = value$1;
|
|
270
271
|
const makeEquivalence = (isEquivalent) => make$8((x, y) => isEquivalent(value(x), value(y)));
|
|
271
272
|
//#endregion
|
|
272
|
-
//#region node_modules/.pnpm/effect@
|
|
273
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/BigDecimal.js
|
|
273
274
|
const TypeId$7 = "~effect/BigDecimal";
|
|
274
275
|
const BigDecimalProto = {
|
|
275
276
|
[TypeId$7]: TypeId$7,
|
|
@@ -373,7 +374,7 @@ const toExponential = (n) => {
|
|
|
373
374
|
};
|
|
374
375
|
const isZero = (n) => n.value === bigint0;
|
|
375
376
|
//#endregion
|
|
376
|
-
//#region node_modules/.pnpm/effect@
|
|
377
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/DateTime.js
|
|
377
378
|
const isDateTime = isDateTime$1;
|
|
378
379
|
const isUtc = isUtc$1;
|
|
379
380
|
const fromDateUnsafe = fromDateUnsafe$1;
|
|
@@ -387,7 +388,7 @@ const removeTime = removeTime$1;
|
|
|
387
388
|
const formatIso = formatIso$1;
|
|
388
389
|
const formatIsoDate = formatIsoDate$1;
|
|
389
390
|
//#endregion
|
|
390
|
-
//#region node_modules/.pnpm/effect@
|
|
391
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/encoding/Base64.js
|
|
391
392
|
const encode = (input) => encodeBytes(typeof input === "string" ? encoder.encode(input) : input);
|
|
392
393
|
const decode = (str) => {
|
|
393
394
|
const stripped = stripCrlf(str);
|
|
@@ -458,7 +459,7 @@ const getCode = (charCode) => {
|
|
|
458
459
|
return codes[charCode];
|
|
459
460
|
};
|
|
460
461
|
//#endregion
|
|
461
|
-
//#region node_modules/.pnpm/effect@
|
|
462
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/http/Cookies.js
|
|
462
463
|
const TypeId$6 = "~effect/http/Cookies";
|
|
463
464
|
const isCookies = (u) => hasProperty(u, TypeId$6);
|
|
464
465
|
const CookieTypeId = "~effect/http/Cookies/Cookie";
|
|
@@ -683,7 +684,7 @@ const tryDecodeURIComponent = (str) => {
|
|
|
683
684
|
}
|
|
684
685
|
};
|
|
685
686
|
//#endregion
|
|
686
|
-
//#region node_modules/.pnpm/effect@
|
|
687
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/http/UrlParams.js
|
|
687
688
|
const TypeId$5 = "~effect/http/UrlParams";
|
|
688
689
|
const isUrlParams = (u) => hasProperty(u, TypeId$5);
|
|
689
690
|
const Proto = {
|
|
@@ -757,7 +758,7 @@ const toRecord = (self) => {
|
|
|
757
758
|
};
|
|
758
759
|
const toReadonlyRecord = toRecord;
|
|
759
760
|
//#endregion
|
|
760
|
-
//#region node_modules/.pnpm/effect@
|
|
761
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/annotations.js
|
|
761
762
|
function resolve$1(ast) {
|
|
762
763
|
return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
|
|
763
764
|
}
|
|
@@ -783,7 +784,6 @@ const jsonSchemaAnnotationKeys = [
|
|
|
783
784
|
const resolveIdentifier$1 = resolveAt$1("identifier");
|
|
784
785
|
const resolveIdentifierFallback = resolveAt$1(IDENTIFIER_FALLBACK_KEY);
|
|
785
786
|
const resolveDescription$1 = resolveAt$1("description");
|
|
786
|
-
const resolveBrands = resolveAt$1("brands");
|
|
787
787
|
const getExpected = memoize((ast) => {
|
|
788
788
|
const identifier = resolve$1(ast)?.identifier;
|
|
789
789
|
if (typeof identifier === "string") return identifier;
|
|
@@ -794,7 +794,6 @@ const annotationExcludedKeys = new Set([
|
|
|
794
794
|
STRUCTURAL_ANNOTATION_KEY,
|
|
795
795
|
"representation",
|
|
796
796
|
"arbitraryConstraint",
|
|
797
|
-
"brands",
|
|
798
797
|
"toJsonSchema",
|
|
799
798
|
"toCode",
|
|
800
799
|
"toEquivalence",
|
|
@@ -806,7 +805,7 @@ const annotationExcludedKeys = new Set([
|
|
|
806
805
|
"toCodecArbitrary"
|
|
807
806
|
]);
|
|
808
807
|
//#endregion
|
|
809
|
-
//#region node_modules/.pnpm/effect@
|
|
808
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/parser.js
|
|
810
809
|
const missing = Symbol();
|
|
811
810
|
const succeed = succeed$2;
|
|
812
811
|
const missingExit = succeed(missing);
|
|
@@ -814,7 +813,7 @@ const sameExit = succeed(missing);
|
|
|
814
813
|
const toOption = (value) => value === missing ? none() : some(value);
|
|
815
814
|
const fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed(option.value);
|
|
816
815
|
//#endregion
|
|
817
|
-
//#region node_modules/.pnpm/effect@
|
|
816
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/SchemaIssue.js
|
|
818
817
|
const TypeId$4 = "~effect/SchemaIssue/Issue";
|
|
819
818
|
function isIssue(u) {
|
|
820
819
|
return hasProperty(u, TypeId$4) && u[TypeId$4] === TypeId$4;
|
|
@@ -1027,7 +1026,7 @@ function findMessage(issue) {
|
|
|
1027
1026
|
if (typeof message === "string") return message;
|
|
1028
1027
|
}
|
|
1029
1028
|
//#endregion
|
|
1030
|
-
//#region node_modules/.pnpm/effect@
|
|
1029
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/cause.js
|
|
1031
1030
|
function getSchemaIssue(cause) {
|
|
1032
1031
|
let issue;
|
|
1033
1032
|
for (const reason of cause.reasons) {
|
|
@@ -1042,7 +1041,7 @@ function getSchemaIssueOrThrow(cause, message) {
|
|
|
1042
1041
|
return issue;
|
|
1043
1042
|
}
|
|
1044
1043
|
//#endregion
|
|
1045
|
-
//#region node_modules/.pnpm/effect@
|
|
1044
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/SchemaGetter.js
|
|
1046
1045
|
const runGetter = (self, input, options) => {
|
|
1047
1046
|
switch (self._tag) {
|
|
1048
1047
|
case "Passthrough": return succeed$3(input);
|
|
@@ -1170,7 +1169,7 @@ function dateTimeUtcFromInput$1() {
|
|
|
1170
1169
|
});
|
|
1171
1170
|
}
|
|
1172
1171
|
//#endregion
|
|
1173
|
-
//#region node_modules/.pnpm/effect@
|
|
1172
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/SchemaTransformation.js
|
|
1174
1173
|
const Middleware = class extends Class$2 {
|
|
1175
1174
|
_tag = "Middleware";
|
|
1176
1175
|
decode;
|
|
@@ -1286,7 +1285,7 @@ function fromJsonString$1(options) {
|
|
|
1286
1285
|
return new Transformation(parseJson(options ?? {}), stringifyJson(options));
|
|
1287
1286
|
}
|
|
1288
1287
|
//#endregion
|
|
1289
|
-
//#region node_modules/.pnpm/effect@
|
|
1288
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/SchemaAST.js
|
|
1290
1289
|
function makeGuard(tag) {
|
|
1291
1290
|
return (ast) => ast._tag === tag;
|
|
1292
1291
|
}
|
|
@@ -1573,19 +1572,20 @@ const Arrays = class extends ASTNodeImpl {
|
|
|
1573
1572
|
else if (index >= tailThreshold) return rest[index - tailThreshold + 1];
|
|
1574
1573
|
return rest[0];
|
|
1575
1574
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
if (
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
ast,
|
|
1586
|
-
parser: compileField(ast)
|
|
1587
|
-
}));
|
|
1575
|
+
const finish = (state) => {
|
|
1576
|
+
const { input, len, options } = state;
|
|
1577
|
+
if (ast.rest.length === 0 && len > elementLen) for (let i = elementLen; i < len; i++) {
|
|
1578
|
+
const unexpected = new UnexpectedKey(ast, input[i], options);
|
|
1579
|
+
const issue = new Pointer([i], unexpected);
|
|
1580
|
+
if (options.errors === "all") {
|
|
1581
|
+
if (state.issues) state.issues.push(issue);
|
|
1582
|
+
else state.issues = [issue];
|
|
1583
|
+
} else return fail$2(new Composite(ast, [issue], input, options));
|
|
1588
1584
|
}
|
|
1585
|
+
if (state.issues) return fail$2(new Composite(ast, state.issues, input, options));
|
|
1586
|
+
return succeed(state.output);
|
|
1587
|
+
};
|
|
1588
|
+
const parse = (input, options) => {
|
|
1589
1589
|
const len = input.length;
|
|
1590
1590
|
const state = {
|
|
1591
1591
|
ast,
|
|
@@ -1603,18 +1603,34 @@ const Arrays = class extends ASTNodeImpl {
|
|
|
1603
1603
|
concurrency,
|
|
1604
1604
|
end
|
|
1605
1605
|
});
|
|
1606
|
-
if (eff)
|
|
1607
|
-
if (
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
if (
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1606
|
+
if (!eff) return finish(state);
|
|
1607
|
+
if (effectIsExit(eff)) return flatMapEager(eff, () => finish(state));
|
|
1608
|
+
let first = true;
|
|
1609
|
+
return suspend(() => {
|
|
1610
|
+
if (!first) return parse(input, options);
|
|
1611
|
+
first = false;
|
|
1612
|
+
return flatMap(eff, () => finish(state));
|
|
1613
|
+
});
|
|
1614
|
+
};
|
|
1615
|
+
return (input, options) => {
|
|
1616
|
+
if (input === missing) return missingExit;
|
|
1617
|
+
try {
|
|
1618
|
+
if (!Array.isArray(input)) return fail$2(new InvalidType(ast, input, options));
|
|
1619
|
+
if (!elements) {
|
|
1620
|
+
elements = ast.elements.map((ast) => ({
|
|
1621
|
+
ast,
|
|
1622
|
+
parser: compileField(ast)
|
|
1623
|
+
}));
|
|
1624
|
+
rest = ast.rest.map((ast) => ({
|
|
1625
|
+
ast,
|
|
1626
|
+
parser: compileField(ast)
|
|
1627
|
+
}));
|
|
1628
|
+
}
|
|
1629
|
+
return parse(input, options);
|
|
1630
|
+
} catch (error) {
|
|
1631
|
+
return die(error);
|
|
1614
1632
|
}
|
|
1615
|
-
|
|
1616
|
-
return state.output;
|
|
1617
|
-
});
|
|
1633
|
+
};
|
|
1618
1634
|
}
|
|
1619
1635
|
_rebuild(recur, checks, encodingChecks) {
|
|
1620
1636
|
const elements = mapOrSame(this.elements, recur);
|
|
@@ -1673,7 +1689,7 @@ function getIndexSignatureKeys(input, parameter, options = defaultParseOptions)
|
|
|
1673
1689
|
case "String":
|
|
1674
1690
|
case "TemplateLiteral": return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchPart(k, options) !== void 0);
|
|
1675
1691
|
case "Number": return (stringKeys ??= Object.keys(input)).filter((k) => parameter.matchKey(k, options) !== void 0);
|
|
1676
|
-
case "Symbol": return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => parameter.matchKey(k, options) !== void 0);
|
|
1692
|
+
case "Symbol": return (symbolKeys ??= Object.getOwnPropertySymbols(input)).filter((k) => Object.prototype.propertyIsEnumerable.call(input, k) && parameter.matchKey(k, options) !== void 0);
|
|
1677
1693
|
case "Union": return [...new Set(parameter.types.flatMap(go))];
|
|
1678
1694
|
default: return [];
|
|
1679
1695
|
}
|
|
@@ -1732,55 +1748,14 @@ const Objects = class extends ASTNodeImpl {
|
|
|
1732
1748
|
this.propertySignatures = propertySignatures;
|
|
1733
1749
|
this.indexSignatures = indexSignatures;
|
|
1734
1750
|
this.encodingChecks = encodingChecks;
|
|
1735
|
-
const seen = new Set();
|
|
1736
|
-
const duplicates = [];
|
|
1737
|
-
for (const propertySignature of propertySignatures) {
|
|
1738
|
-
const name = propertySignature.name;
|
|
1739
|
-
if (seen.has(name)) duplicates.push(name);
|
|
1740
|
-
else seen.add(name);
|
|
1741
|
-
}
|
|
1742
|
-
if (duplicates.length > 0) throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`);
|
|
1743
1751
|
}
|
|
1744
1752
|
getParser(compile, compileField = compile) {
|
|
1745
1753
|
const ast = this;
|
|
1746
|
-
const
|
|
1747
|
-
for (const ps of ast.propertySignatures) expectedKeys.push(typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name);
|
|
1748
|
-
const hasProperties = expectedKeys.length;
|
|
1754
|
+
const hasProperties = ast.propertySignatures.length;
|
|
1749
1755
|
const indexCount = ast.indexSignatures.length;
|
|
1750
|
-
let expectedKeysSet = hasProperties && indexCount ? new Set(expectedKeys) : void 0;
|
|
1751
1756
|
if (!hasProperties && !indexCount) return fromRefinement(ast, isNotNullish);
|
|
1752
1757
|
let properties;
|
|
1753
1758
|
let indexes;
|
|
1754
|
-
const finishIndex = (s, key, k2, inputValue, exitValue) => {
|
|
1755
|
-
if (exitValue._tag === "Failure") return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_$1;
|
|
1756
|
-
const value = exitValue === sameExit ? inputValue : exitValue[args];
|
|
1757
|
-
if (k2 !== missing && value !== missing) {
|
|
1758
|
-
if (hasProperties && (expectedKeysSet.has(key) || expectedKeysSet.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) return void_$1;
|
|
1759
|
-
assignProperty$1(s.out, k2, value);
|
|
1760
|
-
}
|
|
1761
|
-
return void_$1;
|
|
1762
|
-
};
|
|
1763
|
-
const parseIndex = (s, key, index, exitKey) => {
|
|
1764
|
-
if (!exitKey) {
|
|
1765
|
-
const eff = index.parserKey(key, s.options);
|
|
1766
|
-
if (!effectIsExit(eff)) return flatMap(exit(eff), (exit) => parseIndex(s, key, index, exit));
|
|
1767
|
-
exitKey = eff;
|
|
1768
|
-
}
|
|
1769
|
-
if (exitKey._tag === "Failure") return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_$1;
|
|
1770
|
-
const k2 = exitKey === sameExit ? key : exitKey[args];
|
|
1771
|
-
const inputValue = s.input[key];
|
|
1772
|
-
const result = index.parserValue(inputValue, s.options);
|
|
1773
|
-
return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap(exit(result), (exit) => finishIndex(s, key, k2, inputValue, exit));
|
|
1774
|
-
};
|
|
1775
|
-
const parseStringIndex = (s, key, index) => {
|
|
1776
|
-
const inputValue = s.input[key];
|
|
1777
|
-
const result = index.parserValue(inputValue, s.options);
|
|
1778
|
-
return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap(exit(result), (exit) => finishIndex(s, key, key, inputValue, exit));
|
|
1779
|
-
};
|
|
1780
|
-
const parseIndexes = indexCount ? iterateConcurrent()({
|
|
1781
|
-
onItem: (s, [key, index]) => index.is.parameter === string ? parseStringIndex(s, key, index) : parseIndex(s, key, index),
|
|
1782
|
-
step: (_s, _item, exit) => exit._tag === "Failure" ? exit : void 0
|
|
1783
|
-
}) : void 0;
|
|
1784
1759
|
const compileMembers = () => {
|
|
1785
1760
|
if (!properties) {
|
|
1786
1761
|
properties = ast.propertySignatures.map((ps) => ({
|
|
@@ -1796,69 +1771,102 @@ const Objects = class extends ASTNodeImpl {
|
|
|
1796
1771
|
}
|
|
1797
1772
|
return properties;
|
|
1798
1773
|
};
|
|
1799
|
-
const
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
issues: void 0,
|
|
1810
|
-
options
|
|
1774
|
+
const makeFallback = () => {
|
|
1775
|
+
const expectedKeys = new Set(ast.propertySignatures.map((ps) => typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name));
|
|
1776
|
+
const finishIndex = (s, key, k2, inputValue, exitValue) => {
|
|
1777
|
+
if (exitValue._tag === "Failure") return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? void_$1;
|
|
1778
|
+
const value = exitValue === sameExit ? inputValue : exitValue[args];
|
|
1779
|
+
if (k2 !== missing && value !== missing) {
|
|
1780
|
+
if (hasProperties && (expectedKeys.has(key) || expectedKeys.has(typeof k2 === "number" ? globalThis.String(k2) : k2))) return void_$1;
|
|
1781
|
+
assignProperty$1(s.out, k2, value);
|
|
1782
|
+
}
|
|
1783
|
+
return void_$1;
|
|
1811
1784
|
};
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1785
|
+
const parseIndex = (s, key, index, exitKey) => {
|
|
1786
|
+
if (!exitKey) {
|
|
1787
|
+
const eff = index.parserKey(key, s.options);
|
|
1788
|
+
if (!effectIsExit(eff)) return flatMap(exit(eff), (exit) => parseIndex(s, key, index, exit));
|
|
1789
|
+
exitKey = eff;
|
|
1790
|
+
}
|
|
1791
|
+
if (exitKey._tag === "Failure") return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? void_$1;
|
|
1792
|
+
const k2 = exitKey === sameExit ? key : exitKey[args];
|
|
1793
|
+
const inputValue = s.input[key];
|
|
1794
|
+
const result = index.parserValue(inputValue, s.options);
|
|
1795
|
+
return effectIsExit(result) ? finishIndex(s, key, k2, inputValue, result) : flatMap(exit(result), (exit) => finishIndex(s, key, k2, inputValue, exit));
|
|
1796
|
+
};
|
|
1797
|
+
const parseStringIndex = (s, key, index) => {
|
|
1798
|
+
const inputValue = s.input[key];
|
|
1799
|
+
const result = index.parserValue(inputValue, s.options);
|
|
1800
|
+
return effectIsExit(result) ? finishIndex(s, key, key, inputValue, result) : flatMap(exit(result), (exit) => finishIndex(s, key, key, inputValue, exit));
|
|
1801
|
+
};
|
|
1802
|
+
const parseIndexes = indexCount ? iterateConcurrent()({
|
|
1803
|
+
onItem: (s, [key, index]) => index.is.parameter === string ? parseStringIndex(s, key, index) : parseIndex(s, key, index),
|
|
1804
|
+
step: (_s, _item, exit) => exit._tag === "Failure" ? exit : void 0
|
|
1805
|
+
}) : void 0;
|
|
1806
|
+
return fnUntracedEager(function* (input, options) {
|
|
1807
|
+
if (input === missing) return missing;
|
|
1808
|
+
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) return yield* fail$2(new InvalidType(ast, input, options));
|
|
1809
|
+
compileMembers();
|
|
1810
|
+
const record = input;
|
|
1811
|
+
const out = {};
|
|
1812
|
+
const state = {
|
|
1813
|
+
ast,
|
|
1814
|
+
input: record,
|
|
1815
|
+
out,
|
|
1816
|
+
issues: void 0,
|
|
1817
|
+
options
|
|
1818
|
+
};
|
|
1819
|
+
const errorsAllOption = options.errors === "all";
|
|
1820
|
+
const onExcessPropertyError = options.onExcessProperty === "error";
|
|
1821
|
+
const concurrency = options.concurrency === void 0 ? 1 : resolveConcurrency(options.concurrency);
|
|
1822
|
+
const indexKeys = indexCount && onExcessPropertyError ? ast.indexSignatures.map((index) => getIndexSignatureKeys(record, index.parameter, options)) : void 0;
|
|
1823
|
+
if (onExcessPropertyError) {
|
|
1824
|
+
const coveredKeys = indexKeys ? new Set(expectedKeys) : expectedKeys;
|
|
1825
|
+
if (indexKeys) for (const keys of indexKeys) for (const key of keys) coveredKeys.add(key);
|
|
1826
|
+
const inputKeys = Reflect.ownKeys(record);
|
|
1827
|
+
for (let i = 0; i < inputKeys.length; i++) {
|
|
1828
|
+
const key = inputKeys[i];
|
|
1829
|
+
if (!coveredKeys.has(key) && Object.prototype.propertyIsEnumerable.call(record, key)) {
|
|
1830
|
+
const unexpected = new UnexpectedKey(ast, record[key], options);
|
|
1831
|
+
const issue = new Pointer([key], unexpected);
|
|
1832
|
+
if (errorsAllOption) {
|
|
1833
|
+
if (state.issues) state.issues.push(issue);
|
|
1834
|
+
else state.issues = [issue];
|
|
1835
|
+
continue;
|
|
1836
|
+
} else return yield* fail$2(new Composite(ast, [issue], input, options));
|
|
1837
|
+
}
|
|
1831
1838
|
}
|
|
1832
1839
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
if (eff) yield* eff;
|
|
1837
|
-
}
|
|
1838
|
-
if (indexCount && concurrency === 1) for (let i = 0; i < indexCount; i++) {
|
|
1839
|
-
const index = indexes[i];
|
|
1840
|
-
const parse = index.is.parameter === string ? parseStringIndex : parseIndex;
|
|
1841
|
-
const keys = indexKeys?.[i] ?? (index.is.parameter === string ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options));
|
|
1842
|
-
for (let j = 0; j < keys.length; j++) {
|
|
1843
|
-
const eff = parse(state, keys[j], index);
|
|
1844
|
-
if (!effectIsExit(eff)) yield* eff;
|
|
1845
|
-
else if (eff._tag === "Failure") return yield* eff;
|
|
1840
|
+
if (hasProperties) {
|
|
1841
|
+
const eff = concurrency === 1 ? parseProperties(state, properties) : parsePropertiesConcurrent(state, properties, { concurrency });
|
|
1842
|
+
if (eff) yield* eff;
|
|
1846
1843
|
}
|
|
1847
|
-
|
|
1848
|
-
else if (parseIndexes) {
|
|
1849
|
-
const keyPairs = empty$2();
|
|
1850
|
-
for (let i = 0; i < indexCount; i++) {
|
|
1844
|
+
if (indexCount && concurrency === 1) for (let i = 0; i < indexCount; i++) {
|
|
1851
1845
|
const index = indexes[i];
|
|
1846
|
+
const parse = index.is.parameter === string ? parseStringIndex : parseIndex;
|
|
1852
1847
|
const keys = indexKeys?.[i] ?? (index.is.parameter === string ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options));
|
|
1853
|
-
for (let j = 0; j < keys.length; j++)
|
|
1848
|
+
for (let j = 0; j < keys.length; j++) {
|
|
1849
|
+
const eff = parse(state, keys[j], index);
|
|
1850
|
+
if (!effectIsExit(eff)) yield* eff;
|
|
1851
|
+
else if (eff._tag === "Failure") return yield* eff;
|
|
1852
|
+
}
|
|
1854
1853
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1854
|
+
else if (parseIndexes) {
|
|
1855
|
+
const keyPairs = empty$2();
|
|
1856
|
+
for (let i = 0; i < indexCount; i++) {
|
|
1857
|
+
const index = indexes[i];
|
|
1858
|
+
const keys = indexKeys?.[i] ?? (index.is.parameter === string ? Object.keys(record) : getIndexSignatureKeys(record, index.is.parameter, options));
|
|
1859
|
+
for (let j = 0; j < keys.length; j++) keyPairs.push([keys[j], index]);
|
|
1860
|
+
}
|
|
1861
|
+
const eff = parseIndexes(state, keyPairs, { concurrency });
|
|
1862
|
+
if (eff) yield* eff;
|
|
1863
|
+
}
|
|
1864
|
+
if (state.issues) return yield* fail$2(new Composite(ast, state.issues, input, options));
|
|
1865
|
+
return out;
|
|
1866
|
+
});
|
|
1867
|
+
};
|
|
1868
|
+
if (indexCount) return makeFallback();
|
|
1869
|
+
let fallback;
|
|
1862
1870
|
const resume = (state, index, pending) => {
|
|
1863
1871
|
const property = properties[index];
|
|
1864
1872
|
return flatMap(exit(pending), (exit) => {
|
|
@@ -1871,7 +1879,7 @@ const Objects = class extends ASTNodeImpl {
|
|
|
1871
1879
|
};
|
|
1872
1880
|
return (input, options) => {
|
|
1873
1881
|
if (input === missing) return missingExit;
|
|
1874
|
-
if (options.errors === "all" || options.onExcessProperty !== void 0 || options.concurrency !== void 0 && resolveConcurrency(options.concurrency) !== 1) return fallback(input, options);
|
|
1882
|
+
if (options.errors === "all" || options.onExcessProperty !== void 0 || options.concurrency !== void 0 && resolveConcurrency(options.concurrency) !== 1) return (fallback ??= makeFallback())(input, options);
|
|
1875
1883
|
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) return fail$2(new InvalidType(ast, input, options));
|
|
1876
1884
|
const props = compileMembers();
|
|
1877
1885
|
const record = input;
|
|
@@ -1981,6 +1989,7 @@ function structWithRest(ast, records) {
|
|
|
1981
1989
|
let indexSignatures = ast.indexSignatures;
|
|
1982
1990
|
let checks = ast.checks;
|
|
1983
1991
|
for (const record of records) {
|
|
1992
|
+
for (const propertySignature of record.propertySignatures) if (propertySignatures.some((ps) => ps.name === propertySignature.name)) throw new Error(`Duplicate identifier: ${JSON.stringify(propertySignature.name)}. ts(2300)`);
|
|
1984
1993
|
propertySignatures = propertySignatures.concat(record.propertySignatures);
|
|
1985
1994
|
indexSignatures = indexSignatures.concat(record.indexSignatures);
|
|
1986
1995
|
checks = combineChecks(checks, record.checks);
|
|
@@ -2088,8 +2097,9 @@ function collectSentinels(ast) {
|
|
|
2088
2097
|
}
|
|
2089
2098
|
const candidateIndexCache = new WeakMap();
|
|
2090
2099
|
const emptyCandidates = Object.freeze([]);
|
|
2100
|
+
const getRuntimeType = (input) => input === null ? "null" : Array.isArray(input) ? "array" : typeof input;
|
|
2091
2101
|
const hasPropertySignature = (input, key) => key === "__proto__" ? Object.hasOwn(input, key) : key in input;
|
|
2092
|
-
function
|
|
2102
|
+
function getCandidateIndex(types) {
|
|
2093
2103
|
let index = candidateIndexCache.get(types);
|
|
2094
2104
|
if (index) return index;
|
|
2095
2105
|
let bySentinel;
|
|
@@ -2097,19 +2107,19 @@ function getIndex(types) {
|
|
|
2097
2107
|
let otherwise;
|
|
2098
2108
|
let literalCandidates;
|
|
2099
2109
|
let onlyLiterals = true;
|
|
2110
|
+
const literalOf = [];
|
|
2100
2111
|
for (let i = 0; i < types.length; i++) {
|
|
2101
2112
|
const a = types[i];
|
|
2102
2113
|
const encoded = toCandidate(a);
|
|
2103
2114
|
if (isNever(encoded)) continue;
|
|
2104
|
-
if (
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
}
|
|
2115
|
+
if (isLiteral(encoded) || isUniqueSymbol(encoded)) {
|
|
2116
|
+
literalCandidates ??= new Map();
|
|
2117
|
+
const literal = isLiteral(encoded) ? encoded.literal : encoded.symbol;
|
|
2118
|
+
literalOf[i] = literal;
|
|
2119
|
+
let arr = literalCandidates.get(literal);
|
|
2120
|
+
if (!arr) literalCandidates.set(literal, arr = []);
|
|
2121
|
+
arr.push(i);
|
|
2122
|
+
} else onlyLiterals = false;
|
|
2113
2123
|
const sentinels = collectSentinels(encoded);
|
|
2114
2124
|
if (sentinels.length) {
|
|
2115
2125
|
bySentinel ??= new Map();
|
|
@@ -2128,18 +2138,21 @@ function getIndex(types) {
|
|
|
2128
2138
|
for (const t of candidateTypes) (otherwise[t] ??= []).push(i);
|
|
2129
2139
|
}
|
|
2130
2140
|
}
|
|
2141
|
+
const fallbacks = {};
|
|
2142
|
+
const getFallback = (type) => fallbacks[type] ??= Object.freeze(otherwise?.[type] ?? emptyCandidates);
|
|
2131
2143
|
if (onlyLiterals && literalCandidates) {
|
|
2132
2144
|
literalCandidates.forEach(Object.freeze);
|
|
2133
2145
|
index = (input) => literalCandidates.get(input) ?? emptyCandidates;
|
|
2134
2146
|
} else if (bySentinel?.size === 1 && !otherwise) {
|
|
2135
2147
|
const [key, [byValue]] = bySentinel.entries().next().value;
|
|
2136
|
-
const candidates =
|
|
2137
|
-
for (const [literal, indexes] of byValue) candidates.set(literal, Object.freeze(Array.from(indexes
|
|
2148
|
+
const candidates = new Map();
|
|
2149
|
+
for (const [literal, indexes] of byValue) candidates.set(literal, Object.freeze(Array.from(indexes)));
|
|
2150
|
+
const all = Object.freeze(types.map((_, i) => i));
|
|
2138
2151
|
index = (input, isConstructor) => {
|
|
2139
2152
|
if (isObjectKeyword(input)) {
|
|
2140
2153
|
const value = hasPropertySignature(input, key) ? input[key] : void 0;
|
|
2141
2154
|
if (value !== void 0) return candidates.get(value) ?? emptyCandidates;
|
|
2142
|
-
if (isConstructor) return
|
|
2155
|
+
if (isConstructor) return all;
|
|
2143
2156
|
}
|
|
2144
2157
|
return emptyCandidates;
|
|
2145
2158
|
};
|
|
@@ -2147,9 +2160,9 @@ function getIndex(types) {
|
|
|
2147
2160
|
let commonSentinel;
|
|
2148
2161
|
for (const entry of bySentinel) if ((!commonSentinel || entry[1][0].size > commonSentinel[1][0].size) && entry[1][1].size === sentinelCandidateCount) commonSentinel = entry;
|
|
2149
2162
|
index = (input, isConstructor) => {
|
|
2150
|
-
const
|
|
2151
|
-
if (!isObjectKeyword(input)) return
|
|
2152
|
-
const selected = new Set(
|
|
2163
|
+
const runtimeType = getRuntimeType(input);
|
|
2164
|
+
if (!isObjectKeyword(input)) return getFallback(runtimeType);
|
|
2165
|
+
const selected = new Set(otherwise?.[runtimeType]);
|
|
2153
2166
|
let directKey;
|
|
2154
2167
|
if (commonSentinel) {
|
|
2155
2168
|
const [key, [byValue]] = commonSentinel;
|
|
@@ -2157,7 +2170,7 @@ function getIndex(types) {
|
|
|
2157
2170
|
const value = hasKey ? input[key] : void 0;
|
|
2158
2171
|
if (hasKey && (!isConstructor || value !== void 0)) {
|
|
2159
2172
|
const match = byValue.get(value);
|
|
2160
|
-
if (!match) return
|
|
2173
|
+
if (!match) return getFallback(runtimeType);
|
|
2161
2174
|
for (const i of match) selected.add(i);
|
|
2162
2175
|
directKey = key;
|
|
2163
2176
|
}
|
|
@@ -2179,23 +2192,15 @@ function getIndex(types) {
|
|
|
2179
2192
|
for (const i of selected) if (all.has(i) && !match?.has(i)) selected.delete(i);
|
|
2180
2193
|
}
|
|
2181
2194
|
}
|
|
2182
|
-
return Array.from(selected).sort((a, b) => a - b)
|
|
2195
|
+
return Array.from(selected).sort((a, b) => a - b);
|
|
2183
2196
|
};
|
|
2184
2197
|
} else index = (input) => {
|
|
2185
|
-
|
|
2198
|
+
const fallback = getFallback(getRuntimeType(input));
|
|
2199
|
+
return literalCandidates ? fallback.filter((i) => literalOf[i] === void 0 || literalOf[i] === input) : fallback;
|
|
2186
2200
|
};
|
|
2187
2201
|
candidateIndexCache.set(types, index);
|
|
2188
2202
|
return index;
|
|
2189
2203
|
}
|
|
2190
|
-
function filterLiterals(input) {
|
|
2191
|
-
return (ast) => {
|
|
2192
|
-
const encoded = toCandidate(ast);
|
|
2193
|
-
return encoded._tag === "Literal" ? encoded.literal === input : encoded._tag === "UniqueSymbol" ? encoded.symbol === input : true;
|
|
2194
|
-
};
|
|
2195
|
-
}
|
|
2196
|
-
function getCandidates(input, types, isConstructor = false) {
|
|
2197
|
-
return getIndex(types)(input, isConstructor);
|
|
2198
|
-
}
|
|
2199
2204
|
const Union$1 = class extends ASTNodeImpl {
|
|
2200
2205
|
_tag = "Union";
|
|
2201
2206
|
types;
|
|
@@ -2209,34 +2214,20 @@ const Union$1 = class extends ASTNodeImpl {
|
|
|
2209
2214
|
}
|
|
2210
2215
|
getParser(compile, compileField) {
|
|
2211
2216
|
const ast = this;
|
|
2217
|
+
const isConstructor = compileField !== void 0;
|
|
2218
|
+
const parsers = [];
|
|
2219
|
+
const parser = (i) => parsers[i] ??= compile(ast.types[i]);
|
|
2220
|
+
let index;
|
|
2212
2221
|
return (input, options) => {
|
|
2213
2222
|
if (input === missing) return missingExit;
|
|
2214
|
-
const candidates =
|
|
2223
|
+
const candidates = (index ??= getCandidateIndex(ast.types))(input, isConstructor);
|
|
2215
2224
|
if (candidates.length === 0) return fail$2(new AnyOf(ast, [], input, options));
|
|
2216
2225
|
if (candidates.length === 1) {
|
|
2217
|
-
const result =
|
|
2226
|
+
const result = parser(candidates[0])(input, options);
|
|
2218
2227
|
if (result._tag === "Success") return result;
|
|
2219
|
-
return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) :
|
|
2228
|
+
return effectIsExit(result) ? failSingleUnionCandidate(ast, result.cause, input, options) : catchSingleUnionCandidate(ast, result, input, options);
|
|
2220
2229
|
}
|
|
2221
|
-
|
|
2222
|
-
ast,
|
|
2223
|
-
compile,
|
|
2224
|
-
input,
|
|
2225
|
-
out: void 0,
|
|
2226
|
-
successes: ast.options?.mode === "oneOf" ? [] : void 0,
|
|
2227
|
-
issues: void 0,
|
|
2228
|
-
options
|
|
2229
|
-
};
|
|
2230
|
-
const eff = parseUnion(state, candidates);
|
|
2231
|
-
if (!eff) {
|
|
2232
|
-
if (state.out) return state.out;
|
|
2233
|
-
return fail$2(new AnyOf(ast, state.issues ?? [], input, options));
|
|
2234
|
-
}
|
|
2235
|
-
return flatMapEager(eff, (_) => {
|
|
2236
|
-
if (state.out === sameExit) return succeed$3(input);
|
|
2237
|
-
if (state.out) return state.out;
|
|
2238
|
-
return fail$2(new AnyOf(ast, state.issues ?? [], input, options));
|
|
2239
|
-
});
|
|
2230
|
+
return parseUnionCandidates(ast, parser, candidates, input, options);
|
|
2240
2231
|
};
|
|
2241
2232
|
}
|
|
2242
2233
|
_rebuild(recur, checks, encodingChecks) {
|
|
@@ -2283,11 +2274,38 @@ function failSingleUnionCandidate(ast, cause, input, options) {
|
|
|
2283
2274
|
if (!issue) return failCause(cause);
|
|
2284
2275
|
return fail$3(new AnyOf(ast, [issue], input, options));
|
|
2285
2276
|
}
|
|
2277
|
+
function catchSingleUnionCandidate(ast, result, input, options) {
|
|
2278
|
+
return catchCause(result, (cause) => failSingleUnionCandidate(ast, cause, input, options));
|
|
2279
|
+
}
|
|
2280
|
+
function parseUnionCandidates(ast, parser, candidates, input, options) {
|
|
2281
|
+
const state = {
|
|
2282
|
+
ast,
|
|
2283
|
+
parser,
|
|
2284
|
+
input,
|
|
2285
|
+
out: void 0,
|
|
2286
|
+
successes: ast.options?.mode === "oneOf" ? [] : void 0,
|
|
2287
|
+
issues: void 0,
|
|
2288
|
+
options
|
|
2289
|
+
};
|
|
2290
|
+
const eff = parseUnion(state, candidates);
|
|
2291
|
+
if (!eff) {
|
|
2292
|
+
if (state.out) return state.out;
|
|
2293
|
+
return fail$2(new AnyOf(ast, state.issues ?? [], input, options));
|
|
2294
|
+
}
|
|
2295
|
+
return resumeUnion(eff, state);
|
|
2296
|
+
}
|
|
2297
|
+
function resumeUnion(eff, state) {
|
|
2298
|
+
return flatMapEager(eff, (_) => {
|
|
2299
|
+
if (state.out === sameExit) return succeed$3(state.input);
|
|
2300
|
+
if (state.out) return state.out;
|
|
2301
|
+
return fail$2(new AnyOf(state.ast, state.issues ?? [], state.input, state.options));
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2286
2304
|
const parseUnion = iterateEager()({
|
|
2287
|
-
onItem(s,
|
|
2288
|
-
return s.
|
|
2305
|
+
onItem(s, i) {
|
|
2306
|
+
return s.parser(i)(s.input, s.options);
|
|
2289
2307
|
},
|
|
2290
|
-
step(s,
|
|
2308
|
+
step(s, i, exit) {
|
|
2291
2309
|
if (exit._tag === "Failure") {
|
|
2292
2310
|
const issue = getSchemaIssue(exit.cause);
|
|
2293
2311
|
if (issue === void 0) return exit;
|
|
@@ -2295,11 +2313,11 @@ const parseUnion = iterateEager()({
|
|
|
2295
2313
|
else s.issues = [issue];
|
|
2296
2314
|
} else {
|
|
2297
2315
|
if (s.out && s.successes) {
|
|
2298
|
-
s.successes.push(
|
|
2316
|
+
s.successes.push(s.ast.types[i]);
|
|
2299
2317
|
return fail$3(new OneOf(s.ast, s.successes, s.input, s.options));
|
|
2300
2318
|
}
|
|
2301
2319
|
s.out = exit;
|
|
2302
|
-
if (s.successes) s.successes.push(
|
|
2320
|
+
if (s.successes) s.successes.push(s.ast.types[i]);
|
|
2303
2321
|
else return void_$1;
|
|
2304
2322
|
}
|
|
2305
2323
|
}
|
|
@@ -2397,52 +2415,47 @@ function isFinite$1(annotations) {
|
|
|
2397
2415
|
const finite = appendChecks(number, [isFinite$1()]);
|
|
2398
2416
|
const numberToJson = new Link(new Union$1([finite, nonFiniteLiterals]), new Transformation(Number$3(), transform$1((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
|
|
2399
2417
|
function isPattern$1(regExp, annotations) {
|
|
2400
|
-
const
|
|
2401
|
-
const
|
|
2418
|
+
const copy = new globalThis.RegExp(regExp);
|
|
2419
|
+
const payload = {
|
|
2420
|
+
source: copy.source,
|
|
2421
|
+
flags: copy.flags
|
|
2422
|
+
};
|
|
2402
2423
|
return makeFilter$1((s) => {
|
|
2403
|
-
|
|
2404
|
-
return
|
|
2424
|
+
copy.lastIndex = 0;
|
|
2425
|
+
return copy.test(s);
|
|
2405
2426
|
}, {
|
|
2406
|
-
expected: `a string matching the RegExp ${source}`,
|
|
2427
|
+
expected: `a string matching the RegExp ${payload.source}`,
|
|
2407
2428
|
representation: {
|
|
2408
2429
|
id: "effect/schema/isPattern",
|
|
2409
|
-
payload
|
|
2410
|
-
source,
|
|
2411
|
-
flags: regExp.flags
|
|
2412
|
-
}
|
|
2430
|
+
payload
|
|
2413
2431
|
},
|
|
2414
|
-
toJsonSchema: () =>
|
|
2415
|
-
arbitraryConstraint: { patterns: [
|
|
2416
|
-
source: regExp.source,
|
|
2417
|
-
flags: regExp.flags
|
|
2418
|
-
}] },
|
|
2432
|
+
toJsonSchema: () => [{}, true],
|
|
2433
|
+
arbitraryConstraint: { patterns: [payload] },
|
|
2419
2434
|
...annotations
|
|
2420
2435
|
});
|
|
2421
2436
|
}
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2437
|
+
const bodyOwners = new WeakMap();
|
|
2438
|
+
function copy(ast, changes) {
|
|
2439
|
+
const out = Object.assign(Object.create(Object.getPrototypeOf(ast)), ast, changes);
|
|
2440
|
+
if (Reflect.ownKeys(changes).every((key) => key === "context" || key === "encoding")) bodyOwners.set(out, getContextOwner(ast));
|
|
2441
|
+
return out;
|
|
2426
2442
|
}
|
|
2427
|
-
const contextOwners = new WeakMap();
|
|
2428
2443
|
function getContextOwner(ast) {
|
|
2429
|
-
|
|
2444
|
+
const existing = bodyOwners.get(ast);
|
|
2445
|
+
if (existing !== void 0) return existing;
|
|
2446
|
+
if (ast.encoding === void 0) return ast;
|
|
2447
|
+
const owner = Object.assign(Object.create(Object.getPrototypeOf(ast)), ast, { encoding: void 0 });
|
|
2448
|
+
bodyOwners.set(ast, owner);
|
|
2449
|
+
return owner;
|
|
2430
2450
|
}
|
|
2431
2451
|
function replaceEncoding(ast, encoding) {
|
|
2432
|
-
|
|
2433
|
-
return modifyOwnPropertyDescriptors(ast, (d) => {
|
|
2434
|
-
d.encoding.value = encoding;
|
|
2435
|
-
});
|
|
2452
|
+
return ast.encoding === encoding ? ast : copy(ast, { encoding });
|
|
2436
2453
|
}
|
|
2437
2454
|
function replaceContext(ast, context) {
|
|
2438
2455
|
if (ast.context === context) return ast;
|
|
2439
2456
|
const owner = getContextOwner(ast);
|
|
2440
|
-
if (owner.context === context) return owner;
|
|
2441
|
-
|
|
2442
|
-
d.context.value = context;
|
|
2443
|
-
});
|
|
2444
|
-
contextOwners.set(out, owner);
|
|
2445
|
-
return out;
|
|
2457
|
+
if (owner.context === context && owner.encoding === ast.encoding) return owner;
|
|
2458
|
+
return copy(ast, { context });
|
|
2446
2459
|
}
|
|
2447
2460
|
function getLastEncoding(ast) {
|
|
2448
2461
|
return ast.encoding ? getLastEncoding(ast.encoding[ast.encoding.length - 1].to) : ast;
|
|
@@ -2452,19 +2465,15 @@ function annotate(ast, annotations) {
|
|
|
2452
2465
|
const last = ast.checks[ast.checks.length - 1];
|
|
2453
2466
|
return replaceChecks(ast, append(ast.checks.slice(0, -1), last.annotate(annotations)));
|
|
2454
2467
|
}
|
|
2455
|
-
return
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
};
|
|
2460
|
-
});
|
|
2468
|
+
return copy(ast, { annotations: {
|
|
2469
|
+
...ast.annotations,
|
|
2470
|
+
...annotations
|
|
2471
|
+
} });
|
|
2461
2472
|
}
|
|
2462
2473
|
function replaceChecks(ast, checks) {
|
|
2463
2474
|
if (ast._tag === "Suspend" && checks) throw new Error("Cannot add checks to Suspend");
|
|
2464
2475
|
if (ast.checks === checks) return ast;
|
|
2465
|
-
return
|
|
2466
|
-
d.checks.value = checks;
|
|
2467
|
-
});
|
|
2476
|
+
return copy(ast, { checks });
|
|
2468
2477
|
}
|
|
2469
2478
|
function appendChecks(ast, checks) {
|
|
2470
2479
|
return replaceChecks(ast, combineChecks(ast.checks, checks));
|
|
@@ -2505,20 +2514,19 @@ function appendTransformation(from, transformation, to) {
|
|
|
2505
2514
|
const link = new Link(from, transformation);
|
|
2506
2515
|
return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]);
|
|
2507
2516
|
}
|
|
2508
|
-
function brand$1(ast, brand) {
|
|
2509
|
-
const existing = resolveBrands(ast);
|
|
2510
|
-
return annotate(ast, { brands: existing ? [...existing, brand] : [brand] });
|
|
2511
|
-
}
|
|
2512
2517
|
function mapOrSame(as, f) {
|
|
2513
|
-
let
|
|
2514
|
-
const out = new Array(as.length);
|
|
2518
|
+
let out;
|
|
2515
2519
|
for (let i = 0; i < as.length; i++) {
|
|
2516
2520
|
const a = as[i];
|
|
2517
2521
|
const fa = f(a);
|
|
2518
|
-
if (
|
|
2519
|
-
|
|
2522
|
+
if (out) out[i] = fa;
|
|
2523
|
+
else if (fa !== a) {
|
|
2524
|
+
out = new Array(as.length);
|
|
2525
|
+
for (let j = 0; j < i; j++) out[j] = as[j];
|
|
2526
|
+
out[i] = fa;
|
|
2527
|
+
}
|
|
2520
2528
|
}
|
|
2521
|
-
return
|
|
2529
|
+
return out ?? as;
|
|
2522
2530
|
}
|
|
2523
2531
|
function annotateKey(ast, annotations) {
|
|
2524
2532
|
return replaceContext(ast, ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, ast.context.constructorDefault, {
|
|
@@ -2544,10 +2552,10 @@ function parseParameter(ast) {
|
|
|
2544
2552
|
function go(ast) {
|
|
2545
2553
|
switch (ast._tag) {
|
|
2546
2554
|
case "Literal":
|
|
2547
|
-
if (isPropertyKey(ast.literal)) literals.push(ast.literal);
|
|
2555
|
+
if (isPropertyKey(ast.literal) && !literals.includes(ast.literal)) literals.push(ast.literal);
|
|
2548
2556
|
return;
|
|
2549
2557
|
case "UniqueSymbol":
|
|
2550
|
-
literals.push(ast.symbol);
|
|
2558
|
+
if (!literals.includes(ast.symbol)) literals.push(ast.symbol);
|
|
2551
2559
|
return;
|
|
2552
2560
|
case "Never": return;
|
|
2553
2561
|
case "Union":
|
|
@@ -2583,16 +2591,28 @@ function extractStructuralChecks(checks) {
|
|
|
2583
2591
|
const out = checks.flatMap(extract);
|
|
2584
2592
|
return isArrayNonEmpty(out) ? out : void 0;
|
|
2585
2593
|
}
|
|
2594
|
+
function canPreserveEncodingChecks(ast) {
|
|
2595
|
+
let preserve = true;
|
|
2596
|
+
function visit(child) {
|
|
2597
|
+
preserve = preserve && !child.encoding && !isSuspend(child);
|
|
2598
|
+
if (preserve && "recur" in child) child.recur(visit);
|
|
2599
|
+
return child;
|
|
2600
|
+
}
|
|
2601
|
+
if ("recur" in ast) ast.recur(visit);
|
|
2602
|
+
return preserve;
|
|
2603
|
+
}
|
|
2586
2604
|
const toType$1 = memoizeIdempotent((ast) => {
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2605
|
+
const owner = getContextOwner(ast);
|
|
2606
|
+
if (owner !== ast) {
|
|
2607
|
+
const type = toType$1(owner);
|
|
2608
|
+
return type === owner && ast.encoding === void 0 ? ast : replaceContext(type, ast.context);
|
|
2609
|
+
}
|
|
2610
|
+
const type = "recur" in ast ? ast.recur(toType$1) : ast;
|
|
2611
|
+
if ("encodingChecks" in type && type.encodingChecks) {
|
|
2612
|
+
const checks = canPreserveEncodingChecks(ast) ? type.encodingChecks : isArrays(type) || isObjects(type) || isDeclaration(type) && type.typeParameters.length > 0 ? extractStructuralChecks(type.encodingChecks) : void 0;
|
|
2613
|
+
return copy(type, {
|
|
2614
|
+
encodingChecks: void 0,
|
|
2615
|
+
checks: combineChecks(type.checks, checks)
|
|
2596
2616
|
});
|
|
2597
2617
|
}
|
|
2598
2618
|
return type;
|
|
@@ -2612,8 +2632,12 @@ function flipEncoding(ast, encoding) {
|
|
|
2612
2632
|
}
|
|
2613
2633
|
const flip = memoize((ast) => {
|
|
2614
2634
|
if (ast.encoding) return flipEncoding(ast, ast.encoding);
|
|
2615
|
-
const
|
|
2616
|
-
|
|
2635
|
+
const owner = getContextOwner(ast);
|
|
2636
|
+
if (owner !== ast) {
|
|
2637
|
+
const flipped = flip(owner);
|
|
2638
|
+
return flipped === owner ? ast : replaceContext(flipped, ast.context);
|
|
2639
|
+
}
|
|
2640
|
+
return "flip" in ast ? ast.flip(flip) : "recur" in ast ? ast.recur(flip) : ast;
|
|
2617
2641
|
});
|
|
2618
2642
|
function containsUndefined(ast) {
|
|
2619
2643
|
switch (ast._tag) {
|
|
@@ -2784,7 +2808,7 @@ const StringTree = new Declaration([], () => (input, ast, options) => isStringTr
|
|
|
2784
2808
|
});
|
|
2785
2809
|
const unknownToStringTree = new Link(StringTree, passthrough());
|
|
2786
2810
|
//#endregion
|
|
2787
|
-
//#region node_modules/.pnpm/effect@
|
|
2811
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/interpreter.js
|
|
2788
2812
|
const flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager(result, f);
|
|
2789
2813
|
function compileTransformation(transformation) {
|
|
2790
2814
|
if (transformation._tag === "Middleware") return (result, current, options) => {
|
|
@@ -2916,7 +2940,7 @@ function compile(ast, compile, compileField, base, specialize) {
|
|
|
2916
2940
|
};
|
|
2917
2941
|
}
|
|
2918
2942
|
//#endregion
|
|
2919
|
-
//#region node_modules/.pnpm/effect@
|
|
2943
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/compilerRegistry.js
|
|
2920
2944
|
const invalid = Symbol();
|
|
2921
2945
|
const cache = new WeakMap();
|
|
2922
2946
|
let compiler;
|
|
@@ -3004,7 +3028,7 @@ function resolve(ast) {
|
|
|
3004
3028
|
return entry;
|
|
3005
3029
|
}
|
|
3006
3030
|
//#endregion
|
|
3007
|
-
//#region node_modules/.pnpm/effect@
|
|
3031
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/SchemaParser.js
|
|
3008
3032
|
function makeEffect(schema) {
|
|
3009
3033
|
const ast = schema.ast;
|
|
3010
3034
|
let parser;
|
|
@@ -3158,10 +3182,35 @@ function makeConstructorSync(ast) {
|
|
|
3158
3182
|
const normalCompiler = (ast) => resolve(ast).parser;
|
|
3159
3183
|
const constructorCompiler = (ast) => resolve(ast).makeEffect;
|
|
3160
3184
|
//#endregion
|
|
3161
|
-
//#region node_modules/.pnpm/effect@
|
|
3185
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/make.js
|
|
3162
3186
|
const TypeId$1 = "~effect/Schema/Schema";
|
|
3187
|
+
const RebuildOptions = Symbol();
|
|
3163
3188
|
const SchemaProto = {
|
|
3164
3189
|
[TypeId$1]: TypeId$1,
|
|
3190
|
+
get make() {
|
|
3191
|
+
const value = make$2(this);
|
|
3192
|
+
Object.defineProperty(this, "make", {
|
|
3193
|
+
value,
|
|
3194
|
+
enumerable: true
|
|
3195
|
+
});
|
|
3196
|
+
return value;
|
|
3197
|
+
},
|
|
3198
|
+
get makeEffect() {
|
|
3199
|
+
const value = makeEffect(this);
|
|
3200
|
+
Object.defineProperty(this, "makeEffect", {
|
|
3201
|
+
value,
|
|
3202
|
+
enumerable: true
|
|
3203
|
+
});
|
|
3204
|
+
return value;
|
|
3205
|
+
},
|
|
3206
|
+
get makeOption() {
|
|
3207
|
+
const value = makeOption(this);
|
|
3208
|
+
Object.defineProperty(this, "makeOption", {
|
|
3209
|
+
value,
|
|
3210
|
+
enumerable: true
|
|
3211
|
+
});
|
|
3212
|
+
return value;
|
|
3213
|
+
},
|
|
3165
3214
|
pipe() {
|
|
3166
3215
|
return pipeArguments(this, arguments);
|
|
3167
3216
|
},
|
|
@@ -3173,6 +3222,9 @@ const SchemaProto = {
|
|
|
3173
3222
|
},
|
|
3174
3223
|
check(...checks) {
|
|
3175
3224
|
return this.rebuild(appendChecks(this.ast, checks));
|
|
3225
|
+
},
|
|
3226
|
+
rebuild(ast) {
|
|
3227
|
+
return make$1(ast, this[RebuildOptions]);
|
|
3176
3228
|
}
|
|
3177
3229
|
};
|
|
3178
3230
|
function make$1(ast, options) {
|
|
@@ -3180,15 +3232,12 @@ function make$1(ast, options) {
|
|
|
3180
3232
|
const self = Object.setPrototypeOf(Schema, SchemaProto);
|
|
3181
3233
|
if (options && (Object.hasOwn(options, "name") || Object.hasOwn(options, "length") || Object.hasOwn(options, "__proto__"))) Object.defineProperties(self, Object.getOwnPropertyDescriptors({ ...options }));
|
|
3182
3234
|
else Object.assign(self, options);
|
|
3235
|
+
self[RebuildOptions] = options;
|
|
3183
3236
|
self.ast = ast;
|
|
3184
|
-
self.rebuild = (ast) => make$1(ast, options);
|
|
3185
|
-
self.makeEffect = makeEffect(self);
|
|
3186
|
-
self.make = make$2(self);
|
|
3187
|
-
self.makeOption = makeOption(self);
|
|
3188
3237
|
return self;
|
|
3189
3238
|
}
|
|
3190
3239
|
//#endregion
|
|
3191
|
-
//#region node_modules/.pnpm/effect@
|
|
3240
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/JsonPointer.js
|
|
3192
3241
|
function escapeToken(token) {
|
|
3193
3242
|
return token.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3194
3243
|
}
|
|
@@ -3215,7 +3264,7 @@ function parseUriFragment(fragment) {
|
|
|
3215
3264
|
return pointer === void 0 ? void 0 : pointer.length === 0 ? [] : pointer.slice(1).split("/").map(unescapeToken);
|
|
3216
3265
|
}
|
|
3217
3266
|
//#endregion
|
|
3218
|
-
//#region node_modules/.pnpm/effect@
|
|
3267
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/JsonSchema.js
|
|
3219
3268
|
function getReferenceKey($ref) {
|
|
3220
3269
|
const path = $ref.startsWith("#") ? parseUriFragment($ref) : void 0;
|
|
3221
3270
|
return path !== void 0 && path.length === 2 && path[0] === "$defs" ? path[1] : void 0;
|
|
@@ -3311,7 +3360,7 @@ const OPEN_API_30_TO_2020_COLLISIONS = [
|
|
|
3311
3360
|
"then"
|
|
3312
3361
|
];
|
|
3313
3362
|
//#endregion
|
|
3314
|
-
//#region node_modules/.pnpm/effect@
|
|
3363
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/toCodec.js
|
|
3315
3364
|
function toCodecJson$1(schema) {
|
|
3316
3365
|
return make$1(toCodecJsonAST(schema.ast), { schema });
|
|
3317
3366
|
}
|
|
@@ -3329,16 +3378,7 @@ function validateCanonicalObjectPropertyNames(ast) {
|
|
|
3329
3378
|
}
|
|
3330
3379
|
function makeReorder(getPriority) {
|
|
3331
3380
|
return (types) => {
|
|
3332
|
-
const
|
|
3333
|
-
for (let i = 0; i < types.length; i++) indexMap.set(toEncoded$1(types[i]), i);
|
|
3334
|
-
const sortedTypes = [...types].sort((a, b) => {
|
|
3335
|
-
a = toEncoded$1(a);
|
|
3336
|
-
b = toEncoded$1(b);
|
|
3337
|
-
const pa = getPriority(a);
|
|
3338
|
-
const pb = getPriority(b);
|
|
3339
|
-
if (pa !== pb) return pa - pb;
|
|
3340
|
-
return indexMap.get(a) - indexMap.get(b);
|
|
3341
|
-
});
|
|
3381
|
+
const sortedTypes = [...types].sort((a, b) => getPriority(toEncoded$1(a)) - getPriority(toEncoded$1(b)));
|
|
3342
3382
|
if (!sortedTypes.some((ast, index) => ast !== types[index])) return types;
|
|
3343
3383
|
return sortedTypes;
|
|
3344
3384
|
};
|
|
@@ -3446,17 +3486,17 @@ const toCodecStringTreeAST = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
|
3446
3486
|
return out;
|
|
3447
3487
|
}, { stopAt: isCodecArrayFromSingleLink });
|
|
3448
3488
|
//#endregion
|
|
3449
|
-
//#region node_modules/.pnpm/effect@
|
|
3489
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/RegExp.js
|
|
3450
3490
|
const RegExp$1 = globalThis.RegExp;
|
|
3451
3491
|
const escape = (string) => string.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
3452
3492
|
//#endregion
|
|
3453
|
-
//#region node_modules/.pnpm/effect@
|
|
3493
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/errors.js
|
|
3454
3494
|
function errorWithPath(message, path) {
|
|
3455
3495
|
if (path.length > 0) message += `\n at ${formatPath(path)}`;
|
|
3456
3496
|
return new Error(message);
|
|
3457
3497
|
}
|
|
3458
3498
|
//#endregion
|
|
3459
|
-
//#region node_modules/.pnpm/effect@
|
|
3499
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/toJsonSchemaDocument.js
|
|
3460
3500
|
function formatDefinitionReference(key) {
|
|
3461
3501
|
return `#/$defs/${formatUriFragmentToken(key)}`;
|
|
3462
3502
|
}
|
|
@@ -3579,44 +3619,62 @@ function appendJsonSchema(left, right, inlineCheck) {
|
|
|
3579
3619
|
allOf: members
|
|
3580
3620
|
};
|
|
3581
3621
|
}
|
|
3622
|
+
function isExact(exactness, seen = new Set()) {
|
|
3623
|
+
if (typeof exactness === "boolean") return exactness;
|
|
3624
|
+
if (seen.has(exactness)) return true;
|
|
3625
|
+
seen.add(exactness);
|
|
3626
|
+
return exactness.every((dependency) => isExact(dependency, seen));
|
|
3627
|
+
}
|
|
3628
|
+
function isApproximateCheckOutput(output) {
|
|
3629
|
+
return Array.isArray(output);
|
|
3630
|
+
}
|
|
3582
3631
|
function compileJsonSchema(representations, rootPaths, references, options) {
|
|
3583
|
-
const
|
|
3632
|
+
const compiledDefinitions = new Map();
|
|
3633
|
+
const definitionAliases = new Map();
|
|
3584
3634
|
const compiledRepresentations = new WeakMap();
|
|
3635
|
+
const pendingOneOf = new Map();
|
|
3585
3636
|
const fallbackDefinitions = new Map();
|
|
3586
3637
|
const referenceKeys = Object.keys(references);
|
|
3587
3638
|
for (const key of referenceKeys) compileDefinition(key, ["references", key]);
|
|
3588
|
-
const
|
|
3589
|
-
const
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3639
|
+
const compiledSchemas = map$3(representations, (representation, index) => recur(representation, rootPaths[index], []));
|
|
3640
|
+
for (const [branches, schemas] of pendingOneOf.values()) if (!isExact(branches)) {
|
|
3641
|
+
for (const schema of schemas) if (Array.isArray(schema.oneOf)) {
|
|
3642
|
+
schema.anyOf = schema.oneOf;
|
|
3643
|
+
delete schema.oneOf;
|
|
3644
|
+
}
|
|
3593
3645
|
}
|
|
3646
|
+
for (const key of referenceKeys) {
|
|
3647
|
+
const representation = references[key];
|
|
3648
|
+
const fallback = getIdentifierFallback(representation);
|
|
3649
|
+
if (fallback === void 0) continue;
|
|
3650
|
+
const schema = compiledDefinitions.get(key)[0];
|
|
3651
|
+
const candidates = fallbackDefinitions.get(fallback);
|
|
3652
|
+
const match = candidates?.find((candidate) => equals(compiledDefinitions.get(candidate)[0], schema));
|
|
3653
|
+
if (match === void 0) {
|
|
3654
|
+
if (candidates === void 0) fallbackDefinitions.set(fallback, [key]);
|
|
3655
|
+
else candidates.push(key);
|
|
3656
|
+
} else definitionAliases.set(key, match);
|
|
3657
|
+
}
|
|
3658
|
+
const schemas = map$3(compiledSchemas, finalizeJsonSchema);
|
|
3659
|
+
const definitions = {};
|
|
3660
|
+
for (const key of referenceKeys) if (!definitionAliases.has(key)) assignProperty$1(definitions, key, finalizeJsonSchema(compiledDefinitions.get(key)[0]));
|
|
3594
3661
|
return {
|
|
3595
3662
|
dialect: "draft-2020-12",
|
|
3596
3663
|
schemas,
|
|
3597
3664
|
definitions
|
|
3598
3665
|
};
|
|
3666
|
+
function registerPendingOneOf(schema) {
|
|
3667
|
+
if (Array.isArray(schema.oneOf)) pendingOneOf.get(schema.oneOf)?.[1].push(schema);
|
|
3668
|
+
return schema;
|
|
3669
|
+
}
|
|
3599
3670
|
function compileDefinition(key, path) {
|
|
3600
|
-
const compiled = definitionStates.get(key);
|
|
3601
|
-
if (compiled !== void 0) return typeof compiled === "string" ? compiled : key;
|
|
3602
3671
|
if (!Object.hasOwn(references, key)) throw errorWithPath(`Invalid reference ${key}`, [...path, "$ref"]);
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
const
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
const match = candidates?.find((candidate) => equals(definitionStates.get(candidate), schema));
|
|
3610
|
-
if (match === void 0) {
|
|
3611
|
-
if (candidates === void 0) fallbackDefinitions.set(fallback, [key]);
|
|
3612
|
-
else candidates.push(key);
|
|
3613
|
-
} else {
|
|
3614
|
-
definitionStates.set(key, match);
|
|
3615
|
-
return match;
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
definitionStates.set(key, schema);
|
|
3619
|
-
return key;
|
|
3672
|
+
const cached = compiledDefinitions.get(key);
|
|
3673
|
+
if (cached !== void 0) return cached;
|
|
3674
|
+
const result = [{}, []];
|
|
3675
|
+
compiledDefinitions.set(key, result);
|
|
3676
|
+
result[0] = recur(references[key], ["references", key], result[1]);
|
|
3677
|
+
return result;
|
|
3620
3678
|
}
|
|
3621
3679
|
function finalizeJsonSchema(schema) {
|
|
3622
3680
|
return rewriteRefs(schema, ($ref) => {
|
|
@@ -3627,8 +3685,8 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3627
3685
|
}
|
|
3628
3686
|
if (!pointer.startsWith("/$defs/")) return $ref;
|
|
3629
3687
|
const separator = pointer.indexOf("/", 7);
|
|
3630
|
-
const canonical =
|
|
3631
|
-
if (
|
|
3688
|
+
const canonical = definitionAliases.get(unescapeToken(pointer.slice(7, separator < 0 ? void 0 : separator)));
|
|
3689
|
+
if (canonical === void 0) return $ref;
|
|
3632
3690
|
return $ref.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i, formatDefinitionReference(canonical));
|
|
3633
3691
|
});
|
|
3634
3692
|
}
|
|
@@ -3637,48 +3695,63 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3637
3695
|
const annotations = representation.checks.length === 0 ? representation.annotations : representation.checks[representation.checks.length - 1].annotations;
|
|
3638
3696
|
return typeof annotations?.identifier !== "string" && typeof annotations?.["~identifier"] === "string" ? annotations[IDENTIFIER_FALLBACK_KEY] : void 0;
|
|
3639
3697
|
}
|
|
3640
|
-
function
|
|
3641
|
-
return representation?.schemas?.map((schema, index) => recur(schema, [
|
|
3642
|
-
...path,
|
|
3643
|
-
"schemas",
|
|
3644
|
-
index
|
|
3645
|
-
])) ?? [];
|
|
3646
|
-
}
|
|
3647
|
-
function compileCheck(check, type, path) {
|
|
3698
|
+
function compileCheck(check, type, path, dependencies) {
|
|
3648
3699
|
const annotations = check.annotations;
|
|
3649
3700
|
const callback = annotations?.toJsonSchema;
|
|
3650
3701
|
if (callback !== void 0) {
|
|
3651
|
-
const
|
|
3702
|
+
const result = callback({
|
|
3652
3703
|
type,
|
|
3653
|
-
schemas:
|
|
3704
|
+
schemas: check.representation?.schemas?.map((schema, index) => recur(schema, [
|
|
3705
|
+
...path,
|
|
3706
|
+
"representation",
|
|
3707
|
+
"schemas",
|
|
3708
|
+
index
|
|
3709
|
+
], dependencies)) ?? []
|
|
3654
3710
|
});
|
|
3711
|
+
const approximate = isApproximateCheckOutput(result);
|
|
3712
|
+
if (approximate) dependencies.push(false);
|
|
3713
|
+
const fragment = approximate ? result[0] : result;
|
|
3655
3714
|
const ordinary = collectJsonSchemaAnnotations(annotations, options);
|
|
3656
3715
|
const schema = ordinary === void 0 ? fragment : {
|
|
3657
3716
|
...fragment,
|
|
3658
3717
|
...ordinary
|
|
3659
3718
|
};
|
|
3660
3719
|
const allowed = ordinary === void 0 ? inlineableCheckKeywords : inlineableAnnotatedCheckKeywords;
|
|
3661
|
-
return check._tag === "Filter" && hasOnlyKeywords(schema, allowed) && (ordinary === void 0 || hasOnlyKeywords(ordinary, promotableAnnotationKeywords)) ?
|
|
3720
|
+
return [schema, check._tag === "Filter" && hasOnlyKeywords(schema, allowed) && (ordinary === void 0 || hasOnlyKeywords(ordinary, promotableAnnotationKeywords)) ? true : void 0];
|
|
3662
3721
|
}
|
|
3663
|
-
if (check._tag === "Filter")
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3722
|
+
if (check._tag === "Filter") {
|
|
3723
|
+
dependencies.push(false);
|
|
3724
|
+
return;
|
|
3725
|
+
}
|
|
3726
|
+
const schemas = check.checks.flatMap((child, index) => {
|
|
3727
|
+
const result = compileCheck(child, type, [
|
|
3728
|
+
...path,
|
|
3729
|
+
"checks",
|
|
3730
|
+
index
|
|
3731
|
+
], dependencies);
|
|
3732
|
+
return result === void 0 ? [] : [result[0]];
|
|
3733
|
+
});
|
|
3734
|
+
if (schemas.length === 0) return void 0;
|
|
3670
3735
|
const ordinary = collectJsonSchemaAnnotations(annotations, options);
|
|
3671
|
-
const
|
|
3672
|
-
return [ordinary === void 0 ?
|
|
3673
|
-
|
|
3736
|
+
const schema = { allOf: schemas };
|
|
3737
|
+
return [ordinary === void 0 ? schema : {
|
|
3738
|
+
...schema,
|
|
3674
3739
|
...ordinary
|
|
3675
3740
|
}];
|
|
3676
3741
|
}
|
|
3677
|
-
function recur(representation, path) {
|
|
3678
|
-
if (representation._tag === "Reference")
|
|
3742
|
+
function recur(representation, path, dependencies) {
|
|
3743
|
+
if (representation._tag === "Reference") {
|
|
3744
|
+
dependencies.push(compileDefinition(representation.$ref, path)[1]);
|
|
3745
|
+
return { $ref: formatDefinitionReference(representation.$ref) };
|
|
3746
|
+
}
|
|
3679
3747
|
const cached = compiledRepresentations.get(representation);
|
|
3680
|
-
if (cached !== void 0)
|
|
3681
|
-
|
|
3748
|
+
if (cached !== void 0) {
|
|
3749
|
+
dependencies.push(cached[1]);
|
|
3750
|
+
return cached[0];
|
|
3751
|
+
}
|
|
3752
|
+
const local = [];
|
|
3753
|
+
dependencies.push(local);
|
|
3754
|
+
let output = on(representation, path, local);
|
|
3682
3755
|
const ordinary = collectJsonSchemaAnnotations(representation.annotations, options);
|
|
3683
3756
|
if (ordinary !== void 0) output = {
|
|
3684
3757
|
...output,
|
|
@@ -3690,13 +3763,13 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3690
3763
|
...path,
|
|
3691
3764
|
"checks",
|
|
3692
3765
|
index
|
|
3693
|
-
]);
|
|
3766
|
+
], local);
|
|
3694
3767
|
if (check !== void 0) output = appendJsonSchema(output, ...check);
|
|
3695
3768
|
}
|
|
3696
|
-
compiledRepresentations.set(representation, output);
|
|
3697
|
-
return output;
|
|
3769
|
+
compiledRepresentations.set(representation, [output, local]);
|
|
3770
|
+
return registerPendingOneOf(output);
|
|
3698
3771
|
}
|
|
3699
|
-
function on(representation, path) {
|
|
3772
|
+
function on(representation, path, dependencies) {
|
|
3700
3773
|
switch (representation._tag) {
|
|
3701
3774
|
case "Any":
|
|
3702
3775
|
case "Unknown": return {};
|
|
@@ -3716,8 +3789,10 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3716
3789
|
type: "string",
|
|
3717
3790
|
enum: [globalThis.String(representation.symbol)]
|
|
3718
3791
|
};
|
|
3719
|
-
case "Declaration":
|
|
3720
|
-
|
|
3792
|
+
case "Declaration":
|
|
3793
|
+
dependencies.push(false);
|
|
3794
|
+
return {};
|
|
3795
|
+
case "Suspend": return recur(representation.thunk, [...path, "thunk"], dependencies);
|
|
3721
3796
|
case "Never": return { not: {} };
|
|
3722
3797
|
case "String": return { type: "string" };
|
|
3723
3798
|
case "Number": return { anyOf: [{ type: "number" }, {
|
|
@@ -3765,14 +3840,14 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3765
3840
|
let minItems = representation.elements.length;
|
|
3766
3841
|
const prefixItems = representation.elements.map((element, index) => {
|
|
3767
3842
|
if (element.isOptional) minItems--;
|
|
3768
|
-
const
|
|
3843
|
+
const schema = recur(element.type, [
|
|
3769
3844
|
...path,
|
|
3770
3845
|
"elements",
|
|
3771
3846
|
index,
|
|
3772
3847
|
"type"
|
|
3773
|
-
]);
|
|
3848
|
+
], dependencies);
|
|
3774
3849
|
const annotations = collectJsonSchemaAnnotations(element.annotations, options);
|
|
3775
|
-
return annotations === void 0 ?
|
|
3850
|
+
return annotations === void 0 ? schema : registerPendingOneOf(appendJsonSchema(schema, annotations));
|
|
3776
3851
|
});
|
|
3777
3852
|
if (prefixItems.length > 0) {
|
|
3778
3853
|
out.prefixItems = prefixItems;
|
|
@@ -3785,7 +3860,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3785
3860
|
...path,
|
|
3786
3861
|
"rest",
|
|
3787
3862
|
0
|
|
3788
|
-
]);
|
|
3863
|
+
], dependencies);
|
|
3789
3864
|
if (Object.keys(rest).length > 0) out.items = rest;
|
|
3790
3865
|
else delete out.items;
|
|
3791
3866
|
}
|
|
@@ -3805,14 +3880,14 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3805
3880
|
"name"
|
|
3806
3881
|
]);
|
|
3807
3882
|
const name = property.name;
|
|
3808
|
-
const
|
|
3883
|
+
const schema = recur(property.type, [
|
|
3809
3884
|
...path,
|
|
3810
3885
|
"propertySignatures",
|
|
3811
3886
|
index,
|
|
3812
3887
|
"type"
|
|
3813
|
-
]);
|
|
3888
|
+
], dependencies);
|
|
3814
3889
|
const annotations = collectJsonSchemaAnnotations(property.annotations, options);
|
|
3815
|
-
assignProperty$1(properties, name, annotations === void 0 ?
|
|
3890
|
+
assignProperty$1(properties, name, annotations === void 0 ? schema : registerPendingOneOf(appendJsonSchema(schema, annotations)));
|
|
3816
3891
|
if (!property.isOptional) required.push(name);
|
|
3817
3892
|
}
|
|
3818
3893
|
if (representation.propertySignatures.length > 0) out.properties = properties;
|
|
@@ -3828,7 +3903,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3828
3903
|
"indexSignatures",
|
|
3829
3904
|
index,
|
|
3830
3905
|
"type"
|
|
3831
|
-
]);
|
|
3906
|
+
], dependencies);
|
|
3832
3907
|
if (equals(type, { not: {} })) type = false;
|
|
3833
3908
|
indexValueSchemas.push(type);
|
|
3834
3909
|
const patterns = getParameterPatterns(signature.parameter, [
|
|
@@ -3839,12 +3914,13 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3839
3914
|
], new Set());
|
|
3840
3915
|
if (patterns === void 0) {
|
|
3841
3916
|
hasUnrepresentableIndexPattern = true;
|
|
3917
|
+
dependencies.push(false);
|
|
3842
3918
|
continue;
|
|
3843
3919
|
}
|
|
3844
3920
|
if (patterns.length === 0) additionalPropertySchemas.push(type);
|
|
3845
3921
|
else for (const pattern of patterns) {
|
|
3846
3922
|
const previous = patternProperties[pattern];
|
|
3847
|
-
assignProperty$1(patternProperties, pattern, previous === void 0 ? type : previous === false || type === false ? false : appendJsonSchema(previous, type));
|
|
3923
|
+
assignProperty$1(patternProperties, pattern, previous === void 0 ? type : previous === false || type === false ? false : registerPendingOneOf(appendJsonSchema(previous, type)));
|
|
3848
3924
|
}
|
|
3849
3925
|
}
|
|
3850
3926
|
const hasPatternProperties = Object.keys(patternProperties).length > 0;
|
|
@@ -3857,7 +3933,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3857
3933
|
"indexSignatures",
|
|
3858
3934
|
index,
|
|
3859
3935
|
"parameter"
|
|
3860
|
-
]));
|
|
3936
|
+
], dependencies));
|
|
3861
3937
|
out.propertyNames = propertyNames.length === 1 ? propertyNames[0] : { anyOf: propertyNames };
|
|
3862
3938
|
out.additionalProperties = indexValueSchemas.length === 1 ? indexValueSchemas[0] : { anyOf: indexValueSchemas };
|
|
3863
3939
|
if (additionalPropertySchemas.length > 0) out.allOf = additionalPropertySchemas.map((type) => ({
|
|
@@ -3874,18 +3950,21 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3874
3950
|
return out;
|
|
3875
3951
|
}
|
|
3876
3952
|
case "Union": {
|
|
3953
|
+
const branches = [];
|
|
3877
3954
|
const types = representation.types.map((type, index) => recur(type, [
|
|
3878
3955
|
...path,
|
|
3879
3956
|
"types",
|
|
3880
3957
|
index
|
|
3881
|
-
]));
|
|
3958
|
+
], branches));
|
|
3959
|
+
dependencies.push(branches);
|
|
3882
3960
|
if (types.length === 0) return { not: {} };
|
|
3883
3961
|
const mode = representation.options?.mode ?? "anyOf";
|
|
3884
3962
|
if (mode === "anyOf" && types.length > 1) {
|
|
3885
3963
|
const compacted = compactEnums(types);
|
|
3886
3964
|
if (compacted !== void 0) return compacted;
|
|
3887
3965
|
}
|
|
3888
|
-
|
|
3966
|
+
if (mode === "oneOf") pendingOneOf.set(types, [branches, []]);
|
|
3967
|
+
return { [mode]: types };
|
|
3889
3968
|
}
|
|
3890
3969
|
}
|
|
3891
3970
|
}
|
|
@@ -3901,7 +3980,9 @@ function compileJsonSchema(representations, rootPaths, references, options) {
|
|
|
3901
3980
|
case "String": {
|
|
3902
3981
|
if (parameter.checks.length === 0) return [];
|
|
3903
3982
|
if (parameter.checks.length !== 1 || parameter.checks[0]._tag !== "Filter" || parameter.checks[0].annotations?.toJsonSchema === void 0) return;
|
|
3904
|
-
const
|
|
3983
|
+
const dependencies = [];
|
|
3984
|
+
const schema = recur(parameter, path, dependencies);
|
|
3985
|
+
if (!isExact(dependencies)) return void 0;
|
|
3905
3986
|
return schema.type === "string" && typeof schema.pattern === "string" && hasOnlyKeywords(schema, "|type|pattern|title|description|default|examples|readOnly|writeOnly|") ? [schema.pattern] : void 0;
|
|
3906
3987
|
}
|
|
3907
3988
|
case "TemplateLiteral": return parameter.checks.length === 0 ? [`^${parameter.parts.map(getPartPattern).join("")}$`] : void 0;
|
|
@@ -3963,7 +4044,7 @@ function toJsonSchemaDocument$1(document, options) {
|
|
|
3963
4044
|
};
|
|
3964
4045
|
}
|
|
3965
4046
|
//#endregion
|
|
3966
|
-
//#region node_modules/.pnpm/effect@
|
|
4047
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schema/toRepresentation.js
|
|
3967
4048
|
const defaultReferencePolicy = ({ identifier }) => identifier;
|
|
3968
4049
|
function annotationsField(annotations) {
|
|
3969
4050
|
return annotations === void 0 ? void 0 : { annotations };
|
|
@@ -4227,7 +4308,7 @@ function toRepresentations(asts, options) {
|
|
|
4227
4308
|
}
|
|
4228
4309
|
}
|
|
4229
4310
|
//#endregion
|
|
4230
|
-
//#region node_modules/.pnpm/effect@
|
|
4311
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Struct.js
|
|
4231
4312
|
const omit = dual(2, (self, keys) => {
|
|
4232
4313
|
return buildStruct(self, (k, v) => !hasPropertyKey(keys, k) ? [k, v] : void 0);
|
|
4233
4314
|
});
|
|
@@ -4251,13 +4332,13 @@ function buildStruct(source, f) {
|
|
|
4251
4332
|
return out;
|
|
4252
4333
|
}
|
|
4253
4334
|
//#endregion
|
|
4254
|
-
//#region node_modules/.pnpm/effect@
|
|
4335
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/internal/schemaError.js
|
|
4255
4336
|
const SchemaErrorTypeId = "~effect/Schema/SchemaError";
|
|
4256
4337
|
function isSchemaError$1(u) {
|
|
4257
4338
|
return hasProperty(u, "~effect/Schema/SchemaError") && u["~effect/Schema/SchemaError"] === "~effect/Schema/SchemaError";
|
|
4258
4339
|
}
|
|
4259
4340
|
//#endregion
|
|
4260
|
-
//#region node_modules/.pnpm/effect@
|
|
4341
|
+
//#region node_modules/.pnpm/effect@4.0.1/node_modules/effect/dist/Schema.js
|
|
4261
4342
|
const TypeId = TypeId$1;
|
|
4262
4343
|
function declareConstructor() {
|
|
4263
4344
|
return (typeParameters, run, annotations) => {
|
|
@@ -4438,7 +4519,7 @@ function check(...checks) {
|
|
|
4438
4519
|
return (self) => self.check(...checks);
|
|
4439
4520
|
}
|
|
4440
4521
|
function brand(identifier) {
|
|
4441
|
-
return (schema) => make(
|
|
4522
|
+
return (schema) => make(schema.ast, {
|
|
4442
4523
|
schema,
|
|
4443
4524
|
identifier
|
|
4444
4525
|
});
|
|
@@ -4610,8 +4691,10 @@ function makeFilterGroup(checks, annotations = void 0) {
|
|
|
4610
4691
|
function isPattern(regExp, annotations) {
|
|
4611
4692
|
const source = regExp.source;
|
|
4612
4693
|
const flags = regExp.flags;
|
|
4694
|
+
const canExport = /^[dg]*uy?$/.test(flags);
|
|
4613
4695
|
const runtimeRegExp = flags === "" ? `new RegExp(${format$1(source)})` : `new RegExp(${format$1(source)}, ${format$1(flags)})`;
|
|
4614
4696
|
return isPattern$1(regExp, {
|
|
4697
|
+
toJsonSchema: () => canExport ? { pattern: flags.endsWith("y") ? `^(?:${source})` : source } : [{}, true],
|
|
4615
4698
|
toCode: () => ({ runtime: `Schema.isPattern(${runtimeRegExp})` }),
|
|
4616
4699
|
...annotations
|
|
4617
4700
|
});
|
|
@@ -4794,7 +4877,7 @@ function isInt(annotations) {
|
|
|
4794
4877
|
id: "effect/schema/isInt",
|
|
4795
4878
|
payload: null
|
|
4796
4879
|
},
|
|
4797
|
-
toJsonSchema: () =>
|
|
4880
|
+
toJsonSchema: () => [{ type: "integer" }, true],
|
|
4798
4881
|
toCode: () => ({ runtime: "Schema.isInt()" }),
|
|
4799
4882
|
arbitraryConstraint: { number: "integer" },
|
|
4800
4883
|
...annotations
|
|
@@ -4817,7 +4900,7 @@ const isGreaterThanDate = makeIsGreaterThan({
|
|
|
4817
4900
|
id: "effect/schema/isGreaterThanDate",
|
|
4818
4901
|
payload: { exclusiveMinimum: encodeDatePayload(exclusiveMinimum) }
|
|
4819
4902
|
},
|
|
4820
|
-
toJsonSchema: () =>
|
|
4903
|
+
toJsonSchema: () => [{}, true],
|
|
4821
4904
|
toCode: () => ({ runtime: `Schema.isGreaterThanDate(${formatDateRuntime(exclusiveMinimum)})` })
|
|
4822
4905
|
};
|
|
4823
4906
|
}
|
|
@@ -4830,7 +4913,7 @@ const isGreaterThanOrEqualToDate = makeIsGreaterThanOrEqualTo({
|
|
|
4830
4913
|
id: "effect/schema/isGreaterThanOrEqualToDate",
|
|
4831
4914
|
payload: { minimum: encodeDatePayload(minimum) }
|
|
4832
4915
|
},
|
|
4833
|
-
toJsonSchema: () =>
|
|
4916
|
+
toJsonSchema: () => [{}, true],
|
|
4834
4917
|
toCode: () => ({ runtime: `Schema.isGreaterThanOrEqualToDate(${formatDateRuntime(minimum)})` })
|
|
4835
4918
|
};
|
|
4836
4919
|
}
|
|
@@ -4843,7 +4926,7 @@ const isLessThanDate = makeIsLessThan({
|
|
|
4843
4926
|
id: "effect/schema/isLessThanDate",
|
|
4844
4927
|
payload: { exclusiveMaximum: encodeDatePayload(exclusiveMaximum) }
|
|
4845
4928
|
},
|
|
4846
|
-
toJsonSchema: () =>
|
|
4929
|
+
toJsonSchema: () => [{}, true],
|
|
4847
4930
|
toCode: () => ({ runtime: `Schema.isLessThanDate(${formatDateRuntime(exclusiveMaximum)})` })
|
|
4848
4931
|
};
|
|
4849
4932
|
}
|
|
@@ -4856,7 +4939,7 @@ const isLessThanOrEqualToDate = makeIsLessThanOrEqualTo({
|
|
|
4856
4939
|
id: "effect/schema/isLessThanOrEqualToDate",
|
|
4857
4940
|
payload: { maximum: encodeDatePayload(maximum) }
|
|
4858
4941
|
},
|
|
4859
|
-
toJsonSchema: () =>
|
|
4942
|
+
toJsonSchema: () => [{}, true],
|
|
4860
4943
|
toCode: () => ({ runtime: `Schema.isLessThanOrEqualToDate(${formatDateRuntime(maximum)})` })
|
|
4861
4944
|
};
|
|
4862
4945
|
}
|
|
@@ -4876,7 +4959,7 @@ const isBetweenDate = makeIsBetween({
|
|
|
4876
4959
|
...exclusiveMaximum && { exclusiveMaximum }
|
|
4877
4960
|
}
|
|
4878
4961
|
},
|
|
4879
|
-
toJsonSchema: () =>
|
|
4962
|
+
toJsonSchema: () => [{}, true],
|
|
4880
4963
|
toCode: () => ({ runtime: `Schema.isBetweenDate({ minimum: ${formatDateRuntime(options.minimum)}, maximum: ${formatDateRuntime(options.maximum)}, exclusiveMinimum: ${format$1(exclusiveMinimum)}, exclusiveMaximum: ${format$1(exclusiveMaximum)} })` })
|
|
4881
4964
|
};
|
|
4882
4965
|
}
|
|
@@ -4889,7 +4972,7 @@ const isGreaterThanBigInt = makeIsGreaterThan({
|
|
|
4889
4972
|
id: "effect/schema/isGreaterThanBigInt",
|
|
4890
4973
|
payload: { exclusiveMinimum: exclusiveMinimum.toString(10) }
|
|
4891
4974
|
},
|
|
4892
|
-
toJsonSchema: () =>
|
|
4975
|
+
toJsonSchema: () => [{}, true],
|
|
4893
4976
|
toCode: () => ({ runtime: `Schema.isGreaterThanBigInt(${format$1(exclusiveMinimum)})` })
|
|
4894
4977
|
};
|
|
4895
4978
|
}
|
|
@@ -4902,7 +4985,7 @@ const isGreaterThanOrEqualToBigInt = makeIsGreaterThanOrEqualTo({
|
|
|
4902
4985
|
id: "effect/schema/isGreaterThanOrEqualToBigInt",
|
|
4903
4986
|
payload: { minimum: minimum.toString(10) }
|
|
4904
4987
|
},
|
|
4905
|
-
toJsonSchema: () =>
|
|
4988
|
+
toJsonSchema: () => [{}, true],
|
|
4906
4989
|
toCode: () => ({ runtime: `Schema.isGreaterThanOrEqualToBigInt(${format$1(minimum)})` })
|
|
4907
4990
|
};
|
|
4908
4991
|
}
|
|
@@ -4915,7 +4998,7 @@ const isLessThanBigInt = makeIsLessThan({
|
|
|
4915
4998
|
id: "effect/schema/isLessThanBigInt",
|
|
4916
4999
|
payload: { exclusiveMaximum: exclusiveMaximum.toString(10) }
|
|
4917
5000
|
},
|
|
4918
|
-
toJsonSchema: () =>
|
|
5001
|
+
toJsonSchema: () => [{}, true],
|
|
4919
5002
|
toCode: () => ({ runtime: `Schema.isLessThanBigInt(${format$1(exclusiveMaximum)})` })
|
|
4920
5003
|
};
|
|
4921
5004
|
}
|
|
@@ -4928,7 +5011,7 @@ const isLessThanOrEqualToBigInt = makeIsLessThanOrEqualTo({
|
|
|
4928
5011
|
id: "effect/schema/isLessThanOrEqualToBigInt",
|
|
4929
5012
|
payload: { maximum: maximum.toString(10) }
|
|
4930
5013
|
},
|
|
4931
|
-
toJsonSchema: () =>
|
|
5014
|
+
toJsonSchema: () => [{}, true],
|
|
4932
5015
|
toCode: () => ({ runtime: `Schema.isLessThanOrEqualToBigInt(${format$1(maximum)})` })
|
|
4933
5016
|
};
|
|
4934
5017
|
}
|
|
@@ -4948,20 +5031,26 @@ const isBetweenBigInt = makeIsBetween({
|
|
|
4948
5031
|
...exclusiveMaximum && { exclusiveMaximum }
|
|
4949
5032
|
}
|
|
4950
5033
|
},
|
|
4951
|
-
toJsonSchema: () =>
|
|
5034
|
+
toJsonSchema: () => [{}, true],
|
|
4952
5035
|
toCode: () => ({ runtime: `Schema.isBetweenBigInt({ minimum: ${format$1(options.minimum)}, maximum: ${format$1(options.maximum)}, exclusiveMinimum: ${format$1(exclusiveMinimum)}, exclusiveMaximum: ${format$1(exclusiveMaximum)} })` })
|
|
4953
5036
|
};
|
|
4954
5037
|
}
|
|
4955
5038
|
});
|
|
4956
5039
|
function isMinLength(minLength, annotations) {
|
|
4957
|
-
minLength =
|
|
5040
|
+
minLength = normalizeCardinality(minLength);
|
|
5041
|
+
return makeIsMinLength(minLength, Math.ceil(minLength / 2), annotations);
|
|
5042
|
+
}
|
|
5043
|
+
function makeIsMinLength(minLength, minCodePoints, annotations) {
|
|
4958
5044
|
return makeFilter((input) => input.length >= minLength, {
|
|
4959
5045
|
expected: `a value with a length of at least ${minLength}`,
|
|
4960
5046
|
representation: {
|
|
4961
5047
|
id: "effect/schema/isMinLength",
|
|
4962
5048
|
payload: { minLength }
|
|
4963
5049
|
},
|
|
4964
|
-
toJsonSchema: ({ type }) => type === "
|
|
5050
|
+
toJsonSchema: ({ type }) => type === "string" ? minLength <= 1 ? { minLength: minCodePoints } : [{ minLength: minCodePoints }, true] : type === "array" ? { minItems: minLength } : type === void 0 ? [{
|
|
5051
|
+
minLength: minCodePoints,
|
|
5052
|
+
minItems: minLength
|
|
5053
|
+
}, true] : [{}, true],
|
|
4965
5054
|
toCode: () => ({ runtime: `Schema.isMinLength(${minLength})` }),
|
|
4966
5055
|
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4967
5056
|
arbitraryConstraint: { minLength },
|
|
@@ -4969,32 +5058,39 @@ function isMinLength(minLength, annotations) {
|
|
|
4969
5058
|
});
|
|
4970
5059
|
}
|
|
4971
5060
|
function isNonEmpty(annotations) {
|
|
4972
|
-
return
|
|
5061
|
+
return makeIsMinLength(1, 1, annotations);
|
|
4973
5062
|
}
|
|
4974
5063
|
function isMaxLength(maxLength, annotations) {
|
|
4975
|
-
maxLength =
|
|
5064
|
+
maxLength = normalizeCardinality(maxLength);
|
|
4976
5065
|
return makeFilter((input) => input.length <= maxLength, {
|
|
4977
5066
|
expected: `a value with a length of at most ${maxLength}`,
|
|
4978
5067
|
representation: {
|
|
4979
5068
|
id: "effect/schema/isMaxLength",
|
|
4980
5069
|
payload: { maxLength }
|
|
4981
5070
|
},
|
|
4982
|
-
toJsonSchema: ({ type }) => type === "
|
|
5071
|
+
toJsonSchema: ({ type }) => type === "string" ? maxLength === 0 ? { maxLength } : [{ maxLength }, true] : type === "array" ? { maxItems: maxLength } : type === void 0 ? [{
|
|
5072
|
+
maxLength,
|
|
5073
|
+
maxItems: maxLength
|
|
5074
|
+
}, true] : [{}, true],
|
|
4983
5075
|
toCode: () => ({ runtime: `Schema.isMaxLength(${maxLength})` }),
|
|
4984
5076
|
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
4985
5077
|
arbitraryConstraint: { maxLength },
|
|
4986
5078
|
...annotations
|
|
4987
5079
|
});
|
|
4988
5080
|
}
|
|
5081
|
+
function normalizeCardinality(value) {
|
|
5082
|
+
if (!globalThis.Number.isFinite(value)) throw new globalThis.RangeError(`Expected a finite number, got ${value}`);
|
|
5083
|
+
return Math.max(0, Math.floor(value));
|
|
5084
|
+
}
|
|
4989
5085
|
function isMaxProperties(maxProperties, annotations) {
|
|
4990
|
-
maxProperties =
|
|
5086
|
+
maxProperties = normalizeCardinality(maxProperties);
|
|
4991
5087
|
return makeFilter((input) => Reflect.ownKeys(input).length <= maxProperties, {
|
|
4992
5088
|
expected: `a value with at most ${maxProperties === 1 ? "1 entry" : `${maxProperties} entries`}`,
|
|
4993
5089
|
representation: {
|
|
4994
5090
|
id: "effect/schema/isMaxProperties",
|
|
4995
5091
|
payload: { maxProperties }
|
|
4996
5092
|
},
|
|
4997
|
-
toJsonSchema: () =>
|
|
5093
|
+
toJsonSchema: ({ type }) => type === "object" ? { maxProperties } : [{ maxProperties }, true],
|
|
4998
5094
|
toCode: () => ({ runtime: `Schema.isMaxProperties(${maxProperties})` }),
|
|
4999
5095
|
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
5000
5096
|
arbitraryConstraint: { maxProperties },
|
|
@@ -5023,7 +5119,7 @@ function isPropertyNames(keySchema, annotations) {
|
|
|
5023
5119
|
payload: null,
|
|
5024
5120
|
schemas: [propertyNames.ast]
|
|
5025
5121
|
},
|
|
5026
|
-
toJsonSchema: ({ schemas }) =>
|
|
5122
|
+
toJsonSchema: ({ schemas, type }) => type === "object" ? { propertyNames: schemas[0] } : [{ propertyNames: schemas[0] }, true],
|
|
5027
5123
|
toCode: ({ schemas }) => ({ runtime: `Schema.isPropertyNames(${schemas[0].runtime})` }),
|
|
5028
5124
|
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
5029
5125
|
...annotations
|
|
@@ -5783,6 +5879,6 @@ const MutableJson = make(annotate(MutableJson$1, { toCode: () => ({
|
|
|
5783
5879
|
Type: "Schema.MutableJson"
|
|
5784
5880
|
}) }));
|
|
5785
5881
|
//#endregion
|
|
5786
|
-
export { declare as $, Union$1 as $t, OptionFromNullOr as A, toString as An, tag as At, TaggedUnion as B, isRedacted as Bn, omit as Bt, Never as C, transform$1 as Cn, isSchemaError as Ct, NullOr as D, empty as Dn, mutable as Dt, Null as E, Pointer as En, makeFilterGroup as Et, String$1 as F, formatIso as Fn, toType as Ft, Uint8Array$1 as G,
|
|
5882
|
+
export { declare as $, map$1 as $n, Union$1 as $t, OptionFromNullOr as A, toString as An, tag as At, TaggedUnion as B, isRedacted as Bn, omit as Bt, Never as C, transform$1 as Cn, isSchemaError as Ct, NullOr as D, empty as Dn, mutable as Dt, Null as E, Pointer as En, makeFilterGroup as Et, String$1 as F, formatIso as Fn, toType as Ft, Uint8Array$1 as G, monotonicTimeNanos as Gn, encodeEffect$1 as Gt, Tuple as H, value as Hn, _is as Ht, Struct as I, formatIsoDate as In, withConstructorDefault as It, Union as J, TaggedClass$1 as Jn, FilterGroup as Jt, Uint8ArrayFromBase64 as K, EncodingError as Kn, Arrays as Kt, StructWithRest as L, fromDateUnsafe as Ln, withDecodingDefault as Lt, Record as M, fromSetCookie as Mn, toCodecStringTree as Mt, Redacted as N, decode as Nn, toEncoded as Nt, Number$1 as O, fromInput as On, optional as Ot, SchemaError as P, encode as Pn, toJsonSchemaDocument as Pt, check as Q, makeEquivalence$1 as Qn, Suspend as Qt, TaggedClass as R, now as Rn, withDecodingDefaultKey as Rt, Natural as S, passthrough$1 as Sn, isSchema as St, NonEmptyString as T, InvalidValue as Tn, makeFilter as Tt, URL$1 as U, stringOrRedacted as Un, decodeEffect$1 as Ut, TrueLiterals as V, make$6 as Vn, getReferenceKey as Vt, URLFromString as W, Clock as Wn, decodeUnknownEffect$1 as Wt, Void as X, taggedEnum as Xn, Objects as Xt, Unknown as Y, TaggedError$1 as Yn, Literal$1 as Yt, brand as Z, assignProperty as Zn, PropertySignature as Zt, Int as _, transform as _n, isMaxLength as _t, BooleanLiterals as a, null_ as an, decodeUnknownSync as at, Literals as b, dateTimeUtcFromInput$1 as bn, isPattern as bt, DateTimeUtcFromDate as c, resolveAt as cn, encodeUnknownEffect as ct, Defect as d, string as dn, is as dt, applyToSelfOrLastLinkEncoding as en, decodeEffect as et, Duration as f, toEncoded$1 as fn, isFinite as ft, Finite as g, passthrough as gn, isLessThanOrEqualTo as gt, FalseLiterals as h, Transformation as hn, isInt as ht, BooleanFromBit as i, mapOrSame as in, decodeUnknownOption as it, OptionFromOptional as j, empty$1 as jn, toCodecJson as jt, Option as k, setAll as kn, optionalKey as kt, DateTimeUtcFromMillis as l, resolveDescription as ln, fromJsonString as lt, Exit as m, unknown as mn, isGreaterThanOrEqualTo as mt, ArraySchema as n, isNever as nn, decodeTo as nt, Class as o, optionalKey$1 as on, encodeEffect as ot, Error$1 as p, toType$1 as pn, isGreaterThan as pt, UndefinedOr as q, Error$2 as qn, Filter as qt, Boolean as r, isOptional as rn, decodeUnknownEffect as rt, DateTimeUtc as s, replaceChecks as sn, encodeTo as st, Any as t, decodeTo$1 as tn, decodeSync as tt, DateTimeUtcFromString as u, resolveIdentifier as un, instanceOf as ut, Json as v, transformEffect as vn, isMaxProperties as vt, NonEmptyArray as w, transformEffect$1 as wn, make as wt, MutableJson as x, map as xn, isPropertyNames as xt, Literal as y, transformOptional as yn, isMinLength as yt, TaggedError as z, removeTime as zn, evolve as zt };
|
|
5787
5883
|
|
|
5788
|
-
//# sourceMappingURL=Schema-
|
|
5884
|
+
//# sourceMappingURL=Schema-CjUGw2Xh.mjs.map
|