@claw-fact-bus/openclaw-plugin 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -4
- package/dist/{chunk-PR4QN5HX.js → chunk-7D4SUZUM.js} +3 -7
- package/dist/{chunk-PR4QN5HX.js.map → chunk-7D4SUZUM.js.map} +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.js +407 -2830
- package/dist/index.js.map +1 -1
- package/dist/{wrapper-MVER34YC.js → wrapper-HE2LXQRG.js} +3 -3
- package/dist/{wrapper-MVER34YC.js.map → wrapper-HE2LXQRG.js.map} +1 -1
- package/openclaw.plugin.json +66 -1
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './chunk-7D4SUZUM.js';
|
|
2
2
|
import { definePluginEntry } from 'openclaw/plugin-sdk/plugin-entry';
|
|
3
|
+
import { Type } from '@sinclair/typebox';
|
|
3
4
|
|
|
4
5
|
// src/api.ts
|
|
5
6
|
var FactBusClient = class {
|
|
@@ -20,7 +21,7 @@ var FactBusClient = class {
|
|
|
20
21
|
domain_interests: request.domain_interests || [],
|
|
21
22
|
fact_type_patterns: request.fact_type_patterns || [],
|
|
22
23
|
priority_range: request.priority_range || [0, 7],
|
|
23
|
-
modes: request.modes
|
|
24
|
+
modes: request.modes ?? ["exclusive", "broadcast"],
|
|
24
25
|
max_concurrent_claims: request.max_concurrent_claims || 1
|
|
25
26
|
})
|
|
26
27
|
});
|
|
@@ -178,2670 +179,226 @@ var FactBusClient = class {
|
|
|
178
179
|
method: "GET"
|
|
179
180
|
});
|
|
180
181
|
}
|
|
181
|
-
async
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
getWebSocketUrl() {
|
|
190
|
-
const url = new URL(this.baseUrl);
|
|
191
|
-
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
192
|
-
const urlStr = url.toString();
|
|
193
|
-
return urlStr.endsWith("/") ? urlStr.slice(0, -1) : urlStr;
|
|
194
|
-
}
|
|
195
|
-
// ============ Schema Registry Methods ============
|
|
196
|
-
async listSchemas() {
|
|
197
|
-
return this.fetchJson("/schemas", {
|
|
198
|
-
method: "GET"
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
async getSchema(factType, version) {
|
|
202
|
-
const query = version ? `?version=${version}` : "";
|
|
203
|
-
return this.fetchJson(`/schemas/${factType}${query}`, {
|
|
204
|
-
method: "GET"
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
async validateSchema(factType, payload, version) {
|
|
208
|
-
const query = version ? `?version=${version}` : "";
|
|
209
|
-
return this.fetchJson(`/schemas/${factType}/validate${query}`, {
|
|
210
|
-
method: "POST",
|
|
211
|
-
body: JSON.stringify({ payload })
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
// ============ Private Helpers ============
|
|
215
|
-
async fetchJson(path, options = {}) {
|
|
216
|
-
try {
|
|
217
|
-
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
218
|
-
...options,
|
|
219
|
-
headers: {
|
|
220
|
-
"Content-Type": "application/json",
|
|
221
|
-
...options.headers
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
if (!response.ok) {
|
|
225
|
-
const errorData = await response.json().catch(() => ({}));
|
|
226
|
-
return {
|
|
227
|
-
success: false,
|
|
228
|
-
error: errorData.error || `HTTP ${response.status}`
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
const data = await response.json();
|
|
232
|
-
return { success: true, data };
|
|
233
|
-
} catch (error) {
|
|
234
|
-
return {
|
|
235
|
-
success: false,
|
|
236
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
243
|
-
var value_exports = {};
|
|
244
|
-
__export(value_exports, {
|
|
245
|
-
HasPropertyKey: () => HasPropertyKey,
|
|
246
|
-
IsArray: () => IsArray,
|
|
247
|
-
IsAsyncIterator: () => IsAsyncIterator,
|
|
248
|
-
IsBigInt: () => IsBigInt,
|
|
249
|
-
IsBoolean: () => IsBoolean,
|
|
250
|
-
IsDate: () => IsDate,
|
|
251
|
-
IsFunction: () => IsFunction,
|
|
252
|
-
IsIterator: () => IsIterator,
|
|
253
|
-
IsNull: () => IsNull,
|
|
254
|
-
IsNumber: () => IsNumber,
|
|
255
|
-
IsObject: () => IsObject,
|
|
256
|
-
IsRegExp: () => IsRegExp,
|
|
257
|
-
IsString: () => IsString,
|
|
258
|
-
IsSymbol: () => IsSymbol,
|
|
259
|
-
IsUint8Array: () => IsUint8Array,
|
|
260
|
-
IsUndefined: () => IsUndefined
|
|
261
|
-
});
|
|
262
|
-
function HasPropertyKey(value, key) {
|
|
263
|
-
return key in value;
|
|
264
|
-
}
|
|
265
|
-
function IsAsyncIterator(value) {
|
|
266
|
-
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
|
|
267
|
-
}
|
|
268
|
-
function IsArray(value) {
|
|
269
|
-
return Array.isArray(value);
|
|
270
|
-
}
|
|
271
|
-
function IsBigInt(value) {
|
|
272
|
-
return typeof value === "bigint";
|
|
273
|
-
}
|
|
274
|
-
function IsBoolean(value) {
|
|
275
|
-
return typeof value === "boolean";
|
|
276
|
-
}
|
|
277
|
-
function IsDate(value) {
|
|
278
|
-
return value instanceof globalThis.Date;
|
|
279
|
-
}
|
|
280
|
-
function IsFunction(value) {
|
|
281
|
-
return typeof value === "function";
|
|
282
|
-
}
|
|
283
|
-
function IsIterator(value) {
|
|
284
|
-
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
|
|
285
|
-
}
|
|
286
|
-
function IsNull(value) {
|
|
287
|
-
return value === null;
|
|
288
|
-
}
|
|
289
|
-
function IsNumber(value) {
|
|
290
|
-
return typeof value === "number";
|
|
291
|
-
}
|
|
292
|
-
function IsObject(value) {
|
|
293
|
-
return typeof value === "object" && value !== null;
|
|
294
|
-
}
|
|
295
|
-
function IsRegExp(value) {
|
|
296
|
-
return value instanceof globalThis.RegExp;
|
|
297
|
-
}
|
|
298
|
-
function IsString(value) {
|
|
299
|
-
return typeof value === "string";
|
|
300
|
-
}
|
|
301
|
-
function IsSymbol(value) {
|
|
302
|
-
return typeof value === "symbol";
|
|
303
|
-
}
|
|
304
|
-
function IsUint8Array(value) {
|
|
305
|
-
return value instanceof globalThis.Uint8Array;
|
|
306
|
-
}
|
|
307
|
-
function IsUndefined(value) {
|
|
308
|
-
return value === void 0;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
|
|
312
|
-
function ArrayType(value) {
|
|
313
|
-
return value.map((value2) => Visit(value2));
|
|
314
|
-
}
|
|
315
|
-
function DateType(value) {
|
|
316
|
-
return new Date(value.getTime());
|
|
317
|
-
}
|
|
318
|
-
function Uint8ArrayType(value) {
|
|
319
|
-
return new Uint8Array(value);
|
|
320
|
-
}
|
|
321
|
-
function RegExpType(value) {
|
|
322
|
-
return new RegExp(value.source, value.flags);
|
|
323
|
-
}
|
|
324
|
-
function ObjectType(value) {
|
|
325
|
-
const result = {};
|
|
326
|
-
for (const key of Object.getOwnPropertyNames(value)) {
|
|
327
|
-
result[key] = Visit(value[key]);
|
|
328
|
-
}
|
|
329
|
-
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
330
|
-
result[key] = Visit(value[key]);
|
|
331
|
-
}
|
|
332
|
-
return result;
|
|
333
|
-
}
|
|
334
|
-
function Visit(value) {
|
|
335
|
-
return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
|
|
336
|
-
}
|
|
337
|
-
function Clone(value) {
|
|
338
|
-
return Visit(value);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
|
|
342
|
-
function CloneType(schema, options) {
|
|
343
|
-
return Clone(schema) ;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
|
|
347
|
-
function IsObject2(value) {
|
|
348
|
-
return value !== null && typeof value === "object";
|
|
349
|
-
}
|
|
350
|
-
function IsArray2(value) {
|
|
351
|
-
return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
|
|
352
|
-
}
|
|
353
|
-
function IsUndefined2(value) {
|
|
354
|
-
return value === void 0;
|
|
355
|
-
}
|
|
356
|
-
function IsNumber2(value) {
|
|
357
|
-
return typeof value === "number";
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// node_modules/@sinclair/typebox/build/esm/system/policy.mjs
|
|
361
|
-
var TypeSystemPolicy;
|
|
362
|
-
(function(TypeSystemPolicy2) {
|
|
363
|
-
TypeSystemPolicy2.InstanceMode = "default";
|
|
364
|
-
TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
|
|
365
|
-
TypeSystemPolicy2.AllowArrayObject = false;
|
|
366
|
-
TypeSystemPolicy2.AllowNaN = false;
|
|
367
|
-
TypeSystemPolicy2.AllowNullVoid = false;
|
|
368
|
-
function IsExactOptionalProperty(value, key) {
|
|
369
|
-
return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
|
|
370
|
-
}
|
|
371
|
-
TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
|
|
372
|
-
function IsObjectLike(value) {
|
|
373
|
-
const isObject = IsObject2(value);
|
|
374
|
-
return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
|
|
375
|
-
}
|
|
376
|
-
TypeSystemPolicy2.IsObjectLike = IsObjectLike;
|
|
377
|
-
function IsRecordLike(value) {
|
|
378
|
-
return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
|
|
379
|
-
}
|
|
380
|
-
TypeSystemPolicy2.IsRecordLike = IsRecordLike;
|
|
381
|
-
function IsNumberLike(value) {
|
|
382
|
-
return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
|
|
383
|
-
}
|
|
384
|
-
TypeSystemPolicy2.IsNumberLike = IsNumberLike;
|
|
385
|
-
function IsVoidLike(value) {
|
|
386
|
-
const isUndefined = IsUndefined2(value);
|
|
387
|
-
return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
|
|
388
|
-
}
|
|
389
|
-
TypeSystemPolicy2.IsVoidLike = IsVoidLike;
|
|
390
|
-
})(TypeSystemPolicy || (TypeSystemPolicy = {}));
|
|
391
|
-
|
|
392
|
-
// node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
|
|
393
|
-
function ImmutableArray(value) {
|
|
394
|
-
return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
|
|
395
|
-
}
|
|
396
|
-
function ImmutableDate(value) {
|
|
397
|
-
return value;
|
|
398
|
-
}
|
|
399
|
-
function ImmutableUint8Array(value) {
|
|
400
|
-
return value;
|
|
401
|
-
}
|
|
402
|
-
function ImmutableRegExp(value) {
|
|
403
|
-
return value;
|
|
404
|
-
}
|
|
405
|
-
function ImmutableObject(value) {
|
|
406
|
-
const result = {};
|
|
407
|
-
for (const key of Object.getOwnPropertyNames(value)) {
|
|
408
|
-
result[key] = Immutable(value[key]);
|
|
409
|
-
}
|
|
410
|
-
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
411
|
-
result[key] = Immutable(value[key]);
|
|
412
|
-
}
|
|
413
|
-
return globalThis.Object.freeze(result);
|
|
414
|
-
}
|
|
415
|
-
function Immutable(value) {
|
|
416
|
-
return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
|
|
420
|
-
function CreateType(schema, options) {
|
|
421
|
-
const result = options !== void 0 ? { ...options, ...schema } : schema;
|
|
422
|
-
switch (TypeSystemPolicy.InstanceMode) {
|
|
423
|
-
case "freeze":
|
|
424
|
-
return Immutable(result);
|
|
425
|
-
case "clone":
|
|
426
|
-
return Clone(result);
|
|
427
|
-
default:
|
|
428
|
-
return result;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
|
|
433
|
-
var TypeBoxError = class extends Error {
|
|
434
|
-
constructor(message) {
|
|
435
|
-
super(message);
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
// node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
|
|
440
|
-
var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
|
|
441
|
-
var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
|
|
442
|
-
var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
|
|
443
|
-
var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
|
|
444
|
-
var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
|
|
445
|
-
|
|
446
|
-
// node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
|
|
447
|
-
function IsReadonly(value) {
|
|
448
|
-
return IsObject(value) && value[ReadonlyKind] === "Readonly";
|
|
449
|
-
}
|
|
450
|
-
function IsOptional(value) {
|
|
451
|
-
return IsObject(value) && value[OptionalKind] === "Optional";
|
|
452
|
-
}
|
|
453
|
-
function IsAny(value) {
|
|
454
|
-
return IsKindOf(value, "Any");
|
|
455
|
-
}
|
|
456
|
-
function IsArgument(value) {
|
|
457
|
-
return IsKindOf(value, "Argument");
|
|
458
|
-
}
|
|
459
|
-
function IsArray3(value) {
|
|
460
|
-
return IsKindOf(value, "Array");
|
|
461
|
-
}
|
|
462
|
-
function IsAsyncIterator2(value) {
|
|
463
|
-
return IsKindOf(value, "AsyncIterator");
|
|
464
|
-
}
|
|
465
|
-
function IsBigInt2(value) {
|
|
466
|
-
return IsKindOf(value, "BigInt");
|
|
467
|
-
}
|
|
468
|
-
function IsBoolean2(value) {
|
|
469
|
-
return IsKindOf(value, "Boolean");
|
|
470
|
-
}
|
|
471
|
-
function IsComputed(value) {
|
|
472
|
-
return IsKindOf(value, "Computed");
|
|
473
|
-
}
|
|
474
|
-
function IsConstructor(value) {
|
|
475
|
-
return IsKindOf(value, "Constructor");
|
|
476
|
-
}
|
|
477
|
-
function IsDate2(value) {
|
|
478
|
-
return IsKindOf(value, "Date");
|
|
479
|
-
}
|
|
480
|
-
function IsFunction2(value) {
|
|
481
|
-
return IsKindOf(value, "Function");
|
|
482
|
-
}
|
|
483
|
-
function IsInteger(value) {
|
|
484
|
-
return IsKindOf(value, "Integer");
|
|
485
|
-
}
|
|
486
|
-
function IsIntersect(value) {
|
|
487
|
-
return IsKindOf(value, "Intersect");
|
|
488
|
-
}
|
|
489
|
-
function IsIterator2(value) {
|
|
490
|
-
return IsKindOf(value, "Iterator");
|
|
491
|
-
}
|
|
492
|
-
function IsKindOf(value, kind) {
|
|
493
|
-
return IsObject(value) && Kind in value && value[Kind] === kind;
|
|
494
|
-
}
|
|
495
|
-
function IsLiteralValue(value) {
|
|
496
|
-
return IsBoolean(value) || IsNumber(value) || IsString(value);
|
|
497
|
-
}
|
|
498
|
-
function IsLiteral(value) {
|
|
499
|
-
return IsKindOf(value, "Literal");
|
|
500
|
-
}
|
|
501
|
-
function IsMappedKey(value) {
|
|
502
|
-
return IsKindOf(value, "MappedKey");
|
|
503
|
-
}
|
|
504
|
-
function IsMappedResult(value) {
|
|
505
|
-
return IsKindOf(value, "MappedResult");
|
|
506
|
-
}
|
|
507
|
-
function IsNever(value) {
|
|
508
|
-
return IsKindOf(value, "Never");
|
|
509
|
-
}
|
|
510
|
-
function IsNot(value) {
|
|
511
|
-
return IsKindOf(value, "Not");
|
|
512
|
-
}
|
|
513
|
-
function IsNull2(value) {
|
|
514
|
-
return IsKindOf(value, "Null");
|
|
515
|
-
}
|
|
516
|
-
function IsNumber3(value) {
|
|
517
|
-
return IsKindOf(value, "Number");
|
|
518
|
-
}
|
|
519
|
-
function IsObject3(value) {
|
|
520
|
-
return IsKindOf(value, "Object");
|
|
521
|
-
}
|
|
522
|
-
function IsPromise(value) {
|
|
523
|
-
return IsKindOf(value, "Promise");
|
|
524
|
-
}
|
|
525
|
-
function IsRecord(value) {
|
|
526
|
-
return IsKindOf(value, "Record");
|
|
527
|
-
}
|
|
528
|
-
function IsRef(value) {
|
|
529
|
-
return IsKindOf(value, "Ref");
|
|
530
|
-
}
|
|
531
|
-
function IsRegExp2(value) {
|
|
532
|
-
return IsKindOf(value, "RegExp");
|
|
533
|
-
}
|
|
534
|
-
function IsString2(value) {
|
|
535
|
-
return IsKindOf(value, "String");
|
|
536
|
-
}
|
|
537
|
-
function IsSymbol2(value) {
|
|
538
|
-
return IsKindOf(value, "Symbol");
|
|
539
|
-
}
|
|
540
|
-
function IsTemplateLiteral(value) {
|
|
541
|
-
return IsKindOf(value, "TemplateLiteral");
|
|
542
|
-
}
|
|
543
|
-
function IsThis(value) {
|
|
544
|
-
return IsKindOf(value, "This");
|
|
545
|
-
}
|
|
546
|
-
function IsTransform(value) {
|
|
547
|
-
return IsObject(value) && TransformKind in value;
|
|
548
|
-
}
|
|
549
|
-
function IsTuple(value) {
|
|
550
|
-
return IsKindOf(value, "Tuple");
|
|
551
|
-
}
|
|
552
|
-
function IsUndefined3(value) {
|
|
553
|
-
return IsKindOf(value, "Undefined");
|
|
554
|
-
}
|
|
555
|
-
function IsUnion(value) {
|
|
556
|
-
return IsKindOf(value, "Union");
|
|
557
|
-
}
|
|
558
|
-
function IsUint8Array2(value) {
|
|
559
|
-
return IsKindOf(value, "Uint8Array");
|
|
560
|
-
}
|
|
561
|
-
function IsUnknown(value) {
|
|
562
|
-
return IsKindOf(value, "Unknown");
|
|
563
|
-
}
|
|
564
|
-
function IsUnsafe(value) {
|
|
565
|
-
return IsKindOf(value, "Unsafe");
|
|
566
|
-
}
|
|
567
|
-
function IsVoid(value) {
|
|
568
|
-
return IsKindOf(value, "Void");
|
|
569
|
-
}
|
|
570
|
-
function IsKind(value) {
|
|
571
|
-
return IsObject(value) && Kind in value && IsString(value[Kind]);
|
|
572
|
-
}
|
|
573
|
-
function IsSchema(value) {
|
|
574
|
-
return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean2(value) || IsBigInt2(value) || IsAsyncIterator2(value) || IsComputed(value) || IsConstructor(value) || IsDate2(value) || IsFunction2(value) || IsInteger(value) || IsIntersect(value) || IsIterator2(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull2(value) || IsNumber3(value) || IsObject3(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString2(value) || IsSymbol2(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array2(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
|
|
578
|
-
var type_exports = {};
|
|
579
|
-
__export(type_exports, {
|
|
580
|
-
IsAny: () => IsAny2,
|
|
581
|
-
IsArgument: () => IsArgument2,
|
|
582
|
-
IsArray: () => IsArray4,
|
|
583
|
-
IsAsyncIterator: () => IsAsyncIterator3,
|
|
584
|
-
IsBigInt: () => IsBigInt3,
|
|
585
|
-
IsBoolean: () => IsBoolean3,
|
|
586
|
-
IsComputed: () => IsComputed2,
|
|
587
|
-
IsConstructor: () => IsConstructor2,
|
|
588
|
-
IsDate: () => IsDate3,
|
|
589
|
-
IsFunction: () => IsFunction3,
|
|
590
|
-
IsImport: () => IsImport,
|
|
591
|
-
IsInteger: () => IsInteger2,
|
|
592
|
-
IsIntersect: () => IsIntersect2,
|
|
593
|
-
IsIterator: () => IsIterator3,
|
|
594
|
-
IsKind: () => IsKind2,
|
|
595
|
-
IsKindOf: () => IsKindOf2,
|
|
596
|
-
IsLiteral: () => IsLiteral2,
|
|
597
|
-
IsLiteralBoolean: () => IsLiteralBoolean,
|
|
598
|
-
IsLiteralNumber: () => IsLiteralNumber,
|
|
599
|
-
IsLiteralString: () => IsLiteralString,
|
|
600
|
-
IsLiteralValue: () => IsLiteralValue2,
|
|
601
|
-
IsMappedKey: () => IsMappedKey2,
|
|
602
|
-
IsMappedResult: () => IsMappedResult2,
|
|
603
|
-
IsNever: () => IsNever2,
|
|
604
|
-
IsNot: () => IsNot2,
|
|
605
|
-
IsNull: () => IsNull3,
|
|
606
|
-
IsNumber: () => IsNumber4,
|
|
607
|
-
IsObject: () => IsObject4,
|
|
608
|
-
IsOptional: () => IsOptional2,
|
|
609
|
-
IsPromise: () => IsPromise2,
|
|
610
|
-
IsProperties: () => IsProperties,
|
|
611
|
-
IsReadonly: () => IsReadonly2,
|
|
612
|
-
IsRecord: () => IsRecord2,
|
|
613
|
-
IsRecursive: () => IsRecursive,
|
|
614
|
-
IsRef: () => IsRef2,
|
|
615
|
-
IsRegExp: () => IsRegExp3,
|
|
616
|
-
IsSchema: () => IsSchema2,
|
|
617
|
-
IsString: () => IsString3,
|
|
618
|
-
IsSymbol: () => IsSymbol3,
|
|
619
|
-
IsTemplateLiteral: () => IsTemplateLiteral2,
|
|
620
|
-
IsThis: () => IsThis2,
|
|
621
|
-
IsTransform: () => IsTransform2,
|
|
622
|
-
IsTuple: () => IsTuple2,
|
|
623
|
-
IsUint8Array: () => IsUint8Array3,
|
|
624
|
-
IsUndefined: () => IsUndefined4,
|
|
625
|
-
IsUnion: () => IsUnion2,
|
|
626
|
-
IsUnionLiteral: () => IsUnionLiteral,
|
|
627
|
-
IsUnknown: () => IsUnknown2,
|
|
628
|
-
IsUnsafe: () => IsUnsafe2,
|
|
629
|
-
IsVoid: () => IsVoid2,
|
|
630
|
-
TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
|
|
631
|
-
});
|
|
632
|
-
var TypeGuardUnknownTypeError = class extends TypeBoxError {
|
|
633
|
-
};
|
|
634
|
-
var KnownTypes = [
|
|
635
|
-
"Argument",
|
|
636
|
-
"Any",
|
|
637
|
-
"Array",
|
|
638
|
-
"AsyncIterator",
|
|
639
|
-
"BigInt",
|
|
640
|
-
"Boolean",
|
|
641
|
-
"Computed",
|
|
642
|
-
"Constructor",
|
|
643
|
-
"Date",
|
|
644
|
-
"Enum",
|
|
645
|
-
"Function",
|
|
646
|
-
"Integer",
|
|
647
|
-
"Intersect",
|
|
648
|
-
"Iterator",
|
|
649
|
-
"Literal",
|
|
650
|
-
"MappedKey",
|
|
651
|
-
"MappedResult",
|
|
652
|
-
"Not",
|
|
653
|
-
"Null",
|
|
654
|
-
"Number",
|
|
655
|
-
"Object",
|
|
656
|
-
"Promise",
|
|
657
|
-
"Record",
|
|
658
|
-
"Ref",
|
|
659
|
-
"RegExp",
|
|
660
|
-
"String",
|
|
661
|
-
"Symbol",
|
|
662
|
-
"TemplateLiteral",
|
|
663
|
-
"This",
|
|
664
|
-
"Tuple",
|
|
665
|
-
"Undefined",
|
|
666
|
-
"Union",
|
|
667
|
-
"Uint8Array",
|
|
668
|
-
"Unknown",
|
|
669
|
-
"Void"
|
|
670
|
-
];
|
|
671
|
-
function IsPattern(value) {
|
|
672
|
-
try {
|
|
673
|
-
new RegExp(value);
|
|
674
|
-
return true;
|
|
675
|
-
} catch {
|
|
676
|
-
return false;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
function IsControlCharacterFree(value) {
|
|
680
|
-
if (!IsString(value))
|
|
681
|
-
return false;
|
|
682
|
-
for (let i = 0; i < value.length; i++) {
|
|
683
|
-
const code = value.charCodeAt(i);
|
|
684
|
-
if (code >= 7 && code <= 13 || code === 27 || code === 127) {
|
|
685
|
-
return false;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
return true;
|
|
689
|
-
}
|
|
690
|
-
function IsAdditionalProperties(value) {
|
|
691
|
-
return IsOptionalBoolean(value) || IsSchema2(value);
|
|
692
|
-
}
|
|
693
|
-
function IsOptionalBigInt(value) {
|
|
694
|
-
return IsUndefined(value) || IsBigInt(value);
|
|
695
|
-
}
|
|
696
|
-
function IsOptionalNumber(value) {
|
|
697
|
-
return IsUndefined(value) || IsNumber(value);
|
|
698
|
-
}
|
|
699
|
-
function IsOptionalBoolean(value) {
|
|
700
|
-
return IsUndefined(value) || IsBoolean(value);
|
|
701
|
-
}
|
|
702
|
-
function IsOptionalString(value) {
|
|
703
|
-
return IsUndefined(value) || IsString(value);
|
|
704
|
-
}
|
|
705
|
-
function IsOptionalPattern(value) {
|
|
706
|
-
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
|
|
707
|
-
}
|
|
708
|
-
function IsOptionalFormat(value) {
|
|
709
|
-
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
|
|
710
|
-
}
|
|
711
|
-
function IsOptionalSchema(value) {
|
|
712
|
-
return IsUndefined(value) || IsSchema2(value);
|
|
713
|
-
}
|
|
714
|
-
function IsReadonly2(value) {
|
|
715
|
-
return IsObject(value) && value[ReadonlyKind] === "Readonly";
|
|
716
|
-
}
|
|
717
|
-
function IsOptional2(value) {
|
|
718
|
-
return IsObject(value) && value[OptionalKind] === "Optional";
|
|
719
|
-
}
|
|
720
|
-
function IsAny2(value) {
|
|
721
|
-
return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
|
|
722
|
-
}
|
|
723
|
-
function IsArgument2(value) {
|
|
724
|
-
return IsKindOf2(value, "Argument") && IsNumber(value.index);
|
|
725
|
-
}
|
|
726
|
-
function IsArray4(value) {
|
|
727
|
-
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);
|
|
728
|
-
}
|
|
729
|
-
function IsAsyncIterator3(value) {
|
|
730
|
-
return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
731
|
-
}
|
|
732
|
-
function IsBigInt3(value) {
|
|
733
|
-
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);
|
|
734
|
-
}
|
|
735
|
-
function IsBoolean3(value) {
|
|
736
|
-
return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
|
|
737
|
-
}
|
|
738
|
-
function IsComputed2(value) {
|
|
739
|
-
return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
|
|
740
|
-
}
|
|
741
|
-
function IsConstructor2(value) {
|
|
742
|
-
return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
743
|
-
}
|
|
744
|
-
function IsDate3(value) {
|
|
745
|
-
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);
|
|
746
|
-
}
|
|
747
|
-
function IsFunction3(value) {
|
|
748
|
-
return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
749
|
-
}
|
|
750
|
-
function IsImport(value) {
|
|
751
|
-
return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
|
|
752
|
-
}
|
|
753
|
-
function IsInteger2(value) {
|
|
754
|
-
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);
|
|
755
|
-
}
|
|
756
|
-
function IsProperties(value) {
|
|
757
|
-
return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
|
|
758
|
-
}
|
|
759
|
-
function IsIntersect2(value) {
|
|
760
|
-
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);
|
|
761
|
-
}
|
|
762
|
-
function IsIterator3(value) {
|
|
763
|
-
return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
764
|
-
}
|
|
765
|
-
function IsKindOf2(value, kind) {
|
|
766
|
-
return IsObject(value) && Kind in value && value[Kind] === kind;
|
|
767
|
-
}
|
|
768
|
-
function IsLiteralString(value) {
|
|
769
|
-
return IsLiteral2(value) && IsString(value.const);
|
|
770
|
-
}
|
|
771
|
-
function IsLiteralNumber(value) {
|
|
772
|
-
return IsLiteral2(value) && IsNumber(value.const);
|
|
773
|
-
}
|
|
774
|
-
function IsLiteralBoolean(value) {
|
|
775
|
-
return IsLiteral2(value) && IsBoolean(value.const);
|
|
776
|
-
}
|
|
777
|
-
function IsLiteral2(value) {
|
|
778
|
-
return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
|
|
779
|
-
}
|
|
780
|
-
function IsLiteralValue2(value) {
|
|
781
|
-
return IsBoolean(value) || IsNumber(value) || IsString(value);
|
|
782
|
-
}
|
|
783
|
-
function IsMappedKey2(value) {
|
|
784
|
-
return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
|
|
785
|
-
}
|
|
786
|
-
function IsMappedResult2(value) {
|
|
787
|
-
return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
|
|
788
|
-
}
|
|
789
|
-
function IsNever2(value) {
|
|
790
|
-
return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
|
|
791
|
-
}
|
|
792
|
-
function IsNot2(value) {
|
|
793
|
-
return IsKindOf2(value, "Not") && IsSchema2(value.not);
|
|
794
|
-
}
|
|
795
|
-
function IsNull3(value) {
|
|
796
|
-
return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
|
|
797
|
-
}
|
|
798
|
-
function IsNumber4(value) {
|
|
799
|
-
return IsKindOf2(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
|
|
800
|
-
}
|
|
801
|
-
function IsObject4(value) {
|
|
802
|
-
return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
|
|
803
|
-
}
|
|
804
|
-
function IsPromise2(value) {
|
|
805
|
-
return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
|
|
806
|
-
}
|
|
807
|
-
function IsRecord2(value) {
|
|
808
|
-
return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
|
|
809
|
-
const keys = Object.getOwnPropertyNames(schema.patternProperties);
|
|
810
|
-
return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
|
|
811
|
-
})(value);
|
|
812
|
-
}
|
|
813
|
-
function IsRecursive(value) {
|
|
814
|
-
return IsObject(value) && Hint in value && value[Hint] === "Recursive";
|
|
815
|
-
}
|
|
816
|
-
function IsRef2(value) {
|
|
817
|
-
return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
|
|
818
|
-
}
|
|
819
|
-
function IsRegExp3(value) {
|
|
820
|
-
return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
|
|
821
|
-
}
|
|
822
|
-
function IsString3(value) {
|
|
823
|
-
return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
|
|
824
|
-
}
|
|
825
|
-
function IsSymbol3(value) {
|
|
826
|
-
return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
|
|
827
|
-
}
|
|
828
|
-
function IsTemplateLiteral2(value) {
|
|
829
|
-
return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
|
|
830
|
-
}
|
|
831
|
-
function IsThis2(value) {
|
|
832
|
-
return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
|
|
833
|
-
}
|
|
834
|
-
function IsTransform2(value) {
|
|
835
|
-
return IsObject(value) && TransformKind in value;
|
|
836
|
-
}
|
|
837
|
-
function IsTuple2(value) {
|
|
838
|
-
return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
|
|
839
|
-
(IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
|
|
840
|
-
}
|
|
841
|
-
function IsUndefined4(value) {
|
|
842
|
-
return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
|
|
843
|
-
}
|
|
844
|
-
function IsUnionLiteral(value) {
|
|
845
|
-
return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
|
|
846
|
-
}
|
|
847
|
-
function IsUnion2(value) {
|
|
848
|
-
return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
|
|
849
|
-
}
|
|
850
|
-
function IsUint8Array3(value) {
|
|
851
|
-
return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
|
|
852
|
-
}
|
|
853
|
-
function IsUnknown2(value) {
|
|
854
|
-
return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
|
|
855
|
-
}
|
|
856
|
-
function IsUnsafe2(value) {
|
|
857
|
-
return IsKindOf2(value, "Unsafe");
|
|
858
|
-
}
|
|
859
|
-
function IsVoid2(value) {
|
|
860
|
-
return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
|
|
861
|
-
}
|
|
862
|
-
function IsKind2(value) {
|
|
863
|
-
return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
|
|
864
|
-
}
|
|
865
|
-
function IsSchema2(value) {
|
|
866
|
-
return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed2(value) || IsConstructor2(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect2(value) || IsIterator3(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull3(value) || IsNumber4(value) || IsObject4(value) || IsPromise2(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array3(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
// node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
|
|
870
|
-
var PatternBoolean = "(true|false)";
|
|
871
|
-
var PatternNumber = "(0|[1-9][0-9]*)";
|
|
872
|
-
var PatternString = "(.*)";
|
|
873
|
-
var PatternNever = "(?!.*)";
|
|
874
|
-
var PatternNumberExact = `^${PatternNumber}$`;
|
|
875
|
-
var PatternStringExact = `^${PatternString}$`;
|
|
876
|
-
var PatternNeverExact = `^${PatternNever}$`;
|
|
877
|
-
|
|
878
|
-
// node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
|
|
879
|
-
function SetIncludes(T, S) {
|
|
880
|
-
return T.includes(S);
|
|
881
|
-
}
|
|
882
|
-
function SetDistinct(T) {
|
|
883
|
-
return [...new Set(T)];
|
|
884
|
-
}
|
|
885
|
-
function SetIntersect(T, S) {
|
|
886
|
-
return T.filter((L) => S.includes(L));
|
|
887
|
-
}
|
|
888
|
-
function SetIntersectManyResolve(T, Init) {
|
|
889
|
-
return T.reduce((Acc, L) => {
|
|
890
|
-
return SetIntersect(Acc, L);
|
|
891
|
-
}, Init);
|
|
892
|
-
}
|
|
893
|
-
function SetIntersectMany(T) {
|
|
894
|
-
return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
|
|
895
|
-
}
|
|
896
|
-
function SetUnionMany(T) {
|
|
897
|
-
const Acc = [];
|
|
898
|
-
for (const L of T)
|
|
899
|
-
Acc.push(...L);
|
|
900
|
-
return Acc;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
// node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
|
|
904
|
-
function Any(options) {
|
|
905
|
-
return CreateType({ [Kind]: "Any" }, options);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
// node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
|
|
909
|
-
function Array2(items, options) {
|
|
910
|
-
return CreateType({ [Kind]: "Array", type: "array", items }, options);
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
// node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
|
|
914
|
-
function Argument(index) {
|
|
915
|
-
return CreateType({ [Kind]: "Argument", index });
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
|
|
919
|
-
function AsyncIterator(items, options) {
|
|
920
|
-
return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
// node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
|
|
924
|
-
function Computed(target, parameters, options) {
|
|
925
|
-
return CreateType({ [Kind]: "Computed", target, parameters }, options);
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
|
|
929
|
-
function DiscardKey(value, key) {
|
|
930
|
-
const { [key]: _, ...rest } = value;
|
|
931
|
-
return rest;
|
|
932
|
-
}
|
|
933
|
-
function Discard(value, keys) {
|
|
934
|
-
return keys.reduce((acc, key) => DiscardKey(acc, key), value);
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
// node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
|
|
938
|
-
function Never(options) {
|
|
939
|
-
return CreateType({ [Kind]: "Never", not: {} }, options);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
|
|
943
|
-
function MappedResult(properties) {
|
|
944
|
-
return CreateType({
|
|
945
|
-
[Kind]: "MappedResult",
|
|
946
|
-
properties
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
// node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
|
|
951
|
-
function Constructor(parameters, returns, options) {
|
|
952
|
-
return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
// node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
|
|
956
|
-
function Function(parameters, returns, options) {
|
|
957
|
-
return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
// node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
|
|
961
|
-
function UnionCreate(T, options) {
|
|
962
|
-
return CreateType({ [Kind]: "Union", anyOf: T }, options);
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
// node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
|
|
966
|
-
function IsUnionOptional(types) {
|
|
967
|
-
return types.some((type) => IsOptional(type));
|
|
968
|
-
}
|
|
969
|
-
function RemoveOptionalFromRest(types) {
|
|
970
|
-
return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
|
|
971
|
-
}
|
|
972
|
-
function RemoveOptionalFromType(T) {
|
|
973
|
-
return Discard(T, [OptionalKind]);
|
|
974
|
-
}
|
|
975
|
-
function ResolveUnion(types, options) {
|
|
976
|
-
const isOptional = IsUnionOptional(types);
|
|
977
|
-
return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
|
|
978
|
-
}
|
|
979
|
-
function UnionEvaluated(T, options) {
|
|
980
|
-
return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
// node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
|
|
984
|
-
function Union(types, options) {
|
|
985
|
-
return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
|
|
989
|
-
var TemplateLiteralParserError = class extends TypeBoxError {
|
|
990
|
-
};
|
|
991
|
-
function Unescape(pattern) {
|
|
992
|
-
return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
|
|
993
|
-
}
|
|
994
|
-
function IsNonEscaped(pattern, index, char) {
|
|
995
|
-
return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
|
|
996
|
-
}
|
|
997
|
-
function IsOpenParen(pattern, index) {
|
|
998
|
-
return IsNonEscaped(pattern, index, "(");
|
|
999
|
-
}
|
|
1000
|
-
function IsCloseParen(pattern, index) {
|
|
1001
|
-
return IsNonEscaped(pattern, index, ")");
|
|
1002
|
-
}
|
|
1003
|
-
function IsSeparator(pattern, index) {
|
|
1004
|
-
return IsNonEscaped(pattern, index, "|");
|
|
1005
|
-
}
|
|
1006
|
-
function IsGroup(pattern) {
|
|
1007
|
-
if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
|
|
1008
|
-
return false;
|
|
1009
|
-
let count = 0;
|
|
1010
|
-
for (let index = 0; index < pattern.length; index++) {
|
|
1011
|
-
if (IsOpenParen(pattern, index))
|
|
1012
|
-
count += 1;
|
|
1013
|
-
if (IsCloseParen(pattern, index))
|
|
1014
|
-
count -= 1;
|
|
1015
|
-
if (count === 0 && index !== pattern.length - 1)
|
|
1016
|
-
return false;
|
|
1017
|
-
}
|
|
1018
|
-
return true;
|
|
1019
|
-
}
|
|
1020
|
-
function InGroup(pattern) {
|
|
1021
|
-
return pattern.slice(1, pattern.length - 1);
|
|
1022
|
-
}
|
|
1023
|
-
function IsPrecedenceOr(pattern) {
|
|
1024
|
-
let count = 0;
|
|
1025
|
-
for (let index = 0; index < pattern.length; index++) {
|
|
1026
|
-
if (IsOpenParen(pattern, index))
|
|
1027
|
-
count += 1;
|
|
1028
|
-
if (IsCloseParen(pattern, index))
|
|
1029
|
-
count -= 1;
|
|
1030
|
-
if (IsSeparator(pattern, index) && count === 0)
|
|
1031
|
-
return true;
|
|
1032
|
-
}
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1035
|
-
function IsPrecedenceAnd(pattern) {
|
|
1036
|
-
for (let index = 0; index < pattern.length; index++) {
|
|
1037
|
-
if (IsOpenParen(pattern, index))
|
|
1038
|
-
return true;
|
|
1039
|
-
}
|
|
1040
|
-
return false;
|
|
1041
|
-
}
|
|
1042
|
-
function Or(pattern) {
|
|
1043
|
-
let [count, start] = [0, 0];
|
|
1044
|
-
const expressions = [];
|
|
1045
|
-
for (let index = 0; index < pattern.length; index++) {
|
|
1046
|
-
if (IsOpenParen(pattern, index))
|
|
1047
|
-
count += 1;
|
|
1048
|
-
if (IsCloseParen(pattern, index))
|
|
1049
|
-
count -= 1;
|
|
1050
|
-
if (IsSeparator(pattern, index) && count === 0) {
|
|
1051
|
-
const range2 = pattern.slice(start, index);
|
|
1052
|
-
if (range2.length > 0)
|
|
1053
|
-
expressions.push(TemplateLiteralParse(range2));
|
|
1054
|
-
start = index + 1;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
const range = pattern.slice(start);
|
|
1058
|
-
if (range.length > 0)
|
|
1059
|
-
expressions.push(TemplateLiteralParse(range));
|
|
1060
|
-
if (expressions.length === 0)
|
|
1061
|
-
return { type: "const", const: "" };
|
|
1062
|
-
if (expressions.length === 1)
|
|
1063
|
-
return expressions[0];
|
|
1064
|
-
return { type: "or", expr: expressions };
|
|
1065
|
-
}
|
|
1066
|
-
function And(pattern) {
|
|
1067
|
-
function Group(value, index) {
|
|
1068
|
-
if (!IsOpenParen(value, index))
|
|
1069
|
-
throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
|
|
1070
|
-
let count = 0;
|
|
1071
|
-
for (let scan = index; scan < value.length; scan++) {
|
|
1072
|
-
if (IsOpenParen(value, scan))
|
|
1073
|
-
count += 1;
|
|
1074
|
-
if (IsCloseParen(value, scan))
|
|
1075
|
-
count -= 1;
|
|
1076
|
-
if (count === 0)
|
|
1077
|
-
return [index, scan];
|
|
1078
|
-
}
|
|
1079
|
-
throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
|
|
1080
|
-
}
|
|
1081
|
-
function Range(pattern2, index) {
|
|
1082
|
-
for (let scan = index; scan < pattern2.length; scan++) {
|
|
1083
|
-
if (IsOpenParen(pattern2, scan))
|
|
1084
|
-
return [index, scan];
|
|
1085
|
-
}
|
|
1086
|
-
return [index, pattern2.length];
|
|
1087
|
-
}
|
|
1088
|
-
const expressions = [];
|
|
1089
|
-
for (let index = 0; index < pattern.length; index++) {
|
|
1090
|
-
if (IsOpenParen(pattern, index)) {
|
|
1091
|
-
const [start, end] = Group(pattern, index);
|
|
1092
|
-
const range = pattern.slice(start, end + 1);
|
|
1093
|
-
expressions.push(TemplateLiteralParse(range));
|
|
1094
|
-
index = end;
|
|
1095
|
-
} else {
|
|
1096
|
-
const [start, end] = Range(pattern, index);
|
|
1097
|
-
const range = pattern.slice(start, end);
|
|
1098
|
-
if (range.length > 0)
|
|
1099
|
-
expressions.push(TemplateLiteralParse(range));
|
|
1100
|
-
index = end - 1;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
|
|
1104
|
-
}
|
|
1105
|
-
function TemplateLiteralParse(pattern) {
|
|
1106
|
-
return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
|
|
1107
|
-
}
|
|
1108
|
-
function TemplateLiteralParseExact(pattern) {
|
|
1109
|
-
return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
|
|
1113
|
-
var TemplateLiteralFiniteError = class extends TypeBoxError {
|
|
1114
|
-
};
|
|
1115
|
-
function IsNumberExpression(expression) {
|
|
1116
|
-
return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
|
|
1117
|
-
}
|
|
1118
|
-
function IsBooleanExpression(expression) {
|
|
1119
|
-
return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
|
|
1120
|
-
}
|
|
1121
|
-
function IsStringExpression(expression) {
|
|
1122
|
-
return expression.type === "const" && expression.const === ".*";
|
|
1123
|
-
}
|
|
1124
|
-
function IsTemplateLiteralExpressionFinite(expression) {
|
|
1125
|
-
return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
|
|
1126
|
-
throw new TemplateLiteralFiniteError(`Unknown expression type`);
|
|
1127
|
-
})();
|
|
1128
|
-
}
|
|
1129
|
-
function IsTemplateLiteralFinite(schema) {
|
|
1130
|
-
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
1131
|
-
return IsTemplateLiteralExpressionFinite(expression);
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
|
|
1135
|
-
var TemplateLiteralGenerateError = class extends TypeBoxError {
|
|
1136
|
-
};
|
|
1137
|
-
function* GenerateReduce(buffer) {
|
|
1138
|
-
if (buffer.length === 1)
|
|
1139
|
-
return yield* buffer[0];
|
|
1140
|
-
for (const left of buffer[0]) {
|
|
1141
|
-
for (const right of GenerateReduce(buffer.slice(1))) {
|
|
1142
|
-
yield `${left}${right}`;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
function* GenerateAnd(expression) {
|
|
1147
|
-
return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
|
|
1148
|
-
}
|
|
1149
|
-
function* GenerateOr(expression) {
|
|
1150
|
-
for (const expr of expression.expr)
|
|
1151
|
-
yield* TemplateLiteralExpressionGenerate(expr);
|
|
1152
|
-
}
|
|
1153
|
-
function* GenerateConst(expression) {
|
|
1154
|
-
return yield expression.const;
|
|
1155
|
-
}
|
|
1156
|
-
function* TemplateLiteralExpressionGenerate(expression) {
|
|
1157
|
-
return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
|
|
1158
|
-
throw new TemplateLiteralGenerateError("Unknown expression");
|
|
1159
|
-
})();
|
|
1160
|
-
}
|
|
1161
|
-
function TemplateLiteralGenerate(schema) {
|
|
1162
|
-
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
1163
|
-
return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
// node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
|
|
1167
|
-
function Literal(value, options) {
|
|
1168
|
-
return CreateType({
|
|
1169
|
-
[Kind]: "Literal",
|
|
1170
|
-
const: value,
|
|
1171
|
-
type: typeof value
|
|
1172
|
-
}, options);
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
// node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
|
|
1176
|
-
function Boolean(options) {
|
|
1177
|
-
return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
// node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
|
|
1181
|
-
function BigInt(options) {
|
|
1182
|
-
return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
// node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
|
|
1186
|
-
function Number2(options) {
|
|
1187
|
-
return CreateType({ [Kind]: "Number", type: "number" }, options);
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
// node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
|
|
1191
|
-
function String2(options) {
|
|
1192
|
-
return CreateType({ [Kind]: "String", type: "string" }, options);
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
|
|
1196
|
-
function* FromUnion(syntax) {
|
|
1197
|
-
const trim = syntax.trim().replace(/"|'/g, "");
|
|
1198
|
-
return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
|
|
1199
|
-
const literals = trim.split("|").map((literal) => Literal(literal.trim()));
|
|
1200
|
-
return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
|
|
1201
|
-
})();
|
|
1202
|
-
}
|
|
1203
|
-
function* FromTerminal(syntax) {
|
|
1204
|
-
if (syntax[1] !== "{") {
|
|
1205
|
-
const L = Literal("$");
|
|
1206
|
-
const R = FromSyntax(syntax.slice(1));
|
|
1207
|
-
return yield* [L, ...R];
|
|
1208
|
-
}
|
|
1209
|
-
for (let i = 2; i < syntax.length; i++) {
|
|
1210
|
-
if (syntax[i] === "}") {
|
|
1211
|
-
const L = FromUnion(syntax.slice(2, i));
|
|
1212
|
-
const R = FromSyntax(syntax.slice(i + 1));
|
|
1213
|
-
return yield* [...L, ...R];
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
yield Literal(syntax);
|
|
1217
|
-
}
|
|
1218
|
-
function* FromSyntax(syntax) {
|
|
1219
|
-
for (let i = 0; i < syntax.length; i++) {
|
|
1220
|
-
if (syntax[i] === "$") {
|
|
1221
|
-
const L = Literal(syntax.slice(0, i));
|
|
1222
|
-
const R = FromTerminal(syntax.slice(i));
|
|
1223
|
-
return yield* [L, ...R];
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
yield Literal(syntax);
|
|
1227
|
-
}
|
|
1228
|
-
function TemplateLiteralSyntax(syntax) {
|
|
1229
|
-
return [...FromSyntax(syntax)];
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
|
|
1233
|
-
var TemplateLiteralPatternError = class extends TypeBoxError {
|
|
1234
|
-
};
|
|
1235
|
-
function Escape(value) {
|
|
1236
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1237
|
-
}
|
|
1238
|
-
function Visit2(schema, acc) {
|
|
1239
|
-
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}` : IsInteger(schema) ? `${acc}${PatternNumber}` : IsBigInt2(schema) ? `${acc}${PatternNumber}` : IsString2(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean2(schema) ? `${acc}${PatternBoolean}` : (() => {
|
|
1240
|
-
throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
|
|
1241
|
-
})();
|
|
1242
|
-
}
|
|
1243
|
-
function TemplateLiteralPattern(kinds) {
|
|
1244
|
-
return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
|
|
1248
|
-
function TemplateLiteralToUnion(schema) {
|
|
1249
|
-
const R = TemplateLiteralGenerate(schema);
|
|
1250
|
-
const L = R.map((S) => Literal(S));
|
|
1251
|
-
return UnionEvaluated(L);
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
// node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
|
|
1255
|
-
function TemplateLiteral(unresolved, options) {
|
|
1256
|
-
const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
|
|
1257
|
-
return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
|
|
1261
|
-
function FromTemplateLiteral(templateLiteral) {
|
|
1262
|
-
const keys = TemplateLiteralGenerate(templateLiteral);
|
|
1263
|
-
return keys.map((key) => key.toString());
|
|
1264
|
-
}
|
|
1265
|
-
function FromUnion2(types) {
|
|
1266
|
-
const result = [];
|
|
1267
|
-
for (const type of types)
|
|
1268
|
-
result.push(...IndexPropertyKeys(type));
|
|
1269
|
-
return result;
|
|
1270
|
-
}
|
|
1271
|
-
function FromLiteral(literalValue) {
|
|
1272
|
-
return [literalValue.toString()];
|
|
1273
|
-
}
|
|
1274
|
-
function IndexPropertyKeys(type) {
|
|
1275
|
-
return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
|
|
1279
|
-
function FromProperties(type, properties, options) {
|
|
1280
|
-
const result = {};
|
|
1281
|
-
for (const K2 of Object.getOwnPropertyNames(properties)) {
|
|
1282
|
-
result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
|
|
1283
|
-
}
|
|
1284
|
-
return result;
|
|
1285
|
-
}
|
|
1286
|
-
function FromMappedResult(type, mappedResult, options) {
|
|
1287
|
-
return FromProperties(type, mappedResult.properties, options);
|
|
1288
|
-
}
|
|
1289
|
-
function IndexFromMappedResult(type, mappedResult, options) {
|
|
1290
|
-
const properties = FromMappedResult(type, mappedResult, options);
|
|
1291
|
-
return MappedResult(properties);
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
|
|
1295
|
-
function FromRest(types, key) {
|
|
1296
|
-
return types.map((type) => IndexFromPropertyKey(type, key));
|
|
1297
|
-
}
|
|
1298
|
-
function FromIntersectRest(types) {
|
|
1299
|
-
return types.filter((type) => !IsNever(type));
|
|
1300
|
-
}
|
|
1301
|
-
function FromIntersect(types, key) {
|
|
1302
|
-
return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
|
|
1303
|
-
}
|
|
1304
|
-
function FromUnionRest(types) {
|
|
1305
|
-
return types.some((L) => IsNever(L)) ? [] : types;
|
|
1306
|
-
}
|
|
1307
|
-
function FromUnion3(types, key) {
|
|
1308
|
-
return UnionEvaluated(FromUnionRest(FromRest(types, key)));
|
|
1309
|
-
}
|
|
1310
|
-
function FromTuple(types, key) {
|
|
1311
|
-
return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
|
|
1312
|
-
}
|
|
1313
|
-
function FromArray(type, key) {
|
|
1314
|
-
return key === "[number]" ? type : Never();
|
|
1315
|
-
}
|
|
1316
|
-
function FromProperty(properties, propertyKey) {
|
|
1317
|
-
return propertyKey in properties ? properties[propertyKey] : Never();
|
|
1318
|
-
}
|
|
1319
|
-
function IndexFromPropertyKey(type, propertyKey) {
|
|
1320
|
-
return IsIntersect(type) ? FromIntersect(type.allOf, propertyKey) : IsUnion(type) ? FromUnion3(type.anyOf, propertyKey) : IsTuple(type) ? FromTuple(type.items ?? [], propertyKey) : IsArray3(type) ? FromArray(type.items, propertyKey) : IsObject3(type) ? FromProperty(type.properties, propertyKey) : Never();
|
|
1321
|
-
}
|
|
1322
|
-
function IndexFromPropertyKeys(type, propertyKeys) {
|
|
1323
|
-
return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
|
|
1324
|
-
}
|
|
1325
|
-
function FromSchema(type, propertyKeys) {
|
|
1326
|
-
return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
|
|
1327
|
-
}
|
|
1328
|
-
function Index(type, key, options) {
|
|
1329
|
-
if (IsRef(type) || IsRef(key)) {
|
|
1330
|
-
const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
|
|
1331
|
-
if (!IsSchema(type) || !IsSchema(key))
|
|
1332
|
-
throw new TypeBoxError(error);
|
|
1333
|
-
return Computed("Index", [type, key]);
|
|
1334
|
-
}
|
|
1335
|
-
if (IsMappedResult(key))
|
|
1336
|
-
return IndexFromMappedResult(type, key, options);
|
|
1337
|
-
if (IsMappedKey(key))
|
|
1338
|
-
return IndexFromMappedKey(type, key, options);
|
|
1339
|
-
return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
|
|
1343
|
-
function MappedIndexPropertyKey(type, key, options) {
|
|
1344
|
-
return { [key]: Index(type, [key], Clone(options)) };
|
|
1345
|
-
}
|
|
1346
|
-
function MappedIndexPropertyKeys(type, propertyKeys, options) {
|
|
1347
|
-
return propertyKeys.reduce((result, left) => {
|
|
1348
|
-
return { ...result, ...MappedIndexPropertyKey(type, left, options) };
|
|
1349
|
-
}, {});
|
|
1350
|
-
}
|
|
1351
|
-
function MappedIndexProperties(type, mappedKey, options) {
|
|
1352
|
-
return MappedIndexPropertyKeys(type, mappedKey.keys, options);
|
|
1353
|
-
}
|
|
1354
|
-
function IndexFromMappedKey(type, mappedKey, options) {
|
|
1355
|
-
const properties = MappedIndexProperties(type, mappedKey, options);
|
|
1356
|
-
return MappedResult(properties);
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
// node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
|
|
1360
|
-
function Iterator(items, options) {
|
|
1361
|
-
return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
// node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
|
|
1365
|
-
function RequiredArray(properties) {
|
|
1366
|
-
return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
|
|
1367
|
-
}
|
|
1368
|
-
function _Object(properties, options) {
|
|
1369
|
-
const required = RequiredArray(properties);
|
|
1370
|
-
const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
|
|
1371
|
-
return CreateType(schema, options);
|
|
1372
|
-
}
|
|
1373
|
-
var Object2 = _Object;
|
|
1374
|
-
|
|
1375
|
-
// node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
|
|
1376
|
-
function Promise2(item, options) {
|
|
1377
|
-
return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
// node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
|
|
1381
|
-
function RemoveReadonly(schema) {
|
|
1382
|
-
return CreateType(Discard(schema, [ReadonlyKind]));
|
|
1383
|
-
}
|
|
1384
|
-
function AddReadonly(schema) {
|
|
1385
|
-
return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
|
|
1386
|
-
}
|
|
1387
|
-
function ReadonlyWithFlag(schema, F) {
|
|
1388
|
-
return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
|
|
1389
|
-
}
|
|
1390
|
-
function Readonly(schema, enable) {
|
|
1391
|
-
const F = enable ?? true;
|
|
1392
|
-
return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
// node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
|
|
1396
|
-
function FromProperties2(K, F) {
|
|
1397
|
-
const Acc = {};
|
|
1398
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
1399
|
-
Acc[K2] = Readonly(K[K2], F);
|
|
1400
|
-
return Acc;
|
|
1401
|
-
}
|
|
1402
|
-
function FromMappedResult2(R, F) {
|
|
1403
|
-
return FromProperties2(R.properties, F);
|
|
1404
|
-
}
|
|
1405
|
-
function ReadonlyFromMappedResult(R, F) {
|
|
1406
|
-
const P = FromMappedResult2(R, F);
|
|
1407
|
-
return MappedResult(P);
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
// node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
|
|
1411
|
-
function Tuple(types, options) {
|
|
1412
|
-
return CreateType(types.length > 0 ? { [Kind]: "Tuple", type: "array", items: types, additionalItems: false, minItems: types.length, maxItems: types.length } : { [Kind]: "Tuple", type: "array", minItems: types.length, maxItems: types.length }, options);
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
// node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
|
|
1416
|
-
function FromMappedResult3(K, P) {
|
|
1417
|
-
return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
|
|
1418
|
-
}
|
|
1419
|
-
function MappedKeyToKnownMappedResultProperties(K) {
|
|
1420
|
-
return { [K]: Literal(K) };
|
|
1421
|
-
}
|
|
1422
|
-
function MappedKeyToUnknownMappedResultProperties(P) {
|
|
1423
|
-
const Acc = {};
|
|
1424
|
-
for (const L of P)
|
|
1425
|
-
Acc[L] = Literal(L);
|
|
1426
|
-
return Acc;
|
|
1427
|
-
}
|
|
1428
|
-
function MappedKeyToMappedResultProperties(K, P) {
|
|
1429
|
-
return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
|
|
1430
|
-
}
|
|
1431
|
-
function FromMappedKey(K, P) {
|
|
1432
|
-
const R = MappedKeyToMappedResultProperties(K, P);
|
|
1433
|
-
return FromMappedResult3(K, R);
|
|
1434
|
-
}
|
|
1435
|
-
function FromRest2(K, T) {
|
|
1436
|
-
return T.map((L) => FromSchemaType(K, L));
|
|
1437
|
-
}
|
|
1438
|
-
function FromProperties3(K, T) {
|
|
1439
|
-
const Acc = {};
|
|
1440
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(T))
|
|
1441
|
-
Acc[K2] = FromSchemaType(K, T[K2]);
|
|
1442
|
-
return Acc;
|
|
1443
|
-
}
|
|
1444
|
-
function FromSchemaType(K, T) {
|
|
1445
|
-
const options = { ...T };
|
|
1446
|
-
return (
|
|
1447
|
-
// unevaluated modifier types
|
|
1448
|
-
IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
|
|
1449
|
-
// unevaluated mapped types
|
|
1450
|
-
IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
|
|
1451
|
-
// unevaluated types
|
|
1452
|
-
IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction2(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator2(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator2(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) : IsPromise(T) ? Promise2(FromSchemaType(K, T.item), options) : T
|
|
1453
|
-
)
|
|
1454
|
-
)
|
|
1455
|
-
);
|
|
1456
|
-
}
|
|
1457
|
-
function MappedFunctionReturnType(K, T) {
|
|
1458
|
-
const Acc = {};
|
|
1459
|
-
for (const L of K)
|
|
1460
|
-
Acc[L] = FromSchemaType(L, T);
|
|
1461
|
-
return Acc;
|
|
1462
|
-
}
|
|
1463
|
-
function Mapped(key, map, options) {
|
|
1464
|
-
const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
1465
|
-
const RT = map({ [Kind]: "MappedKey", keys: K });
|
|
1466
|
-
const R = MappedFunctionReturnType(K, RT);
|
|
1467
|
-
return Object2(R, options);
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
// node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
|
|
1471
|
-
function RemoveOptional(schema) {
|
|
1472
|
-
return CreateType(Discard(schema, [OptionalKind]));
|
|
1473
|
-
}
|
|
1474
|
-
function AddOptional(schema) {
|
|
1475
|
-
return CreateType({ ...schema, [OptionalKind]: "Optional" });
|
|
1476
|
-
}
|
|
1477
|
-
function OptionalWithFlag(schema, F) {
|
|
1478
|
-
return F === false ? RemoveOptional(schema) : AddOptional(schema);
|
|
1479
|
-
}
|
|
1480
|
-
function Optional(schema, enable) {
|
|
1481
|
-
const F = enable ?? true;
|
|
1482
|
-
return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
// node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
|
|
1486
|
-
function FromProperties4(P, F) {
|
|
1487
|
-
const Acc = {};
|
|
1488
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
1489
|
-
Acc[K2] = Optional(P[K2], F);
|
|
1490
|
-
return Acc;
|
|
1491
|
-
}
|
|
1492
|
-
function FromMappedResult4(R, F) {
|
|
1493
|
-
return FromProperties4(R.properties, F);
|
|
1494
|
-
}
|
|
1495
|
-
function OptionalFromMappedResult(R, F) {
|
|
1496
|
-
const P = FromMappedResult4(R, F);
|
|
1497
|
-
return MappedResult(P);
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
|
|
1501
|
-
function IntersectCreate(T, options = {}) {
|
|
1502
|
-
const allObjects = T.every((schema) => IsObject3(schema));
|
|
1503
|
-
const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
|
|
1504
|
-
return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
|
|
1508
|
-
function IsIntersectOptional(types) {
|
|
1509
|
-
return types.every((left) => IsOptional(left));
|
|
1510
|
-
}
|
|
1511
|
-
function RemoveOptionalFromType2(type) {
|
|
1512
|
-
return Discard(type, [OptionalKind]);
|
|
1513
|
-
}
|
|
1514
|
-
function RemoveOptionalFromRest2(types) {
|
|
1515
|
-
return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
|
|
1516
|
-
}
|
|
1517
|
-
function ResolveIntersect(types, options) {
|
|
1518
|
-
return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
|
|
1519
|
-
}
|
|
1520
|
-
function IntersectEvaluated(types, options = {}) {
|
|
1521
|
-
if (types.length === 1)
|
|
1522
|
-
return CreateType(types[0], options);
|
|
1523
|
-
if (types.length === 0)
|
|
1524
|
-
return Never(options);
|
|
1525
|
-
if (types.some((schema) => IsTransform(schema)))
|
|
1526
|
-
throw new Error("Cannot intersect transform types");
|
|
1527
|
-
return ResolveIntersect(types, options);
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
|
|
1531
|
-
function Intersect(types, options) {
|
|
1532
|
-
if (types.length === 1)
|
|
1533
|
-
return CreateType(types[0], options);
|
|
1534
|
-
if (types.length === 0)
|
|
1535
|
-
return Never(options);
|
|
1536
|
-
if (types.some((schema) => IsTransform(schema)))
|
|
1537
|
-
throw new Error("Cannot intersect transform types");
|
|
1538
|
-
return IntersectCreate(types, options);
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
// node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
|
|
1542
|
-
function Ref(...args) {
|
|
1543
|
-
const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
|
|
1544
|
-
if (typeof $ref !== "string")
|
|
1545
|
-
throw new TypeBoxError("Ref: $ref must be a string");
|
|
1546
|
-
return CreateType({ [Kind]: "Ref", $ref }, options);
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
// node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
|
|
1550
|
-
function FromComputed(target, parameters) {
|
|
1551
|
-
return Computed("Awaited", [Computed(target, parameters)]);
|
|
1552
|
-
}
|
|
1553
|
-
function FromRef($ref) {
|
|
1554
|
-
return Computed("Awaited", [Ref($ref)]);
|
|
1555
|
-
}
|
|
1556
|
-
function FromIntersect2(types) {
|
|
1557
|
-
return Intersect(FromRest3(types));
|
|
1558
|
-
}
|
|
1559
|
-
function FromUnion4(types) {
|
|
1560
|
-
return Union(FromRest3(types));
|
|
1561
|
-
}
|
|
1562
|
-
function FromPromise(type) {
|
|
1563
|
-
return Awaited(type);
|
|
1564
|
-
}
|
|
1565
|
-
function FromRest3(types) {
|
|
1566
|
-
return types.map((type) => Awaited(type));
|
|
1567
|
-
}
|
|
1568
|
-
function Awaited(type, options) {
|
|
1569
|
-
return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
|
|
1573
|
-
function FromRest4(types) {
|
|
1574
|
-
const result = [];
|
|
1575
|
-
for (const L of types)
|
|
1576
|
-
result.push(KeyOfPropertyKeys(L));
|
|
1577
|
-
return result;
|
|
1578
|
-
}
|
|
1579
|
-
function FromIntersect3(types) {
|
|
1580
|
-
const propertyKeysArray = FromRest4(types);
|
|
1581
|
-
const propertyKeys = SetUnionMany(propertyKeysArray);
|
|
1582
|
-
return propertyKeys;
|
|
1583
|
-
}
|
|
1584
|
-
function FromUnion5(types) {
|
|
1585
|
-
const propertyKeysArray = FromRest4(types);
|
|
1586
|
-
const propertyKeys = SetIntersectMany(propertyKeysArray);
|
|
1587
|
-
return propertyKeys;
|
|
1588
|
-
}
|
|
1589
|
-
function FromTuple2(types) {
|
|
1590
|
-
return types.map((_, indexer) => indexer.toString());
|
|
1591
|
-
}
|
|
1592
|
-
function FromArray2(_) {
|
|
1593
|
-
return ["[number]"];
|
|
1594
|
-
}
|
|
1595
|
-
function FromProperties5(T) {
|
|
1596
|
-
return globalThis.Object.getOwnPropertyNames(T);
|
|
1597
|
-
}
|
|
1598
|
-
function FromPatternProperties(patternProperties) {
|
|
1599
|
-
return [];
|
|
1600
|
-
}
|
|
1601
|
-
function KeyOfPropertyKeys(type) {
|
|
1602
|
-
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) : [];
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
|
|
1606
|
-
function FromComputed2(target, parameters) {
|
|
1607
|
-
return Computed("KeyOf", [Computed(target, parameters)]);
|
|
1608
|
-
}
|
|
1609
|
-
function FromRef2($ref) {
|
|
1610
|
-
return Computed("KeyOf", [Ref($ref)]);
|
|
1611
|
-
}
|
|
1612
|
-
function KeyOfFromType(type, options) {
|
|
1613
|
-
const propertyKeys = KeyOfPropertyKeys(type);
|
|
1614
|
-
const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
|
|
1615
|
-
const result = UnionEvaluated(propertyKeyTypes);
|
|
1616
|
-
return CreateType(result, options);
|
|
1617
|
-
}
|
|
1618
|
-
function KeyOfPropertyKeysToRest(propertyKeys) {
|
|
1619
|
-
return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
|
|
1620
|
-
}
|
|
1621
|
-
function KeyOf(type, options) {
|
|
1622
|
-
return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
|
|
1626
|
-
function FromProperties6(properties, options) {
|
|
1627
|
-
const result = {};
|
|
1628
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
1629
|
-
result[K2] = KeyOf(properties[K2], Clone(options));
|
|
1630
|
-
return result;
|
|
1631
|
-
}
|
|
1632
|
-
function FromMappedResult5(mappedResult, options) {
|
|
1633
|
-
return FromProperties6(mappedResult.properties, options);
|
|
1634
|
-
}
|
|
1635
|
-
function KeyOfFromMappedResult(mappedResult, options) {
|
|
1636
|
-
const properties = FromMappedResult5(mappedResult, options);
|
|
1637
|
-
return MappedResult(properties);
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
// node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
|
|
1641
|
-
function CompositeKeys(T) {
|
|
1642
|
-
const Acc = [];
|
|
1643
|
-
for (const L of T)
|
|
1644
|
-
Acc.push(...KeyOfPropertyKeys(L));
|
|
1645
|
-
return SetDistinct(Acc);
|
|
1646
|
-
}
|
|
1647
|
-
function FilterNever(T) {
|
|
1648
|
-
return T.filter((L) => !IsNever(L));
|
|
1649
|
-
}
|
|
1650
|
-
function CompositeProperty(T, K) {
|
|
1651
|
-
const Acc = [];
|
|
1652
|
-
for (const L of T)
|
|
1653
|
-
Acc.push(...IndexFromPropertyKeys(L, [K]));
|
|
1654
|
-
return FilterNever(Acc);
|
|
1655
|
-
}
|
|
1656
|
-
function CompositeProperties(T, K) {
|
|
1657
|
-
const Acc = {};
|
|
1658
|
-
for (const L of K) {
|
|
1659
|
-
Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
|
|
1660
|
-
}
|
|
1661
|
-
return Acc;
|
|
1662
|
-
}
|
|
1663
|
-
function Composite(T, options) {
|
|
1664
|
-
const K = CompositeKeys(T);
|
|
1665
|
-
const P = CompositeProperties(T, K);
|
|
1666
|
-
const R = Object2(P, options);
|
|
1667
|
-
return R;
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
// node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
|
|
1671
|
-
function Date2(options) {
|
|
1672
|
-
return CreateType({ [Kind]: "Date", type: "Date" }, options);
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
// node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
|
|
1676
|
-
function Null(options) {
|
|
1677
|
-
return CreateType({ [Kind]: "Null", type: "null" }, options);
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
// node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
|
|
1681
|
-
function Symbol2(options) {
|
|
1682
|
-
return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
// node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
|
|
1686
|
-
function Undefined(options) {
|
|
1687
|
-
return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
// node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
|
|
1691
|
-
function Uint8Array2(options) {
|
|
1692
|
-
return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
// node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
|
|
1696
|
-
function Unknown(options) {
|
|
1697
|
-
return CreateType({ [Kind]: "Unknown" }, options);
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
// node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
|
|
1701
|
-
function FromArray3(T) {
|
|
1702
|
-
return T.map((L) => FromValue(L, false));
|
|
1703
|
-
}
|
|
1704
|
-
function FromProperties7(value) {
|
|
1705
|
-
const Acc = {};
|
|
1706
|
-
for (const K of globalThis.Object.getOwnPropertyNames(value))
|
|
1707
|
-
Acc[K] = Readonly(FromValue(value[K], false));
|
|
1708
|
-
return Acc;
|
|
1709
|
-
}
|
|
1710
|
-
function ConditionalReadonly(T, root) {
|
|
1711
|
-
return root === true ? T : Readonly(T);
|
|
1712
|
-
}
|
|
1713
|
-
function FromValue(value, root) {
|
|
1714
|
-
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) ? BigInt() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
|
|
1715
|
-
}
|
|
1716
|
-
function Const(T, options) {
|
|
1717
|
-
return CreateType(FromValue(T, true), options);
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
// node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
|
|
1721
|
-
function ConstructorParameters(schema, options) {
|
|
1722
|
-
return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
// node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
|
|
1726
|
-
function Enum(item, options) {
|
|
1727
|
-
if (IsUndefined(item))
|
|
1728
|
-
throw new Error("Enum undefined or empty");
|
|
1729
|
-
const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
|
|
1730
|
-
const values2 = [...new Set(values1)];
|
|
1731
|
-
const anyOf = values2.map((value) => Literal(value));
|
|
1732
|
-
return Union(anyOf, { ...options, [Hint]: "Enum" });
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
|
|
1736
|
-
var ExtendsResolverError = class extends TypeBoxError {
|
|
1737
|
-
};
|
|
1738
|
-
var ExtendsResult;
|
|
1739
|
-
(function(ExtendsResult2) {
|
|
1740
|
-
ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
|
|
1741
|
-
ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
|
|
1742
|
-
ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
|
|
1743
|
-
})(ExtendsResult || (ExtendsResult = {}));
|
|
1744
|
-
function IntoBooleanResult(result) {
|
|
1745
|
-
return result === ExtendsResult.False ? result : ExtendsResult.True;
|
|
1746
|
-
}
|
|
1747
|
-
function Throw(message) {
|
|
1748
|
-
throw new ExtendsResolverError(message);
|
|
1749
|
-
}
|
|
1750
|
-
function IsStructuralRight(right) {
|
|
1751
|
-
return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
|
|
1752
|
-
}
|
|
1753
|
-
function StructuralRight(left, right) {
|
|
1754
|
-
return type_exports.IsNever(right) ? FromNeverRight() : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight() : type_exports.IsAny(right) ? FromAnyRight() : Throw("StructuralRight");
|
|
1755
|
-
}
|
|
1756
|
-
function FromAnyRight(left, right) {
|
|
1757
|
-
return ExtendsResult.True;
|
|
1758
|
-
}
|
|
1759
|
-
function FromAny(left, right) {
|
|
1760
|
-
return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) && right.anyOf.some((schema) => type_exports.IsAny(schema) || type_exports.IsUnknown(schema)) ? ExtendsResult.True : type_exports.IsUnion(right) ? ExtendsResult.Union : type_exports.IsUnknown(right) ? ExtendsResult.True : type_exports.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
|
|
1761
|
-
}
|
|
1762
|
-
function FromArrayRight(left, right) {
|
|
1763
|
-
return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
1764
|
-
}
|
|
1765
|
-
function FromArray4(left, right) {
|
|
1766
|
-
return type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
1767
|
-
}
|
|
1768
|
-
function FromAsyncIterator(left, right) {
|
|
1769
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
1770
|
-
}
|
|
1771
|
-
function FromBigInt(left, right) {
|
|
1772
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1773
|
-
}
|
|
1774
|
-
function FromBooleanRight(left, right) {
|
|
1775
|
-
return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
1776
|
-
}
|
|
1777
|
-
function FromBoolean(left, right) {
|
|
1778
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1779
|
-
}
|
|
1780
|
-
function FromConstructor(left, right) {
|
|
1781
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
|
|
1782
|
-
}
|
|
1783
|
-
function FromDate(left, right) {
|
|
1784
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1785
|
-
}
|
|
1786
|
-
function FromFunction(left, right) {
|
|
1787
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
|
|
1788
|
-
}
|
|
1789
|
-
function FromIntegerRight(left, right) {
|
|
1790
|
-
return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
1791
|
-
}
|
|
1792
|
-
function FromInteger(left, right) {
|
|
1793
|
-
return type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
|
|
1794
|
-
}
|
|
1795
|
-
function FromIntersectRight(left, right) {
|
|
1796
|
-
return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
1797
|
-
}
|
|
1798
|
-
function FromIntersect4(left, right) {
|
|
1799
|
-
return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
1800
|
-
}
|
|
1801
|
-
function FromIterator(left, right) {
|
|
1802
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
1803
|
-
}
|
|
1804
|
-
function FromLiteral2(left, right) {
|
|
1805
|
-
return type_exports.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? FromStringRight(left) : type_exports.IsNumber(right) ? FromNumberRight(left) : type_exports.IsInteger(right) ? FromIntegerRight(left) : type_exports.IsBoolean(right) ? FromBooleanRight(left) : ExtendsResult.False;
|
|
1806
|
-
}
|
|
1807
|
-
function FromNeverRight(left, right) {
|
|
1808
|
-
return ExtendsResult.False;
|
|
1809
|
-
}
|
|
1810
|
-
function FromNever(left, right) {
|
|
1811
|
-
return ExtendsResult.True;
|
|
1812
|
-
}
|
|
1813
|
-
function UnwrapTNot(schema) {
|
|
1814
|
-
let [current, depth] = [schema, 0];
|
|
1815
|
-
while (true) {
|
|
1816
|
-
if (!type_exports.IsNot(current))
|
|
1817
|
-
break;
|
|
1818
|
-
current = current.not;
|
|
1819
|
-
depth += 1;
|
|
1820
|
-
}
|
|
1821
|
-
return depth % 2 === 0 ? current : Unknown();
|
|
1822
|
-
}
|
|
1823
|
-
function FromNot(left, right) {
|
|
1824
|
-
return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
|
|
1825
|
-
}
|
|
1826
|
-
function FromNull(left, right) {
|
|
1827
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1828
|
-
}
|
|
1829
|
-
function FromNumberRight(left, right) {
|
|
1830
|
-
return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
1831
|
-
}
|
|
1832
|
-
function FromNumber(left, right) {
|
|
1833
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1834
|
-
}
|
|
1835
|
-
function IsObjectPropertyCount(schema, count) {
|
|
1836
|
-
return Object.getOwnPropertyNames(schema.properties).length === count;
|
|
1837
|
-
}
|
|
1838
|
-
function IsObjectStringLike(schema) {
|
|
1839
|
-
return IsObjectArrayLike(schema);
|
|
1840
|
-
}
|
|
1841
|
-
function IsObjectSymbolLike(schema) {
|
|
1842
|
-
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && type_exports.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (type_exports.IsString(schema.properties.description.anyOf[0]) && type_exports.IsUndefined(schema.properties.description.anyOf[1]) || type_exports.IsString(schema.properties.description.anyOf[1]) && type_exports.IsUndefined(schema.properties.description.anyOf[0]));
|
|
1843
|
-
}
|
|
1844
|
-
function IsObjectNumberLike(schema) {
|
|
1845
|
-
return IsObjectPropertyCount(schema, 0);
|
|
1846
|
-
}
|
|
1847
|
-
function IsObjectBooleanLike(schema) {
|
|
1848
|
-
return IsObjectPropertyCount(schema, 0);
|
|
1849
|
-
}
|
|
1850
|
-
function IsObjectBigIntLike(schema) {
|
|
1851
|
-
return IsObjectPropertyCount(schema, 0);
|
|
1852
|
-
}
|
|
1853
|
-
function IsObjectDateLike(schema) {
|
|
1854
|
-
return IsObjectPropertyCount(schema, 0);
|
|
1855
|
-
}
|
|
1856
|
-
function IsObjectUint8ArrayLike(schema) {
|
|
1857
|
-
return IsObjectArrayLike(schema);
|
|
1858
|
-
}
|
|
1859
|
-
function IsObjectFunctionLike(schema) {
|
|
1860
|
-
const length = Number2();
|
|
1861
|
-
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
|
|
1862
|
-
}
|
|
1863
|
-
function IsObjectConstructorLike(schema) {
|
|
1864
|
-
return IsObjectPropertyCount(schema, 0);
|
|
1865
|
-
}
|
|
1866
|
-
function IsObjectArrayLike(schema) {
|
|
1867
|
-
const length = Number2();
|
|
1868
|
-
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
|
|
1869
|
-
}
|
|
1870
|
-
function IsObjectPromiseLike(schema) {
|
|
1871
|
-
const then = Function([Any()], Any());
|
|
1872
|
-
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
|
|
1873
|
-
}
|
|
1874
|
-
function Property(left, right) {
|
|
1875
|
-
return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
|
|
1876
|
-
}
|
|
1877
|
-
function FromObjectRight(left, right) {
|
|
1878
|
-
return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) || type_exports.IsLiteralString(left) && IsObjectStringLike(right) || type_exports.IsLiteralNumber(left) && IsObjectNumberLike(right) || type_exports.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsBigInt(left) && IsObjectBigIntLike(right) || type_exports.IsString(left) && IsObjectStringLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsNumber(left) && IsObjectNumberLike(right) || type_exports.IsInteger(left) && IsObjectNumberLike(right) || type_exports.IsBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || type_exports.IsDate(left) && IsObjectDateLike(right) || type_exports.IsConstructor(left) && IsObjectConstructorLike(right) || type_exports.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : type_exports.IsRecord(left) && type_exports.IsString(RecordKey(left)) ? (() => {
|
|
1879
|
-
return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
|
|
1880
|
-
})() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
|
|
1881
|
-
return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
|
|
1882
|
-
})() : ExtendsResult.False;
|
|
1883
|
-
}
|
|
1884
|
-
function FromObject(left, right) {
|
|
1885
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
|
|
1886
|
-
for (const key of Object.getOwnPropertyNames(right.properties)) {
|
|
1887
|
-
if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
|
|
1888
|
-
return ExtendsResult.False;
|
|
1889
|
-
}
|
|
1890
|
-
if (type_exports.IsOptional(right.properties[key])) {
|
|
1891
|
-
return ExtendsResult.True;
|
|
1892
|
-
}
|
|
1893
|
-
if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
|
|
1894
|
-
return ExtendsResult.False;
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
return ExtendsResult.True;
|
|
1898
|
-
})();
|
|
1899
|
-
}
|
|
1900
|
-
function FromPromise2(left, right) {
|
|
1901
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !type_exports.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
|
|
1902
|
-
}
|
|
1903
|
-
function RecordKey(schema) {
|
|
1904
|
-
return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
|
|
1905
|
-
}
|
|
1906
|
-
function RecordValue(schema) {
|
|
1907
|
-
return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
|
|
1908
|
-
}
|
|
1909
|
-
function FromRecordRight(left, right) {
|
|
1910
|
-
const [Key, Value] = [RecordKey(right), RecordValue(right)];
|
|
1911
|
-
return type_exports.IsLiteralString(left) && type_exports.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : type_exports.IsUint8Array(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsString(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsArray(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsObject(left) ? (() => {
|
|
1912
|
-
for (const key of Object.getOwnPropertyNames(left.properties)) {
|
|
1913
|
-
if (Property(Value, left.properties[key]) === ExtendsResult.False) {
|
|
1914
|
-
return ExtendsResult.False;
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
return ExtendsResult.True;
|
|
1918
|
-
})() : ExtendsResult.False;
|
|
1919
|
-
}
|
|
1920
|
-
function FromRecord(left, right) {
|
|
1921
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
|
|
1922
|
-
}
|
|
1923
|
-
function FromRegExp(left, right) {
|
|
1924
|
-
const L = type_exports.IsRegExp(left) ? String2() : left;
|
|
1925
|
-
const R = type_exports.IsRegExp(right) ? String2() : right;
|
|
1926
|
-
return Visit3(L, R);
|
|
1927
|
-
}
|
|
1928
|
-
function FromStringRight(left, right) {
|
|
1929
|
-
return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
1930
|
-
}
|
|
1931
|
-
function FromString(left, right) {
|
|
1932
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1933
|
-
}
|
|
1934
|
-
function FromSymbol(left, right) {
|
|
1935
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1936
|
-
}
|
|
1937
|
-
function FromTemplateLiteral2(left, right) {
|
|
1938
|
-
return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
|
|
1939
|
-
}
|
|
1940
|
-
function IsArrayOfTuple(left, right) {
|
|
1941
|
-
return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
|
|
1942
|
-
}
|
|
1943
|
-
function FromTupleRight(left, right) {
|
|
1944
|
-
return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
|
|
1945
|
-
}
|
|
1946
|
-
function FromTuple3(left, right) {
|
|
1947
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : type_exports.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !type_exports.IsTuple(right) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) || !value_exports.IsUndefined(left.items) && value_exports.IsUndefined(right.items) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit3(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
1948
|
-
}
|
|
1949
|
-
function FromUint8Array(left, right) {
|
|
1950
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1951
|
-
}
|
|
1952
|
-
function FromUndefined(left, right) {
|
|
1953
|
-
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsVoid(right) ? FromVoidRight(left) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1954
|
-
}
|
|
1955
|
-
function FromUnionRight(left, right) {
|
|
1956
|
-
return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
1957
|
-
}
|
|
1958
|
-
function FromUnion6(left, right) {
|
|
1959
|
-
return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
1960
|
-
}
|
|
1961
|
-
function FromUnknownRight(left, right) {
|
|
1962
|
-
return ExtendsResult.True;
|
|
1963
|
-
}
|
|
1964
|
-
function FromUnknown(left, right) {
|
|
1965
|
-
return type_exports.IsNever(right) ? FromNeverRight() : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight() : type_exports.IsString(right) ? FromStringRight(left) : type_exports.IsNumber(right) ? FromNumberRight(left) : type_exports.IsInteger(right) ? FromIntegerRight(left) : type_exports.IsBoolean(right) ? FromBooleanRight(left) : type_exports.IsArray(right) ? FromArrayRight(left) : type_exports.IsTuple(right) ? FromTupleRight(left) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1966
|
-
}
|
|
1967
|
-
function FromVoidRight(left, right) {
|
|
1968
|
-
return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
1969
|
-
}
|
|
1970
|
-
function FromVoid(left, right) {
|
|
1971
|
-
return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight() : type_exports.IsAny(right) ? FromAnyRight() : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
1972
|
-
}
|
|
1973
|
-
function Visit3(left, right) {
|
|
1974
|
-
return (
|
|
1975
|
-
// resolvable
|
|
1976
|
-
type_exports.IsTemplateLiteral(left) || type_exports.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : type_exports.IsRegExp(left) || type_exports.IsRegExp(right) ? FromRegExp(left, right) : type_exports.IsNot(left) || type_exports.IsNot(right) ? FromNot(left, right) : (
|
|
1977
|
-
// standard
|
|
1978
|
-
type_exports.IsAny(left) ? FromAny(left, right) : type_exports.IsArray(left) ? FromArray4(left, right) : type_exports.IsBigInt(left) ? FromBigInt(left, right) : type_exports.IsBoolean(left) ? FromBoolean(left, right) : type_exports.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : type_exports.IsConstructor(left) ? FromConstructor(left, right) : type_exports.IsDate(left) ? FromDate(left, right) : type_exports.IsFunction(left) ? FromFunction(left, right) : type_exports.IsInteger(left) ? FromInteger(left, right) : type_exports.IsIntersect(left) ? FromIntersect4(left, right) : type_exports.IsIterator(left) ? FromIterator(left, right) : type_exports.IsLiteral(left) ? FromLiteral2(left, right) : type_exports.IsNever(left) ? FromNever() : type_exports.IsNull(left) ? FromNull(left, right) : type_exports.IsNumber(left) ? FromNumber(left, right) : type_exports.IsObject(left) ? FromObject(left, right) : type_exports.IsRecord(left) ? FromRecord(left, right) : type_exports.IsString(left) ? FromString(left, right) : type_exports.IsSymbol(left) ? FromSymbol(left, right) : type_exports.IsTuple(left) ? FromTuple3(left, right) : type_exports.IsPromise(left) ? FromPromise2(left, right) : type_exports.IsUint8Array(left) ? FromUint8Array(left, right) : type_exports.IsUndefined(left) ? FromUndefined(left, right) : type_exports.IsUnion(left) ? FromUnion6(left, right) : type_exports.IsUnknown(left) ? FromUnknown(left, right) : type_exports.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`)
|
|
1979
|
-
)
|
|
1980
|
-
);
|
|
1981
|
-
}
|
|
1982
|
-
function ExtendsCheck(left, right) {
|
|
1983
|
-
return Visit3(left, right);
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
|
|
1987
|
-
function FromProperties8(P, Right, True, False, options) {
|
|
1988
|
-
const Acc = {};
|
|
1989
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
1990
|
-
Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
|
|
1991
|
-
return Acc;
|
|
1992
|
-
}
|
|
1993
|
-
function FromMappedResult6(Left, Right, True, False, options) {
|
|
1994
|
-
return FromProperties8(Left.properties, Right, True, False, options);
|
|
1995
|
-
}
|
|
1996
|
-
function ExtendsFromMappedResult(Left, Right, True, False, options) {
|
|
1997
|
-
const P = FromMappedResult6(Left, Right, True, False, options);
|
|
1998
|
-
return MappedResult(P);
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
// node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
|
|
2002
|
-
function ExtendsResolve(left, right, trueType, falseType) {
|
|
2003
|
-
const R = ExtendsCheck(left, right);
|
|
2004
|
-
return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
|
|
2005
|
-
}
|
|
2006
|
-
function Extends(L, R, T, F, options) {
|
|
2007
|
-
return IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
|
|
2011
|
-
function FromPropertyKey(K, U, L, R, options) {
|
|
2012
|
-
return {
|
|
2013
|
-
[K]: Extends(Literal(K), U, L, R, Clone(options))
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
function FromPropertyKeys(K, U, L, R, options) {
|
|
2017
|
-
return K.reduce((Acc, LK) => {
|
|
2018
|
-
return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
|
|
2019
|
-
}, {});
|
|
2020
|
-
}
|
|
2021
|
-
function FromMappedKey2(K, U, L, R, options) {
|
|
2022
|
-
return FromPropertyKeys(K.keys, U, L, R, options);
|
|
2023
|
-
}
|
|
2024
|
-
function ExtendsFromMappedKey(T, U, L, R, options) {
|
|
2025
|
-
const P = FromMappedKey2(T, U, L, R, options);
|
|
2026
|
-
return MappedResult(P);
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
|
|
2030
|
-
function ExcludeFromTemplateLiteral(L, R) {
|
|
2031
|
-
return Exclude(TemplateLiteralToUnion(L), R);
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
|
|
2035
|
-
function ExcludeRest(L, R) {
|
|
2036
|
-
const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
|
|
2037
|
-
return excluded.length === 1 ? excluded[0] : Union(excluded);
|
|
2038
|
-
}
|
|
2039
|
-
function Exclude(L, R, options = {}) {
|
|
2040
|
-
if (IsTemplateLiteral(L))
|
|
2041
|
-
return CreateType(ExcludeFromTemplateLiteral(L, R), options);
|
|
2042
|
-
if (IsMappedResult(L))
|
|
2043
|
-
return CreateType(ExcludeFromMappedResult(L, R), options);
|
|
2044
|
-
return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
|
|
2048
|
-
function FromProperties9(P, U) {
|
|
2049
|
-
const Acc = {};
|
|
2050
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
2051
|
-
Acc[K2] = Exclude(P[K2], U);
|
|
2052
|
-
return Acc;
|
|
2053
|
-
}
|
|
2054
|
-
function FromMappedResult7(R, T) {
|
|
2055
|
-
return FromProperties9(R.properties, T);
|
|
2056
|
-
}
|
|
2057
|
-
function ExcludeFromMappedResult(R, T) {
|
|
2058
|
-
const P = FromMappedResult7(R, T);
|
|
2059
|
-
return MappedResult(P);
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
// node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
|
|
2063
|
-
function ExtractFromTemplateLiteral(L, R) {
|
|
2064
|
-
return Extract(TemplateLiteralToUnion(L), R);
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
// node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
|
|
2068
|
-
function ExtractRest(L, R) {
|
|
2069
|
-
const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
|
|
2070
|
-
return extracted.length === 1 ? extracted[0] : Union(extracted);
|
|
2071
|
-
}
|
|
2072
|
-
function Extract(L, R, options) {
|
|
2073
|
-
if (IsTemplateLiteral(L))
|
|
2074
|
-
return CreateType(ExtractFromTemplateLiteral(L, R), options);
|
|
2075
|
-
if (IsMappedResult(L))
|
|
2076
|
-
return CreateType(ExtractFromMappedResult(L, R), options);
|
|
2077
|
-
return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
|
|
2078
|
-
}
|
|
2079
|
-
|
|
2080
|
-
// node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
|
|
2081
|
-
function FromProperties10(P, T) {
|
|
2082
|
-
const Acc = {};
|
|
2083
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
2084
|
-
Acc[K2] = Extract(P[K2], T);
|
|
2085
|
-
return Acc;
|
|
2086
|
-
}
|
|
2087
|
-
function FromMappedResult8(R, T) {
|
|
2088
|
-
return FromProperties10(R.properties, T);
|
|
2089
|
-
}
|
|
2090
|
-
function ExtractFromMappedResult(R, T) {
|
|
2091
|
-
const P = FromMappedResult8(R, T);
|
|
2092
|
-
return MappedResult(P);
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
// node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
|
|
2096
|
-
function InstanceType(schema, options) {
|
|
2097
|
-
return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
// node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
|
|
2101
|
-
function ReadonlyOptional(schema) {
|
|
2102
|
-
return Readonly(Optional(schema));
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
// node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
|
|
2106
|
-
function RecordCreateFromPattern(pattern, T, options) {
|
|
2107
|
-
return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
|
|
2108
|
-
}
|
|
2109
|
-
function RecordCreateFromKeys(K, T, options) {
|
|
2110
|
-
const result = {};
|
|
2111
|
-
for (const K2 of K)
|
|
2112
|
-
result[K2] = T;
|
|
2113
|
-
return Object2(result, { ...options, [Hint]: "Record" });
|
|
2114
|
-
}
|
|
2115
|
-
function FromTemplateLiteralKey(K, T, options) {
|
|
2116
|
-
return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
|
|
2117
|
-
}
|
|
2118
|
-
function FromUnionKey(key, type, options) {
|
|
2119
|
-
return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
|
|
2120
|
-
}
|
|
2121
|
-
function FromLiteralKey(key, type, options) {
|
|
2122
|
-
return RecordCreateFromKeys([key.toString()], type, options);
|
|
2123
|
-
}
|
|
2124
|
-
function FromRegExpKey(key, type, options) {
|
|
2125
|
-
return RecordCreateFromPattern(key.source, type, options);
|
|
2126
|
-
}
|
|
2127
|
-
function FromStringKey(key, type, options) {
|
|
2128
|
-
const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
|
|
2129
|
-
return RecordCreateFromPattern(pattern, type, options);
|
|
2130
|
-
}
|
|
2131
|
-
function FromAnyKey(_, type, options) {
|
|
2132
|
-
return RecordCreateFromPattern(PatternStringExact, type, options);
|
|
2133
|
-
}
|
|
2134
|
-
function FromNeverKey(_key, type, options) {
|
|
2135
|
-
return RecordCreateFromPattern(PatternNeverExact, type, options);
|
|
2136
|
-
}
|
|
2137
|
-
function FromBooleanKey(_key, type, options) {
|
|
2138
|
-
return Object2({ true: type, false: type }, options);
|
|
2139
|
-
}
|
|
2140
|
-
function FromIntegerKey(_key, type, options) {
|
|
2141
|
-
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
2142
|
-
}
|
|
2143
|
-
function FromNumberKey(_, type, options) {
|
|
2144
|
-
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
2145
|
-
}
|
|
2146
|
-
function Record(key, type, options = {}) {
|
|
2147
|
-
return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean2(key) ? FromBooleanKey(key, type, options) : IsInteger(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString2(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
|
|
2148
|
-
}
|
|
2149
|
-
function RecordPattern(record) {
|
|
2150
|
-
return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
|
|
2151
|
-
}
|
|
2152
|
-
function RecordKey2(type) {
|
|
2153
|
-
const pattern = RecordPattern(type);
|
|
2154
|
-
return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
|
|
2155
|
-
}
|
|
2156
|
-
function RecordValue2(type) {
|
|
2157
|
-
return type.patternProperties[RecordPattern(type)];
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
// node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
|
|
2161
|
-
function FromConstructor2(args, type) {
|
|
2162
|
-
type.parameters = FromTypes(args, type.parameters);
|
|
2163
|
-
type.returns = FromType(args, type.returns);
|
|
2164
|
-
return type;
|
|
2165
|
-
}
|
|
2166
|
-
function FromFunction2(args, type) {
|
|
2167
|
-
type.parameters = FromTypes(args, type.parameters);
|
|
2168
|
-
type.returns = FromType(args, type.returns);
|
|
2169
|
-
return type;
|
|
2170
|
-
}
|
|
2171
|
-
function FromIntersect5(args, type) {
|
|
2172
|
-
type.allOf = FromTypes(args, type.allOf);
|
|
2173
|
-
return type;
|
|
2174
|
-
}
|
|
2175
|
-
function FromUnion7(args, type) {
|
|
2176
|
-
type.anyOf = FromTypes(args, type.anyOf);
|
|
2177
|
-
return type;
|
|
2178
|
-
}
|
|
2179
|
-
function FromTuple4(args, type) {
|
|
2180
|
-
if (IsUndefined(type.items))
|
|
2181
|
-
return type;
|
|
2182
|
-
type.items = FromTypes(args, type.items);
|
|
2183
|
-
return type;
|
|
2184
|
-
}
|
|
2185
|
-
function FromArray5(args, type) {
|
|
2186
|
-
type.items = FromType(args, type.items);
|
|
2187
|
-
return type;
|
|
2188
|
-
}
|
|
2189
|
-
function FromAsyncIterator2(args, type) {
|
|
2190
|
-
type.items = FromType(args, type.items);
|
|
2191
|
-
return type;
|
|
2192
|
-
}
|
|
2193
|
-
function FromIterator2(args, type) {
|
|
2194
|
-
type.items = FromType(args, type.items);
|
|
2195
|
-
return type;
|
|
2196
|
-
}
|
|
2197
|
-
function FromPromise3(args, type) {
|
|
2198
|
-
type.item = FromType(args, type.item);
|
|
2199
|
-
return type;
|
|
2200
|
-
}
|
|
2201
|
-
function FromObject2(args, type) {
|
|
2202
|
-
const mappedProperties = FromProperties11(args, type.properties);
|
|
2203
|
-
return { ...type, ...Object2(mappedProperties) };
|
|
2204
|
-
}
|
|
2205
|
-
function FromRecord2(args, type) {
|
|
2206
|
-
const mappedKey = FromType(args, RecordKey2(type));
|
|
2207
|
-
const mappedValue = FromType(args, RecordValue2(type));
|
|
2208
|
-
const result = Record(mappedKey, mappedValue);
|
|
2209
|
-
return { ...type, ...result };
|
|
2210
|
-
}
|
|
2211
|
-
function FromArgument(args, argument) {
|
|
2212
|
-
return argument.index in args ? args[argument.index] : Unknown();
|
|
2213
|
-
}
|
|
2214
|
-
function FromProperty2(args, type) {
|
|
2215
|
-
const isReadonly = IsReadonly(type);
|
|
2216
|
-
const isOptional = IsOptional(type);
|
|
2217
|
-
const mapped = FromType(args, type);
|
|
2218
|
-
return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
|
|
2219
|
-
}
|
|
2220
|
-
function FromProperties11(args, properties) {
|
|
2221
|
-
return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
|
|
2222
|
-
return { ...result, [key]: FromProperty2(args, properties[key]) };
|
|
2223
|
-
}, {});
|
|
2224
|
-
}
|
|
2225
|
-
function FromTypes(args, types) {
|
|
2226
|
-
return types.map((type) => FromType(args, type));
|
|
2227
|
-
}
|
|
2228
|
-
function FromType(args, type) {
|
|
2229
|
-
return IsConstructor(type) ? FromConstructor2(args, type) : IsFunction2(type) ? FromFunction2(args, type) : IsIntersect(type) ? FromIntersect5(args, type) : IsUnion(type) ? FromUnion7(args, type) : IsTuple(type) ? FromTuple4(args, type) : IsArray3(type) ? FromArray5(args, type) : IsAsyncIterator2(type) ? FromAsyncIterator2(args, type) : IsIterator2(type) ? FromIterator2(args, type) : IsPromise(type) ? FromPromise3(args, type) : IsObject3(type) ? FromObject2(args, type) : IsRecord(type) ? FromRecord2(args, type) : IsArgument(type) ? FromArgument(args, type) : type;
|
|
2230
|
-
}
|
|
2231
|
-
function Instantiate(type, args) {
|
|
2232
|
-
return FromType(args, CloneType(type));
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
// node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
|
|
2236
|
-
function Integer(options) {
|
|
2237
|
-
return CreateType({ [Kind]: "Integer", type: "integer" }, options);
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
|
|
2241
|
-
function MappedIntrinsicPropertyKey(K, M, options) {
|
|
2242
|
-
return {
|
|
2243
|
-
[K]: Intrinsic(Literal(K), M, Clone(options))
|
|
2244
|
-
};
|
|
2245
|
-
}
|
|
2246
|
-
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
2247
|
-
const result = K.reduce((Acc, L) => {
|
|
2248
|
-
return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
|
|
2249
|
-
}, {});
|
|
2250
|
-
return result;
|
|
2251
|
-
}
|
|
2252
|
-
function MappedIntrinsicProperties(T, M, options) {
|
|
2253
|
-
return MappedIntrinsicPropertyKeys(T["keys"], M, options);
|
|
2254
|
-
}
|
|
2255
|
-
function IntrinsicFromMappedKey(T, M, options) {
|
|
2256
|
-
const P = MappedIntrinsicProperties(T, M, options);
|
|
2257
|
-
return MappedResult(P);
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
|
|
2261
|
-
function ApplyUncapitalize(value) {
|
|
2262
|
-
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
2263
|
-
return [first.toLowerCase(), rest].join("");
|
|
2264
|
-
}
|
|
2265
|
-
function ApplyCapitalize(value) {
|
|
2266
|
-
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
2267
|
-
return [first.toUpperCase(), rest].join("");
|
|
2268
|
-
}
|
|
2269
|
-
function ApplyUppercase(value) {
|
|
2270
|
-
return value.toUpperCase();
|
|
2271
|
-
}
|
|
2272
|
-
function ApplyLowercase(value) {
|
|
2273
|
-
return value.toLowerCase();
|
|
2274
|
-
}
|
|
2275
|
-
function FromTemplateLiteral3(schema, mode, options) {
|
|
2276
|
-
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
2277
|
-
const finite = IsTemplateLiteralExpressionFinite(expression);
|
|
2278
|
-
if (!finite)
|
|
2279
|
-
return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
|
|
2280
|
-
const strings = [...TemplateLiteralExpressionGenerate(expression)];
|
|
2281
|
-
const literals = strings.map((value) => Literal(value));
|
|
2282
|
-
const mapped = FromRest5(literals, mode);
|
|
2283
|
-
const union = Union(mapped);
|
|
2284
|
-
return TemplateLiteral([union], options);
|
|
2285
|
-
}
|
|
2286
|
-
function FromLiteralValue(value, mode) {
|
|
2287
|
-
return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
|
|
2288
|
-
}
|
|
2289
|
-
function FromRest5(T, M) {
|
|
2290
|
-
return T.map((L) => Intrinsic(L, M));
|
|
2291
|
-
}
|
|
2292
|
-
function Intrinsic(schema, mode, options = {}) {
|
|
2293
|
-
return (
|
|
2294
|
-
// Intrinsic-Mapped-Inference
|
|
2295
|
-
IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
|
|
2296
|
-
// Standard-Inference
|
|
2297
|
-
IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
|
|
2298
|
-
// Default Type
|
|
2299
|
-
CreateType(schema, options)
|
|
2300
|
-
)
|
|
2301
|
-
)
|
|
2302
|
-
);
|
|
2303
|
-
}
|
|
2304
|
-
|
|
2305
|
-
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
|
|
2306
|
-
function Capitalize(T, options = {}) {
|
|
2307
|
-
return Intrinsic(T, "Capitalize", options);
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
|
|
2311
|
-
function Lowercase(T, options = {}) {
|
|
2312
|
-
return Intrinsic(T, "Lowercase", options);
|
|
2313
|
-
}
|
|
2314
|
-
|
|
2315
|
-
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
|
|
2316
|
-
function Uncapitalize(T, options = {}) {
|
|
2317
|
-
return Intrinsic(T, "Uncapitalize", options);
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
|
|
2321
|
-
function Uppercase(T, options = {}) {
|
|
2322
|
-
return Intrinsic(T, "Uppercase", options);
|
|
2323
|
-
}
|
|
2324
|
-
|
|
2325
|
-
// node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
|
|
2326
|
-
function FromProperties12(properties, propertyKeys, options) {
|
|
2327
|
-
const result = {};
|
|
2328
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
2329
|
-
result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
|
|
2330
|
-
return result;
|
|
2331
|
-
}
|
|
2332
|
-
function FromMappedResult9(mappedResult, propertyKeys, options) {
|
|
2333
|
-
return FromProperties12(mappedResult.properties, propertyKeys, options);
|
|
2334
|
-
}
|
|
2335
|
-
function OmitFromMappedResult(mappedResult, propertyKeys, options) {
|
|
2336
|
-
const properties = FromMappedResult9(mappedResult, propertyKeys, options);
|
|
2337
|
-
return MappedResult(properties);
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
// node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
|
|
2341
|
-
function FromIntersect6(types, propertyKeys) {
|
|
2342
|
-
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
2343
|
-
}
|
|
2344
|
-
function FromUnion8(types, propertyKeys) {
|
|
2345
|
-
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
2346
|
-
}
|
|
2347
|
-
function FromProperty3(properties, key) {
|
|
2348
|
-
const { [key]: _, ...R } = properties;
|
|
2349
|
-
return R;
|
|
2350
|
-
}
|
|
2351
|
-
function FromProperties13(properties, propertyKeys) {
|
|
2352
|
-
return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
|
|
2353
|
-
}
|
|
2354
|
-
function FromObject3(type, propertyKeys, properties) {
|
|
2355
|
-
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
2356
|
-
const mappedProperties = FromProperties13(properties, propertyKeys);
|
|
2357
|
-
return Object2(mappedProperties, options);
|
|
2358
|
-
}
|
|
2359
|
-
function UnionFromPropertyKeys(propertyKeys) {
|
|
2360
|
-
const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
|
|
2361
|
-
return Union(result);
|
|
2362
|
-
}
|
|
2363
|
-
function OmitResolve(type, propertyKeys) {
|
|
2364
|
-
return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
|
|
2365
|
-
}
|
|
2366
|
-
function Omit(type, key, options) {
|
|
2367
|
-
const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
|
|
2368
|
-
const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
2369
|
-
const isTypeRef = IsRef(type);
|
|
2370
|
-
const isKeyRef = IsRef(key);
|
|
2371
|
-
return IsMappedResult(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({ ...OmitResolve(type, propertyKeys), ...options });
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
|
-
// node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
|
|
2375
|
-
function FromPropertyKey2(type, key, options) {
|
|
2376
|
-
return { [key]: Omit(type, [key], Clone(options)) };
|
|
2377
|
-
}
|
|
2378
|
-
function FromPropertyKeys2(type, propertyKeys, options) {
|
|
2379
|
-
return propertyKeys.reduce((Acc, LK) => {
|
|
2380
|
-
return { ...Acc, ...FromPropertyKey2(type, LK, options) };
|
|
2381
|
-
}, {});
|
|
2382
|
-
}
|
|
2383
|
-
function FromMappedKey3(type, mappedKey, options) {
|
|
2384
|
-
return FromPropertyKeys2(type, mappedKey.keys, options);
|
|
2385
|
-
}
|
|
2386
|
-
function OmitFromMappedKey(type, mappedKey, options) {
|
|
2387
|
-
const properties = FromMappedKey3(type, mappedKey, options);
|
|
2388
|
-
return MappedResult(properties);
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
// node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
|
|
2392
|
-
function FromProperties14(properties, propertyKeys, options) {
|
|
2393
|
-
const result = {};
|
|
2394
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
2395
|
-
result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
|
|
2396
|
-
return result;
|
|
2397
|
-
}
|
|
2398
|
-
function FromMappedResult10(mappedResult, propertyKeys, options) {
|
|
2399
|
-
return FromProperties14(mappedResult.properties, propertyKeys, options);
|
|
2400
|
-
}
|
|
2401
|
-
function PickFromMappedResult(mappedResult, propertyKeys, options) {
|
|
2402
|
-
const properties = FromMappedResult10(mappedResult, propertyKeys, options);
|
|
2403
|
-
return MappedResult(properties);
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
|
-
// node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
|
|
2407
|
-
function FromIntersect7(types, propertyKeys) {
|
|
2408
|
-
return types.map((type) => PickResolve(type, propertyKeys));
|
|
2409
|
-
}
|
|
2410
|
-
function FromUnion9(types, propertyKeys) {
|
|
2411
|
-
return types.map((type) => PickResolve(type, propertyKeys));
|
|
2412
|
-
}
|
|
2413
|
-
function FromProperties15(properties, propertyKeys) {
|
|
2414
|
-
const result = {};
|
|
2415
|
-
for (const K2 of propertyKeys)
|
|
2416
|
-
if (K2 in properties)
|
|
2417
|
-
result[K2] = properties[K2];
|
|
2418
|
-
return result;
|
|
2419
|
-
}
|
|
2420
|
-
function FromObject4(Type2, keys, properties) {
|
|
2421
|
-
const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
|
|
2422
|
-
const mappedProperties = FromProperties15(properties, keys);
|
|
2423
|
-
return Object2(mappedProperties, options);
|
|
2424
|
-
}
|
|
2425
|
-
function UnionFromPropertyKeys2(propertyKeys) {
|
|
2426
|
-
const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
|
|
2427
|
-
return Union(result);
|
|
2428
|
-
}
|
|
2429
|
-
function PickResolve(type, propertyKeys) {
|
|
2430
|
-
return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
|
|
2431
|
-
}
|
|
2432
|
-
function Pick(type, key, options) {
|
|
2433
|
-
const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
|
|
2434
|
-
const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
2435
|
-
const isTypeRef = IsRef(type);
|
|
2436
|
-
const isKeyRef = IsRef(key);
|
|
2437
|
-
return IsMappedResult(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({ ...PickResolve(type, propertyKeys), ...options });
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
// node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
|
|
2441
|
-
function FromPropertyKey3(type, key, options) {
|
|
2442
|
-
return {
|
|
2443
|
-
[key]: Pick(type, [key], Clone(options))
|
|
2444
|
-
};
|
|
2445
|
-
}
|
|
2446
|
-
function FromPropertyKeys3(type, propertyKeys, options) {
|
|
2447
|
-
return propertyKeys.reduce((result, leftKey) => {
|
|
2448
|
-
return { ...result, ...FromPropertyKey3(type, leftKey, options) };
|
|
2449
|
-
}, {});
|
|
2450
|
-
}
|
|
2451
|
-
function FromMappedKey4(type, mappedKey, options) {
|
|
2452
|
-
return FromPropertyKeys3(type, mappedKey.keys, options);
|
|
2453
|
-
}
|
|
2454
|
-
function PickFromMappedKey(type, mappedKey, options) {
|
|
2455
|
-
const properties = FromMappedKey4(type, mappedKey, options);
|
|
2456
|
-
return MappedResult(properties);
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2459
|
-
// node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
|
|
2460
|
-
function FromComputed3(target, parameters) {
|
|
2461
|
-
return Computed("Partial", [Computed(target, parameters)]);
|
|
2462
|
-
}
|
|
2463
|
-
function FromRef3($ref) {
|
|
2464
|
-
return Computed("Partial", [Ref($ref)]);
|
|
2465
|
-
}
|
|
2466
|
-
function FromProperties16(properties) {
|
|
2467
|
-
const partialProperties = {};
|
|
2468
|
-
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
2469
|
-
partialProperties[K] = Optional(properties[K]);
|
|
2470
|
-
return partialProperties;
|
|
2471
|
-
}
|
|
2472
|
-
function FromObject5(type, properties) {
|
|
2473
|
-
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
2474
|
-
const mappedProperties = FromProperties16(properties);
|
|
2475
|
-
return Object2(mappedProperties, options);
|
|
2476
|
-
}
|
|
2477
|
-
function FromRest6(types) {
|
|
2478
|
-
return types.map((type) => PartialResolve(type));
|
|
2479
|
-
}
|
|
2480
|
-
function PartialResolve(type) {
|
|
2481
|
-
return (
|
|
2482
|
-
// Mappable
|
|
2483
|
-
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) : (
|
|
2484
|
-
// Intrinsic
|
|
2485
|
-
IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
|
|
2486
|
-
// Passthrough
|
|
2487
|
-
Object2({})
|
|
2488
|
-
)
|
|
2489
|
-
)
|
|
2490
|
-
);
|
|
2491
|
-
}
|
|
2492
|
-
function Partial(type, options) {
|
|
2493
|
-
if (IsMappedResult(type)) {
|
|
2494
|
-
return PartialFromMappedResult(type, options);
|
|
2495
|
-
} else {
|
|
2496
|
-
return CreateType({ ...PartialResolve(type), ...options });
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
// node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
|
|
2501
|
-
function FromProperties17(K, options) {
|
|
2502
|
-
const Acc = {};
|
|
2503
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
2504
|
-
Acc[K2] = Partial(K[K2], Clone(options));
|
|
2505
|
-
return Acc;
|
|
2506
|
-
}
|
|
2507
|
-
function FromMappedResult11(R, options) {
|
|
2508
|
-
return FromProperties17(R.properties, options);
|
|
2509
|
-
}
|
|
2510
|
-
function PartialFromMappedResult(R, options) {
|
|
2511
|
-
const P = FromMappedResult11(R, options);
|
|
2512
|
-
return MappedResult(P);
|
|
2513
|
-
}
|
|
2514
|
-
|
|
2515
|
-
// node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
|
|
2516
|
-
function FromComputed4(target, parameters) {
|
|
2517
|
-
return Computed("Required", [Computed(target, parameters)]);
|
|
2518
|
-
}
|
|
2519
|
-
function FromRef4($ref) {
|
|
2520
|
-
return Computed("Required", [Ref($ref)]);
|
|
2521
|
-
}
|
|
2522
|
-
function FromProperties18(properties) {
|
|
2523
|
-
const requiredProperties = {};
|
|
2524
|
-
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
2525
|
-
requiredProperties[K] = Discard(properties[K], [OptionalKind]);
|
|
2526
|
-
return requiredProperties;
|
|
2527
|
-
}
|
|
2528
|
-
function FromObject6(type, properties) {
|
|
2529
|
-
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
2530
|
-
const mappedProperties = FromProperties18(properties);
|
|
2531
|
-
return Object2(mappedProperties, options);
|
|
2532
|
-
}
|
|
2533
|
-
function FromRest7(types) {
|
|
2534
|
-
return types.map((type) => RequiredResolve(type));
|
|
2535
|
-
}
|
|
2536
|
-
function RequiredResolve(type) {
|
|
2537
|
-
return (
|
|
2538
|
-
// Mappable
|
|
2539
|
-
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) : (
|
|
2540
|
-
// Intrinsic
|
|
2541
|
-
IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : (
|
|
2542
|
-
// Passthrough
|
|
2543
|
-
Object2({})
|
|
2544
|
-
)
|
|
2545
|
-
)
|
|
2546
|
-
);
|
|
2547
|
-
}
|
|
2548
|
-
function Required(type, options) {
|
|
2549
|
-
if (IsMappedResult(type)) {
|
|
2550
|
-
return RequiredFromMappedResult(type, options);
|
|
2551
|
-
} else {
|
|
2552
|
-
return CreateType({ ...RequiredResolve(type), ...options });
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
// node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
|
|
2557
|
-
function FromProperties19(P, options) {
|
|
2558
|
-
const Acc = {};
|
|
2559
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
2560
|
-
Acc[K2] = Required(P[K2], options);
|
|
2561
|
-
return Acc;
|
|
2562
|
-
}
|
|
2563
|
-
function FromMappedResult12(R, options) {
|
|
2564
|
-
return FromProperties19(R.properties, options);
|
|
2565
|
-
}
|
|
2566
|
-
function RequiredFromMappedResult(R, options) {
|
|
2567
|
-
const P = FromMappedResult12(R, options);
|
|
2568
|
-
return MappedResult(P);
|
|
2569
|
-
}
|
|
2570
|
-
|
|
2571
|
-
// node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
|
|
2572
|
-
function DereferenceParameters(moduleProperties, types) {
|
|
2573
|
-
return types.map((type) => {
|
|
2574
|
-
return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
|
|
2575
|
-
});
|
|
2576
|
-
}
|
|
2577
|
-
function Dereference(moduleProperties, ref) {
|
|
2578
|
-
return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
|
|
2579
|
-
}
|
|
2580
|
-
function FromAwaited(parameters) {
|
|
2581
|
-
return Awaited(parameters[0]);
|
|
2582
|
-
}
|
|
2583
|
-
function FromIndex(parameters) {
|
|
2584
|
-
return Index(parameters[0], parameters[1]);
|
|
2585
|
-
}
|
|
2586
|
-
function FromKeyOf(parameters) {
|
|
2587
|
-
return KeyOf(parameters[0]);
|
|
2588
|
-
}
|
|
2589
|
-
function FromPartial(parameters) {
|
|
2590
|
-
return Partial(parameters[0]);
|
|
2591
|
-
}
|
|
2592
|
-
function FromOmit(parameters) {
|
|
2593
|
-
return Omit(parameters[0], parameters[1]);
|
|
2594
|
-
}
|
|
2595
|
-
function FromPick(parameters) {
|
|
2596
|
-
return Pick(parameters[0], parameters[1]);
|
|
2597
|
-
}
|
|
2598
|
-
function FromRequired(parameters) {
|
|
2599
|
-
return Required(parameters[0]);
|
|
2600
|
-
}
|
|
2601
|
-
function FromComputed5(moduleProperties, target, parameters) {
|
|
2602
|
-
const dereferenced = DereferenceParameters(moduleProperties, parameters);
|
|
2603
|
-
return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
|
|
2604
|
-
}
|
|
2605
|
-
function FromArray6(moduleProperties, type) {
|
|
2606
|
-
return Array2(FromType2(moduleProperties, type));
|
|
2607
|
-
}
|
|
2608
|
-
function FromAsyncIterator3(moduleProperties, type) {
|
|
2609
|
-
return AsyncIterator(FromType2(moduleProperties, type));
|
|
2610
|
-
}
|
|
2611
|
-
function FromConstructor3(moduleProperties, parameters, instanceType) {
|
|
2612
|
-
return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
|
|
2613
|
-
}
|
|
2614
|
-
function FromFunction3(moduleProperties, parameters, returnType) {
|
|
2615
|
-
return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
|
|
2616
|
-
}
|
|
2617
|
-
function FromIntersect8(moduleProperties, types) {
|
|
2618
|
-
return Intersect(FromTypes2(moduleProperties, types));
|
|
2619
|
-
}
|
|
2620
|
-
function FromIterator3(moduleProperties, type) {
|
|
2621
|
-
return Iterator(FromType2(moduleProperties, type));
|
|
2622
|
-
}
|
|
2623
|
-
function FromObject7(moduleProperties, properties) {
|
|
2624
|
-
return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
|
|
2625
|
-
return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
|
|
2626
|
-
}, {}));
|
|
2627
|
-
}
|
|
2628
|
-
function FromRecord3(moduleProperties, type) {
|
|
2629
|
-
const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
|
|
2630
|
-
const result = CloneType(type);
|
|
2631
|
-
result.patternProperties[pattern] = value;
|
|
2632
|
-
return result;
|
|
2633
|
-
}
|
|
2634
|
-
function FromTransform(moduleProperties, transform) {
|
|
2635
|
-
return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
|
|
2636
|
-
}
|
|
2637
|
-
function FromTuple5(moduleProperties, types) {
|
|
2638
|
-
return Tuple(FromTypes2(moduleProperties, types));
|
|
2639
|
-
}
|
|
2640
|
-
function FromUnion10(moduleProperties, types) {
|
|
2641
|
-
return Union(FromTypes2(moduleProperties, types));
|
|
2642
|
-
}
|
|
2643
|
-
function FromTypes2(moduleProperties, types) {
|
|
2644
|
-
return types.map((type) => FromType2(moduleProperties, type));
|
|
2645
|
-
}
|
|
2646
|
-
function FromType2(moduleProperties, type) {
|
|
2647
|
-
return (
|
|
2648
|
-
// Modifiers
|
|
2649
|
-
IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
|
|
2650
|
-
// Transform
|
|
2651
|
-
IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
|
|
2652
|
-
// Types
|
|
2653
|
-
IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator2(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) : IsFunction2(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator2(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
|
|
2654
|
-
)
|
|
2655
|
-
)
|
|
2656
|
-
);
|
|
2657
|
-
}
|
|
2658
|
-
function ComputeType(moduleProperties, key) {
|
|
2659
|
-
return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
|
|
2660
|
-
}
|
|
2661
|
-
function ComputeModuleProperties(moduleProperties) {
|
|
2662
|
-
return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
|
|
2663
|
-
return { ...result, [key]: ComputeType(moduleProperties, key) };
|
|
2664
|
-
}, {});
|
|
2665
|
-
}
|
|
2666
|
-
|
|
2667
|
-
// node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
|
|
2668
|
-
var TModule = class {
|
|
2669
|
-
constructor($defs) {
|
|
2670
|
-
const computed = ComputeModuleProperties($defs);
|
|
2671
|
-
const identified = this.WithIdentifiers(computed);
|
|
2672
|
-
this.$defs = identified;
|
|
2673
|
-
}
|
|
2674
|
-
/** `[Json]` Imports a Type by Key. */
|
|
2675
|
-
Import(key, options) {
|
|
2676
|
-
const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
|
|
2677
|
-
return CreateType({ [Kind]: "Import", $defs, $ref: key });
|
|
2678
|
-
}
|
|
2679
|
-
// prettier-ignore
|
|
2680
|
-
WithIdentifiers($defs) {
|
|
2681
|
-
return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
|
|
2682
|
-
return { ...result, [key]: { ...$defs[key], $id: key } };
|
|
2683
|
-
}, {});
|
|
182
|
+
async getSchema(factType) {
|
|
183
|
+
const path = `/schemas/${encodeURIComponent(factType)}`;
|
|
184
|
+
return this.fetchJson(path, {
|
|
185
|
+
method: "GET"
|
|
186
|
+
});
|
|
2684
187
|
}
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
return CreateType({ [Kind]: "Not", not: type }, options);
|
|
2693
|
-
}
|
|
2694
|
-
|
|
2695
|
-
// node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
|
|
2696
|
-
function Parameters(schema, options) {
|
|
2697
|
-
return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
// node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
|
|
2701
|
-
var Ordinal = 0;
|
|
2702
|
-
function Recursive(callback, options = {}) {
|
|
2703
|
-
if (IsUndefined(options.$id))
|
|
2704
|
-
options.$id = `T${Ordinal++}`;
|
|
2705
|
-
const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
|
|
2706
|
-
thisType.$id = options.$id;
|
|
2707
|
-
return CreateType({ [Hint]: "Recursive", ...thisType }, options);
|
|
2708
|
-
}
|
|
2709
|
-
|
|
2710
|
-
// node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
|
|
2711
|
-
function RegExp2(unresolved, options) {
|
|
2712
|
-
const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
|
|
2713
|
-
return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
|
|
2714
|
-
}
|
|
2715
|
-
|
|
2716
|
-
// node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
|
|
2717
|
-
function RestResolve(T) {
|
|
2718
|
-
return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
|
|
2719
|
-
}
|
|
2720
|
-
function Rest(T) {
|
|
2721
|
-
return RestResolve(T);
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
|
-
// node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
|
|
2725
|
-
function ReturnType(schema, options) {
|
|
2726
|
-
return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
2727
|
-
}
|
|
2728
|
-
|
|
2729
|
-
// node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
|
|
2730
|
-
var TransformDecodeBuilder = class {
|
|
2731
|
-
constructor(schema) {
|
|
2732
|
-
this.schema = schema;
|
|
188
|
+
async healthCheck() {
|
|
189
|
+
try {
|
|
190
|
+
const response = await fetch(`${this.baseUrl}/health`);
|
|
191
|
+
return response.ok;
|
|
192
|
+
} catch {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
2733
195
|
}
|
|
2734
|
-
|
|
2735
|
-
|
|
196
|
+
getWebSocketUrl() {
|
|
197
|
+
const url = new URL(this.baseUrl);
|
|
198
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
199
|
+
let s = url.toString();
|
|
200
|
+
if (s.endsWith("/")) {
|
|
201
|
+
s = s.slice(0, -1);
|
|
202
|
+
}
|
|
203
|
+
return s;
|
|
2736
204
|
}
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
205
|
+
// ============ Schema Registry Methods ============
|
|
206
|
+
async listSchemas() {
|
|
207
|
+
return this.fetchJson("/schemas", {
|
|
208
|
+
method: "GET"
|
|
209
|
+
});
|
|
2742
210
|
}
|
|
2743
|
-
|
|
2744
|
-
const
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
211
|
+
async getSchemaInfo(factType, version) {
|
|
212
|
+
const query = version ? `?version=${version}` : "";
|
|
213
|
+
return this.fetchJson(`/schemas/${factType}${query}`, {
|
|
214
|
+
method: "GET"
|
|
215
|
+
});
|
|
2748
216
|
}
|
|
2749
|
-
|
|
2750
|
-
const
|
|
2751
|
-
return {
|
|
217
|
+
async validateSchema(factType, payload, version) {
|
|
218
|
+
const query = version ? `?version=${version}` : "";
|
|
219
|
+
return this.fetchJson(`/schemas/${factType}/validate${query}`, {
|
|
220
|
+
method: "POST",
|
|
221
|
+
body: JSON.stringify({ payload })
|
|
222
|
+
});
|
|
2752
223
|
}
|
|
2753
|
-
|
|
2754
|
-
|
|
224
|
+
// ============ Private Helpers ============
|
|
225
|
+
async fetchJson(path, options = {}) {
|
|
226
|
+
try {
|
|
227
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
228
|
+
...options,
|
|
229
|
+
headers: {
|
|
230
|
+
"Content-Type": "application/json",
|
|
231
|
+
...options.headers
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
if (!response.ok) {
|
|
235
|
+
const errorData = await response.json().catch(() => ({}));
|
|
236
|
+
return {
|
|
237
|
+
success: false,
|
|
238
|
+
error: errorData.error || `HTTP ${response.status}`
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const data = await response.json();
|
|
242
|
+
return { success: true, data };
|
|
243
|
+
} catch (error) {
|
|
244
|
+
return {
|
|
245
|
+
success: false,
|
|
246
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
247
|
+
};
|
|
248
|
+
}
|
|
2755
249
|
}
|
|
2756
250
|
};
|
|
2757
|
-
function Transform(schema) {
|
|
2758
|
-
return new TransformDecodeBuilder(schema);
|
|
2759
|
-
}
|
|
2760
|
-
|
|
2761
|
-
// node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
|
|
2762
|
-
function Unsafe(options = {}) {
|
|
2763
|
-
return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
|
|
2764
|
-
}
|
|
2765
251
|
|
|
2766
|
-
//
|
|
2767
|
-
|
|
2768
|
-
|
|
252
|
+
// src/pending-events.ts
|
|
253
|
+
var MAX_PENDING = 100;
|
|
254
|
+
var pendingEvents = [];
|
|
255
|
+
function pushPendingEvent(event) {
|
|
256
|
+
pendingEvents.push(event);
|
|
257
|
+
while (pendingEvents.length > MAX_PENDING) {
|
|
258
|
+
pendingEvents.shift();
|
|
259
|
+
}
|
|
2769
260
|
}
|
|
2770
261
|
|
|
2771
|
-
// node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
|
|
2772
|
-
var type_exports2 = {};
|
|
2773
|
-
__export(type_exports2, {
|
|
2774
|
-
Any: () => Any,
|
|
2775
|
-
Argument: () => Argument,
|
|
2776
|
-
Array: () => Array2,
|
|
2777
|
-
AsyncIterator: () => AsyncIterator,
|
|
2778
|
-
Awaited: () => Awaited,
|
|
2779
|
-
BigInt: () => BigInt,
|
|
2780
|
-
Boolean: () => Boolean,
|
|
2781
|
-
Capitalize: () => Capitalize,
|
|
2782
|
-
Composite: () => Composite,
|
|
2783
|
-
Const: () => Const,
|
|
2784
|
-
Constructor: () => Constructor,
|
|
2785
|
-
ConstructorParameters: () => ConstructorParameters,
|
|
2786
|
-
Date: () => Date2,
|
|
2787
|
-
Enum: () => Enum,
|
|
2788
|
-
Exclude: () => Exclude,
|
|
2789
|
-
Extends: () => Extends,
|
|
2790
|
-
Extract: () => Extract,
|
|
2791
|
-
Function: () => Function,
|
|
2792
|
-
Index: () => Index,
|
|
2793
|
-
InstanceType: () => InstanceType,
|
|
2794
|
-
Instantiate: () => Instantiate,
|
|
2795
|
-
Integer: () => Integer,
|
|
2796
|
-
Intersect: () => Intersect,
|
|
2797
|
-
Iterator: () => Iterator,
|
|
2798
|
-
KeyOf: () => KeyOf,
|
|
2799
|
-
Literal: () => Literal,
|
|
2800
|
-
Lowercase: () => Lowercase,
|
|
2801
|
-
Mapped: () => Mapped,
|
|
2802
|
-
Module: () => Module,
|
|
2803
|
-
Never: () => Never,
|
|
2804
|
-
Not: () => Not,
|
|
2805
|
-
Null: () => Null,
|
|
2806
|
-
Number: () => Number2,
|
|
2807
|
-
Object: () => Object2,
|
|
2808
|
-
Omit: () => Omit,
|
|
2809
|
-
Optional: () => Optional,
|
|
2810
|
-
Parameters: () => Parameters,
|
|
2811
|
-
Partial: () => Partial,
|
|
2812
|
-
Pick: () => Pick,
|
|
2813
|
-
Promise: () => Promise2,
|
|
2814
|
-
Readonly: () => Readonly,
|
|
2815
|
-
ReadonlyOptional: () => ReadonlyOptional,
|
|
2816
|
-
Record: () => Record,
|
|
2817
|
-
Recursive: () => Recursive,
|
|
2818
|
-
Ref: () => Ref,
|
|
2819
|
-
RegExp: () => RegExp2,
|
|
2820
|
-
Required: () => Required,
|
|
2821
|
-
Rest: () => Rest,
|
|
2822
|
-
ReturnType: () => ReturnType,
|
|
2823
|
-
String: () => String2,
|
|
2824
|
-
Symbol: () => Symbol2,
|
|
2825
|
-
TemplateLiteral: () => TemplateLiteral,
|
|
2826
|
-
Transform: () => Transform,
|
|
2827
|
-
Tuple: () => Tuple,
|
|
2828
|
-
Uint8Array: () => Uint8Array2,
|
|
2829
|
-
Uncapitalize: () => Uncapitalize,
|
|
2830
|
-
Undefined: () => Undefined,
|
|
2831
|
-
Union: () => Union,
|
|
2832
|
-
Unknown: () => Unknown,
|
|
2833
|
-
Unsafe: () => Unsafe,
|
|
2834
|
-
Uppercase: () => Uppercase,
|
|
2835
|
-
Void: () => Void
|
|
2836
|
-
});
|
|
2837
|
-
|
|
2838
|
-
// node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
|
|
2839
|
-
var Type = type_exports2;
|
|
2840
|
-
|
|
2841
262
|
// src/tools.ts
|
|
263
|
+
var semanticKindUnion = Type.Union(
|
|
264
|
+
[
|
|
265
|
+
Type.Literal("observation"),
|
|
266
|
+
Type.Literal("assertion"),
|
|
267
|
+
Type.Literal("request"),
|
|
268
|
+
Type.Literal("resolution"),
|
|
269
|
+
Type.Literal("correction"),
|
|
270
|
+
Type.Literal("signal")
|
|
271
|
+
],
|
|
272
|
+
{ description: "Semantic classification of the fact" }
|
|
273
|
+
);
|
|
274
|
+
function actionHintForFact(semanticKind, mode) {
|
|
275
|
+
const sk = semanticKind ?? "observation";
|
|
276
|
+
const m = mode ?? "exclusive";
|
|
277
|
+
if (sk === "request" && m === "exclusive") {
|
|
278
|
+
return "This fact requests action (exclusive). Call fact_bus_claim to claim it, process it, then fact_bus_resolve (or fact_bus_release if you cannot handle it).";
|
|
279
|
+
}
|
|
280
|
+
if (sk === "request" && m === "broadcast") {
|
|
281
|
+
return "This fact requests action from all capable claws. Process and publish results via fact_bus_publish (optionally with parent_fact_id for causation).";
|
|
282
|
+
}
|
|
283
|
+
if (sk === "observation") {
|
|
284
|
+
return "New observation. You may corroborate or contradict via fact_bus_validate, or publish derived analysis with fact_bus_publish.";
|
|
285
|
+
}
|
|
286
|
+
if (sk === "assertion") {
|
|
287
|
+
return "An inference by another claw. Validate if you can confirm or dispute it (fact_bus_validate) or publish a counter-analysis.";
|
|
288
|
+
}
|
|
289
|
+
if (sk === "correction") {
|
|
290
|
+
return "A previous fact has been corrected. Review the updated information and adjust your plan.";
|
|
291
|
+
}
|
|
292
|
+
if (sk === "resolution") {
|
|
293
|
+
return "A task has been completed. Review the results; no claim needed unless you must follow up.";
|
|
294
|
+
}
|
|
295
|
+
if (sk === "signal") {
|
|
296
|
+
return "Status signal. No action needed unless relevant to your domain.";
|
|
297
|
+
}
|
|
298
|
+
return "Review this fact and decide whether to claim, validate, or publish.";
|
|
299
|
+
}
|
|
300
|
+
function factSummaryForSense(f) {
|
|
301
|
+
return {
|
|
302
|
+
fact_id: f.fact_id,
|
|
303
|
+
fact_type: f.fact_type,
|
|
304
|
+
semantic_kind: f.semantic_kind,
|
|
305
|
+
payload: f.payload,
|
|
306
|
+
confidence: f.confidence,
|
|
307
|
+
epistemic_state: f.epistemic_state,
|
|
308
|
+
mode: f.mode,
|
|
309
|
+
causation_depth: f.causation_depth,
|
|
310
|
+
state: f.state,
|
|
311
|
+
claimed_by: f.claimed_by,
|
|
312
|
+
parent_fact_id: f.parent_fact_id
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
var senseFactTool = {
|
|
316
|
+
name: "fact_bus_sense",
|
|
317
|
+
description: "Check for new facts pushed from the Fact Bus (WebSocket). Call this periodically to sense what is happening on the bus. Returns drained pending events with facts and action guidance (what to do next).",
|
|
318
|
+
parameters: Type.Object({
|
|
319
|
+
limit: Type.Optional(
|
|
320
|
+
Type.Number({
|
|
321
|
+
minimum: 1,
|
|
322
|
+
maximum: 100,
|
|
323
|
+
description: "Max events to drain per call (default: 10)"
|
|
324
|
+
})
|
|
325
|
+
)
|
|
326
|
+
}),
|
|
327
|
+
async execute(_id, params, context) {
|
|
328
|
+
const { logger } = context;
|
|
329
|
+
const limit = params.limit ?? 10;
|
|
330
|
+
const drained = pendingEvents.splice(0, limit);
|
|
331
|
+
if (drained.length === 0) {
|
|
332
|
+
return {
|
|
333
|
+
content: [
|
|
334
|
+
{
|
|
335
|
+
type: "text",
|
|
336
|
+
text: JSON.stringify(
|
|
337
|
+
{
|
|
338
|
+
count: 0,
|
|
339
|
+
message: "No pending bus events. Events arrive via WebSocket; call again after activity or use fact_bus_query to poll."
|
|
340
|
+
},
|
|
341
|
+
null,
|
|
342
|
+
2
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
details: {}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
logger.info(`fact_bus_sense drained ${drained.length} events`);
|
|
350
|
+
const items = drained.map((event) => {
|
|
351
|
+
const base = {
|
|
352
|
+
event_type: event.event_type,
|
|
353
|
+
timestamp: event.timestamp
|
|
354
|
+
};
|
|
355
|
+
if (event.event_type === "fact_available" && event.fact) {
|
|
356
|
+
const f = event.fact;
|
|
357
|
+
return {
|
|
358
|
+
...base,
|
|
359
|
+
fact: factSummaryForSense(f),
|
|
360
|
+
action_hint: actionHintForFact(f.semantic_kind, f.mode)
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
if (event.event_type === "fact_superseded" && event.fact) {
|
|
364
|
+
const f = event.fact;
|
|
365
|
+
return {
|
|
366
|
+
...base,
|
|
367
|
+
fact: factSummaryForSense(f),
|
|
368
|
+
action_hint: "This fact was superseded by newer knowledge. Prefer the latest fact for the same subject_key + fact_type."
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
if (event.event_type === "fact_trust_changed" && event.fact) {
|
|
372
|
+
const f = event.fact;
|
|
373
|
+
return {
|
|
374
|
+
...base,
|
|
375
|
+
fact: factSummaryForSense(f),
|
|
376
|
+
detail: event.detail,
|
|
377
|
+
action_hint: "Trust level of this fact changed. Re-evaluate whether to rely on it; consider fact_bus_validate if you have independent evidence."
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
...base,
|
|
382
|
+
..."claw_id" in event && event.claw_id ? { claw_id: event.claw_id } : {},
|
|
383
|
+
detail: event.detail,
|
|
384
|
+
fact: event.fact ? factSummaryForSense(event.fact) : void 0,
|
|
385
|
+
action_hint: "Review event detail and related facts."
|
|
386
|
+
};
|
|
387
|
+
});
|
|
388
|
+
return {
|
|
389
|
+
content: [
|
|
390
|
+
{
|
|
391
|
+
type: "text",
|
|
392
|
+
text: JSON.stringify({ count: items.length, events: items }, null, 2)
|
|
393
|
+
}
|
|
394
|
+
],
|
|
395
|
+
details: {}
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
};
|
|
2842
399
|
var publishFactTool = {
|
|
2843
400
|
name: "fact_bus_publish",
|
|
2844
|
-
description: "Publish a new fact to the Claw Fact Bus. Facts are immutable records that flow through the bus and can be sensed by other claws.",
|
|
401
|
+
description: "Publish a new fact to the Claw Fact Bus. Facts are immutable records that flow through the bus and can be sensed by other claws. Use semantic_kind to classify: 'observation' for sensed data, 'assertion' for inferences, 'request' for action requests, 'resolution' for completed work, 'correction' to update previous facts, 'signal' for status pings. Use parent_fact_id to link this fact to a prior fact (causation depth +1) without resolving the parent.",
|
|
2845
402
|
parameters: Type.Object({
|
|
2846
403
|
fact_type: Type.String({
|
|
2847
404
|
description: "Dot-notation fact type (e.g., 'code.review.needed', 'incident.latency.high')"
|
|
@@ -2870,18 +427,20 @@ var publishFactTool = {
|
|
|
2870
427
|
})
|
|
2871
428
|
),
|
|
2872
429
|
mode: Type.Optional(
|
|
2873
|
-
Type.Union(
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
description: "broadcast = anyone can process; exclusive = must be claimed first (default: exclusive)"
|
|
2877
|
-
}
|
|
2878
|
-
)
|
|
430
|
+
Type.Union([Type.Literal("broadcast"), Type.Literal("exclusive")], {
|
|
431
|
+
description: "broadcast = anyone can process; exclusive = must be claimed first (default: exclusive)"
|
|
432
|
+
})
|
|
2879
433
|
),
|
|
2880
434
|
subject_key: Type.Optional(
|
|
2881
435
|
Type.String({
|
|
2882
436
|
description: "Groups facts about the same subject for knowledge evolution"
|
|
2883
437
|
})
|
|
2884
438
|
),
|
|
439
|
+
parent_fact_id: Type.Optional(
|
|
440
|
+
Type.String({
|
|
441
|
+
description: "ID of the parent fact this is derived from; builds causation_chain and increments causation_depth"
|
|
442
|
+
})
|
|
443
|
+
),
|
|
2885
444
|
confidence: Type.Optional(
|
|
2886
445
|
Type.Number({
|
|
2887
446
|
minimum: 0,
|
|
@@ -2910,9 +469,30 @@ var publishFactTool = {
|
|
|
2910
469
|
type: "text",
|
|
2911
470
|
text: "Error: Not connected to Fact Bus. Please check configuration."
|
|
2912
471
|
}
|
|
2913
|
-
]
|
|
472
|
+
],
|
|
473
|
+
details: {}
|
|
2914
474
|
};
|
|
2915
475
|
}
|
|
476
|
+
let causation_chain;
|
|
477
|
+
let causation_depth;
|
|
478
|
+
if (params.parent_fact_id) {
|
|
479
|
+
const parentRes = await client2.getFact(params.parent_fact_id);
|
|
480
|
+
if (!parentRes.success || !parentRes.data) {
|
|
481
|
+
return {
|
|
482
|
+
content: [
|
|
483
|
+
{
|
|
484
|
+
type: "text",
|
|
485
|
+
text: `Failed to load parent fact ${params.parent_fact_id}: ${parentRes.error ?? "not found"}`
|
|
486
|
+
}
|
|
487
|
+
],
|
|
488
|
+
details: {}
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
const parent = parentRes.data;
|
|
492
|
+
const chain = [...parent.causation_chain || [], params.parent_fact_id];
|
|
493
|
+
causation_chain = chain;
|
|
494
|
+
causation_depth = (parent.causation_depth ?? 0) + 1;
|
|
495
|
+
}
|
|
2916
496
|
logger.info("Publishing fact:", params.fact_type);
|
|
2917
497
|
const result = await client2.publishFact({
|
|
2918
498
|
fact_type: params.fact_type,
|
|
@@ -2925,12 +505,14 @@ var publishFactTool = {
|
|
|
2925
505
|
ttl_seconds: params.ttl_seconds,
|
|
2926
506
|
domain_tags: params.domain_tags,
|
|
2927
507
|
need_capabilities: params.need_capabilities,
|
|
2928
|
-
|
|
508
|
+
causation_chain,
|
|
509
|
+
causation_depth
|
|
2929
510
|
});
|
|
2930
511
|
if (!result.success) {
|
|
2931
512
|
logger.error("Failed to publish fact:", result.error);
|
|
2932
513
|
return {
|
|
2933
|
-
content: [{ type: "text", text: `Failed to publish fact: ${result.error}` }]
|
|
514
|
+
content: [{ type: "text", text: `Failed to publish fact: ${result.error}` }],
|
|
515
|
+
details: {}
|
|
2934
516
|
};
|
|
2935
517
|
}
|
|
2936
518
|
const fact = result.data;
|
|
@@ -2945,23 +527,24 @@ var publishFactTool = {
|
|
|
2945
527
|
fact_id: fact.fact_id,
|
|
2946
528
|
fact_type: fact.fact_type,
|
|
2947
529
|
state: fact.state,
|
|
530
|
+
causation_depth: fact.causation_depth,
|
|
531
|
+
causation_chain: fact.causation_chain,
|
|
2948
532
|
created_at: new Date(fact.created_at).toISOString()
|
|
2949
533
|
},
|
|
2950
534
|
null,
|
|
2951
535
|
2
|
|
2952
536
|
)
|
|
2953
537
|
}
|
|
2954
|
-
]
|
|
538
|
+
],
|
|
539
|
+
details: {}
|
|
2955
540
|
};
|
|
2956
541
|
}
|
|
2957
542
|
};
|
|
2958
543
|
var queryFactsTool = {
|
|
2959
544
|
name: "fact_bus_query",
|
|
2960
|
-
description: "Query facts from the Claw Fact Bus. Can filter by type, state, and source.",
|
|
545
|
+
description: "Query facts from the Claw Fact Bus. Can filter by type, state, and source. Use together with fact_bus_sense for full coverage.",
|
|
2961
546
|
parameters: Type.Object({
|
|
2962
|
-
fact_type: Type.Optional(
|
|
2963
|
-
Type.String({ description: "Filter by fact type" })
|
|
2964
|
-
),
|
|
547
|
+
fact_type: Type.Optional(Type.String({ description: "Filter by fact type" })),
|
|
2965
548
|
state: Type.Optional(
|
|
2966
549
|
Type.Union(
|
|
2967
550
|
[
|
|
@@ -2999,7 +582,8 @@ var queryFactsTool = {
|
|
|
2999
582
|
if (!result.success) {
|
|
3000
583
|
logger.error("Failed to query facts:", result.error);
|
|
3001
584
|
return {
|
|
3002
|
-
content: [{ type: "text", text: `Failed to query facts: ${result.error}` }]
|
|
585
|
+
content: [{ type: "text", text: `Failed to query facts: ${result.error}` }],
|
|
586
|
+
details: {}
|
|
3003
587
|
};
|
|
3004
588
|
}
|
|
3005
589
|
const facts = result.data;
|
|
@@ -3018,13 +602,14 @@ var queryFactsTool = {
|
|
|
3018
602
|
type: "text",
|
|
3019
603
|
text: JSON.stringify({ count: facts.length, facts: summary }, null, 2)
|
|
3020
604
|
}
|
|
3021
|
-
]
|
|
605
|
+
],
|
|
606
|
+
details: {}
|
|
3022
607
|
};
|
|
3023
608
|
}
|
|
3024
609
|
};
|
|
3025
610
|
var claimFactTool = {
|
|
3026
611
|
name: "fact_bus_claim",
|
|
3027
|
-
description: "Claim an exclusive fact for processing. Only one claw can claim a fact at a time.",
|
|
612
|
+
description: "Claim an exclusive fact for processing. Only one claw can claim a fact at a time. Only needed for exclusive-mode facts. After claiming, you must either resolve (fact_bus_resolve) or release (fact_bus_release) the fact.",
|
|
3028
613
|
parameters: Type.Object({
|
|
3029
614
|
fact_id: Type.String({ description: "The ID of the fact to claim" })
|
|
3030
615
|
}),
|
|
@@ -3032,9 +617,8 @@ var claimFactTool = {
|
|
|
3032
617
|
const { client: client2, logger } = context;
|
|
3033
618
|
if (!client2.isConnected) {
|
|
3034
619
|
return {
|
|
3035
|
-
content: [
|
|
3036
|
-
|
|
3037
|
-
]
|
|
620
|
+
content: [{ type: "text", text: "Error: Not connected to Fact Bus." }],
|
|
621
|
+
details: {}
|
|
3038
622
|
};
|
|
3039
623
|
}
|
|
3040
624
|
logger.info("Claiming fact:", params.fact_id);
|
|
@@ -3042,7 +626,8 @@ var claimFactTool = {
|
|
|
3042
626
|
if (!result.success) {
|
|
3043
627
|
logger.error("Failed to claim fact:", result.error);
|
|
3044
628
|
return {
|
|
3045
|
-
content: [{ type: "text", text: `Failed to claim fact: ${result.error}` }]
|
|
629
|
+
content: [{ type: "text", text: `Failed to claim fact: ${result.error}` }],
|
|
630
|
+
details: {}
|
|
3046
631
|
};
|
|
3047
632
|
}
|
|
3048
633
|
logger.info("Fact claimed:", params.fact_id);
|
|
@@ -3060,13 +645,14 @@ var claimFactTool = {
|
|
|
3060
645
|
2
|
|
3061
646
|
)
|
|
3062
647
|
}
|
|
3063
|
-
]
|
|
648
|
+
],
|
|
649
|
+
details: {}
|
|
3064
650
|
};
|
|
3065
651
|
}
|
|
3066
652
|
};
|
|
3067
653
|
var releaseFactTool = {
|
|
3068
654
|
name: "fact_bus_release",
|
|
3069
|
-
description: "Release a claimed fact back to the
|
|
655
|
+
description: "Release a previously claimed exclusive fact back to the bus so other claws can claim it. Use when you cannot complete the work.",
|
|
3070
656
|
parameters: Type.Object({
|
|
3071
657
|
fact_id: Type.String({ description: "The ID of the fact to release" })
|
|
3072
658
|
}),
|
|
@@ -3074,9 +660,8 @@ var releaseFactTool = {
|
|
|
3074
660
|
const { client: client2, logger } = context;
|
|
3075
661
|
if (!client2.isConnected) {
|
|
3076
662
|
return {
|
|
3077
|
-
content: [
|
|
3078
|
-
|
|
3079
|
-
]
|
|
663
|
+
content: [{ type: "text", text: "Error: Not connected to Fact Bus." }],
|
|
664
|
+
details: {}
|
|
3080
665
|
};
|
|
3081
666
|
}
|
|
3082
667
|
logger.info("Releasing fact:", params.fact_id);
|
|
@@ -3084,36 +669,35 @@ var releaseFactTool = {
|
|
|
3084
669
|
if (!result.success) {
|
|
3085
670
|
logger.error("Failed to release fact:", result.error);
|
|
3086
671
|
return {
|
|
3087
|
-
content: [{ type: "text", text: `Failed to release fact: ${result.error}` }]
|
|
672
|
+
content: [{ type: "text", text: `Failed to release fact: ${result.error}` }],
|
|
673
|
+
details: {}
|
|
3088
674
|
};
|
|
3089
675
|
}
|
|
3090
|
-
logger.info("Fact released:", params.fact_id);
|
|
3091
676
|
return {
|
|
3092
677
|
content: [
|
|
3093
678
|
{
|
|
3094
679
|
type: "text",
|
|
3095
680
|
text: JSON.stringify(
|
|
3096
|
-
{
|
|
3097
|
-
success: true,
|
|
3098
|
-
fact_id: result.data.fact_id
|
|
3099
|
-
},
|
|
681
|
+
{ success: true, fact_id: result.data.fact_id },
|
|
3100
682
|
null,
|
|
3101
683
|
2
|
|
3102
684
|
)
|
|
3103
685
|
}
|
|
3104
|
-
]
|
|
686
|
+
],
|
|
687
|
+
details: {}
|
|
3105
688
|
};
|
|
3106
689
|
}
|
|
3107
690
|
};
|
|
3108
691
|
var resolveFactTool = {
|
|
3109
692
|
name: "fact_bus_resolve",
|
|
3110
|
-
description: "Mark a claimed fact as resolved. Optionally emit child facts as results.",
|
|
693
|
+
description: "Mark a claimed fact as resolved. Optionally emit child facts as results. Child facts automatically inherit the causation chain (depth +1). Use result_facts to emit findings for other claws to sense; set semantic_kind on each child (often 'resolution' for outcomes).",
|
|
3111
694
|
parameters: Type.Object({
|
|
3112
695
|
fact_id: Type.String({ description: "The ID of the fact to resolve" }),
|
|
3113
696
|
result_facts: Type.Optional(
|
|
3114
697
|
Type.Array(
|
|
3115
698
|
Type.Object({
|
|
3116
699
|
fact_type: Type.String(),
|
|
700
|
+
semantic_kind: Type.Optional(semanticKindUnion),
|
|
3117
701
|
payload: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
3118
702
|
domain_tags: Type.Optional(Type.Array(Type.String())),
|
|
3119
703
|
need_capabilities: Type.Optional(Type.Array(Type.String())),
|
|
@@ -3128,7 +712,8 @@ var resolveFactTool = {
|
|
|
3128
712
|
const { client: client2, logger } = context;
|
|
3129
713
|
if (!client2.isConnected) {
|
|
3130
714
|
return {
|
|
3131
|
-
content: [{ type: "text", text: "Error: Not connected to Fact Bus." }]
|
|
715
|
+
content: [{ type: "text", text: "Error: Not connected to Fact Bus." }],
|
|
716
|
+
details: {}
|
|
3132
717
|
};
|
|
3133
718
|
}
|
|
3134
719
|
logger.info("Resolving fact:", params.fact_id);
|
|
@@ -3136,7 +721,8 @@ var resolveFactTool = {
|
|
|
3136
721
|
if (!result.success) {
|
|
3137
722
|
logger.error("Failed to resolve fact:", result.error);
|
|
3138
723
|
return {
|
|
3139
|
-
content: [{ type: "text", text: `Failed to resolve fact: ${result.error}` }]
|
|
724
|
+
content: [{ type: "text", text: `Failed to resolve fact: ${result.error}` }],
|
|
725
|
+
details: {}
|
|
3140
726
|
};
|
|
3141
727
|
}
|
|
3142
728
|
logger.info("Fact resolved:", params.fact_id);
|
|
@@ -3153,25 +739,26 @@ var resolveFactTool = {
|
|
|
3153
739
|
2
|
|
3154
740
|
)
|
|
3155
741
|
}
|
|
3156
|
-
]
|
|
742
|
+
],
|
|
743
|
+
details: {}
|
|
3157
744
|
};
|
|
3158
745
|
}
|
|
3159
746
|
};
|
|
3160
747
|
var validateFactTool = {
|
|
3161
748
|
name: "fact_bus_validate",
|
|
3162
|
-
description: "Corroborate or contradict a fact
|
|
749
|
+
description: "Corroborate or contradict a fact for social validation and consensus. Use 'corroborate' when you independently verify a fact is correct. Use 'contradict' when your evidence disagrees. This affects the fact's trust level (epistemic state).",
|
|
3163
750
|
parameters: Type.Object({
|
|
3164
751
|
fact_id: Type.String({ description: "The ID of the fact to validate" }),
|
|
3165
|
-
action: Type.Union(
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
)
|
|
752
|
+
action: Type.Union([Type.Literal("corroborate"), Type.Literal("contradict")], {
|
|
753
|
+
description: "corroborate = confirm; contradict = dispute"
|
|
754
|
+
})
|
|
3169
755
|
}),
|
|
3170
756
|
async execute(_id, params, context) {
|
|
3171
757
|
const { client: client2, logger } = context;
|
|
3172
758
|
if (!client2.isConnected) {
|
|
3173
759
|
return {
|
|
3174
|
-
content: [{ type: "text", text: "Error: Not connected to Fact Bus." }]
|
|
760
|
+
content: [{ type: "text", text: "Error: Not connected to Fact Bus." }],
|
|
761
|
+
details: {}
|
|
3175
762
|
};
|
|
3176
763
|
}
|
|
3177
764
|
logger.info(`${params.action} fact:`, params.fact_id);
|
|
@@ -3181,7 +768,8 @@ var validateFactTool = {
|
|
|
3181
768
|
return {
|
|
3182
769
|
content: [
|
|
3183
770
|
{ type: "text", text: `Failed to ${params.action} fact: ${result.error}` }
|
|
3184
|
-
]
|
|
771
|
+
],
|
|
772
|
+
details: {}
|
|
3185
773
|
};
|
|
3186
774
|
}
|
|
3187
775
|
logger.info(`Fact ${params.action}d:`, params.fact_id);
|
|
@@ -3200,17 +788,54 @@ var validateFactTool = {
|
|
|
3200
788
|
2
|
|
3201
789
|
)
|
|
3202
790
|
}
|
|
3203
|
-
]
|
|
791
|
+
],
|
|
792
|
+
details: {}
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
var getSchemaFactTool = {
|
|
797
|
+
name: "fact_bus_get_schema",
|
|
798
|
+
description: "Get the registered schema for a fact type. Shows required fields, types, and descriptions so you know what payload to construct or how to interpret an incoming fact. Use fact_bus_query or fact_bus_sense to see live facts first.",
|
|
799
|
+
parameters: Type.Object({
|
|
800
|
+
fact_type: Type.String({
|
|
801
|
+
description: "Dot-notation fact type (e.g. 'code.review.needed')"
|
|
802
|
+
})
|
|
803
|
+
}),
|
|
804
|
+
async execute(_id, params, context) {
|
|
805
|
+
const { client: client2, logger } = context;
|
|
806
|
+
logger.debug("Fetching schema for:", params.fact_type);
|
|
807
|
+
const result = await client2.getSchema(params.fact_type);
|
|
808
|
+
if (!result.success) {
|
|
809
|
+
return {
|
|
810
|
+
content: [
|
|
811
|
+
{
|
|
812
|
+
type: "text",
|
|
813
|
+
text: `Failed to get schema: ${result.error ?? "unknown error"}`
|
|
814
|
+
}
|
|
815
|
+
],
|
|
816
|
+
details: {}
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
return {
|
|
820
|
+
content: [
|
|
821
|
+
{
|
|
822
|
+
type: "text",
|
|
823
|
+
text: JSON.stringify(result.data, null, 2)
|
|
824
|
+
}
|
|
825
|
+
],
|
|
826
|
+
details: {}
|
|
3204
827
|
};
|
|
3205
828
|
}
|
|
3206
829
|
};
|
|
3207
830
|
var factBusTools = [
|
|
831
|
+
senseFactTool,
|
|
3208
832
|
publishFactTool,
|
|
3209
833
|
queryFactsTool,
|
|
3210
834
|
claimFactTool,
|
|
3211
835
|
releaseFactTool,
|
|
3212
836
|
resolveFactTool,
|
|
3213
|
-
validateFactTool
|
|
837
|
+
validateFactTool,
|
|
838
|
+
getSchemaFactTool
|
|
3214
839
|
];
|
|
3215
840
|
|
|
3216
841
|
// src/websocket.ts
|
|
@@ -3315,7 +940,7 @@ var FactBusWebSocketService = class {
|
|
|
3315
940
|
return WebSocket;
|
|
3316
941
|
}
|
|
3317
942
|
try {
|
|
3318
|
-
const wsModule = await import('./wrapper-
|
|
943
|
+
const wsModule = await import('./wrapper-HE2LXQRG.js');
|
|
3319
944
|
return wsModule.default || wsModule.WebSocket;
|
|
3320
945
|
} catch {
|
|
3321
946
|
throw new Error(
|
|
@@ -3420,7 +1045,11 @@ var FactBusWebSocketService = class {
|
|
|
3420
1045
|
fact_type_patterns: this.config.factTypePatterns || [],
|
|
3421
1046
|
priority_range: this.config.priorityRange || [0, 7],
|
|
3422
1047
|
modes: this.config.modes?.map((m) => m) || ["exclusive", "broadcast"],
|
|
3423
|
-
|
|
1048
|
+
semantic_kinds: this.config.semanticKinds || [],
|
|
1049
|
+
min_epistemic_rank: this.config.minEpistemicRank ?? -3,
|
|
1050
|
+
min_confidence: this.config.minConfidence ?? 0,
|
|
1051
|
+
exclude_superseded: true,
|
|
1052
|
+
subject_key_patterns: this.config.subjectKeyPatterns || []
|
|
3424
1053
|
}
|
|
3425
1054
|
};
|
|
3426
1055
|
this.logger.debug("Subscribing with filter:", subscribeRequest.filter);
|
|
@@ -3516,118 +1145,89 @@ var FactBusWebSocketService = class {
|
|
|
3516
1145
|
};
|
|
3517
1146
|
|
|
3518
1147
|
// index.ts
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
return { success: false, error: { issues: [{ path: [], message: "config must be an object" }] } };
|
|
3525
|
-
}
|
|
3526
|
-
const cfg = value;
|
|
3527
|
-
if (typeof cfg.busUrl !== "string" || !cfg.busUrl) {
|
|
3528
|
-
return { success: false, error: { issues: [{ path: ["busUrl"], message: "busUrl is required" }] } };
|
|
3529
|
-
}
|
|
3530
|
-
const validConfig = {
|
|
3531
|
-
busUrl: cfg.busUrl,
|
|
3532
|
-
clawName: cfg.clawName,
|
|
3533
|
-
clawDescription: cfg.clawDescription,
|
|
3534
|
-
capabilityOffer: cfg.capabilityOffer,
|
|
3535
|
-
domainInterests: cfg.domainInterests,
|
|
3536
|
-
factTypePatterns: cfg.factTypePatterns,
|
|
3537
|
-
priorityRange: cfg.priorityRange,
|
|
3538
|
-
modes: cfg.modes,
|
|
3539
|
-
autoReconnect: cfg.autoReconnect,
|
|
3540
|
-
reconnectInterval: cfg.reconnectInterval
|
|
3541
|
-
};
|
|
3542
|
-
return { success: true, data: validConfig };
|
|
3543
|
-
},
|
|
3544
|
-
parse(value) {
|
|
3545
|
-
const result = this.safeParse(value);
|
|
3546
|
-
if (!result.success) {
|
|
3547
|
-
throw new Error(result.error.issues.map((i) => i.message).join(", "));
|
|
3548
|
-
}
|
|
3549
|
-
return result.data;
|
|
3550
|
-
},
|
|
3551
|
-
uiHints: {
|
|
3552
|
-
busUrl: {
|
|
3553
|
-
label: "Fact Bus URL",
|
|
3554
|
-
placeholder: "http://localhost:8080",
|
|
3555
|
-
help: "The URL of the Claw Fact Bus server"
|
|
3556
|
-
},
|
|
3557
|
-
clawName: {
|
|
3558
|
-
label: "Claw Name",
|
|
3559
|
-
help: "Unique identifier for this Claw agent"
|
|
3560
|
-
},
|
|
3561
|
-
clawDescription: {
|
|
3562
|
-
label: "Claw Description",
|
|
3563
|
-
help: "Description of this Claw's purpose"
|
|
3564
|
-
},
|
|
3565
|
-
capabilityOffer: {
|
|
3566
|
-
label: "Capabilities Offered",
|
|
3567
|
-
help: "List of capabilities this Claw can provide"
|
|
3568
|
-
},
|
|
3569
|
-
domainInterests: {
|
|
3570
|
-
label: "Domain Interests",
|
|
3571
|
-
help: "List of domains this Claw is interested in"
|
|
1148
|
+
function wrapPluginLogger(log) {
|
|
1149
|
+
const join = (args) => args.map((a) => a instanceof Error ? a.stack ?? a.message : String(a)).join(" ");
|
|
1150
|
+
return {
|
|
1151
|
+
debug: (...args) => {
|
|
1152
|
+
log.debug?.(join(args));
|
|
3572
1153
|
},
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
help: "Glob patterns for fact types to subscribe to"
|
|
1154
|
+
info: (...args) => {
|
|
1155
|
+
log.info(join(args));
|
|
3576
1156
|
},
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
help: "Automatically reconnect WebSocket on disconnect"
|
|
1157
|
+
warn: (...args) => {
|
|
1158
|
+
log.warn(join(args));
|
|
3580
1159
|
},
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
help: "Interval between reconnection attempts",
|
|
3584
|
-
advanced: true
|
|
1160
|
+
error: (...args) => {
|
|
1161
|
+
log.error(join(args));
|
|
3585
1162
|
}
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
function sendJson(res, body) {
|
|
1166
|
+
res.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
1167
|
+
res.end(JSON.stringify(body));
|
|
1168
|
+
}
|
|
1169
|
+
var client = null;
|
|
1170
|
+
var wsService = null;
|
|
3588
1171
|
var index_default = definePluginEntry({
|
|
3589
1172
|
id: "fact-bus",
|
|
3590
1173
|
name: "Claw Fact Bus Plugin",
|
|
3591
1174
|
description: "Integrates OpenClaw with Claw Fact Bus for fact-driven autonomous agent coordination",
|
|
3592
|
-
configSchema
|
|
1175
|
+
configSchema: Type.Object({
|
|
1176
|
+
busUrl: Type.String({ default: "http://localhost:8080" }),
|
|
1177
|
+
clawName: Type.Optional(Type.String()),
|
|
1178
|
+
clawDescription: Type.Optional(Type.String()),
|
|
1179
|
+
capabilityOffer: Type.Optional(Type.Array(Type.String())),
|
|
1180
|
+
domainInterests: Type.Optional(Type.Array(Type.String())),
|
|
1181
|
+
factTypePatterns: Type.Optional(Type.Array(Type.String())),
|
|
1182
|
+
priorityRange: Type.Optional(
|
|
1183
|
+
Type.Tuple([Type.Number(), Type.Number()], {
|
|
1184
|
+
description: "Priority range [low, high] for subscription filter (0-7)"
|
|
1185
|
+
})
|
|
1186
|
+
),
|
|
1187
|
+
modes: Type.Optional(
|
|
1188
|
+
Type.Array(Type.Union([Type.Literal("exclusive"), Type.Literal("broadcast")]))
|
|
1189
|
+
),
|
|
1190
|
+
semanticKinds: Type.Optional(
|
|
1191
|
+
Type.Array(
|
|
1192
|
+
Type.Union([
|
|
1193
|
+
Type.Literal("observation"),
|
|
1194
|
+
Type.Literal("assertion"),
|
|
1195
|
+
Type.Literal("request"),
|
|
1196
|
+
Type.Literal("resolution"),
|
|
1197
|
+
Type.Literal("correction"),
|
|
1198
|
+
Type.Literal("signal")
|
|
1199
|
+
])
|
|
1200
|
+
)
|
|
1201
|
+
),
|
|
1202
|
+
minEpistemicRank: Type.Optional(Type.Number({ default: -3 })),
|
|
1203
|
+
minConfidence: Type.Optional(Type.Number({ default: 0, minimum: 0, maximum: 1 })),
|
|
1204
|
+
subjectKeyPatterns: Type.Optional(Type.Array(Type.String())),
|
|
1205
|
+
autoReconnect: Type.Optional(Type.Boolean({ default: true })),
|
|
1206
|
+
reconnectInterval: Type.Optional(Type.Number({ default: 5e3 }))
|
|
1207
|
+
}),
|
|
3593
1208
|
register(api) {
|
|
3594
|
-
const config =
|
|
3595
|
-
const logger = api.logger;
|
|
1209
|
+
const config = api.pluginConfig;
|
|
1210
|
+
const logger = wrapPluginLogger(api.logger);
|
|
3596
1211
|
client = new FactBusClient(config.busUrl);
|
|
3597
1212
|
const toolContext = {
|
|
3598
1213
|
client,
|
|
3599
|
-
logger
|
|
3600
|
-
debug: (...args) => {
|
|
3601
|
-
logger.debug?.(args.map(String).join(" "));
|
|
3602
|
-
},
|
|
3603
|
-
info: (...args) => {
|
|
3604
|
-
logger.info?.(args.map(String).join(" "));
|
|
3605
|
-
},
|
|
3606
|
-
warn: (...args) => {
|
|
3607
|
-
logger.warn?.(args.map(String).join(" "));
|
|
3608
|
-
},
|
|
3609
|
-
error: (...args) => {
|
|
3610
|
-
logger.error?.(args.map(String).join(" "));
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
1214
|
+
logger
|
|
3613
1215
|
};
|
|
3614
1216
|
for (const tool of factBusTools) {
|
|
3615
|
-
api.registerTool(
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
1217
|
+
api.registerTool(
|
|
1218
|
+
{
|
|
1219
|
+
name: tool.name,
|
|
1220
|
+
label: tool.name,
|
|
1221
|
+
description: tool.description,
|
|
1222
|
+
parameters: tool.parameters,
|
|
1223
|
+
execute: async (id, params) => {
|
|
1224
|
+
if (!client?.isConnected) {
|
|
1225
|
+
await connectToBus(config, logger);
|
|
1226
|
+
}
|
|
1227
|
+
return tool.execute(id, params, toolContext);
|
|
3623
1228
|
}
|
|
3624
|
-
const result = await tool.execute(_id, params, toolContext);
|
|
3625
|
-
return {
|
|
3626
|
-
content: result.content,
|
|
3627
|
-
details: {}
|
|
3628
|
-
};
|
|
3629
1229
|
}
|
|
3630
|
-
|
|
1230
|
+
);
|
|
3631
1231
|
}
|
|
3632
1232
|
api.on("gateway_start", async () => {
|
|
3633
1233
|
toolContext.logger.info("Gateway starting, connecting to Fact Bus...");
|
|
@@ -3649,16 +1249,15 @@ var index_default = definePluginEntry({
|
|
|
3649
1249
|
});
|
|
3650
1250
|
api.registerHttpRoute({
|
|
3651
1251
|
path: "/plugins/fact-bus/health",
|
|
3652
|
-
auth: "
|
|
1252
|
+
auth: "gateway",
|
|
3653
1253
|
handler: async (_req, res) => {
|
|
3654
|
-
const response = res;
|
|
3655
1254
|
const health = {
|
|
3656
1255
|
plugin: "fact-bus",
|
|
3657
1256
|
connected: client?.isConnected ?? false,
|
|
3658
1257
|
websocket: wsService?.isConnected ?? false,
|
|
3659
1258
|
clawId: client?.currentClawId
|
|
3660
1259
|
};
|
|
3661
|
-
|
|
1260
|
+
sendJson(res, health);
|
|
3662
1261
|
}
|
|
3663
1262
|
});
|
|
3664
1263
|
}
|
|
@@ -3679,7 +1278,9 @@ async function connectToBus(config, logger) {
|
|
|
3679
1278
|
description: config.clawDescription ?? "OpenClaw Agent via Fact Bus Plugin",
|
|
3680
1279
|
capability_offer: config.capabilityOffer ?? [],
|
|
3681
1280
|
domain_interests: config.domainInterests ?? [],
|
|
3682
|
-
fact_type_patterns: config.factTypePatterns ?? []
|
|
1281
|
+
fact_type_patterns: config.factTypePatterns ?? [],
|
|
1282
|
+
priority_range: config.priorityRange ?? [0, 7],
|
|
1283
|
+
modes: config.modes ?? ["exclusive", "broadcast"]
|
|
3683
1284
|
});
|
|
3684
1285
|
logger.info(`Connected to Fact Bus as claw: ${response.claw_id}`);
|
|
3685
1286
|
} catch (error) {
|
|
@@ -3700,36 +1301,9 @@ function startWebSocketService(config, logger) {
|
|
|
3700
1301
|
handleWebSocketEvent(event, logger);
|
|
3701
1302
|
}
|
|
3702
1303
|
});
|
|
3703
|
-
setupWebSocketEventHandlers(wsService, logger);
|
|
3704
1304
|
wsService.start();
|
|
3705
1305
|
logger.info("WebSocket service started");
|
|
3706
1306
|
}
|
|
3707
|
-
function setupWebSocketEventHandlers(service, logger) {
|
|
3708
|
-
service.on("fact_available", ((event) => {
|
|
3709
|
-
logger.info(`New fact available: ${event.fact?.fact_type} (id: ${event.fact?.fact_id})`);
|
|
3710
|
-
}));
|
|
3711
|
-
service.on("fact_claimed", ((event) => {
|
|
3712
|
-
logger.debug(`Fact claimed: ${event.fact?.fact_id} by ${event.fact?.claimed_by}`);
|
|
3713
|
-
}));
|
|
3714
|
-
service.on("fact_resolved", ((event) => {
|
|
3715
|
-
logger.info(`Fact resolved: ${event.fact?.fact_id}`);
|
|
3716
|
-
}));
|
|
3717
|
-
service.on("fact_superseded", ((event) => {
|
|
3718
|
-
logger.info(`Fact superseded: ${event.fact?.fact_id} -> ${event.fact?.superseded_by}`);
|
|
3719
|
-
}));
|
|
3720
|
-
service.on("fact_trust_changed", ((event) => {
|
|
3721
|
-
logger.debug(`Fact trust changed: ${event.fact?.fact_id}`, event.detail);
|
|
3722
|
-
}));
|
|
3723
|
-
service.on("claw_state_changed", ((event) => {
|
|
3724
|
-
logger.info(`Claw state changed: ${event.claw_id}`, event.detail);
|
|
3725
|
-
}));
|
|
3726
|
-
service.on("fact_expired", ((event) => {
|
|
3727
|
-
logger.debug(`Fact expired: ${event.fact?.fact_id}`);
|
|
3728
|
-
}));
|
|
3729
|
-
service.on("fact_dead", ((event) => {
|
|
3730
|
-
logger.debug(`Fact dead: ${event.fact?.fact_id}`);
|
|
3731
|
-
}));
|
|
3732
|
-
}
|
|
3733
1307
|
function stopWebSocketService() {
|
|
3734
1308
|
if (wsService) {
|
|
3735
1309
|
wsService.stop();
|
|
@@ -3740,7 +1314,8 @@ function handleWebSocketEvent(event, logger) {
|
|
|
3740
1314
|
const ev = event;
|
|
3741
1315
|
switch (ev.event_type) {
|
|
3742
1316
|
case "fact_available":
|
|
3743
|
-
logger.info(`Fact available: ${
|
|
1317
|
+
logger.info(`Fact available: ${event.fact?.fact_type}`);
|
|
1318
|
+
pushPendingEvent(event);
|
|
3744
1319
|
break;
|
|
3745
1320
|
case "fact_claimed":
|
|
3746
1321
|
logger.debug(`Fact claimed: ${ev.fact?.fact_id}`);
|
|
@@ -3749,10 +1324,12 @@ function handleWebSocketEvent(event, logger) {
|
|
|
3749
1324
|
logger.info(`Fact resolved: ${ev.fact?.fact_id}`);
|
|
3750
1325
|
break;
|
|
3751
1326
|
case "fact_superseded":
|
|
3752
|
-
logger.info(`Fact superseded: ${
|
|
1327
|
+
logger.info(`Fact superseded: ${event.fact?.fact_id}`);
|
|
1328
|
+
pushPendingEvent(event);
|
|
3753
1329
|
break;
|
|
3754
1330
|
case "fact_trust_changed":
|
|
3755
|
-
logger.debug(`Fact trust changed: ${
|
|
1331
|
+
logger.debug(`Fact trust changed: ${event.fact?.fact_id}`, event.detail);
|
|
1332
|
+
pushPendingEvent(event);
|
|
3756
1333
|
break;
|
|
3757
1334
|
case "claw_state_changed":
|
|
3758
1335
|
logger.debug(`Claw state changed`, ev.detail);
|