clanka 0.11.0 → 0.12.1
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 +49 -0
- package/dist/Acp.d.ts +1 -1
- package/dist/Acp.d.ts.map +1 -1
- package/dist/Acp.js +122 -7
- package/dist/Acp.js.map +1 -1
- package/dist/Acp.test.js +240 -0
- package/dist/Acp.test.js.map +1 -1
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +26 -8
- package/dist/Agent.js.map +1 -1
- package/dist/AgentExecutor.js +15 -1
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentTools.d.ts +7 -0
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +7 -0
- package/dist/AgentTools.js.map +1 -1
- package/dist/McpConfig.d.ts +36 -0
- package/dist/McpConfig.d.ts.map +1 -0
- package/dist/McpConfig.js +182 -0
- package/dist/McpConfig.js.map +1 -0
- package/dist/McpConfig.test.d.ts +2 -0
- package/dist/McpConfig.test.d.ts.map +1 -0
- package/dist/McpConfig.test.js +163 -0
- package/dist/McpConfig.test.js.map +1 -0
- package/dist/McpServers.d.ts +176 -0
- package/dist/McpServers.d.ts.map +1 -0
- package/dist/McpServers.js +707 -0
- package/dist/McpServers.js.map +1 -0
- package/dist/McpServers.test.d.ts +2 -0
- package/dist/McpServers.test.d.ts.map +1 -0
- package/dist/McpServers.test.js +717 -0
- package/dist/McpServers.test.js.map +1 -0
- package/dist/TypeBuilder.d.ts +9 -0
- package/dist/TypeBuilder.d.ts.map +1 -1
- package/dist/TypeBuilder.js +24 -11
- package/dist/TypeBuilder.js.map +1 -1
- package/dist/TypeBuilder.test.js +33 -0
- package/dist/TypeBuilder.test.js.map +1 -1
- package/dist/bin/{Effect-zUBunSAW.mjs → Effect-DuThyCJ1.mjs} +87 -9
- package/dist/bin/Effect-DuThyCJ1.mjs.map +1 -0
- package/dist/bin/McpClient-CIiPyMDJ.mjs +36 -0
- package/dist/bin/McpClient-CIiPyMDJ.mjs.map +1 -0
- package/dist/bin/{OutputFormatter-BPdc6RmH.mjs → OutputFormatter-BvIjvUmT.mjs} +3 -3
- package/dist/bin/{OutputFormatter-BPdc6RmH.mjs.map → OutputFormatter-BvIjvUmT.mjs.map} +1 -1
- package/dist/bin/{Schema-C2Y2y3tU.mjs → Schema-DcXUXpRg.mjs} +831 -35
- package/dist/bin/Schema-DcXUXpRg.mjs.map +1 -0
- package/dist/bin/{SemanticSearch-BKZxP19F.mjs → SemanticSearch-CdGA4CIC.mjs} +5 -5
- package/dist/bin/{SemanticSearch-BKZxP19F.mjs.map → SemanticSearch-CdGA4CIC.mjs.map} +1 -1
- package/dist/bin/{Stream-BvmRbTMu.mjs → Stream-I9SRMlLj.mjs} +20 -22
- package/dist/bin/Stream-I9SRMlLj.mjs.map +1 -0
- package/dist/bin/cli.mjs +17646 -802
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/{index.min-DbZbUHX3.mjs → index.min-Bkz7vIWv.mjs} +5 -5
- package/dist/bin/{index.min-DbZbUHX3.mjs.map → index.min-Bkz7vIWv.mjs.map} +1 -1
- package/dist/bin/rolldown-runtime-zY4HT0JA.mjs +30 -0
- package/dist/bin/{turndown.cjs-DK29wZw3.mjs → turndown.cjs-LntFxFyd.mjs} +2 -2
- package/dist/bin/{turndown.cjs-DK29wZw3.mjs.map → turndown.cjs-LntFxFyd.mjs.map} +1 -1
- package/dist/cli.js +24 -2
- package/dist/cli.js.map +1 -1
- package/dist/fixtures/McpFakeServer.d.ts +47 -0
- package/dist/fixtures/McpFakeServer.d.ts.map +1 -0
- package/dist/fixtures/McpFakeServer.js +112 -0
- package/dist/fixtures/McpFakeServer.js.map +1 -0
- package/dist/fixtures/McpStdioServer.d.ts +2 -0
- package/dist/fixtures/McpStdioServer.d.ts.map +1 -0
- package/dist/fixtures/McpStdioServer.js +53 -0
- package/dist/fixtures/McpStdioServer.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Acp.test.ts +348 -0
- package/src/Acp.ts +154 -5
- package/src/Agent.ts +38 -10
- package/src/AgentExecutor.ts +14 -1
- package/src/AgentTools.ts +8 -0
- package/src/McpConfig.test.ts +238 -0
- package/src/McpConfig.ts +255 -0
- package/src/McpServers.test.ts +1050 -0
- package/src/McpServers.ts +1072 -0
- package/src/TypeBuilder.test.ts +70 -0
- package/src/TypeBuilder.ts +41 -14
- package/src/cli.ts +46 -0
- package/src/fixtures/McpFakeServer.ts +162 -0
- package/src/fixtures/McpStdioServer.ts +60 -0
- package/src/index.ts +5 -0
- package/dist/bin/Effect-zUBunSAW.mjs.map +0 -1
- package/dist/bin/McpClient-CnP2P7c9.mjs +0 -14179
- package/dist/bin/McpClient-CnP2P7c9.mjs.map +0 -1
- package/dist/bin/Schema-C2Y2y3tU.mjs.map +0 -1
- package/dist/bin/Stream-BvmRbTMu.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $a as millis, $o as make$9, $s as isNotUndefined, $t as tryPromise, As as symbolRedactable, Ba as isFailure, Bi as iterateConcurrent, Bs as string$1, Cc as Class$2, Ci as currentTimeMillis$1, Cs as format$1, Da as map$3, Ds as formatPropertyKey, Ea as makeEquivalence$3, Es as formatPath, F as failCauseSync, Fa as fail$1, Fo as liftThrowable, Fs as array, Gi as map$2, Go as Number$4, Gs as isBigInt, H as fnUntracedEager, Ha as map$6, Hs as structureKeys, Io as map$4, Is as combine, It as runSyncExit, Ja as infinity, Jo as isGreaterThanOrEqualTo$1, Js as isFunction, Ki as monotonicTimeNanos$1, Ko as String$4, Ks as isBoolean, Kt as suspend$1, L as flatMap, La as flatMap$1, Lo as match, Ls as hash, M as exit, Mo as isNone, N as fail$2, No as isOption, Ns as equals, Os as currentFiberTypeId, Po as isSome, Ps as symbol$2, Qo as Tuple$1, Qs as isNotNullish, R as flatMapEager, Ra as getOrThrow, Ro as none, Rs as number$1, Sa as isReadonlyArrayNonEmpty, Tc as pipeArguments, To as fromNullOr, Ts as formatJson, Ua as match$1, Uo as BigInt$4, Us as symbol$1, Ut as succeed$3, Va as isSuccess$1, Vi as iterateEager, Vo as some, Vs as structure, Wa as succeed$1, Wn as remainder, Wo as Date$3, Ws as hasProperty, Wt as succeedNone, Xa as isFinite$2, Xo as isLessThanOrEqualTo$1, Xs as isNever$1, Y as fromResult, Ya as isDuration, Yi as resolveConcurrency, Yo as isLessThan$1, Zo as make$10, _c as dual, _r as makeInterruptReason, _s as getStackTraceLimit, aa as encode$1, ac as isPropertyKey, ao as toSeconds, as as TaggedError$2, ba as isArrayNonEmpty, bc as memoize, cc as isTagged, ci as failCause, ct as mapBothEager, di as isExit, do as get, dt as mapErrorEager, en as try_, er as die$1, es as strictEqual, fa as dedupe, fr as isFailReason, gi as ClockRef, gr as makeFailReason, gs as assignProperty$1, hi as void_$1, hr as makeDieReason, hs as assignProperties, ic as isObjectKeyword, io as toMillis, is as PipeInspectableProto, js as asEquivalence, k as die, ko as getOrNull, ks as redact$2, lt as mapEager, m as catchCause, mi as succeed$2, nc as isNumber, no as negativeInfinity, oc as isString$1, or as fromReasons, os as args, pa as empty$4, pi as isSuccess, pr as isReason, qa as fromInputUnsafe, qn as IllegalArgumentError, qo as isGreaterThan$1, qs as isError, rc as isObject, ro as seconds, rs as Error$3, sc as isSymbol, si as fail$3, sn as void_$2, so as Reference, to as nanos, ua as append, uc as isUnknown, uo as empty$3, ur as isCause, va as fromIterable$1, vr as map$5, vs as setStackTraceLimit, wc as Prototype, wi as effectIsExit, wo as flatten, ws as formatDate, xc as memoizeIdempotent, xo as filter, xs as NodeInspectSymbol, yc as identity, ys as BaseProto, zs as optimize } from "./Effect-DuThyCJ1.mjs";
|
|
2
2
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Tuple.js
|
|
3
3
|
const makeEquivalence$2 = Tuple$1;
|
|
4
4
|
//#endregion
|
|
@@ -80,10 +80,10 @@ const Proto$4 = {
|
|
|
80
80
|
const ProtoUtc = {
|
|
81
81
|
...Proto$4,
|
|
82
82
|
_tag: "Utc",
|
|
83
|
-
[symbol]() {
|
|
83
|
+
[symbol$1]() {
|
|
84
84
|
return number$1(this.epochMilliseconds);
|
|
85
85
|
},
|
|
86
|
-
[symbol$
|
|
86
|
+
[symbol$2](that) {
|
|
87
87
|
return isDateTime$1(that) && that._tag === "Utc" && this.epochMilliseconds === that.epochMilliseconds;
|
|
88
88
|
},
|
|
89
89
|
toString() {
|
|
@@ -93,10 +93,10 @@ const ProtoUtc = {
|
|
|
93
93
|
const ProtoZoned = {
|
|
94
94
|
...Proto$4,
|
|
95
95
|
_tag: "Zoned",
|
|
96
|
-
[symbol]() {
|
|
96
|
+
[symbol$1]() {
|
|
97
97
|
return combine(number$1(this.epochMilliseconds))(hash(this.zone));
|
|
98
98
|
},
|
|
99
|
-
[symbol$
|
|
99
|
+
[symbol$2](that) {
|
|
100
100
|
return isDateTime$1(that) && that._tag === "Zoned" && this.epochMilliseconds === that.epochMilliseconds && equals(this.zone, that.zone);
|
|
101
101
|
},
|
|
102
102
|
toString() {
|
|
@@ -112,10 +112,10 @@ const ProtoTimeZone = {
|
|
|
112
112
|
const ProtoTimeZoneNamed = {
|
|
113
113
|
...ProtoTimeZone,
|
|
114
114
|
_tag: "Named",
|
|
115
|
-
[symbol]() {
|
|
115
|
+
[symbol$1]() {
|
|
116
116
|
return string$1(`Named:${this.id}`);
|
|
117
117
|
},
|
|
118
|
-
[symbol$
|
|
118
|
+
[symbol$2](that) {
|
|
119
119
|
return isTimeZone(that) && that._tag === "Named" && this.id === that.id;
|
|
120
120
|
},
|
|
121
121
|
toString() {
|
|
@@ -132,10 +132,10 @@ const ProtoTimeZoneNamed = {
|
|
|
132
132
|
const ProtoTimeZoneOffset = {
|
|
133
133
|
...ProtoTimeZone,
|
|
134
134
|
_tag: "Offset",
|
|
135
|
-
[symbol]() {
|
|
135
|
+
[symbol$1]() {
|
|
136
136
|
return string$1(`Offset:${this.offset}`);
|
|
137
137
|
},
|
|
138
|
-
[symbol$
|
|
138
|
+
[symbol$2](that) {
|
|
139
139
|
return isTimeZone(that) && that._tag === "Offset" && this.offset === that.offset;
|
|
140
140
|
},
|
|
141
141
|
toString() {
|
|
@@ -260,10 +260,10 @@ const Proto$3 = {
|
|
|
260
260
|
toString() {
|
|
261
261
|
return `<redacted${isString$1(this.label) ? ":" + this.label : ""}>`;
|
|
262
262
|
},
|
|
263
|
-
[symbol]() {
|
|
263
|
+
[symbol$1]() {
|
|
264
264
|
return hash(redactedRegistry.get(this));
|
|
265
265
|
},
|
|
266
|
-
[symbol$
|
|
266
|
+
[symbol$2](that) {
|
|
267
267
|
return isRedacted(that) && equals(redactedRegistry.get(this), redactedRegistry.get(that));
|
|
268
268
|
}
|
|
269
269
|
};
|
|
@@ -274,11 +274,11 @@ const makeEquivalence = (isEquivalent) => make$9((x, y) => isEquivalent(value(x)
|
|
|
274
274
|
const TypeId$10 = "~effect/BigDecimal";
|
|
275
275
|
const BigDecimalProto = {
|
|
276
276
|
[TypeId$10]: TypeId$10,
|
|
277
|
-
[symbol]() {
|
|
277
|
+
[symbol$1]() {
|
|
278
278
|
const normalized = normalize(this);
|
|
279
279
|
return combine(string$1(String(normalized.value)), number$1(normalized.scale));
|
|
280
280
|
},
|
|
281
|
-
[symbol$
|
|
281
|
+
[symbol$2](that) {
|
|
282
282
|
return isBigDecimal(that) && compare(this, that) === 0;
|
|
283
283
|
},
|
|
284
284
|
toString() {
|
|
@@ -694,10 +694,10 @@ const Proto$1 = Object.defineProperties(Object.create(null), {
|
|
|
694
694
|
toJSON: { value() {
|
|
695
695
|
return redact$2(this);
|
|
696
696
|
} },
|
|
697
|
-
[symbol$
|
|
697
|
+
[symbol$2]: { value(that) {
|
|
698
698
|
return Equivalence$1(this, that);
|
|
699
699
|
} },
|
|
700
|
-
[symbol]: { value() {
|
|
700
|
+
[symbol$1]: { value() {
|
|
701
701
|
return structure(this);
|
|
702
702
|
} },
|
|
703
703
|
toString: { value: BaseProto.toString },
|
|
@@ -788,10 +788,10 @@ const Proto = {
|
|
|
788
788
|
toJSON() {
|
|
789
789
|
return redact$2(this);
|
|
790
790
|
},
|
|
791
|
-
[symbol$
|
|
791
|
+
[symbol$2](that) {
|
|
792
792
|
return Equivalence(this, that);
|
|
793
793
|
},
|
|
794
|
-
[symbol]() {
|
|
794
|
+
[symbol$1]() {
|
|
795
795
|
return array(this.params.flat());
|
|
796
796
|
}
|
|
797
797
|
};
|
|
@@ -1240,6 +1240,9 @@ const passthrough_$1 = makeGetter({ _tag: "Passthrough" });
|
|
|
1240
1240
|
function passthrough$1() {
|
|
1241
1241
|
return passthrough_$1;
|
|
1242
1242
|
}
|
|
1243
|
+
function passthroughSubtype() {
|
|
1244
|
+
return passthrough_$1;
|
|
1245
|
+
}
|
|
1243
1246
|
function transform$1(f) {
|
|
1244
1247
|
return makeGetter({
|
|
1245
1248
|
_tag: "Transform",
|
|
@@ -1586,6 +1589,140 @@ const Unknown$1 = class extends ASTNodeImpl {
|
|
|
1586
1589
|
}
|
|
1587
1590
|
};
|
|
1588
1591
|
const unknown = new Unknown$1();
|
|
1592
|
+
const ObjectKeyword$1 = class extends ASTNodeImpl {
|
|
1593
|
+
_tag = "ObjectKeyword";
|
|
1594
|
+
getParser() {
|
|
1595
|
+
return fromRefinement(this, isObjectKeyword);
|
|
1596
|
+
}
|
|
1597
|
+
getExpected() {
|
|
1598
|
+
return "object | array | function";
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
const objectKeyword = new ObjectKeyword$1();
|
|
1602
|
+
const Enum$1 = class extends ASTNodeImpl {
|
|
1603
|
+
_tag = "Enum";
|
|
1604
|
+
enums;
|
|
1605
|
+
constructor(enums, annotations, checks, encoding, context) {
|
|
1606
|
+
super(annotations, checks, encoding, context);
|
|
1607
|
+
for (const [, value] of enums) if (typeof value === "number" && !globalThis.Number.isFinite(value)) throw new Error(`A numeric enum value must be finite, got ${format$1(value)}`);
|
|
1608
|
+
this.enums = enums;
|
|
1609
|
+
}
|
|
1610
|
+
getParser() {
|
|
1611
|
+
const values = new Set(this.enums.map(([, v]) => v));
|
|
1612
|
+
return fromRefinement(this, (input) => values.has(input));
|
|
1613
|
+
}
|
|
1614
|
+
toCodecStringTree() {
|
|
1615
|
+
if (this.enums.some(([_, v]) => typeof v === "number")) {
|
|
1616
|
+
const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v]));
|
|
1617
|
+
return replaceEncoding(this, [new Link(new Union$1(Object.keys(coercions).map((k) => new Literal$1(k))), new Transformation(transform$1((s) => coercions[s]), String$3()))]);
|
|
1618
|
+
}
|
|
1619
|
+
return this;
|
|
1620
|
+
}
|
|
1621
|
+
getExpected() {
|
|
1622
|
+
return this.enums.map(([_, value]) => JSON.stringify(value)).join(" | ");
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
function formatTemplateLiteralPath(path) {
|
|
1626
|
+
return typeof path === "number" ? `parts[${path}]` : path;
|
|
1627
|
+
}
|
|
1628
|
+
function isTemplateLiteralPart(ast, path, validated) {
|
|
1629
|
+
if (validated.has(ast)) return true;
|
|
1630
|
+
if (ast.encoding) throw new Error(`TemplateLiteral parts cannot have an encoding at ${formatTemplateLiteralPath(path)}`);
|
|
1631
|
+
let valid;
|
|
1632
|
+
switch (ast._tag) {
|
|
1633
|
+
case "String":
|
|
1634
|
+
case "Number":
|
|
1635
|
+
case "BigInt":
|
|
1636
|
+
valid = true;
|
|
1637
|
+
break;
|
|
1638
|
+
case "Literal":
|
|
1639
|
+
valid = !ast.checks;
|
|
1640
|
+
break;
|
|
1641
|
+
case "TemplateLiteral": {
|
|
1642
|
+
const currentPath = formatTemplateLiteralPath(path);
|
|
1643
|
+
valid = !ast.checks && ast.parts.every((part, index) => isTemplateLiteralPart(part, `${currentPath}.parts[${index}]`, validated));
|
|
1644
|
+
break;
|
|
1645
|
+
}
|
|
1646
|
+
case "Union": {
|
|
1647
|
+
const currentPath = formatTemplateLiteralPath(path);
|
|
1648
|
+
valid = !ast.checks && ast.types.every((part, index) => isTemplateLiteralPart(part, `${currentPath}.types[${index}]`, validated));
|
|
1649
|
+
break;
|
|
1650
|
+
}
|
|
1651
|
+
default: return false;
|
|
1652
|
+
}
|
|
1653
|
+
if (valid) validated.add(ast);
|
|
1654
|
+
return valid;
|
|
1655
|
+
}
|
|
1656
|
+
const TemplateLiteral$1 = class extends ASTNodeImpl {
|
|
1657
|
+
_tag = "TemplateLiteral";
|
|
1658
|
+
parts;
|
|
1659
|
+
encodedParts;
|
|
1660
|
+
literals;
|
|
1661
|
+
suffixLengths;
|
|
1662
|
+
constructor(parts, annotations, checks, encoding, context) {
|
|
1663
|
+
super(annotations, checks, encoding, context);
|
|
1664
|
+
const encodedParts = [];
|
|
1665
|
+
const literals = [];
|
|
1666
|
+
const validated = new Set();
|
|
1667
|
+
for (let index = 0; index < parts.length; index++) {
|
|
1668
|
+
const part = parts[index];
|
|
1669
|
+
if (!isTemplateLiteralPart(part, index, validated)) throw new Error(`Invalid TemplateLiteral part ${part._tag}`);
|
|
1670
|
+
encodedParts.push(part);
|
|
1671
|
+
literals.push(part._tag === "Literal" ? globalThis.String(part.literal) : void 0);
|
|
1672
|
+
}
|
|
1673
|
+
const suffixLengths = new Array(encodedParts.length + 1);
|
|
1674
|
+
suffixLengths[encodedParts.length] = 0;
|
|
1675
|
+
for (let i = encodedParts.length - 1; i >= 0; i--) suffixLengths[i] = suffixLengths[i + 1] + (literals[i]?.length ?? 0);
|
|
1676
|
+
this.parts = parts;
|
|
1677
|
+
this.encodedParts = encodedParts;
|
|
1678
|
+
this.literals = literals;
|
|
1679
|
+
this.suffixLengths = suffixLengths;
|
|
1680
|
+
}
|
|
1681
|
+
getParser(compile) {
|
|
1682
|
+
const tuple = new Arrays(false, this.parts.map(partFromString), []);
|
|
1683
|
+
const parser = compile(decodeTo$1(string, tuple, templateLiteralTransformation(this)));
|
|
1684
|
+
return (input, options) => {
|
|
1685
|
+
if (input === missing) return missingExit;
|
|
1686
|
+
const result = parser(input, options);
|
|
1687
|
+
if (result._tag === "Success") return sameExit;
|
|
1688
|
+
return mapBothEager(result, {
|
|
1689
|
+
onSuccess: () => input,
|
|
1690
|
+
onFailure: (issue) => new Composite(this, [issue], input, options)
|
|
1691
|
+
});
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
getExpected() {
|
|
1695
|
+
return "string";
|
|
1696
|
+
}
|
|
1697
|
+
matchPart(s, options) {
|
|
1698
|
+
return segmentTemplateLiteralParts(this, s, options) === void 0 ? void 0 : s;
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
function templateLiteralTransformation(template) {
|
|
1702
|
+
return new Transformation(transformEffect$1((s, options) => {
|
|
1703
|
+
const segments = segmentTemplateLiteralParts(template, s, options);
|
|
1704
|
+
if (segments) return succeed$3(segments);
|
|
1705
|
+
return fail$2(new InvalidValue({ expected: "a string matching template literal parts" }, s, options));
|
|
1706
|
+
}), transform$1((parts) => parts.join("")));
|
|
1707
|
+
}
|
|
1708
|
+
const UniqueSymbol$1 = class extends ASTNodeImpl {
|
|
1709
|
+
_tag = "UniqueSymbol";
|
|
1710
|
+
symbol;
|
|
1711
|
+
constructor(symbol, annotations, checks, encoding, context) {
|
|
1712
|
+
super(annotations, checks, encoding, context);
|
|
1713
|
+
this.symbol = symbol;
|
|
1714
|
+
}
|
|
1715
|
+
getParser() {
|
|
1716
|
+
return fromConst(this, this.symbol);
|
|
1717
|
+
}
|
|
1718
|
+
toCodecStringTree() {
|
|
1719
|
+
const key = globalThis.Symbol.keyFor(this.symbol);
|
|
1720
|
+
return replaceEncoding(this, [new Link(key === void 0 ? never : new Literal$1(globalThis.String(this.symbol)), symbolToString.transformation)]);
|
|
1721
|
+
}
|
|
1722
|
+
getExpected() {
|
|
1723
|
+
return globalThis.String(this.symbol);
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1589
1726
|
const Literal$1 = class extends ASTNodeImpl {
|
|
1590
1727
|
_tag = "Literal";
|
|
1591
1728
|
literal;
|
|
@@ -1671,6 +1808,23 @@ const Boolean$1 = class extends ASTNodeImpl {
|
|
|
1671
1808
|
}
|
|
1672
1809
|
};
|
|
1673
1810
|
const boolean = new Boolean$1();
|
|
1811
|
+
const Symbol$2 = class extends ASTNodeImpl {
|
|
1812
|
+
_tag = "Symbol";
|
|
1813
|
+
getParser() {
|
|
1814
|
+
return fromRefinement(this, isSymbol);
|
|
1815
|
+
}
|
|
1816
|
+
matchKey(s, options) {
|
|
1817
|
+
if (options.disableChecks || !this.checks) return s;
|
|
1818
|
+
return collectIssues(this.checks, s, void 0, this, options) ? void 0 : s;
|
|
1819
|
+
}
|
|
1820
|
+
toCodecStringTree() {
|
|
1821
|
+
return replaceEncoding(this, [symbolToString]);
|
|
1822
|
+
}
|
|
1823
|
+
getExpected() {
|
|
1824
|
+
return "symbol";
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
const symbol = new Symbol$2();
|
|
1674
1828
|
const BigInt$2 = class extends ASTNodeImpl {
|
|
1675
1829
|
_tag = "BigInt";
|
|
1676
1830
|
getParser() {
|
|
@@ -2143,6 +2297,10 @@ function structWithRest(ast, records) {
|
|
|
2143
2297
|
}
|
|
2144
2298
|
return new Objects(propertySignatures, indexSignatures, void 0, checks);
|
|
2145
2299
|
}
|
|
2300
|
+
function tupleWithRest(ast, rest) {
|
|
2301
|
+
if (ast.encoding) throw new Error("TupleWithRest does not support encodings");
|
|
2302
|
+
return new Arrays(ast.isMutable, ast.elements, rest, void 0, ast.checks);
|
|
2303
|
+
}
|
|
2146
2304
|
function mutable$1(ast) {
|
|
2147
2305
|
if (ast.encoding) throw new Error("mutable does not support encodings");
|
|
2148
2306
|
return new Arrays(true, ast.elements, ast.rest, ast.annotations, ast.checks, void 0, ast.context, ast.encodingChecks);
|
|
@@ -2693,6 +2851,11 @@ const optionalKey$1 = memoizeIdempotent((ast) => {
|
|
|
2693
2851
|
});
|
|
2694
2852
|
const optionalKeyLastLink = applyToLastLink(optionalKey$1);
|
|
2695
2853
|
const optional$1 = memoize((ast) => optionalKey$1(new Union$1([ast, undefined_])));
|
|
2854
|
+
const mutableKey$1 = memoizeIdempotent((ast) => {
|
|
2855
|
+
const context = ast.context ? ast.context.isMutable === false ? new Context(ast.context.isOptional, true, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(false, true);
|
|
2856
|
+
return mutableKeyLastLink(replaceContext(ast, context));
|
|
2857
|
+
});
|
|
2858
|
+
const mutableKeyLastLink = applyToLastLink(mutableKey$1);
|
|
2696
2859
|
function withConstructorDefault$1(ast, defaultValue) {
|
|
2697
2860
|
return replaceContext(ast, ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue));
|
|
2698
2861
|
}
|
|
@@ -2814,6 +2977,53 @@ function fromRefinement(ast, refinement) {
|
|
|
2814
2977
|
return fail$2(new InvalidType(ast, input, options));
|
|
2815
2978
|
};
|
|
2816
2979
|
}
|
|
2980
|
+
function segmentTemplateLiteralParts(ast, input, options) {
|
|
2981
|
+
const parts = ast.encodedParts;
|
|
2982
|
+
const literals = ast.literals;
|
|
2983
|
+
const inputLength = input.length;
|
|
2984
|
+
for (let i = 0; i < literals.length; i++) {
|
|
2985
|
+
const literal = literals[i];
|
|
2986
|
+
if (literal && !input.includes(literal)) return void 0;
|
|
2987
|
+
}
|
|
2988
|
+
if (ast.suffixLengths[0] > inputLength) return void 0;
|
|
2989
|
+
const out = new Array(parts.length);
|
|
2990
|
+
let failures;
|
|
2991
|
+
function go(i, pos) {
|
|
2992
|
+
if (i === parts.length) return pos === inputLength;
|
|
2993
|
+
if (failures?.has(i * (inputLength + 1) + pos)) return false;
|
|
2994
|
+
const part = parts[i];
|
|
2995
|
+
if (i === parts.length - 1) {
|
|
2996
|
+
const s = input.slice(pos);
|
|
2997
|
+
if (part.matchPart(s, options) !== void 0) {
|
|
2998
|
+
out[i] = s;
|
|
2999
|
+
return true;
|
|
3000
|
+
}
|
|
3001
|
+
} else if (part._tag === "Literal") {
|
|
3002
|
+
const s = literals[i];
|
|
3003
|
+
if (input.startsWith(s, pos) && go(i + 1, pos + s.length)) {
|
|
3004
|
+
out[i] = s;
|
|
3005
|
+
return true;
|
|
3006
|
+
}
|
|
3007
|
+
} else {
|
|
3008
|
+
const maximumEnd = inputLength - ast.suffixLengths[i + 1];
|
|
3009
|
+
const anchor = literals[i + 1];
|
|
3010
|
+
let end = anchor === void 0 ? maximumEnd : input.lastIndexOf(anchor, maximumEnd);
|
|
3011
|
+
while (end >= pos) {
|
|
3012
|
+
const s = input.slice(pos, end);
|
|
3013
|
+
if (part.matchPart(s, options) !== void 0 && go(i + 1, end)) {
|
|
3014
|
+
out[i] = s;
|
|
3015
|
+
return true;
|
|
3016
|
+
}
|
|
3017
|
+
if (end === 0) break;
|
|
3018
|
+
end = anchor === void 0 ? end - 1 : input.lastIndexOf(anchor, end - 1);
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
failures ??= new Set();
|
|
3022
|
+
failures.add(i * (inputLength + 1) + pos);
|
|
3023
|
+
return false;
|
|
3024
|
+
}
|
|
3025
|
+
return go(0, 0) ? out : void 0;
|
|
3026
|
+
}
|
|
2817
3027
|
const parameterFromPropertyKey = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
2818
3028
|
switch (ast._tag) {
|
|
2819
3029
|
default: return ast;
|
|
@@ -2829,6 +3039,15 @@ const parameterFromString = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
|
2829
3039
|
case "Union": return ast.recur(parameterFromString);
|
|
2830
3040
|
}
|
|
2831
3041
|
});
|
|
3042
|
+
const partFromString = applyToSelfOrLastLinkEncodingIdempotent((ast) => {
|
|
3043
|
+
switch (ast._tag) {
|
|
3044
|
+
default: return ast;
|
|
3045
|
+
case "Number":
|
|
3046
|
+
case "Literal":
|
|
3047
|
+
case "BigInt": return ast.toCodecStringTree();
|
|
3048
|
+
case "Union": return ast.recur(partFromString);
|
|
3049
|
+
}
|
|
3050
|
+
});
|
|
2832
3051
|
const STRING_PATTERN = "[\\s\\S]*?";
|
|
2833
3052
|
const isStringFiniteRegExp = new globalThis.RegExp(`^${FINITE_PATTERN}$`);
|
|
2834
3053
|
const isStringNumberRegExp = new globalThis.RegExp(`^(?:${FINITE_PATTERN}|Infinity|-Infinity|NaN)$`);
|
|
@@ -2860,6 +3079,23 @@ function isStringBigInt(annotations) {
|
|
|
2860
3079
|
}
|
|
2861
3080
|
const bigIntString = appendChecks(string, [isStringBigInt({ expected: "a string representing a bigint" })]);
|
|
2862
3081
|
const bigIntToString = new Link(bigIntString, bigintFromString);
|
|
3082
|
+
const isStringSymbolRegExp = new globalThis.RegExp(`^Symbol\\(([\\s\\S]*)\\)$`);
|
|
3083
|
+
const symbolString = appendChecks(string, [isStringSymbol()]);
|
|
3084
|
+
const symbolToString = new Link(symbolString, new Transformation(transform$1((description) => globalThis.Symbol.for(isStringSymbolRegExp.exec(description)[1])), transformEffect$1((sym, options) => {
|
|
3085
|
+
if (globalThis.Symbol.keyFor(sym) !== void 0) return succeed$3(globalThis.String(sym));
|
|
3086
|
+
return fail$2(new Forbidden({ message: "cannot serialize to string, Symbol is not registered" }, sym, options));
|
|
3087
|
+
})));
|
|
3088
|
+
function isStringSymbol(annotations) {
|
|
3089
|
+
return isPattern$1(isStringSymbolRegExp, {
|
|
3090
|
+
expected: "a string representing a symbol",
|
|
3091
|
+
representation: {
|
|
3092
|
+
id: "effect/schema/isStringSymbol",
|
|
3093
|
+
payload: null
|
|
3094
|
+
},
|
|
3095
|
+
toJsonSchema: () => ({ pattern: isStringSymbolRegExp.source }),
|
|
3096
|
+
...annotations
|
|
3097
|
+
});
|
|
3098
|
+
}
|
|
2863
3099
|
function collectIssues(checks, value, issues, ast, options) {
|
|
2864
3100
|
for (let i = 0; i < checks.length; i++) {
|
|
2865
3101
|
const check = checks[i];
|
|
@@ -3261,6 +3497,9 @@ const decodeEffect$1 = decodeUnknownEffect$1;
|
|
|
3261
3497
|
function decodeUnknownOption$1(schema, options) {
|
|
3262
3498
|
return asOption(decodeUnknownEffect$1(schema, options));
|
|
3263
3499
|
}
|
|
3500
|
+
function decodeUnknownResult(schema, options) {
|
|
3501
|
+
return asResult(decodeUnknownEffect$1(schema, options));
|
|
3502
|
+
}
|
|
3264
3503
|
function encodeUnknownEffect$1(schema, options) {
|
|
3265
3504
|
const parser = run(flip(schema.ast));
|
|
3266
3505
|
return options === void 0 ? parser : (input, overrideOptions) => parser(input, mergeParseOptions(options, overrideOptions));
|
|
@@ -3303,6 +3542,14 @@ function asOption(parser) {
|
|
|
3303
3542
|
return none();
|
|
3304
3543
|
};
|
|
3305
3544
|
}
|
|
3545
|
+
function asResult(parser) {
|
|
3546
|
+
const parserExit = asExit(parser);
|
|
3547
|
+
return (input, options) => {
|
|
3548
|
+
const exit = parserExit(input, options);
|
|
3549
|
+
if (isSuccess(exit)) return succeed$1(exit.value);
|
|
3550
|
+
return fail$1(getSchemaIssueOrThrow(exit.cause, "Result adapter can only return schema issues"));
|
|
3551
|
+
};
|
|
3552
|
+
}
|
|
3306
3553
|
function runSync(effect, message) {
|
|
3307
3554
|
const exit = runSyncExit(effect);
|
|
3308
3555
|
if (isSuccess(exit)) return exit.value;
|
|
@@ -3416,8 +3663,27 @@ function parseUriFragment(fragment) {
|
|
|
3416
3663
|
const pointer = decodeUriFragment(fragment);
|
|
3417
3664
|
return pointer === void 0 ? void 0 : pointer.length === 0 ? [] : pointer.slice(1).split("/").map(unescapeToken);
|
|
3418
3665
|
}
|
|
3666
|
+
function formatUriFragment(path) {
|
|
3667
|
+
return path.reduce((fragment, token) => `${fragment}/${formatUriFragmentToken(token)}`, "#");
|
|
3668
|
+
}
|
|
3419
3669
|
//#endregion
|
|
3420
3670
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/JsonSchema.js
|
|
3671
|
+
const META_SCHEMA_URI_DRAFT_07 = "http://json-schema.org/draft-07/schema#";
|
|
3672
|
+
const META_SCHEMA_URI_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
3673
|
+
function isMetaSchemaUri(value, uri) {
|
|
3674
|
+
return value === uri || value === (uri.endsWith("#") ? uri.slice(0, -1) : `${uri}#`);
|
|
3675
|
+
}
|
|
3676
|
+
function fromSchemaDraft07(js) {
|
|
3677
|
+
return fromSchemaDraft2020_12(convertDraft07(js));
|
|
3678
|
+
}
|
|
3679
|
+
function fromSchemaDraft2020_12(js) {
|
|
3680
|
+
const { $defs, ...schema } = js;
|
|
3681
|
+
return {
|
|
3682
|
+
dialect: "draft-2020-12",
|
|
3683
|
+
schema,
|
|
3684
|
+
definitions: isObject($defs) ? $defs : {}
|
|
3685
|
+
};
|
|
3686
|
+
}
|
|
3421
3687
|
function getReferenceKey($ref) {
|
|
3422
3688
|
const path = $ref.startsWith("#") ? parseUriFragment($ref) : void 0;
|
|
3423
3689
|
return path !== void 0 && path.length === 2 && path[0] === "$defs" ? path[1] : void 0;
|
|
@@ -3477,9 +3743,154 @@ function mapObject(value, f) {
|
|
|
3477
3743
|
for (const key of Object.keys(value)) assignProperty$1(out, key, f(value[key], key));
|
|
3478
3744
|
return out;
|
|
3479
3745
|
}
|
|
3746
|
+
function runConverter(adapter, options, use) {
|
|
3747
|
+
const locations = new Map();
|
|
3748
|
+
const references = [];
|
|
3749
|
+
let rootUri = ROOT_URI;
|
|
3750
|
+
function convert(root, sourcePath = [], targetPath = []) {
|
|
3751
|
+
if (sourcePath.length === 0 && options?.trackIds) rootUri = resolveResourceUri(isObject(root) ? getResourceId(root) : void 0, ROOT_URI) ?? ROOT_URI;
|
|
3752
|
+
return loop(root, sourcePath, targetPath, {
|
|
3753
|
+
sourceRoot: [],
|
|
3754
|
+
targetRoot: [],
|
|
3755
|
+
uri: rootUri
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
function finish() {
|
|
3759
|
+
for (const [out, value, sourceResource] of references) {
|
|
3760
|
+
let reference = value;
|
|
3761
|
+
const resolved = resolveUrl(value, sourceResource);
|
|
3762
|
+
if (resolved !== void 0) {
|
|
3763
|
+
const sourcePointer = parseUriFragment(resolved.hash);
|
|
3764
|
+
resolved.hash = "";
|
|
3765
|
+
if (sourcePointer !== void 0) {
|
|
3766
|
+
const targetPath = locations.get(locationKey(resolved.href, sourcePointer));
|
|
3767
|
+
if (targetPath !== void 0) reference = relocateReference(value, targetPath);
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
assignProperty$1(out, "$ref", reference);
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
const out = use(convert);
|
|
3774
|
+
finish();
|
|
3775
|
+
return out;
|
|
3776
|
+
function loop(node, sourcePath, targetPath, resourceScope) {
|
|
3777
|
+
if (typeof node === "boolean") {
|
|
3778
|
+
recordLocations(sourcePath, targetPath, resourceScope);
|
|
3779
|
+
return options?.booleanAdapter?.(node) ?? node;
|
|
3780
|
+
}
|
|
3781
|
+
if (!isObject(node)) return node;
|
|
3782
|
+
let currentResourceScope = resourceScope;
|
|
3783
|
+
const id = getResourceId(node);
|
|
3784
|
+
if (sourcePath.length > 0 && options?.trackIds && createsResource(id)) {
|
|
3785
|
+
const uri = resolveResourceUri(id, resourceScope.uri);
|
|
3786
|
+
if (uri !== void 0) currentResourceScope = {
|
|
3787
|
+
parent: resourceScope,
|
|
3788
|
+
sourceRoot: sourcePath,
|
|
3789
|
+
targetRoot: targetPath,
|
|
3790
|
+
uri
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
recordLocations(sourcePath, targetPath, currentResourceScope);
|
|
3794
|
+
const currentResource = currentResourceScope.uri;
|
|
3795
|
+
return adapter(node, {
|
|
3796
|
+
isDocumentRoot: sourcePath.length === 0,
|
|
3797
|
+
schema(value, sourceKey, targetKey = sourceKey) {
|
|
3798
|
+
return loop(value, [...sourcePath, sourceKey], [...targetPath, targetKey], currentResourceScope);
|
|
3799
|
+
},
|
|
3800
|
+
schemaAt(value, sourceSuffix, targetSuffix) {
|
|
3801
|
+
return loop(value, [...sourcePath, ...sourceSuffix], [...targetPath, ...targetSuffix], currentResourceScope);
|
|
3802
|
+
},
|
|
3803
|
+
schemaArray(value, sourceKey, targetKey = sourceKey) {
|
|
3804
|
+
return Array.isArray(value) ? value.map((item, index) => loop(item, [
|
|
3805
|
+
...sourcePath,
|
|
3806
|
+
sourceKey,
|
|
3807
|
+
String(index)
|
|
3808
|
+
], [
|
|
3809
|
+
...targetPath,
|
|
3810
|
+
targetKey,
|
|
3811
|
+
String(index)
|
|
3812
|
+
], currentResourceScope)) : value;
|
|
3813
|
+
},
|
|
3814
|
+
schemaMap(value, sourceKey, targetKey = sourceKey) {
|
|
3815
|
+
if (!isObject(value)) return value;
|
|
3816
|
+
return mapObject(value, (item, key) => loop(item, [
|
|
3817
|
+
...sourcePath,
|
|
3818
|
+
sourceKey,
|
|
3819
|
+
key
|
|
3820
|
+
], [
|
|
3821
|
+
...targetPath,
|
|
3822
|
+
targetKey,
|
|
3823
|
+
key
|
|
3824
|
+
], currentResourceScope));
|
|
3825
|
+
},
|
|
3826
|
+
reference(out, value) {
|
|
3827
|
+
if (typeof value === "string") references.push([
|
|
3828
|
+
out,
|
|
3829
|
+
value,
|
|
3830
|
+
currentResource
|
|
3831
|
+
]);
|
|
3832
|
+
else assignProperty$1(out, "$ref", value);
|
|
3833
|
+
}
|
|
3834
|
+
});
|
|
3835
|
+
}
|
|
3836
|
+
function getResourceId(schema) {
|
|
3837
|
+
return options?.ignoreRefSiblings === true && typeof schema.$ref === "string" ? void 0 : schema.$id;
|
|
3838
|
+
}
|
|
3839
|
+
function recordLocations(sourcePath, targetPath, scope) {
|
|
3840
|
+
if (scope.parent !== void 0) recordLocations(sourcePath, targetPath, scope.parent);
|
|
3841
|
+
locations.set(locationKey(scope.uri, sourcePath.slice(scope.sourceRoot.length)), targetPath.slice(scope.targetRoot.length));
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
const ROOT_URI = "https://effect.invalid/.json-schema/";
|
|
3845
|
+
function resolveUrl(value, base) {
|
|
3846
|
+
return URL.canParse(value, base) ? new URL(value, base) : void 0;
|
|
3847
|
+
}
|
|
3848
|
+
function resolveResourceUri(value, base) {
|
|
3849
|
+
if (typeof value !== "string") return void 0;
|
|
3850
|
+
const url = resolveUrl(value, base);
|
|
3851
|
+
if (url === void 0) return void 0;
|
|
3852
|
+
url.hash = "";
|
|
3853
|
+
return url.href;
|
|
3854
|
+
}
|
|
3855
|
+
function relocateReference(reference, targetPath) {
|
|
3856
|
+
const index = reference.indexOf("#");
|
|
3857
|
+
if (index === -1 && targetPath.length === 0) return reference;
|
|
3858
|
+
return `${index === -1 ? reference : reference.slice(0, index)}${formatUriFragment(targetPath)}`;
|
|
3859
|
+
}
|
|
3860
|
+
function locationKey(resource, pointer) {
|
|
3861
|
+
return `${resource}\u0000${JSON.stringify(pointer)}`;
|
|
3862
|
+
}
|
|
3480
3863
|
function createsResource(id) {
|
|
3481
3864
|
return typeof id === "string" && id.length > 0 && id[0] !== "#";
|
|
3482
3865
|
}
|
|
3866
|
+
function convertSchema(root, adapter, options) {
|
|
3867
|
+
return runConverter(adapter, options, (convert) => convert(root));
|
|
3868
|
+
}
|
|
3869
|
+
const SCHEMA_MAP_KEYWORDS = new Set(["properties", "patternProperties"]);
|
|
3870
|
+
const SCHEMA_ARRAY_KEYWORDS = new Set([
|
|
3871
|
+
"allOf",
|
|
3872
|
+
"anyOf",
|
|
3873
|
+
"oneOf"
|
|
3874
|
+
]);
|
|
3875
|
+
const JSON_SCHEMA_SINGLE_KEYWORDS = new Set([
|
|
3876
|
+
"not",
|
|
3877
|
+
"additionalProperties",
|
|
3878
|
+
"propertyNames",
|
|
3879
|
+
"contains",
|
|
3880
|
+
"if",
|
|
3881
|
+
"then",
|
|
3882
|
+
"else",
|
|
3883
|
+
"contentSchema"
|
|
3884
|
+
]);
|
|
3885
|
+
function convertSubschemaKeyword(out, key, value, context, singleKeywords, mapKeywords = SCHEMA_MAP_KEYWORDS) {
|
|
3886
|
+
let converted;
|
|
3887
|
+
if (mapKeywords.has(key)) converted = context.schemaMap(value, key);
|
|
3888
|
+
else if (SCHEMA_ARRAY_KEYWORDS.has(key)) converted = context.schemaArray(value, key);
|
|
3889
|
+
else if (singleKeywords.has(key)) converted = context.schema(value, key);
|
|
3890
|
+
else return false;
|
|
3891
|
+
assignProperty$1(out, key, converted);
|
|
3892
|
+
return true;
|
|
3893
|
+
}
|
|
3483
3894
|
const PRE_2020_TO_2020_COLLISIONS = [
|
|
3484
3895
|
"$anchor",
|
|
3485
3896
|
"$defs",
|
|
@@ -3512,6 +3923,89 @@ const OPEN_API_30_TO_2020_COLLISIONS = [
|
|
|
3512
3923
|
"propertyNames",
|
|
3513
3924
|
"then"
|
|
3514
3925
|
];
|
|
3926
|
+
const ANCHOR_REGEXP = /^[A-Za-z_][-A-Za-z0-9._]*$/;
|
|
3927
|
+
function convertDraft07(root) {
|
|
3928
|
+
return convertSchema(root, (source, context) => {
|
|
3929
|
+
const out = {};
|
|
3930
|
+
if (typeof source.$ref === "string") {
|
|
3931
|
+
context.reference(out, source.$ref);
|
|
3932
|
+
if (Object.hasOwn(source, "definitions")) assignProperty$1(out, "$defs", context.schemaMap(source.definitions, "definitions", "$defs"));
|
|
3933
|
+
return out;
|
|
3934
|
+
}
|
|
3935
|
+
rejectKeywordCollisions(source, DRAFT_07_TO_2020_COLLISIONS, "Draft 2020-12", "Draft-07");
|
|
3936
|
+
let items = void 0;
|
|
3937
|
+
let additionalItems = void 0;
|
|
3938
|
+
for (const key of Object.keys(source)) {
|
|
3939
|
+
const value = source[key];
|
|
3940
|
+
if (convertSubschemaKeyword(out, key, value, context, JSON_SCHEMA_SINGLE_KEYWORDS)) continue;
|
|
3941
|
+
switch (key) {
|
|
3942
|
+
case "$schema":
|
|
3943
|
+
assignProperty$1(out, key, isMetaSchemaUri(value, "http://json-schema.org/draft-07/schema#") ? META_SCHEMA_URI_DRAFT_2020_12 : value);
|
|
3944
|
+
break;
|
|
3945
|
+
case "$id":
|
|
3946
|
+
convertDraft07Id(out, value);
|
|
3947
|
+
break;
|
|
3948
|
+
case "definitions":
|
|
3949
|
+
assignProperty$1(out, "$defs", context.schemaMap(value, key, "$defs"));
|
|
3950
|
+
break;
|
|
3951
|
+
case "dependencies": {
|
|
3952
|
+
if (!isObject(value)) {
|
|
3953
|
+
assignProperty$1(out, key, value);
|
|
3954
|
+
break;
|
|
3955
|
+
}
|
|
3956
|
+
const dependentRequired = {};
|
|
3957
|
+
const dependentSchemas = {};
|
|
3958
|
+
for (const dependency of Object.keys(value)) {
|
|
3959
|
+
const dependencyValue = value[dependency];
|
|
3960
|
+
assignProperty$1(Array.isArray(dependencyValue) ? dependentRequired : dependentSchemas, dependency, Array.isArray(dependencyValue) ? dependencyValue : context.schemaAt(dependencyValue, ["dependencies", dependency], ["dependentSchemas", dependency]));
|
|
3961
|
+
}
|
|
3962
|
+
if (Object.keys(dependentRequired).length > 0) assignProperty$1(out, "dependentRequired", dependentRequired);
|
|
3963
|
+
if (Object.keys(dependentSchemas).length > 0) assignProperty$1(out, "dependentSchemas", dependentSchemas);
|
|
3964
|
+
break;
|
|
3965
|
+
}
|
|
3966
|
+
case "items":
|
|
3967
|
+
items = value;
|
|
3968
|
+
break;
|
|
3969
|
+
case "additionalItems":
|
|
3970
|
+
additionalItems = value;
|
|
3971
|
+
break;
|
|
3972
|
+
default: assignProperty$1(out, key, value);
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
if (items !== void 0) {
|
|
3976
|
+
if (Array.isArray(items)) {
|
|
3977
|
+
assignProperty$1(out, "prefixItems", context.schemaArray(items, "items", "prefixItems"));
|
|
3978
|
+
if (additionalItems !== void 0) assignProperty$1(out, "items", context.schema(additionalItems, "additionalItems", "items"));
|
|
3979
|
+
} else assignProperty$1(out, "items", context.schema(items, "items"));
|
|
3980
|
+
}
|
|
3981
|
+
return out;
|
|
3982
|
+
}, {
|
|
3983
|
+
trackIds: true,
|
|
3984
|
+
ignoreRefSiblings: true
|
|
3985
|
+
});
|
|
3986
|
+
}
|
|
3987
|
+
function convertDraft07Id(out, value) {
|
|
3988
|
+
if (typeof value !== "string" || !value.includes("#")) {
|
|
3989
|
+
assignProperty$1(out, "$id", value);
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3992
|
+
const fragmentIndex = value.indexOf("#");
|
|
3993
|
+
const id = value.slice(0, fragmentIndex);
|
|
3994
|
+
const anchor = value.slice(fragmentIndex + 1);
|
|
3995
|
+
if (anchor.length === 0) {
|
|
3996
|
+
if (id.length > 0) assignProperty$1(out, "$id", id);
|
|
3997
|
+
return;
|
|
3998
|
+
}
|
|
3999
|
+
if (!ANCHOR_REGEXP.test(anchor)) unsupported("$id", "Draft 2020-12", `fragment "#${anchor}" is not a valid $anchor`);
|
|
4000
|
+
if (id.length > 0) assignProperty$1(out, "$id", id);
|
|
4001
|
+
assignProperty$1(out, "$anchor", anchor);
|
|
4002
|
+
}
|
|
4003
|
+
function unsupported(keyword, dialect, details) {
|
|
4004
|
+
throw new Error(`Cannot convert JSON Schema keyword "${keyword}" to ${dialect}: ${details}`);
|
|
4005
|
+
}
|
|
4006
|
+
function rejectKeywordCollisions(source, keywords, targetDialect, sourceDialect) {
|
|
4007
|
+
for (const keyword of keywords) if (Object.hasOwn(source, keyword)) unsupported(keyword, targetDialect, `it is not active in ${sourceDialect} but would become active in the target`);
|
|
4008
|
+
}
|
|
3515
4009
|
//#endregion
|
|
3516
4010
|
//#region node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/schema/toCodec.js
|
|
3517
4011
|
function toCodecJson$1(schema) {
|
|
@@ -4529,10 +5023,10 @@ const Ipv4Proto = {
|
|
|
4529
5023
|
...BaseProto,
|
|
4530
5024
|
_tag: "Ipv4Address",
|
|
4531
5025
|
[TypeId$2]: TypeId$2,
|
|
4532
|
-
[symbol$
|
|
5026
|
+
[symbol$2](that) {
|
|
4533
5027
|
return isIpv4Address(that) && ipv4Value(this) === ipv4Value(that);
|
|
4534
5028
|
},
|
|
4535
|
-
[symbol]() {
|
|
5029
|
+
[symbol$1]() {
|
|
4536
5030
|
return optimize(combine(ipv4HashSeed, ipv4Value(this) | 0));
|
|
4537
5031
|
},
|
|
4538
5032
|
toString() {
|
|
@@ -4546,13 +5040,13 @@ const Ipv6Proto = {
|
|
|
4546
5040
|
...BaseProto,
|
|
4547
5041
|
_tag: "Ipv6Address",
|
|
4548
5042
|
[TypeId$2]: TypeId$2,
|
|
4549
|
-
[symbol$
|
|
5043
|
+
[symbol$2](that) {
|
|
4550
5044
|
if (!isIpv6Address(that)) return false;
|
|
4551
5045
|
const self = ipv6Words(this);
|
|
4552
5046
|
const other = ipv6Words(that);
|
|
4553
5047
|
return self.w0 === other.w0 && self.w1 === other.w1 && self.w2 === other.w2 && self.w3 === other.w3;
|
|
4554
5048
|
},
|
|
4555
|
-
[symbol]() {
|
|
5049
|
+
[symbol$1]() {
|
|
4556
5050
|
const self = ipv6Words(this);
|
|
4557
5051
|
let h = combine(ipv6HashSeed, self.w0 | 0);
|
|
4558
5052
|
h = combine(h, self.w1 | 0);
|
|
@@ -4570,10 +5064,10 @@ const MacProto = {
|
|
|
4570
5064
|
...BaseProto,
|
|
4571
5065
|
_tag: "MacAddress",
|
|
4572
5066
|
[TypeId$2]: TypeId$2,
|
|
4573
|
-
[symbol$
|
|
5067
|
+
[symbol$2](that) {
|
|
4574
5068
|
return isMacAddress(that) && bytesEqual(getMacBytes(this), getMacBytes(that));
|
|
4575
5069
|
},
|
|
4576
|
-
[symbol]() {
|
|
5070
|
+
[symbol$1]() {
|
|
4577
5071
|
return combine(macHashSeed, array(getMacBytes(this)));
|
|
4578
5072
|
},
|
|
4579
5073
|
toString() {
|
|
@@ -4721,10 +5215,10 @@ const InetV4Proto = {
|
|
|
4721
5215
|
...BaseProto,
|
|
4722
5216
|
_tag: "InetAddressV4",
|
|
4723
5217
|
[TypeId$2]: TypeId$2,
|
|
4724
|
-
[symbol$
|
|
5218
|
+
[symbol$2](that) {
|
|
4725
5219
|
return isInetAddressV4(that) && this.port === that.port && equals(this.address, that.address);
|
|
4726
5220
|
},
|
|
4727
|
-
[symbol]() {
|
|
5221
|
+
[symbol$1]() {
|
|
4728
5222
|
return combine(hash(this.address), number$1(this.port));
|
|
4729
5223
|
},
|
|
4730
5224
|
toString() {
|
|
@@ -4738,10 +5232,10 @@ const InetV6Proto = {
|
|
|
4738
5232
|
...BaseProto,
|
|
4739
5233
|
_tag: "InetAddressV6",
|
|
4740
5234
|
[TypeId$2]: TypeId$2,
|
|
4741
|
-
[symbol$
|
|
5235
|
+
[symbol$2](that) {
|
|
4742
5236
|
return isInetAddressV6(that) && this.port === that.port && this.scopeId === that.scopeId && equals(this.address, that.address);
|
|
4743
5237
|
},
|
|
4744
|
-
[symbol]() {
|
|
5238
|
+
[symbol$1]() {
|
|
4745
5239
|
return combine(combine(hash(this.address), number$1(this.port)), number$1(this.scopeId));
|
|
4746
5240
|
},
|
|
4747
5241
|
toString() {
|
|
@@ -4760,10 +5254,10 @@ const UnixPathProto = {
|
|
|
4760
5254
|
...BaseProto,
|
|
4761
5255
|
_tag: "UnixPathAddress",
|
|
4762
5256
|
[TypeId$2]: TypeId$2,
|
|
4763
|
-
[symbol$
|
|
5257
|
+
[symbol$2](that) {
|
|
4764
5258
|
return isUnixPathAddress(that) && this.path === that.path;
|
|
4765
5259
|
},
|
|
4766
|
-
[symbol]() {
|
|
5260
|
+
[symbol$1]() {
|
|
4767
5261
|
return combine(string$1("UnixPathAddress"), string$1(this.path));
|
|
4768
5262
|
},
|
|
4769
5263
|
toString() {
|
|
@@ -4798,10 +5292,10 @@ const HostPortProto = {
|
|
|
4798
5292
|
...BaseProto,
|
|
4799
5293
|
_tag: "HostPort",
|
|
4800
5294
|
[TypeId$1]: TypeId$1,
|
|
4801
|
-
[symbol$
|
|
5295
|
+
[symbol$2](that) {
|
|
4802
5296
|
return isHostPort(that) && this.port === that.port && equals(this.host, that.host);
|
|
4803
5297
|
},
|
|
4804
|
-
[symbol]() {
|
|
5298
|
+
[symbol$1]() {
|
|
4805
5299
|
return combine(hash(this.host), number$1(this.port));
|
|
4806
5300
|
},
|
|
4807
5301
|
toString() {
|
|
@@ -4875,10 +5369,10 @@ const isDnsRecord = (u) => hasProperty(u, RecordTypeId);
|
|
|
4875
5369
|
const RecordPrototype = {
|
|
4876
5370
|
...BaseProto,
|
|
4877
5371
|
[RecordTypeId]: RecordTypeId,
|
|
4878
|
-
[symbol$
|
|
5372
|
+
[symbol$2](that) {
|
|
4879
5373
|
return isDnsRecord(that) && that._tag === this._tag && Object.keys(this).every((key) => equals(this[key], that[key]));
|
|
4880
5374
|
},
|
|
4881
|
-
[symbol]() {
|
|
5375
|
+
[symbol$1]() {
|
|
4882
5376
|
return structureKeys(this, Object.keys(this));
|
|
4883
5377
|
},
|
|
4884
5378
|
toString() {
|
|
@@ -5047,6 +5541,7 @@ const optional = lambda((self) => {
|
|
|
5047
5541
|
const schema = UndefinedOr(self);
|
|
5048
5542
|
return make(optional$1(self.ast), { schema });
|
|
5049
5543
|
});
|
|
5544
|
+
const mutableKey = lambda((schema) => make(mutableKey$1(schema.ast), { schema }));
|
|
5050
5545
|
const toType = lambda((schema) => make(toType$1(schema.ast), { schema }));
|
|
5051
5546
|
const toEncoded = lambda((schema) => make(toEncoded$1(schema.ast), { schema }));
|
|
5052
5547
|
function Literal(literal) {
|
|
@@ -5061,6 +5556,15 @@ function Literal(literal) {
|
|
|
5061
5556
|
});
|
|
5062
5557
|
return out;
|
|
5063
5558
|
}
|
|
5559
|
+
function templateLiteralParts(parts) {
|
|
5560
|
+
return parts.map((part) => isSchema(part) ? part.ast : new Literal$1(part));
|
|
5561
|
+
}
|
|
5562
|
+
function TemplateLiteral(parts) {
|
|
5563
|
+
return make(new TemplateLiteral$1(templateLiteralParts(parts)), { parts });
|
|
5564
|
+
}
|
|
5565
|
+
function Enum(enums) {
|
|
5566
|
+
return make(new Enum$1(Object.keys(enums).filter((key) => typeof enums[enums[key]] !== "number").map((key) => [key, enums[key]])), { enums });
|
|
5567
|
+
}
|
|
5064
5568
|
const Never = make(never);
|
|
5065
5569
|
const Any = make(any);
|
|
5066
5570
|
const Unknown = make(unknown);
|
|
@@ -5070,8 +5574,13 @@ const String$1 = make(string);
|
|
|
5070
5574
|
const StringForLiteralAutocomplete = String$1;
|
|
5071
5575
|
const Number$1 = make(number);
|
|
5072
5576
|
const Boolean = make(boolean);
|
|
5577
|
+
const Symbol$1 = make(symbol);
|
|
5073
5578
|
const BigInt$1 = make(bigInt);
|
|
5074
5579
|
const Void = make(void_);
|
|
5580
|
+
const ObjectKeyword = make(objectKeyword);
|
|
5581
|
+
function UniqueSymbol(symbol) {
|
|
5582
|
+
return make(new UniqueSymbol$1(symbol));
|
|
5583
|
+
}
|
|
5075
5584
|
function makeStruct(ast, fields) {
|
|
5076
5585
|
return make(ast, {
|
|
5077
5586
|
fields,
|
|
@@ -5108,6 +5617,12 @@ function makeTuple(ast, elements) {
|
|
|
5108
5617
|
function Tuple(elements) {
|
|
5109
5618
|
return makeTuple(tuple(elements), elements);
|
|
5110
5619
|
}
|
|
5620
|
+
function TupleWithRest(schema, rest) {
|
|
5621
|
+
return make(tupleWithRest(schema.ast, rest.map(getAST)), {
|
|
5622
|
+
schema,
|
|
5623
|
+
rest
|
|
5624
|
+
});
|
|
5625
|
+
}
|
|
5111
5626
|
const ArraySchema = lambda((schema) => make(new Arrays(false, [], [schema.ast]), { value: schema }));
|
|
5112
5627
|
const NonEmptyArray = lambda((schema) => make(new Arrays(false, [schema.ast], [schema.ast]), { value: schema }));
|
|
5113
5628
|
const mutable = lambda((schema) => make(mutable$1(schema.ast), { schema }));
|
|
@@ -5317,6 +5832,9 @@ function link() {
|
|
|
5317
5832
|
};
|
|
5318
5833
|
}
|
|
5319
5834
|
const makeFilter = makeFilter$1;
|
|
5835
|
+
function makeFilterGroup(checks, annotations = void 0) {
|
|
5836
|
+
return new FilterGroup(checks, annotations);
|
|
5837
|
+
}
|
|
5320
5838
|
function isPattern(regExp, annotations) {
|
|
5321
5839
|
const source = regExp.source;
|
|
5322
5840
|
const flags = regExp.flags;
|
|
@@ -5328,6 +5846,26 @@ function isPattern(regExp, annotations) {
|
|
|
5328
5846
|
...annotations
|
|
5329
5847
|
});
|
|
5330
5848
|
}
|
|
5849
|
+
const getUUIDRegExp = (version) => {
|
|
5850
|
+
if (version) return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
5851
|
+
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;
|
|
5852
|
+
};
|
|
5853
|
+
function isUUID(version, annotations) {
|
|
5854
|
+
const regExp = getUUIDRegExp(version);
|
|
5855
|
+
return isPattern(regExp, {
|
|
5856
|
+
expected: version ? `a UUID v${version}` : "a UUID",
|
|
5857
|
+
representation: {
|
|
5858
|
+
id: "effect/schema/isUUID",
|
|
5859
|
+
payload: { version: version ?? null }
|
|
5860
|
+
},
|
|
5861
|
+
toJsonSchema: () => ({
|
|
5862
|
+
pattern: regExp.source,
|
|
5863
|
+
format: "uuid"
|
|
5864
|
+
}),
|
|
5865
|
+
toCode: () => ({ runtime: version === void 0 ? "Schema.isUUID()" : `Schema.isUUID(${version})` }),
|
|
5866
|
+
...annotations
|
|
5867
|
+
});
|
|
5868
|
+
}
|
|
5331
5869
|
function isBase64(annotations) {
|
|
5332
5870
|
const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
5333
5871
|
return isPattern(regExp, {
|
|
@@ -5341,6 +5879,68 @@ function isBase64(annotations) {
|
|
|
5341
5879
|
...annotations
|
|
5342
5880
|
});
|
|
5343
5881
|
}
|
|
5882
|
+
function literalToJsonSchema(literal, original, pattern) {
|
|
5883
|
+
if (literal.length === 0) return original.length === 0 ? {} : [{}, true];
|
|
5884
|
+
const constraint = { pattern: new globalThis.RegExp(pattern).source };
|
|
5885
|
+
return literal === original ? constraint : [constraint, true];
|
|
5886
|
+
}
|
|
5887
|
+
function isStartingWith(startsWith, annotations) {
|
|
5888
|
+
const formatted = JSON.stringify(startsWith);
|
|
5889
|
+
const regExp = new globalThis.RegExp(`^${escape(startsWith)}`);
|
|
5890
|
+
const jsonSchemaLiteral = startsWith.replace(/[\uD800-\uDBFF]$/, "");
|
|
5891
|
+
return makeFilter((s) => s.startsWith(startsWith), {
|
|
5892
|
+
expected: `a string starting with ${formatted}`,
|
|
5893
|
+
representation: {
|
|
5894
|
+
id: "effect/schema/isStartingWith",
|
|
5895
|
+
payload: { startsWith }
|
|
5896
|
+
},
|
|
5897
|
+
toJsonSchema: () => literalToJsonSchema(jsonSchemaLiteral, startsWith, `^${escape(jsonSchemaLiteral)}`),
|
|
5898
|
+
toCode: () => ({ runtime: `Schema.isStartingWith(${format$1(startsWith)})` }),
|
|
5899
|
+
arbitraryConstraint: { patterns: [{
|
|
5900
|
+
source: regExp.source,
|
|
5901
|
+
flags: regExp.flags
|
|
5902
|
+
}] },
|
|
5903
|
+
...annotations
|
|
5904
|
+
});
|
|
5905
|
+
}
|
|
5906
|
+
function isEndingWith(endsWith, annotations) {
|
|
5907
|
+
const formatted = JSON.stringify(endsWith);
|
|
5908
|
+
const regExp = new globalThis.RegExp(`${escape(endsWith)}$`);
|
|
5909
|
+
const jsonSchemaLiteral = endsWith.replace(/^[\uDC00-\uDFFF]/, "");
|
|
5910
|
+
return makeFilter((s) => s.endsWith(endsWith), {
|
|
5911
|
+
expected: `a string ending with ${formatted}`,
|
|
5912
|
+
representation: {
|
|
5913
|
+
id: "effect/schema/isEndingWith",
|
|
5914
|
+
payload: { endsWith }
|
|
5915
|
+
},
|
|
5916
|
+
toJsonSchema: () => literalToJsonSchema(jsonSchemaLiteral, endsWith, `${escape(jsonSchemaLiteral)}$`),
|
|
5917
|
+
toCode: () => ({ runtime: `Schema.isEndingWith(${format$1(endsWith)})` }),
|
|
5918
|
+
arbitraryConstraint: { patterns: [{
|
|
5919
|
+
source: regExp.source,
|
|
5920
|
+
flags: regExp.flags
|
|
5921
|
+
}] },
|
|
5922
|
+
...annotations
|
|
5923
|
+
});
|
|
5924
|
+
}
|
|
5925
|
+
function isIncluding(includes, annotations) {
|
|
5926
|
+
const formatted = JSON.stringify(includes);
|
|
5927
|
+
const regExp = new globalThis.RegExp(escape(includes));
|
|
5928
|
+
const jsonSchemaLiteral = includes.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g, "");
|
|
5929
|
+
return makeFilter((s) => s.includes(includes), {
|
|
5930
|
+
expected: `a string including ${formatted}`,
|
|
5931
|
+
representation: {
|
|
5932
|
+
id: "effect/schema/isIncluding",
|
|
5933
|
+
payload: { includes }
|
|
5934
|
+
},
|
|
5935
|
+
toJsonSchema: () => literalToJsonSchema(jsonSchemaLiteral, includes, escape(jsonSchemaLiteral)),
|
|
5936
|
+
toCode: () => ({ runtime: `Schema.isIncluding(${format$1(includes)})` }),
|
|
5937
|
+
arbitraryConstraint: { patterns: [{
|
|
5938
|
+
source: regExp.source,
|
|
5939
|
+
flags: regExp.flags
|
|
5940
|
+
}] },
|
|
5941
|
+
...annotations
|
|
5942
|
+
});
|
|
5943
|
+
}
|
|
5344
5944
|
const Finite = make(finite);
|
|
5345
5945
|
const isFinite = isFinite$1;
|
|
5346
5946
|
function makeIsGreaterThan(options) {
|
|
@@ -5499,6 +6099,20 @@ const isBetween = makeIsBetween({
|
|
|
5499
6099
|
};
|
|
5500
6100
|
}
|
|
5501
6101
|
});
|
|
6102
|
+
function isMultipleOf(divisor, annotations) {
|
|
6103
|
+
if (!globalThis.Number.isFinite(divisor) || divisor === 0) throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(divisor)}`);
|
|
6104
|
+
divisor = globalThis.Math.abs(divisor);
|
|
6105
|
+
return makeFilter((input) => remainder(input, divisor) === 0, {
|
|
6106
|
+
expected: `a value that is a multiple of ${divisor}`,
|
|
6107
|
+
representation: {
|
|
6108
|
+
id: "effect/schema/isMultipleOf",
|
|
6109
|
+
payload: { divisor }
|
|
6110
|
+
},
|
|
6111
|
+
toJsonSchema: () => ({ multipleOf: divisor }),
|
|
6112
|
+
toCode: () => ({ runtime: `Schema.isMultipleOf(${format$1(divisor)})` }),
|
|
6113
|
+
...annotations
|
|
6114
|
+
});
|
|
6115
|
+
}
|
|
5502
6116
|
function isInt(annotations) {
|
|
5503
6117
|
return makeFilter((n) => globalThis.Number.isSafeInteger(n), {
|
|
5504
6118
|
expected: "an integer",
|
|
@@ -5711,6 +6325,42 @@ function isMaxLength(maxLength, annotations) {
|
|
|
5711
6325
|
...annotations
|
|
5712
6326
|
});
|
|
5713
6327
|
}
|
|
6328
|
+
function isBetweenLength(minimum, maximum, annotations) {
|
|
6329
|
+
minimum = normalizeCardinality(minimum);
|
|
6330
|
+
maximum = normalizeCardinality(maximum);
|
|
6331
|
+
return makeFilter((input) => input.length >= minimum && input.length <= maximum, {
|
|
6332
|
+
expected: minimum === maximum ? `a value with a length of ${minimum}` : `a value with a length between ${minimum} and ${maximum}`,
|
|
6333
|
+
representation: {
|
|
6334
|
+
id: "effect/schema/isBetweenLength",
|
|
6335
|
+
payload: {
|
|
6336
|
+
minimum,
|
|
6337
|
+
maximum
|
|
6338
|
+
}
|
|
6339
|
+
},
|
|
6340
|
+
toJsonSchema: ({ type }) => type === "string" ? maximum === 0 || Math.ceil(minimum / 2) > maximum ? {
|
|
6341
|
+
minLength: Math.ceil(minimum / 2),
|
|
6342
|
+
maxLength: maximum
|
|
6343
|
+
} : [{
|
|
6344
|
+
minLength: Math.ceil(minimum / 2),
|
|
6345
|
+
maxLength: maximum
|
|
6346
|
+
}, true] : type === "array" ? {
|
|
6347
|
+
minItems: minimum,
|
|
6348
|
+
maxItems: maximum
|
|
6349
|
+
} : type === void 0 ? [{
|
|
6350
|
+
minLength: Math.ceil(minimum / 2),
|
|
6351
|
+
maxLength: maximum,
|
|
6352
|
+
minItems: minimum,
|
|
6353
|
+
maxItems: maximum
|
|
6354
|
+
}, true] : [{}, true],
|
|
6355
|
+
toCode: () => ({ runtime: `Schema.isBetweenLength(${minimum}, ${maximum})` }),
|
|
6356
|
+
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
6357
|
+
arbitraryConstraint: {
|
|
6358
|
+
minLength: minimum,
|
|
6359
|
+
maxLength: maximum
|
|
6360
|
+
},
|
|
6361
|
+
...annotations
|
|
6362
|
+
});
|
|
6363
|
+
}
|
|
5714
6364
|
function isMinCodePoints(minCodePoints, annotations) {
|
|
5715
6365
|
minCodePoints = normalizeCardinality(minCodePoints);
|
|
5716
6366
|
return makeFilter((input) => countCodePointsUpTo(input, minCodePoints) >= minCodePoints, {
|
|
@@ -5739,6 +6389,30 @@ function isMaxCodePoints(maxCodePoints, annotations) {
|
|
|
5739
6389
|
...annotations
|
|
5740
6390
|
});
|
|
5741
6391
|
}
|
|
6392
|
+
function isBetweenCodePoints(minimum, maximum, annotations) {
|
|
6393
|
+
minimum = normalizeCardinality(minimum);
|
|
6394
|
+
maximum = normalizeCardinality(maximum);
|
|
6395
|
+
return makeFilter((input) => {
|
|
6396
|
+
const count = countCodePointsUpTo(input, maximum + 1);
|
|
6397
|
+
return count >= minimum && count <= maximum;
|
|
6398
|
+
}, {
|
|
6399
|
+
expected: minimum === maximum ? `a string with ${minimum} code points` : `a string with between ${minimum} and ${maximum} code points`,
|
|
6400
|
+
representation: {
|
|
6401
|
+
id: "effect/schema/isBetweenCodePoints",
|
|
6402
|
+
payload: {
|
|
6403
|
+
minimum,
|
|
6404
|
+
maximum
|
|
6405
|
+
}
|
|
6406
|
+
},
|
|
6407
|
+
toJsonSchema: () => ({ allOf: [{ minLength: minimum }, { maxLength: maximum }] }),
|
|
6408
|
+
toCode: () => ({ runtime: `Schema.isBetweenCodePoints(${minimum}, ${maximum})` }),
|
|
6409
|
+
arbitraryConstraint: {
|
|
6410
|
+
minCodePoints: minimum,
|
|
6411
|
+
maxCodePoints: maximum
|
|
6412
|
+
},
|
|
6413
|
+
...annotations
|
|
6414
|
+
});
|
|
6415
|
+
}
|
|
5742
6416
|
function countCodePointsUpTo(input, limit) {
|
|
5743
6417
|
if (limit === 0) return 0;
|
|
5744
6418
|
let count = 0;
|
|
@@ -5749,6 +6423,73 @@ function normalizeCardinality(value) {
|
|
|
5749
6423
|
if (!globalThis.Number.isFinite(value)) throw new globalThis.RangeError(`Expected a finite number, got ${value}`);
|
|
5750
6424
|
return Math.max(0, Math.floor(value));
|
|
5751
6425
|
}
|
|
6426
|
+
function isMinSize(minSize, annotations) {
|
|
6427
|
+
minSize = normalizeCardinality(minSize);
|
|
6428
|
+
return makeFilter((input) => input.size >= minSize, {
|
|
6429
|
+
expected: `a value with a size of at least ${minSize}`,
|
|
6430
|
+
representation: {
|
|
6431
|
+
id: "effect/schema/isMinSize",
|
|
6432
|
+
payload: { minSize }
|
|
6433
|
+
},
|
|
6434
|
+
toJsonSchema: () => [{}, true],
|
|
6435
|
+
toCode: () => ({ runtime: `Schema.isMinSize(${minSize})` }),
|
|
6436
|
+
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
6437
|
+
arbitraryConstraint: { minSize },
|
|
6438
|
+
...annotations
|
|
6439
|
+
});
|
|
6440
|
+
}
|
|
6441
|
+
function isMaxSize(maxSize, annotations) {
|
|
6442
|
+
maxSize = normalizeCardinality(maxSize);
|
|
6443
|
+
return makeFilter((input) => input.size <= maxSize, {
|
|
6444
|
+
expected: `a value with a size of at most ${maxSize}`,
|
|
6445
|
+
representation: {
|
|
6446
|
+
id: "effect/schema/isMaxSize",
|
|
6447
|
+
payload: { maxSize }
|
|
6448
|
+
},
|
|
6449
|
+
toJsonSchema: () => [{}, true],
|
|
6450
|
+
toCode: () => ({ runtime: `Schema.isMaxSize(${maxSize})` }),
|
|
6451
|
+
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
6452
|
+
arbitraryConstraint: { maxSize },
|
|
6453
|
+
...annotations
|
|
6454
|
+
});
|
|
6455
|
+
}
|
|
6456
|
+
function isBetweenSize(minimum, maximum, annotations) {
|
|
6457
|
+
minimum = normalizeCardinality(minimum);
|
|
6458
|
+
maximum = normalizeCardinality(maximum);
|
|
6459
|
+
return makeFilter((input) => input.size >= minimum && input.size <= maximum, {
|
|
6460
|
+
expected: minimum === maximum ? `a value with a size of ${minimum}` : `a value with a size between ${minimum} and ${maximum}`,
|
|
6461
|
+
representation: {
|
|
6462
|
+
id: "effect/schema/isBetweenSize",
|
|
6463
|
+
payload: {
|
|
6464
|
+
minimum,
|
|
6465
|
+
maximum
|
|
6466
|
+
}
|
|
6467
|
+
},
|
|
6468
|
+
toJsonSchema: () => [{}, true],
|
|
6469
|
+
toCode: () => ({ runtime: `Schema.isBetweenSize(${minimum}, ${maximum})` }),
|
|
6470
|
+
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
6471
|
+
arbitraryConstraint: {
|
|
6472
|
+
minSize: minimum,
|
|
6473
|
+
maxSize: maximum
|
|
6474
|
+
},
|
|
6475
|
+
...annotations
|
|
6476
|
+
});
|
|
6477
|
+
}
|
|
6478
|
+
function isMinProperties(minProperties, annotations) {
|
|
6479
|
+
minProperties = normalizeCardinality(minProperties);
|
|
6480
|
+
return makeFilter((input) => Reflect.ownKeys(input).length >= minProperties, {
|
|
6481
|
+
expected: `a value with at least ${minProperties === 1 ? "1 entry" : `${minProperties} entries`}`,
|
|
6482
|
+
representation: {
|
|
6483
|
+
id: "effect/schema/isMinProperties",
|
|
6484
|
+
payload: { minProperties }
|
|
6485
|
+
},
|
|
6486
|
+
toJsonSchema: ({ type }) => type === "object" ? { minProperties } : [{ minProperties }, true],
|
|
6487
|
+
toCode: () => ({ runtime: `Schema.isMinProperties(${minProperties})` }),
|
|
6488
|
+
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
6489
|
+
arbitraryConstraint: { minProperties },
|
|
6490
|
+
...annotations
|
|
6491
|
+
});
|
|
6492
|
+
}
|
|
5752
6493
|
function isMaxProperties(maxProperties, annotations) {
|
|
5753
6494
|
maxProperties = normalizeCardinality(maxProperties);
|
|
5754
6495
|
return makeFilter((input) => Reflect.ownKeys(input).length <= maxProperties, {
|
|
@@ -5764,6 +6505,34 @@ function isMaxProperties(maxProperties, annotations) {
|
|
|
5764
6505
|
...annotations
|
|
5765
6506
|
});
|
|
5766
6507
|
}
|
|
6508
|
+
function isBetweenProperties(minimum, maximum, annotations) {
|
|
6509
|
+
minimum = normalizeCardinality(minimum);
|
|
6510
|
+
maximum = normalizeCardinality(maximum);
|
|
6511
|
+
return makeFilter((input) => Reflect.ownKeys(input).length >= minimum && Reflect.ownKeys(input).length <= maximum, {
|
|
6512
|
+
expected: minimum === maximum ? `a value with exactly ${minimum === 1 ? "1 entry" : `${minimum} entries`}` : `a value with between ${minimum} and ${maximum} entries`,
|
|
6513
|
+
representation: {
|
|
6514
|
+
id: "effect/schema/isBetweenProperties",
|
|
6515
|
+
payload: {
|
|
6516
|
+
minimum,
|
|
6517
|
+
maximum
|
|
6518
|
+
}
|
|
6519
|
+
},
|
|
6520
|
+
toJsonSchema: ({ type }) => type === "object" ? {
|
|
6521
|
+
minProperties: minimum,
|
|
6522
|
+
maxProperties: maximum
|
|
6523
|
+
} : [{
|
|
6524
|
+
minProperties: minimum,
|
|
6525
|
+
maxProperties: maximum
|
|
6526
|
+
}, true],
|
|
6527
|
+
toCode: () => ({ runtime: `Schema.isBetweenProperties(${minimum}, ${maximum})` }),
|
|
6528
|
+
[STRUCTURAL_ANNOTATION_KEY]: true,
|
|
6529
|
+
arbitraryConstraint: {
|
|
6530
|
+
minProperties: minimum,
|
|
6531
|
+
maxProperties: maximum
|
|
6532
|
+
},
|
|
6533
|
+
...annotations
|
|
6534
|
+
});
|
|
6535
|
+
}
|
|
5767
6536
|
function isPropertyNames(keySchema, annotations) {
|
|
5768
6537
|
const propertyNames = toEncoded(keySchema);
|
|
5769
6538
|
const parser = _issue(propertyNames.ast);
|
|
@@ -5792,6 +6561,19 @@ function isPropertyNames(keySchema, annotations) {
|
|
|
5792
6561
|
...annotations
|
|
5793
6562
|
});
|
|
5794
6563
|
}
|
|
6564
|
+
function isUnique(annotations) {
|
|
6565
|
+
return makeFilter((input) => dedupe(input).length === input.length, {
|
|
6566
|
+
expected: "an array with unique items",
|
|
6567
|
+
representation: {
|
|
6568
|
+
id: "effect/schema/isUnique",
|
|
6569
|
+
payload: null
|
|
6570
|
+
},
|
|
6571
|
+
toJsonSchema: () => ({ uniqueItems: true }),
|
|
6572
|
+
toCode: () => ({ runtime: "Schema.isUnique()" }),
|
|
6573
|
+
arbitraryConstraint: { uniqueBy: identity },
|
|
6574
|
+
...annotations
|
|
6575
|
+
});
|
|
6576
|
+
}
|
|
5795
6577
|
const NonEmptyString = String$1.check(isNonEmpty());
|
|
5796
6578
|
const getErrorOptionsKey = (options) => (options?.includeStack === true ? 1 : 0) | (options?.excludeCause === true ? 2 : 0);
|
|
5797
6579
|
const getErrorOptions = (key) => {
|
|
@@ -6164,6 +6946,10 @@ const DateTimeUtcFromMillis = Int.pipe(decodeTo(DateTimeUtc, {
|
|
|
6164
6946
|
}));
|
|
6165
6947
|
const Ipv4Address = declare(isIpv4Address, { identifier: "Ipv4Address" });
|
|
6166
6948
|
const Ipv6Address = declare(isIpv6Address, { identifier: "Ipv6Address" });
|
|
6949
|
+
const durationFromMillis = transform({
|
|
6950
|
+
decode: (i) => millis(i),
|
|
6951
|
+
encode: (a) => toMillis(a)
|
|
6952
|
+
});
|
|
6167
6953
|
const Duration = declare(isDuration, {
|
|
6168
6954
|
representation: {
|
|
6169
6955
|
id: "effect/schema/Duration",
|
|
@@ -6211,6 +6997,7 @@ const Duration = declare(isDuration, {
|
|
|
6211
6997
|
}
|
|
6212
6998
|
}))
|
|
6213
6999
|
});
|
|
7000
|
+
const DurationFromMillis = Number$1.pipe(decodeTo(Duration, durationFromMillis));
|
|
6214
7001
|
const dnsCanonicalAddress = (schema, parse) => String$1.pipe(decodeTo(schema, transformEffect({
|
|
6215
7002
|
decode: (input, options) => {
|
|
6216
7003
|
const result = parse(input);
|
|
@@ -6432,6 +7219,15 @@ function Redacted(value$4, options) {
|
|
|
6432
7219
|
});
|
|
6433
7220
|
return make(schema.ast, { value: value$4 });
|
|
6434
7221
|
}
|
|
7222
|
+
function RedactedFromValue(value$2, options) {
|
|
7223
|
+
return decodeTo(Redacted(toType(value$2), {
|
|
7224
|
+
label: options?.label,
|
|
7225
|
+
disallowJsonEncode: options?.disallowEncode
|
|
7226
|
+
}), {
|
|
7227
|
+
decode: transform$1((t) => make$7(t, { label: options?.label })),
|
|
7228
|
+
encode: options?.disallowEncode ? forbidden((oe) => "Cannot encode Redacted" + (isSome(oe) && typeof oe.value.label === "string" ? ` with label: "${oe.value.label}"` : "")) : transform$1(value)
|
|
7229
|
+
})(value$2);
|
|
7230
|
+
}
|
|
6435
7231
|
const immerable = globalThis.Symbol.for("immer-draftable");
|
|
6436
7232
|
const payloadToken = {};
|
|
6437
7233
|
function makeClass(Inherited, identifier, struct$1, annotations, proto) {
|
|
@@ -6581,6 +7377,6 @@ const MutableJson = make(annotate(MutableJson$1, { toCode: () => ({
|
|
|
6581
7377
|
Type: "Schema.MutableJson"
|
|
6582
7378
|
}) }));
|
|
6583
7379
|
//#endregion
|
|
6584
|
-
export {
|
|
7380
|
+
export { TupleWithRest as $, null_ as $n, monotonicTimeNanos as $r, isMinLength as $t, NonEmptyString as A, toCodecJson$1 as An, CurrentRedactedNames$1 as Ar, isBetweenProperties as At, RedactedFromValue as B, Filter as Bn, fromSetCookie as Br, isIncluding as Bt, JsonObject as C, toType as Cn, CurrentRedactedNames as Cr, instanceOf as Ct, Natural as D, evolve as Dn, setAll as Dr, isBetweenCodePoints as Dt, MutableJson as E, withDecodingDefaultKey as En, redactUrl as Er, isBetweenBigInt as Et, Option as F, decodeEffect$1 as Fn, merge as Fr, isGreaterThanBigInt as Ft, StructWithRest as G, Suspend as Gn, fromDateUnsafe as Gr, isLessThanOrEqualTo as Gt, String$1 as H, Literal$1 as Hn, encode as Hr, isLessThan as Ht, OptionFromNullOr as I, decodeUnknownEffect$1 as In, remove as Ir, isGreaterThanDate as It, TaggedError as J, decodeTo$1 as Jn, isRedacted as Jr, isMaxCodePoints as Jt, Symbol$1 as K, Union$1 as Kn, now as Kr, isLessThanOrEqualToBigInt as Kt, OptionFromOptional as L, decodeUnknownResult as Ln, set as Lr, isGreaterThanOrEqualTo as Lt, NullOr as M, fromSchemaDraft2020_12 as Mn, fromInput$1 as Mr, isEndingWith as Mt, Number$1 as N, getReferenceKey as Nn, fromRecordUnsafe as Nr, isFinite as Nt, Never as O, omit as On, toString as Or, isBetweenDate as Ot, ObjectKeyword as P, _is as Pn, isRedactedName$1 as Pr, isGreaterThan as Pt, Tuple as Q, mapOrSame as Qn, Clock as Qr, isMinCodePoints as Qt, Record as R, encodeEffect$1 as Rn, setAll$1 as Rr, isGreaterThanOrEqualToBigInt as Rt, Json as S, toJsonSchemaDocument as Sn, Pointer as Sr, fromJsonString as St, Literals as T, withDecodingDefault as Tn, fromInput as Tr, isBetween as Tt, StringForLiteralAutocomplete as U, Objects as Un, formatIso as Ur, isLessThanBigInt as Ut, SchemaError as V, FilterGroup as Vn, decode as Vr, isInt as Vt, Struct as W, PropertySignature as Wn, formatIsoDate as Wr, isLessThanDate as Wt, TemplateLiteral as X, isNever as Xn, value as Xr, isMaxProperties as Xt, TaggedUnion as Y, isJson as Yn, make$7 as Yr, isMaxLength as Yt, TrueLiterals as Z, isOptional as Zn, stringOrRedacted as Zr, isMaxSize as Zt, Error$1 as _, suspend as _n, passthroughSubtype as _r, decodeUnknownOption as _t, BooleanFromBit as a, assignProperty as ai, isSchema as an, string as ar, UndefinedOr as at, Finite as b, toCodecStringTree as bn, transformOptional$1 as br, encodeTo as bt, Date$1 as c, isUUID as cn, unknown as cr, Unknown as ct, DateTimeUtcFromMillis as d, makeFilter as dn, transform as dr, check as dt, EncodingError as ei, isMinProperties as en, optionalKey$1 as er, URL$1 as et, DateTimeUtcFromString as f, makeFilterGroup as fn, transformEffect as fr, declare as ft, Enum as g, optionalKey as gn, passthrough$1 as gr, decodeUnknownEffect as gt, DurationFromMillis as h, optional as hn, map as hr, decodeTo as ht, Boolean as i, taggedEnum as ii, isPropertyNames as in, resolveIdentifier as ir, Undefined as it, Null as j, fromSchemaDraft07 as jn, empty$1 as jr, isBetweenSize as jt, NonEmptyArray as k, errorWithPath as kn, unwrap as kr, isBetweenLength as kt, DateTimeUtc as l, isUnique as ln, Transformation as lr, Void as lt, Duration as m, mutableKey as mn, dateTimeUtcFromInput$1 as mr, decodeSync as mt, ArraySchema as n, TaggedClass$1 as ni, isMultipleOf as nn, resolveAt as nr, Uint8Array$1 as nt, BooleanLiterals as o, map$1 as oi, isSchemaError as on, toEncoded$1 as or, Union as ot, Defect as p, mutable as pn, transformOptional as pr, decodeEffect as pt, TaggedClass as q, applyToSelfOrLastLinkEncoding as qn, removeTime as qr, isLessThanOrEqualToDate as qt, BigInt$1 as r, TaggedError$1 as ri, isPattern as rn, resolveDescription as rr, Uint8ArrayFromBase64 as rt, Class as s, isStartingWith as sn, toType$1 as sr, UniqueSymbol as st, Any as t, Error$2 as ti, isMinSize as tn, replaceChecks as tr, URLFromString as tt, DateTimeUtcFromDate as u, make as un, passthrough as ur, brand as ut, Exit as v, tag as vn, transform$1 as vr, decodeUnknownSync as vt, Literal as w, withConstructorDefault as wn, empty as wr, is as wt, Int as x, toEncoded as xn, InvalidValue as xr, encodeUnknownEffect as xt, FalseLiterals as y, toCodecJson as yn, transformEffect$1 as yr, encodeEffect as yt, Redacted as z, Arrays as zn, empty$2 as zr, isGreaterThanOrEqualToDate as zt };
|
|
6585
7381
|
|
|
6586
|
-
//# sourceMappingURL=Schema-
|
|
7382
|
+
//# sourceMappingURL=Schema-DcXUXpRg.mjs.map
|