@agntn/harnesses 0.1.1 → 0.2.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 +152 -117
- package/dist/_chunks/agents.mjs +2 -30
- package/dist/_chunks/agents.mjs.map +1 -1
- package/dist/_chunks/libs/typebox.mjs +535 -608
- package/dist/_chunks/libs/typebox.mjs.map +1 -1
- package/dist/_chunks/mcp-servers.mjs +5 -34
- package/dist/_chunks/mcp-servers.mjs.map +1 -1
- package/dist/_chunks/mcp.mjs +13 -163
- package/dist/_chunks/mcp.mjs.map +1 -1
- package/dist/_chunks/output.mjs +28 -0
- package/dist/_chunks/output.mjs.map +1 -0
- package/dist/_chunks/{agents-sync.d.mts → prompt-sync.d.mts} +91 -44
- package/dist/_chunks/prompt-sync.d.mts.map +1 -0
- package/dist/_chunks/{agents-sync.mjs → prompt-sync.mjs} +565 -26
- package/dist/_chunks/prompt-sync.mjs.map +1 -0
- package/dist/_chunks/prompts.mjs +28 -0
- package/dist/_chunks/prompts.mjs.map +1 -0
- package/dist/_chunks/tool-operations.mjs +43 -10
- package/dist/_chunks/tool-operations.mjs.map +1 -1
- package/dist/_chunks/tool-schemas.d.mts +17 -13
- package/dist/_chunks/tool-schemas.d.mts.map +1 -1
- package/dist/_chunks/tool-schemas.mjs +4 -0
- package/dist/_chunks/tool-schemas.mjs.map +1 -1
- package/dist/_chunks/types.mjs +1 -1
- package/dist/_chunks/types.mjs.map +1 -1
- package/dist/cli.mjs +6 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +26 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +1 -2
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +176 -1
- package/dist/mcp.mjs.map +1 -0
- package/dist/tool-operations.d.mts +42 -32
- package/dist/tool-operations.d.mts.map +1 -1
- package/dist/tool-operations.mjs +2 -2
- package/dist/tool-schemas.d.mts +2 -2
- package/package.json +24 -21
- package/packages/omp/extensions/harnesses.ts +19 -1
- package/packages/pi/extensions/harnesses.ts +26 -2
- package/packages/shared/tui.ts +22 -1
- package/dist/_chunks/agents-sync.d.mts.map +0 -1
- package/dist/_chunks/agents-sync.mjs.map +0 -1
- package/dist/_chunks/mcp2.mjs +0 -17
- package/dist/_chunks/mcp2.mjs.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "node:module";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __exportAll = (all, no_symbols) => {
|
|
3
4
|
let target = {};
|
|
@@ -15,89 +16,20 @@ const Metrics = {
|
|
|
15
16
|
discard: 0,
|
|
16
17
|
update: 0
|
|
17
18
|
};
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
function IsZeroWidthJoiner(value) {
|
|
22
|
-
return value === 8205;
|
|
23
|
-
}
|
|
24
|
-
function IsHighSurrogate(value) {
|
|
25
|
-
return IsBetween(value, 55296, 56319);
|
|
26
|
-
}
|
|
27
|
-
function IsRegionalIndicator(value) {
|
|
28
|
-
return IsBetween(value, 127462, 127487);
|
|
29
|
-
}
|
|
30
|
-
function IsVariationSelector(value) {
|
|
31
|
-
return IsBetween(value, 65024, 65039);
|
|
32
|
-
}
|
|
33
|
-
function IsCombiningMark(value) {
|
|
34
|
-
return IsBetween(value, 768, 879) || IsBetween(value, 6832, 6911) || IsBetween(value, 7616, 7679) || IsBetween(value, 65056, 65071);
|
|
35
|
-
}
|
|
36
|
-
function CodePointLength(value) {
|
|
37
|
-
return value > 65535 ? 2 : 1;
|
|
38
|
-
}
|
|
39
|
-
function ConsumeModifiers(value, index) {
|
|
19
|
+
function CodePointCount$1(value) {
|
|
20
|
+
let result = 0, index = 0, prev = 0;
|
|
40
21
|
while (index < value.length) {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
const next = value.charCodeAt(index++) >> 10;
|
|
23
|
+
result += +((prev << 8 | next) !== 13879);
|
|
24
|
+
prev = next;
|
|
44
25
|
}
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
function NextGraphemeClusterIndex(value, clusterStart) {
|
|
48
|
-
const startCP = value.codePointAt(clusterStart);
|
|
49
|
-
let clusterEnd = clusterStart + CodePointLength(startCP);
|
|
50
|
-
clusterEnd = ConsumeModifiers(value, clusterEnd);
|
|
51
|
-
while (clusterEnd < value.length - 1 && IsZeroWidthJoiner(value.codePointAt(clusterEnd))) {
|
|
52
|
-
const nextCP = value.codePointAt(clusterEnd + 1);
|
|
53
|
-
clusterEnd += 1 + CodePointLength(nextCP);
|
|
54
|
-
clusterEnd = ConsumeModifiers(value, clusterEnd);
|
|
55
|
-
}
|
|
56
|
-
if (IsRegionalIndicator(startCP) && clusterEnd < value.length && IsRegionalIndicator(value.codePointAt(clusterEnd))) clusterEnd += CodePointLength(value.codePointAt(clusterEnd));
|
|
57
|
-
return clusterEnd;
|
|
58
|
-
}
|
|
59
|
-
function IsGraphemeCodePoint(value) {
|
|
60
|
-
return IsHighSurrogate(value) || IsCombiningMark(value) || IsVariationSelector(value) || IsZeroWidthJoiner(value);
|
|
61
|
-
}
|
|
62
|
-
function IsMinLengthSegmented(value, minLength) {
|
|
63
|
-
if (minLength === 0) return true;
|
|
64
|
-
let count = 0;
|
|
65
|
-
let index = 0;
|
|
66
|
-
while (index < value.length) {
|
|
67
|
-
index = NextGraphemeClusterIndex(value, index);
|
|
68
|
-
count++;
|
|
69
|
-
if (count >= minLength) return true;
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
26
|
+
return result;
|
|
72
27
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
let index = 0;
|
|
76
|
-
while (index < value.length) {
|
|
77
|
-
index = NextGraphemeClusterIndex(value, index);
|
|
78
|
-
count++;
|
|
79
|
-
if (count > maxLength) return false;
|
|
80
|
-
}
|
|
81
|
-
return true;
|
|
28
|
+
function IsMaxLength$2(value, maxLength) {
|
|
29
|
+
return value.length <= maxLength || value.length <= maxLength << 1 && CodePointCount$1(value) <= maxLength;
|
|
82
30
|
}
|
|
83
31
|
function IsMinLength$2(value, minLength) {
|
|
84
|
-
|
|
85
|
-
let index = 0;
|
|
86
|
-
while (index < value.length) {
|
|
87
|
-
if (IsGraphemeCodePoint(value.charCodeAt(index))) return IsMinLengthSegmented(value, minLength);
|
|
88
|
-
index++;
|
|
89
|
-
if (index >= minLength) return true;
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
function IsMaxLength$2(value, maxLength) {
|
|
94
|
-
let index = 0;
|
|
95
|
-
while (index < value.length) {
|
|
96
|
-
if (IsGraphemeCodePoint(value.charCodeAt(index))) return IsMaxLengthSegmented(value, maxLength);
|
|
97
|
-
index++;
|
|
98
|
-
if (index > maxLength) return false;
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
32
|
+
return value.length >= minLength << 1 || value.length >= minLength && CodePointCount$1(value) >= minLength;
|
|
101
33
|
}
|
|
102
34
|
function IsArray$1(value) {
|
|
103
35
|
return Array.isArray(value);
|
|
@@ -174,28 +106,30 @@ function IsClassInstance(value) {
|
|
|
174
106
|
function IsValueLike(value) {
|
|
175
107
|
return IsBigInt$1(value) || IsBoolean$2(value) || IsNull$1(value) || IsNumber$2(value) || IsString$2(value) || IsUndefined$1(value);
|
|
176
108
|
}
|
|
177
|
-
function IsMaxLength$1(value,
|
|
178
|
-
return IsMaxLength$2(value,
|
|
109
|
+
function IsMaxLength$1(value, maxLength) {
|
|
110
|
+
return IsMaxLength$2(value, maxLength);
|
|
179
111
|
}
|
|
180
|
-
function IsMinLength$1(value,
|
|
181
|
-
return IsMinLength$2(value,
|
|
112
|
+
function IsMinLength$1(value, minLength) {
|
|
113
|
+
return IsMinLength$2(value, minLength);
|
|
182
114
|
}
|
|
183
115
|
function Every(value, offset, callback) {
|
|
184
|
-
|
|
185
|
-
return true;
|
|
116
|
+
return value.every((item, index) => index < offset || callback(item, index));
|
|
186
117
|
}
|
|
187
118
|
function EveryAll(value, offset, callback) {
|
|
188
119
|
let result = true;
|
|
189
|
-
|
|
120
|
+
value.forEach((item, index) => {
|
|
121
|
+
if (index >= offset && !callback(item, index)) result = false;
|
|
122
|
+
});
|
|
190
123
|
return result;
|
|
191
124
|
}
|
|
192
125
|
function Some(value, callback) {
|
|
193
|
-
|
|
194
|
-
return false;
|
|
126
|
+
return value.some((value, index) => callback(value, index));
|
|
195
127
|
}
|
|
196
128
|
function SomeAll(value, callback) {
|
|
197
129
|
let result = false;
|
|
198
|
-
|
|
130
|
+
value.forEach((item, index) => {
|
|
131
|
+
if (callback(item, index)) result = true;
|
|
132
|
+
});
|
|
199
133
|
return result;
|
|
200
134
|
}
|
|
201
135
|
function Counted(value, callback) {
|
|
@@ -260,6 +194,7 @@ function IsMap(value) {
|
|
|
260
194
|
const settings = {
|
|
261
195
|
immutableTypes: false,
|
|
262
196
|
maxErrors: 8,
|
|
197
|
+
maxParseErrors: 1,
|
|
263
198
|
maxInstantiationCount: 128,
|
|
264
199
|
useAcceleration: true,
|
|
265
200
|
exactOptionalPropertyTypes: false,
|
|
@@ -291,7 +226,7 @@ function FromSchemaObject(value) {
|
|
|
291
226
|
for (const key of Keys(value)) {
|
|
292
227
|
if (IsUnsafePropertyKey(key)) continue;
|
|
293
228
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
294
|
-
descriptor.value = FromValue$
|
|
229
|
+
descriptor.value = FromValue$1(descriptor.value);
|
|
295
230
|
if (IsEqual(descriptor.enumerable, true)) result[key] = descriptor.value;
|
|
296
231
|
else Object.defineProperty(result, key, descriptor);
|
|
297
232
|
}
|
|
@@ -301,16 +236,16 @@ function FromPlainObject(value) {
|
|
|
301
236
|
const result = {};
|
|
302
237
|
for (const key of Keys(value)) {
|
|
303
238
|
if (IsUnsafePropertyKey(key)) continue;
|
|
304
|
-
result[key] = FromValue$
|
|
239
|
+
result[key] = FromValue$1(value[key]);
|
|
305
240
|
}
|
|
306
|
-
for (const key of Symbols(value)) result[key] = FromValue$
|
|
241
|
+
for (const key of Symbols(value)) result[key] = FromValue$1(value[key]);
|
|
307
242
|
return result;
|
|
308
243
|
}
|
|
309
|
-
function FromObject$
|
|
244
|
+
function FromObject$12(value) {
|
|
310
245
|
return IsClassInstance(value) ? FromClassInstance(value) : IsSchemaObject$1(value) ? FromSchemaObject(value) : FromPlainObject(value);
|
|
311
246
|
}
|
|
312
|
-
function FromArray$
|
|
313
|
-
return value.map((element) => FromValue$
|
|
247
|
+
function FromArray$8(value) {
|
|
248
|
+
return value.map((element) => FromValue$1(element));
|
|
314
249
|
}
|
|
315
250
|
function FromTypedArray(value) {
|
|
316
251
|
return value.slice();
|
|
@@ -319,17 +254,17 @@ function FromRegExp$1(value) {
|
|
|
319
254
|
return new RegExp(value.source, value.flags);
|
|
320
255
|
}
|
|
321
256
|
function FromMap(value) {
|
|
322
|
-
return new Map(FromValue$
|
|
257
|
+
return new Map(FromValue$1([...value.entries()]));
|
|
323
258
|
}
|
|
324
259
|
function FromSet(value) {
|
|
325
|
-
return new Set(FromValue$
|
|
260
|
+
return new Set(FromValue$1([...value.values()]));
|
|
326
261
|
}
|
|
327
|
-
function FromValue$
|
|
328
|
-
return IsTypeArray(value) ? FromTypedArray(value) : IsRegExp(value) ? FromRegExp$1(value) : IsMap(value) ? FromMap(value) : IsSet(value) ? FromSet(value) : IsArray$1(value) ? FromArray$
|
|
262
|
+
function FromValue$1(value) {
|
|
263
|
+
return IsTypeArray(value) ? FromTypedArray(value) : IsRegExp(value) ? FromRegExp$1(value) : IsMap(value) ? FromMap(value) : IsSet(value) ? FromSet(value) : IsArray$1(value) ? FromArray$8(value) : IsObject$1(value) ? FromObject$12(value) : value;
|
|
329
264
|
}
|
|
330
265
|
function Clone$1(value) {
|
|
331
266
|
Metrics.clone += 1;
|
|
332
|
-
return FromValue$
|
|
267
|
+
return FromValue$1(value);
|
|
333
268
|
}
|
|
334
269
|
function MergeHidden(left, right) {
|
|
335
270
|
for (const key of Object.keys(right)) Object.defineProperty(left, key, {
|
|
@@ -674,9 +609,9 @@ function FNV1A64_OP(byte) {
|
|
|
674
609
|
Accumulator = Accumulator ^ Bytes[byte];
|
|
675
610
|
Accumulator = Accumulator * Prime % Size;
|
|
676
611
|
}
|
|
677
|
-
function FromArray$
|
|
612
|
+
function FromArray$7(value) {
|
|
678
613
|
FNV1A64_OP(ByteMarker.Array);
|
|
679
|
-
for (const item of value) FromValue
|
|
614
|
+
for (const item of value) FromValue(item);
|
|
680
615
|
}
|
|
681
616
|
function FromBigInt$5(value) {
|
|
682
617
|
FNV1A64_OP(ByteMarker.BigInt);
|
|
@@ -689,15 +624,15 @@ function FromBoolean$5(value) {
|
|
|
689
624
|
}
|
|
690
625
|
function FromConstructor(value) {
|
|
691
626
|
FNV1A64_OP(ByteMarker.Constructor);
|
|
692
|
-
FromValue
|
|
627
|
+
FromValue(value.toString());
|
|
693
628
|
}
|
|
694
629
|
function FromDate(value) {
|
|
695
630
|
FNV1A64_OP(ByteMarker.Date);
|
|
696
|
-
FromValue
|
|
631
|
+
FromValue(value.getTime());
|
|
697
632
|
}
|
|
698
633
|
function FromFunction(value) {
|
|
699
634
|
FNV1A64_OP(ByteMarker.Function);
|
|
700
|
-
FromValue
|
|
635
|
+
FromValue(value.toString());
|
|
701
636
|
}
|
|
702
637
|
function FromNull$1(_value) {
|
|
703
638
|
FNV1A64_OP(ByteMarker.Null);
|
|
@@ -707,11 +642,11 @@ function FromNumber$4(value) {
|
|
|
707
642
|
F64In.setFloat64(0, value, true);
|
|
708
643
|
for (const byte of F64Out) FNV1A64_OP(byte);
|
|
709
644
|
}
|
|
710
|
-
function FromObject$
|
|
645
|
+
function FromObject$11(value) {
|
|
711
646
|
FNV1A64_OP(ByteMarker.Object);
|
|
712
647
|
for (const key of InstanceKeys(value).sort()) {
|
|
713
|
-
FromValue
|
|
714
|
-
FromValue
|
|
648
|
+
FromValue(key);
|
|
649
|
+
FromValue(value[key]);
|
|
715
650
|
}
|
|
716
651
|
}
|
|
717
652
|
function FromRegExp(value) {
|
|
@@ -725,7 +660,7 @@ function FromString$6(value) {
|
|
|
725
660
|
}
|
|
726
661
|
function FromSymbol(value) {
|
|
727
662
|
FNV1A64_OP(ByteMarker.Symbol);
|
|
728
|
-
FromValue
|
|
663
|
+
FromValue(value.toString());
|
|
729
664
|
}
|
|
730
665
|
function FromTypeArray(value) {
|
|
731
666
|
FNV1A64_OP(ByteMarker.TypeArray);
|
|
@@ -735,12 +670,12 @@ function FromTypeArray(value) {
|
|
|
735
670
|
function FromUndefined$1(_value) {
|
|
736
671
|
return FNV1A64_OP(ByteMarker.Undefined);
|
|
737
672
|
}
|
|
738
|
-
function FromValue
|
|
739
|
-
return IsTypeArray(value) ? FromTypeArray(value) : IsDate$1(value) ? FromDate(value) : IsRegExp(value) ? FromRegExp(value) : IsBoolean$1(value) ? FromBoolean$5(value.valueOf()) : IsString$1(value) ? FromString$6(value.valueOf()) : IsNumber$1(value) ? FromNumber$4(value.valueOf()) : IsIEEE754(value) ? FromNumber$4(value) : IsArray$1(value) ? FromArray$
|
|
673
|
+
function FromValue(value) {
|
|
674
|
+
return IsTypeArray(value) ? FromTypeArray(value) : IsDate$1(value) ? FromDate(value) : IsRegExp(value) ? FromRegExp(value) : IsBoolean$1(value) ? FromBoolean$5(value.valueOf()) : IsString$1(value) ? FromString$6(value.valueOf()) : IsNumber$1(value) ? FromNumber$4(value.valueOf()) : IsIEEE754(value) ? FromNumber$4(value) : IsArray$1(value) ? FromArray$7(value) : IsBoolean$2(value) ? FromBoolean$5(value) : IsBigInt$1(value) ? FromBigInt$5(value) : IsConstructor$1(value) ? FromConstructor(value) : IsNull$1(value) ? FromNull$1(value) : IsObject$1(value) ? FromObject$11(value) : IsString$2(value) ? FromString$6(value) : IsSymbol$1(value) ? FromSymbol(value) : IsUndefined$1(value) ? FromUndefined$1(value) : IsFunction$1(value) ? FromFunction(value) : Unreachable$1();
|
|
740
675
|
}
|
|
741
676
|
function HashCode(value) {
|
|
742
677
|
Accumulator = BigInt("14695981039346656037");
|
|
743
|
-
FromValue
|
|
678
|
+
FromValue(value);
|
|
744
679
|
return Accumulator;
|
|
745
680
|
}
|
|
746
681
|
function Hash(value) {
|
|
@@ -2029,13 +1964,13 @@ const Extends$1 = (input) => If(If(If(Const("extends", input), ([_0, input]) =>
|
|
|
2029
1964
|
_4,
|
|
2030
1965
|
_5
|
|
2031
1966
|
], input])))))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [ExtendsMapping(_0), input]);
|
|
2032
|
-
const Base = (input) => If(If(If(Const("(", input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Const(")", input), ([_2, input]) => [[
|
|
1967
|
+
const Base$1 = (input) => If(If(If(Const("(", input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Const(")", input), ([_2, input]) => [[
|
|
2033
1968
|
_0,
|
|
2034
1969
|
_1,
|
|
2035
1970
|
_2
|
|
2036
1971
|
], input]))), ([_0, input]) => [_0, input], () => If(KeywordString(input), ([_0, input]) => [_0, input], () => If(KeywordNumber(input), ([_0, input]) => [_0, input], () => If(KeywordBoolean(input), ([_0, input]) => [_0, input], () => If(KeywordUndefined(input), ([_0, input]) => [_0, input], () => If(KeywordNull(input), ([_0, input]) => [_0, input], () => If(KeywordInteger(input), ([_0, input]) => [_0, input], () => If(KeywordBigInt(input), ([_0, input]) => [_0, input], () => If(KeywordUnknown(input), ([_0, input]) => [_0, input], () => If(KeywordAny(input), ([_0, input]) => [_0, input], () => If(KeywordObject(input), ([_0, input]) => [_0, input], () => If(KeywordNever(input), ([_0, input]) => [_0, input], () => If(KeywordSymbol(input), ([_0, input]) => [_0, input], () => If(KeywordVoid(input), ([_0, input]) => [_0, input], () => If(KeywordThis(input), ([_0, input]) => [_0, input], () => If(LiteralBigInt(input), ([_0, input]) => [_0, input], () => If(LiteralBoolean(input), ([_0, input]) => [_0, input], () => If(LiteralNumber(input), ([_0, input]) => [_0, input], () => If(LiteralString(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral$1(input), ([_0, input]) => [_0, input], () => If(Dependent(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(_Tuple_(input), ([_0, input]) => [_0, input], () => If(_Constructor_(input), ([_0, input]) => [_0, input], () => If(_Function_(input), ([_0, input]) => [_0, input], () => If(_Mapped_(input), ([_0, input]) => [_0, input], () => If(GenericCall(input), ([_0, input]) => [_0, input], () => If(Reference(input), ([_0, input]) => [_0, input], () => [])))))))))))))))))))))))))))), ([_0, input]) => [BaseMapping(_0), input]);
|
|
2037
1972
|
const With$1 = (input) => If(If(If(Const("with", input), ([_0, input]) => If(WithObject(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [WithMapping(_0), input]);
|
|
2038
|
-
const Factor = (input) => If(If(KeyOf$1(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends$1(input), ([_3, input]) => If(With$1(input), ([_4, input]) => [[
|
|
1973
|
+
const Factor = (input) => If(If(KeyOf$1(input), ([_0, input]) => If(Base$1(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends$1(input), ([_3, input]) => If(With$1(input), ([_4, input]) => [[
|
|
2039
1974
|
_0,
|
|
2040
1975
|
_1,
|
|
2041
1976
|
_2,
|
|
@@ -2581,14 +2516,14 @@ function ExtendsObjectToRecord(inferred, properties, _pattern, value) {
|
|
|
2581
2516
|
function ExtendsObject(inferred, left, right) {
|
|
2582
2517
|
return IsRecord(right) ? ExtendsObjectToRecord(inferred, left, RecordPattern(right), RecordValue(right)) : IsObject(right) ? ExtendsObjectToObject(inferred, left, right.properties) : ExtendsRight(inferred, _Object_$1(left), right);
|
|
2583
2518
|
}
|
|
2584
|
-
function FromObject$
|
|
2519
|
+
function FromObject$10(inferred, properties) {
|
|
2585
2520
|
return IsEqual(Keys(properties).length, 0) ? ExtendsTrue(inferred) : ExtendsFalse();
|
|
2586
2521
|
}
|
|
2587
2522
|
function FromRecord$5(inferred, _leftKey, leftValue, _rightKey, rightValue) {
|
|
2588
2523
|
return ExtendsLeft(inferred, leftValue, rightValue);
|
|
2589
2524
|
}
|
|
2590
2525
|
function ExtendsRecord(inferred, leftPattern, leftValue, right) {
|
|
2591
|
-
return IsRecord(right) ? FromRecord$5(inferred, RecordPatternToType(leftPattern), leftValue, RecordPatternToType(RecordPattern(right)), RecordValue(right)) : IsObject(right) ? FromObject$
|
|
2526
|
+
return IsRecord(right) ? FromRecord$5(inferred, RecordPatternToType(leftPattern), leftValue, RecordPatternToType(RecordPattern(right)), RecordValue(right)) : IsObject(right) ? FromObject$10(inferred, right.properties) : IsAny(right) ? ExtendsTrue(inferred) : IsUnknown(right) ? ExtendsTrue(inferred) : ExtendsFalse();
|
|
2592
2527
|
}
|
|
2593
2528
|
function ExtendsString(inferred, left, right) {
|
|
2594
2529
|
return IsString(right) ? ExtendsTrue(inferred) : ExtendsRight(inferred, left, right);
|
|
@@ -2614,8 +2549,13 @@ function TryRestInferable(type) {
|
|
|
2614
2549
|
function TryInferable(type) {
|
|
2615
2550
|
return IsInfer(type) ? Inferrable(type.name, type.extends) : void 0;
|
|
2616
2551
|
}
|
|
2617
|
-
function TryInferResults(rest, right
|
|
2618
|
-
|
|
2552
|
+
function TryInferResults(rest, right) {
|
|
2553
|
+
const result = [];
|
|
2554
|
+
for (const head of rest) {
|
|
2555
|
+
if (!IsExtendsTrueLike(ExtendsLeft({}, head, right))) return void 0;
|
|
2556
|
+
result.push(head);
|
|
2557
|
+
}
|
|
2558
|
+
return result;
|
|
2619
2559
|
}
|
|
2620
2560
|
function InferTupleResult(inferred, name, left, right) {
|
|
2621
2561
|
const results = TryInferResults(left, right);
|
|
@@ -2653,9 +2593,17 @@ function ExtendsTupleToTuple(inferred, left, right) {
|
|
|
2653
2593
|
const reversed = Reversed(instantiatedRight);
|
|
2654
2594
|
return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed));
|
|
2655
2595
|
}
|
|
2596
|
+
function ExtendsTupleToArrayReduce(inferred, left, right) {
|
|
2597
|
+
for (const head of left) {
|
|
2598
|
+
const result = ExtendsLeft(inferred, head, right);
|
|
2599
|
+
if (!IsExtendsTrueLike(result)) return result;
|
|
2600
|
+
inferred = result.inferred;
|
|
2601
|
+
}
|
|
2602
|
+
return ExtendsTrue(inferred);
|
|
2603
|
+
}
|
|
2656
2604
|
function ExtendsTupleToArray(inferred, left, right) {
|
|
2657
2605
|
const inferrable = TryInferable(right);
|
|
2658
|
-
return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) :
|
|
2606
|
+
return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) : ExtendsTupleToArrayReduce(inferred, left, right);
|
|
2659
2607
|
}
|
|
2660
2608
|
function ExtendsTuple(inferred, left, right) {
|
|
2661
2609
|
const instantiatedLeft = InstantiateElements(inferred, State([], []), left);
|
|
@@ -3149,7 +3097,7 @@ function FromIntersect$8(types) {
|
|
|
3149
3097
|
return CollapseIntersectProperties(result, FromType$15(left));
|
|
3150
3098
|
}, {});
|
|
3151
3099
|
}
|
|
3152
|
-
function FromObject$
|
|
3100
|
+
function FromObject$9(properties) {
|
|
3153
3101
|
return properties;
|
|
3154
3102
|
}
|
|
3155
3103
|
function FromTuple$7(types) {
|
|
@@ -3170,7 +3118,7 @@ function FromUnion$9(types) {
|
|
|
3170
3118
|
return ShiftLeft(types, (left, right) => ReduceVariants(right, FromType$15(left)), () => Unreachable$1());
|
|
3171
3119
|
}
|
|
3172
3120
|
function FromType$15(type) {
|
|
3173
|
-
return IsCyclic(type) ? FromCyclic$8(type.$defs, type.$ref) : IsDependent(type) ? FromDependent$4(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$8(type.allOf) : IsUnion(type) ? FromUnion$9(type.anyOf) : IsTuple(type) ? FromTuple$7(type.items) : IsObject(type) ? FromObject$
|
|
3121
|
+
return IsCyclic(type) ? FromCyclic$8(type.$defs, type.$ref) : IsDependent(type) ? FromDependent$4(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$8(type.allOf) : IsUnion(type) ? FromUnion$9(type.anyOf) : IsTuple(type) ? FromTuple$7(type.items) : IsObject(type) ? FromObject$9(type.properties) : {};
|
|
3174
3122
|
}
|
|
3175
3123
|
function CollapseToObject(type) {
|
|
3176
3124
|
return _Object_$1(FromType$15(type));
|
|
@@ -3189,7 +3137,7 @@ function NormalizeIndexerTypes(types) {
|
|
|
3189
3137
|
function NormalizeIndexer(type) {
|
|
3190
3138
|
return IsIntersect(type) ? Intersect(NormalizeIndexerTypes(type.allOf)) : IsUnion(type) ? Union(NormalizeIndexerTypes(type.anyOf)) : IsLiteral(type) ? NormalizeLiteral(type.const) : type;
|
|
3191
3139
|
}
|
|
3192
|
-
function FromArray$
|
|
3140
|
+
function FromArray$6(type, indexer) {
|
|
3193
3141
|
return IsExtendsTrueLike(Extends({}, NormalizeIndexer(indexer), Number$2())) ? type : IsLiteral(indexer) && IsEqual(indexer.const, "length") ? Number$2() : Never();
|
|
3194
3142
|
}
|
|
3195
3143
|
function FromCyclic$7(defs, ref) {
|
|
@@ -3248,7 +3196,7 @@ function NumericKeys(keys) {
|
|
|
3248
3196
|
function FromIndexerNumber(properties) {
|
|
3249
3197
|
return EvaluateUnion(IndexProperties(properties, NumericKeys(PropertyKeys(properties))));
|
|
3250
3198
|
}
|
|
3251
|
-
function FromObject$
|
|
3199
|
+
function FromObject$8(properties, indexer) {
|
|
3252
3200
|
return IsNumber(indexer) ? FromIndexerNumber(properties) : FromIndexer(properties, indexer);
|
|
3253
3201
|
}
|
|
3254
3202
|
function ConvertLiteral(value) {
|
|
@@ -3275,7 +3223,7 @@ function FromTuple$6(types, indexer) {
|
|
|
3275
3223
|
return IsLiteral(indexer) && IsEqual(indexer.const, "length") ? Literal(types.length) : IsNumber(indexer) || IsInteger(indexer) ? FromTupleWithoutIndexer(types) : FromTupleWithIndexer(types, indexer);
|
|
3276
3224
|
}
|
|
3277
3225
|
function FromType$12(type, indexer) {
|
|
3278
|
-
return IsArray(type) ? FromArray$
|
|
3226
|
+
return IsArray(type) ? FromArray$6(type.items, indexer) : IsObject(type) ? FromObject$8(type.properties, indexer) : IsTuple(type) ? FromTuple$6(type.items, indexer) : Never();
|
|
3279
3227
|
}
|
|
3280
3228
|
function NormalizeType$1(type) {
|
|
3281
3229
|
return IsCyclic(type) || IsDependent(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) : type;
|
|
@@ -3314,7 +3262,7 @@ function FromAny() {
|
|
|
3314
3262
|
Symbol$1()
|
|
3315
3263
|
]);
|
|
3316
3264
|
}
|
|
3317
|
-
function FromArray$
|
|
3265
|
+
function FromArray$5(_type) {
|
|
3318
3266
|
return Number$2();
|
|
3319
3267
|
}
|
|
3320
3268
|
function FromPropertyKeys(keys) {
|
|
@@ -3322,7 +3270,7 @@ function FromPropertyKeys(keys) {
|
|
|
3322
3270
|
return IsLiteralValue(left) ? [...result, Literal(ConvertToIntegerKey(left))] : Unreachable$1();
|
|
3323
3271
|
}, []);
|
|
3324
3272
|
}
|
|
3325
|
-
function FromObject$
|
|
3273
|
+
function FromObject$7(properties) {
|
|
3326
3274
|
return EvaluateUnionFast(FromPropertyKeys(Keys(properties)));
|
|
3327
3275
|
}
|
|
3328
3276
|
function FromRecord$4(type) {
|
|
@@ -3332,7 +3280,7 @@ function FromTuple$5(types) {
|
|
|
3332
3280
|
return EvaluateUnionFast(types.map((_, index) => Literal(index)));
|
|
3333
3281
|
}
|
|
3334
3282
|
function FromType$11(type) {
|
|
3335
|
-
return IsAny(type) ? FromAny() : IsArray(type) ? FromArray$
|
|
3283
|
+
return IsAny(type) ? FromAny() : IsArray(type) ? FromArray$5(type.items) : IsObject(type) ? FromObject$7(type.properties) : IsRecord(type) ? FromRecord$4(type) : IsTuple(type) ? FromTuple$5(type.items) : Never();
|
|
3336
3284
|
}
|
|
3337
3285
|
function NormalizeType(type) {
|
|
3338
3286
|
return IsCyclic(type) || IsDependent(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) : type;
|
|
@@ -3509,7 +3457,7 @@ function FromIntersect$6(types) {
|
|
|
3509
3457
|
function FromUnion$6(types) {
|
|
3510
3458
|
return Union(types.map((type) => FromType$8(type)));
|
|
3511
3459
|
}
|
|
3512
|
-
function FromObject$
|
|
3460
|
+
function FromObject$6(properties) {
|
|
3513
3461
|
return _Object_$1(Keys(properties).reduce((result, left) => {
|
|
3514
3462
|
return {
|
|
3515
3463
|
...result,
|
|
@@ -3518,7 +3466,7 @@ function FromObject$7(properties) {
|
|
|
3518
3466
|
}, {}));
|
|
3519
3467
|
}
|
|
3520
3468
|
function FromType$8(type) {
|
|
3521
|
-
return IsCyclic(type) ? FromCyclic$6(type.$defs, type.$ref) : IsDependent(type) ? FromDependent$2(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$6(type.allOf) : IsUnion(type) ? FromUnion$6(type.anyOf) : IsObject(type) ? FromObject$
|
|
3469
|
+
return IsCyclic(type) ? FromCyclic$6(type.$defs, type.$ref) : IsDependent(type) ? FromDependent$2(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$6(type.allOf) : IsUnion(type) ? FromUnion$6(type.anyOf) : IsObject(type) ? FromObject$6(type.properties) : _Object_$1({});
|
|
3522
3470
|
}
|
|
3523
3471
|
function PartialAction(type, options) {
|
|
3524
3472
|
return CanInstantiate([type]) ? Update$1(FromType$8(type), {}, options) : PartialDeferred(type, options);
|
|
@@ -3553,7 +3501,7 @@ function ReadonlyObject(type, options = {}) {
|
|
|
3553
3501
|
return ReadonlyObjectAction(type, options);
|
|
3554
3502
|
}
|
|
3555
3503
|
const ReadonlyType = ReadonlyObject;
|
|
3556
|
-
function FromArray$
|
|
3504
|
+
function FromArray$4(type) {
|
|
3557
3505
|
return AddImmutable(_Array_(type));
|
|
3558
3506
|
}
|
|
3559
3507
|
function FromCyclic$5(defs, ref) {
|
|
@@ -3566,7 +3514,7 @@ function FromDependent$1(if_, then_, else_) {
|
|
|
3566
3514
|
function FromIntersect$5(types) {
|
|
3567
3515
|
return FromType$6(EvaluateIntersect(types));
|
|
3568
3516
|
}
|
|
3569
|
-
function FromObject$
|
|
3517
|
+
function FromObject$5(properties) {
|
|
3570
3518
|
return _Object_$1(Keys(properties).reduce((result, left) => {
|
|
3571
3519
|
return {
|
|
3572
3520
|
...result,
|
|
@@ -3581,7 +3529,7 @@ function FromUnion$5(types) {
|
|
|
3581
3529
|
return Union(types.map((type) => FromType$6(type)));
|
|
3582
3530
|
}
|
|
3583
3531
|
function FromType$6(type) {
|
|
3584
|
-
return IsArray(type) ? FromArray$
|
|
3532
|
+
return IsArray(type) ? FromArray$4(type.items) : IsCyclic(type) ? FromCyclic$5(type.$defs, type.$ref) : IsDependent(type) ? FromDependent$1(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$5(type.allOf) : IsObject(type) ? FromObject$5(type.properties) : IsTuple(type) ? FromTuple$4(type.items) : IsUnion(type) ? FromUnion$5(type.anyOf) : type;
|
|
3585
3533
|
}
|
|
3586
3534
|
function ReadonlyObjectAction(type, options) {
|
|
3587
3535
|
return CanInstantiate([type]) ? Update$1(FromType$6(type), {}, options) : ReadonlyObjectDeferred(type);
|
|
@@ -3605,7 +3553,7 @@ function FromIntersect$4(types) {
|
|
|
3605
3553
|
function FromUnion$4(types) {
|
|
3606
3554
|
return Union(types.map((type) => FromType$5(type)));
|
|
3607
3555
|
}
|
|
3608
|
-
function FromObject$
|
|
3556
|
+
function FromObject$4(properties) {
|
|
3609
3557
|
return _Object_$1(Keys(properties).reduce((result, left) => {
|
|
3610
3558
|
return {
|
|
3611
3559
|
...result,
|
|
@@ -3614,7 +3562,7 @@ function FromObject$5(properties) {
|
|
|
3614
3562
|
}, {}));
|
|
3615
3563
|
}
|
|
3616
3564
|
function FromType$5(type) {
|
|
3617
|
-
return IsCyclic(type) ? FromCyclic$4(type.$defs, type.$ref) : IsDependent(type) ? FromDependent(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$4(type.allOf) : IsUnion(type) ? FromUnion$4(type.anyOf) : IsObject(type) ? FromObject$
|
|
3565
|
+
return IsCyclic(type) ? FromCyclic$4(type.$defs, type.$ref) : IsDependent(type) ? FromDependent(type.if, type.then, type.else) : IsIntersect(type) ? FromIntersect$4(type.allOf) : IsUnion(type) ? FromUnion$4(type.anyOf) : IsObject(type) ? FromObject$4(type.properties) : _Object_$1({});
|
|
3618
3566
|
}
|
|
3619
3567
|
function RequiredDeferred(type, options = {}) {
|
|
3620
3568
|
return Deferred("Required", [type], options);
|
|
@@ -4080,44 +4028,137 @@ var CheckContext = class {
|
|
|
4080
4028
|
}
|
|
4081
4029
|
};
|
|
4082
4030
|
var ErrorContext = class extends CheckContext {
|
|
4083
|
-
constructor(
|
|
4031
|
+
constructor() {
|
|
4084
4032
|
super();
|
|
4085
|
-
this.
|
|
4033
|
+
this.errors = [];
|
|
4086
4034
|
}
|
|
4087
|
-
|
|
4088
|
-
this.
|
|
4089
|
-
return false;
|
|
4035
|
+
AtCapacity() {
|
|
4036
|
+
return this.errors.length >= Get$2().maxErrors;
|
|
4090
4037
|
}
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4038
|
+
AddError(keyword, schemaPath, instancePath, params) {
|
|
4039
|
+
return this.AddErrorObject({
|
|
4040
|
+
keyword,
|
|
4041
|
+
schemaPath,
|
|
4042
|
+
instancePath,
|
|
4043
|
+
params
|
|
4044
|
+
});
|
|
4096
4045
|
}
|
|
4097
|
-
|
|
4098
|
-
this.
|
|
4046
|
+
AddErrors(error) {
|
|
4047
|
+
error.forEach((error) => this.AddErrorObject(error));
|
|
4099
4048
|
return false;
|
|
4100
4049
|
}
|
|
4101
4050
|
GetErrors() {
|
|
4102
4051
|
return this.errors;
|
|
4103
4052
|
}
|
|
4053
|
+
AddErrorObject(error) {
|
|
4054
|
+
if (!this.AtCapacity()) this.errors.push(error);
|
|
4055
|
+
return false;
|
|
4056
|
+
}
|
|
4104
4057
|
};
|
|
4105
4058
|
function CheckRefine(_stack, _context, schema, value) {
|
|
4106
4059
|
return Every(schema["~refine"], 0, (refinement, _) => refinement.check(value));
|
|
4107
4060
|
}
|
|
4108
4061
|
function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
|
|
4109
4062
|
return EveryAll(schema["~refine"], 0, (refinement, index) => {
|
|
4110
|
-
return refinement.check(value) || context.AddError({
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
instancePath,
|
|
4114
|
-
params: {
|
|
4115
|
-
index,
|
|
4116
|
-
message: refinement.error(value)
|
|
4117
|
-
}
|
|
4063
|
+
return refinement.check(value) || context.AddError("~refine", schemaPath, instancePath, {
|
|
4064
|
+
index,
|
|
4065
|
+
message: refinement.error(value)
|
|
4118
4066
|
});
|
|
4119
4067
|
});
|
|
4120
4068
|
}
|
|
4069
|
+
const DefaultUri = "urn:typebox:root";
|
|
4070
|
+
function NextUri(ref, base) {
|
|
4071
|
+
return URL.canParse(ref, base) ? new URL(ref, base) : IsEqual(base, "urn:typebox:root") ? new URL(`${base}:${ref}`) : new URL(`${base.slice(0, base.lastIndexOf(":"))}:${ref}`);
|
|
4072
|
+
}
|
|
4073
|
+
function Stack(context, schema) {
|
|
4074
|
+
const base = IsSchemaObject(schema) && IsId(schema) ? NextUri(schema.$id, DefaultUri).href : DefaultUri;
|
|
4075
|
+
return {
|
|
4076
|
+
context,
|
|
4077
|
+
schema,
|
|
4078
|
+
lexicalSchema: schema,
|
|
4079
|
+
lexicalBase: base,
|
|
4080
|
+
resourceBase: base,
|
|
4081
|
+
referenceBase: base,
|
|
4082
|
+
ids: [],
|
|
4083
|
+
useResourceBaseForReference: true,
|
|
4084
|
+
recursiveAnchor: void 0,
|
|
4085
|
+
dynamicAnchors: [],
|
|
4086
|
+
resourceEntries: /* @__PURE__ */ new Map(),
|
|
4087
|
+
pendingResource: true,
|
|
4088
|
+
enteredResource: false
|
|
4089
|
+
};
|
|
4090
|
+
}
|
|
4091
|
+
function RegisterResourceAnchors(anchors, schema, isRoot = true) {
|
|
4092
|
+
if (IsSchemaBoolean(schema)) return anchors;
|
|
4093
|
+
if (Array.isArray(schema)) return schema.reduce((result, item) => RegisterResourceAnchors(result, item, false), anchors);
|
|
4094
|
+
if (!IsSchemaObject(schema)) return anchors;
|
|
4095
|
+
if (!isRoot && IsId(schema)) return anchors;
|
|
4096
|
+
const next = !isRoot && IsDynamicAnchor(schema) ? [...anchors, schema] : anchors;
|
|
4097
|
+
return Object.keys(schema).reduce((result, key) => RegisterResourceAnchors(result, schema[key], false), next);
|
|
4098
|
+
}
|
|
4099
|
+
function ResourceEntry(stack, schema) {
|
|
4100
|
+
return stack.resourceEntries.get(schema);
|
|
4101
|
+
}
|
|
4102
|
+
function NextEnteredResource(stack, schema) {
|
|
4103
|
+
return stack.enteredResource || ResourceEntry(stack, schema) !== void 0;
|
|
4104
|
+
}
|
|
4105
|
+
function IsRelativeId(schema) {
|
|
4106
|
+
return !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(schema.$id);
|
|
4107
|
+
}
|
|
4108
|
+
function NextIds(stack, schema) {
|
|
4109
|
+
return IsId(schema) ? [...stack.ids, schema] : stack.ids;
|
|
4110
|
+
}
|
|
4111
|
+
function NextRecursiveAnchor(stack, schema) {
|
|
4112
|
+
return stack.recursiveAnchor ?? (IsRecursiveAnchorTrue(schema) ? schema : void 0);
|
|
4113
|
+
}
|
|
4114
|
+
function NextDynamicAnchors(stack, schema) {
|
|
4115
|
+
const registered = IsId(schema) ? RegisterResourceAnchors(stack.dynamicAnchors, schema) : stack.dynamicAnchors;
|
|
4116
|
+
return IsDynamicAnchor(schema) ? [...registered, schema] : registered;
|
|
4117
|
+
}
|
|
4118
|
+
function NextPendingResource(stack, schema) {
|
|
4119
|
+
return IsId(schema) ? false : stack.pendingResource;
|
|
4120
|
+
}
|
|
4121
|
+
function NextLexicalBase(stack, schema) {
|
|
4122
|
+
const entry = ResourceEntry(stack, schema);
|
|
4123
|
+
if (entry) return entry.base;
|
|
4124
|
+
return IsId(schema) ? NextUri(schema.$id, stack.lexicalBase).href : stack.lexicalBase;
|
|
4125
|
+
}
|
|
4126
|
+
function NextResourceBase(stack, schema) {
|
|
4127
|
+
const entry = ResourceEntry(stack, schema);
|
|
4128
|
+
if (entry) return entry.base;
|
|
4129
|
+
return IsId(schema) && stack.pendingResource ? NextUri(schema.$id, stack.resourceBase).href : stack.resourceBase;
|
|
4130
|
+
}
|
|
4131
|
+
function NextUseResourceBaseForReference(stack, schema) {
|
|
4132
|
+
return IsId(schema) ? !IsRelativeId(schema) : stack.useResourceBaseForReference;
|
|
4133
|
+
}
|
|
4134
|
+
function NextReferenceBase(stack, schema) {
|
|
4135
|
+
const isRetrieved = NextEnteredResource(stack, schema);
|
|
4136
|
+
const useResourceBaseForReference = NextUseResourceBaseForReference(stack, schema);
|
|
4137
|
+
return isRetrieved || useResourceBaseForReference ? NextResourceBase(stack, schema) : NextLexicalBase(stack, schema);
|
|
4138
|
+
}
|
|
4139
|
+
function NextLexicalSchema(stack, schema) {
|
|
4140
|
+
const entry = ResourceEntry(stack, schema);
|
|
4141
|
+
if (entry) return entry.root;
|
|
4142
|
+
return IsId(schema) ? schema : stack.lexicalSchema;
|
|
4143
|
+
}
|
|
4144
|
+
function HasStackKeywords(stack, schema) {
|
|
4145
|
+
return IsSchemaObject(schema) && (IsId(schema) || IsDynamicAnchor(schema) || IsUndefined$1(stack.recursiveAnchor) && IsRecursiveAnchorTrue(schema) || !IsUndefined$1(ResourceEntry(stack, schema)));
|
|
4146
|
+
}
|
|
4147
|
+
function NextStack(stack, schema) {
|
|
4148
|
+
return HasStackKeywords(stack, schema) ? {
|
|
4149
|
+
...stack,
|
|
4150
|
+
ids: NextIds(stack, schema),
|
|
4151
|
+
dynamicAnchors: NextDynamicAnchors(stack, schema),
|
|
4152
|
+
recursiveAnchor: NextRecursiveAnchor(stack, schema),
|
|
4153
|
+
pendingResource: NextPendingResource(stack, schema),
|
|
4154
|
+
lexicalBase: NextLexicalBase(stack, schema),
|
|
4155
|
+
resourceBase: NextResourceBase(stack, schema),
|
|
4156
|
+
useResourceBaseForReference: NextUseResourceBaseForReference(stack, schema),
|
|
4157
|
+
referenceBase: NextReferenceBase(stack, schema),
|
|
4158
|
+
lexicalSchema: NextLexicalSchema(stack, schema),
|
|
4159
|
+
enteredResource: NextEnteredResource(stack, schema)
|
|
4160
|
+
} : stack;
|
|
4161
|
+
}
|
|
4121
4162
|
function IsValid$4(schema) {
|
|
4122
4163
|
return IsItems(schema) && IsArray$1(schema.items);
|
|
4123
4164
|
}
|
|
@@ -4135,6 +4176,9 @@ function ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema,
|
|
|
4135
4176
|
return IsLessThan(index, schema.items.length) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalItems, item) && context.AddIndex(index);
|
|
4136
4177
|
});
|
|
4137
4178
|
}
|
|
4179
|
+
function EncodeFragment(fragment) {
|
|
4180
|
+
return fragment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
4181
|
+
}
|
|
4138
4182
|
function UnicodeRegExp(pattern) {
|
|
4139
4183
|
return new RegExp(pattern, "u");
|
|
4140
4184
|
}
|
|
@@ -4158,17 +4202,11 @@ function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, sch
|
|
|
4158
4202
|
const additionalProperties = [];
|
|
4159
4203
|
return EveryAll(Keys(value), 0, (key, _index) => {
|
|
4160
4204
|
const nextSchemaPath = `${schemaPath}/additionalProperties`;
|
|
4161
|
-
const nextInstancePath = `${instancePath}/${key}`;
|
|
4162
|
-
const
|
|
4163
|
-
const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, nextContext, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context.AddKey(key);
|
|
4205
|
+
const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
|
|
4206
|
+
const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context.AddKey(key);
|
|
4164
4207
|
if (!isAdditionalProperty) additionalProperties.push(key);
|
|
4165
4208
|
return isAdditionalProperty;
|
|
4166
|
-
}) || context.AddError({
|
|
4167
|
-
keyword: "additionalProperties",
|
|
4168
|
-
schemaPath,
|
|
4169
|
-
instancePath,
|
|
4170
|
-
params: { additionalProperties }
|
|
4171
|
-
});
|
|
4209
|
+
}) || context.AddError("additionalProperties", schemaPath, instancePath, { additionalProperties });
|
|
4172
4210
|
}
|
|
4173
4211
|
function CheckAllOf(stack, context, schema, value) {
|
|
4174
4212
|
const results = schema.allOf.reduce((result, schema) => {
|
|
@@ -4181,13 +4219,13 @@ function ErrorAllOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
|
4181
4219
|
const failedContexts = [];
|
|
4182
4220
|
const results = schema.allOf.reduce((result, schema, index) => {
|
|
4183
4221
|
const nextSchemaPath = `${schemaPath}/allOf/${index}`;
|
|
4184
|
-
const nextContext = new
|
|
4222
|
+
const nextContext = new ErrorContext();
|
|
4185
4223
|
const isSchema = ErrorSchema(stack, nextContext, nextSchemaPath, instancePath, schema, value);
|
|
4186
4224
|
if (!isSchema) failedContexts.push(nextContext);
|
|
4187
4225
|
return isSchema ? [...result, nextContext] : result;
|
|
4188
4226
|
}, []);
|
|
4189
4227
|
const isAllOf = IsEqual(results.length, schema.allOf.length) && context.Merge(results);
|
|
4190
|
-
if (!isAllOf) failedContexts.forEach((failed) => failed.GetErrors()
|
|
4228
|
+
if (!isAllOf) failedContexts.forEach((failed) => context.AddErrors(failed.GetErrors()));
|
|
4191
4229
|
return isAllOf;
|
|
4192
4230
|
}
|
|
4193
4231
|
function CheckAnyOf(stack, context, schema, value) {
|
|
@@ -4200,41 +4238,26 @@ function CheckAnyOf(stack, context, schema, value) {
|
|
|
4200
4238
|
function ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
4201
4239
|
const failedContexts = [];
|
|
4202
4240
|
const results = schema.anyOf.reduce((result, schema, index) => {
|
|
4203
|
-
const nextContext = new
|
|
4241
|
+
const nextContext = new ErrorContext();
|
|
4204
4242
|
const isSchema = ErrorSchema(stack, nextContext, `${schemaPath}/anyOf/${index}`, instancePath, schema, value);
|
|
4205
4243
|
if (!isSchema) failedContexts.push(nextContext);
|
|
4206
4244
|
return isSchema ? [...result, nextContext] : result;
|
|
4207
4245
|
}, []);
|
|
4208
4246
|
const isAnyOf = IsGreaterThan(results.length, 0) && context.Merge(results);
|
|
4209
|
-
if (!isAnyOf) failedContexts.forEach((failed) => failed.GetErrors()
|
|
4210
|
-
return isAnyOf || context.AddError({
|
|
4211
|
-
keyword: "anyOf",
|
|
4212
|
-
schemaPath,
|
|
4213
|
-
instancePath,
|
|
4214
|
-
params: {}
|
|
4215
|
-
});
|
|
4247
|
+
if (!isAnyOf) failedContexts.forEach((failed) => context.AddErrors(failed.GetErrors()));
|
|
4248
|
+
return isAnyOf || context.AddError("anyOf", schemaPath, instancePath, {});
|
|
4216
4249
|
}
|
|
4217
4250
|
function CheckSchemaBoolean(_stack, _context, schema, _value) {
|
|
4218
4251
|
return schema;
|
|
4219
4252
|
}
|
|
4220
4253
|
function ErrorSchemaBoolean(stack, context, schemaPath, instancePath, schema, value) {
|
|
4221
|
-
return CheckSchemaBoolean(stack, context, schema, value) || context.AddError({
|
|
4222
|
-
keyword: "boolean",
|
|
4223
|
-
schemaPath,
|
|
4224
|
-
instancePath,
|
|
4225
|
-
params: {}
|
|
4226
|
-
});
|
|
4254
|
+
return CheckSchemaBoolean(stack, context, schema, value) || context.AddError("boolean", schemaPath, instancePath, {});
|
|
4227
4255
|
}
|
|
4228
4256
|
function CheckConst(_stack, _context, schema, value) {
|
|
4229
4257
|
return IsValueLike(schema.const) ? IsEqual(value, schema.const) : IsDeepEqual(value, schema.const);
|
|
4230
4258
|
}
|
|
4231
4259
|
function ErrorConst(stack, context, schemaPath, instancePath, schema, value) {
|
|
4232
|
-
return CheckConst(stack, context, schema, value) || context.AddError({
|
|
4233
|
-
keyword: "const",
|
|
4234
|
-
schemaPath,
|
|
4235
|
-
instancePath,
|
|
4236
|
-
params: { allowedValue: schema.const }
|
|
4237
|
-
});
|
|
4260
|
+
return CheckConst(stack, context, schema, value) || context.AddError("const", schemaPath, instancePath, { allowedValue: schema.const });
|
|
4238
4261
|
}
|
|
4239
4262
|
function IsValid$3(schema) {
|
|
4240
4263
|
return !(IsMinContains(schema) && IsEqual(schema.minContains, 0));
|
|
@@ -4246,12 +4269,7 @@ function CheckContains(stack, context, schema, value) {
|
|
|
4246
4269
|
});
|
|
4247
4270
|
}
|
|
4248
4271
|
function ErrorContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
4249
|
-
return CheckContains(stack, context, schema, value) || context.AddError({
|
|
4250
|
-
keyword: "contains",
|
|
4251
|
-
schemaPath,
|
|
4252
|
-
instancePath,
|
|
4253
|
-
params: { minContains: 1 }
|
|
4254
|
-
});
|
|
4272
|
+
return CheckContains(stack, context, schema, value) || context.AddError("contains", schemaPath, instancePath, { minContains: 1 });
|
|
4255
4273
|
}
|
|
4256
4274
|
function CheckDependencies(stack, context, schema, value) {
|
|
4257
4275
|
const isLength = IsEqual(Keys(value).length, 0);
|
|
@@ -4263,15 +4281,10 @@ function CheckDependencies(stack, context, schema, value) {
|
|
|
4263
4281
|
function ErrorDependencies(stack, context, schemaPath, instancePath, schema, value) {
|
|
4264
4282
|
const isLength = IsEqual(Keys(value).length, 0);
|
|
4265
4283
|
const isEvery = EveryAll(Entries(schema.dependencies), 0, ([key, schema]) => {
|
|
4266
|
-
const nextSchemaPath = `${schemaPath}/dependencies/${key}`;
|
|
4267
|
-
return !HasPropertyKey(value, key) || (IsArray$1(schema) ? schema.every((dependency) => HasPropertyKey(value, dependency) || context.AddError({
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
instancePath,
|
|
4271
|
-
params: {
|
|
4272
|
-
property: key,
|
|
4273
|
-
dependencies: schema
|
|
4274
|
-
}
|
|
4284
|
+
const nextSchemaPath = `${schemaPath}/dependencies/${EncodeFragment(key)}`;
|
|
4285
|
+
return !HasPropertyKey(value, key) || (IsArray$1(schema) ? schema.every((dependency) => HasPropertyKey(value, dependency) || context.AddError("dependencies", schemaPath, instancePath, {
|
|
4286
|
+
property: key,
|
|
4287
|
+
dependencies: schema
|
|
4275
4288
|
})) : ErrorSchema(stack, context, nextSchemaPath, instancePath, schema, value));
|
|
4276
4289
|
});
|
|
4277
4290
|
return isLength || isEvery;
|
|
@@ -4286,14 +4299,9 @@ function CheckDependentRequired(_stack, _context, schema, value) {
|
|
|
4286
4299
|
function ErrorDependentRequired(_stack, context, schemaPath, instancePath, schema, value) {
|
|
4287
4300
|
const isLength = IsEqual(Keys(value).length, 0);
|
|
4288
4301
|
const isEveryEntry = EveryAll(Entries(schema.dependentRequired), 0, ([key, keys]) => {
|
|
4289
|
-
return !HasPropertyKey(value, key) || EveryAll(keys, 0, (dependency) => HasPropertyKey(value, dependency) || context.AddError({
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
instancePath,
|
|
4293
|
-
params: {
|
|
4294
|
-
property: key,
|
|
4295
|
-
dependencies: keys
|
|
4296
|
-
}
|
|
4302
|
+
return !HasPropertyKey(value, key) || EveryAll(keys, 0, (dependency) => HasPropertyKey(value, dependency) || context.AddError("dependentRequired", schemaPath, instancePath, {
|
|
4303
|
+
property: key,
|
|
4304
|
+
dependencies: keys
|
|
4297
4305
|
}));
|
|
4298
4306
|
});
|
|
4299
4307
|
return isLength || isEveryEntry;
|
|
@@ -4308,56 +4316,263 @@ function CheckDependentSchemas(stack, context, schema, value) {
|
|
|
4308
4316
|
function ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value) {
|
|
4309
4317
|
const isLength = IsEqual(Keys(value).length, 0);
|
|
4310
4318
|
const isEvery = EveryAll(Entries(schema.dependentSchemas), 0, ([key, schema]) => {
|
|
4311
|
-
const nextSchemaPath = `${schemaPath}/dependentSchemas/${key}`;
|
|
4319
|
+
const nextSchemaPath = `${schemaPath}/dependentSchemas/${EncodeFragment(key)}`;
|
|
4312
4320
|
return !HasPropertyKey(value, key) || ErrorSchema(stack, context, nextSchemaPath, instancePath, schema, value);
|
|
4313
4321
|
});
|
|
4314
4322
|
return isLength || isEvery;
|
|
4315
4323
|
}
|
|
4316
|
-
function
|
|
4317
|
-
const
|
|
4318
|
-
return
|
|
4324
|
+
function Indices(pointer) {
|
|
4325
|
+
const indices = pointer.split("/").map((index) => index.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
4326
|
+
return indices[0] === "" ? indices.slice(1) : indices;
|
|
4319
4327
|
}
|
|
4320
|
-
function
|
|
4321
|
-
|
|
4322
|
-
|
|
4328
|
+
function Get(value, pointer) {
|
|
4329
|
+
let current = value;
|
|
4330
|
+
for (const index of Indices(pointer)) {
|
|
4331
|
+
if (!IsObject$1(current) || IsUnsafePropertyKey(index)) return void 0;
|
|
4332
|
+
current = current[index];
|
|
4333
|
+
}
|
|
4334
|
+
return current;
|
|
4335
|
+
}
|
|
4336
|
+
function RelativeBase(schema, base) {
|
|
4337
|
+
return IsSchemaObject(schema) && IsId(schema) ? NextUri(schema.$id, base.href) : base;
|
|
4338
|
+
}
|
|
4339
|
+
function AbsoluteBase(base) {
|
|
4340
|
+
return NextUri(base, DefaultUri);
|
|
4341
|
+
}
|
|
4342
|
+
function CanonicalHref(url) {
|
|
4343
|
+
return url.href.split("#")[0];
|
|
4344
|
+
}
|
|
4345
|
+
function Base(schema, base, target) {
|
|
4346
|
+
return SearchBase(schema, AbsoluteBase(base), target);
|
|
4347
|
+
}
|
|
4348
|
+
function RefRoot(stack, ref) {
|
|
4349
|
+
return ref.$ref.startsWith("#") || stack.enteredResource ? stack.lexicalSchema : stack.schema;
|
|
4350
|
+
}
|
|
4351
|
+
function IsPointerFragment(fragment) {
|
|
4352
|
+
return fragment.startsWith("#/");
|
|
4353
|
+
}
|
|
4354
|
+
function SearchDynamicAnchor(schema, name) {
|
|
4355
|
+
if (IsObject$1(schema) && IsDynamicAnchor(schema) && IsEqual(schema.$dynamicAnchor, name)) return schema;
|
|
4356
|
+
if (IsObject$1(schema)) for (const key of Keys(schema)) {
|
|
4357
|
+
const result = SearchDynamicAnchor(schema[key], name);
|
|
4358
|
+
if (result) return result;
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
function SearchBase(schema, base, target) {
|
|
4362
|
+
if (IsEqual(schema, target)) return base.href;
|
|
4363
|
+
const nextBase = RelativeBase(schema, base);
|
|
4364
|
+
if (IsArray$1(schema)) for (const item of schema) {
|
|
4365
|
+
const result = SearchBase(item, nextBase, target);
|
|
4366
|
+
if (!IsUndefined$1(result)) return result;
|
|
4367
|
+
}
|
|
4368
|
+
else if (IsObject$1(schema)) for (const key of Keys(schema)) {
|
|
4369
|
+
const result = SearchBase(schema[key], nextBase, target);
|
|
4370
|
+
if (!IsUndefined$1(result)) return result;
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
function MatchWithHash(schema, ref) {
|
|
4374
|
+
if (ref.href.endsWith("#")) return schema;
|
|
4375
|
+
if (!ref.hash.startsWith("#")) return void 0;
|
|
4376
|
+
const fragment = decodeURIComponent(ref.hash.slice(1));
|
|
4377
|
+
if (!fragment.startsWith("/")) return void 0;
|
|
4378
|
+
return Get(schema, fragment);
|
|
4379
|
+
}
|
|
4380
|
+
function MatchWithId(schema, base, ref) {
|
|
4381
|
+
if (!IsId(schema)) return void 0;
|
|
4382
|
+
if (IsEqual(schema.$id, ref.hash)) return schema;
|
|
4383
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
4384
|
+
if (IsEqual(base.pathname, absoluteRef.pathname)) return ref.hash.startsWith("#") ? MatchWithHash(schema, ref) : schema;
|
|
4385
|
+
}
|
|
4386
|
+
function MatchWithAnchor(schema, base, ref) {
|
|
4387
|
+
if (!IsAnchor(schema)) return void 0;
|
|
4388
|
+
const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
|
|
4389
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
4390
|
+
return IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
|
|
4391
|
+
}
|
|
4392
|
+
function MatchWithDynamicAnchor(schema, base, ref) {
|
|
4393
|
+
if (!IsDynamicAnchor(schema)) return void 0;
|
|
4394
|
+
const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
|
|
4395
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
4396
|
+
return IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
|
|
4397
|
+
}
|
|
4398
|
+
function MatchSchemaObject(schema, base, ref) {
|
|
4399
|
+
if (!IsSchemaObject(schema)) return void 0;
|
|
4400
|
+
return MatchWithId(schema, base, ref) ?? MatchWithAnchor(schema, base, ref) ?? MatchWithDynamicAnchor(schema, base, ref) ?? MatchWithHash(schema, ref);
|
|
4401
|
+
}
|
|
4402
|
+
function MatchFromArray(schema, base, ref) {
|
|
4403
|
+
if (!IsArray$1(schema)) return void 0;
|
|
4404
|
+
return schema.reduce((result, item) => {
|
|
4405
|
+
const match = Match(item, base, ref);
|
|
4406
|
+
return !IsUndefined$1(match) ? match : result;
|
|
4407
|
+
}, void 0);
|
|
4408
|
+
}
|
|
4409
|
+
function MatchFromObject(schema, base, ref) {
|
|
4410
|
+
if (!IsObject$1(schema)) return void 0;
|
|
4411
|
+
return Keys(schema).reduce((result, key) => {
|
|
4412
|
+
if (IsEqual(key, "const") || IsEqual(key, "enum")) return result;
|
|
4413
|
+
const match = Match(schema[key], base, ref);
|
|
4414
|
+
return !IsUndefined$1(match) ? match : result;
|
|
4415
|
+
}, void 0);
|
|
4416
|
+
}
|
|
4417
|
+
function Match(schema, base, ref) {
|
|
4418
|
+
const relativeBase = RelativeBase(schema, base);
|
|
4419
|
+
return MatchSchemaObject(schema, relativeBase, ref) ?? MatchFromArray(schema, relativeBase, ref) ?? MatchFromObject(schema, relativeBase, ref);
|
|
4420
|
+
}
|
|
4421
|
+
function Resource(context, schema, base, ref) {
|
|
4422
|
+
const result = RefInternal(context, schema, base, ref);
|
|
4423
|
+
return IsSchemaObject(result) && IsId(result) ? result : void 0;
|
|
4424
|
+
}
|
|
4425
|
+
function FindDeferredResourceLegacy(stack, ref, schema) {
|
|
4426
|
+
if (!ref.$ref.startsWith("#")) return void 0;
|
|
4427
|
+
if (!IsSchemaObject(stack.schema) || HasPropertyKey(stack.schema, "$schema")) return void 0;
|
|
4428
|
+
const targetBase = Base(stack.lexicalSchema, stack.referenceBase, schema);
|
|
4429
|
+
if (IsUndefined$1(targetBase) || IsEqual(targetBase, stack.referenceBase)) return void 0;
|
|
4430
|
+
return {
|
|
4431
|
+
target: schema,
|
|
4432
|
+
base: targetBase,
|
|
4433
|
+
root: stack.lexicalSchema
|
|
4434
|
+
};
|
|
4435
|
+
}
|
|
4436
|
+
function FindDeferredResourceModern(stack, canonical, schema) {
|
|
4437
|
+
const remoteRoot = stack.context[canonical];
|
|
4438
|
+
if (!IsSchemaObject(remoteRoot)) return void 0;
|
|
4439
|
+
return {
|
|
4440
|
+
target: schema,
|
|
4441
|
+
base: canonical,
|
|
4442
|
+
root: remoteRoot
|
|
4443
|
+
};
|
|
4444
|
+
}
|
|
4445
|
+
function FindDeferredResource(stack, ref, schema, canonical, isRemote) {
|
|
4446
|
+
const remote = isRemote ? FindDeferredResourceModern(stack, canonical, schema) : void 0;
|
|
4447
|
+
return IsUndefined$1(remote) ? FindDeferredResourceLegacy(stack, ref, schema) : remote;
|
|
4448
|
+
}
|
|
4449
|
+
function FindResolvedResource(stack, canonical, schema) {
|
|
4450
|
+
if (IsId(schema)) return void 0;
|
|
4451
|
+
const resource = Resource(stack.context, stack.schema, stack.referenceBase, canonical);
|
|
4452
|
+
if (!resource || stack.ids.includes(resource)) return void 0;
|
|
4453
|
+
return { resource };
|
|
4454
|
+
}
|
|
4455
|
+
function RefInternalWithContext(context, ref) {
|
|
4456
|
+
return HasPropertyKey(context, ref) ? context[ref] : void 0;
|
|
4457
|
+
}
|
|
4458
|
+
function RefInternalWithLocal(schema, base, ref) {
|
|
4459
|
+
return Match(schema, base, ref);
|
|
4460
|
+
}
|
|
4461
|
+
function RefInternalWithRemote(context, base, ref) {
|
|
4462
|
+
const canonicalHref = CanonicalHref(ref);
|
|
4463
|
+
if (!HasPropertyKey(context, canonicalHref) || IsEqual(canonicalHref, CanonicalHref(base))) return void 0;
|
|
4464
|
+
const remoteSchema = context[canonicalHref];
|
|
4465
|
+
const remoteBase = RelativeBase(remoteSchema, new URL(canonicalHref));
|
|
4466
|
+
return IsEqual(ref.hash, "") ? remoteSchema : Match(remoteSchema, remoteBase, ref);
|
|
4467
|
+
}
|
|
4468
|
+
function RefInternal(context, schema, base, ref) {
|
|
4469
|
+
const absoluteBase = AbsoluteBase(base);
|
|
4470
|
+
const target = NextUri(ref, absoluteBase.href);
|
|
4471
|
+
return RefInternalWithContext(context, ref) ?? RefInternalWithLocal(schema, absoluteBase, target) ?? RefInternalWithRemote(context, absoluteBase, target);
|
|
4472
|
+
}
|
|
4473
|
+
function RefNextStackDeferred(stack, deferredResource) {
|
|
4474
|
+
if (!deferredResource) return stack;
|
|
4475
|
+
const resourceEntries = new Map(stack.resourceEntries);
|
|
4476
|
+
resourceEntries.set(deferredResource.target, {
|
|
4477
|
+
base: deferredResource.base,
|
|
4478
|
+
root: deferredResource.root
|
|
4479
|
+
});
|
|
4480
|
+
return {
|
|
4481
|
+
...stack,
|
|
4482
|
+
resourceEntries
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
function RefNextStackResolved(stack, resolvedResource) {
|
|
4486
|
+
return resolvedResource ? NextStack(stack, resolvedResource.resource) : stack;
|
|
4487
|
+
}
|
|
4488
|
+
function RefNextStack(stack, pendingResource, deferredResource, resolvedResource) {
|
|
4489
|
+
return RefNextStackResolved(RefNextStackDeferred({
|
|
4490
|
+
...stack,
|
|
4491
|
+
pendingResource
|
|
4492
|
+
}, deferredResource), resolvedResource);
|
|
4493
|
+
}
|
|
4494
|
+
function RefResultFound(stack, ref, schema) {
|
|
4495
|
+
const canonical = CanonicalHref(NextUri(ref.$ref, stack.referenceBase));
|
|
4496
|
+
const isRemote = !IsEqual(canonical, stack.resourceBase);
|
|
4497
|
+
return {
|
|
4498
|
+
schema,
|
|
4499
|
+
stack: RefNextStack(stack, true, FindDeferredResource(stack, ref, schema, canonical, isRemote), isRemote ? FindResolvedResource(stack, canonical, schema) : void 0)
|
|
4500
|
+
};
|
|
4501
|
+
}
|
|
4502
|
+
function RefResultNotFound(stack, schema) {
|
|
4503
|
+
return {
|
|
4504
|
+
schema,
|
|
4505
|
+
stack: RefNextStack(stack, !IsUndefined$1(schema))
|
|
4506
|
+
};
|
|
4507
|
+
}
|
|
4508
|
+
function Ref(stack, ref) {
|
|
4509
|
+
const schema = RefInternal(stack.context, RefRoot(stack, ref), stack.referenceBase, ref.$ref);
|
|
4510
|
+
return IsSchemaObject(schema) ? RefResultFound(stack, ref, schema) : RefResultNotFound(stack, schema);
|
|
4511
|
+
}
|
|
4512
|
+
function IsRecursiveAnchorInScope(stack) {
|
|
4513
|
+
return IsSchemaObject(stack.lexicalSchema) && IsRecursiveAnchorTrue(stack.lexicalSchema);
|
|
4514
|
+
}
|
|
4515
|
+
function RecursiveRef(stack, recursiveRef) {
|
|
4516
|
+
const schema = IsRecursiveAnchorInScope(stack) ? stack.recursiveAnchor : stack.lexicalSchema;
|
|
4517
|
+
return RefInternal(stack.context, schema, stack.lexicalBase, recursiveRef.$recursiveRef);
|
|
4518
|
+
}
|
|
4519
|
+
function DynamicRefFragment(stack, dynamicRef) {
|
|
4520
|
+
return NextUri(dynamicRef.$dynamicRef, AbsoluteBase(stack.lexicalBase).href).hash;
|
|
4521
|
+
}
|
|
4522
|
+
function FindScopedDynamicAnchor(stack, name) {
|
|
4523
|
+
return stack.dynamicAnchors.find((anchor) => IsEqual(anchor.$dynamicAnchor, name)) ?? SearchDynamicAnchor(stack.schema, name);
|
|
4524
|
+
}
|
|
4525
|
+
function DynamicRefWhenFound(stack, dynamicRef, fragmentTarget) {
|
|
4526
|
+
if (!IsSchemaObject(fragmentTarget) || !IsDynamicAnchor(fragmentTarget)) return fragmentTarget;
|
|
4527
|
+
return IsPointerFragment(DynamicRefFragment(stack, dynamicRef)) ? fragmentTarget : FindScopedDynamicAnchor(stack, fragmentTarget.$dynamicAnchor);
|
|
4528
|
+
}
|
|
4529
|
+
function DynamicRefWhenNotFound(stack, dynamicRef) {
|
|
4530
|
+
const fragment = DynamicRefFragment(stack, dynamicRef);
|
|
4531
|
+
return FindScopedDynamicAnchor(stack, decodeURIComponent(fragment.slice(1)));
|
|
4532
|
+
}
|
|
4533
|
+
function DynamicRef(stack, dynamicRef) {
|
|
4534
|
+
const fragmentRoot = dynamicRef.$dynamicRef.startsWith("#") ? stack.lexicalSchema : stack.schema;
|
|
4535
|
+
const fragmentTarget = RefInternal(stack.context, fragmentRoot, stack.lexicalBase, dynamicRef.$dynamicRef);
|
|
4536
|
+
return IsUndefined$1(fragmentTarget) ? DynamicRefWhenNotFound(stack, dynamicRef) : DynamicRefWhenFound(stack, dynamicRef, fragmentTarget);
|
|
4537
|
+
}
|
|
4538
|
+
function CheckDynamicRef(stack, context, schema, value) {
|
|
4539
|
+
const target = DynamicRef(stack, schema) ?? false;
|
|
4540
|
+
const nextStack = target ? {
|
|
4541
|
+
...stack,
|
|
4542
|
+
pendingResource: true
|
|
4543
|
+
} : stack;
|
|
4544
|
+
return IsSchema(target) && CheckSchema(nextStack, context, target, value);
|
|
4545
|
+
}
|
|
4546
|
+
function ErrorDynamicRef(stack, context, schemaPath, instancePath, schema, value) {
|
|
4547
|
+
const target = DynamicRef(stack, schema) ?? false;
|
|
4548
|
+
const nextStack = target ? {
|
|
4549
|
+
...stack,
|
|
4550
|
+
pendingResource: true
|
|
4551
|
+
} : stack;
|
|
4552
|
+
return IsSchema(target) && ErrorSchema(nextStack, context, schemaPath, instancePath, target, value);
|
|
4323
4553
|
}
|
|
4324
4554
|
function CheckEnum(_stack, _context, schema, value) {
|
|
4325
4555
|
return Some(schema.enum, (option) => IsValueLike(option) ? IsEqual(value, option) : IsDeepEqual(value, option));
|
|
4326
4556
|
}
|
|
4327
4557
|
function ErrorEnum(stack, context, schemaPath, instancePath, schema, value) {
|
|
4328
|
-
return CheckEnum(stack, context, schema, value) || context.AddError({
|
|
4329
|
-
keyword: "enum",
|
|
4330
|
-
schemaPath,
|
|
4331
|
-
instancePath,
|
|
4332
|
-
params: { allowedValues: schema.enum }
|
|
4333
|
-
});
|
|
4558
|
+
return CheckEnum(stack, context, schema, value) || context.AddError("enum", schemaPath, instancePath, { allowedValues: schema.enum });
|
|
4334
4559
|
}
|
|
4335
4560
|
function CheckExclusiveMaximum(_stack, _context, schema, value) {
|
|
4336
4561
|
return IsLessThan(value, schema.exclusiveMaximum);
|
|
4337
4562
|
}
|
|
4338
4563
|
function ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema, value) {
|
|
4339
|
-
return CheckExclusiveMaximum(stack, context, schema, value) || context.AddError({
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
instancePath,
|
|
4343
|
-
params: {
|
|
4344
|
-
comparison: "<",
|
|
4345
|
-
limit: schema.exclusiveMaximum
|
|
4346
|
-
}
|
|
4564
|
+
return CheckExclusiveMaximum(stack, context, schema, value) || context.AddError("exclusiveMaximum", schemaPath, instancePath, {
|
|
4565
|
+
comparison: "<",
|
|
4566
|
+
limit: schema.exclusiveMaximum
|
|
4347
4567
|
});
|
|
4348
4568
|
}
|
|
4349
4569
|
function CheckExclusiveMinimum(_stack, _context, schema, value) {
|
|
4350
4570
|
return IsGreaterThan(value, schema.exclusiveMinimum);
|
|
4351
4571
|
}
|
|
4352
4572
|
function ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value) {
|
|
4353
|
-
return CheckExclusiveMinimum(stack, context, schema, value) || context.AddError({
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
instancePath,
|
|
4357
|
-
params: {
|
|
4358
|
-
comparison: ">",
|
|
4359
|
-
limit: schema.exclusiveMinimum
|
|
4360
|
-
}
|
|
4573
|
+
return CheckExclusiveMinimum(stack, context, schema, value) || context.AddError("exclusiveMinimum", schemaPath, instancePath, {
|
|
4574
|
+
comparison: ">",
|
|
4575
|
+
limit: schema.exclusiveMinimum
|
|
4361
4576
|
});
|
|
4362
4577
|
}
|
|
4363
4578
|
const DAYS = [
|
|
@@ -4702,15 +4917,12 @@ const MalformedScheme = /^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;
|
|
|
4702
4917
|
function IsIriReference(value) {
|
|
4703
4918
|
return !InvalidIriChars$1.test(value) && !MalformedScheme.test(value) && URL.canParse(value, "http://example.com");
|
|
4704
4919
|
}
|
|
4705
|
-
const IpvFutureMatchMaxLength = 2048;
|
|
4706
|
-
const IpvFutureMatch = /\[[vV][0-9a-fA-F]+\.[^\]]+\]/;
|
|
4707
4920
|
const InvalidIriChars = /[\x00-\x20<>\^`{|}\\]/;
|
|
4708
|
-
|
|
4709
|
-
return value.length < IpvFutureMatchMaxLength ? value.replace(IpvFutureMatch, "[::1]") : value;
|
|
4710
|
-
}
|
|
4921
|
+
const InvalidPercentEncoding = /%(?![0-9a-fA-F]{2})/;
|
|
4711
4922
|
function IsIri(value) {
|
|
4712
4923
|
if (InvalidIriChars.test(value)) return false;
|
|
4713
|
-
|
|
4924
|
+
if (InvalidPercentEncoding.test(value)) return false;
|
|
4925
|
+
return URL.canParse(value);
|
|
4714
4926
|
}
|
|
4715
4927
|
const JsonPointerUriFragment = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
4716
4928
|
function IsJsonPointerUriFragment(value) {
|
|
@@ -4787,12 +4999,7 @@ function CheckFormat(_stack, _context, schema, value) {
|
|
|
4787
4999
|
return Test(schema.format, value);
|
|
4788
5000
|
}
|
|
4789
5001
|
function ErrorFormat(stack, context, schemaPath, instancePath, schema, value) {
|
|
4790
|
-
return CheckFormat(stack, context, schema, value) || context.AddError({
|
|
4791
|
-
keyword: "format",
|
|
4792
|
-
schemaPath,
|
|
4793
|
-
instancePath,
|
|
4794
|
-
params: { format: schema.format }
|
|
4795
|
-
});
|
|
5002
|
+
return CheckFormat(stack, context, schema, value) || context.AddError("format", schemaPath, instancePath, { format: schema.format });
|
|
4796
5003
|
}
|
|
4797
5004
|
function CheckIf(stack, context, schema, value) {
|
|
4798
5005
|
const thenSchema = IsThen(schema) ? schema.then : true;
|
|
@@ -4802,18 +5009,8 @@ function CheckIf(stack, context, schema, value) {
|
|
|
4802
5009
|
function ErrorIf(stack, context, schemaPath, instancePath, schema, value) {
|
|
4803
5010
|
const thenSchema = IsThen(schema) ? schema.then : true;
|
|
4804
5011
|
const elseSchema = IsElse(schema) ? schema.else : true;
|
|
4805
|
-
const trueContext = new
|
|
4806
|
-
const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value) ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError({
|
|
4807
|
-
keyword: "if",
|
|
4808
|
-
schemaPath,
|
|
4809
|
-
instancePath,
|
|
4810
|
-
params: { failingKeyword: "then" }
|
|
4811
|
-
}) : ErrorSchema(stack, context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError({
|
|
4812
|
-
keyword: "if",
|
|
4813
|
-
schemaPath,
|
|
4814
|
-
instancePath,
|
|
4815
|
-
params: { failingKeyword: "else" }
|
|
4816
|
-
});
|
|
5012
|
+
const trueContext = new ErrorContext();
|
|
5013
|
+
const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value) ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError("if", schemaPath, instancePath, { failingKeyword: "then" }) : ErrorSchema(stack, context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError("if", schemaPath, instancePath, { failingKeyword: "else" });
|
|
4817
5014
|
if (isIf) context.Merge([trueContext]);
|
|
4818
5015
|
return isIf;
|
|
4819
5016
|
}
|
|
@@ -4854,62 +5051,37 @@ function CheckMaxContains(stack, context, schema, value) {
|
|
|
4854
5051
|
}
|
|
4855
5052
|
function ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
4856
5053
|
const minContains = IsMinContains(schema) ? schema.minContains : 1;
|
|
4857
|
-
return CheckMaxContains(stack, context, schema, value) || context.AddError({
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
instancePath,
|
|
4861
|
-
params: {
|
|
4862
|
-
minContains,
|
|
4863
|
-
maxContains: schema.maxContains
|
|
4864
|
-
}
|
|
5054
|
+
return CheckMaxContains(stack, context, schema, value) || context.AddError("contains", schemaPath, instancePath, {
|
|
5055
|
+
minContains,
|
|
5056
|
+
maxContains: schema.maxContains
|
|
4865
5057
|
});
|
|
4866
5058
|
}
|
|
4867
5059
|
function CheckMaximum(_stack, _context, schema, value) {
|
|
4868
5060
|
return IsLessEqualThan(value, schema.maximum);
|
|
4869
5061
|
}
|
|
4870
5062
|
function ErrorMaximum(stack, context, schemaPath, instancePath, schema, value) {
|
|
4871
|
-
return CheckMaximum(stack, context, schema, value) || context.AddError({
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
instancePath,
|
|
4875
|
-
params: {
|
|
4876
|
-
comparison: "<=",
|
|
4877
|
-
limit: schema.maximum
|
|
4878
|
-
}
|
|
5063
|
+
return CheckMaximum(stack, context, schema, value) || context.AddError("maximum", schemaPath, instancePath, {
|
|
5064
|
+
comparison: "<=",
|
|
5065
|
+
limit: schema.maximum
|
|
4879
5066
|
});
|
|
4880
5067
|
}
|
|
4881
5068
|
function CheckMaxItems(_stack, _context, schema, value) {
|
|
4882
5069
|
return IsLessEqualThan(value.length, schema.maxItems);
|
|
4883
5070
|
}
|
|
4884
5071
|
function ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
4885
|
-
return CheckMaxItems(stack, context, schema, value) || context.AddError({
|
|
4886
|
-
keyword: "maxItems",
|
|
4887
|
-
schemaPath,
|
|
4888
|
-
instancePath,
|
|
4889
|
-
params: { limit: schema.maxItems }
|
|
4890
|
-
});
|
|
5072
|
+
return CheckMaxItems(stack, context, schema, value) || context.AddError("maxItems", schemaPath, instancePath, { limit: schema.maxItems });
|
|
4891
5073
|
}
|
|
4892
5074
|
function CheckMaxLength(_stack, _context, schema, value) {
|
|
4893
5075
|
return IsMaxLength$1(value, schema.maxLength);
|
|
4894
5076
|
}
|
|
4895
5077
|
function ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value) {
|
|
4896
|
-
return CheckMaxLength(stack, context, schema, value) || context.AddError({
|
|
4897
|
-
keyword: "maxLength",
|
|
4898
|
-
schemaPath,
|
|
4899
|
-
instancePath,
|
|
4900
|
-
params: { limit: schema.maxLength }
|
|
4901
|
-
});
|
|
5078
|
+
return CheckMaxLength(stack, context, schema, value) || context.AddError("maxLength", schemaPath, instancePath, { limit: schema.maxLength });
|
|
4902
5079
|
}
|
|
4903
5080
|
function CheckMaxProperties(_stack, _context, schema, value) {
|
|
4904
5081
|
return IsLessEqualThan(Keys(value).length, schema.maxProperties);
|
|
4905
5082
|
}
|
|
4906
5083
|
function ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
4907
|
-
return CheckMaxProperties(stack, context, schema, value) || context.AddError({
|
|
4908
|
-
keyword: "maxProperties",
|
|
4909
|
-
schemaPath,
|
|
4910
|
-
instancePath,
|
|
4911
|
-
params: { limit: schema.maxProperties }
|
|
4912
|
-
});
|
|
5084
|
+
return CheckMaxProperties(stack, context, schema, value) || context.AddError("maxProperties", schemaPath, instancePath, { limit: schema.maxProperties });
|
|
4913
5085
|
}
|
|
4914
5086
|
function IsValid$1(schema) {
|
|
4915
5087
|
return IsContains(schema);
|
|
@@ -4919,82 +5091,47 @@ function CheckMinContains(stack, context, schema, value) {
|
|
|
4919
5091
|
return IsGreaterEqualThan(Counted(value, (item, index) => CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index)), schema.minContains);
|
|
4920
5092
|
}
|
|
4921
5093
|
function ErrorMinContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
4922
|
-
return CheckMinContains(stack, context, schema, value) || context.AddError({
|
|
4923
|
-
keyword: "contains",
|
|
4924
|
-
schemaPath,
|
|
4925
|
-
instancePath,
|
|
4926
|
-
params: { minContains: schema.minContains }
|
|
4927
|
-
});
|
|
5094
|
+
return CheckMinContains(stack, context, schema, value) || context.AddError("contains", schemaPath, instancePath, { minContains: schema.minContains });
|
|
4928
5095
|
}
|
|
4929
5096
|
function CheckMinimum(_stack, _context, schema, value) {
|
|
4930
5097
|
return IsGreaterEqualThan(value, schema.minimum);
|
|
4931
5098
|
}
|
|
4932
5099
|
function ErrorMinimum(stack, context, schemaPath, instancePath, schema, value) {
|
|
4933
|
-
return CheckMinimum(stack, context, schema, value) || context.AddError({
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
instancePath,
|
|
4937
|
-
params: {
|
|
4938
|
-
comparison: ">=",
|
|
4939
|
-
limit: schema.minimum
|
|
4940
|
-
}
|
|
5100
|
+
return CheckMinimum(stack, context, schema, value) || context.AddError("minimum", schemaPath, instancePath, {
|
|
5101
|
+
comparison: ">=",
|
|
5102
|
+
limit: schema.minimum
|
|
4941
5103
|
});
|
|
4942
5104
|
}
|
|
4943
5105
|
function CheckMinItems(_stack, _context, schema, value) {
|
|
4944
5106
|
return IsGreaterEqualThan(value.length, schema.minItems);
|
|
4945
5107
|
}
|
|
4946
5108
|
function ErrorMinItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
4947
|
-
return CheckMinItems(stack, context, schema, value) || context.AddError({
|
|
4948
|
-
keyword: "minItems",
|
|
4949
|
-
schemaPath,
|
|
4950
|
-
instancePath,
|
|
4951
|
-
params: { limit: schema.minItems }
|
|
4952
|
-
});
|
|
5109
|
+
return CheckMinItems(stack, context, schema, value) || context.AddError("minItems", schemaPath, instancePath, { limit: schema.minItems });
|
|
4953
5110
|
}
|
|
4954
5111
|
function CheckMinLength(_stack, _context, schema, value) {
|
|
4955
5112
|
return IsMinLength$1(value, schema.minLength);
|
|
4956
5113
|
}
|
|
4957
5114
|
function ErrorMinLength(stack, context, schemaPath, instancePath, schema, value) {
|
|
4958
|
-
return CheckMinLength(stack, context, schema, value) || context.AddError({
|
|
4959
|
-
keyword: "minLength",
|
|
4960
|
-
schemaPath,
|
|
4961
|
-
instancePath,
|
|
4962
|
-
params: { limit: schema.minLength }
|
|
4963
|
-
});
|
|
5115
|
+
return CheckMinLength(stack, context, schema, value) || context.AddError("minLength", schemaPath, instancePath, { limit: schema.minLength });
|
|
4964
5116
|
}
|
|
4965
5117
|
function CheckMinProperties(_stack, _context, schema, value) {
|
|
4966
5118
|
return IsGreaterEqualThan(Keys(value).length, schema.minProperties);
|
|
4967
5119
|
}
|
|
4968
5120
|
function ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
4969
|
-
return CheckMinProperties(stack, context, schema, value) || context.AddError({
|
|
4970
|
-
keyword: "minProperties",
|
|
4971
|
-
schemaPath,
|
|
4972
|
-
instancePath,
|
|
4973
|
-
params: { limit: schema.minProperties }
|
|
4974
|
-
});
|
|
5121
|
+
return CheckMinProperties(stack, context, schema, value) || context.AddError("minProperties", schemaPath, instancePath, { limit: schema.minProperties });
|
|
4975
5122
|
}
|
|
4976
5123
|
function CheckMultipleOf(_stack, _context, schema, value) {
|
|
4977
5124
|
return IsMultipleOf$1(value, schema.multipleOf);
|
|
4978
5125
|
}
|
|
4979
5126
|
function ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
4980
|
-
return CheckMultipleOf(stack, context, schema, value) || context.AddError({
|
|
4981
|
-
keyword: "multipleOf",
|
|
4982
|
-
schemaPath,
|
|
4983
|
-
instancePath,
|
|
4984
|
-
params: { multipleOf: schema.multipleOf }
|
|
4985
|
-
});
|
|
5127
|
+
return CheckMultipleOf(stack, context, schema, value) || context.AddError("multipleOf", schemaPath, instancePath, { multipleOf: schema.multipleOf });
|
|
4986
5128
|
}
|
|
4987
5129
|
function CheckNot(stack, context, schema, value) {
|
|
4988
5130
|
const nextContext = new CheckContext();
|
|
4989
5131
|
return !CheckSchema(stack, nextContext, schema.not, value) && context.Merge([nextContext]);
|
|
4990
5132
|
}
|
|
4991
5133
|
function ErrorNot(stack, context, schemaPath, instancePath, schema, value) {
|
|
4992
|
-
return CheckNot(stack, context, schema, value) || context.AddError({
|
|
4993
|
-
keyword: "not",
|
|
4994
|
-
schemaPath,
|
|
4995
|
-
instancePath,
|
|
4996
|
-
params: {}
|
|
4997
|
-
});
|
|
5134
|
+
return CheckNot(stack, context, schema, value) || context.AddError("not", schemaPath, instancePath, {});
|
|
4998
5135
|
}
|
|
4999
5136
|
function CheckOneOf(stack, context, schema, value) {
|
|
5000
5137
|
const passedContexts = schema.oneOf.reduce((result, schema) => {
|
|
@@ -5007,31 +5144,21 @@ function ErrorOneOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
|
5007
5144
|
const failedContexts = [];
|
|
5008
5145
|
const passingSchemas = [];
|
|
5009
5146
|
const passedContexts = schema.oneOf.reduce((result, schema, index) => {
|
|
5010
|
-
const nextContext = new
|
|
5147
|
+
const nextContext = new ErrorContext();
|
|
5011
5148
|
const isSchema = ErrorSchema(stack, nextContext, `${schemaPath}/oneOf/${index}`, instancePath, schema, value);
|
|
5012
5149
|
if (isSchema) passingSchemas.push(index);
|
|
5013
5150
|
if (!isSchema) failedContexts.push(nextContext);
|
|
5014
5151
|
return isSchema ? [...result, nextContext] : result;
|
|
5015
5152
|
}, []);
|
|
5016
5153
|
const isOneOf = IsEqual(passedContexts.length, 1) && context.Merge(passedContexts);
|
|
5017
|
-
if (!isOneOf && IsEqual(passingSchemas.length, 0)) failedContexts.forEach((failed) => failed.GetErrors()
|
|
5018
|
-
return isOneOf || context.AddError({
|
|
5019
|
-
keyword: "oneOf",
|
|
5020
|
-
schemaPath,
|
|
5021
|
-
instancePath,
|
|
5022
|
-
params: { passingSchemas }
|
|
5023
|
-
});
|
|
5154
|
+
if (!isOneOf && IsEqual(passingSchemas.length, 0)) failedContexts.forEach((failed) => context.AddErrors(failed.GetErrors()));
|
|
5155
|
+
return isOneOf || context.AddError("oneOf", schemaPath, instancePath, { passingSchemas });
|
|
5024
5156
|
}
|
|
5025
5157
|
function CheckPattern(_stack, _context, schema, value) {
|
|
5026
5158
|
return (IsString$2(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern).test(value);
|
|
5027
5159
|
}
|
|
5028
5160
|
function ErrorPattern(stack, context, schemaPath, instancePath, schema, value) {
|
|
5029
|
-
return CheckPattern(stack, context, schema, value) || context.AddError({
|
|
5030
|
-
keyword: "pattern",
|
|
5031
|
-
schemaPath,
|
|
5032
|
-
instancePath,
|
|
5033
|
-
params: { pattern: schema.pattern }
|
|
5034
|
-
});
|
|
5161
|
+
return CheckPattern(stack, context, schema, value) || context.AddError("pattern", schemaPath, instancePath, { pattern: schema.pattern });
|
|
5035
5162
|
}
|
|
5036
5163
|
function CheckPatternProperties(stack, context, schema, value) {
|
|
5037
5164
|
return Every(Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
@@ -5043,10 +5170,10 @@ function CheckPatternProperties(stack, context, schema, value) {
|
|
|
5043
5170
|
}
|
|
5044
5171
|
function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
5045
5172
|
return EveryAll(Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
5046
|
-
const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
|
|
5173
|
+
const nextSchemaPath = `${schemaPath}/patternProperties/${EncodeFragment(pattern)}`;
|
|
5047
5174
|
const regexp = UnicodeRegExp(pattern);
|
|
5048
5175
|
return EveryAll(Entries(value), 0, ([key, value]) => {
|
|
5049
|
-
const nextInstancePath = `${instancePath}/${key}`;
|
|
5176
|
+
const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
|
|
5050
5177
|
return !regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value) && context.AddKey(key);
|
|
5051
5178
|
});
|
|
5052
5179
|
});
|
|
@@ -5079,8 +5206,8 @@ function CheckProperties(stack, context, schema, value) {
|
|
|
5079
5206
|
function ErrorProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
5080
5207
|
const required = IsRequired(schema) ? schema.required : [];
|
|
5081
5208
|
return EveryAll(Entries(schema.properties), 0, ([key, schema]) => {
|
|
5082
|
-
const nextSchemaPath = `${schemaPath}/properties/${key}`;
|
|
5083
|
-
const nextInstancePath = `${instancePath}/${key}`;
|
|
5209
|
+
const nextSchemaPath = `${schemaPath}/properties/${EncodeFragment(key)}`;
|
|
5210
|
+
const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
|
|
5084
5211
|
const isProperty = () => !HasPropertyKey(value, key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema, value[key]) && context.AddKey(key);
|
|
5085
5212
|
return IsExactOptional(required, key) ? isProperty() : InexactOptionalCheck(value, key) || isProperty();
|
|
5086
5213
|
});
|
|
@@ -5091,40 +5218,44 @@ function CheckPropertyNames(stack, context, schema, value) {
|
|
|
5091
5218
|
function ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value) {
|
|
5092
5219
|
const propertyNames = [];
|
|
5093
5220
|
return EveryAll(Keys(value), 0, (key, _index) => {
|
|
5094
|
-
const nextInstancePath = `${instancePath}/${key}`;
|
|
5095
|
-
const
|
|
5096
|
-
const isPropertyName = ErrorSchema(stack, new AccumulatedErrorContext(), nextSchemaPath, nextInstancePath, schema.propertyNames, key);
|
|
5221
|
+
const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
|
|
5222
|
+
const isPropertyName = ErrorSchema(stack, context, `${schemaPath}/propertyNames`, nextInstancePath, schema.propertyNames, key);
|
|
5097
5223
|
if (!isPropertyName) propertyNames.push(key);
|
|
5098
5224
|
return isPropertyName;
|
|
5099
|
-
}) || context.AddError({
|
|
5100
|
-
keyword: "propertyNames",
|
|
5101
|
-
schemaPath,
|
|
5102
|
-
instancePath,
|
|
5103
|
-
params: { propertyNames }
|
|
5104
|
-
});
|
|
5225
|
+
}) || context.AddError("propertyNames", schemaPath, instancePath, { propertyNames });
|
|
5105
5226
|
}
|
|
5106
5227
|
function CheckRecursiveRef(stack, context, schema, value) {
|
|
5107
|
-
const target =
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
return IsSchema(target) &&
|
|
5228
|
+
const target = RecursiveRef(stack, schema) ?? false;
|
|
5229
|
+
const nextStack = target ? {
|
|
5230
|
+
...stack,
|
|
5231
|
+
pendingResource: true
|
|
5232
|
+
} : stack;
|
|
5233
|
+
return IsSchema(target) && CheckSchema(nextStack, context, target, value);
|
|
5234
|
+
}
|
|
5235
|
+
function ErrorRecursiveRef(stack, context, schemaPath, instancePath, schema, value) {
|
|
5236
|
+
const target = RecursiveRef(stack, schema) ?? false;
|
|
5237
|
+
const nextStack = target ? {
|
|
5238
|
+
...stack,
|
|
5239
|
+
pendingResource: true
|
|
5240
|
+
} : stack;
|
|
5241
|
+
return IsSchema(target) && ErrorSchema(nextStack, context, schemaPath, instancePath, target, value);
|
|
5113
5242
|
}
|
|
5114
5243
|
function CheckRef(stack, context, schema, value) {
|
|
5115
|
-
const
|
|
5244
|
+
const result = Ref(stack, schema);
|
|
5245
|
+
const target = result.schema ?? false;
|
|
5116
5246
|
const nextContext = new CheckContext();
|
|
5117
|
-
const
|
|
5118
|
-
if (
|
|
5119
|
-
return
|
|
5120
|
-
}
|
|
5121
|
-
function ErrorRef(stack, context,
|
|
5122
|
-
const
|
|
5123
|
-
const
|
|
5124
|
-
const
|
|
5125
|
-
|
|
5126
|
-
if (
|
|
5127
|
-
|
|
5247
|
+
const valid = IsSchema(target) && CheckSchema(result.stack, nextContext, target, value);
|
|
5248
|
+
if (valid) context.Merge([nextContext]);
|
|
5249
|
+
return valid;
|
|
5250
|
+
}
|
|
5251
|
+
function ErrorRef(stack, context, schemaPath, instancePath, schema, value) {
|
|
5252
|
+
const result = Ref(stack, schema);
|
|
5253
|
+
const target = result.schema ?? false;
|
|
5254
|
+
const nextContext = new ErrorContext();
|
|
5255
|
+
const valid = IsSchema(target) && ErrorSchema(result.stack, nextContext, schemaPath, instancePath, target, value);
|
|
5256
|
+
if (valid) context.Merge([nextContext]);
|
|
5257
|
+
if (!valid) context.AddErrors(nextContext.GetErrors());
|
|
5258
|
+
return valid;
|
|
5128
5259
|
}
|
|
5129
5260
|
function CheckRequired(_stack, _context, schema, value) {
|
|
5130
5261
|
return Every(schema.required, 0, (key) => HasPropertyKey(value, key));
|
|
@@ -5135,12 +5266,7 @@ function ErrorRequired(_stack, context, schemaPath, instancePath, schema, value)
|
|
|
5135
5266
|
const hasKey = HasPropertyKey(value, key);
|
|
5136
5267
|
if (!hasKey) requiredProperties.push(key);
|
|
5137
5268
|
return hasKey;
|
|
5138
|
-
}) || context.AddError({
|
|
5139
|
-
keyword: "required",
|
|
5140
|
-
schemaPath,
|
|
5141
|
-
instancePath,
|
|
5142
|
-
params: { requiredProperties }
|
|
5143
|
-
});
|
|
5269
|
+
}) || context.AddError("required", schemaPath, instancePath, { requiredProperties });
|
|
5144
5270
|
}
|
|
5145
5271
|
function CheckTypeName(_stack, _context, type, _schema, value) {
|
|
5146
5272
|
return IsEqual(type, "object") ? IsObjectNotArray(value) : IsEqual(type, "array") ? IsArray$1(value) : IsEqual(type, "boolean") ? IsBoolean$2(value) : IsEqual(type, "integer") ? IsInteger$1(value) : IsEqual(type, "number") ? IsNumber$2(value) : IsEqual(type, "null") ? IsNull$1(value) : IsEqual(type, "string") ? IsString$2(value) : IsEqual(type, "bigint") ? IsBigInt$1(value) : IsEqual(type, "constructor") ? IsConstructor$1(value) : IsEqual(type, "function") ? IsFunction$1(value) : IsEqual(type, "symbol") ? IsSymbol$1(value) : IsEqual(type, "undefined") ? IsUndefined$1(value) : IsEqual(type, "void") ? IsUndefined$1(value) : true;
|
|
@@ -5152,12 +5278,7 @@ function CheckType(stack, context, schema, value) {
|
|
|
5152
5278
|
return IsArray$1(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value);
|
|
5153
5279
|
}
|
|
5154
5280
|
function ErrorType(stack, context, schemaPath, instancePath, schema, value) {
|
|
5155
|
-
return (IsArray$1(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value)) || context.AddError({
|
|
5156
|
-
keyword: "type",
|
|
5157
|
-
schemaPath,
|
|
5158
|
-
instancePath,
|
|
5159
|
-
params: { type: schema.type }
|
|
5160
|
-
});
|
|
5281
|
+
return (IsArray$1(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value)) || context.AddError("type", schemaPath, instancePath, { type: schema.type });
|
|
5161
5282
|
}
|
|
5162
5283
|
function CheckUnevaluatedItems(stack, context, schema, value) {
|
|
5163
5284
|
const indices = context.GetIndices();
|
|
@@ -5169,16 +5290,11 @@ function ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema,
|
|
|
5169
5290
|
const indices = context.GetIndices();
|
|
5170
5291
|
const unevaluatedItems = [];
|
|
5171
5292
|
return EveryAll(value, 0, (item, index) => {
|
|
5172
|
-
const nextContext = new
|
|
5293
|
+
const nextContext = new ErrorContext();
|
|
5173
5294
|
const isEvaluatedItem = (indices.has(index) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedItems, item)) && context.AddIndex(index);
|
|
5174
5295
|
if (!isEvaluatedItem) unevaluatedItems.push(index);
|
|
5175
5296
|
return isEvaluatedItem;
|
|
5176
|
-
}) || context.AddError({
|
|
5177
|
-
keyword: "unevaluatedItems",
|
|
5178
|
-
schemaPath,
|
|
5179
|
-
instancePath,
|
|
5180
|
-
params: { unevaluatedItems }
|
|
5181
|
-
});
|
|
5297
|
+
}) || context.AddError("unevaluatedItems", schemaPath, instancePath, { unevaluatedItems });
|
|
5182
5298
|
}
|
|
5183
5299
|
function CheckUnevaluatedProperties(stack, context, schema, value) {
|
|
5184
5300
|
const keys = context.GetKeys();
|
|
@@ -5190,16 +5306,11 @@ function ErrorUnevaluatedProperties(stack, context, schemaPath, instancePath, sc
|
|
|
5190
5306
|
const keys = context.GetKeys();
|
|
5191
5307
|
const unevaluatedProperties = [];
|
|
5192
5308
|
return EveryAll(Entries(value), 0, ([key, prop]) => {
|
|
5193
|
-
const nextContext = new
|
|
5309
|
+
const nextContext = new ErrorContext();
|
|
5194
5310
|
const isEvaluatedProperty = keys.has(key) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedProperties, prop) && context.AddKey(key);
|
|
5195
5311
|
if (!isEvaluatedProperty) unevaluatedProperties.push(key);
|
|
5196
5312
|
return isEvaluatedProperty;
|
|
5197
|
-
}) || context.AddError({
|
|
5198
|
-
keyword: "unevaluatedProperties",
|
|
5199
|
-
schemaPath,
|
|
5200
|
-
instancePath,
|
|
5201
|
-
params: { unevaluatedProperties }
|
|
5202
|
-
});
|
|
5313
|
+
}) || context.AddError("unevaluatedProperties", schemaPath, instancePath, { unevaluatedProperties });
|
|
5203
5314
|
}
|
|
5204
5315
|
function IsValid(schema) {
|
|
5205
5316
|
return !IsEqual(schema.uniqueItems, false);
|
|
@@ -5219,206 +5330,23 @@ function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, val
|
|
|
5219
5330
|
set.add(hash);
|
|
5220
5331
|
return result;
|
|
5221
5332
|
}, []);
|
|
5222
|
-
return IsEqual(duplicateItems.length, 0) || context.AddError({
|
|
5223
|
-
keyword: "uniqueItems",
|
|
5224
|
-
schemaPath,
|
|
5225
|
-
instancePath,
|
|
5226
|
-
params: { duplicateItems }
|
|
5227
|
-
});
|
|
5333
|
+
return IsEqual(duplicateItems.length, 0) || context.AddError("uniqueItems", schemaPath, instancePath, { duplicateItems });
|
|
5228
5334
|
}
|
|
5229
5335
|
function CheckSchemaPushStack(stack, context, schema, value) {
|
|
5230
5336
|
return context.Push() && CheckSchema(stack, context, schema, value) && context.Pop();
|
|
5231
5337
|
}
|
|
5232
5338
|
function CheckSchema(stack, context, schema, value) {
|
|
5233
|
-
stack
|
|
5234
|
-
|
|
5235
|
-
stack.Pop(schema);
|
|
5236
|
-
return result;
|
|
5339
|
+
const current = NextStack(stack, schema);
|
|
5340
|
+
return IsSchemaBoolean(schema) ? CheckSchemaBoolean(current, context, schema, value) : (!IsType(schema) || CheckType(current, context, schema, value)) && (!(IsObject$1(value) && !IsArray$1(value)) || (!IsRequired(schema) || CheckRequired(current, context, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(current, context, schema, value)) && (!IsDependencies(schema) || CheckDependencies(current, context, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(current, context, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(current, context, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(current, context, schema, value)) && (!IsProperties(schema) || CheckProperties(current, context, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(current, context, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(current, context, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(current, context, schema, value))) && (!IsArray$1(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(current, context, schema, value)) && (!IsContains(schema) || CheckContains(current, context, schema, value)) && (!IsItems(schema) || CheckItems(current, context, schema, value)) && (!IsMinContains(schema) || CheckMinContains(current, context, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(current, context, schema, value)) && (!IsMinItems(schema) || CheckMinItems(current, context, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(current, context, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(current, context, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(current, context, schema, value))) && (!IsString$2(value) || (!IsMinLength(schema) || CheckMinLength(current, context, schema, value)) && (!IsMaxLength(schema) || CheckMaxLength(current, context, schema, value)) && (!IsFormat(schema) || CheckFormat(current, context, schema, value)) && (!IsPattern(schema) || CheckPattern(current, context, schema, value))) && (!(IsNumber$2(value) || IsBigInt$1(value)) || (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(current, context, schema, value)) && (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(current, context, schema, value)) && (!IsMinimum(schema) || CheckMinimum(current, context, schema, value)) && (!IsMaximum(schema) || CheckMaximum(current, context, schema, value)) && (!IsMultipleOf(schema) || CheckMultipleOf(current, context, schema, value))) && (!IsRef(schema) || CheckRef(current, context, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(current, context, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(current, context, schema, value)) && (!IsConst(schema) || CheckConst(current, context, schema, value)) && (!IsEnum(schema) || CheckEnum(current, context, schema, value)) && (!IsIf(schema) || CheckIf(current, context, schema, value)) && (!IsNot(schema) || CheckNot(current, context, schema, value)) && (!IsAllOf(schema) || CheckAllOf(current, context, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(current, context, schema, value)) && (!IsOneOf(schema) || CheckOneOf(current, context, schema, value)) && (!IsUnevaluatedItems(schema) || !IsArray$1(value) || CheckUnevaluatedItems(current, context, schema, value)) && (!IsUnevaluatedProperties(schema) || !IsObject$1(value) || CheckUnevaluatedProperties(current, context, schema, value)) && (!IsRefine(schema) || CheckRefine(current, context, schema, value));
|
|
5237
5341
|
}
|
|
5238
5342
|
function ErrorSchemaPushStack(stack, context, schemaPath, instancePath, schema, value) {
|
|
5239
5343
|
return context.Push() && ErrorSchema(stack, context, schemaPath, instancePath, schema, value) && context.Pop();
|
|
5240
5344
|
}
|
|
5241
5345
|
function ErrorSchema(stack, context, schemaPath, instancePath, schema, value) {
|
|
5242
|
-
|
|
5243
|
-
const
|
|
5244
|
-
|
|
5245
|
-
return result;
|
|
5346
|
+
if (context.AtCapacity()) return false;
|
|
5347
|
+
const current = NextStack(stack, schema);
|
|
5348
|
+
return IsSchemaBoolean(schema) ? ErrorSchemaBoolean(current, context, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(current, context, schemaPath, instancePath, schema, value)) & +(!(IsObject$1(value) && !IsArray$1(value)) || !!(+(!IsRequired(schema) || ErrorRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(current, context, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(current, context, schemaPath, instancePath, schema, value)))) & +(!IsArray$1(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(current, context, schemaPath, instancePath, schema, value)))) & +(!IsString$2(value) || !!(+(!IsMinLength(schema) || ErrorMinLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxLength(schema) || ErrorMaxLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(current, context, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(current, context, schemaPath, instancePath, schema, value)))) & +(!(IsNumber$2(value) || IsBigInt$1(value)) || !!(+(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf(schema) || ErrorMultipleOf(current, context, schemaPath, instancePath, schema, value)))) & +(!IsRef(schema) || ErrorRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(current, context, schemaPath, instancePath, schema, value)) & +(!IsEnum(schema) || ErrorEnum(current, context, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(current, context, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(current, context, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || !IsArray$1(value) || ErrorUnevaluatedItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedProperties(schema) || !IsObject$1(value) || ErrorUnevaluatedProperties(current, context, schemaPath, instancePath, schema, value))) && (!IsRefine(schema) || ErrorRefine(current, context, schemaPath, instancePath, schema, value));
|
|
5246
5349
|
}
|
|
5247
|
-
function GetIndex(index, value) {
|
|
5248
|
-
return IsObject$1(value) && !IsUnsafePropertyKey(index) ? value[index] : void 0;
|
|
5249
|
-
}
|
|
5250
|
-
function GetIndices(indices, value) {
|
|
5251
|
-
return indices.reduce((value, index) => GetIndex(index, value), value);
|
|
5252
|
-
}
|
|
5253
|
-
function Indices(pointer) {
|
|
5254
|
-
if (IsEqual(pointer.length, 0)) return [];
|
|
5255
|
-
const indices = pointer.split("/").map((index) => index.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
5256
|
-
return indices.length > 0 && indices[0] === "" ? indices.slice(1) : indices;
|
|
5257
|
-
}
|
|
5258
|
-
function Get(value, pointer) {
|
|
5259
|
-
return GetIndices(Indices(pointer), value);
|
|
5260
|
-
}
|
|
5261
|
-
const DefaultBase = new URL("https://json-schema.org");
|
|
5262
|
-
function MatchId(schema, base, ref) {
|
|
5263
|
-
if (schema.$id === ref.hash) return schema;
|
|
5264
|
-
const absoluteId = new URL(schema.$id, base.href);
|
|
5265
|
-
const absoluteRef = new URL(ref.href, base.href);
|
|
5266
|
-
if (IsEqual(absoluteId.pathname, absoluteRef.pathname)) return ref.hash.startsWith("#") ? MatchHash(schema, base, ref) : schema;
|
|
5267
|
-
}
|
|
5268
|
-
function MatchAnchor(schema, base, ref) {
|
|
5269
|
-
const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
|
|
5270
|
-
const absoluteRef = new URL(ref.href, base.href);
|
|
5271
|
-
return IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
|
|
5272
|
-
}
|
|
5273
|
-
function MatchDynamicAnchor(schema, base, ref) {
|
|
5274
|
-
const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
|
|
5275
|
-
const absoluteRef = new URL(ref.href, base.href);
|
|
5276
|
-
return IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : void 0;
|
|
5277
|
-
}
|
|
5278
|
-
function MatchHash(schema, _base, ref) {
|
|
5279
|
-
if (ref.href.endsWith("#")) return schema;
|
|
5280
|
-
if (!ref.hash.startsWith("#")) return void 0;
|
|
5281
|
-
const fragment = decodeURIComponent(ref.hash.slice(1));
|
|
5282
|
-
if (!fragment.startsWith("/")) return void 0;
|
|
5283
|
-
return Get(schema, fragment);
|
|
5284
|
-
}
|
|
5285
|
-
function Match(schema, base, ref) {
|
|
5286
|
-
if (IsId(schema)) {
|
|
5287
|
-
const result = MatchId(schema, base, ref);
|
|
5288
|
-
if (!IsUndefined$1(result)) return result;
|
|
5289
|
-
}
|
|
5290
|
-
if (IsAnchor(schema)) {
|
|
5291
|
-
const result = MatchAnchor(schema, base, ref);
|
|
5292
|
-
if (!IsUndefined$1(result)) return result;
|
|
5293
|
-
}
|
|
5294
|
-
if (IsDynamicAnchor(schema)) {
|
|
5295
|
-
const result = MatchDynamicAnchor(schema, base, ref);
|
|
5296
|
-
if (!IsUndefined$1(result)) return result;
|
|
5297
|
-
}
|
|
5298
|
-
return MatchHash(schema, base, ref);
|
|
5299
|
-
}
|
|
5300
|
-
function FromArray$4(schema, base, ref) {
|
|
5301
|
-
return schema.reduce((result, item) => {
|
|
5302
|
-
const match = FromValue(item, base, ref);
|
|
5303
|
-
return !IsUndefined$1(match) ? match : result;
|
|
5304
|
-
}, void 0);
|
|
5305
|
-
}
|
|
5306
|
-
function SkipProperty(key) {
|
|
5307
|
-
return IsEqual(key, "const") || IsEqual(key, "enum");
|
|
5308
|
-
}
|
|
5309
|
-
function FromObject$4(schema, base, ref) {
|
|
5310
|
-
return Keys(schema).reduce((result, key) => {
|
|
5311
|
-
if (SkipProperty(key)) return result;
|
|
5312
|
-
const match = FromValue(schema[key], base, ref);
|
|
5313
|
-
return !IsUndefined$1(match) ? match : result;
|
|
5314
|
-
}, void 0);
|
|
5315
|
-
}
|
|
5316
|
-
function FromValue(schema, base, ref) {
|
|
5317
|
-
const nextBase = IsSchemaObject(schema) && IsId(schema) ? new URL(schema.$id, base.href) : base;
|
|
5318
|
-
if (IsSchemaObject(schema)) {
|
|
5319
|
-
const result = Match(schema, nextBase, ref);
|
|
5320
|
-
if (!IsUndefined$1(result)) return result;
|
|
5321
|
-
}
|
|
5322
|
-
if (IsArray$1(schema)) return FromArray$4(schema, nextBase, ref);
|
|
5323
|
-
if (IsObject$1(schema)) return FromObject$4(schema, nextBase, ref);
|
|
5324
|
-
}
|
|
5325
|
-
function CanonicalHref(url) {
|
|
5326
|
-
return url.href.split("#")[0];
|
|
5327
|
-
}
|
|
5328
|
-
function RefContext(context, ref) {
|
|
5329
|
-
return HasPropertyKey(context, ref) ? context[ref] : void 0;
|
|
5330
|
-
}
|
|
5331
|
-
function RefLocal(schema, base, ref) {
|
|
5332
|
-
return FromValue(schema, base, ref);
|
|
5333
|
-
}
|
|
5334
|
-
function RefRemote(context, base, ref) {
|
|
5335
|
-
const targetDocumentHref = CanonicalHref(ref);
|
|
5336
|
-
if (IsEqual(targetDocumentHref, CanonicalHref(base))) return void 0;
|
|
5337
|
-
if (!HasPropertyKey(context, targetDocumentHref)) return void 0;
|
|
5338
|
-
const remoteSchema = context[targetDocumentHref];
|
|
5339
|
-
return FromValue(remoteSchema, IsSchemaObject(remoteSchema) && IsId(remoteSchema) ? new URL(remoteSchema.$id, DefaultBase.href) : new URL(targetDocumentHref), ref);
|
|
5340
|
-
}
|
|
5341
|
-
function Ref(context, schema, ref) {
|
|
5342
|
-
const initialBase = IsId(schema) ? new URL(schema.$id, DefaultBase.href) : DefaultBase;
|
|
5343
|
-
const initialRef = new URL(ref, initialBase.href);
|
|
5344
|
-
return RefContext(context, ref) ?? RefLocal(schema, initialBase, initialRef) ?? RefRemote(context, initialBase, initialRef);
|
|
5345
|
-
}
|
|
5346
|
-
function DynamicRef(context, root, base, dynamicRef, dynamicAnchors) {
|
|
5347
|
-
const fragmentTarget = dynamicRef.$dynamicRef.startsWith("#") ? Ref(context, base, dynamicRef.$dynamicRef) : Ref(context, root, dynamicRef.$dynamicRef);
|
|
5348
|
-
if (IsUndefined$1(fragmentTarget)) return void 0;
|
|
5349
|
-
if (!IsSchemaObject(fragmentTarget) || !IsDynamicAnchor(fragmentTarget)) return fragmentTarget;
|
|
5350
|
-
if (new URL(dynamicRef.$dynamicRef, DefaultBase).hash.startsWith("#/")) return fragmentTarget;
|
|
5351
|
-
return dynamicAnchors.find((anchor) => anchor.$dynamicAnchor === fragmentTarget.$dynamicAnchor) ?? fragmentTarget;
|
|
5352
|
-
}
|
|
5353
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
5354
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5355
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5356
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5357
|
-
};
|
|
5358
|
-
var _Stack_instances;
|
|
5359
|
-
var _Stack_PushResourceAnchors;
|
|
5360
|
-
var _Stack_PopResourceAnchors;
|
|
5361
|
-
var Stack = class {
|
|
5362
|
-
constructor(context, schema) {
|
|
5363
|
-
_Stack_instances.add(this);
|
|
5364
|
-
this.context = context;
|
|
5365
|
-
this.schema = schema;
|
|
5366
|
-
this.ids = [];
|
|
5367
|
-
this.anchors = [];
|
|
5368
|
-
this.recursiveAnchors = [];
|
|
5369
|
-
this.dynamicAnchors = [];
|
|
5370
|
-
}
|
|
5371
|
-
BaseURL() {
|
|
5372
|
-
return this.ids.reduce((result, schema) => new URL(schema.$id, result), DefaultBase);
|
|
5373
|
-
}
|
|
5374
|
-
Base() {
|
|
5375
|
-
return this.ids[this.ids.length - 1] ?? this.schema;
|
|
5376
|
-
}
|
|
5377
|
-
Push(schema) {
|
|
5378
|
-
if (!IsSchemaObject(schema)) return;
|
|
5379
|
-
if (IsId(schema)) {
|
|
5380
|
-
this.ids.push(schema);
|
|
5381
|
-
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PushResourceAnchors).call(this, schema);
|
|
5382
|
-
}
|
|
5383
|
-
if (IsAnchor(schema)) this.anchors.push(schema);
|
|
5384
|
-
if (IsRecursiveAnchorTrue(schema)) this.recursiveAnchors.push(schema);
|
|
5385
|
-
if (IsDynamicAnchor(schema)) this.dynamicAnchors.push(schema);
|
|
5386
|
-
}
|
|
5387
|
-
Pop(schema) {
|
|
5388
|
-
if (!IsSchemaObject(schema)) return;
|
|
5389
|
-
if (IsId(schema)) {
|
|
5390
|
-
this.ids.pop();
|
|
5391
|
-
__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PopResourceAnchors).call(this, schema);
|
|
5392
|
-
}
|
|
5393
|
-
if (IsAnchor(schema)) this.anchors.pop();
|
|
5394
|
-
if (IsRecursiveAnchorTrue(schema)) this.recursiveAnchors.pop();
|
|
5395
|
-
if (IsDynamicAnchor(schema)) this.dynamicAnchors.pop();
|
|
5396
|
-
}
|
|
5397
|
-
Ref(ref) {
|
|
5398
|
-
const root = this.schema;
|
|
5399
|
-
return !ref.$ref.startsWith("#") ? Ref(this.context, root, ref.$ref) : Ref(this.context, this.Base(), ref.$ref);
|
|
5400
|
-
}
|
|
5401
|
-
RecursiveRef(recursiveRef) {
|
|
5402
|
-
return IsRecursiveAnchorTrue(this.Base()) ? Ref(this.context, this.recursiveAnchors[0], recursiveRef.$recursiveRef) : Ref(this.context, this.Base(), recursiveRef.$recursiveRef);
|
|
5403
|
-
}
|
|
5404
|
-
DynamicRef(dynamicRef) {
|
|
5405
|
-
const root = this.schema;
|
|
5406
|
-
return DynamicRef(this.context, root, this.Base(), dynamicRef, this.dynamicAnchors);
|
|
5407
|
-
}
|
|
5408
|
-
};
|
|
5409
|
-
_Stack_instances = /* @__PURE__ */ new WeakSet(), _Stack_PushResourceAnchors = function _Stack_PushResourceAnchors(schema, isRoot = true) {
|
|
5410
|
-
if (!IsSchemaObject(schema)) return;
|
|
5411
|
-
const current = schema;
|
|
5412
|
-
if (!isRoot && IsId(current)) return;
|
|
5413
|
-
if (!isRoot && IsDynamicAnchor(current)) this.dynamicAnchors.push(current);
|
|
5414
|
-
for (const key of Keys(current)) __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PushResourceAnchors).call(this, current[key], false);
|
|
5415
|
-
}, _Stack_PopResourceAnchors = function _Stack_PopResourceAnchors(schema, isRoot = true) {
|
|
5416
|
-
if (!IsSchemaObject(schema)) return;
|
|
5417
|
-
const current = schema;
|
|
5418
|
-
if (!isRoot && IsId(current)) return;
|
|
5419
|
-
if (!isRoot && IsDynamicAnchor(current)) this.dynamicAnchors.pop();
|
|
5420
|
-
for (const key of Keys(current)) __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_PopResourceAnchors).call(this, current[key], false);
|
|
5421
|
-
};
|
|
5422
5350
|
function Errors$1(...args) {
|
|
5423
5351
|
const [context, schema, value] = Match$3(args, {
|
|
5424
5352
|
3: (context, schema, value) => [
|
|
@@ -5432,16 +5360,15 @@ function Errors$1(...args) {
|
|
|
5432
5360
|
value
|
|
5433
5361
|
]
|
|
5434
5362
|
});
|
|
5435
|
-
const
|
|
5363
|
+
const stack = Stack(context, schema);
|
|
5364
|
+
const errorContext = new ErrorContext();
|
|
5365
|
+
const result = ErrorSchema(stack, errorContext, "#", "", schema, value);
|
|
5366
|
+
const errors = errorContext.GetErrors();
|
|
5436
5367
|
const locale = Get$1();
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
...error,
|
|
5442
|
-
message: locale(error)
|
|
5443
|
-
});
|
|
5444
|
-
}), "#", "", schema, value), errors];
|
|
5368
|
+
return [result, errors.map((error) => ({
|
|
5369
|
+
...error,
|
|
5370
|
+
message: locale(error)
|
|
5371
|
+
}))];
|
|
5445
5372
|
}
|
|
5446
5373
|
function Check$1(...args) {
|
|
5447
5374
|
const [context, schema, value] = Match$3(args, {
|
|
@@ -5456,7 +5383,7 @@ function Check$1(...args) {
|
|
|
5456
5383
|
value
|
|
5457
5384
|
]
|
|
5458
5385
|
});
|
|
5459
|
-
return CheckSchema(
|
|
5386
|
+
return CheckSchema(Stack(context, schema), new CheckContext(), schema, value);
|
|
5460
5387
|
}
|
|
5461
5388
|
function Check(...args) {
|
|
5462
5389
|
const [context, type, value] = Match$3(args, {
|