@anvailabs/agentbrowser-mcp 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +2939 -438
- package/dist/index.js +2753 -252
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +46 -29
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -105,6 +105,24 @@ function Clone(value) {
|
|
|
105
105
|
function CloneType(schema, options) {
|
|
106
106
|
return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
|
|
107
107
|
}
|
|
108
|
+
function IsAsyncIterator2(value) {
|
|
109
|
+
return IsObject2(value) && globalThis.Symbol.asyncIterator in value;
|
|
110
|
+
}
|
|
111
|
+
function IsIterator2(value) {
|
|
112
|
+
return IsObject2(value) && globalThis.Symbol.iterator in value;
|
|
113
|
+
}
|
|
114
|
+
function IsPromise(value) {
|
|
115
|
+
return value instanceof globalThis.Promise;
|
|
116
|
+
}
|
|
117
|
+
function IsDate2(value) {
|
|
118
|
+
return value instanceof Date && globalThis.Number.isFinite(value.getTime());
|
|
119
|
+
}
|
|
120
|
+
function IsUint8Array2(value) {
|
|
121
|
+
return value instanceof globalThis.Uint8Array;
|
|
122
|
+
}
|
|
123
|
+
function HasPropertyKey2(value, key) {
|
|
124
|
+
return key in value;
|
|
125
|
+
}
|
|
108
126
|
function IsObject2(value) {
|
|
109
127
|
return value !== null && typeof value === "object";
|
|
110
128
|
}
|
|
@@ -114,9 +132,33 @@ function IsArray2(value) {
|
|
|
114
132
|
function IsUndefined2(value) {
|
|
115
133
|
return value === void 0;
|
|
116
134
|
}
|
|
135
|
+
function IsNull2(value) {
|
|
136
|
+
return value === null;
|
|
137
|
+
}
|
|
138
|
+
function IsBoolean2(value) {
|
|
139
|
+
return typeof value === "boolean";
|
|
140
|
+
}
|
|
117
141
|
function IsNumber2(value) {
|
|
118
142
|
return typeof value === "number";
|
|
119
143
|
}
|
|
144
|
+
function IsInteger(value) {
|
|
145
|
+
return globalThis.Number.isInteger(value);
|
|
146
|
+
}
|
|
147
|
+
function IsBigInt2(value) {
|
|
148
|
+
return typeof value === "bigint";
|
|
149
|
+
}
|
|
150
|
+
function IsString2(value) {
|
|
151
|
+
return typeof value === "string";
|
|
152
|
+
}
|
|
153
|
+
function IsFunction2(value) {
|
|
154
|
+
return typeof value === "function";
|
|
155
|
+
}
|
|
156
|
+
function IsSymbol2(value) {
|
|
157
|
+
return typeof value === "symbol";
|
|
158
|
+
}
|
|
159
|
+
function IsValueType(value) {
|
|
160
|
+
return IsBigInt2(value) || IsBoolean2(value) || IsNull2(value) || IsNumber2(value) || IsString2(value) || IsSymbol2(value) || IsUndefined2(value);
|
|
161
|
+
}
|
|
120
162
|
var TypeSystemPolicy;
|
|
121
163
|
(function(TypeSystemPolicy2) {
|
|
122
164
|
TypeSystemPolicy2.InstanceMode = "default";
|
|
@@ -208,13 +250,13 @@ function IsArgument(value) {
|
|
|
208
250
|
function IsArray3(value) {
|
|
209
251
|
return IsKindOf(value, "Array");
|
|
210
252
|
}
|
|
211
|
-
function
|
|
253
|
+
function IsAsyncIterator3(value) {
|
|
212
254
|
return IsKindOf(value, "AsyncIterator");
|
|
213
255
|
}
|
|
214
|
-
function
|
|
256
|
+
function IsBigInt3(value) {
|
|
215
257
|
return IsKindOf(value, "BigInt");
|
|
216
258
|
}
|
|
217
|
-
function
|
|
259
|
+
function IsBoolean3(value) {
|
|
218
260
|
return IsKindOf(value, "Boolean");
|
|
219
261
|
}
|
|
220
262
|
function IsComputed(value) {
|
|
@@ -223,19 +265,19 @@ function IsComputed(value) {
|
|
|
223
265
|
function IsConstructor(value) {
|
|
224
266
|
return IsKindOf(value, "Constructor");
|
|
225
267
|
}
|
|
226
|
-
function
|
|
268
|
+
function IsDate3(value) {
|
|
227
269
|
return IsKindOf(value, "Date");
|
|
228
270
|
}
|
|
229
|
-
function
|
|
271
|
+
function IsFunction3(value) {
|
|
230
272
|
return IsKindOf(value, "Function");
|
|
231
273
|
}
|
|
232
|
-
function
|
|
274
|
+
function IsInteger2(value) {
|
|
233
275
|
return IsKindOf(value, "Integer");
|
|
234
276
|
}
|
|
235
277
|
function IsIntersect(value) {
|
|
236
278
|
return IsKindOf(value, "Intersect");
|
|
237
279
|
}
|
|
238
|
-
function
|
|
280
|
+
function IsIterator3(value) {
|
|
239
281
|
return IsKindOf(value, "Iterator");
|
|
240
282
|
}
|
|
241
283
|
function IsKindOf(value, kind) {
|
|
@@ -259,7 +301,7 @@ function IsNever(value) {
|
|
|
259
301
|
function IsNot(value) {
|
|
260
302
|
return IsKindOf(value, "Not");
|
|
261
303
|
}
|
|
262
|
-
function
|
|
304
|
+
function IsNull3(value) {
|
|
263
305
|
return IsKindOf(value, "Null");
|
|
264
306
|
}
|
|
265
307
|
function IsNumber3(value) {
|
|
@@ -268,7 +310,7 @@ function IsNumber3(value) {
|
|
|
268
310
|
function IsObject3(value) {
|
|
269
311
|
return IsKindOf(value, "Object");
|
|
270
312
|
}
|
|
271
|
-
function
|
|
313
|
+
function IsPromise2(value) {
|
|
272
314
|
return IsKindOf(value, "Promise");
|
|
273
315
|
}
|
|
274
316
|
function IsRecord(value) {
|
|
@@ -280,10 +322,10 @@ function IsRef(value) {
|
|
|
280
322
|
function IsRegExp2(value) {
|
|
281
323
|
return IsKindOf(value, "RegExp");
|
|
282
324
|
}
|
|
283
|
-
function
|
|
325
|
+
function IsString3(value) {
|
|
284
326
|
return IsKindOf(value, "String");
|
|
285
327
|
}
|
|
286
|
-
function
|
|
328
|
+
function IsSymbol3(value) {
|
|
287
329
|
return IsKindOf(value, "Symbol");
|
|
288
330
|
}
|
|
289
331
|
function IsTemplateLiteral(value) {
|
|
@@ -304,7 +346,7 @@ function IsUndefined3(value) {
|
|
|
304
346
|
function IsUnion(value) {
|
|
305
347
|
return IsKindOf(value, "Union");
|
|
306
348
|
}
|
|
307
|
-
function
|
|
349
|
+
function IsUint8Array3(value) {
|
|
308
350
|
return IsKindOf(value, "Uint8Array");
|
|
309
351
|
}
|
|
310
352
|
function IsUnknown(value) {
|
|
@@ -320,24 +362,24 @@ function IsKind(value) {
|
|
|
320
362
|
return IsObject(value) && Kind in value && IsString(value[Kind]);
|
|
321
363
|
}
|
|
322
364
|
function IsSchema(value) {
|
|
323
|
-
return IsAny(value) || IsArgument(value) || IsArray3(value) ||
|
|
365
|
+
return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed(value) || IsConstructor(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect(value) || IsIterator3(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull3(value) || IsNumber3(value) || IsObject3(value) || IsPromise2(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array3(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
|
|
324
366
|
}
|
|
325
367
|
var type_exports = {};
|
|
326
368
|
__export(type_exports, {
|
|
327
369
|
IsAny: () => IsAny2,
|
|
328
370
|
IsArgument: () => IsArgument2,
|
|
329
371
|
IsArray: () => IsArray4,
|
|
330
|
-
IsAsyncIterator: () =>
|
|
331
|
-
IsBigInt: () =>
|
|
332
|
-
IsBoolean: () =>
|
|
372
|
+
IsAsyncIterator: () => IsAsyncIterator4,
|
|
373
|
+
IsBigInt: () => IsBigInt4,
|
|
374
|
+
IsBoolean: () => IsBoolean4,
|
|
333
375
|
IsComputed: () => IsComputed2,
|
|
334
376
|
IsConstructor: () => IsConstructor2,
|
|
335
|
-
IsDate: () =>
|
|
336
|
-
IsFunction: () =>
|
|
377
|
+
IsDate: () => IsDate4,
|
|
378
|
+
IsFunction: () => IsFunction4,
|
|
337
379
|
IsImport: () => IsImport,
|
|
338
|
-
IsInteger: () =>
|
|
380
|
+
IsInteger: () => IsInteger3,
|
|
339
381
|
IsIntersect: () => IsIntersect2,
|
|
340
|
-
IsIterator: () =>
|
|
382
|
+
IsIterator: () => IsIterator4,
|
|
341
383
|
IsKind: () => IsKind2,
|
|
342
384
|
IsKindOf: () => IsKindOf2,
|
|
343
385
|
IsLiteral: () => IsLiteral2,
|
|
@@ -349,11 +391,11 @@ __export(type_exports, {
|
|
|
349
391
|
IsMappedResult: () => IsMappedResult2,
|
|
350
392
|
IsNever: () => IsNever2,
|
|
351
393
|
IsNot: () => IsNot2,
|
|
352
|
-
IsNull: () =>
|
|
394
|
+
IsNull: () => IsNull4,
|
|
353
395
|
IsNumber: () => IsNumber4,
|
|
354
396
|
IsObject: () => IsObject4,
|
|
355
397
|
IsOptional: () => IsOptional2,
|
|
356
|
-
IsPromise: () =>
|
|
398
|
+
IsPromise: () => IsPromise3,
|
|
357
399
|
IsProperties: () => IsProperties,
|
|
358
400
|
IsReadonly: () => IsReadonly2,
|
|
359
401
|
IsRecord: () => IsRecord2,
|
|
@@ -361,13 +403,13 @@ __export(type_exports, {
|
|
|
361
403
|
IsRef: () => IsRef2,
|
|
362
404
|
IsRegExp: () => IsRegExp3,
|
|
363
405
|
IsSchema: () => IsSchema2,
|
|
364
|
-
IsString: () =>
|
|
365
|
-
IsSymbol: () =>
|
|
406
|
+
IsString: () => IsString4,
|
|
407
|
+
IsSymbol: () => IsSymbol4,
|
|
366
408
|
IsTemplateLiteral: () => IsTemplateLiteral2,
|
|
367
409
|
IsThis: () => IsThis2,
|
|
368
410
|
IsTransform: () => IsTransform2,
|
|
369
411
|
IsTuple: () => IsTuple2,
|
|
370
|
-
IsUint8Array: () =>
|
|
412
|
+
IsUint8Array: () => IsUint8Array4,
|
|
371
413
|
IsUndefined: () => IsUndefined4,
|
|
372
414
|
IsUnion: () => IsUnion2,
|
|
373
415
|
IsUnionLiteral: () => IsUnionLiteral,
|
|
@@ -473,13 +515,13 @@ function IsArgument2(value) {
|
|
|
473
515
|
function IsArray4(value) {
|
|
474
516
|
return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
|
|
475
517
|
}
|
|
476
|
-
function
|
|
518
|
+
function IsAsyncIterator4(value) {
|
|
477
519
|
return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
478
520
|
}
|
|
479
|
-
function
|
|
521
|
+
function IsBigInt4(value) {
|
|
480
522
|
return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
|
|
481
523
|
}
|
|
482
|
-
function
|
|
524
|
+
function IsBoolean4(value) {
|
|
483
525
|
return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
|
|
484
526
|
}
|
|
485
527
|
function IsComputed2(value) {
|
|
@@ -488,16 +530,16 @@ function IsComputed2(value) {
|
|
|
488
530
|
function IsConstructor2(value) {
|
|
489
531
|
return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
490
532
|
}
|
|
491
|
-
function
|
|
533
|
+
function IsDate4(value) {
|
|
492
534
|
return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
|
|
493
535
|
}
|
|
494
|
-
function
|
|
536
|
+
function IsFunction4(value) {
|
|
495
537
|
return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
496
538
|
}
|
|
497
539
|
function IsImport(value) {
|
|
498
540
|
return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
|
|
499
541
|
}
|
|
500
|
-
function
|
|
542
|
+
function IsInteger3(value) {
|
|
501
543
|
return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
|
|
502
544
|
}
|
|
503
545
|
function IsProperties(value) {
|
|
@@ -506,7 +548,7 @@ function IsProperties(value) {
|
|
|
506
548
|
function IsIntersect2(value) {
|
|
507
549
|
return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
|
|
508
550
|
}
|
|
509
|
-
function
|
|
551
|
+
function IsIterator4(value) {
|
|
510
552
|
return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
511
553
|
}
|
|
512
554
|
function IsKindOf2(value, kind) {
|
|
@@ -539,7 +581,7 @@ function IsNever2(value) {
|
|
|
539
581
|
function IsNot2(value) {
|
|
540
582
|
return IsKindOf2(value, "Not") && IsSchema2(value.not);
|
|
541
583
|
}
|
|
542
|
-
function
|
|
584
|
+
function IsNull4(value) {
|
|
543
585
|
return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
|
|
544
586
|
}
|
|
545
587
|
function IsNumber4(value) {
|
|
@@ -548,7 +590,7 @@ function IsNumber4(value) {
|
|
|
548
590
|
function IsObject4(value) {
|
|
549
591
|
return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
|
|
550
592
|
}
|
|
551
|
-
function
|
|
593
|
+
function IsPromise3(value) {
|
|
552
594
|
return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
|
|
553
595
|
}
|
|
554
596
|
function IsRecord2(value) {
|
|
@@ -566,10 +608,10 @@ function IsRef2(value) {
|
|
|
566
608
|
function IsRegExp3(value) {
|
|
567
609
|
return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
|
|
568
610
|
}
|
|
569
|
-
function
|
|
611
|
+
function IsString4(value) {
|
|
570
612
|
return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
|
|
571
613
|
}
|
|
572
|
-
function
|
|
614
|
+
function IsSymbol4(value) {
|
|
573
615
|
return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
|
|
574
616
|
}
|
|
575
617
|
function IsTemplateLiteral2(value) {
|
|
@@ -594,7 +636,7 @@ function IsUnionLiteral(value) {
|
|
|
594
636
|
function IsUnion2(value) {
|
|
595
637
|
return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
|
|
596
638
|
}
|
|
597
|
-
function
|
|
639
|
+
function IsUint8Array4(value) {
|
|
598
640
|
return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
|
|
599
641
|
}
|
|
600
642
|
function IsUnknown2(value) {
|
|
@@ -610,7 +652,7 @@ function IsKind2(value) {
|
|
|
610
652
|
return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
|
|
611
653
|
}
|
|
612
654
|
function IsSchema2(value) {
|
|
613
|
-
return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) ||
|
|
655
|
+
return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean4(value) || IsBigInt4(value) || IsAsyncIterator4(value) || IsComputed2(value) || IsConstructor2(value) || IsDate4(value) || IsFunction4(value) || IsInteger3(value) || IsIntersect2(value) || IsIterator4(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull4(value) || IsNumber4(value) || IsObject4(value) || IsPromise3(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString4(value) || IsSymbol4(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array4(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
|
|
614
656
|
}
|
|
615
657
|
var PatternBoolean = "(true|false)";
|
|
616
658
|
var PatternNumber = "(0|[1-9][0-9]*)";
|
|
@@ -620,6 +662,62 @@ var PatternBooleanExact = `^${PatternBoolean}$`;
|
|
|
620
662
|
var PatternNumberExact = `^${PatternNumber}$`;
|
|
621
663
|
var PatternStringExact = `^${PatternString}$`;
|
|
622
664
|
var PatternNeverExact = `^${PatternNever}$`;
|
|
665
|
+
var format_exports = {};
|
|
666
|
+
__export(format_exports, {
|
|
667
|
+
Clear: () => Clear,
|
|
668
|
+
Delete: () => Delete,
|
|
669
|
+
Entries: () => Entries,
|
|
670
|
+
Get: () => Get,
|
|
671
|
+
Has: () => Has,
|
|
672
|
+
Set: () => Set2
|
|
673
|
+
});
|
|
674
|
+
var map = /* @__PURE__ */ new Map();
|
|
675
|
+
function Entries() {
|
|
676
|
+
return new Map(map);
|
|
677
|
+
}
|
|
678
|
+
function Clear() {
|
|
679
|
+
return map.clear();
|
|
680
|
+
}
|
|
681
|
+
function Delete(format) {
|
|
682
|
+
return map.delete(format);
|
|
683
|
+
}
|
|
684
|
+
function Has(format) {
|
|
685
|
+
return map.has(format);
|
|
686
|
+
}
|
|
687
|
+
function Set2(format, func) {
|
|
688
|
+
map.set(format, func);
|
|
689
|
+
}
|
|
690
|
+
function Get(format) {
|
|
691
|
+
return map.get(format);
|
|
692
|
+
}
|
|
693
|
+
var type_exports2 = {};
|
|
694
|
+
__export(type_exports2, {
|
|
695
|
+
Clear: () => Clear2,
|
|
696
|
+
Delete: () => Delete2,
|
|
697
|
+
Entries: () => Entries2,
|
|
698
|
+
Get: () => Get2,
|
|
699
|
+
Has: () => Has2,
|
|
700
|
+
Set: () => Set3
|
|
701
|
+
});
|
|
702
|
+
var map2 = /* @__PURE__ */ new Map();
|
|
703
|
+
function Entries2() {
|
|
704
|
+
return new Map(map2);
|
|
705
|
+
}
|
|
706
|
+
function Clear2() {
|
|
707
|
+
return map2.clear();
|
|
708
|
+
}
|
|
709
|
+
function Delete2(kind) {
|
|
710
|
+
return map2.delete(kind);
|
|
711
|
+
}
|
|
712
|
+
function Has2(kind) {
|
|
713
|
+
return map2.has(kind);
|
|
714
|
+
}
|
|
715
|
+
function Set3(kind, func) {
|
|
716
|
+
map2.set(kind, func);
|
|
717
|
+
}
|
|
718
|
+
function Get2(kind) {
|
|
719
|
+
return map2.get(kind);
|
|
720
|
+
}
|
|
623
721
|
function SetIncludes(T, S) {
|
|
624
722
|
return T.includes(S);
|
|
625
723
|
}
|
|
@@ -884,7 +982,7 @@ function Literal(value, options) {
|
|
|
884
982
|
function Boolean2(options) {
|
|
885
983
|
return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
|
|
886
984
|
}
|
|
887
|
-
function
|
|
985
|
+
function BigInt2(options) {
|
|
888
986
|
return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
|
|
889
987
|
}
|
|
890
988
|
function Number2(options) {
|
|
@@ -895,7 +993,7 @@ function String2(options) {
|
|
|
895
993
|
}
|
|
896
994
|
function* FromUnion(syntax) {
|
|
897
995
|
const trim = syntax.trim().replace(/"|'/g, "");
|
|
898
|
-
return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield
|
|
996
|
+
return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt2() : trim === "string" ? yield String2() : yield (() => {
|
|
899
997
|
const literals = trim.split("|").map((literal) => Literal(literal.trim()));
|
|
900
998
|
return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
|
|
901
999
|
})();
|
|
@@ -934,7 +1032,7 @@ function Escape(value) {
|
|
|
934
1032
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
935
1033
|
}
|
|
936
1034
|
function Visit2(schema, acc) {
|
|
937
|
-
return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` :
|
|
1035
|
+
return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` : IsInteger2(schema) ? `${acc}${PatternNumber}` : IsBigInt3(schema) ? `${acc}${PatternNumber}` : IsString3(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean3(schema) ? `${acc}${PatternBoolean}` : (() => {
|
|
938
1036
|
throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
|
|
939
1037
|
})();
|
|
940
1038
|
}
|
|
@@ -964,7 +1062,7 @@ function FromLiteral(literalValue) {
|
|
|
964
1062
|
return [literalValue.toString()];
|
|
965
1063
|
}
|
|
966
1064
|
function IndexPropertyKeys(type) {
|
|
967
|
-
return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] :
|
|
1065
|
+
return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger2(type) ? ["[number]"] : [])];
|
|
968
1066
|
}
|
|
969
1067
|
function FromProperties(type, properties, options) {
|
|
970
1068
|
const result = {};
|
|
@@ -1121,7 +1219,7 @@ function FromSchemaType(K, T) {
|
|
|
1121
1219
|
// unevaluated mapped types
|
|
1122
1220
|
IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
|
|
1123
1221
|
// unevaluated types
|
|
1124
|
-
IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) :
|
|
1222
|
+
IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction3(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator3(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator3(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect(T) ? Intersect(FromRest2(K, T.allOf), options) : IsUnion(T) ? Union(FromRest2(K, T.anyOf), options) : IsTuple(T) ? Tuple(FromRest2(K, T.items ?? []), options) : IsObject3(T) ? Object2(FromProperties3(K, T.properties), options) : IsArray3(T) ? Array2(FromSchemaType(K, T.items), options) : IsPromise2(T) ? Promise2(FromSchemaType(K, T.item), options) : T
|
|
1125
1223
|
)
|
|
1126
1224
|
)
|
|
1127
1225
|
);
|
|
@@ -1132,9 +1230,9 @@ function MappedFunctionReturnType(K, T) {
|
|
|
1132
1230
|
Acc[L] = FromSchemaType(L, T);
|
|
1133
1231
|
return Acc;
|
|
1134
1232
|
}
|
|
1135
|
-
function Mapped(key,
|
|
1233
|
+
function Mapped(key, map3, options) {
|
|
1136
1234
|
const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
1137
|
-
const RT =
|
|
1235
|
+
const RT = map3({ [Kind]: "MappedKey", keys: K });
|
|
1138
1236
|
const R = MappedFunctionReturnType(K, RT);
|
|
1139
1237
|
return Object2(R, options);
|
|
1140
1238
|
}
|
|
@@ -1224,7 +1322,7 @@ function FromRest3(types) {
|
|
|
1224
1322
|
return types.map((type) => Awaited(type));
|
|
1225
1323
|
}
|
|
1226
1324
|
function Awaited(type, options) {
|
|
1227
|
-
return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) :
|
|
1325
|
+
return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise2(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
|
|
1228
1326
|
}
|
|
1229
1327
|
function FromRest4(types) {
|
|
1230
1328
|
const result = [];
|
|
@@ -1263,6 +1361,13 @@ function KeyOfPropertyKeys(type) {
|
|
|
1263
1361
|
return IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion5(type.anyOf) : IsTuple(type) ? FromTuple2(type.items ?? []) : IsArray3(type) ? FromArray2(type.items) : IsObject3(type) ? FromProperties5(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
|
|
1264
1362
|
}
|
|
1265
1363
|
var includePatternProperties = false;
|
|
1364
|
+
function KeyOfPattern(schema) {
|
|
1365
|
+
includePatternProperties = true;
|
|
1366
|
+
const keys = KeyOfPropertyKeys(schema);
|
|
1367
|
+
includePatternProperties = false;
|
|
1368
|
+
const pattern = keys.map((key) => `(${key})`);
|
|
1369
|
+
return `^(${pattern.join("|")})$`;
|
|
1370
|
+
}
|
|
1266
1371
|
function FromComputed2(target, parameters) {
|
|
1267
1372
|
return Computed("KeyOf", [Computed(target, parameters)]);
|
|
1268
1373
|
}
|
|
@@ -1294,6 +1399,11 @@ function KeyOfFromMappedResult(mappedResult, options) {
|
|
|
1294
1399
|
const properties = FromMappedResult5(mappedResult, options);
|
|
1295
1400
|
return MappedResult(properties);
|
|
1296
1401
|
}
|
|
1402
|
+
function KeyOfPropertyEntries(schema) {
|
|
1403
|
+
const keys = KeyOfPropertyKeys(schema);
|
|
1404
|
+
const schemas = IndexFromPropertyKeys(schema, keys);
|
|
1405
|
+
return keys.map((_, index) => [keys[index], schemas[index]]);
|
|
1406
|
+
}
|
|
1297
1407
|
function CompositeKeys(T) {
|
|
1298
1408
|
const Acc = [];
|
|
1299
1409
|
for (const L of T)
|
|
@@ -1353,7 +1463,7 @@ function ConditionalReadonly(T, root) {
|
|
|
1353
1463
|
return root === true ? T : Readonly(T);
|
|
1354
1464
|
}
|
|
1355
1465
|
function FromValue(value, root) {
|
|
1356
|
-
return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ?
|
|
1466
|
+
return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ? BigInt2() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
|
|
1357
1467
|
}
|
|
1358
1468
|
function Const(T, options) {
|
|
1359
1469
|
return CreateType(FromValue(T, true), options);
|
|
@@ -1655,6 +1765,18 @@ function ExtendsFromMappedKey(T, U, L, R, options) {
|
|
|
1655
1765
|
const P = FromMappedKey2(T, U, L, R, options);
|
|
1656
1766
|
return MappedResult(P);
|
|
1657
1767
|
}
|
|
1768
|
+
function Intersect2(schema) {
|
|
1769
|
+
return schema.allOf.every((schema2) => ExtendsUndefinedCheck(schema2));
|
|
1770
|
+
}
|
|
1771
|
+
function Union2(schema) {
|
|
1772
|
+
return schema.anyOf.some((schema2) => ExtendsUndefinedCheck(schema2));
|
|
1773
|
+
}
|
|
1774
|
+
function Not(schema) {
|
|
1775
|
+
return !ExtendsUndefinedCheck(schema.not);
|
|
1776
|
+
}
|
|
1777
|
+
function ExtendsUndefinedCheck(schema) {
|
|
1778
|
+
return schema[Kind] === "Intersect" ? Intersect2(schema) : schema[Kind] === "Union" ? Union2(schema) : schema[Kind] === "Not" ? Not(schema) : schema[Kind] === "Undefined" ? true : false;
|
|
1779
|
+
}
|
|
1658
1780
|
function ExcludeFromTemplateLiteral(L, R) {
|
|
1659
1781
|
return Exclude(TemplateLiteralToUnion(L), R);
|
|
1660
1782
|
}
|
|
@@ -1756,7 +1878,7 @@ function FromNumberKey(_, type, options) {
|
|
|
1756
1878
|
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
1757
1879
|
}
|
|
1758
1880
|
function Record(key, type, options = {}) {
|
|
1759
|
-
return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) :
|
|
1881
|
+
return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean3(key) ? FromBooleanKey(key, type, options) : IsInteger2(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString3(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
|
|
1760
1882
|
}
|
|
1761
1883
|
function RecordPattern(record) {
|
|
1762
1884
|
return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
|
|
@@ -1836,7 +1958,7 @@ function FromTypes(args, types) {
|
|
|
1836
1958
|
return types.map((type) => FromType(args, type));
|
|
1837
1959
|
}
|
|
1838
1960
|
function FromType(args, type) {
|
|
1839
|
-
return IsConstructor(type) ? FromConstructor2(args, type) :
|
|
1961
|
+
return IsConstructor(type) ? FromConstructor2(args, type) : IsFunction3(type) ? FromFunction2(args, type) : IsIntersect(type) ? FromIntersect5(args, type) : IsUnion(type) ? FromUnion7(args, type) : IsTuple(type) ? FromTuple4(args, type) : IsArray3(type) ? FromArray5(args, type) : IsAsyncIterator3(type) ? FromAsyncIterator2(args, type) : IsIterator3(type) ? FromIterator2(args, type) : IsPromise2(type) ? FromPromise3(args, type) : IsObject3(type) ? FromObject2(args, type) : IsRecord(type) ? FromRecord2(args, type) : IsArgument(type) ? FromArgument(args, type) : type;
|
|
1840
1962
|
}
|
|
1841
1963
|
function Instantiate(type, args) {
|
|
1842
1964
|
return FromType(args, CloneType(type));
|
|
@@ -2064,7 +2186,7 @@ function PartialResolve(type) {
|
|
|
2064
2186
|
// Mappable
|
|
2065
2187
|
IsComputed(type) ? FromComputed3(type.target, type.parameters) : IsRef(type) ? FromRef3(type.$ref) : IsIntersect(type) ? Intersect(FromRest6(type.allOf)) : IsUnion(type) ? Union(FromRest6(type.anyOf)) : IsObject3(type) ? FromObject5(type, type.properties) : (
|
|
2066
2188
|
// Intrinsic
|
|
2067
|
-
|
|
2189
|
+
IsBigInt3(type) ? type : IsBoolean3(type) ? type : IsInteger2(type) ? type : IsLiteral(type) ? type : IsNull3(type) ? type : IsNumber3(type) ? type : IsString3(type) ? type : IsSymbol3(type) ? type : IsUndefined3(type) ? type : (
|
|
2068
2190
|
// Passthrough
|
|
2069
2191
|
Object2({})
|
|
2070
2192
|
)
|
|
@@ -2116,7 +2238,7 @@ function RequiredResolve(type) {
|
|
|
2116
2238
|
// Mappable
|
|
2117
2239
|
IsComputed(type) ? FromComputed4(type.target, type.parameters) : IsRef(type) ? FromRef4(type.$ref) : IsIntersect(type) ? Intersect(FromRest7(type.allOf)) : IsUnion(type) ? Union(FromRest7(type.anyOf)) : IsObject3(type) ? FromObject6(type, type.properties) : (
|
|
2118
2240
|
// Intrinsic
|
|
2119
|
-
|
|
2241
|
+
IsBigInt3(type) ? type : IsBoolean3(type) ? type : IsInteger2(type) ? type : IsLiteral(type) ? type : IsNull3(type) ? type : IsNumber3(type) ? type : IsString3(type) ? type : IsSymbol3(type) ? type : IsUndefined3(type) ? type : (
|
|
2120
2242
|
// Passthrough
|
|
2121
2243
|
Object2({})
|
|
2122
2244
|
)
|
|
@@ -2224,7 +2346,7 @@ function FromType2(moduleProperties, type) {
|
|
|
2224
2346
|
// Transform
|
|
2225
2347
|
IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
|
|
2226
2348
|
// Types
|
|
2227
|
-
IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) :
|
|
2349
|
+
IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator3(type) ? CreateType(FromAsyncIterator3(moduleProperties, type.items), type) : IsComputed(type) ? CreateType(FromComputed5(moduleProperties, type.target, type.parameters)) : IsConstructor(type) ? CreateType(FromConstructor3(moduleProperties, type.parameters, type.returns), type) : IsFunction3(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator3(type) ? CreateType(FromIterator3(moduleProperties, type.items), type) : IsObject3(type) ? CreateType(FromObject7(moduleProperties, type.properties), type) : IsRecord(type) ? CreateType(FromRecord3(moduleProperties, type)) : IsTuple(type) ? CreateType(FromTuple5(moduleProperties, type.items || []), type) : IsUnion(type) ? CreateType(FromUnion10(moduleProperties, type.anyOf), type) : type
|
|
2228
2350
|
)
|
|
2229
2351
|
)
|
|
2230
2352
|
);
|
|
@@ -2258,11 +2380,11 @@ var TModule = class {
|
|
|
2258
2380
|
function Module(properties) {
|
|
2259
2381
|
return new TModule(properties);
|
|
2260
2382
|
}
|
|
2261
|
-
function
|
|
2383
|
+
function Not2(type, options) {
|
|
2262
2384
|
return CreateType({ [Kind]: "Not", not: type }, options);
|
|
2263
2385
|
}
|
|
2264
2386
|
function Parameters(schema, options) {
|
|
2265
|
-
return
|
|
2387
|
+
return IsFunction3(schema) ? Tuple(schema.parameters, options) : Never();
|
|
2266
2388
|
}
|
|
2267
2389
|
var Ordinal = 0;
|
|
2268
2390
|
function Recursive(callback, options = {}) {
|
|
@@ -2283,7 +2405,7 @@ function Rest(T) {
|
|
|
2283
2405
|
return RestResolve(T);
|
|
2284
2406
|
}
|
|
2285
2407
|
function ReturnType(schema, options) {
|
|
2286
|
-
return
|
|
2408
|
+
return IsFunction3(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
2287
2409
|
}
|
|
2288
2410
|
var TransformDecodeBuilder = class {
|
|
2289
2411
|
constructor(schema) {
|
|
@@ -2321,14 +2443,14 @@ function Unsafe(options = {}) {
|
|
|
2321
2443
|
function Void(options) {
|
|
2322
2444
|
return CreateType({ [Kind]: "Void", type: "void" }, options);
|
|
2323
2445
|
}
|
|
2324
|
-
var
|
|
2325
|
-
__export(
|
|
2446
|
+
var type_exports3 = {};
|
|
2447
|
+
__export(type_exports3, {
|
|
2326
2448
|
Any: () => Any,
|
|
2327
2449
|
Argument: () => Argument,
|
|
2328
2450
|
Array: () => Array2,
|
|
2329
2451
|
AsyncIterator: () => AsyncIterator,
|
|
2330
2452
|
Awaited: () => Awaited,
|
|
2331
|
-
BigInt: () =>
|
|
2453
|
+
BigInt: () => BigInt2,
|
|
2332
2454
|
Boolean: () => Boolean2,
|
|
2333
2455
|
Capitalize: () => Capitalize,
|
|
2334
2456
|
Composite: () => Composite,
|
|
@@ -2353,7 +2475,7 @@ __export(type_exports2, {
|
|
|
2353
2475
|
Mapped: () => Mapped,
|
|
2354
2476
|
Module: () => Module,
|
|
2355
2477
|
Never: () => Never,
|
|
2356
|
-
Not: () =>
|
|
2478
|
+
Not: () => Not2,
|
|
2357
2479
|
Null: () => Null,
|
|
2358
2480
|
Number: () => Number2,
|
|
2359
2481
|
Object: () => Object2,
|
|
@@ -2386,171 +2508,1907 @@ __export(type_exports2, {
|
|
|
2386
2508
|
Uppercase: () => Uppercase,
|
|
2387
2509
|
Void: () => Void
|
|
2388
2510
|
});
|
|
2389
|
-
var Type =
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2511
|
+
var Type = type_exports3;
|
|
2512
|
+
function Evaluate(...args) {
|
|
2513
|
+
return new globalThis.Function(...args);
|
|
2514
|
+
}
|
|
2515
|
+
function DefaultErrorFunction(error2) {
|
|
2516
|
+
switch (error2.errorType) {
|
|
2517
|
+
case ValueErrorType.ArrayContains:
|
|
2518
|
+
return "Expected array to contain at least one matching value";
|
|
2519
|
+
case ValueErrorType.ArrayMaxContains:
|
|
2520
|
+
return `Expected array to contain no more than ${error2.schema.maxContains} matching values`;
|
|
2521
|
+
case ValueErrorType.ArrayMinContains:
|
|
2522
|
+
return `Expected array to contain at least ${error2.schema.minContains} matching values`;
|
|
2523
|
+
case ValueErrorType.ArrayMaxItems:
|
|
2524
|
+
return `Expected array length to be less or equal to ${error2.schema.maxItems}`;
|
|
2525
|
+
case ValueErrorType.ArrayMinItems:
|
|
2526
|
+
return `Expected array length to be greater or equal to ${error2.schema.minItems}`;
|
|
2527
|
+
case ValueErrorType.ArrayUniqueItems:
|
|
2528
|
+
return "Expected array elements to be unique";
|
|
2529
|
+
case ValueErrorType.Array:
|
|
2530
|
+
return "Expected array";
|
|
2531
|
+
case ValueErrorType.AsyncIterator:
|
|
2532
|
+
return "Expected AsyncIterator";
|
|
2533
|
+
case ValueErrorType.BigIntExclusiveMaximum:
|
|
2534
|
+
return `Expected bigint to be less than ${error2.schema.exclusiveMaximum}`;
|
|
2535
|
+
case ValueErrorType.BigIntExclusiveMinimum:
|
|
2536
|
+
return `Expected bigint to be greater than ${error2.schema.exclusiveMinimum}`;
|
|
2537
|
+
case ValueErrorType.BigIntMaximum:
|
|
2538
|
+
return `Expected bigint to be less or equal to ${error2.schema.maximum}`;
|
|
2539
|
+
case ValueErrorType.BigIntMinimum:
|
|
2540
|
+
return `Expected bigint to be greater or equal to ${error2.schema.minimum}`;
|
|
2541
|
+
case ValueErrorType.BigIntMultipleOf:
|
|
2542
|
+
return `Expected bigint to be a multiple of ${error2.schema.multipleOf}`;
|
|
2543
|
+
case ValueErrorType.BigInt:
|
|
2544
|
+
return "Expected bigint";
|
|
2545
|
+
case ValueErrorType.Boolean:
|
|
2546
|
+
return "Expected boolean";
|
|
2547
|
+
case ValueErrorType.DateExclusiveMinimumTimestamp:
|
|
2548
|
+
return `Expected Date timestamp to be greater than ${error2.schema.exclusiveMinimumTimestamp}`;
|
|
2549
|
+
case ValueErrorType.DateExclusiveMaximumTimestamp:
|
|
2550
|
+
return `Expected Date timestamp to be less than ${error2.schema.exclusiveMaximumTimestamp}`;
|
|
2551
|
+
case ValueErrorType.DateMinimumTimestamp:
|
|
2552
|
+
return `Expected Date timestamp to be greater or equal to ${error2.schema.minimumTimestamp}`;
|
|
2553
|
+
case ValueErrorType.DateMaximumTimestamp:
|
|
2554
|
+
return `Expected Date timestamp to be less or equal to ${error2.schema.maximumTimestamp}`;
|
|
2555
|
+
case ValueErrorType.DateMultipleOfTimestamp:
|
|
2556
|
+
return `Expected Date timestamp to be a multiple of ${error2.schema.multipleOfTimestamp}`;
|
|
2557
|
+
case ValueErrorType.Date:
|
|
2558
|
+
return "Expected Date";
|
|
2559
|
+
case ValueErrorType.Function:
|
|
2560
|
+
return "Expected function";
|
|
2561
|
+
case ValueErrorType.IntegerExclusiveMaximum:
|
|
2562
|
+
return `Expected integer to be less than ${error2.schema.exclusiveMaximum}`;
|
|
2563
|
+
case ValueErrorType.IntegerExclusiveMinimum:
|
|
2564
|
+
return `Expected integer to be greater than ${error2.schema.exclusiveMinimum}`;
|
|
2565
|
+
case ValueErrorType.IntegerMaximum:
|
|
2566
|
+
return `Expected integer to be less or equal to ${error2.schema.maximum}`;
|
|
2567
|
+
case ValueErrorType.IntegerMinimum:
|
|
2568
|
+
return `Expected integer to be greater or equal to ${error2.schema.minimum}`;
|
|
2569
|
+
case ValueErrorType.IntegerMultipleOf:
|
|
2570
|
+
return `Expected integer to be a multiple of ${error2.schema.multipleOf}`;
|
|
2571
|
+
case ValueErrorType.Integer:
|
|
2572
|
+
return "Expected integer";
|
|
2573
|
+
case ValueErrorType.IntersectUnevaluatedProperties:
|
|
2574
|
+
return "Unexpected property";
|
|
2575
|
+
case ValueErrorType.Intersect:
|
|
2576
|
+
return "Expected all values to match";
|
|
2577
|
+
case ValueErrorType.Iterator:
|
|
2578
|
+
return "Expected Iterator";
|
|
2579
|
+
case ValueErrorType.Literal:
|
|
2580
|
+
return `Expected ${typeof error2.schema.const === "string" ? `'${error2.schema.const}'` : error2.schema.const}`;
|
|
2581
|
+
case ValueErrorType.Never:
|
|
2582
|
+
return "Never";
|
|
2583
|
+
case ValueErrorType.Not:
|
|
2584
|
+
return "Value should not match";
|
|
2585
|
+
case ValueErrorType.Null:
|
|
2586
|
+
return "Expected null";
|
|
2587
|
+
case ValueErrorType.NumberExclusiveMaximum:
|
|
2588
|
+
return `Expected number to be less than ${error2.schema.exclusiveMaximum}`;
|
|
2589
|
+
case ValueErrorType.NumberExclusiveMinimum:
|
|
2590
|
+
return `Expected number to be greater than ${error2.schema.exclusiveMinimum}`;
|
|
2591
|
+
case ValueErrorType.NumberMaximum:
|
|
2592
|
+
return `Expected number to be less or equal to ${error2.schema.maximum}`;
|
|
2593
|
+
case ValueErrorType.NumberMinimum:
|
|
2594
|
+
return `Expected number to be greater or equal to ${error2.schema.minimum}`;
|
|
2595
|
+
case ValueErrorType.NumberMultipleOf:
|
|
2596
|
+
return `Expected number to be a multiple of ${error2.schema.multipleOf}`;
|
|
2597
|
+
case ValueErrorType.Number:
|
|
2598
|
+
return "Expected number";
|
|
2599
|
+
case ValueErrorType.Object:
|
|
2600
|
+
return "Expected object";
|
|
2601
|
+
case ValueErrorType.ObjectAdditionalProperties:
|
|
2602
|
+
return "Unexpected property";
|
|
2603
|
+
case ValueErrorType.ObjectMaxProperties:
|
|
2604
|
+
return `Expected object to have no more than ${error2.schema.maxProperties} properties`;
|
|
2605
|
+
case ValueErrorType.ObjectMinProperties:
|
|
2606
|
+
return `Expected object to have at least ${error2.schema.minProperties} properties`;
|
|
2607
|
+
case ValueErrorType.ObjectRequiredProperty:
|
|
2608
|
+
return "Expected required property";
|
|
2609
|
+
case ValueErrorType.Promise:
|
|
2610
|
+
return "Expected Promise";
|
|
2611
|
+
case ValueErrorType.RegExp:
|
|
2612
|
+
return "Expected string to match regular expression";
|
|
2613
|
+
case ValueErrorType.StringFormatUnknown:
|
|
2614
|
+
return `Unknown format '${error2.schema.format}'`;
|
|
2615
|
+
case ValueErrorType.StringFormat:
|
|
2616
|
+
return `Expected string to match '${error2.schema.format}' format`;
|
|
2617
|
+
case ValueErrorType.StringMaxLength:
|
|
2618
|
+
return `Expected string length less or equal to ${error2.schema.maxLength}`;
|
|
2619
|
+
case ValueErrorType.StringMinLength:
|
|
2620
|
+
return `Expected string length greater or equal to ${error2.schema.minLength}`;
|
|
2621
|
+
case ValueErrorType.StringPattern:
|
|
2622
|
+
return `Expected string to match '${error2.schema.pattern}'`;
|
|
2623
|
+
case ValueErrorType.String:
|
|
2624
|
+
return "Expected string";
|
|
2625
|
+
case ValueErrorType.Symbol:
|
|
2626
|
+
return "Expected symbol";
|
|
2627
|
+
case ValueErrorType.TupleLength:
|
|
2628
|
+
return `Expected tuple to have ${error2.schema.maxItems || 0} elements`;
|
|
2629
|
+
case ValueErrorType.Tuple:
|
|
2630
|
+
return "Expected tuple";
|
|
2631
|
+
case ValueErrorType.Uint8ArrayMaxByteLength:
|
|
2632
|
+
return `Expected byte length less or equal to ${error2.schema.maxByteLength}`;
|
|
2633
|
+
case ValueErrorType.Uint8ArrayMinByteLength:
|
|
2634
|
+
return `Expected byte length greater or equal to ${error2.schema.minByteLength}`;
|
|
2635
|
+
case ValueErrorType.Uint8Array:
|
|
2636
|
+
return "Expected Uint8Array";
|
|
2637
|
+
case ValueErrorType.Undefined:
|
|
2638
|
+
return "Expected undefined";
|
|
2639
|
+
case ValueErrorType.Union:
|
|
2640
|
+
return "Expected union value";
|
|
2641
|
+
case ValueErrorType.Void:
|
|
2642
|
+
return "Expected void";
|
|
2643
|
+
case ValueErrorType.Kind:
|
|
2644
|
+
return `Expected kind '${error2.schema[Kind]}'`;
|
|
2645
|
+
default:
|
|
2646
|
+
return "Unknown error type";
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
var errorFunction = DefaultErrorFunction;
|
|
2650
|
+
function GetErrorFunction() {
|
|
2651
|
+
return errorFunction;
|
|
2652
|
+
}
|
|
2653
|
+
var TypeDereferenceError = class extends TypeBoxError {
|
|
2654
|
+
constructor(schema) {
|
|
2655
|
+
super(`Unable to dereference schema with $id '${schema.$ref}'`);
|
|
2656
|
+
this.schema = schema;
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
function Resolve(schema, references) {
|
|
2660
|
+
const target = references.find((target2) => target2.$id === schema.$ref);
|
|
2661
|
+
if (target === void 0)
|
|
2662
|
+
throw new TypeDereferenceError(schema);
|
|
2663
|
+
return Deref(target, references);
|
|
2664
|
+
}
|
|
2665
|
+
function Pushref(schema, references) {
|
|
2666
|
+
if (!IsString2(schema.$id) || references.some((target) => target.$id === schema.$id))
|
|
2667
|
+
return references;
|
|
2668
|
+
references.push(schema);
|
|
2669
|
+
return references;
|
|
2670
|
+
}
|
|
2671
|
+
function Deref(schema, references) {
|
|
2672
|
+
return schema[Kind] === "This" || schema[Kind] === "Ref" ? Resolve(schema, references) : schema;
|
|
2673
|
+
}
|
|
2674
|
+
var ValueHashError = class extends TypeBoxError {
|
|
2675
|
+
constructor(value) {
|
|
2676
|
+
super(`Unable to hash value`);
|
|
2677
|
+
this.value = value;
|
|
2678
|
+
}
|
|
2679
|
+
};
|
|
2680
|
+
var ByteMarker;
|
|
2681
|
+
(function(ByteMarker2) {
|
|
2682
|
+
ByteMarker2[ByteMarker2["Undefined"] = 0] = "Undefined";
|
|
2683
|
+
ByteMarker2[ByteMarker2["Null"] = 1] = "Null";
|
|
2684
|
+
ByteMarker2[ByteMarker2["Boolean"] = 2] = "Boolean";
|
|
2685
|
+
ByteMarker2[ByteMarker2["Number"] = 3] = "Number";
|
|
2686
|
+
ByteMarker2[ByteMarker2["String"] = 4] = "String";
|
|
2687
|
+
ByteMarker2[ByteMarker2["Object"] = 5] = "Object";
|
|
2688
|
+
ByteMarker2[ByteMarker2["Array"] = 6] = "Array";
|
|
2689
|
+
ByteMarker2[ByteMarker2["Date"] = 7] = "Date";
|
|
2690
|
+
ByteMarker2[ByteMarker2["Uint8Array"] = 8] = "Uint8Array";
|
|
2691
|
+
ByteMarker2[ByteMarker2["Symbol"] = 9] = "Symbol";
|
|
2692
|
+
ByteMarker2[ByteMarker2["BigInt"] = 10] = "BigInt";
|
|
2693
|
+
})(ByteMarker || (ByteMarker = {}));
|
|
2694
|
+
var Accumulator = BigInt("14695981039346656037");
|
|
2695
|
+
var [Prime, Size] = [BigInt("1099511628211"), BigInt(
|
|
2696
|
+
"18446744073709551616"
|
|
2697
|
+
/* 2 ^ 64 */
|
|
2698
|
+
)];
|
|
2699
|
+
var Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));
|
|
2700
|
+
var F64 = new Float64Array(1);
|
|
2701
|
+
var F64In = new DataView(F64.buffer);
|
|
2702
|
+
var F64Out = new Uint8Array(F64.buffer);
|
|
2703
|
+
function* NumberToBytes(value) {
|
|
2704
|
+
const byteCount = value === 0 ? 1 : Math.ceil(Math.floor(Math.log2(value) + 1) / 8);
|
|
2705
|
+
for (let i = 0; i < byteCount; i++) {
|
|
2706
|
+
yield value >> 8 * (byteCount - 1 - i) & 255;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
function ArrayType2(value) {
|
|
2710
|
+
FNV1A64(ByteMarker.Array);
|
|
2711
|
+
for (const item of value) {
|
|
2712
|
+
Visit4(item);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
function BooleanType(value) {
|
|
2716
|
+
FNV1A64(ByteMarker.Boolean);
|
|
2717
|
+
FNV1A64(value ? 1 : 0);
|
|
2718
|
+
}
|
|
2719
|
+
function BigIntType(value) {
|
|
2720
|
+
FNV1A64(ByteMarker.BigInt);
|
|
2721
|
+
F64In.setBigInt64(0, value);
|
|
2722
|
+
for (const byte of F64Out) {
|
|
2723
|
+
FNV1A64(byte);
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
function DateType2(value) {
|
|
2727
|
+
FNV1A64(ByteMarker.Date);
|
|
2728
|
+
Visit4(value.getTime());
|
|
2729
|
+
}
|
|
2730
|
+
function NullType(value) {
|
|
2731
|
+
FNV1A64(ByteMarker.Null);
|
|
2732
|
+
}
|
|
2733
|
+
function NumberType(value) {
|
|
2734
|
+
FNV1A64(ByteMarker.Number);
|
|
2735
|
+
F64In.setFloat64(0, value);
|
|
2736
|
+
for (const byte of F64Out) {
|
|
2737
|
+
FNV1A64(byte);
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
function ObjectType2(value) {
|
|
2741
|
+
FNV1A64(ByteMarker.Object);
|
|
2742
|
+
for (const key of globalThis.Object.getOwnPropertyNames(value).sort()) {
|
|
2743
|
+
Visit4(key);
|
|
2744
|
+
Visit4(value[key]);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
function StringType(value) {
|
|
2748
|
+
FNV1A64(ByteMarker.String);
|
|
2749
|
+
for (let i = 0; i < value.length; i++) {
|
|
2750
|
+
for (const byte of NumberToBytes(value.charCodeAt(i))) {
|
|
2751
|
+
FNV1A64(byte);
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
function SymbolType(value) {
|
|
2756
|
+
FNV1A64(ByteMarker.Symbol);
|
|
2757
|
+
Visit4(value.description);
|
|
2758
|
+
}
|
|
2759
|
+
function Uint8ArrayType2(value) {
|
|
2760
|
+
FNV1A64(ByteMarker.Uint8Array);
|
|
2761
|
+
for (let i = 0; i < value.length; i++) {
|
|
2762
|
+
FNV1A64(value[i]);
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
function UndefinedType(value) {
|
|
2766
|
+
return FNV1A64(ByteMarker.Undefined);
|
|
2767
|
+
}
|
|
2768
|
+
function Visit4(value) {
|
|
2769
|
+
if (IsArray2(value))
|
|
2770
|
+
return ArrayType2(value);
|
|
2771
|
+
if (IsBoolean2(value))
|
|
2772
|
+
return BooleanType(value);
|
|
2773
|
+
if (IsBigInt2(value))
|
|
2774
|
+
return BigIntType(value);
|
|
2775
|
+
if (IsDate2(value))
|
|
2776
|
+
return DateType2(value);
|
|
2777
|
+
if (IsNull2(value))
|
|
2778
|
+
return NullType(value);
|
|
2779
|
+
if (IsNumber2(value))
|
|
2780
|
+
return NumberType(value);
|
|
2781
|
+
if (IsObject2(value))
|
|
2782
|
+
return ObjectType2(value);
|
|
2783
|
+
if (IsString2(value))
|
|
2784
|
+
return StringType(value);
|
|
2785
|
+
if (IsSymbol2(value))
|
|
2786
|
+
return SymbolType(value);
|
|
2787
|
+
if (IsUint8Array2(value))
|
|
2788
|
+
return Uint8ArrayType2(value);
|
|
2789
|
+
if (IsUndefined2(value))
|
|
2790
|
+
return UndefinedType(value);
|
|
2791
|
+
throw new ValueHashError(value);
|
|
2792
|
+
}
|
|
2793
|
+
function FNV1A64(byte) {
|
|
2794
|
+
Accumulator = Accumulator ^ Bytes[byte];
|
|
2795
|
+
Accumulator = Accumulator * Prime % Size;
|
|
2796
|
+
}
|
|
2797
|
+
function Hash(value) {
|
|
2798
|
+
Accumulator = BigInt("14695981039346656037");
|
|
2799
|
+
Visit4(value);
|
|
2800
|
+
return Accumulator;
|
|
2801
|
+
}
|
|
2802
|
+
var ValueCheckUnknownTypeError = class extends TypeBoxError {
|
|
2803
|
+
constructor(schema) {
|
|
2804
|
+
super(`Unknown type`);
|
|
2805
|
+
this.schema = schema;
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
function IsAnyOrUnknown(schema) {
|
|
2809
|
+
return schema[Kind] === "Any" || schema[Kind] === "Unknown";
|
|
2810
|
+
}
|
|
2811
|
+
function IsDefined(value) {
|
|
2812
|
+
return value !== void 0;
|
|
2813
|
+
}
|
|
2814
|
+
function FromAny2(schema, references, value) {
|
|
2815
|
+
return true;
|
|
2816
|
+
}
|
|
2817
|
+
function FromArgument2(schema, references, value) {
|
|
2818
|
+
return true;
|
|
2819
|
+
}
|
|
2820
|
+
function FromArray7(schema, references, value) {
|
|
2821
|
+
if (!IsArray2(value))
|
|
2822
|
+
return false;
|
|
2823
|
+
if (IsDefined(schema.minItems) && !(value.length >= schema.minItems)) {
|
|
2824
|
+
return false;
|
|
2825
|
+
}
|
|
2826
|
+
if (IsDefined(schema.maxItems) && !(value.length <= schema.maxItems)) {
|
|
2827
|
+
return false;
|
|
2828
|
+
}
|
|
2829
|
+
for (const element of value) {
|
|
2830
|
+
if (!Visit5(schema.items, references, element))
|
|
2831
|
+
return false;
|
|
2832
|
+
}
|
|
2833
|
+
if (schema.uniqueItems === true && !(function() {
|
|
2834
|
+
const set = /* @__PURE__ */ new Set();
|
|
2835
|
+
for (const element of value) {
|
|
2836
|
+
const hashed = Hash(element);
|
|
2837
|
+
if (set.has(hashed)) {
|
|
2838
|
+
return false;
|
|
2839
|
+
} else {
|
|
2840
|
+
set.add(hashed);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
return true;
|
|
2844
|
+
})()) {
|
|
2845
|
+
return false;
|
|
2846
|
+
}
|
|
2847
|
+
if (!(IsDefined(schema.contains) || IsNumber2(schema.minContains) || IsNumber2(schema.maxContains))) {
|
|
2848
|
+
return true;
|
|
2849
|
+
}
|
|
2850
|
+
const containsSchema = IsDefined(schema.contains) ? schema.contains : Never();
|
|
2851
|
+
const containsCount = value.reduce((acc, value2) => Visit5(containsSchema, references, value2) ? acc + 1 : acc, 0);
|
|
2852
|
+
if (containsCount === 0) {
|
|
2853
|
+
return false;
|
|
2854
|
+
}
|
|
2855
|
+
if (IsNumber2(schema.minContains) && containsCount < schema.minContains) {
|
|
2856
|
+
return false;
|
|
2857
|
+
}
|
|
2858
|
+
if (IsNumber2(schema.maxContains) && containsCount > schema.maxContains) {
|
|
2859
|
+
return false;
|
|
2860
|
+
}
|
|
2861
|
+
return true;
|
|
2862
|
+
}
|
|
2863
|
+
function FromAsyncIterator4(schema, references, value) {
|
|
2864
|
+
return IsAsyncIterator2(value);
|
|
2865
|
+
}
|
|
2866
|
+
function FromBigInt2(schema, references, value) {
|
|
2867
|
+
if (!IsBigInt2(value))
|
|
2868
|
+
return false;
|
|
2869
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
2870
|
+
return false;
|
|
2871
|
+
}
|
|
2872
|
+
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
2873
|
+
return false;
|
|
2874
|
+
}
|
|
2875
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
2876
|
+
return false;
|
|
2877
|
+
}
|
|
2878
|
+
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
2879
|
+
return false;
|
|
2880
|
+
}
|
|
2881
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) {
|
|
2882
|
+
return false;
|
|
2883
|
+
}
|
|
2884
|
+
return true;
|
|
2885
|
+
}
|
|
2886
|
+
function FromBoolean2(schema, references, value) {
|
|
2887
|
+
return IsBoolean2(value);
|
|
2888
|
+
}
|
|
2889
|
+
function FromConstructor4(schema, references, value) {
|
|
2890
|
+
return Visit5(schema.returns, references, value.prototype);
|
|
2891
|
+
}
|
|
2892
|
+
function FromDate2(schema, references, value) {
|
|
2893
|
+
if (!IsDate2(value))
|
|
2894
|
+
return false;
|
|
2895
|
+
if (IsDefined(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
|
|
2896
|
+
return false;
|
|
2897
|
+
}
|
|
2898
|
+
if (IsDefined(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) {
|
|
2899
|
+
return false;
|
|
2900
|
+
}
|
|
2901
|
+
if (IsDefined(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) {
|
|
2902
|
+
return false;
|
|
2903
|
+
}
|
|
2904
|
+
if (IsDefined(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) {
|
|
2905
|
+
return false;
|
|
2906
|
+
}
|
|
2907
|
+
if (IsDefined(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) {
|
|
2908
|
+
return false;
|
|
2909
|
+
}
|
|
2910
|
+
return true;
|
|
2911
|
+
}
|
|
2912
|
+
function FromFunction4(schema, references, value) {
|
|
2913
|
+
return IsFunction2(value);
|
|
2914
|
+
}
|
|
2915
|
+
function FromImport(schema, references, value) {
|
|
2916
|
+
const definitions = globalThis.Object.values(schema.$defs);
|
|
2917
|
+
const target = schema.$defs[schema.$ref];
|
|
2918
|
+
return Visit5(target, [...references, ...definitions], value);
|
|
2919
|
+
}
|
|
2920
|
+
function FromInteger2(schema, references, value) {
|
|
2921
|
+
if (!IsInteger(value)) {
|
|
2922
|
+
return false;
|
|
2923
|
+
}
|
|
2924
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2927
|
+
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
2928
|
+
return false;
|
|
2929
|
+
}
|
|
2930
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
2931
|
+
return false;
|
|
2932
|
+
}
|
|
2933
|
+
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
2934
|
+
return false;
|
|
2935
|
+
}
|
|
2936
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
2937
|
+
return false;
|
|
2938
|
+
}
|
|
2939
|
+
return true;
|
|
2940
|
+
}
|
|
2941
|
+
function FromIntersect9(schema, references, value) {
|
|
2942
|
+
const check1 = schema.allOf.every((schema2) => Visit5(schema2, references, value));
|
|
2943
|
+
if (schema.unevaluatedProperties === false) {
|
|
2944
|
+
const keyPattern = new RegExp(KeyOfPattern(schema));
|
|
2945
|
+
const check2 = Object.getOwnPropertyNames(value).every((key) => keyPattern.test(key));
|
|
2946
|
+
return check1 && check2;
|
|
2947
|
+
} else if (IsSchema(schema.unevaluatedProperties)) {
|
|
2948
|
+
const keyCheck = new RegExp(KeyOfPattern(schema));
|
|
2949
|
+
const check2 = Object.getOwnPropertyNames(value).every((key) => keyCheck.test(key) || Visit5(schema.unevaluatedProperties, references, value[key]));
|
|
2950
|
+
return check1 && check2;
|
|
2951
|
+
} else {
|
|
2952
|
+
return check1;
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
function FromIterator4(schema, references, value) {
|
|
2956
|
+
return IsIterator2(value);
|
|
2957
|
+
}
|
|
2958
|
+
function FromLiteral3(schema, references, value) {
|
|
2959
|
+
return value === schema.const;
|
|
2960
|
+
}
|
|
2961
|
+
function FromNever2(schema, references, value) {
|
|
2962
|
+
return false;
|
|
2963
|
+
}
|
|
2964
|
+
function FromNot2(schema, references, value) {
|
|
2965
|
+
return !Visit5(schema.not, references, value);
|
|
2966
|
+
}
|
|
2967
|
+
function FromNull2(schema, references, value) {
|
|
2968
|
+
return IsNull2(value);
|
|
2969
|
+
}
|
|
2970
|
+
function FromNumber2(schema, references, value) {
|
|
2971
|
+
if (!TypeSystemPolicy.IsNumberLike(value))
|
|
2972
|
+
return false;
|
|
2973
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
2974
|
+
return false;
|
|
2975
|
+
}
|
|
2976
|
+
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
2977
|
+
return false;
|
|
2978
|
+
}
|
|
2979
|
+
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
2980
|
+
return false;
|
|
2981
|
+
}
|
|
2982
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
2983
|
+
return false;
|
|
2984
|
+
}
|
|
2985
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
2986
|
+
return false;
|
|
2987
|
+
}
|
|
2988
|
+
return true;
|
|
2989
|
+
}
|
|
2990
|
+
function FromObject8(schema, references, value) {
|
|
2991
|
+
if (!TypeSystemPolicy.IsObjectLike(value))
|
|
2992
|
+
return false;
|
|
2993
|
+
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
2994
|
+
return false;
|
|
2995
|
+
}
|
|
2996
|
+
if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
2997
|
+
return false;
|
|
2998
|
+
}
|
|
2999
|
+
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
3000
|
+
for (const knownKey of knownKeys) {
|
|
3001
|
+
const property = schema.properties[knownKey];
|
|
3002
|
+
if (schema.required && schema.required.includes(knownKey)) {
|
|
3003
|
+
if (!Visit5(property, references, value[knownKey])) {
|
|
3004
|
+
return false;
|
|
3005
|
+
}
|
|
3006
|
+
if ((ExtendsUndefinedCheck(property) || IsAnyOrUnknown(property)) && !(knownKey in value)) {
|
|
3007
|
+
return false;
|
|
3008
|
+
}
|
|
3009
|
+
} else {
|
|
3010
|
+
if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey) && !Visit5(property, references, value[knownKey])) {
|
|
3011
|
+
return false;
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
if (schema.additionalProperties === false) {
|
|
3016
|
+
const valueKeys = Object.getOwnPropertyNames(value);
|
|
3017
|
+
if (schema.required && schema.required.length === knownKeys.length && valueKeys.length === knownKeys.length) {
|
|
3018
|
+
return true;
|
|
3019
|
+
} else {
|
|
3020
|
+
return valueKeys.every((valueKey) => knownKeys.includes(valueKey));
|
|
3021
|
+
}
|
|
3022
|
+
} else if (typeof schema.additionalProperties === "object") {
|
|
3023
|
+
const valueKeys = Object.getOwnPropertyNames(value);
|
|
3024
|
+
return valueKeys.every((key) => knownKeys.includes(key) || Visit5(schema.additionalProperties, references, value[key]));
|
|
3025
|
+
} else {
|
|
3026
|
+
return true;
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
function FromPromise4(schema, references, value) {
|
|
3030
|
+
return IsPromise(value);
|
|
3031
|
+
}
|
|
3032
|
+
function FromRecord4(schema, references, value) {
|
|
3033
|
+
if (!TypeSystemPolicy.IsRecordLike(value)) {
|
|
3034
|
+
return false;
|
|
3035
|
+
}
|
|
3036
|
+
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
3037
|
+
return false;
|
|
3038
|
+
}
|
|
3039
|
+
if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
3040
|
+
return false;
|
|
3041
|
+
}
|
|
3042
|
+
const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
|
|
3043
|
+
const regex = new RegExp(patternKey);
|
|
3044
|
+
const check1 = Object.entries(value).every(([key, value2]) => {
|
|
3045
|
+
return regex.test(key) ? Visit5(patternSchema, references, value2) : true;
|
|
3046
|
+
});
|
|
3047
|
+
const check2 = typeof schema.additionalProperties === "object" ? Object.entries(value).every(([key, value2]) => {
|
|
3048
|
+
return !regex.test(key) ? Visit5(schema.additionalProperties, references, value2) : true;
|
|
3049
|
+
}) : true;
|
|
3050
|
+
const check3 = schema.additionalProperties === false ? Object.getOwnPropertyNames(value).every((key) => {
|
|
3051
|
+
return regex.test(key);
|
|
3052
|
+
}) : true;
|
|
3053
|
+
return check1 && check2 && check3;
|
|
3054
|
+
}
|
|
3055
|
+
function FromRef5(schema, references, value) {
|
|
3056
|
+
return Visit5(Deref(schema, references), references, value);
|
|
3057
|
+
}
|
|
3058
|
+
function FromRegExp2(schema, references, value) {
|
|
3059
|
+
const regex = new RegExp(schema.source, schema.flags);
|
|
3060
|
+
if (IsDefined(schema.minLength)) {
|
|
3061
|
+
if (!(value.length >= schema.minLength))
|
|
3062
|
+
return false;
|
|
3063
|
+
}
|
|
3064
|
+
if (IsDefined(schema.maxLength)) {
|
|
3065
|
+
if (!(value.length <= schema.maxLength))
|
|
3066
|
+
return false;
|
|
3067
|
+
}
|
|
3068
|
+
return regex.test(value);
|
|
3069
|
+
}
|
|
3070
|
+
function FromString2(schema, references, value) {
|
|
3071
|
+
if (!IsString2(value)) {
|
|
3072
|
+
return false;
|
|
3073
|
+
}
|
|
3074
|
+
if (IsDefined(schema.minLength)) {
|
|
3075
|
+
if (!(value.length >= schema.minLength))
|
|
3076
|
+
return false;
|
|
3077
|
+
}
|
|
3078
|
+
if (IsDefined(schema.maxLength)) {
|
|
3079
|
+
if (!(value.length <= schema.maxLength))
|
|
3080
|
+
return false;
|
|
3081
|
+
}
|
|
3082
|
+
if (IsDefined(schema.pattern)) {
|
|
3083
|
+
const regex = new RegExp(schema.pattern);
|
|
3084
|
+
if (!regex.test(value))
|
|
3085
|
+
return false;
|
|
3086
|
+
}
|
|
3087
|
+
if (IsDefined(schema.format)) {
|
|
3088
|
+
if (!format_exports.Has(schema.format))
|
|
3089
|
+
return false;
|
|
3090
|
+
const func = format_exports.Get(schema.format);
|
|
3091
|
+
return func(value);
|
|
3092
|
+
}
|
|
3093
|
+
return true;
|
|
3094
|
+
}
|
|
3095
|
+
function FromSymbol2(schema, references, value) {
|
|
3096
|
+
return IsSymbol2(value);
|
|
3097
|
+
}
|
|
3098
|
+
function FromTemplateLiteral4(schema, references, value) {
|
|
3099
|
+
return IsString2(value) && new RegExp(schema.pattern).test(value);
|
|
3100
|
+
}
|
|
3101
|
+
function FromThis(schema, references, value) {
|
|
3102
|
+
return Visit5(Deref(schema, references), references, value);
|
|
3103
|
+
}
|
|
3104
|
+
function FromTuple6(schema, references, value) {
|
|
3105
|
+
if (!IsArray2(value)) {
|
|
3106
|
+
return false;
|
|
3107
|
+
}
|
|
3108
|
+
if (schema.items === void 0 && !(value.length === 0)) {
|
|
3109
|
+
return false;
|
|
3110
|
+
}
|
|
3111
|
+
if (!(value.length === schema.maxItems)) {
|
|
3112
|
+
return false;
|
|
3113
|
+
}
|
|
3114
|
+
if (!schema.items) {
|
|
3115
|
+
return true;
|
|
3116
|
+
}
|
|
3117
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
3118
|
+
if (!Visit5(schema.items[i], references, value[i]))
|
|
3119
|
+
return false;
|
|
3120
|
+
}
|
|
3121
|
+
return true;
|
|
3122
|
+
}
|
|
3123
|
+
function FromUndefined2(schema, references, value) {
|
|
3124
|
+
return IsUndefined2(value);
|
|
3125
|
+
}
|
|
3126
|
+
function FromUnion11(schema, references, value) {
|
|
3127
|
+
return schema.anyOf.some((inner) => Visit5(inner, references, value));
|
|
3128
|
+
}
|
|
3129
|
+
function FromUint8Array2(schema, references, value) {
|
|
3130
|
+
if (!IsUint8Array2(value)) {
|
|
3131
|
+
return false;
|
|
3132
|
+
}
|
|
3133
|
+
if (IsDefined(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
|
|
3134
|
+
return false;
|
|
3135
|
+
}
|
|
3136
|
+
if (IsDefined(schema.minByteLength) && !(value.length >= schema.minByteLength)) {
|
|
3137
|
+
return false;
|
|
3138
|
+
}
|
|
3139
|
+
return true;
|
|
3140
|
+
}
|
|
3141
|
+
function FromUnknown2(schema, references, value) {
|
|
3142
|
+
return true;
|
|
3143
|
+
}
|
|
3144
|
+
function FromVoid2(schema, references, value) {
|
|
3145
|
+
return TypeSystemPolicy.IsVoidLike(value);
|
|
3146
|
+
}
|
|
3147
|
+
function FromKind(schema, references, value) {
|
|
3148
|
+
if (!type_exports2.Has(schema[Kind]))
|
|
3149
|
+
return false;
|
|
3150
|
+
const func = type_exports2.Get(schema[Kind]);
|
|
3151
|
+
return func(schema, value);
|
|
3152
|
+
}
|
|
3153
|
+
function Visit5(schema, references, value) {
|
|
3154
|
+
const references_ = IsDefined(schema.$id) ? Pushref(schema, references) : references;
|
|
3155
|
+
const schema_ = schema;
|
|
3156
|
+
switch (schema_[Kind]) {
|
|
3157
|
+
case "Any":
|
|
3158
|
+
return FromAny2(schema_, references_, value);
|
|
3159
|
+
case "Argument":
|
|
3160
|
+
return FromArgument2(schema_, references_, value);
|
|
3161
|
+
case "Array":
|
|
3162
|
+
return FromArray7(schema_, references_, value);
|
|
3163
|
+
case "AsyncIterator":
|
|
3164
|
+
return FromAsyncIterator4(schema_, references_, value);
|
|
3165
|
+
case "BigInt":
|
|
3166
|
+
return FromBigInt2(schema_, references_, value);
|
|
3167
|
+
case "Boolean":
|
|
3168
|
+
return FromBoolean2(schema_, references_, value);
|
|
3169
|
+
case "Constructor":
|
|
3170
|
+
return FromConstructor4(schema_, references_, value);
|
|
3171
|
+
case "Date":
|
|
3172
|
+
return FromDate2(schema_, references_, value);
|
|
3173
|
+
case "Function":
|
|
3174
|
+
return FromFunction4(schema_, references_, value);
|
|
3175
|
+
case "Import":
|
|
3176
|
+
return FromImport(schema_, references_, value);
|
|
3177
|
+
case "Integer":
|
|
3178
|
+
return FromInteger2(schema_, references_, value);
|
|
3179
|
+
case "Intersect":
|
|
3180
|
+
return FromIntersect9(schema_, references_, value);
|
|
3181
|
+
case "Iterator":
|
|
3182
|
+
return FromIterator4(schema_, references_, value);
|
|
3183
|
+
case "Literal":
|
|
3184
|
+
return FromLiteral3(schema_, references_, value);
|
|
3185
|
+
case "Never":
|
|
3186
|
+
return FromNever2(schema_, references_, value);
|
|
3187
|
+
case "Not":
|
|
3188
|
+
return FromNot2(schema_, references_, value);
|
|
3189
|
+
case "Null":
|
|
3190
|
+
return FromNull2(schema_, references_, value);
|
|
3191
|
+
case "Number":
|
|
3192
|
+
return FromNumber2(schema_, references_, value);
|
|
3193
|
+
case "Object":
|
|
3194
|
+
return FromObject8(schema_, references_, value);
|
|
3195
|
+
case "Promise":
|
|
3196
|
+
return FromPromise4(schema_, references_, value);
|
|
3197
|
+
case "Record":
|
|
3198
|
+
return FromRecord4(schema_, references_, value);
|
|
3199
|
+
case "Ref":
|
|
3200
|
+
return FromRef5(schema_, references_, value);
|
|
3201
|
+
case "RegExp":
|
|
3202
|
+
return FromRegExp2(schema_, references_, value);
|
|
3203
|
+
case "String":
|
|
3204
|
+
return FromString2(schema_, references_, value);
|
|
3205
|
+
case "Symbol":
|
|
3206
|
+
return FromSymbol2(schema_, references_, value);
|
|
3207
|
+
case "TemplateLiteral":
|
|
3208
|
+
return FromTemplateLiteral4(schema_, references_, value);
|
|
3209
|
+
case "This":
|
|
3210
|
+
return FromThis(schema_, references_, value);
|
|
3211
|
+
case "Tuple":
|
|
3212
|
+
return FromTuple6(schema_, references_, value);
|
|
3213
|
+
case "Undefined":
|
|
3214
|
+
return FromUndefined2(schema_, references_, value);
|
|
3215
|
+
case "Union":
|
|
3216
|
+
return FromUnion11(schema_, references_, value);
|
|
3217
|
+
case "Uint8Array":
|
|
3218
|
+
return FromUint8Array2(schema_, references_, value);
|
|
3219
|
+
case "Unknown":
|
|
3220
|
+
return FromUnknown2(schema_, references_, value);
|
|
3221
|
+
case "Void":
|
|
3222
|
+
return FromVoid2(schema_, references_, value);
|
|
3223
|
+
default:
|
|
3224
|
+
if (!type_exports2.Has(schema_[Kind]))
|
|
3225
|
+
throw new ValueCheckUnknownTypeError(schema_);
|
|
3226
|
+
return FromKind(schema_, references_, value);
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
function Check(...args) {
|
|
3230
|
+
return args.length === 3 ? Visit5(args[0], args[1], args[2]) : Visit5(args[0], [], args[1]);
|
|
3231
|
+
}
|
|
3232
|
+
var ValueErrorType;
|
|
3233
|
+
(function(ValueErrorType2) {
|
|
3234
|
+
ValueErrorType2[ValueErrorType2["ArrayContains"] = 0] = "ArrayContains";
|
|
3235
|
+
ValueErrorType2[ValueErrorType2["ArrayMaxContains"] = 1] = "ArrayMaxContains";
|
|
3236
|
+
ValueErrorType2[ValueErrorType2["ArrayMaxItems"] = 2] = "ArrayMaxItems";
|
|
3237
|
+
ValueErrorType2[ValueErrorType2["ArrayMinContains"] = 3] = "ArrayMinContains";
|
|
3238
|
+
ValueErrorType2[ValueErrorType2["ArrayMinItems"] = 4] = "ArrayMinItems";
|
|
3239
|
+
ValueErrorType2[ValueErrorType2["ArrayUniqueItems"] = 5] = "ArrayUniqueItems";
|
|
3240
|
+
ValueErrorType2[ValueErrorType2["Array"] = 6] = "Array";
|
|
3241
|
+
ValueErrorType2[ValueErrorType2["AsyncIterator"] = 7] = "AsyncIterator";
|
|
3242
|
+
ValueErrorType2[ValueErrorType2["BigIntExclusiveMaximum"] = 8] = "BigIntExclusiveMaximum";
|
|
3243
|
+
ValueErrorType2[ValueErrorType2["BigIntExclusiveMinimum"] = 9] = "BigIntExclusiveMinimum";
|
|
3244
|
+
ValueErrorType2[ValueErrorType2["BigIntMaximum"] = 10] = "BigIntMaximum";
|
|
3245
|
+
ValueErrorType2[ValueErrorType2["BigIntMinimum"] = 11] = "BigIntMinimum";
|
|
3246
|
+
ValueErrorType2[ValueErrorType2["BigIntMultipleOf"] = 12] = "BigIntMultipleOf";
|
|
3247
|
+
ValueErrorType2[ValueErrorType2["BigInt"] = 13] = "BigInt";
|
|
3248
|
+
ValueErrorType2[ValueErrorType2["Boolean"] = 14] = "Boolean";
|
|
3249
|
+
ValueErrorType2[ValueErrorType2["DateExclusiveMaximumTimestamp"] = 15] = "DateExclusiveMaximumTimestamp";
|
|
3250
|
+
ValueErrorType2[ValueErrorType2["DateExclusiveMinimumTimestamp"] = 16] = "DateExclusiveMinimumTimestamp";
|
|
3251
|
+
ValueErrorType2[ValueErrorType2["DateMaximumTimestamp"] = 17] = "DateMaximumTimestamp";
|
|
3252
|
+
ValueErrorType2[ValueErrorType2["DateMinimumTimestamp"] = 18] = "DateMinimumTimestamp";
|
|
3253
|
+
ValueErrorType2[ValueErrorType2["DateMultipleOfTimestamp"] = 19] = "DateMultipleOfTimestamp";
|
|
3254
|
+
ValueErrorType2[ValueErrorType2["Date"] = 20] = "Date";
|
|
3255
|
+
ValueErrorType2[ValueErrorType2["Function"] = 21] = "Function";
|
|
3256
|
+
ValueErrorType2[ValueErrorType2["IntegerExclusiveMaximum"] = 22] = "IntegerExclusiveMaximum";
|
|
3257
|
+
ValueErrorType2[ValueErrorType2["IntegerExclusiveMinimum"] = 23] = "IntegerExclusiveMinimum";
|
|
3258
|
+
ValueErrorType2[ValueErrorType2["IntegerMaximum"] = 24] = "IntegerMaximum";
|
|
3259
|
+
ValueErrorType2[ValueErrorType2["IntegerMinimum"] = 25] = "IntegerMinimum";
|
|
3260
|
+
ValueErrorType2[ValueErrorType2["IntegerMultipleOf"] = 26] = "IntegerMultipleOf";
|
|
3261
|
+
ValueErrorType2[ValueErrorType2["Integer"] = 27] = "Integer";
|
|
3262
|
+
ValueErrorType2[ValueErrorType2["IntersectUnevaluatedProperties"] = 28] = "IntersectUnevaluatedProperties";
|
|
3263
|
+
ValueErrorType2[ValueErrorType2["Intersect"] = 29] = "Intersect";
|
|
3264
|
+
ValueErrorType2[ValueErrorType2["Iterator"] = 30] = "Iterator";
|
|
3265
|
+
ValueErrorType2[ValueErrorType2["Kind"] = 31] = "Kind";
|
|
3266
|
+
ValueErrorType2[ValueErrorType2["Literal"] = 32] = "Literal";
|
|
3267
|
+
ValueErrorType2[ValueErrorType2["Never"] = 33] = "Never";
|
|
3268
|
+
ValueErrorType2[ValueErrorType2["Not"] = 34] = "Not";
|
|
3269
|
+
ValueErrorType2[ValueErrorType2["Null"] = 35] = "Null";
|
|
3270
|
+
ValueErrorType2[ValueErrorType2["NumberExclusiveMaximum"] = 36] = "NumberExclusiveMaximum";
|
|
3271
|
+
ValueErrorType2[ValueErrorType2["NumberExclusiveMinimum"] = 37] = "NumberExclusiveMinimum";
|
|
3272
|
+
ValueErrorType2[ValueErrorType2["NumberMaximum"] = 38] = "NumberMaximum";
|
|
3273
|
+
ValueErrorType2[ValueErrorType2["NumberMinimum"] = 39] = "NumberMinimum";
|
|
3274
|
+
ValueErrorType2[ValueErrorType2["NumberMultipleOf"] = 40] = "NumberMultipleOf";
|
|
3275
|
+
ValueErrorType2[ValueErrorType2["Number"] = 41] = "Number";
|
|
3276
|
+
ValueErrorType2[ValueErrorType2["ObjectAdditionalProperties"] = 42] = "ObjectAdditionalProperties";
|
|
3277
|
+
ValueErrorType2[ValueErrorType2["ObjectMaxProperties"] = 43] = "ObjectMaxProperties";
|
|
3278
|
+
ValueErrorType2[ValueErrorType2["ObjectMinProperties"] = 44] = "ObjectMinProperties";
|
|
3279
|
+
ValueErrorType2[ValueErrorType2["ObjectRequiredProperty"] = 45] = "ObjectRequiredProperty";
|
|
3280
|
+
ValueErrorType2[ValueErrorType2["Object"] = 46] = "Object";
|
|
3281
|
+
ValueErrorType2[ValueErrorType2["Promise"] = 47] = "Promise";
|
|
3282
|
+
ValueErrorType2[ValueErrorType2["RegExp"] = 48] = "RegExp";
|
|
3283
|
+
ValueErrorType2[ValueErrorType2["StringFormatUnknown"] = 49] = "StringFormatUnknown";
|
|
3284
|
+
ValueErrorType2[ValueErrorType2["StringFormat"] = 50] = "StringFormat";
|
|
3285
|
+
ValueErrorType2[ValueErrorType2["StringMaxLength"] = 51] = "StringMaxLength";
|
|
3286
|
+
ValueErrorType2[ValueErrorType2["StringMinLength"] = 52] = "StringMinLength";
|
|
3287
|
+
ValueErrorType2[ValueErrorType2["StringPattern"] = 53] = "StringPattern";
|
|
3288
|
+
ValueErrorType2[ValueErrorType2["String"] = 54] = "String";
|
|
3289
|
+
ValueErrorType2[ValueErrorType2["Symbol"] = 55] = "Symbol";
|
|
3290
|
+
ValueErrorType2[ValueErrorType2["TupleLength"] = 56] = "TupleLength";
|
|
3291
|
+
ValueErrorType2[ValueErrorType2["Tuple"] = 57] = "Tuple";
|
|
3292
|
+
ValueErrorType2[ValueErrorType2["Uint8ArrayMaxByteLength"] = 58] = "Uint8ArrayMaxByteLength";
|
|
3293
|
+
ValueErrorType2[ValueErrorType2["Uint8ArrayMinByteLength"] = 59] = "Uint8ArrayMinByteLength";
|
|
3294
|
+
ValueErrorType2[ValueErrorType2["Uint8Array"] = 60] = "Uint8Array";
|
|
3295
|
+
ValueErrorType2[ValueErrorType2["Undefined"] = 61] = "Undefined";
|
|
3296
|
+
ValueErrorType2[ValueErrorType2["Union"] = 62] = "Union";
|
|
3297
|
+
ValueErrorType2[ValueErrorType2["Void"] = 63] = "Void";
|
|
3298
|
+
})(ValueErrorType || (ValueErrorType = {}));
|
|
3299
|
+
var ValueErrorsUnknownTypeError = class extends TypeBoxError {
|
|
3300
|
+
constructor(schema) {
|
|
3301
|
+
super("Unknown type");
|
|
3302
|
+
this.schema = schema;
|
|
3303
|
+
}
|
|
3304
|
+
};
|
|
3305
|
+
function EscapeKey(key) {
|
|
3306
|
+
return key.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3307
|
+
}
|
|
3308
|
+
function IsDefined2(value) {
|
|
3309
|
+
return value !== void 0;
|
|
3310
|
+
}
|
|
3311
|
+
var ValueErrorIterator = class {
|
|
3312
|
+
constructor(iterator) {
|
|
3313
|
+
this.iterator = iterator;
|
|
3314
|
+
}
|
|
3315
|
+
[Symbol.iterator]() {
|
|
3316
|
+
return this.iterator;
|
|
3317
|
+
}
|
|
3318
|
+
/** Returns the first value error or undefined if no errors */
|
|
3319
|
+
First() {
|
|
3320
|
+
const next = this.iterator.next();
|
|
3321
|
+
return next.done ? void 0 : next.value;
|
|
3322
|
+
}
|
|
3323
|
+
};
|
|
3324
|
+
function Create(errorType, schema, path, value, errors = []) {
|
|
3325
|
+
return {
|
|
3326
|
+
type: errorType,
|
|
3327
|
+
schema,
|
|
3328
|
+
path,
|
|
3329
|
+
value,
|
|
3330
|
+
message: GetErrorFunction()({ errorType, path, schema, value, errors }),
|
|
3331
|
+
errors
|
|
3332
|
+
};
|
|
3333
|
+
}
|
|
3334
|
+
function* FromAny3(schema, references, path, value) {
|
|
3335
|
+
}
|
|
3336
|
+
function* FromArgument3(schema, references, path, value) {
|
|
3337
|
+
}
|
|
3338
|
+
function* FromArray8(schema, references, path, value) {
|
|
3339
|
+
if (!IsArray2(value)) {
|
|
3340
|
+
return yield Create(ValueErrorType.Array, schema, path, value);
|
|
3341
|
+
}
|
|
3342
|
+
if (IsDefined2(schema.minItems) && !(value.length >= schema.minItems)) {
|
|
3343
|
+
yield Create(ValueErrorType.ArrayMinItems, schema, path, value);
|
|
3344
|
+
}
|
|
3345
|
+
if (IsDefined2(schema.maxItems) && !(value.length <= schema.maxItems)) {
|
|
3346
|
+
yield Create(ValueErrorType.ArrayMaxItems, schema, path, value);
|
|
3347
|
+
}
|
|
3348
|
+
for (let i = 0; i < value.length; i++) {
|
|
3349
|
+
yield* Visit6(schema.items, references, `${path}/${i}`, value[i]);
|
|
3350
|
+
}
|
|
3351
|
+
if (schema.uniqueItems === true && !(function() {
|
|
3352
|
+
const set = /* @__PURE__ */ new Set();
|
|
3353
|
+
for (const element of value) {
|
|
3354
|
+
const hashed = Hash(element);
|
|
3355
|
+
if (set.has(hashed)) {
|
|
3356
|
+
return false;
|
|
3357
|
+
} else {
|
|
3358
|
+
set.add(hashed);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
return true;
|
|
3362
|
+
})()) {
|
|
3363
|
+
yield Create(ValueErrorType.ArrayUniqueItems, schema, path, value);
|
|
3364
|
+
}
|
|
3365
|
+
if (!(IsDefined2(schema.contains) || IsDefined2(schema.minContains) || IsDefined2(schema.maxContains))) {
|
|
3366
|
+
return;
|
|
3367
|
+
}
|
|
3368
|
+
const containsSchema = IsDefined2(schema.contains) ? schema.contains : Never();
|
|
3369
|
+
const containsCount = value.reduce((acc, value2, index) => Visit6(containsSchema, references, `${path}${index}`, value2).next().done === true ? acc + 1 : acc, 0);
|
|
3370
|
+
if (containsCount === 0) {
|
|
3371
|
+
yield Create(ValueErrorType.ArrayContains, schema, path, value);
|
|
3372
|
+
}
|
|
3373
|
+
if (IsNumber2(schema.minContains) && containsCount < schema.minContains) {
|
|
3374
|
+
yield Create(ValueErrorType.ArrayMinContains, schema, path, value);
|
|
3375
|
+
}
|
|
3376
|
+
if (IsNumber2(schema.maxContains) && containsCount > schema.maxContains) {
|
|
3377
|
+
yield Create(ValueErrorType.ArrayMaxContains, schema, path, value);
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
function* FromAsyncIterator5(schema, references, path, value) {
|
|
3381
|
+
if (!IsAsyncIterator2(value))
|
|
3382
|
+
yield Create(ValueErrorType.AsyncIterator, schema, path, value);
|
|
3383
|
+
}
|
|
3384
|
+
function* FromBigInt3(schema, references, path, value) {
|
|
3385
|
+
if (!IsBigInt2(value))
|
|
3386
|
+
return yield Create(ValueErrorType.BigInt, schema, path, value);
|
|
3387
|
+
if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
3388
|
+
yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path, value);
|
|
3389
|
+
}
|
|
3390
|
+
if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
3391
|
+
yield Create(ValueErrorType.BigIntExclusiveMinimum, schema, path, value);
|
|
3392
|
+
}
|
|
3393
|
+
if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
|
|
3394
|
+
yield Create(ValueErrorType.BigIntMaximum, schema, path, value);
|
|
3395
|
+
}
|
|
3396
|
+
if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
|
|
3397
|
+
yield Create(ValueErrorType.BigIntMinimum, schema, path, value);
|
|
3398
|
+
}
|
|
3399
|
+
if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) {
|
|
3400
|
+
yield Create(ValueErrorType.BigIntMultipleOf, schema, path, value);
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
function* FromBoolean3(schema, references, path, value) {
|
|
3404
|
+
if (!IsBoolean2(value))
|
|
3405
|
+
yield Create(ValueErrorType.Boolean, schema, path, value);
|
|
3406
|
+
}
|
|
3407
|
+
function* FromConstructor5(schema, references, path, value) {
|
|
3408
|
+
yield* Visit6(schema.returns, references, path, value.prototype);
|
|
3409
|
+
}
|
|
3410
|
+
function* FromDate3(schema, references, path, value) {
|
|
3411
|
+
if (!IsDate2(value))
|
|
3412
|
+
return yield Create(ValueErrorType.Date, schema, path, value);
|
|
3413
|
+
if (IsDefined2(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
|
|
3414
|
+
yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path, value);
|
|
3415
|
+
}
|
|
3416
|
+
if (IsDefined2(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) {
|
|
3417
|
+
yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema, path, value);
|
|
3418
|
+
}
|
|
3419
|
+
if (IsDefined2(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) {
|
|
3420
|
+
yield Create(ValueErrorType.DateMaximumTimestamp, schema, path, value);
|
|
3421
|
+
}
|
|
3422
|
+
if (IsDefined2(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) {
|
|
3423
|
+
yield Create(ValueErrorType.DateMinimumTimestamp, schema, path, value);
|
|
3424
|
+
}
|
|
3425
|
+
if (IsDefined2(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) {
|
|
3426
|
+
yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path, value);
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
function* FromFunction5(schema, references, path, value) {
|
|
3430
|
+
if (!IsFunction2(value))
|
|
3431
|
+
yield Create(ValueErrorType.Function, schema, path, value);
|
|
3432
|
+
}
|
|
3433
|
+
function* FromImport2(schema, references, path, value) {
|
|
3434
|
+
const definitions = globalThis.Object.values(schema.$defs);
|
|
3435
|
+
const target = schema.$defs[schema.$ref];
|
|
3436
|
+
yield* Visit6(target, [...references, ...definitions], path, value);
|
|
3437
|
+
}
|
|
3438
|
+
function* FromInteger3(schema, references, path, value) {
|
|
3439
|
+
if (!IsInteger(value))
|
|
3440
|
+
return yield Create(ValueErrorType.Integer, schema, path, value);
|
|
3441
|
+
if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
3442
|
+
yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path, value);
|
|
3443
|
+
}
|
|
3444
|
+
if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
3445
|
+
yield Create(ValueErrorType.IntegerExclusiveMinimum, schema, path, value);
|
|
3446
|
+
}
|
|
3447
|
+
if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
|
|
3448
|
+
yield Create(ValueErrorType.IntegerMaximum, schema, path, value);
|
|
3449
|
+
}
|
|
3450
|
+
if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
|
|
3451
|
+
yield Create(ValueErrorType.IntegerMinimum, schema, path, value);
|
|
3452
|
+
}
|
|
3453
|
+
if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
3454
|
+
yield Create(ValueErrorType.IntegerMultipleOf, schema, path, value);
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
function* FromIntersect10(schema, references, path, value) {
|
|
3458
|
+
let hasError = false;
|
|
3459
|
+
for (const inner of schema.allOf) {
|
|
3460
|
+
for (const error2 of Visit6(inner, references, path, value)) {
|
|
3461
|
+
hasError = true;
|
|
3462
|
+
yield error2;
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
if (hasError) {
|
|
3466
|
+
return yield Create(ValueErrorType.Intersect, schema, path, value);
|
|
3467
|
+
}
|
|
3468
|
+
if (schema.unevaluatedProperties === false) {
|
|
3469
|
+
const keyCheck = new RegExp(KeyOfPattern(schema));
|
|
3470
|
+
for (const valueKey of Object.getOwnPropertyNames(value)) {
|
|
3471
|
+
if (!keyCheck.test(valueKey)) {
|
|
3472
|
+
yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${path}/${valueKey}`, value);
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
}
|
|
3476
|
+
if (typeof schema.unevaluatedProperties === "object") {
|
|
3477
|
+
const keyCheck = new RegExp(KeyOfPattern(schema));
|
|
3478
|
+
for (const valueKey of Object.getOwnPropertyNames(value)) {
|
|
3479
|
+
if (!keyCheck.test(valueKey)) {
|
|
3480
|
+
const next = Visit6(schema.unevaluatedProperties, references, `${path}/${valueKey}`, value[valueKey]).next();
|
|
3481
|
+
if (!next.done)
|
|
3482
|
+
yield next.value;
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
function* FromIterator5(schema, references, path, value) {
|
|
3488
|
+
if (!IsIterator2(value))
|
|
3489
|
+
yield Create(ValueErrorType.Iterator, schema, path, value);
|
|
3490
|
+
}
|
|
3491
|
+
function* FromLiteral4(schema, references, path, value) {
|
|
3492
|
+
if (!(value === schema.const))
|
|
3493
|
+
yield Create(ValueErrorType.Literal, schema, path, value);
|
|
3494
|
+
}
|
|
3495
|
+
function* FromNever3(schema, references, path, value) {
|
|
3496
|
+
yield Create(ValueErrorType.Never, schema, path, value);
|
|
3497
|
+
}
|
|
3498
|
+
function* FromNot3(schema, references, path, value) {
|
|
3499
|
+
if (Visit6(schema.not, references, path, value).next().done === true)
|
|
3500
|
+
yield Create(ValueErrorType.Not, schema, path, value);
|
|
3501
|
+
}
|
|
3502
|
+
function* FromNull3(schema, references, path, value) {
|
|
3503
|
+
if (!IsNull2(value))
|
|
3504
|
+
yield Create(ValueErrorType.Null, schema, path, value);
|
|
3505
|
+
}
|
|
3506
|
+
function* FromNumber3(schema, references, path, value) {
|
|
3507
|
+
if (!TypeSystemPolicy.IsNumberLike(value))
|
|
3508
|
+
return yield Create(ValueErrorType.Number, schema, path, value);
|
|
3509
|
+
if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
3510
|
+
yield Create(ValueErrorType.NumberExclusiveMaximum, schema, path, value);
|
|
3511
|
+
}
|
|
3512
|
+
if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
3513
|
+
yield Create(ValueErrorType.NumberExclusiveMinimum, schema, path, value);
|
|
3514
|
+
}
|
|
3515
|
+
if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
|
|
3516
|
+
yield Create(ValueErrorType.NumberMaximum, schema, path, value);
|
|
3517
|
+
}
|
|
3518
|
+
if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
|
|
3519
|
+
yield Create(ValueErrorType.NumberMinimum, schema, path, value);
|
|
3520
|
+
}
|
|
3521
|
+
if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
3522
|
+
yield Create(ValueErrorType.NumberMultipleOf, schema, path, value);
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
function* FromObject9(schema, references, path, value) {
|
|
3526
|
+
if (!TypeSystemPolicy.IsObjectLike(value))
|
|
3527
|
+
return yield Create(ValueErrorType.Object, schema, path, value);
|
|
3528
|
+
if (IsDefined2(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
3529
|
+
yield Create(ValueErrorType.ObjectMinProperties, schema, path, value);
|
|
3530
|
+
}
|
|
3531
|
+
if (IsDefined2(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
3532
|
+
yield Create(ValueErrorType.ObjectMaxProperties, schema, path, value);
|
|
3533
|
+
}
|
|
3534
|
+
const requiredKeys = Array.isArray(schema.required) ? schema.required : [];
|
|
3535
|
+
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
3536
|
+
const unknownKeys = Object.getOwnPropertyNames(value);
|
|
3537
|
+
for (const requiredKey of requiredKeys) {
|
|
3538
|
+
if (unknownKeys.includes(requiredKey))
|
|
3539
|
+
continue;
|
|
3540
|
+
yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${path}/${EscapeKey(requiredKey)}`, void 0);
|
|
3541
|
+
}
|
|
3542
|
+
if (schema.additionalProperties === false) {
|
|
3543
|
+
for (const valueKey of unknownKeys) {
|
|
3544
|
+
if (!knownKeys.includes(valueKey)) {
|
|
3545
|
+
yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path}/${EscapeKey(valueKey)}`, value[valueKey]);
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3549
|
+
if (typeof schema.additionalProperties === "object") {
|
|
3550
|
+
for (const valueKey of unknownKeys) {
|
|
3551
|
+
if (knownKeys.includes(valueKey))
|
|
3552
|
+
continue;
|
|
3553
|
+
yield* Visit6(schema.additionalProperties, references, `${path}/${EscapeKey(valueKey)}`, value[valueKey]);
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
for (const knownKey of knownKeys) {
|
|
3557
|
+
const property = schema.properties[knownKey];
|
|
3558
|
+
if (schema.required && schema.required.includes(knownKey)) {
|
|
3559
|
+
yield* Visit6(property, references, `${path}/${EscapeKey(knownKey)}`, value[knownKey]);
|
|
3560
|
+
if (ExtendsUndefinedCheck(schema) && !(knownKey in value)) {
|
|
3561
|
+
yield Create(ValueErrorType.ObjectRequiredProperty, property, `${path}/${EscapeKey(knownKey)}`, void 0);
|
|
3562
|
+
}
|
|
3563
|
+
} else {
|
|
3564
|
+
if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey)) {
|
|
3565
|
+
yield* Visit6(property, references, `${path}/${EscapeKey(knownKey)}`, value[knownKey]);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
function* FromPromise5(schema, references, path, value) {
|
|
3571
|
+
if (!IsPromise(value))
|
|
3572
|
+
yield Create(ValueErrorType.Promise, schema, path, value);
|
|
3573
|
+
}
|
|
3574
|
+
function* FromRecord5(schema, references, path, value) {
|
|
3575
|
+
if (!TypeSystemPolicy.IsRecordLike(value))
|
|
3576
|
+
return yield Create(ValueErrorType.Object, schema, path, value);
|
|
3577
|
+
if (IsDefined2(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
3578
|
+
yield Create(ValueErrorType.ObjectMinProperties, schema, path, value);
|
|
3579
|
+
}
|
|
3580
|
+
if (IsDefined2(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
3581
|
+
yield Create(ValueErrorType.ObjectMaxProperties, schema, path, value);
|
|
3582
|
+
}
|
|
3583
|
+
const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
|
|
3584
|
+
const regex = new RegExp(patternKey);
|
|
3585
|
+
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
3586
|
+
if (regex.test(propertyKey))
|
|
3587
|
+
yield* Visit6(patternSchema, references, `${path}/${EscapeKey(propertyKey)}`, propertyValue);
|
|
3588
|
+
}
|
|
3589
|
+
if (typeof schema.additionalProperties === "object") {
|
|
3590
|
+
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
3591
|
+
if (!regex.test(propertyKey))
|
|
3592
|
+
yield* Visit6(schema.additionalProperties, references, `${path}/${EscapeKey(propertyKey)}`, propertyValue);
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
if (schema.additionalProperties === false) {
|
|
3596
|
+
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
3597
|
+
if (regex.test(propertyKey))
|
|
3598
|
+
continue;
|
|
3599
|
+
return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path}/${EscapeKey(propertyKey)}`, propertyValue);
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
function* FromRef6(schema, references, path, value) {
|
|
3604
|
+
yield* Visit6(Deref(schema, references), references, path, value);
|
|
3605
|
+
}
|
|
3606
|
+
function* FromRegExp3(schema, references, path, value) {
|
|
3607
|
+
if (!IsString2(value))
|
|
3608
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
3609
|
+
if (IsDefined2(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
3610
|
+
yield Create(ValueErrorType.StringMinLength, schema, path, value);
|
|
3611
|
+
}
|
|
3612
|
+
if (IsDefined2(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
3613
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path, value);
|
|
3614
|
+
}
|
|
3615
|
+
const regex = new RegExp(schema.source, schema.flags);
|
|
3616
|
+
if (!regex.test(value)) {
|
|
3617
|
+
return yield Create(ValueErrorType.RegExp, schema, path, value);
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
function* FromString3(schema, references, path, value) {
|
|
3621
|
+
if (!IsString2(value))
|
|
3622
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
3623
|
+
if (IsDefined2(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
3624
|
+
yield Create(ValueErrorType.StringMinLength, schema, path, value);
|
|
3625
|
+
}
|
|
3626
|
+
if (IsDefined2(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
3627
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path, value);
|
|
3628
|
+
}
|
|
3629
|
+
if (IsString2(schema.pattern)) {
|
|
3630
|
+
const regex = new RegExp(schema.pattern);
|
|
3631
|
+
if (!regex.test(value)) {
|
|
3632
|
+
yield Create(ValueErrorType.StringPattern, schema, path, value);
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
if (IsString2(schema.format)) {
|
|
3636
|
+
if (!format_exports.Has(schema.format)) {
|
|
3637
|
+
yield Create(ValueErrorType.StringFormatUnknown, schema, path, value);
|
|
3638
|
+
} else {
|
|
3639
|
+
const format = format_exports.Get(schema.format);
|
|
3640
|
+
if (!format(value)) {
|
|
3641
|
+
yield Create(ValueErrorType.StringFormat, schema, path, value);
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
function* FromSymbol3(schema, references, path, value) {
|
|
3647
|
+
if (!IsSymbol2(value))
|
|
3648
|
+
yield Create(ValueErrorType.Symbol, schema, path, value);
|
|
3649
|
+
}
|
|
3650
|
+
function* FromTemplateLiteral5(schema, references, path, value) {
|
|
3651
|
+
if (!IsString2(value))
|
|
3652
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
3653
|
+
const regex = new RegExp(schema.pattern);
|
|
3654
|
+
if (!regex.test(value)) {
|
|
3655
|
+
yield Create(ValueErrorType.StringPattern, schema, path, value);
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
function* FromThis2(schema, references, path, value) {
|
|
3659
|
+
yield* Visit6(Deref(schema, references), references, path, value);
|
|
3660
|
+
}
|
|
3661
|
+
function* FromTuple7(schema, references, path, value) {
|
|
3662
|
+
if (!IsArray2(value))
|
|
3663
|
+
return yield Create(ValueErrorType.Tuple, schema, path, value);
|
|
3664
|
+
if (schema.items === void 0 && !(value.length === 0)) {
|
|
3665
|
+
return yield Create(ValueErrorType.TupleLength, schema, path, value);
|
|
3666
|
+
}
|
|
3667
|
+
if (!(value.length === schema.maxItems)) {
|
|
3668
|
+
return yield Create(ValueErrorType.TupleLength, schema, path, value);
|
|
3669
|
+
}
|
|
3670
|
+
if (!schema.items) {
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
3674
|
+
yield* Visit6(schema.items[i], references, `${path}/${i}`, value[i]);
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
3677
|
+
function* FromUndefined3(schema, references, path, value) {
|
|
3678
|
+
if (!IsUndefined2(value))
|
|
3679
|
+
yield Create(ValueErrorType.Undefined, schema, path, value);
|
|
3680
|
+
}
|
|
3681
|
+
function* FromUnion12(schema, references, path, value) {
|
|
3682
|
+
if (Check(schema, references, value))
|
|
3683
|
+
return;
|
|
3684
|
+
const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit6(variant, references, path, value)));
|
|
3685
|
+
yield Create(ValueErrorType.Union, schema, path, value, errors);
|
|
3686
|
+
}
|
|
3687
|
+
function* FromUint8Array3(schema, references, path, value) {
|
|
3688
|
+
if (!IsUint8Array2(value))
|
|
3689
|
+
return yield Create(ValueErrorType.Uint8Array, schema, path, value);
|
|
3690
|
+
if (IsDefined2(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
|
|
3691
|
+
yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path, value);
|
|
3692
|
+
}
|
|
3693
|
+
if (IsDefined2(schema.minByteLength) && !(value.length >= schema.minByteLength)) {
|
|
3694
|
+
yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path, value);
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
function* FromUnknown3(schema, references, path, value) {
|
|
3698
|
+
}
|
|
3699
|
+
function* FromVoid3(schema, references, path, value) {
|
|
3700
|
+
if (!TypeSystemPolicy.IsVoidLike(value))
|
|
3701
|
+
yield Create(ValueErrorType.Void, schema, path, value);
|
|
3702
|
+
}
|
|
3703
|
+
function* FromKind2(schema, references, path, value) {
|
|
3704
|
+
const check = type_exports2.Get(schema[Kind]);
|
|
3705
|
+
if (!check(schema, value))
|
|
3706
|
+
yield Create(ValueErrorType.Kind, schema, path, value);
|
|
3707
|
+
}
|
|
3708
|
+
function* Visit6(schema, references, path, value) {
|
|
3709
|
+
const references_ = IsDefined2(schema.$id) ? [...references, schema] : references;
|
|
3710
|
+
const schema_ = schema;
|
|
3711
|
+
switch (schema_[Kind]) {
|
|
3712
|
+
case "Any":
|
|
3713
|
+
return yield* FromAny3(schema_, references_, path, value);
|
|
3714
|
+
case "Argument":
|
|
3715
|
+
return yield* FromArgument3(schema_, references_, path, value);
|
|
3716
|
+
case "Array":
|
|
3717
|
+
return yield* FromArray8(schema_, references_, path, value);
|
|
3718
|
+
case "AsyncIterator":
|
|
3719
|
+
return yield* FromAsyncIterator5(schema_, references_, path, value);
|
|
3720
|
+
case "BigInt":
|
|
3721
|
+
return yield* FromBigInt3(schema_, references_, path, value);
|
|
3722
|
+
case "Boolean":
|
|
3723
|
+
return yield* FromBoolean3(schema_, references_, path, value);
|
|
3724
|
+
case "Constructor":
|
|
3725
|
+
return yield* FromConstructor5(schema_, references_, path, value);
|
|
3726
|
+
case "Date":
|
|
3727
|
+
return yield* FromDate3(schema_, references_, path, value);
|
|
3728
|
+
case "Function":
|
|
3729
|
+
return yield* FromFunction5(schema_, references_, path, value);
|
|
3730
|
+
case "Import":
|
|
3731
|
+
return yield* FromImport2(schema_, references_, path, value);
|
|
3732
|
+
case "Integer":
|
|
3733
|
+
return yield* FromInteger3(schema_, references_, path, value);
|
|
3734
|
+
case "Intersect":
|
|
3735
|
+
return yield* FromIntersect10(schema_, references_, path, value);
|
|
3736
|
+
case "Iterator":
|
|
3737
|
+
return yield* FromIterator5(schema_, references_, path, value);
|
|
3738
|
+
case "Literal":
|
|
3739
|
+
return yield* FromLiteral4(schema_, references_, path, value);
|
|
3740
|
+
case "Never":
|
|
3741
|
+
return yield* FromNever3(schema_, references_, path, value);
|
|
3742
|
+
case "Not":
|
|
3743
|
+
return yield* FromNot3(schema_, references_, path, value);
|
|
3744
|
+
case "Null":
|
|
3745
|
+
return yield* FromNull3(schema_, references_, path, value);
|
|
3746
|
+
case "Number":
|
|
3747
|
+
return yield* FromNumber3(schema_, references_, path, value);
|
|
3748
|
+
case "Object":
|
|
3749
|
+
return yield* FromObject9(schema_, references_, path, value);
|
|
3750
|
+
case "Promise":
|
|
3751
|
+
return yield* FromPromise5(schema_, references_, path, value);
|
|
3752
|
+
case "Record":
|
|
3753
|
+
return yield* FromRecord5(schema_, references_, path, value);
|
|
3754
|
+
case "Ref":
|
|
3755
|
+
return yield* FromRef6(schema_, references_, path, value);
|
|
3756
|
+
case "RegExp":
|
|
3757
|
+
return yield* FromRegExp3(schema_, references_, path, value);
|
|
3758
|
+
case "String":
|
|
3759
|
+
return yield* FromString3(schema_, references_, path, value);
|
|
3760
|
+
case "Symbol":
|
|
3761
|
+
return yield* FromSymbol3(schema_, references_, path, value);
|
|
3762
|
+
case "TemplateLiteral":
|
|
3763
|
+
return yield* FromTemplateLiteral5(schema_, references_, path, value);
|
|
3764
|
+
case "This":
|
|
3765
|
+
return yield* FromThis2(schema_, references_, path, value);
|
|
3766
|
+
case "Tuple":
|
|
3767
|
+
return yield* FromTuple7(schema_, references_, path, value);
|
|
3768
|
+
case "Undefined":
|
|
3769
|
+
return yield* FromUndefined3(schema_, references_, path, value);
|
|
3770
|
+
case "Union":
|
|
3771
|
+
return yield* FromUnion12(schema_, references_, path, value);
|
|
3772
|
+
case "Uint8Array":
|
|
3773
|
+
return yield* FromUint8Array3(schema_, references_, path, value);
|
|
3774
|
+
case "Unknown":
|
|
3775
|
+
return yield* FromUnknown3(schema_, references_, path, value);
|
|
3776
|
+
case "Void":
|
|
3777
|
+
return yield* FromVoid3(schema_, references_, path, value);
|
|
3778
|
+
default:
|
|
3779
|
+
if (!type_exports2.Has(schema_[Kind]))
|
|
3780
|
+
throw new ValueErrorsUnknownTypeError(schema);
|
|
3781
|
+
return yield* FromKind2(schema_, references_, path, value);
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
function Errors(...args) {
|
|
3785
|
+
const iterator = args.length === 3 ? Visit6(args[0], args[1], "", args[2]) : Visit6(args[0], [], "", args[1]);
|
|
3786
|
+
return new ValueErrorIterator(iterator);
|
|
3787
|
+
}
|
|
3788
|
+
var TransformDecodeCheckError = class extends TypeBoxError {
|
|
3789
|
+
constructor(schema, value, error2) {
|
|
3790
|
+
super(`Unable to decode value as it does not match the expected schema`);
|
|
3791
|
+
this.schema = schema;
|
|
3792
|
+
this.value = value;
|
|
3793
|
+
this.error = error2;
|
|
3794
|
+
}
|
|
3795
|
+
};
|
|
3796
|
+
var TransformDecodeError = class extends TypeBoxError {
|
|
3797
|
+
constructor(schema, path, value, error2) {
|
|
3798
|
+
super(error2 instanceof Error ? error2.message : "Unknown error");
|
|
3799
|
+
this.schema = schema;
|
|
3800
|
+
this.path = path;
|
|
3801
|
+
this.value = value;
|
|
3802
|
+
this.error = error2;
|
|
3803
|
+
}
|
|
3804
|
+
};
|
|
3805
|
+
function Default(schema, path, value) {
|
|
3806
|
+
try {
|
|
3807
|
+
return IsTransform(schema) ? schema[TransformKind].Decode(value) : value;
|
|
3808
|
+
} catch (error2) {
|
|
3809
|
+
throw new TransformDecodeError(schema, path, value, error2);
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
function FromArray9(schema, references, path, value) {
|
|
3813
|
+
return IsArray2(value) ? Default(schema, path, value.map((value2, index) => Visit7(schema.items, references, `${path}/${index}`, value2))) : Default(schema, path, value);
|
|
3814
|
+
}
|
|
3815
|
+
function FromIntersect11(schema, references, path, value) {
|
|
3816
|
+
if (!IsObject2(value) || IsValueType(value))
|
|
3817
|
+
return Default(schema, path, value);
|
|
3818
|
+
const knownEntries = KeyOfPropertyEntries(schema);
|
|
3819
|
+
const knownKeys = knownEntries.map((entry) => entry[0]);
|
|
3820
|
+
const knownProperties = { ...value };
|
|
3821
|
+
for (const [knownKey, knownSchema] of knownEntries)
|
|
3822
|
+
if (knownKey in knownProperties) {
|
|
3823
|
+
knownProperties[knownKey] = Visit7(knownSchema, references, `${path}/${knownKey}`, knownProperties[knownKey]);
|
|
3824
|
+
}
|
|
3825
|
+
if (!IsTransform(schema.unevaluatedProperties)) {
|
|
3826
|
+
return Default(schema, path, knownProperties);
|
|
3827
|
+
}
|
|
3828
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
3829
|
+
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
3830
|
+
const unknownProperties = { ...knownProperties };
|
|
3831
|
+
for (const key of unknownKeys)
|
|
3832
|
+
if (!knownKeys.includes(key)) {
|
|
3833
|
+
unknownProperties[key] = Default(unevaluatedProperties, `${path}/${key}`, unknownProperties[key]);
|
|
3834
|
+
}
|
|
3835
|
+
return Default(schema, path, unknownProperties);
|
|
3836
|
+
}
|
|
3837
|
+
function FromImport3(schema, references, path, value) {
|
|
3838
|
+
const additional = globalThis.Object.values(schema.$defs);
|
|
3839
|
+
const target = schema.$defs[schema.$ref];
|
|
3840
|
+
const result = Visit7(target, [...references, ...additional], path, value);
|
|
3841
|
+
return Default(schema, path, result);
|
|
3842
|
+
}
|
|
3843
|
+
function FromNot4(schema, references, path, value) {
|
|
3844
|
+
return Default(schema, path, Visit7(schema.not, references, path, value));
|
|
3845
|
+
}
|
|
3846
|
+
function FromObject10(schema, references, path, value) {
|
|
3847
|
+
if (!IsObject2(value))
|
|
3848
|
+
return Default(schema, path, value);
|
|
3849
|
+
const knownKeys = KeyOfPropertyKeys(schema);
|
|
3850
|
+
const knownProperties = { ...value };
|
|
3851
|
+
for (const key of knownKeys) {
|
|
3852
|
+
if (!HasPropertyKey2(knownProperties, key))
|
|
3853
|
+
continue;
|
|
3854
|
+
if (IsUndefined2(knownProperties[key]) && (!IsUndefined3(schema.properties[key]) || TypeSystemPolicy.IsExactOptionalProperty(knownProperties, key)))
|
|
3855
|
+
continue;
|
|
3856
|
+
knownProperties[key] = Visit7(schema.properties[key], references, `${path}/${key}`, knownProperties[key]);
|
|
3857
|
+
}
|
|
3858
|
+
if (!IsSchema(schema.additionalProperties)) {
|
|
3859
|
+
return Default(schema, path, knownProperties);
|
|
3860
|
+
}
|
|
3861
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
3862
|
+
const additionalProperties = schema.additionalProperties;
|
|
3863
|
+
const unknownProperties = { ...knownProperties };
|
|
3864
|
+
for (const key of unknownKeys)
|
|
3865
|
+
if (!knownKeys.includes(key)) {
|
|
3866
|
+
unknownProperties[key] = Default(additionalProperties, `${path}/${key}`, unknownProperties[key]);
|
|
3867
|
+
}
|
|
3868
|
+
return Default(schema, path, unknownProperties);
|
|
3869
|
+
}
|
|
3870
|
+
function FromRecord6(schema, references, path, value) {
|
|
3871
|
+
if (!IsObject2(value))
|
|
3872
|
+
return Default(schema, path, value);
|
|
3873
|
+
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
3874
|
+
const knownKeys = new RegExp(pattern);
|
|
3875
|
+
const knownProperties = { ...value };
|
|
3876
|
+
for (const key of Object.getOwnPropertyNames(value))
|
|
3877
|
+
if (knownKeys.test(key)) {
|
|
3878
|
+
knownProperties[key] = Visit7(schema.patternProperties[pattern], references, `${path}/${key}`, knownProperties[key]);
|
|
3879
|
+
}
|
|
3880
|
+
if (!IsSchema(schema.additionalProperties)) {
|
|
3881
|
+
return Default(schema, path, knownProperties);
|
|
3882
|
+
}
|
|
3883
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
3884
|
+
const additionalProperties = schema.additionalProperties;
|
|
3885
|
+
const unknownProperties = { ...knownProperties };
|
|
3886
|
+
for (const key of unknownKeys)
|
|
3887
|
+
if (!knownKeys.test(key)) {
|
|
3888
|
+
unknownProperties[key] = Default(additionalProperties, `${path}/${key}`, unknownProperties[key]);
|
|
3889
|
+
}
|
|
3890
|
+
return Default(schema, path, unknownProperties);
|
|
3891
|
+
}
|
|
3892
|
+
function FromRef7(schema, references, path, value) {
|
|
3893
|
+
const target = Deref(schema, references);
|
|
3894
|
+
return Default(schema, path, Visit7(target, references, path, value));
|
|
3895
|
+
}
|
|
3896
|
+
function FromThis3(schema, references, path, value) {
|
|
3897
|
+
const target = Deref(schema, references);
|
|
3898
|
+
return Default(schema, path, Visit7(target, references, path, value));
|
|
3899
|
+
}
|
|
3900
|
+
function FromTuple8(schema, references, path, value) {
|
|
3901
|
+
return IsArray2(value) && IsArray2(schema.items) ? Default(schema, path, schema.items.map((schema2, index) => Visit7(schema2, references, `${path}/${index}`, value[index]))) : Default(schema, path, value);
|
|
3902
|
+
}
|
|
3903
|
+
function FromUnion13(schema, references, path, value) {
|
|
3904
|
+
for (const subschema of schema.anyOf) {
|
|
3905
|
+
if (!Check(subschema, references, value))
|
|
3906
|
+
continue;
|
|
3907
|
+
const decoded = Visit7(subschema, references, path, value);
|
|
3908
|
+
return Default(schema, path, decoded);
|
|
3909
|
+
}
|
|
3910
|
+
return Default(schema, path, value);
|
|
3911
|
+
}
|
|
3912
|
+
function Visit7(schema, references, path, value) {
|
|
3913
|
+
const references_ = Pushref(schema, references);
|
|
3914
|
+
const schema_ = schema;
|
|
3915
|
+
switch (schema[Kind]) {
|
|
3916
|
+
case "Array":
|
|
3917
|
+
return FromArray9(schema_, references_, path, value);
|
|
3918
|
+
case "Import":
|
|
3919
|
+
return FromImport3(schema_, references_, path, value);
|
|
3920
|
+
case "Intersect":
|
|
3921
|
+
return FromIntersect11(schema_, references_, path, value);
|
|
3922
|
+
case "Not":
|
|
3923
|
+
return FromNot4(schema_, references_, path, value);
|
|
3924
|
+
case "Object":
|
|
3925
|
+
return FromObject10(schema_, references_, path, value);
|
|
3926
|
+
case "Record":
|
|
3927
|
+
return FromRecord6(schema_, references_, path, value);
|
|
3928
|
+
case "Ref":
|
|
3929
|
+
return FromRef7(schema_, references_, path, value);
|
|
3930
|
+
case "Symbol":
|
|
3931
|
+
return Default(schema_, path, value);
|
|
3932
|
+
case "This":
|
|
3933
|
+
return FromThis3(schema_, references_, path, value);
|
|
3934
|
+
case "Tuple":
|
|
3935
|
+
return FromTuple8(schema_, references_, path, value);
|
|
3936
|
+
case "Union":
|
|
3937
|
+
return FromUnion13(schema_, references_, path, value);
|
|
3938
|
+
default:
|
|
3939
|
+
return Default(schema_, path, value);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
function TransformDecode(schema, references, value) {
|
|
3943
|
+
return Visit7(schema, references, "", value);
|
|
3944
|
+
}
|
|
3945
|
+
var TransformEncodeCheckError = class extends TypeBoxError {
|
|
3946
|
+
constructor(schema, value, error2) {
|
|
3947
|
+
super(`The encoded value does not match the expected schema`);
|
|
3948
|
+
this.schema = schema;
|
|
3949
|
+
this.value = value;
|
|
3950
|
+
this.error = error2;
|
|
3951
|
+
}
|
|
3952
|
+
};
|
|
3953
|
+
var TransformEncodeError = class extends TypeBoxError {
|
|
3954
|
+
constructor(schema, path, value, error2) {
|
|
3955
|
+
super(`${error2 instanceof Error ? error2.message : "Unknown error"}`);
|
|
3956
|
+
this.schema = schema;
|
|
3957
|
+
this.path = path;
|
|
3958
|
+
this.value = value;
|
|
3959
|
+
this.error = error2;
|
|
3960
|
+
}
|
|
3961
|
+
};
|
|
3962
|
+
function Default2(schema, path, value) {
|
|
3963
|
+
try {
|
|
3964
|
+
return IsTransform(schema) ? schema[TransformKind].Encode(value) : value;
|
|
3965
|
+
} catch (error2) {
|
|
3966
|
+
throw new TransformEncodeError(schema, path, value, error2);
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
function FromArray10(schema, references, path, value) {
|
|
3970
|
+
const defaulted = Default2(schema, path, value);
|
|
3971
|
+
return IsArray2(defaulted) ? defaulted.map((value2, index) => Visit8(schema.items, references, `${path}/${index}`, value2)) : defaulted;
|
|
3972
|
+
}
|
|
3973
|
+
function FromImport4(schema, references, path, value) {
|
|
3974
|
+
const additional = globalThis.Object.values(schema.$defs);
|
|
3975
|
+
const target = schema.$defs[schema.$ref];
|
|
3976
|
+
const result = Default2(schema, path, value);
|
|
3977
|
+
return Visit8(target, [...references, ...additional], path, result);
|
|
3978
|
+
}
|
|
3979
|
+
function FromIntersect12(schema, references, path, value) {
|
|
3980
|
+
const defaulted = Default2(schema, path, value);
|
|
3981
|
+
if (!IsObject2(value) || IsValueType(value))
|
|
3982
|
+
return defaulted;
|
|
3983
|
+
const knownEntries = KeyOfPropertyEntries(schema);
|
|
3984
|
+
const knownKeys = knownEntries.map((entry) => entry[0]);
|
|
3985
|
+
const knownProperties = { ...defaulted };
|
|
3986
|
+
for (const [knownKey, knownSchema] of knownEntries)
|
|
3987
|
+
if (knownKey in knownProperties) {
|
|
3988
|
+
knownProperties[knownKey] = Visit8(knownSchema, references, `${path}/${knownKey}`, knownProperties[knownKey]);
|
|
3989
|
+
}
|
|
3990
|
+
if (!IsTransform(schema.unevaluatedProperties)) {
|
|
3991
|
+
return knownProperties;
|
|
3992
|
+
}
|
|
3993
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
3994
|
+
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
3995
|
+
const properties = { ...knownProperties };
|
|
3996
|
+
for (const key of unknownKeys)
|
|
3997
|
+
if (!knownKeys.includes(key)) {
|
|
3998
|
+
properties[key] = Default2(unevaluatedProperties, `${path}/${key}`, properties[key]);
|
|
3999
|
+
}
|
|
4000
|
+
return properties;
|
|
4001
|
+
}
|
|
4002
|
+
function FromNot5(schema, references, path, value) {
|
|
4003
|
+
return Default2(schema.not, path, Default2(schema, path, value));
|
|
4004
|
+
}
|
|
4005
|
+
function FromObject11(schema, references, path, value) {
|
|
4006
|
+
const defaulted = Default2(schema, path, value);
|
|
4007
|
+
if (!IsObject2(defaulted))
|
|
4008
|
+
return defaulted;
|
|
4009
|
+
const knownKeys = KeyOfPropertyKeys(schema);
|
|
4010
|
+
const knownProperties = { ...defaulted };
|
|
4011
|
+
for (const key of knownKeys) {
|
|
4012
|
+
if (!HasPropertyKey2(knownProperties, key))
|
|
4013
|
+
continue;
|
|
4014
|
+
if (IsUndefined2(knownProperties[key]) && (!IsUndefined3(schema.properties[key]) || TypeSystemPolicy.IsExactOptionalProperty(knownProperties, key)))
|
|
4015
|
+
continue;
|
|
4016
|
+
knownProperties[key] = Visit8(schema.properties[key], references, `${path}/${key}`, knownProperties[key]);
|
|
4017
|
+
}
|
|
4018
|
+
if (!IsSchema(schema.additionalProperties)) {
|
|
4019
|
+
return knownProperties;
|
|
4020
|
+
}
|
|
4021
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
4022
|
+
const additionalProperties = schema.additionalProperties;
|
|
4023
|
+
const properties = { ...knownProperties };
|
|
4024
|
+
for (const key of unknownKeys)
|
|
4025
|
+
if (!knownKeys.includes(key)) {
|
|
4026
|
+
properties[key] = Default2(additionalProperties, `${path}/${key}`, properties[key]);
|
|
4027
|
+
}
|
|
4028
|
+
return properties;
|
|
4029
|
+
}
|
|
4030
|
+
function FromRecord7(schema, references, path, value) {
|
|
4031
|
+
const defaulted = Default2(schema, path, value);
|
|
4032
|
+
if (!IsObject2(value))
|
|
4033
|
+
return defaulted;
|
|
4034
|
+
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
4035
|
+
const knownKeys = new RegExp(pattern);
|
|
4036
|
+
const knownProperties = { ...defaulted };
|
|
4037
|
+
for (const key of Object.getOwnPropertyNames(value))
|
|
4038
|
+
if (knownKeys.test(key)) {
|
|
4039
|
+
knownProperties[key] = Visit8(schema.patternProperties[pattern], references, `${path}/${key}`, knownProperties[key]);
|
|
4040
|
+
}
|
|
4041
|
+
if (!IsSchema(schema.additionalProperties)) {
|
|
4042
|
+
return knownProperties;
|
|
4043
|
+
}
|
|
4044
|
+
const unknownKeys = Object.getOwnPropertyNames(knownProperties);
|
|
4045
|
+
const additionalProperties = schema.additionalProperties;
|
|
4046
|
+
const properties = { ...knownProperties };
|
|
4047
|
+
for (const key of unknownKeys)
|
|
4048
|
+
if (!knownKeys.test(key)) {
|
|
4049
|
+
properties[key] = Default2(additionalProperties, `${path}/${key}`, properties[key]);
|
|
4050
|
+
}
|
|
4051
|
+
return properties;
|
|
4052
|
+
}
|
|
4053
|
+
function FromRef8(schema, references, path, value) {
|
|
4054
|
+
const target = Deref(schema, references);
|
|
4055
|
+
const resolved = Visit8(target, references, path, value);
|
|
4056
|
+
return Default2(schema, path, resolved);
|
|
4057
|
+
}
|
|
4058
|
+
function FromThis4(schema, references, path, value) {
|
|
4059
|
+
const target = Deref(schema, references);
|
|
4060
|
+
const resolved = Visit8(target, references, path, value);
|
|
4061
|
+
return Default2(schema, path, resolved);
|
|
4062
|
+
}
|
|
4063
|
+
function FromTuple9(schema, references, path, value) {
|
|
4064
|
+
const value1 = Default2(schema, path, value);
|
|
4065
|
+
return IsArray2(schema.items) ? schema.items.map((schema2, index) => Visit8(schema2, references, `${path}/${index}`, value1[index])) : [];
|
|
4066
|
+
}
|
|
4067
|
+
function FromUnion14(schema, references, path, value) {
|
|
4068
|
+
for (const subschema of schema.anyOf) {
|
|
4069
|
+
if (!Check(subschema, references, value))
|
|
4070
|
+
continue;
|
|
4071
|
+
const value1 = Visit8(subschema, references, path, value);
|
|
4072
|
+
return Default2(schema, path, value1);
|
|
4073
|
+
}
|
|
4074
|
+
for (const subschema of schema.anyOf) {
|
|
4075
|
+
const value1 = Visit8(subschema, references, path, value);
|
|
4076
|
+
if (!Check(schema, references, value1))
|
|
4077
|
+
continue;
|
|
4078
|
+
return Default2(schema, path, value1);
|
|
4079
|
+
}
|
|
4080
|
+
return Default2(schema, path, value);
|
|
4081
|
+
}
|
|
4082
|
+
function Visit8(schema, references, path, value) {
|
|
4083
|
+
const references_ = Pushref(schema, references);
|
|
4084
|
+
const schema_ = schema;
|
|
4085
|
+
switch (schema[Kind]) {
|
|
4086
|
+
case "Array":
|
|
4087
|
+
return FromArray10(schema_, references_, path, value);
|
|
4088
|
+
case "Import":
|
|
4089
|
+
return FromImport4(schema_, references_, path, value);
|
|
4090
|
+
case "Intersect":
|
|
4091
|
+
return FromIntersect12(schema_, references_, path, value);
|
|
4092
|
+
case "Not":
|
|
4093
|
+
return FromNot5(schema_, references_, path, value);
|
|
4094
|
+
case "Object":
|
|
4095
|
+
return FromObject11(schema_, references_, path, value);
|
|
4096
|
+
case "Record":
|
|
4097
|
+
return FromRecord7(schema_, references_, path, value);
|
|
4098
|
+
case "Ref":
|
|
4099
|
+
return FromRef8(schema_, references_, path, value);
|
|
4100
|
+
case "This":
|
|
4101
|
+
return FromThis4(schema_, references_, path, value);
|
|
4102
|
+
case "Tuple":
|
|
4103
|
+
return FromTuple9(schema_, references_, path, value);
|
|
4104
|
+
case "Union":
|
|
4105
|
+
return FromUnion14(schema_, references_, path, value);
|
|
4106
|
+
default:
|
|
4107
|
+
return Default2(schema_, path, value);
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
function TransformEncode(schema, references, value) {
|
|
4111
|
+
return Visit8(schema, references, "", value);
|
|
4112
|
+
}
|
|
4113
|
+
function FromArray11(schema, references) {
|
|
4114
|
+
return IsTransform(schema) || Visit9(schema.items, references);
|
|
4115
|
+
}
|
|
4116
|
+
function FromAsyncIterator6(schema, references) {
|
|
4117
|
+
return IsTransform(schema) || Visit9(schema.items, references);
|
|
4118
|
+
}
|
|
4119
|
+
function FromConstructor6(schema, references) {
|
|
4120
|
+
return IsTransform(schema) || Visit9(schema.returns, references) || schema.parameters.some((schema2) => Visit9(schema2, references));
|
|
4121
|
+
}
|
|
4122
|
+
function FromFunction6(schema, references) {
|
|
4123
|
+
return IsTransform(schema) || Visit9(schema.returns, references) || schema.parameters.some((schema2) => Visit9(schema2, references));
|
|
4124
|
+
}
|
|
4125
|
+
function FromIntersect13(schema, references) {
|
|
4126
|
+
return IsTransform(schema) || IsTransform(schema.unevaluatedProperties) || schema.allOf.some((schema2) => Visit9(schema2, references));
|
|
4127
|
+
}
|
|
4128
|
+
function FromImport5(schema, references) {
|
|
4129
|
+
const additional = globalThis.Object.getOwnPropertyNames(schema.$defs).reduce((result, key) => [...result, schema.$defs[key]], []);
|
|
4130
|
+
const target = schema.$defs[schema.$ref];
|
|
4131
|
+
return IsTransform(schema) || Visit9(target, [...additional, ...references]);
|
|
4132
|
+
}
|
|
4133
|
+
function FromIterator6(schema, references) {
|
|
4134
|
+
return IsTransform(schema) || Visit9(schema.items, references);
|
|
4135
|
+
}
|
|
4136
|
+
function FromNot6(schema, references) {
|
|
4137
|
+
return IsTransform(schema) || Visit9(schema.not, references);
|
|
4138
|
+
}
|
|
4139
|
+
function FromObject12(schema, references) {
|
|
4140
|
+
return IsTransform(schema) || Object.values(schema.properties).some((schema2) => Visit9(schema2, references)) || IsSchema(schema.additionalProperties) && Visit9(schema.additionalProperties, references);
|
|
4141
|
+
}
|
|
4142
|
+
function FromPromise6(schema, references) {
|
|
4143
|
+
return IsTransform(schema) || Visit9(schema.item, references);
|
|
4144
|
+
}
|
|
4145
|
+
function FromRecord8(schema, references) {
|
|
4146
|
+
const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
|
|
4147
|
+
const property = schema.patternProperties[pattern];
|
|
4148
|
+
return IsTransform(schema) || Visit9(property, references) || IsSchema(schema.additionalProperties) && IsTransform(schema.additionalProperties);
|
|
4149
|
+
}
|
|
4150
|
+
function FromRef9(schema, references) {
|
|
4151
|
+
if (IsTransform(schema))
|
|
4152
|
+
return true;
|
|
4153
|
+
return Visit9(Deref(schema, references), references);
|
|
4154
|
+
}
|
|
4155
|
+
function FromThis5(schema, references) {
|
|
4156
|
+
if (IsTransform(schema))
|
|
4157
|
+
return true;
|
|
4158
|
+
return Visit9(Deref(schema, references), references);
|
|
4159
|
+
}
|
|
4160
|
+
function FromTuple10(schema, references) {
|
|
4161
|
+
return IsTransform(schema) || !IsUndefined2(schema.items) && schema.items.some((schema2) => Visit9(schema2, references));
|
|
4162
|
+
}
|
|
4163
|
+
function FromUnion15(schema, references) {
|
|
4164
|
+
return IsTransform(schema) || schema.anyOf.some((schema2) => Visit9(schema2, references));
|
|
4165
|
+
}
|
|
4166
|
+
function Visit9(schema, references) {
|
|
4167
|
+
const references_ = Pushref(schema, references);
|
|
4168
|
+
const schema_ = schema;
|
|
4169
|
+
if (schema.$id && visited.has(schema.$id))
|
|
4170
|
+
return false;
|
|
4171
|
+
if (schema.$id)
|
|
4172
|
+
visited.add(schema.$id);
|
|
4173
|
+
switch (schema[Kind]) {
|
|
4174
|
+
case "Array":
|
|
4175
|
+
return FromArray11(schema_, references_);
|
|
4176
|
+
case "AsyncIterator":
|
|
4177
|
+
return FromAsyncIterator6(schema_, references_);
|
|
4178
|
+
case "Constructor":
|
|
4179
|
+
return FromConstructor6(schema_, references_);
|
|
4180
|
+
case "Function":
|
|
4181
|
+
return FromFunction6(schema_, references_);
|
|
4182
|
+
case "Import":
|
|
4183
|
+
return FromImport5(schema_, references_);
|
|
4184
|
+
case "Intersect":
|
|
4185
|
+
return FromIntersect13(schema_, references_);
|
|
4186
|
+
case "Iterator":
|
|
4187
|
+
return FromIterator6(schema_, references_);
|
|
4188
|
+
case "Not":
|
|
4189
|
+
return FromNot6(schema_, references_);
|
|
4190
|
+
case "Object":
|
|
4191
|
+
return FromObject12(schema_, references_);
|
|
4192
|
+
case "Promise":
|
|
4193
|
+
return FromPromise6(schema_, references_);
|
|
4194
|
+
case "Record":
|
|
4195
|
+
return FromRecord8(schema_, references_);
|
|
4196
|
+
case "Ref":
|
|
4197
|
+
return FromRef9(schema_, references_);
|
|
4198
|
+
case "This":
|
|
4199
|
+
return FromThis5(schema_, references_);
|
|
4200
|
+
case "Tuple":
|
|
4201
|
+
return FromTuple10(schema_, references_);
|
|
4202
|
+
case "Union":
|
|
4203
|
+
return FromUnion15(schema_, references_);
|
|
4204
|
+
default:
|
|
4205
|
+
return IsTransform(schema);
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
var visited = /* @__PURE__ */ new Set();
|
|
4209
|
+
function HasTransform(schema, references) {
|
|
4210
|
+
visited.clear();
|
|
4211
|
+
return Visit9(schema, references);
|
|
4212
|
+
}
|
|
4213
|
+
var REF_PATTERN = /^e\d+_\d+$/;
|
|
4214
|
+
var DELIVERED_EXTRACT_FORMATS = [
|
|
4215
|
+
"text",
|
|
4216
|
+
"markdown",
|
|
4217
|
+
"links",
|
|
4218
|
+
"tables",
|
|
4219
|
+
"forms",
|
|
4220
|
+
"jsonld",
|
|
4221
|
+
"schema"
|
|
4222
|
+
];
|
|
4223
|
+
var DELIVERED_ACTION_TYPES = [
|
|
4224
|
+
"click",
|
|
4225
|
+
"dblclick",
|
|
4226
|
+
"hover",
|
|
4227
|
+
"fill",
|
|
4228
|
+
"clear",
|
|
4229
|
+
"check",
|
|
4230
|
+
"uncheck",
|
|
4231
|
+
"select",
|
|
4232
|
+
"scroll",
|
|
4233
|
+
"press",
|
|
4234
|
+
"wait",
|
|
4235
|
+
"goBack",
|
|
4236
|
+
"goForward",
|
|
4237
|
+
"reload",
|
|
4238
|
+
"acceptDialog",
|
|
4239
|
+
"dismissDialog"
|
|
4240
|
+
];
|
|
4241
|
+
var ErrorCodeEnum = Type.Union([
|
|
4242
|
+
Type.Literal("INVALID_REQUEST"),
|
|
4243
|
+
Type.Literal("UNAUTHORIZED"),
|
|
4244
|
+
Type.Literal("FORBIDDEN"),
|
|
4245
|
+
Type.Literal("NOT_FOUND"),
|
|
4246
|
+
Type.Literal("POLICY_DENIED"),
|
|
4247
|
+
Type.Literal("APPROVAL_REQUIRED"),
|
|
4248
|
+
Type.Literal("SESSION_NOT_FOUND"),
|
|
4249
|
+
Type.Literal("SESSION_EXPIRED"),
|
|
4250
|
+
Type.Literal("PAGE_NOT_FOUND"),
|
|
4251
|
+
Type.Literal("STALE_TARGET"),
|
|
4252
|
+
Type.Literal("TARGET_NOT_FOUND"),
|
|
4253
|
+
Type.Literal("TARGET_AMBIGUOUS"),
|
|
4254
|
+
Type.Literal("TARGET_NOT_VISIBLE"),
|
|
4255
|
+
Type.Literal("TARGET_DISABLED"),
|
|
4256
|
+
Type.Literal("NAVIGATION_TIMEOUT"),
|
|
4257
|
+
Type.Literal("ACTION_TIMEOUT"),
|
|
4258
|
+
Type.Literal("ENGINE_UNSUPPORTED"),
|
|
4259
|
+
Type.Literal("ENGINE_CRASHED"),
|
|
4260
|
+
Type.Literal("DOWNLOAD_BLOCKED"),
|
|
4261
|
+
Type.Literal("QUOTA_EXCEEDED"),
|
|
4262
|
+
Type.Literal("OUTPUT_TRUNCATED"),
|
|
4263
|
+
Type.Literal("INTERNAL")
|
|
4264
|
+
]);
|
|
4265
|
+
var ApiErrorDetailSchema = Type.Object({
|
|
4266
|
+
code: ErrorCodeEnum,
|
|
4267
|
+
message: Type.String(),
|
|
4268
|
+
retryable: Type.Boolean(),
|
|
4269
|
+
action: Type.Optional(Type.String()),
|
|
4270
|
+
details: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
4271
|
+
traceId: Type.Optional(Type.String())
|
|
4272
|
+
});
|
|
4273
|
+
var ApiErrorSchema = Type.Object({
|
|
4274
|
+
error: ApiErrorDetailSchema
|
|
4275
|
+
});
|
|
4276
|
+
var ViewportSchema = Type.Object({
|
|
4277
|
+
width: Type.Number({ minimum: 1, maximum: 32768 }),
|
|
4278
|
+
height: Type.Number({ minimum: 1, maximum: 32768 })
|
|
4279
|
+
});
|
|
4280
|
+
var EngineTypeSchema = Type.Union([
|
|
4281
|
+
Type.Literal("playwright-chromium"),
|
|
4282
|
+
Type.Literal("auto")
|
|
4283
|
+
]);
|
|
4284
|
+
var ApprovalPolicySchema = Type.Object({
|
|
4285
|
+
transactions: Type.Optional(Type.Union([Type.Literal("allow"), Type.Literal("deny"), Type.Literal("required")])),
|
|
4286
|
+
externalMessages: Type.Optional(Type.Union([Type.Literal("allow"), Type.Literal("deny"), Type.Literal("required")]))
|
|
4287
|
+
});
|
|
4288
|
+
var SessionPolicySchema = Type.Object({
|
|
4289
|
+
allowedHosts: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
4290
|
+
blockedHosts: Type.Optional(Type.Array(Type.String())),
|
|
4291
|
+
allowDownloads: Type.Optional(Type.Boolean()),
|
|
4292
|
+
maxDownloadBytes: Type.Optional(Type.Number({ minimum: 0 })),
|
|
4293
|
+
approval: Type.Optional(ApprovalPolicySchema)
|
|
4294
|
+
});
|
|
4295
|
+
var SessionCookieSchema = Type.Object({
|
|
4296
|
+
name: Type.String({ minLength: 1 }),
|
|
4297
|
+
value: Type.String(),
|
|
4298
|
+
domain: Type.String({ minLength: 1 }),
|
|
4299
|
+
path: Type.String(),
|
|
4300
|
+
expires: Type.Optional(Type.Number()),
|
|
4301
|
+
httpOnly: Type.Optional(Type.Boolean()),
|
|
4302
|
+
secure: Type.Optional(Type.Boolean()),
|
|
4303
|
+
sameSite: Type.Optional(Type.Union([Type.Literal("Strict"), Type.Literal("Lax"), Type.Literal("None")]))
|
|
4304
|
+
});
|
|
4305
|
+
var SessionRequestSchema = Type.Object({
|
|
4306
|
+
tenantId: Type.Optional(Type.String({ minLength: 1 })),
|
|
4307
|
+
// Known engine names plus any registered engine name (TD-BROWSER-7
|
|
4308
|
+
// registry routes arbitrary names; unknown names fail at the service).
|
|
4309
|
+
engine: Type.Optional(Type.Union([EngineTypeSchema, Type.String({ minLength: 1 })])),
|
|
4310
|
+
ttlMs: Type.Optional(Type.Number({ minimum: 1e3, maximum: 864e5 })),
|
|
4311
|
+
idleTimeoutMs: Type.Optional(Type.Number({ minimum: 1e3, maximum: 36e5 })),
|
|
4312
|
+
viewport: Type.Optional(ViewportSchema),
|
|
4313
|
+
locale: Type.Optional(Type.String({ pattern: "^[a-z]{2}-[A-Z]{2}$" })),
|
|
4314
|
+
timezoneId: Type.Optional(Type.String()),
|
|
4315
|
+
headless: Type.Optional(Type.Boolean()),
|
|
4316
|
+
cookies: Type.Optional(Type.Array(SessionCookieSchema)),
|
|
4317
|
+
policy: Type.Optional(SessionPolicySchema)
|
|
4318
|
+
});
|
|
4319
|
+
var ObservationModeSchema = Type.Union([
|
|
4320
|
+
Type.Literal("interactive"),
|
|
4321
|
+
Type.Literal("content"),
|
|
4322
|
+
Type.Literal("accessibility"),
|
|
4323
|
+
Type.Literal("compact_dom"),
|
|
4324
|
+
Type.Literal("visual")
|
|
4325
|
+
]);
|
|
4326
|
+
var ACTION_TYPE_LITERALS = [
|
|
4327
|
+
"navigate",
|
|
4328
|
+
"click",
|
|
4329
|
+
"dblclick",
|
|
4330
|
+
"hover",
|
|
4331
|
+
"fill",
|
|
4332
|
+
"type",
|
|
4333
|
+
"clear",
|
|
4334
|
+
"press",
|
|
4335
|
+
"select",
|
|
4336
|
+
"check",
|
|
4337
|
+
"uncheck",
|
|
4338
|
+
"scroll",
|
|
4339
|
+
"wait",
|
|
4340
|
+
"upload",
|
|
4341
|
+
"download",
|
|
4342
|
+
"goBack",
|
|
4343
|
+
"goForward",
|
|
4344
|
+
"reload",
|
|
4345
|
+
"dismissDialog",
|
|
4346
|
+
"acceptDialog"
|
|
4347
|
+
];
|
|
4348
|
+
var ActionTypeSchema = Type.Union(ACTION_TYPE_LITERALS.map((literal) => Type.Literal(literal)));
|
|
4349
|
+
var EngineCapabilitiesSchema = Type.Object({
|
|
4350
|
+
supportsScreenshots: Type.Boolean(),
|
|
4351
|
+
supportsPdf: Type.Boolean(),
|
|
4352
|
+
supportsDownloads: Type.Boolean(),
|
|
4353
|
+
supportsUploads: Type.Boolean(),
|
|
4354
|
+
supportsJavascript: Type.Boolean(),
|
|
4355
|
+
supportsWebgl: Type.Boolean(),
|
|
4356
|
+
supportsVideo: Type.Boolean(),
|
|
4357
|
+
supportsPersistentStorage: Type.Boolean(),
|
|
4358
|
+
supportsAccessibilityTree: Type.Boolean(),
|
|
4359
|
+
supportsCdp: Type.Boolean(),
|
|
4360
|
+
supportedObservationModes: Type.Array(ObservationModeSchema, { minItems: 1 }),
|
|
4361
|
+
supportedActionTypes: Type.Array(ActionTypeSchema, { minItems: 1 })
|
|
4362
|
+
});
|
|
4363
|
+
var EngineInfoSchema = Type.Object({
|
|
4364
|
+
name: Type.String(),
|
|
4365
|
+
version: Type.String(),
|
|
4366
|
+
capabilities: EngineCapabilitiesSchema
|
|
4367
|
+
});
|
|
4368
|
+
var SessionResponseSchema = Type.Object({
|
|
4369
|
+
sessionId: Type.String({ pattern: "^ses_[a-zA-Z0-9_]+$" }),
|
|
4370
|
+
engine: EngineInfoSchema,
|
|
4371
|
+
createdAt: Type.String(),
|
|
4372
|
+
ttlMs: Type.Number({ minimum: 0 }),
|
|
4373
|
+
idleTimeoutMs: Type.Number({ minimum: 0 })
|
|
4374
|
+
});
|
|
4375
|
+
var ActionEffectSchema = Type.Union([
|
|
4376
|
+
Type.Literal("read"),
|
|
4377
|
+
Type.Literal("write-local"),
|
|
4378
|
+
Type.Literal("external-message"),
|
|
4379
|
+
Type.Literal("transaction"),
|
|
4380
|
+
Type.Literal("account-security"),
|
|
4381
|
+
Type.Literal("destructive")
|
|
4382
|
+
]);
|
|
4383
|
+
var PageStatusSchema = Type.Union([
|
|
4384
|
+
Type.Literal("loading"),
|
|
4385
|
+
Type.Literal("interactive"),
|
|
4386
|
+
Type.Literal("complete")
|
|
4387
|
+
]);
|
|
4388
|
+
var PageElementSchema = Type.Object({
|
|
4389
|
+
ref: Type.String({ pattern: REF_PATTERN.source }),
|
|
4390
|
+
role: Type.String(),
|
|
4391
|
+
name: Type.Optional(Type.String()),
|
|
4392
|
+
value: Type.Optional(Type.String()),
|
|
4393
|
+
required: Type.Optional(Type.Boolean()),
|
|
4394
|
+
visible: Type.Boolean(),
|
|
4395
|
+
enabled: Type.Boolean(),
|
|
4396
|
+
focused: Type.Optional(Type.Boolean()),
|
|
4397
|
+
risk: Type.Optional(ActionEffectSchema)
|
|
4398
|
+
});
|
|
4399
|
+
var ElementChangeSchema = Type.Object({
|
|
4400
|
+
ref: Type.String(),
|
|
4401
|
+
change: Type.Union([Type.Literal("added"), Type.Literal("removed"), Type.Literal("modified")]),
|
|
4402
|
+
properties: Type.Record(Type.String(), Type.Object({
|
|
4403
|
+
old: Type.Unknown(),
|
|
4404
|
+
new: Type.Unknown()
|
|
4405
|
+
}))
|
|
4406
|
+
});
|
|
4407
|
+
var ContinuationCursorSchema = Type.Object({
|
|
4408
|
+
nextOrdinal: Type.Integer({ minimum: 0 }),
|
|
4409
|
+
remaining: Type.Integer({ minimum: 0 })
|
|
4410
|
+
});
|
|
4411
|
+
var PageStateSchema = Type.Object({
|
|
2554
4412
|
sessionId: Type.String(),
|
|
2555
4413
|
pageId: Type.String(),
|
|
2556
4414
|
revision: Type.Integer({ minimum: 1 }),
|
|
@@ -2567,7 +4425,7 @@ var PageStateSchema = Type.Object({
|
|
|
2567
4425
|
continuation: Type.Optional(ContinuationCursorSchema)
|
|
2568
4426
|
});
|
|
2569
4427
|
var ElementTargetSchema = Type.Object({
|
|
2570
|
-
ref: Type.String({ pattern:
|
|
4428
|
+
ref: Type.String({ pattern: REF_PATTERN.source })
|
|
2571
4429
|
});
|
|
2572
4430
|
var NavigateActionSchema = Type.Object({
|
|
2573
4431
|
type: Type.Literal("navigate"),
|
|
@@ -2637,14 +4495,60 @@ var WaitActionSchema = Type.Object({
|
|
|
2637
4495
|
type: Type.Literal("wait"),
|
|
2638
4496
|
condition: WaitConditionSchema
|
|
2639
4497
|
});
|
|
4498
|
+
var HoverActionSchema = Type.Object({
|
|
4499
|
+
type: Type.Literal("hover"),
|
|
4500
|
+
target: ElementTargetSchema
|
|
4501
|
+
});
|
|
4502
|
+
var DblClickActionSchema = Type.Object({
|
|
4503
|
+
type: Type.Literal("dblclick"),
|
|
4504
|
+
target: ElementTargetSchema
|
|
4505
|
+
});
|
|
4506
|
+
var ClearActionSchema = Type.Object({
|
|
4507
|
+
type: Type.Literal("clear"),
|
|
4508
|
+
target: ElementTargetSchema
|
|
4509
|
+
});
|
|
4510
|
+
var CheckActionSchema = Type.Object({
|
|
4511
|
+
type: Type.Literal("check"),
|
|
4512
|
+
target: ElementTargetSchema
|
|
4513
|
+
});
|
|
4514
|
+
var UncheckActionSchema = Type.Object({
|
|
4515
|
+
type: Type.Literal("uncheck"),
|
|
4516
|
+
target: ElementTargetSchema
|
|
4517
|
+
});
|
|
4518
|
+
var GoBackActionSchema = Type.Object({
|
|
4519
|
+
type: Type.Literal("goBack")
|
|
4520
|
+
});
|
|
4521
|
+
var GoForwardActionSchema = Type.Object({
|
|
4522
|
+
type: Type.Literal("goForward")
|
|
4523
|
+
});
|
|
4524
|
+
var ReloadActionSchema = Type.Object({
|
|
4525
|
+
type: Type.Literal("reload")
|
|
4526
|
+
});
|
|
4527
|
+
var AcceptDialogActionSchema = Type.Object({
|
|
4528
|
+
type: Type.Literal("acceptDialog"),
|
|
4529
|
+
promptText: Type.Optional(Type.String())
|
|
4530
|
+
});
|
|
4531
|
+
var DismissDialogActionSchema = Type.Object({
|
|
4532
|
+
type: Type.Literal("dismissDialog")
|
|
4533
|
+
});
|
|
2640
4534
|
var ActionSchema = Type.Union([
|
|
2641
4535
|
NavigateActionSchema,
|
|
2642
4536
|
ClickActionSchema,
|
|
4537
|
+
DblClickActionSchema,
|
|
4538
|
+
HoverActionSchema,
|
|
2643
4539
|
FillActionSchema,
|
|
4540
|
+
ClearActionSchema,
|
|
4541
|
+
CheckActionSchema,
|
|
4542
|
+
UncheckActionSchema,
|
|
2644
4543
|
SelectActionSchema,
|
|
2645
4544
|
ScrollActionSchema,
|
|
2646
4545
|
PressActionSchema,
|
|
2647
|
-
WaitActionSchema
|
|
4546
|
+
WaitActionSchema,
|
|
4547
|
+
GoBackActionSchema,
|
|
4548
|
+
GoForwardActionSchema,
|
|
4549
|
+
ReloadActionSchema,
|
|
4550
|
+
AcceptDialogActionSchema,
|
|
4551
|
+
DismissDialogActionSchema
|
|
2648
4552
|
]);
|
|
2649
4553
|
var ObservationRequestSchema = Type.Object({
|
|
2650
4554
|
mode: Type.Optional(ObservationModeSchema),
|
|
@@ -2712,6 +4616,569 @@ var ActionResultSchema = Type.Object({
|
|
|
2712
4616
|
artifacts: Type.Optional(Type.Array(ArtifactRefSchema)),
|
|
2713
4617
|
error: Type.Optional(ApiErrorDetailSchema)
|
|
2714
4618
|
});
|
|
4619
|
+
var TypeCheck = class {
|
|
4620
|
+
constructor(schema, references, checkFunc, code) {
|
|
4621
|
+
this.schema = schema;
|
|
4622
|
+
this.references = references;
|
|
4623
|
+
this.checkFunc = checkFunc;
|
|
4624
|
+
this.code = code;
|
|
4625
|
+
this.hasTransform = HasTransform(schema, references);
|
|
4626
|
+
}
|
|
4627
|
+
/** Returns the generated assertion code used to validate this type. */
|
|
4628
|
+
Code() {
|
|
4629
|
+
return this.code;
|
|
4630
|
+
}
|
|
4631
|
+
/** Returns the schema type used to validate */
|
|
4632
|
+
Schema() {
|
|
4633
|
+
return this.schema;
|
|
4634
|
+
}
|
|
4635
|
+
/** Returns reference types used to validate */
|
|
4636
|
+
References() {
|
|
4637
|
+
return this.references;
|
|
4638
|
+
}
|
|
4639
|
+
/** Returns an iterator for each error in this value. */
|
|
4640
|
+
Errors(value) {
|
|
4641
|
+
return Errors(this.schema, this.references, value);
|
|
4642
|
+
}
|
|
4643
|
+
/** Returns true if the value matches the compiled type. */
|
|
4644
|
+
Check(value) {
|
|
4645
|
+
return this.checkFunc(value);
|
|
4646
|
+
}
|
|
4647
|
+
/** Decodes a value or throws if error */
|
|
4648
|
+
Decode(value) {
|
|
4649
|
+
if (!this.checkFunc(value))
|
|
4650
|
+
throw new TransformDecodeCheckError(this.schema, value, this.Errors(value).First());
|
|
4651
|
+
return this.hasTransform ? TransformDecode(this.schema, this.references, value) : value;
|
|
4652
|
+
}
|
|
4653
|
+
/** Encodes a value or throws if error */
|
|
4654
|
+
Encode(value) {
|
|
4655
|
+
const encoded = this.hasTransform ? TransformEncode(this.schema, this.references, value) : value;
|
|
4656
|
+
if (!this.checkFunc(encoded))
|
|
4657
|
+
throw new TransformEncodeCheckError(this.schema, value, this.Errors(value).First());
|
|
4658
|
+
return encoded;
|
|
4659
|
+
}
|
|
4660
|
+
};
|
|
4661
|
+
var Character;
|
|
4662
|
+
(function(Character2) {
|
|
4663
|
+
function DollarSign(code) {
|
|
4664
|
+
return code === 36;
|
|
4665
|
+
}
|
|
4666
|
+
Character2.DollarSign = DollarSign;
|
|
4667
|
+
function IsUnderscore(code) {
|
|
4668
|
+
return code === 95;
|
|
4669
|
+
}
|
|
4670
|
+
Character2.IsUnderscore = IsUnderscore;
|
|
4671
|
+
function IsAlpha(code) {
|
|
4672
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
4673
|
+
}
|
|
4674
|
+
Character2.IsAlpha = IsAlpha;
|
|
4675
|
+
function IsNumeric(code) {
|
|
4676
|
+
return code >= 48 && code <= 57;
|
|
4677
|
+
}
|
|
4678
|
+
Character2.IsNumeric = IsNumeric;
|
|
4679
|
+
})(Character || (Character = {}));
|
|
4680
|
+
var Identifier;
|
|
4681
|
+
(function(Identifier2) {
|
|
4682
|
+
function Encode($id) {
|
|
4683
|
+
const buffer = [];
|
|
4684
|
+
for (let i = 0; i < $id.length; i++) {
|
|
4685
|
+
const code = $id.charCodeAt(i);
|
|
4686
|
+
if (Character.IsNumeric(code) || Character.IsAlpha(code)) {
|
|
4687
|
+
buffer.push($id.charAt(i));
|
|
4688
|
+
} else {
|
|
4689
|
+
buffer.push(`_${code}_`);
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
return buffer.join("").replace(/__/g, "_");
|
|
4693
|
+
}
|
|
4694
|
+
Identifier2.Encode = Encode;
|
|
4695
|
+
})(Identifier || (Identifier = {}));
|
|
4696
|
+
function StringConstant(value) {
|
|
4697
|
+
if (!IsString2(value))
|
|
4698
|
+
throw Error("ConstantString: Not a String");
|
|
4699
|
+
const canonical = JSON.stringify(value).slice(1, -1);
|
|
4700
|
+
const escaped = canonical.replace(/'/g, "\\'");
|
|
4701
|
+
return `'${escaped}'`;
|
|
4702
|
+
}
|
|
4703
|
+
function MemberExpression(value, key) {
|
|
4704
|
+
return `${value}[${StringConstant(key)}]`;
|
|
4705
|
+
}
|
|
4706
|
+
var TypeCompilerUnknownTypeError = class extends TypeBoxError {
|
|
4707
|
+
constructor(schema) {
|
|
4708
|
+
super("Unknown type");
|
|
4709
|
+
this.schema = schema;
|
|
4710
|
+
}
|
|
4711
|
+
};
|
|
4712
|
+
var TypeCompilerTypeGuardError = class extends TypeBoxError {
|
|
4713
|
+
constructor(schema) {
|
|
4714
|
+
super("Preflight validation check failed to guard for the given schema");
|
|
4715
|
+
this.schema = schema;
|
|
4716
|
+
}
|
|
4717
|
+
};
|
|
4718
|
+
var Policy;
|
|
4719
|
+
(function(Policy2) {
|
|
4720
|
+
function IsExactOptionalProperty(value, key, expression) {
|
|
4721
|
+
return TypeSystemPolicy.ExactOptionalPropertyTypes ? `(${StringConstant(key)} in ${value} ? ${expression} : true)` : `(${MemberExpression(value, key)} !== undefined ? ${expression} : true)`;
|
|
4722
|
+
}
|
|
4723
|
+
Policy2.IsExactOptionalProperty = IsExactOptionalProperty;
|
|
4724
|
+
function IsObjectLike(value) {
|
|
4725
|
+
return !TypeSystemPolicy.AllowArrayObject ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}))` : `(typeof ${value} === 'object' && ${value} !== null)`;
|
|
4726
|
+
}
|
|
4727
|
+
Policy2.IsObjectLike = IsObjectLike;
|
|
4728
|
+
function IsRecordLike(value) {
|
|
4729
|
+
return !TypeSystemPolicy.AllowArrayObject ? `(typeof ${value} === 'object' && ${value} !== null && !Array.isArray(${value}) && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))` : `(typeof ${value} === 'object' && ${value} !== null && !(${value} instanceof Date) && !(${value} instanceof Uint8Array))`;
|
|
4730
|
+
}
|
|
4731
|
+
Policy2.IsRecordLike = IsRecordLike;
|
|
4732
|
+
function IsNumberLike(value) {
|
|
4733
|
+
return TypeSystemPolicy.AllowNaN ? `typeof ${value} === 'number'` : `Number.isFinite(${value})`;
|
|
4734
|
+
}
|
|
4735
|
+
Policy2.IsNumberLike = IsNumberLike;
|
|
4736
|
+
function IsVoidLike(value) {
|
|
4737
|
+
return TypeSystemPolicy.AllowNullVoid ? `(${value} === undefined || ${value} === null)` : `${value} === undefined`;
|
|
4738
|
+
}
|
|
4739
|
+
Policy2.IsVoidLike = IsVoidLike;
|
|
4740
|
+
})(Policy || (Policy = {}));
|
|
4741
|
+
var TypeCompiler;
|
|
4742
|
+
(function(TypeCompiler2) {
|
|
4743
|
+
function IsAnyOrUnknown2(schema) {
|
|
4744
|
+
return schema[Kind] === "Any" || schema[Kind] === "Unknown";
|
|
4745
|
+
}
|
|
4746
|
+
function* FromAny4(schema, references, value) {
|
|
4747
|
+
yield "true";
|
|
4748
|
+
}
|
|
4749
|
+
function* FromArgument4(schema, references, value) {
|
|
4750
|
+
yield "true";
|
|
4751
|
+
}
|
|
4752
|
+
function* FromArray12(schema, references, value) {
|
|
4753
|
+
yield `Array.isArray(${value})`;
|
|
4754
|
+
const [parameter, accumulator] = [CreateParameter("value", "any"), CreateParameter("acc", "number")];
|
|
4755
|
+
if (IsNumber2(schema.maxItems))
|
|
4756
|
+
yield `${value}.length <= ${schema.maxItems}`;
|
|
4757
|
+
if (IsNumber2(schema.minItems))
|
|
4758
|
+
yield `${value}.length >= ${schema.minItems}`;
|
|
4759
|
+
const elementExpression = CreateExpression(schema.items, references, "value");
|
|
4760
|
+
yield `((array) => { for(const ${parameter} of array) if(!(${elementExpression})) { return false }; return true; })(${value})`;
|
|
4761
|
+
if (IsSchema2(schema.contains) || IsNumber2(schema.minContains) || IsNumber2(schema.maxContains)) {
|
|
4762
|
+
const containsSchema = IsSchema2(schema.contains) ? schema.contains : Never();
|
|
4763
|
+
const checkExpression = CreateExpression(containsSchema, references, "value");
|
|
4764
|
+
const checkMinContains = IsNumber2(schema.minContains) ? [`(count >= ${schema.minContains})`] : [];
|
|
4765
|
+
const checkMaxContains = IsNumber2(schema.maxContains) ? [`(count <= ${schema.maxContains})`] : [];
|
|
4766
|
+
const checkCount = `const count = value.reduce((${accumulator}, ${parameter}) => ${checkExpression} ? acc + 1 : acc, 0)`;
|
|
4767
|
+
const check = [`(count > 0)`, ...checkMinContains, ...checkMaxContains].join(" && ");
|
|
4768
|
+
yield `((${parameter}) => { ${checkCount}; return ${check}})(${value})`;
|
|
4769
|
+
}
|
|
4770
|
+
if (schema.uniqueItems === true) {
|
|
4771
|
+
const check = `const hashed = hash(element); if(set.has(hashed)) { return false } else { set.add(hashed) } } return true`;
|
|
4772
|
+
const block = `const set = new Set(); for(const element of value) { ${check} }`;
|
|
4773
|
+
yield `((${parameter}) => { ${block} )(${value})`;
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
function* FromAsyncIterator7(schema, references, value) {
|
|
4777
|
+
yield `(typeof value === 'object' && Symbol.asyncIterator in ${value})`;
|
|
4778
|
+
}
|
|
4779
|
+
function* FromBigInt4(schema, references, value) {
|
|
4780
|
+
yield `(typeof ${value} === 'bigint')`;
|
|
4781
|
+
if (IsBigInt2(schema.exclusiveMaximum))
|
|
4782
|
+
yield `${value} < BigInt(${schema.exclusiveMaximum})`;
|
|
4783
|
+
if (IsBigInt2(schema.exclusiveMinimum))
|
|
4784
|
+
yield `${value} > BigInt(${schema.exclusiveMinimum})`;
|
|
4785
|
+
if (IsBigInt2(schema.maximum))
|
|
4786
|
+
yield `${value} <= BigInt(${schema.maximum})`;
|
|
4787
|
+
if (IsBigInt2(schema.minimum))
|
|
4788
|
+
yield `${value} >= BigInt(${schema.minimum})`;
|
|
4789
|
+
if (IsBigInt2(schema.multipleOf))
|
|
4790
|
+
yield `(${value} % BigInt(${schema.multipleOf})) === 0`;
|
|
4791
|
+
}
|
|
4792
|
+
function* FromBoolean4(schema, references, value) {
|
|
4793
|
+
yield `(typeof ${value} === 'boolean')`;
|
|
4794
|
+
}
|
|
4795
|
+
function* FromConstructor7(schema, references, value) {
|
|
4796
|
+
yield* Visit10(schema.returns, references, `${value}.prototype`);
|
|
4797
|
+
}
|
|
4798
|
+
function* FromDate4(schema, references, value) {
|
|
4799
|
+
yield `(${value} instanceof Date) && Number.isFinite(${value}.getTime())`;
|
|
4800
|
+
if (IsNumber2(schema.exclusiveMaximumTimestamp))
|
|
4801
|
+
yield `${value}.getTime() < ${schema.exclusiveMaximumTimestamp}`;
|
|
4802
|
+
if (IsNumber2(schema.exclusiveMinimumTimestamp))
|
|
4803
|
+
yield `${value}.getTime() > ${schema.exclusiveMinimumTimestamp}`;
|
|
4804
|
+
if (IsNumber2(schema.maximumTimestamp))
|
|
4805
|
+
yield `${value}.getTime() <= ${schema.maximumTimestamp}`;
|
|
4806
|
+
if (IsNumber2(schema.minimumTimestamp))
|
|
4807
|
+
yield `${value}.getTime() >= ${schema.minimumTimestamp}`;
|
|
4808
|
+
if (IsNumber2(schema.multipleOfTimestamp))
|
|
4809
|
+
yield `(${value}.getTime() % ${schema.multipleOfTimestamp}) === 0`;
|
|
4810
|
+
}
|
|
4811
|
+
function* FromFunction7(schema, references, value) {
|
|
4812
|
+
yield `(typeof ${value} === 'function')`;
|
|
4813
|
+
}
|
|
4814
|
+
function* FromImport6(schema, references, value) {
|
|
4815
|
+
const members = globalThis.Object.getOwnPropertyNames(schema.$defs).reduce((result, key) => {
|
|
4816
|
+
return [...result, schema.$defs[key]];
|
|
4817
|
+
}, []);
|
|
4818
|
+
yield* Visit10(Ref(schema.$ref), [...references, ...members], value);
|
|
4819
|
+
}
|
|
4820
|
+
function* FromInteger4(schema, references, value) {
|
|
4821
|
+
yield `Number.isInteger(${value})`;
|
|
4822
|
+
if (IsNumber2(schema.exclusiveMaximum))
|
|
4823
|
+
yield `${value} < ${schema.exclusiveMaximum}`;
|
|
4824
|
+
if (IsNumber2(schema.exclusiveMinimum))
|
|
4825
|
+
yield `${value} > ${schema.exclusiveMinimum}`;
|
|
4826
|
+
if (IsNumber2(schema.maximum))
|
|
4827
|
+
yield `${value} <= ${schema.maximum}`;
|
|
4828
|
+
if (IsNumber2(schema.minimum))
|
|
4829
|
+
yield `${value} >= ${schema.minimum}`;
|
|
4830
|
+
if (IsNumber2(schema.multipleOf))
|
|
4831
|
+
yield `(${value} % ${schema.multipleOf}) === 0`;
|
|
4832
|
+
}
|
|
4833
|
+
function* FromIntersect14(schema, references, value) {
|
|
4834
|
+
const check1 = schema.allOf.map((schema2) => CreateExpression(schema2, references, value)).join(" && ");
|
|
4835
|
+
if (schema.unevaluatedProperties === false) {
|
|
4836
|
+
const keyCheck = CreateVariable(`${new RegExp(KeyOfPattern(schema))};`);
|
|
4837
|
+
const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key))`;
|
|
4838
|
+
yield `(${check1} && ${check2})`;
|
|
4839
|
+
} else if (IsSchema2(schema.unevaluatedProperties)) {
|
|
4840
|
+
const keyCheck = CreateVariable(`${new RegExp(KeyOfPattern(schema))};`);
|
|
4841
|
+
const check2 = `Object.getOwnPropertyNames(${value}).every(key => ${keyCheck}.test(key) || ${CreateExpression(schema.unevaluatedProperties, references, `${value}[key]`)})`;
|
|
4842
|
+
yield `(${check1} && ${check2})`;
|
|
4843
|
+
} else {
|
|
4844
|
+
yield `(${check1})`;
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
function* FromIterator7(schema, references, value) {
|
|
4848
|
+
yield `(typeof value === 'object' && Symbol.iterator in ${value})`;
|
|
4849
|
+
}
|
|
4850
|
+
function* FromLiteral5(schema, references, value) {
|
|
4851
|
+
if (typeof schema.const === "number" || typeof schema.const === "boolean") {
|
|
4852
|
+
yield `(${value} === ${schema.const})`;
|
|
4853
|
+
} else if (typeof schema.const === "string") {
|
|
4854
|
+
yield `(${value} === ${StringConstant(schema.const)})`;
|
|
4855
|
+
} else {
|
|
4856
|
+
throw Error("Invalid Literal Value");
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
function* FromNever4(schema, references, value) {
|
|
4860
|
+
yield `false`;
|
|
4861
|
+
}
|
|
4862
|
+
function* FromNot7(schema, references, value) {
|
|
4863
|
+
const expression = CreateExpression(schema.not, references, value);
|
|
4864
|
+
yield `(!${expression})`;
|
|
4865
|
+
}
|
|
4866
|
+
function* FromNull4(schema, references, value) {
|
|
4867
|
+
yield `(${value} === null)`;
|
|
4868
|
+
}
|
|
4869
|
+
function* FromNumber4(schema, references, value) {
|
|
4870
|
+
yield Policy.IsNumberLike(value);
|
|
4871
|
+
if (IsNumber2(schema.exclusiveMaximum))
|
|
4872
|
+
yield `${value} < ${schema.exclusiveMaximum}`;
|
|
4873
|
+
if (IsNumber2(schema.exclusiveMinimum))
|
|
4874
|
+
yield `${value} > ${schema.exclusiveMinimum}`;
|
|
4875
|
+
if (IsNumber2(schema.maximum))
|
|
4876
|
+
yield `${value} <= ${schema.maximum}`;
|
|
4877
|
+
if (IsNumber2(schema.minimum))
|
|
4878
|
+
yield `${value} >= ${schema.minimum}`;
|
|
4879
|
+
if (IsNumber2(schema.multipleOf))
|
|
4880
|
+
yield `(${value} % ${schema.multipleOf}) === 0`;
|
|
4881
|
+
}
|
|
4882
|
+
function* FromObject13(schema, references, value) {
|
|
4883
|
+
yield Policy.IsObjectLike(value);
|
|
4884
|
+
if (IsNumber2(schema.minProperties))
|
|
4885
|
+
yield `Object.getOwnPropertyNames(${value}).length >= ${schema.minProperties}`;
|
|
4886
|
+
if (IsNumber2(schema.maxProperties))
|
|
4887
|
+
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
4888
|
+
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
4889
|
+
for (const knownKey of knownKeys) {
|
|
4890
|
+
const memberExpression = MemberExpression(value, knownKey);
|
|
4891
|
+
const property = schema.properties[knownKey];
|
|
4892
|
+
if (schema.required && schema.required.includes(knownKey)) {
|
|
4893
|
+
yield* Visit10(property, references, memberExpression);
|
|
4894
|
+
if (ExtendsUndefinedCheck(property) || IsAnyOrUnknown2(property))
|
|
4895
|
+
yield `(${StringConstant(knownKey)} in ${value})`;
|
|
4896
|
+
} else {
|
|
4897
|
+
const expression = CreateExpression(property, references, memberExpression);
|
|
4898
|
+
yield Policy.IsExactOptionalProperty(value, knownKey, expression);
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
if (schema.additionalProperties === false) {
|
|
4902
|
+
if (schema.required && schema.required.length === knownKeys.length) {
|
|
4903
|
+
yield `Object.getOwnPropertyNames(${value}).length === ${knownKeys.length}`;
|
|
4904
|
+
} else {
|
|
4905
|
+
const keys = `[${knownKeys.map((key) => `${StringConstant(key)}`).join(", ")}]`;
|
|
4906
|
+
yield `Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key))`;
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4909
|
+
if (typeof schema.additionalProperties === "object") {
|
|
4910
|
+
const expression = CreateExpression(schema.additionalProperties, references, `${value}[key]`);
|
|
4911
|
+
const keys = `[${knownKeys.map((key) => `${StringConstant(key)}`).join(", ")}]`;
|
|
4912
|
+
yield `(Object.getOwnPropertyNames(${value}).every(key => ${keys}.includes(key) || ${expression}))`;
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
function* FromPromise7(schema, references, value) {
|
|
4916
|
+
yield `${value} instanceof Promise`;
|
|
4917
|
+
}
|
|
4918
|
+
function* FromRecord9(schema, references, value) {
|
|
4919
|
+
yield Policy.IsRecordLike(value);
|
|
4920
|
+
if (IsNumber2(schema.minProperties))
|
|
4921
|
+
yield `Object.getOwnPropertyNames(${value}).length >= ${schema.minProperties}`;
|
|
4922
|
+
if (IsNumber2(schema.maxProperties))
|
|
4923
|
+
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
4924
|
+
const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
|
|
4925
|
+
const variable = CreateVariable(`${new RegExp(patternKey)}`);
|
|
4926
|
+
const check1 = CreateExpression(patternSchema, references, "value");
|
|
4927
|
+
const check2 = IsSchema2(schema.additionalProperties) ? CreateExpression(schema.additionalProperties, references, value) : schema.additionalProperties === false ? "false" : "true";
|
|
4928
|
+
const expression = `(${variable}.test(key) ? ${check1} : ${check2})`;
|
|
4929
|
+
yield `(Object.entries(${value}).every(([key, value]) => ${expression}))`;
|
|
4930
|
+
}
|
|
4931
|
+
function* FromRef10(schema, references, value) {
|
|
4932
|
+
const target = Deref(schema, references);
|
|
4933
|
+
if (state.functions.has(schema.$ref))
|
|
4934
|
+
return yield `${CreateFunctionName(schema.$ref)}(${value})`;
|
|
4935
|
+
yield* Visit10(target, references, value);
|
|
4936
|
+
}
|
|
4937
|
+
function* FromRegExp4(schema, references, value) {
|
|
4938
|
+
const variable = CreateVariable(`${new RegExp(schema.source, schema.flags)};`);
|
|
4939
|
+
yield `(typeof ${value} === 'string')`;
|
|
4940
|
+
if (IsNumber2(schema.maxLength))
|
|
4941
|
+
yield `${value}.length <= ${schema.maxLength}`;
|
|
4942
|
+
if (IsNumber2(schema.minLength))
|
|
4943
|
+
yield `${value}.length >= ${schema.minLength}`;
|
|
4944
|
+
yield `${variable}.test(${value})`;
|
|
4945
|
+
}
|
|
4946
|
+
function* FromString4(schema, references, value) {
|
|
4947
|
+
yield `(typeof ${value} === 'string')`;
|
|
4948
|
+
if (IsNumber2(schema.maxLength))
|
|
4949
|
+
yield `${value}.length <= ${schema.maxLength}`;
|
|
4950
|
+
if (IsNumber2(schema.minLength))
|
|
4951
|
+
yield `${value}.length >= ${schema.minLength}`;
|
|
4952
|
+
if (schema.pattern !== void 0) {
|
|
4953
|
+
const variable = CreateVariable(`${new RegExp(schema.pattern)};`);
|
|
4954
|
+
yield `${variable}.test(${value})`;
|
|
4955
|
+
}
|
|
4956
|
+
if (schema.format !== void 0) {
|
|
4957
|
+
yield `format(${StringConstant(schema.format)}, ${value})`;
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
4960
|
+
function* FromSymbol4(schema, references, value) {
|
|
4961
|
+
yield `(typeof ${value} === 'symbol')`;
|
|
4962
|
+
}
|
|
4963
|
+
function* FromTemplateLiteral6(schema, references, value) {
|
|
4964
|
+
yield `(typeof ${value} === 'string')`;
|
|
4965
|
+
const variable = CreateVariable(`${new RegExp(schema.pattern)};`);
|
|
4966
|
+
yield `${variable}.test(${value})`;
|
|
4967
|
+
}
|
|
4968
|
+
function* FromThis6(schema, references, value) {
|
|
4969
|
+
yield `${CreateFunctionName(schema.$ref)}(${value})`;
|
|
4970
|
+
}
|
|
4971
|
+
function* FromTuple11(schema, references, value) {
|
|
4972
|
+
yield `Array.isArray(${value})`;
|
|
4973
|
+
if (schema.items === void 0)
|
|
4974
|
+
return yield `${value}.length === 0`;
|
|
4975
|
+
yield `(${value}.length === ${schema.maxItems})`;
|
|
4976
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
4977
|
+
const expression = CreateExpression(schema.items[i], references, `${value}[${i}]`);
|
|
4978
|
+
yield `${expression}`;
|
|
4979
|
+
}
|
|
4980
|
+
}
|
|
4981
|
+
function* FromUndefined4(schema, references, value) {
|
|
4982
|
+
yield `${value} === undefined`;
|
|
4983
|
+
}
|
|
4984
|
+
function* FromUnion16(schema, references, value) {
|
|
4985
|
+
const expressions = schema.anyOf.map((schema2) => CreateExpression(schema2, references, value));
|
|
4986
|
+
yield `(${expressions.join(" || ")})`;
|
|
4987
|
+
}
|
|
4988
|
+
function* FromUint8Array4(schema, references, value) {
|
|
4989
|
+
yield `${value} instanceof Uint8Array`;
|
|
4990
|
+
if (IsNumber2(schema.maxByteLength))
|
|
4991
|
+
yield `(${value}.length <= ${schema.maxByteLength})`;
|
|
4992
|
+
if (IsNumber2(schema.minByteLength))
|
|
4993
|
+
yield `(${value}.length >= ${schema.minByteLength})`;
|
|
4994
|
+
}
|
|
4995
|
+
function* FromUnknown4(schema, references, value) {
|
|
4996
|
+
yield "true";
|
|
4997
|
+
}
|
|
4998
|
+
function* FromVoid4(schema, references, value) {
|
|
4999
|
+
yield Policy.IsVoidLike(value);
|
|
5000
|
+
}
|
|
5001
|
+
function* FromKind3(schema, references, value) {
|
|
5002
|
+
const instance = state.instances.size;
|
|
5003
|
+
state.instances.set(instance, schema);
|
|
5004
|
+
yield `kind(${StringConstant(schema[Kind])}, ${instance}, ${value})`;
|
|
5005
|
+
}
|
|
5006
|
+
function* Visit10(schema, references, value, useHoisting = true) {
|
|
5007
|
+
const references_ = IsString2(schema.$id) ? [...references, schema] : references;
|
|
5008
|
+
const schema_ = schema;
|
|
5009
|
+
if (useHoisting && IsString2(schema.$id)) {
|
|
5010
|
+
const functionName = CreateFunctionName(schema.$id);
|
|
5011
|
+
if (state.functions.has(functionName)) {
|
|
5012
|
+
return yield `${functionName}(${value})`;
|
|
5013
|
+
} else {
|
|
5014
|
+
state.functions.set(functionName, "<deferred>");
|
|
5015
|
+
const functionCode = CreateFunction(functionName, schema, references, "value", false);
|
|
5016
|
+
state.functions.set(functionName, functionCode);
|
|
5017
|
+
return yield `${functionName}(${value})`;
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
5020
|
+
switch (schema_[Kind]) {
|
|
5021
|
+
case "Any":
|
|
5022
|
+
return yield* FromAny4(schema_, references_, value);
|
|
5023
|
+
case "Argument":
|
|
5024
|
+
return yield* FromArgument4(schema_, references_, value);
|
|
5025
|
+
case "Array":
|
|
5026
|
+
return yield* FromArray12(schema_, references_, value);
|
|
5027
|
+
case "AsyncIterator":
|
|
5028
|
+
return yield* FromAsyncIterator7(schema_, references_, value);
|
|
5029
|
+
case "BigInt":
|
|
5030
|
+
return yield* FromBigInt4(schema_, references_, value);
|
|
5031
|
+
case "Boolean":
|
|
5032
|
+
return yield* FromBoolean4(schema_, references_, value);
|
|
5033
|
+
case "Constructor":
|
|
5034
|
+
return yield* FromConstructor7(schema_, references_, value);
|
|
5035
|
+
case "Date":
|
|
5036
|
+
return yield* FromDate4(schema_, references_, value);
|
|
5037
|
+
case "Function":
|
|
5038
|
+
return yield* FromFunction7(schema_, references_, value);
|
|
5039
|
+
case "Import":
|
|
5040
|
+
return yield* FromImport6(schema_, references_, value);
|
|
5041
|
+
case "Integer":
|
|
5042
|
+
return yield* FromInteger4(schema_, references_, value);
|
|
5043
|
+
case "Intersect":
|
|
5044
|
+
return yield* FromIntersect14(schema_, references_, value);
|
|
5045
|
+
case "Iterator":
|
|
5046
|
+
return yield* FromIterator7(schema_, references_, value);
|
|
5047
|
+
case "Literal":
|
|
5048
|
+
return yield* FromLiteral5(schema_, references_, value);
|
|
5049
|
+
case "Never":
|
|
5050
|
+
return yield* FromNever4(schema_, references_, value);
|
|
5051
|
+
case "Not":
|
|
5052
|
+
return yield* FromNot7(schema_, references_, value);
|
|
5053
|
+
case "Null":
|
|
5054
|
+
return yield* FromNull4(schema_, references_, value);
|
|
5055
|
+
case "Number":
|
|
5056
|
+
return yield* FromNumber4(schema_, references_, value);
|
|
5057
|
+
case "Object":
|
|
5058
|
+
return yield* FromObject13(schema_, references_, value);
|
|
5059
|
+
case "Promise":
|
|
5060
|
+
return yield* FromPromise7(schema_, references_, value);
|
|
5061
|
+
case "Record":
|
|
5062
|
+
return yield* FromRecord9(schema_, references_, value);
|
|
5063
|
+
case "Ref":
|
|
5064
|
+
return yield* FromRef10(schema_, references_, value);
|
|
5065
|
+
case "RegExp":
|
|
5066
|
+
return yield* FromRegExp4(schema_, references_, value);
|
|
5067
|
+
case "String":
|
|
5068
|
+
return yield* FromString4(schema_, references_, value);
|
|
5069
|
+
case "Symbol":
|
|
5070
|
+
return yield* FromSymbol4(schema_, references_, value);
|
|
5071
|
+
case "TemplateLiteral":
|
|
5072
|
+
return yield* FromTemplateLiteral6(schema_, references_, value);
|
|
5073
|
+
case "This":
|
|
5074
|
+
return yield* FromThis6(schema_, references_, value);
|
|
5075
|
+
case "Tuple":
|
|
5076
|
+
return yield* FromTuple11(schema_, references_, value);
|
|
5077
|
+
case "Undefined":
|
|
5078
|
+
return yield* FromUndefined4(schema_, references_, value);
|
|
5079
|
+
case "Union":
|
|
5080
|
+
return yield* FromUnion16(schema_, references_, value);
|
|
5081
|
+
case "Uint8Array":
|
|
5082
|
+
return yield* FromUint8Array4(schema_, references_, value);
|
|
5083
|
+
case "Unknown":
|
|
5084
|
+
return yield* FromUnknown4(schema_, references_, value);
|
|
5085
|
+
case "Void":
|
|
5086
|
+
return yield* FromVoid4(schema_, references_, value);
|
|
5087
|
+
default:
|
|
5088
|
+
if (!type_exports2.Has(schema_[Kind]))
|
|
5089
|
+
throw new TypeCompilerUnknownTypeError(schema);
|
|
5090
|
+
return yield* FromKind3(schema_, references_, value);
|
|
5091
|
+
}
|
|
5092
|
+
}
|
|
5093
|
+
const state = {
|
|
5094
|
+
language: "javascript",
|
|
5095
|
+
// target language
|
|
5096
|
+
functions: /* @__PURE__ */ new Map(),
|
|
5097
|
+
// local functions
|
|
5098
|
+
variables: /* @__PURE__ */ new Map(),
|
|
5099
|
+
// local variables
|
|
5100
|
+
instances: /* @__PURE__ */ new Map()
|
|
5101
|
+
// exterior kind instances
|
|
5102
|
+
};
|
|
5103
|
+
function CreateExpression(schema, references, value, useHoisting = true) {
|
|
5104
|
+
return `(${[...Visit10(schema, references, value, useHoisting)].join(" && ")})`;
|
|
5105
|
+
}
|
|
5106
|
+
function CreateFunctionName($id) {
|
|
5107
|
+
return `check_${Identifier.Encode($id)}`;
|
|
5108
|
+
}
|
|
5109
|
+
function CreateVariable(expression) {
|
|
5110
|
+
const variableName = `local_${state.variables.size}`;
|
|
5111
|
+
state.variables.set(variableName, `const ${variableName} = ${expression}`);
|
|
5112
|
+
return variableName;
|
|
5113
|
+
}
|
|
5114
|
+
function CreateFunction(name, schema, references, value, useHoisting = true) {
|
|
5115
|
+
const [newline, pad] = ["\n", (length) => "".padStart(length, " ")];
|
|
5116
|
+
const parameter = CreateParameter("value", "any");
|
|
5117
|
+
const returns = CreateReturns("boolean");
|
|
5118
|
+
const expression = [...Visit10(schema, references, value, useHoisting)].map((expression2) => `${pad(4)}${expression2}`).join(` &&${newline}`);
|
|
5119
|
+
return `function ${name}(${parameter})${returns} {${newline}${pad(2)}return (${newline}${expression}${newline}${pad(2)})
|
|
5120
|
+
}`;
|
|
5121
|
+
}
|
|
5122
|
+
function CreateParameter(name, type) {
|
|
5123
|
+
const annotation = state.language === "typescript" ? `: ${type}` : "";
|
|
5124
|
+
return `${name}${annotation}`;
|
|
5125
|
+
}
|
|
5126
|
+
function CreateReturns(type) {
|
|
5127
|
+
return state.language === "typescript" ? `: ${type}` : "";
|
|
5128
|
+
}
|
|
5129
|
+
function Build(schema, references, options) {
|
|
5130
|
+
const functionCode = CreateFunction("check", schema, references, "value");
|
|
5131
|
+
const parameter = CreateParameter("value", "any");
|
|
5132
|
+
const returns = CreateReturns("boolean");
|
|
5133
|
+
const functions = [...state.functions.values()];
|
|
5134
|
+
const variables = [...state.variables.values()];
|
|
5135
|
+
const checkFunction = IsString2(schema.$id) ? `return function check(${parameter})${returns} {
|
|
5136
|
+
return ${CreateFunctionName(schema.$id)}(value)
|
|
5137
|
+
}` : `return ${functionCode}`;
|
|
5138
|
+
return [...variables, ...functions, checkFunction].join("\n");
|
|
5139
|
+
}
|
|
5140
|
+
function Code(...args) {
|
|
5141
|
+
const defaults = { language: "javascript" };
|
|
5142
|
+
const [schema, references, options] = args.length === 2 && IsArray2(args[1]) ? [args[0], args[1], defaults] : args.length === 2 && !IsArray2(args[1]) ? [args[0], [], args[1]] : args.length === 3 ? [args[0], args[1], args[2]] : args.length === 1 ? [args[0], [], defaults] : [null, [], defaults];
|
|
5143
|
+
state.language = options.language;
|
|
5144
|
+
state.variables.clear();
|
|
5145
|
+
state.functions.clear();
|
|
5146
|
+
state.instances.clear();
|
|
5147
|
+
if (!IsSchema2(schema))
|
|
5148
|
+
throw new TypeCompilerTypeGuardError(schema);
|
|
5149
|
+
for (const schema2 of references)
|
|
5150
|
+
if (!IsSchema2(schema2))
|
|
5151
|
+
throw new TypeCompilerTypeGuardError(schema2);
|
|
5152
|
+
return Build(schema, references, options);
|
|
5153
|
+
}
|
|
5154
|
+
TypeCompiler2.Code = Code;
|
|
5155
|
+
function Compile(schema, references = []) {
|
|
5156
|
+
const generatedCode = Code(schema, references, { language: "javascript" });
|
|
5157
|
+
const compiledFunction = Evaluate("kind", "format", "hash", generatedCode);
|
|
5158
|
+
const instances = new Map(state.instances);
|
|
5159
|
+
function typeRegistryFunction(kind, instance, value) {
|
|
5160
|
+
if (!type_exports2.Has(kind) || !instances.has(instance))
|
|
5161
|
+
return false;
|
|
5162
|
+
const checkFunc = type_exports2.Get(kind);
|
|
5163
|
+
const schema2 = instances.get(instance);
|
|
5164
|
+
return checkFunc(schema2, value);
|
|
5165
|
+
}
|
|
5166
|
+
function formatRegistryFunction(format, value) {
|
|
5167
|
+
if (!format_exports.Has(format))
|
|
5168
|
+
return false;
|
|
5169
|
+
const checkFunc = format_exports.Get(format);
|
|
5170
|
+
return checkFunc(value);
|
|
5171
|
+
}
|
|
5172
|
+
function hashFunction(value) {
|
|
5173
|
+
return Hash(value);
|
|
5174
|
+
}
|
|
5175
|
+
const checkFunction = compiledFunction(typeRegistryFunction, formatRegistryFunction, hashFunction);
|
|
5176
|
+
return new TypeCheck(schema, references, checkFunction, generatedCode);
|
|
5177
|
+
}
|
|
5178
|
+
TypeCompiler2.Compile = Compile;
|
|
5179
|
+
})(TypeCompiler || (TypeCompiler = {}));
|
|
5180
|
+
var sessionRequest = TypeCompiler.Compile(SessionRequestSchema);
|
|
5181
|
+
var action = TypeCompiler.Compile(ActionSchema);
|
|
2715
5182
|
var ErrorCode;
|
|
2716
5183
|
(function(ErrorCode2) {
|
|
2717
5184
|
ErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
|
|
@@ -2737,8 +5204,28 @@ var ErrorCode;
|
|
|
2737
5204
|
ErrorCode2["OUTPUT_TRUNCATED"] = "OUTPUT_TRUNCATED";
|
|
2738
5205
|
ErrorCode2["INTERNAL"] = "INTERNAL";
|
|
2739
5206
|
})(ErrorCode || (ErrorCode = {}));
|
|
5207
|
+
var UsageError = class extends Error {
|
|
5208
|
+
constructor(message) {
|
|
5209
|
+
super(message);
|
|
5210
|
+
this.name = "UsageError";
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
function formatErrorForUser(error2, staleHint) {
|
|
5214
|
+
if (error2 instanceof UsageError) {
|
|
5215
|
+
return error2.message;
|
|
5216
|
+
}
|
|
5217
|
+
if (error2 instanceof Error) {
|
|
5218
|
+
const code = error2.code;
|
|
5219
|
+
if (code === "STALE_TARGET" && staleHint) {
|
|
5220
|
+
return `${error2.message}
|
|
5221
|
+
|
|
5222
|
+
${staleHint}`;
|
|
5223
|
+
}
|
|
5224
|
+
return code && !error2.message.startsWith(code) ? `${code}: ${error2.message}` : error2.message;
|
|
5225
|
+
}
|
|
5226
|
+
return String(error2);
|
|
5227
|
+
}
|
|
2740
5228
|
var PROTOCOL_VERSION = "2024-11-05";
|
|
2741
|
-
var REF_PATTERN = "^e\\d+_\\d+$";
|
|
2742
5229
|
function buildMcpServer(deps) {
|
|
2743
5230
|
const client = deps.createClient({ baseUrl: deps.baseUrl ?? "http://localhost:3000" });
|
|
2744
5231
|
const serverInfo = deps.serverInfo ?? { name: "agentbrowser", version: "1.0.0" };
|
|
@@ -2937,7 +5424,7 @@ function buildMcpServer(deps) {
|
|
|
2937
5424
|
},
|
|
2938
5425
|
{
|
|
2939
5426
|
name: "browser_act",
|
|
2940
|
-
description: "Perform an action on an element by ref: click, fill, select, scroll or
|
|
5427
|
+
description: "Perform an action on an element by ref: click, dblclick, hover, fill, clear, check, uncheck, select, scroll, press, wait, goBack, goForward, reload, or handle a dialog. Elements are addressed by the ref from browser_observe, never by CSS selector or XPath. If the page changed since the observation, the action fails with STALE_TARGET: call browser_observe again and use the new refs; do not retry the old one.",
|
|
2941
5428
|
inputSchema: {
|
|
2942
5429
|
type: "object",
|
|
2943
5430
|
properties: {
|
|
@@ -2952,7 +5439,7 @@ function buildMcpServer(deps) {
|
|
|
2952
5439
|
properties: {
|
|
2953
5440
|
ref: {
|
|
2954
5441
|
type: "string",
|
|
2955
|
-
pattern: REF_PATTERN,
|
|
5442
|
+
pattern: REF_PATTERN.source,
|
|
2956
5443
|
description: "Element ref from browser_observe, e.g. e1_0."
|
|
2957
5444
|
}
|
|
2958
5445
|
},
|
|
@@ -2961,16 +5448,35 @@ function buildMcpServer(deps) {
|
|
|
2961
5448
|
value: { type: "string", description: "Value for fill/select." },
|
|
2962
5449
|
key: { type: "string", description: "Key for press." },
|
|
2963
5450
|
direction: { type: "string", enum: ["up", "down", "left", "right"] },
|
|
2964
|
-
amount: { type: "number" }
|
|
5451
|
+
amount: { type: "number" },
|
|
5452
|
+
condition: {
|
|
5453
|
+
type: "object",
|
|
5454
|
+
description: 'Wait-action condition (action: "wait" only).',
|
|
5455
|
+
properties: {
|
|
5456
|
+
until: {
|
|
5457
|
+
type: "string",
|
|
5458
|
+
enum: ["settled", "domcontentloaded", "load", "networkidle"]
|
|
5459
|
+
},
|
|
5460
|
+
timeoutMs: { type: "number" }
|
|
5461
|
+
},
|
|
5462
|
+
required: ["until"]
|
|
5463
|
+
}
|
|
2965
5464
|
},
|
|
2966
5465
|
required: ["sessionId", "pageId", "action"]
|
|
2967
5466
|
},
|
|
2968
5467
|
handler: async (args) => {
|
|
2969
5468
|
const [sessionId, pageId] = sessionAndPage(args);
|
|
2970
5469
|
const target = args.target ?? {};
|
|
2971
|
-
const
|
|
5470
|
+
const UNTARGETED_ACTIONS = /* @__PURE__ */ new Set([
|
|
5471
|
+
"acceptDialog",
|
|
5472
|
+
"dismissDialog",
|
|
5473
|
+
"wait",
|
|
5474
|
+
"goBack",
|
|
5475
|
+
"goForward",
|
|
5476
|
+
"reload"
|
|
5477
|
+
]);
|
|
2972
5478
|
const ref = target.ref;
|
|
2973
|
-
if (!
|
|
5479
|
+
if (!UNTARGETED_ACTIONS.has(String(args.action)) && (typeof ref !== "string" || !REF_PATTERN.test(ref))) {
|
|
2974
5480
|
throw new UsageError(`Invalid element reference '${String(ref)}'. Expected a ref of the form e<revision>_<ordinal>, such as e1_0. Call browser_observe to list current refs.`);
|
|
2975
5481
|
}
|
|
2976
5482
|
const request = {
|
|
@@ -2985,6 +5491,9 @@ function buildMcpServer(deps) {
|
|
|
2985
5491
|
request.direction = args.direction;
|
|
2986
5492
|
if (typeof args.amount === "number")
|
|
2987
5493
|
request.amount = args.amount;
|
|
5494
|
+
if (args.condition !== void 0 && typeof args.condition === "object") {
|
|
5495
|
+
request.condition = args.condition;
|
|
5496
|
+
}
|
|
2988
5497
|
return await client.sessions.executeAction(sessionId, pageId, request);
|
|
2989
5498
|
}
|
|
2990
5499
|
},
|
|
@@ -2998,8 +5507,12 @@ function buildMcpServer(deps) {
|
|
|
2998
5507
|
pageId: { type: "string" },
|
|
2999
5508
|
format: {
|
|
3000
5509
|
type: "string",
|
|
3001
|
-
enum: [
|
|
5510
|
+
enum: [...DELIVERED_EXTRACT_FORMATS],
|
|
3002
5511
|
description: "What to extract (default: text)."
|
|
5512
|
+
},
|
|
5513
|
+
schema: {
|
|
5514
|
+
type: "object",
|
|
5515
|
+
description: 'JSON Schema constraining the extraction (format: "schema" only): properties to pick, with type/description/enum constraints.'
|
|
3003
5516
|
}
|
|
3004
5517
|
},
|
|
3005
5518
|
required: ["sessionId", "pageId", "format"]
|
|
@@ -3007,13 +5520,15 @@ function buildMcpServer(deps) {
|
|
|
3007
5520
|
handler: async (args) => {
|
|
3008
5521
|
const [sessionId, pageId] = sessionAndPage(args);
|
|
3009
5522
|
const format = args.format;
|
|
3010
|
-
const supported =
|
|
5523
|
+
const supported = DELIVERED_EXTRACT_FORMATS;
|
|
3011
5524
|
if (typeof format !== "string" || !supported.includes(format)) {
|
|
3012
5525
|
throw new UsageError(`Unknown extraction format '${String(format)}'. Supported: ${supported.join(", ")}.`);
|
|
3013
5526
|
}
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
5527
|
+
const request = { format };
|
|
5528
|
+
if (args.schema !== void 0 && typeof args.schema === "object") {
|
|
5529
|
+
request.schema = args.schema;
|
|
5530
|
+
}
|
|
5531
|
+
return await client.sessions.extract(sessionId, pageId, request);
|
|
3017
5532
|
}
|
|
3018
5533
|
},
|
|
3019
5534
|
{
|
|
@@ -3117,8 +5632,6 @@ function buildMcpServer(deps) {
|
|
|
3117
5632
|
}
|
|
3118
5633
|
};
|
|
3119
5634
|
}
|
|
3120
|
-
var UsageError = class extends Error {
|
|
3121
|
-
};
|
|
3122
5635
|
function requireHttpUrl(value) {
|
|
3123
5636
|
const url = typeof value === "string" ? value : "";
|
|
3124
5637
|
if (!/^https?:\/\//.test(url)) {
|
|
@@ -3138,19 +5651,7 @@ function errorResult(message) {
|
|
|
3138
5651
|
};
|
|
3139
5652
|
}
|
|
3140
5653
|
function formatToolError(error2) {
|
|
3141
|
-
|
|
3142
|
-
return error2.message;
|
|
3143
|
-
}
|
|
3144
|
-
if (error2 instanceof Error) {
|
|
3145
|
-
const code = error2.code;
|
|
3146
|
-
if (code === "STALE_TARGET") {
|
|
3147
|
-
return `${error2.message}
|
|
3148
|
-
|
|
3149
|
-
The element ref is stale. Call browser_observe to get fresh refs at the current revision, then act on the new ref. Do not retry the old one.`;
|
|
3150
|
-
}
|
|
3151
|
-
return code && !error2.message.startsWith(code) ? `${code}: ${error2.message}` : error2.message;
|
|
3152
|
-
}
|
|
3153
|
-
return String(error2);
|
|
5654
|
+
return formatErrorForUser(error2, "The element ref is stale. Call browser_observe to get fresh refs at the current revision, then act on the new ref. Do not retry the old one.");
|
|
3154
5655
|
}
|
|
3155
5656
|
function ok(id, result) {
|
|
3156
5657
|
return JSON.stringify({ jsonrpc: "2.0", id, result });
|