@elpapi42/pi-fleet 0.1.0-beta.0 → 0.1.0-beta.10
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/CHANGELOG.md +162 -3
- package/README.md +170 -104
- package/bin/pifleet-runtime.mjs +1 -1
- package/dist/cli-meta.json +5464 -82
- package/dist/cli.mjs +3481 -253
- package/dist/cli.mjs.map +4 -4
- package/dist/installer-meta.json +87 -13
- package/dist/installer.mjs +555 -95
- package/dist/installer.mjs.map +4 -4
- package/dist/runtime-manifest.json +37 -43
- package/dist/runtime-meta.json +2976 -2868
- package/dist/runtime.mjs +6316 -5247
- package/dist/runtime.mjs.map +4 -4
- package/dist/sqlite-worker-meta.json +6 -6
- package/dist/sqlite-worker.mjs +95 -40
- package/dist/sqlite-worker.mjs.map +2 -2
- package/package.json +11 -5
package/dist/cli.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// src/entry/cli.ts
|
|
2
8
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
3
9
|
import { pathToFileURL } from "node:url";
|
|
@@ -3385,10 +3391,7 @@ function splitArgv(argv) {
|
|
|
3385
3391
|
|
|
3386
3392
|
// src/shared/product-identity.ts
|
|
3387
3393
|
var PRODUCT_BINARY = "pifleet";
|
|
3388
|
-
var PRODUCT_VERSION = "0.1.0-beta.
|
|
3389
|
-
|
|
3390
|
-
// src/cli/commands/create.ts
|
|
3391
|
-
import { resolve } from "node:path";
|
|
3394
|
+
var PRODUCT_VERSION = "0.1.0-beta.10";
|
|
3392
3395
|
|
|
3393
3396
|
// src/shared/identifiers.ts
|
|
3394
3397
|
var AGENT_NAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
@@ -3396,31 +3399,16 @@ function isAgentName(value) {
|
|
|
3396
3399
|
return AGENT_NAME_PATTERN.test(value);
|
|
3397
3400
|
}
|
|
3398
3401
|
|
|
3399
|
-
// src/cli/input.ts
|
|
3400
|
-
var DEFAULT_MAX_INPUT_BYTES = 1024 * 1024;
|
|
3401
|
-
async function resolveMessageInput(value, stdin, maxBytes = DEFAULT_MAX_INPUT_BYTES) {
|
|
3402
|
-
if (value !== "-") return requireContent(value);
|
|
3403
|
-
const chunks = [];
|
|
3404
|
-
let bytes = 0;
|
|
3405
|
-
for await (const chunk of stdin) {
|
|
3406
|
-
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
|
|
3407
|
-
bytes += buffer.length;
|
|
3408
|
-
if (bytes > maxBytes) throw new Error(`stdin exceeds the ${maxBytes}-byte limit`);
|
|
3409
|
-
chunks.push(buffer);
|
|
3410
|
-
}
|
|
3411
|
-
return requireContent(Buffer.concat(chunks).toString("utf8"));
|
|
3412
|
-
}
|
|
3413
|
-
function requireContent(value) {
|
|
3414
|
-
if (value.trim().length === 0) throw new Error("message must not be empty or whitespace-only");
|
|
3415
|
-
return value;
|
|
3416
|
-
}
|
|
3417
|
-
|
|
3418
3402
|
// src/cli/output.ts
|
|
3419
3403
|
function writeResult(stream, result, human) {
|
|
3420
3404
|
stream.write(human ? `${renderHuman(result)}
|
|
3421
3405
|
` : `${JSON.stringify(result)}
|
|
3422
3406
|
`);
|
|
3423
3407
|
}
|
|
3408
|
+
function writeWatchReady(stream, name) {
|
|
3409
|
+
stream.write(`${JSON.stringify({ schemaVersion: 1, type: "watch.ready", agent: { name } })}
|
|
3410
|
+
`);
|
|
3411
|
+
}
|
|
3424
3412
|
function writeError(stream, error, human) {
|
|
3425
3413
|
if (human) {
|
|
3426
3414
|
stream.write(`${error.message}
|
|
@@ -3444,6 +3432,8 @@ function renderHuman(result) {
|
|
|
3444
3432
|
return result.agents.length === 0 ? "No agents" : result.agents.map((agent) => `${agent.name} ${agent.state} ${agent.process.state}`).join("\n");
|
|
3445
3433
|
case "agent.destroyed":
|
|
3446
3434
|
return `${result.agent.name}: destroyed`;
|
|
3435
|
+
case "agent.compacted":
|
|
3436
|
+
return `${result.agent.name}: compacted (${String(result.compaction.tokensBefore)} \u2192 ${String(result.compaction.estimatedTokensAfter ?? "unknown")} estimated tokens)`;
|
|
3447
3437
|
}
|
|
3448
3438
|
}
|
|
3449
3439
|
|
|
@@ -3457,6 +3447,44 @@ function finishFinite(result, context, human) {
|
|
|
3457
3447
|
return result.error.code === "timeout" ? 124 : 1;
|
|
3458
3448
|
}
|
|
3459
3449
|
|
|
3450
|
+
// src/cli/commands/compact.ts
|
|
3451
|
+
async function runCompact(input, context) {
|
|
3452
|
+
if (!isAgentName(input.name)) throw new Error("invalid agent name");
|
|
3453
|
+
const result = await context.client.compact(
|
|
3454
|
+
{ name: input.name },
|
|
3455
|
+
{ signal: context.signal, operation: context.operationIds() }
|
|
3456
|
+
);
|
|
3457
|
+
return finishFinite(result, context, input.human);
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
// src/cli/commands/create.ts
|
|
3461
|
+
import { resolve } from "node:path";
|
|
3462
|
+
|
|
3463
|
+
// src/cli/input.ts
|
|
3464
|
+
var DEFAULT_MAX_INPUT_BYTES = 512 * 1024;
|
|
3465
|
+
async function resolveMessageInput(value, stdin, maxBytes = DEFAULT_MAX_INPUT_BYTES) {
|
|
3466
|
+
if (value !== "-") return requireContent(value);
|
|
3467
|
+
const chunks = [];
|
|
3468
|
+
let bytes = 0;
|
|
3469
|
+
for await (const chunk of stdin) {
|
|
3470
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
|
|
3471
|
+
bytes += buffer.length;
|
|
3472
|
+
if (bytes > maxBytes) throw new Error(`stdin exceeds the ${maxBytes}-byte limit`);
|
|
3473
|
+
chunks.push(buffer);
|
|
3474
|
+
}
|
|
3475
|
+
let decoded;
|
|
3476
|
+
try {
|
|
3477
|
+
decoded = new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks));
|
|
3478
|
+
} catch {
|
|
3479
|
+
throw new Error("stdin must be valid UTF-8");
|
|
3480
|
+
}
|
|
3481
|
+
return requireContent(decoded);
|
|
3482
|
+
}
|
|
3483
|
+
function requireContent(value) {
|
|
3484
|
+
if (value.trim().length === 0) throw new Error("message must not be empty or whitespace-only");
|
|
3485
|
+
return value;
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3460
3488
|
// src/cli/commands/create.ts
|
|
3461
3489
|
async function runCreate(input, context) {
|
|
3462
3490
|
if (!isAgentName(input.name)) throw new Error("invalid agent name");
|
|
@@ -3549,23 +3577,32 @@ async function runStatus(input, context) {
|
|
|
3549
3577
|
import { once } from "node:events";
|
|
3550
3578
|
async function runWatch(name, context) {
|
|
3551
3579
|
if (!isAgentName(name)) throw new Error("invalid agent name");
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3580
|
+
try {
|
|
3581
|
+
for await (const result of context.client.watch({ name }, { signal: context.signal })) {
|
|
3582
|
+
if (!result.ok) {
|
|
3583
|
+
writeError(context.stderr, result.error, false);
|
|
3584
|
+
return 1;
|
|
3585
|
+
}
|
|
3586
|
+
if (result.value.type === "ready") {
|
|
3587
|
+
writeWatchReady(context.stderr, name);
|
|
3588
|
+
continue;
|
|
3589
|
+
}
|
|
3590
|
+
if (!context.stdout.write(result.value.bytes)) await once(context.stdout, "drain");
|
|
3556
3591
|
}
|
|
3557
|
-
|
|
3592
|
+
return 0;
|
|
3593
|
+
} catch (error) {
|
|
3594
|
+
if (error.code === "EPIPE") return 0;
|
|
3595
|
+
throw error;
|
|
3558
3596
|
}
|
|
3559
|
-
return 0;
|
|
3560
3597
|
}
|
|
3561
3598
|
|
|
3562
3599
|
// src/cli/program.ts
|
|
3563
3600
|
function createProgram(context, setExitCode) {
|
|
3564
|
-
const program2 = new Command().name(PRODUCT_BINARY).description("
|
|
3601
|
+
const program2 = new Command().name(PRODUCT_BINARY).description("Pi-native execution infrastructure for programmatic orchestration").version(PRODUCT_VERSION).exitOverride().showHelpAfterError(false).showSuggestionAfterError(false).configureOutput({
|
|
3565
3602
|
writeOut: (text) => context.stdout.write(text),
|
|
3566
3603
|
writeErr: () => void 0
|
|
3567
3604
|
});
|
|
3568
|
-
program2.command("create").description("Create a
|
|
3605
|
+
program2.command("create").description("Create a Pi agent with a stable local name").argument("<name>").argument("[instructions]").option("--cwd <path>").option("--human").action(async (name, instructions, options) => {
|
|
3569
3606
|
setExitCode(
|
|
3570
3607
|
await runCreate(
|
|
3571
3608
|
{
|
|
@@ -3578,10 +3615,10 @@ function createProgram(context, setExitCode) {
|
|
|
3578
3615
|
)
|
|
3579
3616
|
);
|
|
3580
3617
|
});
|
|
3581
|
-
program2.command("send").description("
|
|
3618
|
+
program2.command("send").description("Submit or steer Pi input").argument("<name>").argument("<message>").option("--human").action(async (name, message, options) => {
|
|
3582
3619
|
setExitCode(await runSend({ name, message, human: options.human ?? false }, context));
|
|
3583
3620
|
});
|
|
3584
|
-
program2.command("receive").description("Wait for idle and return the latest assistant
|
|
3621
|
+
program2.command("receive").description("Wait for idle and return the exact latest assistant text").argument("<name>").option("--timeout <duration>").option("--human").action(async (name, options) => {
|
|
3585
3622
|
setExitCode(
|
|
3586
3623
|
await runReceive(
|
|
3587
3624
|
{
|
|
@@ -3593,16 +3630,19 @@ function createProgram(context, setExitCode) {
|
|
|
3593
3630
|
)
|
|
3594
3631
|
);
|
|
3595
3632
|
});
|
|
3596
|
-
program2.command("status").description("Inspect
|
|
3633
|
+
program2.command("status").description("Inspect an agent without waking Pi").argument("<name>").option("--human").action(async (name, options) => {
|
|
3597
3634
|
setExitCode(await runStatus({ name, human: options.human ?? false }, context));
|
|
3598
3635
|
});
|
|
3599
|
-
program2.command("list").description("List
|
|
3636
|
+
program2.command("list").description("List agents without waking Pi").option("--human").action(async (options) => {
|
|
3600
3637
|
setExitCode(await runList({ human: options.human ?? false }, context));
|
|
3601
3638
|
});
|
|
3602
|
-
program2.command("watch").description("
|
|
3639
|
+
program2.command("watch").description("Stream live raw Pi RPC JSONL").argument("<name>").action(async (name) => {
|
|
3603
3640
|
setExitCode(await runWatch(name, context));
|
|
3604
3641
|
});
|
|
3605
|
-
program2.command("
|
|
3642
|
+
program2.command("compact").description("Compact an idle Pi agent session").argument("<name>").option("--human").action(async (name, options) => {
|
|
3643
|
+
setExitCode(await runCompact({ name, human: options.human ?? false }, context));
|
|
3644
|
+
});
|
|
3645
|
+
program2.command("destroy").description("Destroy an agent without deleting its Pi session").argument("<name>").option("--human").action(async (name, options) => {
|
|
3606
3646
|
setExitCode(await runDestroy({ name, human: options.human ?? false }, context));
|
|
3607
3647
|
});
|
|
3608
3648
|
return program2;
|
|
@@ -3613,7 +3653,7 @@ import { randomUUID } from "node:crypto";
|
|
|
3613
3653
|
import { createConnection } from "node:net";
|
|
3614
3654
|
|
|
3615
3655
|
// src/protocol/version.ts
|
|
3616
|
-
var PROTOCOL_VERSION =
|
|
3656
|
+
var PROTOCOL_VERSION = 2;
|
|
3617
3657
|
var MAX_PROTOCOL_FRAME_BYTES = 1024 * 1024;
|
|
3618
3658
|
|
|
3619
3659
|
// src/protocol/jsonl.ts
|
|
@@ -3652,162 +3692,2843 @@ function writeJsonLine(socket, value) {
|
|
|
3652
3692
|
`);
|
|
3653
3693
|
}
|
|
3654
3694
|
|
|
3655
|
-
//
|
|
3656
|
-
var
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3695
|
+
// node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
|
|
3696
|
+
var value_exports = {};
|
|
3697
|
+
__export(value_exports, {
|
|
3698
|
+
HasPropertyKey: () => HasPropertyKey,
|
|
3699
|
+
IsArray: () => IsArray,
|
|
3700
|
+
IsAsyncIterator: () => IsAsyncIterator,
|
|
3701
|
+
IsBigInt: () => IsBigInt,
|
|
3702
|
+
IsBoolean: () => IsBoolean,
|
|
3703
|
+
IsDate: () => IsDate,
|
|
3704
|
+
IsFunction: () => IsFunction,
|
|
3705
|
+
IsIterator: () => IsIterator,
|
|
3706
|
+
IsNull: () => IsNull,
|
|
3707
|
+
IsNumber: () => IsNumber,
|
|
3708
|
+
IsObject: () => IsObject,
|
|
3709
|
+
IsRegExp: () => IsRegExp,
|
|
3710
|
+
IsString: () => IsString,
|
|
3711
|
+
IsSymbol: () => IsSymbol,
|
|
3712
|
+
IsUint8Array: () => IsUint8Array,
|
|
3713
|
+
IsUndefined: () => IsUndefined
|
|
3714
|
+
});
|
|
3715
|
+
function HasPropertyKey(value, key) {
|
|
3716
|
+
return key in value;
|
|
3717
|
+
}
|
|
3718
|
+
function IsAsyncIterator(value) {
|
|
3719
|
+
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
|
|
3720
|
+
}
|
|
3721
|
+
function IsArray(value) {
|
|
3722
|
+
return Array.isArray(value);
|
|
3723
|
+
}
|
|
3724
|
+
function IsBigInt(value) {
|
|
3725
|
+
return typeof value === "bigint";
|
|
3726
|
+
}
|
|
3727
|
+
function IsBoolean(value) {
|
|
3728
|
+
return typeof value === "boolean";
|
|
3729
|
+
}
|
|
3730
|
+
function IsDate(value) {
|
|
3731
|
+
return value instanceof globalThis.Date;
|
|
3732
|
+
}
|
|
3733
|
+
function IsFunction(value) {
|
|
3734
|
+
return typeof value === "function";
|
|
3735
|
+
}
|
|
3736
|
+
function IsIterator(value) {
|
|
3737
|
+
return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
|
|
3738
|
+
}
|
|
3739
|
+
function IsNull(value) {
|
|
3740
|
+
return value === null;
|
|
3741
|
+
}
|
|
3742
|
+
function IsNumber(value) {
|
|
3743
|
+
return typeof value === "number";
|
|
3744
|
+
}
|
|
3745
|
+
function IsObject(value) {
|
|
3746
|
+
return typeof value === "object" && value !== null;
|
|
3747
|
+
}
|
|
3748
|
+
function IsRegExp(value) {
|
|
3749
|
+
return value instanceof globalThis.RegExp;
|
|
3750
|
+
}
|
|
3751
|
+
function IsString(value) {
|
|
3752
|
+
return typeof value === "string";
|
|
3753
|
+
}
|
|
3754
|
+
function IsSymbol(value) {
|
|
3755
|
+
return typeof value === "symbol";
|
|
3756
|
+
}
|
|
3757
|
+
function IsUint8Array(value) {
|
|
3758
|
+
return value instanceof globalThis.Uint8Array;
|
|
3759
|
+
}
|
|
3760
|
+
function IsUndefined(value) {
|
|
3761
|
+
return value === void 0;
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
// node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
|
|
3765
|
+
function ArrayType(value) {
|
|
3766
|
+
return value.map((value2) => Visit(value2));
|
|
3767
|
+
}
|
|
3768
|
+
function DateType(value) {
|
|
3769
|
+
return new Date(value.getTime());
|
|
3770
|
+
}
|
|
3771
|
+
function Uint8ArrayType(value) {
|
|
3772
|
+
return new Uint8Array(value);
|
|
3773
|
+
}
|
|
3774
|
+
function RegExpType(value) {
|
|
3775
|
+
return new RegExp(value.source, value.flags);
|
|
3776
|
+
}
|
|
3777
|
+
function ObjectType(value) {
|
|
3778
|
+
const result = {};
|
|
3779
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
3780
|
+
result[key] = Visit(value[key]);
|
|
3668
3781
|
}
|
|
3669
|
-
|
|
3670
|
-
|
|
3782
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
3783
|
+
result[key] = Visit(value[key]);
|
|
3671
3784
|
}
|
|
3672
|
-
|
|
3673
|
-
|
|
3785
|
+
return result;
|
|
3786
|
+
}
|
|
3787
|
+
function Visit(value) {
|
|
3788
|
+
return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
|
|
3789
|
+
}
|
|
3790
|
+
function Clone(value) {
|
|
3791
|
+
return Visit(value);
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
// node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
|
|
3795
|
+
function CloneType(schema, options) {
|
|
3796
|
+
return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
// node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
|
|
3800
|
+
function IsObject2(value) {
|
|
3801
|
+
return value !== null && typeof value === "object";
|
|
3802
|
+
}
|
|
3803
|
+
function IsArray2(value) {
|
|
3804
|
+
return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
|
|
3805
|
+
}
|
|
3806
|
+
function IsUndefined2(value) {
|
|
3807
|
+
return value === void 0;
|
|
3808
|
+
}
|
|
3809
|
+
function IsNumber2(value) {
|
|
3810
|
+
return typeof value === "number";
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
// node_modules/@sinclair/typebox/build/esm/system/policy.mjs
|
|
3814
|
+
var TypeSystemPolicy;
|
|
3815
|
+
(function(TypeSystemPolicy2) {
|
|
3816
|
+
TypeSystemPolicy2.InstanceMode = "default";
|
|
3817
|
+
TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
|
|
3818
|
+
TypeSystemPolicy2.AllowArrayObject = false;
|
|
3819
|
+
TypeSystemPolicy2.AllowNaN = false;
|
|
3820
|
+
TypeSystemPolicy2.AllowNullVoid = false;
|
|
3821
|
+
function IsExactOptionalProperty(value, key) {
|
|
3822
|
+
return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
|
|
3823
|
+
}
|
|
3824
|
+
TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
|
|
3825
|
+
function IsObjectLike(value) {
|
|
3826
|
+
const isObject = IsObject2(value);
|
|
3827
|
+
return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
|
|
3828
|
+
}
|
|
3829
|
+
TypeSystemPolicy2.IsObjectLike = IsObjectLike;
|
|
3830
|
+
function IsRecordLike(value) {
|
|
3831
|
+
return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
|
|
3832
|
+
}
|
|
3833
|
+
TypeSystemPolicy2.IsRecordLike = IsRecordLike;
|
|
3834
|
+
function IsNumberLike(value) {
|
|
3835
|
+
return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
|
|
3836
|
+
}
|
|
3837
|
+
TypeSystemPolicy2.IsNumberLike = IsNumberLike;
|
|
3838
|
+
function IsVoidLike(value) {
|
|
3839
|
+
const isUndefined = IsUndefined2(value);
|
|
3840
|
+
return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
|
|
3841
|
+
}
|
|
3842
|
+
TypeSystemPolicy2.IsVoidLike = IsVoidLike;
|
|
3843
|
+
})(TypeSystemPolicy || (TypeSystemPolicy = {}));
|
|
3844
|
+
|
|
3845
|
+
// node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
|
|
3846
|
+
function ImmutableArray(value) {
|
|
3847
|
+
return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
|
|
3848
|
+
}
|
|
3849
|
+
function ImmutableDate(value) {
|
|
3850
|
+
return value;
|
|
3851
|
+
}
|
|
3852
|
+
function ImmutableUint8Array(value) {
|
|
3853
|
+
return value;
|
|
3854
|
+
}
|
|
3855
|
+
function ImmutableRegExp(value) {
|
|
3856
|
+
return value;
|
|
3857
|
+
}
|
|
3858
|
+
function ImmutableObject(value) {
|
|
3859
|
+
const result = {};
|
|
3860
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
3861
|
+
result[key] = Immutable(value[key]);
|
|
3674
3862
|
}
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
try {
|
|
3678
|
-
await this.options.beforeConnect?.();
|
|
3679
|
-
socket = await connect(this.options.socketPath, options.signal);
|
|
3680
|
-
} catch (error) {
|
|
3681
|
-
yield err(connectionError(error));
|
|
3682
|
-
return;
|
|
3683
|
-
}
|
|
3684
|
-
const requestId = randomUUID();
|
|
3685
|
-
const frames = frameIterator(socket, options.signal);
|
|
3686
|
-
writeJsonLine(socket, {
|
|
3687
|
-
v: PROTOCOL_VERSION,
|
|
3688
|
-
requestId,
|
|
3689
|
-
method: "agent.watch",
|
|
3690
|
-
params: input
|
|
3691
|
-
});
|
|
3692
|
-
let endedExplicitly = false;
|
|
3693
|
-
try {
|
|
3694
|
-
for await (const frame of frames) {
|
|
3695
|
-
if (!isRecord(frame) || frame.requestId !== requestId) continue;
|
|
3696
|
-
if (frame.stream === "ready") continue;
|
|
3697
|
-
if (frame.stream === "end") {
|
|
3698
|
-
endedExplicitly = true;
|
|
3699
|
-
return;
|
|
3700
|
-
}
|
|
3701
|
-
if (frame.stream === "chunk" && typeof frame.data === "string") {
|
|
3702
|
-
yield ok({ bytes: Buffer.from(frame.data, "base64") });
|
|
3703
|
-
continue;
|
|
3704
|
-
}
|
|
3705
|
-
if (frame.stream === "error" && isErrorRecord(frame.error)) {
|
|
3706
|
-
yield err(frame.error);
|
|
3707
|
-
return;
|
|
3708
|
-
}
|
|
3709
|
-
yield err({ code: "protocol_error", message: "Invalid watch stream frame." });
|
|
3710
|
-
return;
|
|
3711
|
-
}
|
|
3712
|
-
if (!endedExplicitly && !options.signal.aborted) {
|
|
3713
|
-
yield err({
|
|
3714
|
-
code: "runtime_unavailable",
|
|
3715
|
-
message: "Runtime connection closed before the watch stream ended."
|
|
3716
|
-
});
|
|
3717
|
-
}
|
|
3718
|
-
} catch (error) {
|
|
3719
|
-
if (!options.signal.aborted) yield err(connectionError(error));
|
|
3720
|
-
} finally {
|
|
3721
|
-
socket.destroy();
|
|
3722
|
-
}
|
|
3863
|
+
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
3864
|
+
result[key] = Immutable(value[key]);
|
|
3723
3865
|
}
|
|
3724
|
-
|
|
3725
|
-
|
|
3866
|
+
return globalThis.Object.freeze(result);
|
|
3867
|
+
}
|
|
3868
|
+
function Immutable(value) {
|
|
3869
|
+
return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
|
|
3870
|
+
}
|
|
3871
|
+
|
|
3872
|
+
// node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
|
|
3873
|
+
function CreateType(schema, options) {
|
|
3874
|
+
const result = options !== void 0 ? { ...options, ...schema } : schema;
|
|
3875
|
+
switch (TypeSystemPolicy.InstanceMode) {
|
|
3876
|
+
case "freeze":
|
|
3877
|
+
return Immutable(result);
|
|
3878
|
+
case "clone":
|
|
3879
|
+
return Clone(result);
|
|
3880
|
+
default:
|
|
3881
|
+
return result;
|
|
3726
3882
|
}
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
return err(connectionError(error));
|
|
3734
|
-
}
|
|
3735
|
-
const requestId = randomUUID();
|
|
3736
|
-
const response = firstMatchingFrame(socket, requestId, options.signal);
|
|
3737
|
-
writeJsonLine(socket, {
|
|
3738
|
-
v: PROTOCOL_VERSION,
|
|
3739
|
-
requestId,
|
|
3740
|
-
method,
|
|
3741
|
-
params,
|
|
3742
|
-
...isMutationOptions(options) ? { operation: options.operation } : {}
|
|
3743
|
-
});
|
|
3744
|
-
try {
|
|
3745
|
-
const frame = await response;
|
|
3746
|
-
if (!isRecord(frame) || frame.requestId !== requestId || typeof frame.ok !== "boolean") {
|
|
3747
|
-
return err({ code: "protocol_error", message: "Invalid runtime response." });
|
|
3748
|
-
}
|
|
3749
|
-
if (frame.ok) return ok(frame.result);
|
|
3750
|
-
if (isErrorRecord(frame.error)) return err(frame.error);
|
|
3751
|
-
return err({ code: "protocol_error", message: "Runtime returned an invalid error." });
|
|
3752
|
-
} catch (error) {
|
|
3753
|
-
return err(connectionError(error));
|
|
3754
|
-
} finally {
|
|
3755
|
-
socket.destroy();
|
|
3756
|
-
}
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
// node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
|
|
3886
|
+
var TypeBoxError = class extends Error {
|
|
3887
|
+
constructor(message) {
|
|
3888
|
+
super(message);
|
|
3757
3889
|
}
|
|
3758
3890
|
};
|
|
3759
|
-
|
|
3760
|
-
|
|
3891
|
+
|
|
3892
|
+
// node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
|
|
3893
|
+
var TransformKind = Symbol.for("TypeBox.Transform");
|
|
3894
|
+
var ReadonlyKind = Symbol.for("TypeBox.Readonly");
|
|
3895
|
+
var OptionalKind = Symbol.for("TypeBox.Optional");
|
|
3896
|
+
var Hint = Symbol.for("TypeBox.Hint");
|
|
3897
|
+
var Kind = Symbol.for("TypeBox.Kind");
|
|
3898
|
+
|
|
3899
|
+
// node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
|
|
3900
|
+
function IsReadonly(value) {
|
|
3901
|
+
return IsObject(value) && value[ReadonlyKind] === "Readonly";
|
|
3761
3902
|
}
|
|
3762
|
-
function
|
|
3763
|
-
return
|
|
3764
|
-
if (signal.aborted) {
|
|
3765
|
-
rejectConnect(new Error("Request cancelled"));
|
|
3766
|
-
return;
|
|
3767
|
-
}
|
|
3768
|
-
const socket = createConnection(socketPath);
|
|
3769
|
-
const onAbort = () => socket.destroy(new Error("Request cancelled"));
|
|
3770
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
3771
|
-
socket.once("connect", () => {
|
|
3772
|
-
signal.removeEventListener("abort", onAbort);
|
|
3773
|
-
resolveConnect(socket);
|
|
3774
|
-
});
|
|
3775
|
-
socket.once("error", rejectConnect);
|
|
3776
|
-
});
|
|
3903
|
+
function IsOptional(value) {
|
|
3904
|
+
return IsObject(value) && value[OptionalKind] === "Optional";
|
|
3777
3905
|
}
|
|
3778
|
-
function
|
|
3779
|
-
return
|
|
3780
|
-
let settled = false;
|
|
3781
|
-
const finish = (action) => {
|
|
3782
|
-
if (settled) return;
|
|
3783
|
-
settled = true;
|
|
3784
|
-
stop();
|
|
3785
|
-
signal.removeEventListener("abort", onAbort);
|
|
3786
|
-
action();
|
|
3787
|
-
};
|
|
3788
|
-
const stop = readJsonLines(
|
|
3789
|
-
socket,
|
|
3790
|
-
(frame) => {
|
|
3791
|
-
if (!isRecord(frame) || frame.requestId !== requestId) return;
|
|
3792
|
-
finish(() => resolveFrame(frame));
|
|
3793
|
-
},
|
|
3794
|
-
(error) => finish(() => rejectFrame(error))
|
|
3795
|
-
);
|
|
3796
|
-
const onAbort = () => finish(() => rejectFrame(new Error("Request cancelled")));
|
|
3797
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
3798
|
-
socket.once(
|
|
3799
|
-
"close",
|
|
3800
|
-
() => finish(() => rejectFrame(new Error("Runtime connection closed before responding")))
|
|
3801
|
-
);
|
|
3802
|
-
});
|
|
3906
|
+
function IsAny(value) {
|
|
3907
|
+
return IsKindOf(value, "Any");
|
|
3803
3908
|
}
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3909
|
+
function IsArgument(value) {
|
|
3910
|
+
return IsKindOf(value, "Argument");
|
|
3911
|
+
}
|
|
3912
|
+
function IsArray3(value) {
|
|
3913
|
+
return IsKindOf(value, "Array");
|
|
3914
|
+
}
|
|
3915
|
+
function IsAsyncIterator2(value) {
|
|
3916
|
+
return IsKindOf(value, "AsyncIterator");
|
|
3917
|
+
}
|
|
3918
|
+
function IsBigInt2(value) {
|
|
3919
|
+
return IsKindOf(value, "BigInt");
|
|
3920
|
+
}
|
|
3921
|
+
function IsBoolean2(value) {
|
|
3922
|
+
return IsKindOf(value, "Boolean");
|
|
3923
|
+
}
|
|
3924
|
+
function IsComputed(value) {
|
|
3925
|
+
return IsKindOf(value, "Computed");
|
|
3926
|
+
}
|
|
3927
|
+
function IsConstructor(value) {
|
|
3928
|
+
return IsKindOf(value, "Constructor");
|
|
3929
|
+
}
|
|
3930
|
+
function IsDate2(value) {
|
|
3931
|
+
return IsKindOf(value, "Date");
|
|
3932
|
+
}
|
|
3933
|
+
function IsFunction2(value) {
|
|
3934
|
+
return IsKindOf(value, "Function");
|
|
3935
|
+
}
|
|
3936
|
+
function IsInteger(value) {
|
|
3937
|
+
return IsKindOf(value, "Integer");
|
|
3938
|
+
}
|
|
3939
|
+
function IsIntersect(value) {
|
|
3940
|
+
return IsKindOf(value, "Intersect");
|
|
3941
|
+
}
|
|
3942
|
+
function IsIterator2(value) {
|
|
3943
|
+
return IsKindOf(value, "Iterator");
|
|
3944
|
+
}
|
|
3945
|
+
function IsKindOf(value, kind) {
|
|
3946
|
+
return IsObject(value) && Kind in value && value[Kind] === kind;
|
|
3947
|
+
}
|
|
3948
|
+
function IsLiteralValue(value) {
|
|
3949
|
+
return IsBoolean(value) || IsNumber(value) || IsString(value);
|
|
3950
|
+
}
|
|
3951
|
+
function IsLiteral(value) {
|
|
3952
|
+
return IsKindOf(value, "Literal");
|
|
3953
|
+
}
|
|
3954
|
+
function IsMappedKey(value) {
|
|
3955
|
+
return IsKindOf(value, "MappedKey");
|
|
3956
|
+
}
|
|
3957
|
+
function IsMappedResult(value) {
|
|
3958
|
+
return IsKindOf(value, "MappedResult");
|
|
3959
|
+
}
|
|
3960
|
+
function IsNever(value) {
|
|
3961
|
+
return IsKindOf(value, "Never");
|
|
3962
|
+
}
|
|
3963
|
+
function IsNot(value) {
|
|
3964
|
+
return IsKindOf(value, "Not");
|
|
3965
|
+
}
|
|
3966
|
+
function IsNull2(value) {
|
|
3967
|
+
return IsKindOf(value, "Null");
|
|
3968
|
+
}
|
|
3969
|
+
function IsNumber3(value) {
|
|
3970
|
+
return IsKindOf(value, "Number");
|
|
3971
|
+
}
|
|
3972
|
+
function IsObject3(value) {
|
|
3973
|
+
return IsKindOf(value, "Object");
|
|
3974
|
+
}
|
|
3975
|
+
function IsPromise(value) {
|
|
3976
|
+
return IsKindOf(value, "Promise");
|
|
3977
|
+
}
|
|
3978
|
+
function IsRecord(value) {
|
|
3979
|
+
return IsKindOf(value, "Record");
|
|
3980
|
+
}
|
|
3981
|
+
function IsRef(value) {
|
|
3982
|
+
return IsKindOf(value, "Ref");
|
|
3983
|
+
}
|
|
3984
|
+
function IsRegExp2(value) {
|
|
3985
|
+
return IsKindOf(value, "RegExp");
|
|
3986
|
+
}
|
|
3987
|
+
function IsString2(value) {
|
|
3988
|
+
return IsKindOf(value, "String");
|
|
3989
|
+
}
|
|
3990
|
+
function IsSymbol2(value) {
|
|
3991
|
+
return IsKindOf(value, "Symbol");
|
|
3992
|
+
}
|
|
3993
|
+
function IsTemplateLiteral(value) {
|
|
3994
|
+
return IsKindOf(value, "TemplateLiteral");
|
|
3995
|
+
}
|
|
3996
|
+
function IsThis(value) {
|
|
3997
|
+
return IsKindOf(value, "This");
|
|
3998
|
+
}
|
|
3999
|
+
function IsTransform(value) {
|
|
4000
|
+
return IsObject(value) && TransformKind in value;
|
|
4001
|
+
}
|
|
4002
|
+
function IsTuple(value) {
|
|
4003
|
+
return IsKindOf(value, "Tuple");
|
|
4004
|
+
}
|
|
4005
|
+
function IsUndefined3(value) {
|
|
4006
|
+
return IsKindOf(value, "Undefined");
|
|
4007
|
+
}
|
|
4008
|
+
function IsUnion(value) {
|
|
4009
|
+
return IsKindOf(value, "Union");
|
|
4010
|
+
}
|
|
4011
|
+
function IsUint8Array2(value) {
|
|
4012
|
+
return IsKindOf(value, "Uint8Array");
|
|
4013
|
+
}
|
|
4014
|
+
function IsUnknown(value) {
|
|
4015
|
+
return IsKindOf(value, "Unknown");
|
|
4016
|
+
}
|
|
4017
|
+
function IsUnsafe(value) {
|
|
4018
|
+
return IsKindOf(value, "Unsafe");
|
|
4019
|
+
}
|
|
4020
|
+
function IsVoid(value) {
|
|
4021
|
+
return IsKindOf(value, "Void");
|
|
4022
|
+
}
|
|
4023
|
+
function IsKind(value) {
|
|
4024
|
+
return IsObject(value) && Kind in value && IsString(value[Kind]);
|
|
4025
|
+
}
|
|
4026
|
+
function IsSchema(value) {
|
|
4027
|
+
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);
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
// node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
|
|
4031
|
+
var type_exports = {};
|
|
4032
|
+
__export(type_exports, {
|
|
4033
|
+
IsAny: () => IsAny2,
|
|
4034
|
+
IsArgument: () => IsArgument2,
|
|
4035
|
+
IsArray: () => IsArray4,
|
|
4036
|
+
IsAsyncIterator: () => IsAsyncIterator3,
|
|
4037
|
+
IsBigInt: () => IsBigInt3,
|
|
4038
|
+
IsBoolean: () => IsBoolean3,
|
|
4039
|
+
IsComputed: () => IsComputed2,
|
|
4040
|
+
IsConstructor: () => IsConstructor2,
|
|
4041
|
+
IsDate: () => IsDate3,
|
|
4042
|
+
IsFunction: () => IsFunction3,
|
|
4043
|
+
IsImport: () => IsImport,
|
|
4044
|
+
IsInteger: () => IsInteger2,
|
|
4045
|
+
IsIntersect: () => IsIntersect2,
|
|
4046
|
+
IsIterator: () => IsIterator3,
|
|
4047
|
+
IsKind: () => IsKind2,
|
|
4048
|
+
IsKindOf: () => IsKindOf2,
|
|
4049
|
+
IsLiteral: () => IsLiteral2,
|
|
4050
|
+
IsLiteralBoolean: () => IsLiteralBoolean,
|
|
4051
|
+
IsLiteralNumber: () => IsLiteralNumber,
|
|
4052
|
+
IsLiteralString: () => IsLiteralString,
|
|
4053
|
+
IsLiteralValue: () => IsLiteralValue2,
|
|
4054
|
+
IsMappedKey: () => IsMappedKey2,
|
|
4055
|
+
IsMappedResult: () => IsMappedResult2,
|
|
4056
|
+
IsNever: () => IsNever2,
|
|
4057
|
+
IsNot: () => IsNot2,
|
|
4058
|
+
IsNull: () => IsNull3,
|
|
4059
|
+
IsNumber: () => IsNumber4,
|
|
4060
|
+
IsObject: () => IsObject4,
|
|
4061
|
+
IsOptional: () => IsOptional2,
|
|
4062
|
+
IsPromise: () => IsPromise2,
|
|
4063
|
+
IsProperties: () => IsProperties,
|
|
4064
|
+
IsReadonly: () => IsReadonly2,
|
|
4065
|
+
IsRecord: () => IsRecord2,
|
|
4066
|
+
IsRecursive: () => IsRecursive,
|
|
4067
|
+
IsRef: () => IsRef2,
|
|
4068
|
+
IsRegExp: () => IsRegExp3,
|
|
4069
|
+
IsSchema: () => IsSchema2,
|
|
4070
|
+
IsString: () => IsString3,
|
|
4071
|
+
IsSymbol: () => IsSymbol3,
|
|
4072
|
+
IsTemplateLiteral: () => IsTemplateLiteral2,
|
|
4073
|
+
IsThis: () => IsThis2,
|
|
4074
|
+
IsTransform: () => IsTransform2,
|
|
4075
|
+
IsTuple: () => IsTuple2,
|
|
4076
|
+
IsUint8Array: () => IsUint8Array3,
|
|
4077
|
+
IsUndefined: () => IsUndefined4,
|
|
4078
|
+
IsUnion: () => IsUnion2,
|
|
4079
|
+
IsUnionLiteral: () => IsUnionLiteral,
|
|
4080
|
+
IsUnknown: () => IsUnknown2,
|
|
4081
|
+
IsUnsafe: () => IsUnsafe2,
|
|
4082
|
+
IsVoid: () => IsVoid2,
|
|
4083
|
+
TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
|
|
4084
|
+
});
|
|
4085
|
+
var TypeGuardUnknownTypeError = class extends TypeBoxError {
|
|
4086
|
+
};
|
|
4087
|
+
var KnownTypes = [
|
|
4088
|
+
"Argument",
|
|
4089
|
+
"Any",
|
|
4090
|
+
"Array",
|
|
4091
|
+
"AsyncIterator",
|
|
4092
|
+
"BigInt",
|
|
4093
|
+
"Boolean",
|
|
4094
|
+
"Computed",
|
|
4095
|
+
"Constructor",
|
|
4096
|
+
"Date",
|
|
4097
|
+
"Enum",
|
|
4098
|
+
"Function",
|
|
4099
|
+
"Integer",
|
|
4100
|
+
"Intersect",
|
|
4101
|
+
"Iterator",
|
|
4102
|
+
"Literal",
|
|
4103
|
+
"MappedKey",
|
|
4104
|
+
"MappedResult",
|
|
4105
|
+
"Not",
|
|
4106
|
+
"Null",
|
|
4107
|
+
"Number",
|
|
4108
|
+
"Object",
|
|
4109
|
+
"Promise",
|
|
4110
|
+
"Record",
|
|
4111
|
+
"Ref",
|
|
4112
|
+
"RegExp",
|
|
4113
|
+
"String",
|
|
4114
|
+
"Symbol",
|
|
4115
|
+
"TemplateLiteral",
|
|
4116
|
+
"This",
|
|
4117
|
+
"Tuple",
|
|
4118
|
+
"Undefined",
|
|
4119
|
+
"Union",
|
|
4120
|
+
"Uint8Array",
|
|
4121
|
+
"Unknown",
|
|
4122
|
+
"Void"
|
|
4123
|
+
];
|
|
4124
|
+
function IsPattern(value) {
|
|
4125
|
+
try {
|
|
4126
|
+
new RegExp(value);
|
|
4127
|
+
return true;
|
|
4128
|
+
} catch {
|
|
4129
|
+
return false;
|
|
4130
|
+
}
|
|
4131
|
+
}
|
|
4132
|
+
function IsControlCharacterFree(value) {
|
|
4133
|
+
if (!IsString(value))
|
|
4134
|
+
return false;
|
|
4135
|
+
for (let i = 0; i < value.length; i++) {
|
|
4136
|
+
const code = value.charCodeAt(i);
|
|
4137
|
+
if (code >= 7 && code <= 13 || code === 27 || code === 127) {
|
|
4138
|
+
return false;
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
return true;
|
|
4142
|
+
}
|
|
4143
|
+
function IsAdditionalProperties(value) {
|
|
4144
|
+
return IsOptionalBoolean(value) || IsSchema2(value);
|
|
4145
|
+
}
|
|
4146
|
+
function IsOptionalBigInt(value) {
|
|
4147
|
+
return IsUndefined(value) || IsBigInt(value);
|
|
4148
|
+
}
|
|
4149
|
+
function IsOptionalNumber(value) {
|
|
4150
|
+
return IsUndefined(value) || IsNumber(value);
|
|
4151
|
+
}
|
|
4152
|
+
function IsOptionalBoolean(value) {
|
|
4153
|
+
return IsUndefined(value) || IsBoolean(value);
|
|
4154
|
+
}
|
|
4155
|
+
function IsOptionalString(value) {
|
|
4156
|
+
return IsUndefined(value) || IsString(value);
|
|
4157
|
+
}
|
|
4158
|
+
function IsOptionalPattern(value) {
|
|
4159
|
+
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
|
|
4160
|
+
}
|
|
4161
|
+
function IsOptionalFormat(value) {
|
|
4162
|
+
return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
|
|
4163
|
+
}
|
|
4164
|
+
function IsOptionalSchema(value) {
|
|
4165
|
+
return IsUndefined(value) || IsSchema2(value);
|
|
4166
|
+
}
|
|
4167
|
+
function IsReadonly2(value) {
|
|
4168
|
+
return IsObject(value) && value[ReadonlyKind] === "Readonly";
|
|
4169
|
+
}
|
|
4170
|
+
function IsOptional2(value) {
|
|
4171
|
+
return IsObject(value) && value[OptionalKind] === "Optional";
|
|
4172
|
+
}
|
|
4173
|
+
function IsAny2(value) {
|
|
4174
|
+
return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
|
|
4175
|
+
}
|
|
4176
|
+
function IsArgument2(value) {
|
|
4177
|
+
return IsKindOf2(value, "Argument") && IsNumber(value.index);
|
|
4178
|
+
}
|
|
4179
|
+
function IsArray4(value) {
|
|
4180
|
+
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);
|
|
4181
|
+
}
|
|
4182
|
+
function IsAsyncIterator3(value) {
|
|
4183
|
+
return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
4184
|
+
}
|
|
4185
|
+
function IsBigInt3(value) {
|
|
4186
|
+
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);
|
|
4187
|
+
}
|
|
4188
|
+
function IsBoolean3(value) {
|
|
4189
|
+
return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
|
|
4190
|
+
}
|
|
4191
|
+
function IsComputed2(value) {
|
|
4192
|
+
return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
|
|
4193
|
+
}
|
|
4194
|
+
function IsConstructor2(value) {
|
|
4195
|
+
return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
4196
|
+
}
|
|
4197
|
+
function IsDate3(value) {
|
|
4198
|
+
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);
|
|
4199
|
+
}
|
|
4200
|
+
function IsFunction3(value) {
|
|
4201
|
+
return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
|
|
4202
|
+
}
|
|
4203
|
+
function IsImport(value) {
|
|
4204
|
+
return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
|
|
4205
|
+
}
|
|
4206
|
+
function IsInteger2(value) {
|
|
4207
|
+
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);
|
|
4208
|
+
}
|
|
4209
|
+
function IsProperties(value) {
|
|
4210
|
+
return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
|
|
4211
|
+
}
|
|
4212
|
+
function IsIntersect2(value) {
|
|
4213
|
+
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);
|
|
4214
|
+
}
|
|
4215
|
+
function IsIterator3(value) {
|
|
4216
|
+
return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
|
|
4217
|
+
}
|
|
4218
|
+
function IsKindOf2(value, kind) {
|
|
4219
|
+
return IsObject(value) && Kind in value && value[Kind] === kind;
|
|
4220
|
+
}
|
|
4221
|
+
function IsLiteralString(value) {
|
|
4222
|
+
return IsLiteral2(value) && IsString(value.const);
|
|
4223
|
+
}
|
|
4224
|
+
function IsLiteralNumber(value) {
|
|
4225
|
+
return IsLiteral2(value) && IsNumber(value.const);
|
|
4226
|
+
}
|
|
4227
|
+
function IsLiteralBoolean(value) {
|
|
4228
|
+
return IsLiteral2(value) && IsBoolean(value.const);
|
|
4229
|
+
}
|
|
4230
|
+
function IsLiteral2(value) {
|
|
4231
|
+
return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
|
|
4232
|
+
}
|
|
4233
|
+
function IsLiteralValue2(value) {
|
|
4234
|
+
return IsBoolean(value) || IsNumber(value) || IsString(value);
|
|
4235
|
+
}
|
|
4236
|
+
function IsMappedKey2(value) {
|
|
4237
|
+
return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
|
|
4238
|
+
}
|
|
4239
|
+
function IsMappedResult2(value) {
|
|
4240
|
+
return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
|
|
4241
|
+
}
|
|
4242
|
+
function IsNever2(value) {
|
|
4243
|
+
return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
|
|
4244
|
+
}
|
|
4245
|
+
function IsNot2(value) {
|
|
4246
|
+
return IsKindOf2(value, "Not") && IsSchema2(value.not);
|
|
4247
|
+
}
|
|
4248
|
+
function IsNull3(value) {
|
|
4249
|
+
return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
|
|
4250
|
+
}
|
|
4251
|
+
function IsNumber4(value) {
|
|
4252
|
+
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);
|
|
4253
|
+
}
|
|
4254
|
+
function IsObject4(value) {
|
|
4255
|
+
return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
|
|
4256
|
+
}
|
|
4257
|
+
function IsPromise2(value) {
|
|
4258
|
+
return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
|
|
4259
|
+
}
|
|
4260
|
+
function IsRecord2(value) {
|
|
4261
|
+
return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
|
|
4262
|
+
const keys = Object.getOwnPropertyNames(schema.patternProperties);
|
|
4263
|
+
return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
|
|
4264
|
+
})(value);
|
|
4265
|
+
}
|
|
4266
|
+
function IsRecursive(value) {
|
|
4267
|
+
return IsObject(value) && Hint in value && value[Hint] === "Recursive";
|
|
4268
|
+
}
|
|
4269
|
+
function IsRef2(value) {
|
|
4270
|
+
return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
|
|
4271
|
+
}
|
|
4272
|
+
function IsRegExp3(value) {
|
|
4273
|
+
return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
|
|
4274
|
+
}
|
|
4275
|
+
function IsString3(value) {
|
|
4276
|
+
return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
|
|
4277
|
+
}
|
|
4278
|
+
function IsSymbol3(value) {
|
|
4279
|
+
return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
|
|
4280
|
+
}
|
|
4281
|
+
function IsTemplateLiteral2(value) {
|
|
4282
|
+
return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
|
|
4283
|
+
}
|
|
4284
|
+
function IsThis2(value) {
|
|
4285
|
+
return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
|
|
4286
|
+
}
|
|
4287
|
+
function IsTransform2(value) {
|
|
4288
|
+
return IsObject(value) && TransformKind in value;
|
|
4289
|
+
}
|
|
4290
|
+
function IsTuple2(value) {
|
|
4291
|
+
return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
|
|
4292
|
+
(IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
|
|
4293
|
+
}
|
|
4294
|
+
function IsUndefined4(value) {
|
|
4295
|
+
return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
|
|
4296
|
+
}
|
|
4297
|
+
function IsUnionLiteral(value) {
|
|
4298
|
+
return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
|
|
4299
|
+
}
|
|
4300
|
+
function IsUnion2(value) {
|
|
4301
|
+
return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
|
|
4302
|
+
}
|
|
4303
|
+
function IsUint8Array3(value) {
|
|
4304
|
+
return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
|
|
4305
|
+
}
|
|
4306
|
+
function IsUnknown2(value) {
|
|
4307
|
+
return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
|
|
4308
|
+
}
|
|
4309
|
+
function IsUnsafe2(value) {
|
|
4310
|
+
return IsKindOf2(value, "Unsafe");
|
|
4311
|
+
}
|
|
4312
|
+
function IsVoid2(value) {
|
|
4313
|
+
return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
|
|
4314
|
+
}
|
|
4315
|
+
function IsKind2(value) {
|
|
4316
|
+
return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
|
|
4317
|
+
}
|
|
4318
|
+
function IsSchema2(value) {
|
|
4319
|
+
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));
|
|
4320
|
+
}
|
|
4321
|
+
|
|
4322
|
+
// node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
|
|
4323
|
+
var PatternBoolean = "(true|false)";
|
|
4324
|
+
var PatternNumber = "(0|[1-9][0-9]*)";
|
|
4325
|
+
var PatternString = "(.*)";
|
|
4326
|
+
var PatternNever = "(?!.*)";
|
|
4327
|
+
var PatternBooleanExact = `^${PatternBoolean}$`;
|
|
4328
|
+
var PatternNumberExact = `^${PatternNumber}$`;
|
|
4329
|
+
var PatternStringExact = `^${PatternString}$`;
|
|
4330
|
+
var PatternNeverExact = `^${PatternNever}$`;
|
|
4331
|
+
|
|
4332
|
+
// node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
|
|
4333
|
+
function SetIncludes(T, S) {
|
|
4334
|
+
return T.includes(S);
|
|
4335
|
+
}
|
|
4336
|
+
function SetDistinct(T) {
|
|
4337
|
+
return [...new Set(T)];
|
|
4338
|
+
}
|
|
4339
|
+
function SetIntersect(T, S) {
|
|
4340
|
+
return T.filter((L) => S.includes(L));
|
|
4341
|
+
}
|
|
4342
|
+
function SetIntersectManyResolve(T, Init) {
|
|
4343
|
+
return T.reduce((Acc, L) => {
|
|
4344
|
+
return SetIntersect(Acc, L);
|
|
4345
|
+
}, Init);
|
|
4346
|
+
}
|
|
4347
|
+
function SetIntersectMany(T) {
|
|
4348
|
+
return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
|
|
4349
|
+
}
|
|
4350
|
+
function SetUnionMany(T) {
|
|
4351
|
+
const Acc = [];
|
|
4352
|
+
for (const L of T)
|
|
4353
|
+
Acc.push(...L);
|
|
4354
|
+
return Acc;
|
|
4355
|
+
}
|
|
4356
|
+
|
|
4357
|
+
// node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
|
|
4358
|
+
function Any(options) {
|
|
4359
|
+
return CreateType({ [Kind]: "Any" }, options);
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
// node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
|
|
4363
|
+
function Array2(items, options) {
|
|
4364
|
+
return CreateType({ [Kind]: "Array", type: "array", items }, options);
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
// node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
|
|
4368
|
+
function Argument2(index) {
|
|
4369
|
+
return CreateType({ [Kind]: "Argument", index });
|
|
4370
|
+
}
|
|
4371
|
+
|
|
4372
|
+
// node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
|
|
4373
|
+
function AsyncIterator(items, options) {
|
|
4374
|
+
return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
|
|
4375
|
+
}
|
|
4376
|
+
|
|
4377
|
+
// node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
|
|
4378
|
+
function Computed(target, parameters, options) {
|
|
4379
|
+
return CreateType({ [Kind]: "Computed", target, parameters }, options);
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
// node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
|
|
4383
|
+
function DiscardKey(value, key) {
|
|
4384
|
+
const { [key]: _, ...rest } = value;
|
|
4385
|
+
return rest;
|
|
4386
|
+
}
|
|
4387
|
+
function Discard(value, keys) {
|
|
4388
|
+
return keys.reduce((acc, key) => DiscardKey(acc, key), value);
|
|
4389
|
+
}
|
|
4390
|
+
|
|
4391
|
+
// node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
|
|
4392
|
+
function Never(options) {
|
|
4393
|
+
return CreateType({ [Kind]: "Never", not: {} }, options);
|
|
4394
|
+
}
|
|
4395
|
+
|
|
4396
|
+
// node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
|
|
4397
|
+
function MappedResult(properties) {
|
|
4398
|
+
return CreateType({
|
|
4399
|
+
[Kind]: "MappedResult",
|
|
4400
|
+
properties
|
|
4401
|
+
});
|
|
4402
|
+
}
|
|
4403
|
+
|
|
4404
|
+
// node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
|
|
4405
|
+
function Constructor(parameters, returns, options) {
|
|
4406
|
+
return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
// node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
|
|
4410
|
+
function Function(parameters, returns, options) {
|
|
4411
|
+
return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
|
|
4412
|
+
}
|
|
4413
|
+
|
|
4414
|
+
// node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
|
|
4415
|
+
function UnionCreate(T, options) {
|
|
4416
|
+
return CreateType({ [Kind]: "Union", anyOf: T }, options);
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
// node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
|
|
4420
|
+
function IsUnionOptional(types) {
|
|
4421
|
+
return types.some((type) => IsOptional(type));
|
|
4422
|
+
}
|
|
4423
|
+
function RemoveOptionalFromRest(types) {
|
|
4424
|
+
return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
|
|
4425
|
+
}
|
|
4426
|
+
function RemoveOptionalFromType(T) {
|
|
4427
|
+
return Discard(T, [OptionalKind]);
|
|
4428
|
+
}
|
|
4429
|
+
function ResolveUnion(types, options) {
|
|
4430
|
+
const isOptional = IsUnionOptional(types);
|
|
4431
|
+
return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
|
|
4432
|
+
}
|
|
4433
|
+
function UnionEvaluated(T, options) {
|
|
4434
|
+
return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
|
|
4435
|
+
}
|
|
4436
|
+
|
|
4437
|
+
// node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
|
|
4438
|
+
function Union(types, options) {
|
|
4439
|
+
return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
|
|
4443
|
+
var TemplateLiteralParserError = class extends TypeBoxError {
|
|
4444
|
+
};
|
|
4445
|
+
function Unescape(pattern) {
|
|
4446
|
+
return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
|
|
4447
|
+
}
|
|
4448
|
+
function IsNonEscaped(pattern, index, char) {
|
|
4449
|
+
return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
|
|
4450
|
+
}
|
|
4451
|
+
function IsOpenParen(pattern, index) {
|
|
4452
|
+
return IsNonEscaped(pattern, index, "(");
|
|
4453
|
+
}
|
|
4454
|
+
function IsCloseParen(pattern, index) {
|
|
4455
|
+
return IsNonEscaped(pattern, index, ")");
|
|
4456
|
+
}
|
|
4457
|
+
function IsSeparator(pattern, index) {
|
|
4458
|
+
return IsNonEscaped(pattern, index, "|");
|
|
4459
|
+
}
|
|
4460
|
+
function IsGroup(pattern) {
|
|
4461
|
+
if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
|
|
4462
|
+
return false;
|
|
4463
|
+
let count = 0;
|
|
4464
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
4465
|
+
if (IsOpenParen(pattern, index))
|
|
4466
|
+
count += 1;
|
|
4467
|
+
if (IsCloseParen(pattern, index))
|
|
4468
|
+
count -= 1;
|
|
4469
|
+
if (count === 0 && index !== pattern.length - 1)
|
|
4470
|
+
return false;
|
|
4471
|
+
}
|
|
4472
|
+
return true;
|
|
4473
|
+
}
|
|
4474
|
+
function InGroup(pattern) {
|
|
4475
|
+
return pattern.slice(1, pattern.length - 1);
|
|
4476
|
+
}
|
|
4477
|
+
function IsPrecedenceOr(pattern) {
|
|
4478
|
+
let count = 0;
|
|
4479
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
4480
|
+
if (IsOpenParen(pattern, index))
|
|
4481
|
+
count += 1;
|
|
4482
|
+
if (IsCloseParen(pattern, index))
|
|
4483
|
+
count -= 1;
|
|
4484
|
+
if (IsSeparator(pattern, index) && count === 0)
|
|
4485
|
+
return true;
|
|
4486
|
+
}
|
|
4487
|
+
return false;
|
|
4488
|
+
}
|
|
4489
|
+
function IsPrecedenceAnd(pattern) {
|
|
4490
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
4491
|
+
if (IsOpenParen(pattern, index))
|
|
4492
|
+
return true;
|
|
4493
|
+
}
|
|
4494
|
+
return false;
|
|
4495
|
+
}
|
|
4496
|
+
function Or(pattern) {
|
|
4497
|
+
let [count, start] = [0, 0];
|
|
4498
|
+
const expressions = [];
|
|
4499
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
4500
|
+
if (IsOpenParen(pattern, index))
|
|
4501
|
+
count += 1;
|
|
4502
|
+
if (IsCloseParen(pattern, index))
|
|
4503
|
+
count -= 1;
|
|
4504
|
+
if (IsSeparator(pattern, index) && count === 0) {
|
|
4505
|
+
const range2 = pattern.slice(start, index);
|
|
4506
|
+
if (range2.length > 0)
|
|
4507
|
+
expressions.push(TemplateLiteralParse(range2));
|
|
4508
|
+
start = index + 1;
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4511
|
+
const range = pattern.slice(start);
|
|
4512
|
+
if (range.length > 0)
|
|
4513
|
+
expressions.push(TemplateLiteralParse(range));
|
|
4514
|
+
if (expressions.length === 0)
|
|
4515
|
+
return { type: "const", const: "" };
|
|
4516
|
+
if (expressions.length === 1)
|
|
4517
|
+
return expressions[0];
|
|
4518
|
+
return { type: "or", expr: expressions };
|
|
4519
|
+
}
|
|
4520
|
+
function And(pattern) {
|
|
4521
|
+
function Group(value, index) {
|
|
4522
|
+
if (!IsOpenParen(value, index))
|
|
4523
|
+
throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
|
|
4524
|
+
let count = 0;
|
|
4525
|
+
for (let scan = index; scan < value.length; scan++) {
|
|
4526
|
+
if (IsOpenParen(value, scan))
|
|
4527
|
+
count += 1;
|
|
4528
|
+
if (IsCloseParen(value, scan))
|
|
4529
|
+
count -= 1;
|
|
4530
|
+
if (count === 0)
|
|
4531
|
+
return [index, scan];
|
|
4532
|
+
}
|
|
4533
|
+
throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
|
|
4534
|
+
}
|
|
4535
|
+
function Range(pattern2, index) {
|
|
4536
|
+
for (let scan = index; scan < pattern2.length; scan++) {
|
|
4537
|
+
if (IsOpenParen(pattern2, scan))
|
|
4538
|
+
return [index, scan];
|
|
4539
|
+
}
|
|
4540
|
+
return [index, pattern2.length];
|
|
4541
|
+
}
|
|
4542
|
+
const expressions = [];
|
|
4543
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
4544
|
+
if (IsOpenParen(pattern, index)) {
|
|
4545
|
+
const [start, end] = Group(pattern, index);
|
|
4546
|
+
const range = pattern.slice(start, end + 1);
|
|
4547
|
+
expressions.push(TemplateLiteralParse(range));
|
|
4548
|
+
index = end;
|
|
4549
|
+
} else {
|
|
4550
|
+
const [start, end] = Range(pattern, index);
|
|
4551
|
+
const range = pattern.slice(start, end);
|
|
4552
|
+
if (range.length > 0)
|
|
4553
|
+
expressions.push(TemplateLiteralParse(range));
|
|
4554
|
+
index = end - 1;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
|
|
4558
|
+
}
|
|
4559
|
+
function TemplateLiteralParse(pattern) {
|
|
4560
|
+
return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
|
|
4561
|
+
}
|
|
4562
|
+
function TemplateLiteralParseExact(pattern) {
|
|
4563
|
+
return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4566
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
|
|
4567
|
+
var TemplateLiteralFiniteError = class extends TypeBoxError {
|
|
4568
|
+
};
|
|
4569
|
+
function IsNumberExpression(expression) {
|
|
4570
|
+
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]*";
|
|
4571
|
+
}
|
|
4572
|
+
function IsBooleanExpression(expression) {
|
|
4573
|
+
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";
|
|
4574
|
+
}
|
|
4575
|
+
function IsStringExpression(expression) {
|
|
4576
|
+
return expression.type === "const" && expression.const === ".*";
|
|
4577
|
+
}
|
|
4578
|
+
function IsTemplateLiteralExpressionFinite(expression) {
|
|
4579
|
+
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 : (() => {
|
|
4580
|
+
throw new TemplateLiteralFiniteError(`Unknown expression type`);
|
|
4581
|
+
})();
|
|
4582
|
+
}
|
|
4583
|
+
function IsTemplateLiteralFinite(schema) {
|
|
4584
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
4585
|
+
return IsTemplateLiteralExpressionFinite(expression);
|
|
4586
|
+
}
|
|
4587
|
+
|
|
4588
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
|
|
4589
|
+
var TemplateLiteralGenerateError = class extends TypeBoxError {
|
|
4590
|
+
};
|
|
4591
|
+
function* GenerateReduce(buffer) {
|
|
4592
|
+
if (buffer.length === 1)
|
|
4593
|
+
return yield* buffer[0];
|
|
4594
|
+
for (const left of buffer[0]) {
|
|
4595
|
+
for (const right of GenerateReduce(buffer.slice(1))) {
|
|
4596
|
+
yield `${left}${right}`;
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4600
|
+
function* GenerateAnd(expression) {
|
|
4601
|
+
return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
|
|
4602
|
+
}
|
|
4603
|
+
function* GenerateOr(expression) {
|
|
4604
|
+
for (const expr of expression.expr)
|
|
4605
|
+
yield* TemplateLiteralExpressionGenerate(expr);
|
|
4606
|
+
}
|
|
4607
|
+
function* GenerateConst(expression) {
|
|
4608
|
+
return yield expression.const;
|
|
4609
|
+
}
|
|
4610
|
+
function* TemplateLiteralExpressionGenerate(expression) {
|
|
4611
|
+
return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
|
|
4612
|
+
throw new TemplateLiteralGenerateError("Unknown expression");
|
|
4613
|
+
})();
|
|
4614
|
+
}
|
|
4615
|
+
function TemplateLiteralGenerate(schema) {
|
|
4616
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
4617
|
+
return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4620
|
+
// node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
|
|
4621
|
+
function Literal(value, options) {
|
|
4622
|
+
return CreateType({
|
|
4623
|
+
[Kind]: "Literal",
|
|
4624
|
+
const: value,
|
|
4625
|
+
type: typeof value
|
|
4626
|
+
}, options);
|
|
4627
|
+
}
|
|
4628
|
+
|
|
4629
|
+
// node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
|
|
4630
|
+
function Boolean2(options) {
|
|
4631
|
+
return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
|
|
4632
|
+
}
|
|
4633
|
+
|
|
4634
|
+
// node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
|
|
4635
|
+
function BigInt(options) {
|
|
4636
|
+
return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
|
|
4637
|
+
}
|
|
4638
|
+
|
|
4639
|
+
// node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
|
|
4640
|
+
function Number2(options) {
|
|
4641
|
+
return CreateType({ [Kind]: "Number", type: "number" }, options);
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
// node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
|
|
4645
|
+
function String2(options) {
|
|
4646
|
+
return CreateType({ [Kind]: "String", type: "string" }, options);
|
|
4647
|
+
}
|
|
4648
|
+
|
|
4649
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
|
|
4650
|
+
function* FromUnion(syntax) {
|
|
4651
|
+
const trim = syntax.trim().replace(/"|'/g, "");
|
|
4652
|
+
return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
|
|
4653
|
+
const literals = trim.split("|").map((literal) => Literal(literal.trim()));
|
|
4654
|
+
return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
|
|
4655
|
+
})();
|
|
4656
|
+
}
|
|
4657
|
+
function* FromTerminal(syntax) {
|
|
4658
|
+
if (syntax[1] !== "{") {
|
|
4659
|
+
const L = Literal("$");
|
|
4660
|
+
const R = FromSyntax(syntax.slice(1));
|
|
4661
|
+
return yield* [L, ...R];
|
|
4662
|
+
}
|
|
4663
|
+
for (let i = 2; i < syntax.length; i++) {
|
|
4664
|
+
if (syntax[i] === "}") {
|
|
4665
|
+
const L = FromUnion(syntax.slice(2, i));
|
|
4666
|
+
const R = FromSyntax(syntax.slice(i + 1));
|
|
4667
|
+
return yield* [...L, ...R];
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
yield Literal(syntax);
|
|
4671
|
+
}
|
|
4672
|
+
function* FromSyntax(syntax) {
|
|
4673
|
+
for (let i = 0; i < syntax.length; i++) {
|
|
4674
|
+
if (syntax[i] === "$") {
|
|
4675
|
+
const L = Literal(syntax.slice(0, i));
|
|
4676
|
+
const R = FromTerminal(syntax.slice(i));
|
|
4677
|
+
return yield* [L, ...R];
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
yield Literal(syntax);
|
|
4681
|
+
}
|
|
4682
|
+
function TemplateLiteralSyntax(syntax) {
|
|
4683
|
+
return [...FromSyntax(syntax)];
|
|
4684
|
+
}
|
|
4685
|
+
|
|
4686
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
|
|
4687
|
+
var TemplateLiteralPatternError = class extends TypeBoxError {
|
|
4688
|
+
};
|
|
4689
|
+
function Escape(value) {
|
|
4690
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4691
|
+
}
|
|
4692
|
+
function Visit2(schema, acc) {
|
|
4693
|
+
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}` : (() => {
|
|
4694
|
+
throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
|
|
4695
|
+
})();
|
|
4696
|
+
}
|
|
4697
|
+
function TemplateLiteralPattern(kinds) {
|
|
4698
|
+
return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
|
|
4699
|
+
}
|
|
4700
|
+
|
|
4701
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
|
|
4702
|
+
function TemplateLiteralToUnion(schema) {
|
|
4703
|
+
const R = TemplateLiteralGenerate(schema);
|
|
4704
|
+
const L = R.map((S) => Literal(S));
|
|
4705
|
+
return UnionEvaluated(L);
|
|
4706
|
+
}
|
|
4707
|
+
|
|
4708
|
+
// node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
|
|
4709
|
+
function TemplateLiteral(unresolved, options) {
|
|
4710
|
+
const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
|
|
4711
|
+
return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
|
|
4712
|
+
}
|
|
4713
|
+
|
|
4714
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
|
|
4715
|
+
function FromTemplateLiteral(templateLiteral) {
|
|
4716
|
+
const keys = TemplateLiteralGenerate(templateLiteral);
|
|
4717
|
+
return keys.map((key) => key.toString());
|
|
4718
|
+
}
|
|
4719
|
+
function FromUnion2(types) {
|
|
4720
|
+
const result = [];
|
|
4721
|
+
for (const type of types)
|
|
4722
|
+
result.push(...IndexPropertyKeys(type));
|
|
4723
|
+
return result;
|
|
4724
|
+
}
|
|
4725
|
+
function FromLiteral(literalValue) {
|
|
4726
|
+
return [literalValue.toString()];
|
|
4727
|
+
}
|
|
4728
|
+
function IndexPropertyKeys(type) {
|
|
4729
|
+
return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
|
|
4730
|
+
}
|
|
4731
|
+
|
|
4732
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
|
|
4733
|
+
function FromProperties(type, properties, options) {
|
|
4734
|
+
const result = {};
|
|
4735
|
+
for (const K2 of Object.getOwnPropertyNames(properties)) {
|
|
4736
|
+
result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
|
|
4737
|
+
}
|
|
4738
|
+
return result;
|
|
4739
|
+
}
|
|
4740
|
+
function FromMappedResult(type, mappedResult, options) {
|
|
4741
|
+
return FromProperties(type, mappedResult.properties, options);
|
|
4742
|
+
}
|
|
4743
|
+
function IndexFromMappedResult(type, mappedResult, options) {
|
|
4744
|
+
const properties = FromMappedResult(type, mappedResult, options);
|
|
4745
|
+
return MappedResult(properties);
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4748
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
|
|
4749
|
+
function FromRest(types, key) {
|
|
4750
|
+
return types.map((type) => IndexFromPropertyKey(type, key));
|
|
4751
|
+
}
|
|
4752
|
+
function FromIntersectRest(types) {
|
|
4753
|
+
return types.filter((type) => !IsNever(type));
|
|
4754
|
+
}
|
|
4755
|
+
function FromIntersect(types, key) {
|
|
4756
|
+
return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
|
|
4757
|
+
}
|
|
4758
|
+
function FromUnionRest(types) {
|
|
4759
|
+
return types.some((L) => IsNever(L)) ? [] : types;
|
|
4760
|
+
}
|
|
4761
|
+
function FromUnion3(types, key) {
|
|
4762
|
+
return UnionEvaluated(FromUnionRest(FromRest(types, key)));
|
|
4763
|
+
}
|
|
4764
|
+
function FromTuple(types, key) {
|
|
4765
|
+
return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
|
|
4766
|
+
}
|
|
4767
|
+
function FromArray(type, key) {
|
|
4768
|
+
return key === "[number]" ? type : Never();
|
|
4769
|
+
}
|
|
4770
|
+
function FromProperty(properties, propertyKey) {
|
|
4771
|
+
return propertyKey in properties ? properties[propertyKey] : Never();
|
|
4772
|
+
}
|
|
4773
|
+
function IndexFromPropertyKey(type, propertyKey) {
|
|
4774
|
+
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();
|
|
4775
|
+
}
|
|
4776
|
+
function IndexFromPropertyKeys(type, propertyKeys) {
|
|
4777
|
+
return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
|
|
4778
|
+
}
|
|
4779
|
+
function FromSchema(type, propertyKeys) {
|
|
4780
|
+
return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
|
|
4781
|
+
}
|
|
4782
|
+
function Index(type, key, options) {
|
|
4783
|
+
if (IsRef(type) || IsRef(key)) {
|
|
4784
|
+
const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
|
|
4785
|
+
if (!IsSchema(type) || !IsSchema(key))
|
|
4786
|
+
throw new TypeBoxError(error);
|
|
4787
|
+
return Computed("Index", [type, key]);
|
|
4788
|
+
}
|
|
4789
|
+
if (IsMappedResult(key))
|
|
4790
|
+
return IndexFromMappedResult(type, key, options);
|
|
4791
|
+
if (IsMappedKey(key))
|
|
4792
|
+
return IndexFromMappedKey(type, key, options);
|
|
4793
|
+
return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
|
|
4794
|
+
}
|
|
4795
|
+
|
|
4796
|
+
// node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
|
|
4797
|
+
function MappedIndexPropertyKey(type, key, options) {
|
|
4798
|
+
return { [key]: Index(type, [key], Clone(options)) };
|
|
4799
|
+
}
|
|
4800
|
+
function MappedIndexPropertyKeys(type, propertyKeys, options) {
|
|
4801
|
+
return propertyKeys.reduce((result, left) => {
|
|
4802
|
+
return { ...result, ...MappedIndexPropertyKey(type, left, options) };
|
|
4803
|
+
}, {});
|
|
4804
|
+
}
|
|
4805
|
+
function MappedIndexProperties(type, mappedKey, options) {
|
|
4806
|
+
return MappedIndexPropertyKeys(type, mappedKey.keys, options);
|
|
4807
|
+
}
|
|
4808
|
+
function IndexFromMappedKey(type, mappedKey, options) {
|
|
4809
|
+
const properties = MappedIndexProperties(type, mappedKey, options);
|
|
4810
|
+
return MappedResult(properties);
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4813
|
+
// node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
|
|
4814
|
+
function Iterator(items, options) {
|
|
4815
|
+
return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
|
|
4816
|
+
}
|
|
4817
|
+
|
|
4818
|
+
// node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
|
|
4819
|
+
function RequiredArray(properties) {
|
|
4820
|
+
return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
|
|
4821
|
+
}
|
|
4822
|
+
function _Object_(properties, options) {
|
|
4823
|
+
const required = RequiredArray(properties);
|
|
4824
|
+
const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
|
|
4825
|
+
return CreateType(schema, options);
|
|
4826
|
+
}
|
|
4827
|
+
var Object2 = _Object_;
|
|
4828
|
+
|
|
4829
|
+
// node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
|
|
4830
|
+
function Promise2(item, options) {
|
|
4831
|
+
return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
|
|
4832
|
+
}
|
|
4833
|
+
|
|
4834
|
+
// node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
|
|
4835
|
+
function RemoveReadonly(schema) {
|
|
4836
|
+
return CreateType(Discard(schema, [ReadonlyKind]));
|
|
4837
|
+
}
|
|
4838
|
+
function AddReadonly(schema) {
|
|
4839
|
+
return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
|
|
4840
|
+
}
|
|
4841
|
+
function ReadonlyWithFlag(schema, F) {
|
|
4842
|
+
return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
|
|
4843
|
+
}
|
|
4844
|
+
function Readonly(schema, enable) {
|
|
4845
|
+
const F = enable ?? true;
|
|
4846
|
+
return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
|
|
4847
|
+
}
|
|
4848
|
+
|
|
4849
|
+
// node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
|
|
4850
|
+
function FromProperties2(K, F) {
|
|
4851
|
+
const Acc = {};
|
|
4852
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
4853
|
+
Acc[K2] = Readonly(K[K2], F);
|
|
4854
|
+
return Acc;
|
|
4855
|
+
}
|
|
4856
|
+
function FromMappedResult2(R, F) {
|
|
4857
|
+
return FromProperties2(R.properties, F);
|
|
4858
|
+
}
|
|
4859
|
+
function ReadonlyFromMappedResult(R, F) {
|
|
4860
|
+
const P = FromMappedResult2(R, F);
|
|
4861
|
+
return MappedResult(P);
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4864
|
+
// node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
|
|
4865
|
+
function Tuple(types, options) {
|
|
4866
|
+
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);
|
|
4867
|
+
}
|
|
4868
|
+
|
|
4869
|
+
// node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
|
|
4870
|
+
function FromMappedResult3(K, P) {
|
|
4871
|
+
return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
|
|
4872
|
+
}
|
|
4873
|
+
function MappedKeyToKnownMappedResultProperties(K) {
|
|
4874
|
+
return { [K]: Literal(K) };
|
|
4875
|
+
}
|
|
4876
|
+
function MappedKeyToUnknownMappedResultProperties(P) {
|
|
4877
|
+
const Acc = {};
|
|
4878
|
+
for (const L of P)
|
|
4879
|
+
Acc[L] = Literal(L);
|
|
4880
|
+
return Acc;
|
|
4881
|
+
}
|
|
4882
|
+
function MappedKeyToMappedResultProperties(K, P) {
|
|
4883
|
+
return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
|
|
4884
|
+
}
|
|
4885
|
+
function FromMappedKey(K, P) {
|
|
4886
|
+
const R = MappedKeyToMappedResultProperties(K, P);
|
|
4887
|
+
return FromMappedResult3(K, R);
|
|
4888
|
+
}
|
|
4889
|
+
function FromRest2(K, T) {
|
|
4890
|
+
return T.map((L) => FromSchemaType(K, L));
|
|
4891
|
+
}
|
|
4892
|
+
function FromProperties3(K, T) {
|
|
4893
|
+
const Acc = {};
|
|
4894
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(T))
|
|
4895
|
+
Acc[K2] = FromSchemaType(K, T[K2]);
|
|
4896
|
+
return Acc;
|
|
4897
|
+
}
|
|
4898
|
+
function FromSchemaType(K, T) {
|
|
4899
|
+
const options = { ...T };
|
|
4900
|
+
return (
|
|
4901
|
+
// unevaluated modifier types
|
|
4902
|
+
IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
|
|
4903
|
+
// unevaluated mapped types
|
|
4904
|
+
IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
|
|
4905
|
+
// unevaluated types
|
|
4906
|
+
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
|
|
4907
|
+
)
|
|
4908
|
+
)
|
|
4909
|
+
);
|
|
4910
|
+
}
|
|
4911
|
+
function MappedFunctionReturnType(K, T) {
|
|
4912
|
+
const Acc = {};
|
|
4913
|
+
for (const L of K)
|
|
4914
|
+
Acc[L] = FromSchemaType(L, T);
|
|
4915
|
+
return Acc;
|
|
4916
|
+
}
|
|
4917
|
+
function Mapped(key, map, options) {
|
|
4918
|
+
const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
4919
|
+
const RT = map({ [Kind]: "MappedKey", keys: K });
|
|
4920
|
+
const R = MappedFunctionReturnType(K, RT);
|
|
4921
|
+
return Object2(R, options);
|
|
4922
|
+
}
|
|
4923
|
+
|
|
4924
|
+
// node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
|
|
4925
|
+
function RemoveOptional(schema) {
|
|
4926
|
+
return CreateType(Discard(schema, [OptionalKind]));
|
|
4927
|
+
}
|
|
4928
|
+
function AddOptional(schema) {
|
|
4929
|
+
return CreateType({ ...schema, [OptionalKind]: "Optional" });
|
|
4930
|
+
}
|
|
4931
|
+
function OptionalWithFlag(schema, F) {
|
|
4932
|
+
return F === false ? RemoveOptional(schema) : AddOptional(schema);
|
|
4933
|
+
}
|
|
4934
|
+
function Optional(schema, enable) {
|
|
4935
|
+
const F = enable ?? true;
|
|
4936
|
+
return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
// node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
|
|
4940
|
+
function FromProperties4(P, F) {
|
|
4941
|
+
const Acc = {};
|
|
4942
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
4943
|
+
Acc[K2] = Optional(P[K2], F);
|
|
4944
|
+
return Acc;
|
|
4945
|
+
}
|
|
4946
|
+
function FromMappedResult4(R, F) {
|
|
4947
|
+
return FromProperties4(R.properties, F);
|
|
4948
|
+
}
|
|
4949
|
+
function OptionalFromMappedResult(R, F) {
|
|
4950
|
+
const P = FromMappedResult4(R, F);
|
|
4951
|
+
return MappedResult(P);
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
|
|
4955
|
+
function IntersectCreate(T, options = {}) {
|
|
4956
|
+
const allObjects = T.every((schema) => IsObject3(schema));
|
|
4957
|
+
const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
|
|
4958
|
+
return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4961
|
+
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
|
|
4962
|
+
function IsIntersectOptional(types) {
|
|
4963
|
+
return types.every((left) => IsOptional(left));
|
|
4964
|
+
}
|
|
4965
|
+
function RemoveOptionalFromType2(type) {
|
|
4966
|
+
return Discard(type, [OptionalKind]);
|
|
4967
|
+
}
|
|
4968
|
+
function RemoveOptionalFromRest2(types) {
|
|
4969
|
+
return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
|
|
4970
|
+
}
|
|
4971
|
+
function ResolveIntersect(types, options) {
|
|
4972
|
+
return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
|
|
4973
|
+
}
|
|
4974
|
+
function IntersectEvaluated(types, options = {}) {
|
|
4975
|
+
if (types.length === 1)
|
|
4976
|
+
return CreateType(types[0], options);
|
|
4977
|
+
if (types.length === 0)
|
|
4978
|
+
return Never(options);
|
|
4979
|
+
if (types.some((schema) => IsTransform(schema)))
|
|
4980
|
+
throw new Error("Cannot intersect transform types");
|
|
4981
|
+
return ResolveIntersect(types, options);
|
|
4982
|
+
}
|
|
4983
|
+
|
|
4984
|
+
// node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
|
|
4985
|
+
function Intersect(types, options) {
|
|
4986
|
+
if (types.length === 1)
|
|
4987
|
+
return CreateType(types[0], options);
|
|
4988
|
+
if (types.length === 0)
|
|
4989
|
+
return Never(options);
|
|
4990
|
+
if (types.some((schema) => IsTransform(schema)))
|
|
4991
|
+
throw new Error("Cannot intersect transform types");
|
|
4992
|
+
return IntersectCreate(types, options);
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
// node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
|
|
4996
|
+
function Ref(...args) {
|
|
4997
|
+
const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
|
|
4998
|
+
if (typeof $ref !== "string")
|
|
4999
|
+
throw new TypeBoxError("Ref: $ref must be a string");
|
|
5000
|
+
return CreateType({ [Kind]: "Ref", $ref }, options);
|
|
5001
|
+
}
|
|
5002
|
+
|
|
5003
|
+
// node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
|
|
5004
|
+
function FromComputed(target, parameters) {
|
|
5005
|
+
return Computed("Awaited", [Computed(target, parameters)]);
|
|
5006
|
+
}
|
|
5007
|
+
function FromRef($ref) {
|
|
5008
|
+
return Computed("Awaited", [Ref($ref)]);
|
|
5009
|
+
}
|
|
5010
|
+
function FromIntersect2(types) {
|
|
5011
|
+
return Intersect(FromRest3(types));
|
|
5012
|
+
}
|
|
5013
|
+
function FromUnion4(types) {
|
|
5014
|
+
return Union(FromRest3(types));
|
|
5015
|
+
}
|
|
5016
|
+
function FromPromise(type) {
|
|
5017
|
+
return Awaited(type);
|
|
5018
|
+
}
|
|
5019
|
+
function FromRest3(types) {
|
|
5020
|
+
return types.map((type) => Awaited(type));
|
|
5021
|
+
}
|
|
5022
|
+
function Awaited(type, options) {
|
|
5023
|
+
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);
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
|
|
5027
|
+
function FromRest4(types) {
|
|
5028
|
+
const result = [];
|
|
5029
|
+
for (const L of types)
|
|
5030
|
+
result.push(KeyOfPropertyKeys(L));
|
|
5031
|
+
return result;
|
|
5032
|
+
}
|
|
5033
|
+
function FromIntersect3(types) {
|
|
5034
|
+
const propertyKeysArray = FromRest4(types);
|
|
5035
|
+
const propertyKeys = SetUnionMany(propertyKeysArray);
|
|
5036
|
+
return propertyKeys;
|
|
5037
|
+
}
|
|
5038
|
+
function FromUnion5(types) {
|
|
5039
|
+
const propertyKeysArray = FromRest4(types);
|
|
5040
|
+
const propertyKeys = SetIntersectMany(propertyKeysArray);
|
|
5041
|
+
return propertyKeys;
|
|
5042
|
+
}
|
|
5043
|
+
function FromTuple2(types) {
|
|
5044
|
+
return types.map((_, indexer) => indexer.toString());
|
|
5045
|
+
}
|
|
5046
|
+
function FromArray2(_) {
|
|
5047
|
+
return ["[number]"];
|
|
5048
|
+
}
|
|
5049
|
+
function FromProperties5(T) {
|
|
5050
|
+
return globalThis.Object.getOwnPropertyNames(T);
|
|
5051
|
+
}
|
|
5052
|
+
function FromPatternProperties(patternProperties) {
|
|
5053
|
+
if (!includePatternProperties)
|
|
5054
|
+
return [];
|
|
5055
|
+
const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
|
|
5056
|
+
return patternPropertyKeys.map((key) => {
|
|
5057
|
+
return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
|
|
5058
|
+
});
|
|
5059
|
+
}
|
|
5060
|
+
function KeyOfPropertyKeys(type) {
|
|
5061
|
+
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) : [];
|
|
5062
|
+
}
|
|
5063
|
+
var includePatternProperties = false;
|
|
5064
|
+
|
|
5065
|
+
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
|
|
5066
|
+
function FromComputed2(target, parameters) {
|
|
5067
|
+
return Computed("KeyOf", [Computed(target, parameters)]);
|
|
5068
|
+
}
|
|
5069
|
+
function FromRef2($ref) {
|
|
5070
|
+
return Computed("KeyOf", [Ref($ref)]);
|
|
5071
|
+
}
|
|
5072
|
+
function KeyOfFromType(type, options) {
|
|
5073
|
+
const propertyKeys = KeyOfPropertyKeys(type);
|
|
5074
|
+
const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
|
|
5075
|
+
const result = UnionEvaluated(propertyKeyTypes);
|
|
5076
|
+
return CreateType(result, options);
|
|
5077
|
+
}
|
|
5078
|
+
function KeyOfPropertyKeysToRest(propertyKeys) {
|
|
5079
|
+
return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
|
|
5080
|
+
}
|
|
5081
|
+
function KeyOf(type, options) {
|
|
5082
|
+
return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
|
|
5083
|
+
}
|
|
5084
|
+
|
|
5085
|
+
// node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
|
|
5086
|
+
function FromProperties6(properties, options) {
|
|
5087
|
+
const result = {};
|
|
5088
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
5089
|
+
result[K2] = KeyOf(properties[K2], Clone(options));
|
|
5090
|
+
return result;
|
|
5091
|
+
}
|
|
5092
|
+
function FromMappedResult5(mappedResult, options) {
|
|
5093
|
+
return FromProperties6(mappedResult.properties, options);
|
|
5094
|
+
}
|
|
5095
|
+
function KeyOfFromMappedResult(mappedResult, options) {
|
|
5096
|
+
const properties = FromMappedResult5(mappedResult, options);
|
|
5097
|
+
return MappedResult(properties);
|
|
5098
|
+
}
|
|
5099
|
+
|
|
5100
|
+
// node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
|
|
5101
|
+
function CompositeKeys(T) {
|
|
5102
|
+
const Acc = [];
|
|
5103
|
+
for (const L of T)
|
|
5104
|
+
Acc.push(...KeyOfPropertyKeys(L));
|
|
5105
|
+
return SetDistinct(Acc);
|
|
5106
|
+
}
|
|
5107
|
+
function FilterNever(T) {
|
|
5108
|
+
return T.filter((L) => !IsNever(L));
|
|
5109
|
+
}
|
|
5110
|
+
function CompositeProperty(T, K) {
|
|
5111
|
+
const Acc = [];
|
|
5112
|
+
for (const L of T)
|
|
5113
|
+
Acc.push(...IndexFromPropertyKeys(L, [K]));
|
|
5114
|
+
return FilterNever(Acc);
|
|
5115
|
+
}
|
|
5116
|
+
function CompositeProperties(T, K) {
|
|
5117
|
+
const Acc = {};
|
|
5118
|
+
for (const L of K) {
|
|
5119
|
+
Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
|
|
5120
|
+
}
|
|
5121
|
+
return Acc;
|
|
5122
|
+
}
|
|
5123
|
+
function Composite(T, options) {
|
|
5124
|
+
const K = CompositeKeys(T);
|
|
5125
|
+
const P = CompositeProperties(T, K);
|
|
5126
|
+
const R = Object2(P, options);
|
|
5127
|
+
return R;
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
// node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
|
|
5131
|
+
function Date2(options) {
|
|
5132
|
+
return CreateType({ [Kind]: "Date", type: "Date" }, options);
|
|
5133
|
+
}
|
|
5134
|
+
|
|
5135
|
+
// node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
|
|
5136
|
+
function Null(options) {
|
|
5137
|
+
return CreateType({ [Kind]: "Null", type: "null" }, options);
|
|
5138
|
+
}
|
|
5139
|
+
|
|
5140
|
+
// node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
|
|
5141
|
+
function Symbol2(options) {
|
|
5142
|
+
return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
|
|
5143
|
+
}
|
|
5144
|
+
|
|
5145
|
+
// node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
|
|
5146
|
+
function Undefined(options) {
|
|
5147
|
+
return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
|
|
5148
|
+
}
|
|
5149
|
+
|
|
5150
|
+
// node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
|
|
5151
|
+
function Uint8Array2(options) {
|
|
5152
|
+
return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
|
|
5153
|
+
}
|
|
5154
|
+
|
|
5155
|
+
// node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
|
|
5156
|
+
function Unknown(options) {
|
|
5157
|
+
return CreateType({ [Kind]: "Unknown" }, options);
|
|
5158
|
+
}
|
|
5159
|
+
|
|
5160
|
+
// node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
|
|
5161
|
+
function FromArray3(T) {
|
|
5162
|
+
return T.map((L) => FromValue(L, false));
|
|
5163
|
+
}
|
|
5164
|
+
function FromProperties7(value) {
|
|
5165
|
+
const Acc = {};
|
|
5166
|
+
for (const K of globalThis.Object.getOwnPropertyNames(value))
|
|
5167
|
+
Acc[K] = Readonly(FromValue(value[K], false));
|
|
5168
|
+
return Acc;
|
|
5169
|
+
}
|
|
5170
|
+
function ConditionalReadonly(T, root) {
|
|
5171
|
+
return root === true ? T : Readonly(T);
|
|
5172
|
+
}
|
|
5173
|
+
function FromValue(value, root) {
|
|
5174
|
+
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({});
|
|
5175
|
+
}
|
|
5176
|
+
function Const(T, options) {
|
|
5177
|
+
return CreateType(FromValue(T, true), options);
|
|
5178
|
+
}
|
|
5179
|
+
|
|
5180
|
+
// node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
|
|
5181
|
+
function ConstructorParameters(schema, options) {
|
|
5182
|
+
return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
|
|
5183
|
+
}
|
|
5184
|
+
|
|
5185
|
+
// node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
|
|
5186
|
+
function Enum(item, options) {
|
|
5187
|
+
if (IsUndefined(item))
|
|
5188
|
+
throw new Error("Enum undefined or empty");
|
|
5189
|
+
const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
|
|
5190
|
+
const values2 = [...new Set(values1)];
|
|
5191
|
+
const anyOf = values2.map((value) => Literal(value));
|
|
5192
|
+
return Union(anyOf, { ...options, [Hint]: "Enum" });
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5195
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
|
|
5196
|
+
var ExtendsResolverError = class extends TypeBoxError {
|
|
5197
|
+
};
|
|
5198
|
+
var ExtendsResult;
|
|
5199
|
+
(function(ExtendsResult2) {
|
|
5200
|
+
ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
|
|
5201
|
+
ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
|
|
5202
|
+
ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
|
|
5203
|
+
})(ExtendsResult || (ExtendsResult = {}));
|
|
5204
|
+
function IntoBooleanResult(result) {
|
|
5205
|
+
return result === ExtendsResult.False ? result : ExtendsResult.True;
|
|
5206
|
+
}
|
|
5207
|
+
function Throw(message) {
|
|
5208
|
+
throw new ExtendsResolverError(message);
|
|
5209
|
+
}
|
|
5210
|
+
function IsStructuralRight(right) {
|
|
5211
|
+
return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
|
|
5212
|
+
}
|
|
5213
|
+
function StructuralRight(left, right) {
|
|
5214
|
+
return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
|
|
5215
|
+
}
|
|
5216
|
+
function FromAnyRight(left, right) {
|
|
5217
|
+
return ExtendsResult.True;
|
|
5218
|
+
}
|
|
5219
|
+
function FromAny(left, right) {
|
|
5220
|
+
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;
|
|
5221
|
+
}
|
|
5222
|
+
function FromArrayRight(left, right) {
|
|
5223
|
+
return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
5224
|
+
}
|
|
5225
|
+
function FromArray4(left, right) {
|
|
5226
|
+
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));
|
|
5227
|
+
}
|
|
5228
|
+
function FromAsyncIterator(left, right) {
|
|
5229
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
5230
|
+
}
|
|
5231
|
+
function FromBigInt(left, right) {
|
|
5232
|
+
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;
|
|
5233
|
+
}
|
|
5234
|
+
function FromBooleanRight(left, right) {
|
|
5235
|
+
return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
5236
|
+
}
|
|
5237
|
+
function FromBoolean(left, right) {
|
|
5238
|
+
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;
|
|
5239
|
+
}
|
|
5240
|
+
function FromConstructor(left, right) {
|
|
5241
|
+
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));
|
|
5242
|
+
}
|
|
5243
|
+
function FromDate(left, right) {
|
|
5244
|
+
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;
|
|
5245
|
+
}
|
|
5246
|
+
function FromFunction(left, right) {
|
|
5247
|
+
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));
|
|
5248
|
+
}
|
|
5249
|
+
function FromIntegerRight(left, right) {
|
|
5250
|
+
return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
5251
|
+
}
|
|
5252
|
+
function FromInteger(left, right) {
|
|
5253
|
+
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;
|
|
5254
|
+
}
|
|
5255
|
+
function FromIntersectRight(left, right) {
|
|
5256
|
+
return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
5257
|
+
}
|
|
5258
|
+
function FromIntersect4(left, right) {
|
|
5259
|
+
return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
5260
|
+
}
|
|
5261
|
+
function FromIterator(left, right) {
|
|
5262
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
|
|
5263
|
+
}
|
|
5264
|
+
function FromLiteral2(left, right) {
|
|
5265
|
+
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, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
|
|
5266
|
+
}
|
|
5267
|
+
function FromNeverRight(left, right) {
|
|
5268
|
+
return ExtendsResult.False;
|
|
5269
|
+
}
|
|
5270
|
+
function FromNever(left, right) {
|
|
5271
|
+
return ExtendsResult.True;
|
|
5272
|
+
}
|
|
5273
|
+
function UnwrapTNot(schema) {
|
|
5274
|
+
let [current, depth] = [schema, 0];
|
|
5275
|
+
while (true) {
|
|
5276
|
+
if (!type_exports.IsNot(current))
|
|
5277
|
+
break;
|
|
5278
|
+
current = current.not;
|
|
5279
|
+
depth += 1;
|
|
5280
|
+
}
|
|
5281
|
+
return depth % 2 === 0 ? current : Unknown();
|
|
5282
|
+
}
|
|
5283
|
+
function FromNot(left, right) {
|
|
5284
|
+
return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
|
|
5285
|
+
}
|
|
5286
|
+
function FromNull(left, right) {
|
|
5287
|
+
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;
|
|
5288
|
+
}
|
|
5289
|
+
function FromNumberRight(left, right) {
|
|
5290
|
+
return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
5291
|
+
}
|
|
5292
|
+
function FromNumber(left, right) {
|
|
5293
|
+
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;
|
|
5294
|
+
}
|
|
5295
|
+
function IsObjectPropertyCount(schema, count) {
|
|
5296
|
+
return Object.getOwnPropertyNames(schema.properties).length === count;
|
|
5297
|
+
}
|
|
5298
|
+
function IsObjectStringLike(schema) {
|
|
5299
|
+
return IsObjectArrayLike(schema);
|
|
5300
|
+
}
|
|
5301
|
+
function IsObjectSymbolLike(schema) {
|
|
5302
|
+
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]));
|
|
5303
|
+
}
|
|
5304
|
+
function IsObjectNumberLike(schema) {
|
|
5305
|
+
return IsObjectPropertyCount(schema, 0);
|
|
5306
|
+
}
|
|
5307
|
+
function IsObjectBooleanLike(schema) {
|
|
5308
|
+
return IsObjectPropertyCount(schema, 0);
|
|
5309
|
+
}
|
|
5310
|
+
function IsObjectBigIntLike(schema) {
|
|
5311
|
+
return IsObjectPropertyCount(schema, 0);
|
|
5312
|
+
}
|
|
5313
|
+
function IsObjectDateLike(schema) {
|
|
5314
|
+
return IsObjectPropertyCount(schema, 0);
|
|
5315
|
+
}
|
|
5316
|
+
function IsObjectUint8ArrayLike(schema) {
|
|
5317
|
+
return IsObjectArrayLike(schema);
|
|
5318
|
+
}
|
|
5319
|
+
function IsObjectFunctionLike(schema) {
|
|
5320
|
+
const length = Number2();
|
|
5321
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
|
|
5322
|
+
}
|
|
5323
|
+
function IsObjectConstructorLike(schema) {
|
|
5324
|
+
return IsObjectPropertyCount(schema, 0);
|
|
5325
|
+
}
|
|
5326
|
+
function IsObjectArrayLike(schema) {
|
|
5327
|
+
const length = Number2();
|
|
5328
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
|
|
5329
|
+
}
|
|
5330
|
+
function IsObjectPromiseLike(schema) {
|
|
5331
|
+
const then = Function([Any()], Any());
|
|
5332
|
+
return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
|
|
5333
|
+
}
|
|
5334
|
+
function Property(left, right) {
|
|
5335
|
+
return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
|
|
5336
|
+
}
|
|
5337
|
+
function FromObjectRight(left, right) {
|
|
5338
|
+
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)) ? (() => {
|
|
5339
|
+
return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
|
|
5340
|
+
})() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
|
|
5341
|
+
return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
|
|
5342
|
+
})() : ExtendsResult.False;
|
|
5343
|
+
}
|
|
5344
|
+
function FromObject(left, right) {
|
|
5345
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
|
|
5346
|
+
for (const key of Object.getOwnPropertyNames(right.properties)) {
|
|
5347
|
+
if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
|
|
5348
|
+
return ExtendsResult.False;
|
|
5349
|
+
}
|
|
5350
|
+
if (type_exports.IsOptional(right.properties[key])) {
|
|
5351
|
+
return ExtendsResult.True;
|
|
5352
|
+
}
|
|
5353
|
+
if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
|
|
5354
|
+
return ExtendsResult.False;
|
|
5355
|
+
}
|
|
5356
|
+
}
|
|
5357
|
+
return ExtendsResult.True;
|
|
5358
|
+
})();
|
|
5359
|
+
}
|
|
5360
|
+
function FromPromise2(left, right) {
|
|
5361
|
+
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));
|
|
5362
|
+
}
|
|
5363
|
+
function RecordKey(schema) {
|
|
5364
|
+
return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
|
|
5365
|
+
}
|
|
5366
|
+
function RecordValue(schema) {
|
|
5367
|
+
return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
|
|
5368
|
+
}
|
|
5369
|
+
function FromRecordRight(left, right) {
|
|
5370
|
+
const [Key, Value] = [RecordKey(right), RecordValue(right)];
|
|
5371
|
+
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) ? (() => {
|
|
5372
|
+
for (const key of Object.getOwnPropertyNames(left.properties)) {
|
|
5373
|
+
if (Property(Value, left.properties[key]) === ExtendsResult.False) {
|
|
5374
|
+
return ExtendsResult.False;
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
return ExtendsResult.True;
|
|
5378
|
+
})() : ExtendsResult.False;
|
|
5379
|
+
}
|
|
5380
|
+
function FromRecord(left, right) {
|
|
5381
|
+
return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
|
|
5382
|
+
}
|
|
5383
|
+
function FromRegExp(left, right) {
|
|
5384
|
+
const L = type_exports.IsRegExp(left) ? String2() : left;
|
|
5385
|
+
const R = type_exports.IsRegExp(right) ? String2() : right;
|
|
5386
|
+
return Visit3(L, R);
|
|
5387
|
+
}
|
|
5388
|
+
function FromStringRight(left, right) {
|
|
5389
|
+
return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
5390
|
+
}
|
|
5391
|
+
function FromString(left, right) {
|
|
5392
|
+
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;
|
|
5393
|
+
}
|
|
5394
|
+
function FromSymbol(left, right) {
|
|
5395
|
+
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;
|
|
5396
|
+
}
|
|
5397
|
+
function FromTemplateLiteral2(left, right) {
|
|
5398
|
+
return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
|
|
5399
|
+
}
|
|
5400
|
+
function IsArrayOfTuple(left, right) {
|
|
5401
|
+
return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
|
|
5402
|
+
}
|
|
5403
|
+
function FromTupleRight(left, right) {
|
|
5404
|
+
return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
|
|
5405
|
+
}
|
|
5406
|
+
function FromTuple3(left, right) {
|
|
5407
|
+
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;
|
|
5408
|
+
}
|
|
5409
|
+
function FromUint8Array(left, right) {
|
|
5410
|
+
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;
|
|
5411
|
+
}
|
|
5412
|
+
function FromUndefined(left, right) {
|
|
5413
|
+
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, right) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
5414
|
+
}
|
|
5415
|
+
function FromUnionRight(left, right) {
|
|
5416
|
+
return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
5417
|
+
}
|
|
5418
|
+
function FromUnion6(left, right) {
|
|
5419
|
+
return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
|
|
5420
|
+
}
|
|
5421
|
+
function FromUnknownRight(left, right) {
|
|
5422
|
+
return ExtendsResult.True;
|
|
5423
|
+
}
|
|
5424
|
+
function FromUnknown(left, right) {
|
|
5425
|
+
return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : type_exports.IsArray(right) ? FromArrayRight(left, right) : type_exports.IsTuple(right) ? FromTupleRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
5426
|
+
}
|
|
5427
|
+
function FromVoidRight(left, right) {
|
|
5428
|
+
return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
|
|
5429
|
+
}
|
|
5430
|
+
function FromVoid(left, right) {
|
|
5431
|
+
return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
|
|
5432
|
+
}
|
|
5433
|
+
function Visit3(left, right) {
|
|
5434
|
+
return (
|
|
5435
|
+
// resolvable
|
|
5436
|
+
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) : (
|
|
5437
|
+
// standard
|
|
5438
|
+
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(left, right) : 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]}'`)
|
|
5439
|
+
)
|
|
5440
|
+
);
|
|
5441
|
+
}
|
|
5442
|
+
function ExtendsCheck(left, right) {
|
|
5443
|
+
return Visit3(left, right);
|
|
5444
|
+
}
|
|
5445
|
+
|
|
5446
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
|
|
5447
|
+
function FromProperties8(P, Right, True, False, options) {
|
|
5448
|
+
const Acc = {};
|
|
5449
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
5450
|
+
Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
|
|
5451
|
+
return Acc;
|
|
5452
|
+
}
|
|
5453
|
+
function FromMappedResult6(Left, Right, True, False, options) {
|
|
5454
|
+
return FromProperties8(Left.properties, Right, True, False, options);
|
|
5455
|
+
}
|
|
5456
|
+
function ExtendsFromMappedResult(Left, Right, True, False, options) {
|
|
5457
|
+
const P = FromMappedResult6(Left, Right, True, False, options);
|
|
5458
|
+
return MappedResult(P);
|
|
5459
|
+
}
|
|
5460
|
+
|
|
5461
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
|
|
5462
|
+
function ExtendsResolve(left, right, trueType, falseType) {
|
|
5463
|
+
const R = ExtendsCheck(left, right);
|
|
5464
|
+
return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
|
|
5465
|
+
}
|
|
5466
|
+
function Extends(L, R, T, F, options) {
|
|
5467
|
+
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);
|
|
5468
|
+
}
|
|
5469
|
+
|
|
5470
|
+
// node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
|
|
5471
|
+
function FromPropertyKey(K, U, L, R, options) {
|
|
5472
|
+
return {
|
|
5473
|
+
[K]: Extends(Literal(K), U, L, R, Clone(options))
|
|
5474
|
+
};
|
|
5475
|
+
}
|
|
5476
|
+
function FromPropertyKeys(K, U, L, R, options) {
|
|
5477
|
+
return K.reduce((Acc, LK) => {
|
|
5478
|
+
return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
|
|
5479
|
+
}, {});
|
|
5480
|
+
}
|
|
5481
|
+
function FromMappedKey2(K, U, L, R, options) {
|
|
5482
|
+
return FromPropertyKeys(K.keys, U, L, R, options);
|
|
5483
|
+
}
|
|
5484
|
+
function ExtendsFromMappedKey(T, U, L, R, options) {
|
|
5485
|
+
const P = FromMappedKey2(T, U, L, R, options);
|
|
5486
|
+
return MappedResult(P);
|
|
5487
|
+
}
|
|
5488
|
+
|
|
5489
|
+
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
|
|
5490
|
+
function ExcludeFromTemplateLiteral(L, R) {
|
|
5491
|
+
return Exclude(TemplateLiteralToUnion(L), R);
|
|
5492
|
+
}
|
|
5493
|
+
|
|
5494
|
+
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
|
|
5495
|
+
function ExcludeRest(L, R) {
|
|
5496
|
+
const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
|
|
5497
|
+
return excluded.length === 1 ? excluded[0] : Union(excluded);
|
|
5498
|
+
}
|
|
5499
|
+
function Exclude(L, R, options = {}) {
|
|
5500
|
+
if (IsTemplateLiteral(L))
|
|
5501
|
+
return CreateType(ExcludeFromTemplateLiteral(L, R), options);
|
|
5502
|
+
if (IsMappedResult(L))
|
|
5503
|
+
return CreateType(ExcludeFromMappedResult(L, R), options);
|
|
5504
|
+
return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
|
|
5505
|
+
}
|
|
5506
|
+
|
|
5507
|
+
// node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
|
|
5508
|
+
function FromProperties9(P, U) {
|
|
5509
|
+
const Acc = {};
|
|
5510
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
5511
|
+
Acc[K2] = Exclude(P[K2], U);
|
|
5512
|
+
return Acc;
|
|
5513
|
+
}
|
|
5514
|
+
function FromMappedResult7(R, T) {
|
|
5515
|
+
return FromProperties9(R.properties, T);
|
|
5516
|
+
}
|
|
5517
|
+
function ExcludeFromMappedResult(R, T) {
|
|
5518
|
+
const P = FromMappedResult7(R, T);
|
|
5519
|
+
return MappedResult(P);
|
|
5520
|
+
}
|
|
5521
|
+
|
|
5522
|
+
// node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
|
|
5523
|
+
function ExtractFromTemplateLiteral(L, R) {
|
|
5524
|
+
return Extract(TemplateLiteralToUnion(L), R);
|
|
5525
|
+
}
|
|
5526
|
+
|
|
5527
|
+
// node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
|
|
5528
|
+
function ExtractRest(L, R) {
|
|
5529
|
+
const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
|
|
5530
|
+
return extracted.length === 1 ? extracted[0] : Union(extracted);
|
|
5531
|
+
}
|
|
5532
|
+
function Extract(L, R, options) {
|
|
5533
|
+
if (IsTemplateLiteral(L))
|
|
5534
|
+
return CreateType(ExtractFromTemplateLiteral(L, R), options);
|
|
5535
|
+
if (IsMappedResult(L))
|
|
5536
|
+
return CreateType(ExtractFromMappedResult(L, R), options);
|
|
5537
|
+
return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5540
|
+
// node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
|
|
5541
|
+
function FromProperties10(P, T) {
|
|
5542
|
+
const Acc = {};
|
|
5543
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
5544
|
+
Acc[K2] = Extract(P[K2], T);
|
|
5545
|
+
return Acc;
|
|
5546
|
+
}
|
|
5547
|
+
function FromMappedResult8(R, T) {
|
|
5548
|
+
return FromProperties10(R.properties, T);
|
|
5549
|
+
}
|
|
5550
|
+
function ExtractFromMappedResult(R, T) {
|
|
5551
|
+
const P = FromMappedResult8(R, T);
|
|
5552
|
+
return MappedResult(P);
|
|
5553
|
+
}
|
|
5554
|
+
|
|
5555
|
+
// node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
|
|
5556
|
+
function InstanceType(schema, options) {
|
|
5557
|
+
return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
5558
|
+
}
|
|
5559
|
+
|
|
5560
|
+
// node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
|
|
5561
|
+
function ReadonlyOptional(schema) {
|
|
5562
|
+
return Readonly(Optional(schema));
|
|
5563
|
+
}
|
|
5564
|
+
|
|
5565
|
+
// node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
|
|
5566
|
+
function RecordCreateFromPattern(pattern, T, options) {
|
|
5567
|
+
return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
|
|
5568
|
+
}
|
|
5569
|
+
function RecordCreateFromKeys(K, T, options) {
|
|
5570
|
+
const result = {};
|
|
5571
|
+
for (const K2 of K)
|
|
5572
|
+
result[K2] = T;
|
|
5573
|
+
return Object2(result, { ...options, [Hint]: "Record" });
|
|
5574
|
+
}
|
|
5575
|
+
function FromTemplateLiteralKey(K, T, options) {
|
|
5576
|
+
return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
|
|
5577
|
+
}
|
|
5578
|
+
function FromUnionKey(key, type, options) {
|
|
5579
|
+
return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
|
|
5580
|
+
}
|
|
5581
|
+
function FromLiteralKey(key, type, options) {
|
|
5582
|
+
return RecordCreateFromKeys([key.toString()], type, options);
|
|
5583
|
+
}
|
|
5584
|
+
function FromRegExpKey(key, type, options) {
|
|
5585
|
+
return RecordCreateFromPattern(key.source, type, options);
|
|
5586
|
+
}
|
|
5587
|
+
function FromStringKey(key, type, options) {
|
|
5588
|
+
const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
|
|
5589
|
+
return RecordCreateFromPattern(pattern, type, options);
|
|
5590
|
+
}
|
|
5591
|
+
function FromAnyKey(_, type, options) {
|
|
5592
|
+
return RecordCreateFromPattern(PatternStringExact, type, options);
|
|
5593
|
+
}
|
|
5594
|
+
function FromNeverKey(_key, type, options) {
|
|
5595
|
+
return RecordCreateFromPattern(PatternNeverExact, type, options);
|
|
5596
|
+
}
|
|
5597
|
+
function FromBooleanKey(_key, type, options) {
|
|
5598
|
+
return Object2({ true: type, false: type }, options);
|
|
5599
|
+
}
|
|
5600
|
+
function FromIntegerKey(_key, type, options) {
|
|
5601
|
+
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
5602
|
+
}
|
|
5603
|
+
function FromNumberKey(_, type, options) {
|
|
5604
|
+
return RecordCreateFromPattern(PatternNumberExact, type, options);
|
|
5605
|
+
}
|
|
5606
|
+
function Record(key, type, options = {}) {
|
|
5607
|
+
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);
|
|
5608
|
+
}
|
|
5609
|
+
function RecordPattern(record) {
|
|
5610
|
+
return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
|
|
5611
|
+
}
|
|
5612
|
+
function RecordKey2(type) {
|
|
5613
|
+
const pattern = RecordPattern(type);
|
|
5614
|
+
return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
|
|
5615
|
+
}
|
|
5616
|
+
function RecordValue2(type) {
|
|
5617
|
+
return type.patternProperties[RecordPattern(type)];
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5620
|
+
// node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
|
|
5621
|
+
function FromConstructor2(args, type) {
|
|
5622
|
+
type.parameters = FromTypes(args, type.parameters);
|
|
5623
|
+
type.returns = FromType(args, type.returns);
|
|
5624
|
+
return type;
|
|
5625
|
+
}
|
|
5626
|
+
function FromFunction2(args, type) {
|
|
5627
|
+
type.parameters = FromTypes(args, type.parameters);
|
|
5628
|
+
type.returns = FromType(args, type.returns);
|
|
5629
|
+
return type;
|
|
5630
|
+
}
|
|
5631
|
+
function FromIntersect5(args, type) {
|
|
5632
|
+
type.allOf = FromTypes(args, type.allOf);
|
|
5633
|
+
return type;
|
|
5634
|
+
}
|
|
5635
|
+
function FromUnion7(args, type) {
|
|
5636
|
+
type.anyOf = FromTypes(args, type.anyOf);
|
|
5637
|
+
return type;
|
|
5638
|
+
}
|
|
5639
|
+
function FromTuple4(args, type) {
|
|
5640
|
+
if (IsUndefined(type.items))
|
|
5641
|
+
return type;
|
|
5642
|
+
type.items = FromTypes(args, type.items);
|
|
5643
|
+
return type;
|
|
5644
|
+
}
|
|
5645
|
+
function FromArray5(args, type) {
|
|
5646
|
+
type.items = FromType(args, type.items);
|
|
5647
|
+
return type;
|
|
5648
|
+
}
|
|
5649
|
+
function FromAsyncIterator2(args, type) {
|
|
5650
|
+
type.items = FromType(args, type.items);
|
|
5651
|
+
return type;
|
|
5652
|
+
}
|
|
5653
|
+
function FromIterator2(args, type) {
|
|
5654
|
+
type.items = FromType(args, type.items);
|
|
5655
|
+
return type;
|
|
5656
|
+
}
|
|
5657
|
+
function FromPromise3(args, type) {
|
|
5658
|
+
type.item = FromType(args, type.item);
|
|
5659
|
+
return type;
|
|
5660
|
+
}
|
|
5661
|
+
function FromObject2(args, type) {
|
|
5662
|
+
const mappedProperties = FromProperties11(args, type.properties);
|
|
5663
|
+
return { ...type, ...Object2(mappedProperties) };
|
|
5664
|
+
}
|
|
5665
|
+
function FromRecord2(args, type) {
|
|
5666
|
+
const mappedKey = FromType(args, RecordKey2(type));
|
|
5667
|
+
const mappedValue = FromType(args, RecordValue2(type));
|
|
5668
|
+
const result = Record(mappedKey, mappedValue);
|
|
5669
|
+
return { ...type, ...result };
|
|
5670
|
+
}
|
|
5671
|
+
function FromArgument(args, argument) {
|
|
5672
|
+
return argument.index in args ? args[argument.index] : Unknown();
|
|
5673
|
+
}
|
|
5674
|
+
function FromProperty2(args, type) {
|
|
5675
|
+
const isReadonly = IsReadonly(type);
|
|
5676
|
+
const isOptional = IsOptional(type);
|
|
5677
|
+
const mapped = FromType(args, type);
|
|
5678
|
+
return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
|
|
5679
|
+
}
|
|
5680
|
+
function FromProperties11(args, properties) {
|
|
5681
|
+
return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
|
|
5682
|
+
return { ...result, [key]: FromProperty2(args, properties[key]) };
|
|
5683
|
+
}, {});
|
|
5684
|
+
}
|
|
5685
|
+
function FromTypes(args, types) {
|
|
5686
|
+
return types.map((type) => FromType(args, type));
|
|
5687
|
+
}
|
|
5688
|
+
function FromType(args, type) {
|
|
5689
|
+
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;
|
|
5690
|
+
}
|
|
5691
|
+
function Instantiate(type, args) {
|
|
5692
|
+
return FromType(args, CloneType(type));
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
// node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
|
|
5696
|
+
function Integer(options) {
|
|
5697
|
+
return CreateType({ [Kind]: "Integer", type: "integer" }, options);
|
|
5698
|
+
}
|
|
5699
|
+
|
|
5700
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
|
|
5701
|
+
function MappedIntrinsicPropertyKey(K, M, options) {
|
|
5702
|
+
return {
|
|
5703
|
+
[K]: Intrinsic(Literal(K), M, Clone(options))
|
|
5704
|
+
};
|
|
5705
|
+
}
|
|
5706
|
+
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
5707
|
+
const result = K.reduce((Acc, L) => {
|
|
5708
|
+
return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
|
|
5709
|
+
}, {});
|
|
5710
|
+
return result;
|
|
5711
|
+
}
|
|
5712
|
+
function MappedIntrinsicProperties(T, M, options) {
|
|
5713
|
+
return MappedIntrinsicPropertyKeys(T["keys"], M, options);
|
|
5714
|
+
}
|
|
5715
|
+
function IntrinsicFromMappedKey(T, M, options) {
|
|
5716
|
+
const P = MappedIntrinsicProperties(T, M, options);
|
|
5717
|
+
return MappedResult(P);
|
|
5718
|
+
}
|
|
5719
|
+
|
|
5720
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
|
|
5721
|
+
function ApplyUncapitalize(value) {
|
|
5722
|
+
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
5723
|
+
return [first.toLowerCase(), rest].join("");
|
|
5724
|
+
}
|
|
5725
|
+
function ApplyCapitalize(value) {
|
|
5726
|
+
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
5727
|
+
return [first.toUpperCase(), rest].join("");
|
|
5728
|
+
}
|
|
5729
|
+
function ApplyUppercase(value) {
|
|
5730
|
+
return value.toUpperCase();
|
|
5731
|
+
}
|
|
5732
|
+
function ApplyLowercase(value) {
|
|
5733
|
+
return value.toLowerCase();
|
|
5734
|
+
}
|
|
5735
|
+
function FromTemplateLiteral3(schema, mode, options) {
|
|
5736
|
+
const expression = TemplateLiteralParseExact(schema.pattern);
|
|
5737
|
+
const finite = IsTemplateLiteralExpressionFinite(expression);
|
|
5738
|
+
if (!finite)
|
|
5739
|
+
return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
|
|
5740
|
+
const strings = [...TemplateLiteralExpressionGenerate(expression)];
|
|
5741
|
+
const literals = strings.map((value) => Literal(value));
|
|
5742
|
+
const mapped = FromRest5(literals, mode);
|
|
5743
|
+
const union = Union(mapped);
|
|
5744
|
+
return TemplateLiteral([union], options);
|
|
5745
|
+
}
|
|
5746
|
+
function FromLiteralValue(value, mode) {
|
|
5747
|
+
return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
|
|
5748
|
+
}
|
|
5749
|
+
function FromRest5(T, M) {
|
|
5750
|
+
return T.map((L) => Intrinsic(L, M));
|
|
5751
|
+
}
|
|
5752
|
+
function Intrinsic(schema, mode, options = {}) {
|
|
5753
|
+
return (
|
|
5754
|
+
// Intrinsic-Mapped-Inference
|
|
5755
|
+
IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
|
|
5756
|
+
// Standard-Inference
|
|
5757
|
+
IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
|
|
5758
|
+
// Default Type
|
|
5759
|
+
CreateType(schema, options)
|
|
5760
|
+
)
|
|
5761
|
+
)
|
|
5762
|
+
);
|
|
5763
|
+
}
|
|
5764
|
+
|
|
5765
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
|
|
5766
|
+
function Capitalize(T, options = {}) {
|
|
5767
|
+
return Intrinsic(T, "Capitalize", options);
|
|
5768
|
+
}
|
|
5769
|
+
|
|
5770
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
|
|
5771
|
+
function Lowercase(T, options = {}) {
|
|
5772
|
+
return Intrinsic(T, "Lowercase", options);
|
|
5773
|
+
}
|
|
5774
|
+
|
|
5775
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
|
|
5776
|
+
function Uncapitalize(T, options = {}) {
|
|
5777
|
+
return Intrinsic(T, "Uncapitalize", options);
|
|
5778
|
+
}
|
|
5779
|
+
|
|
5780
|
+
// node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
|
|
5781
|
+
function Uppercase(T, options = {}) {
|
|
5782
|
+
return Intrinsic(T, "Uppercase", options);
|
|
5783
|
+
}
|
|
5784
|
+
|
|
5785
|
+
// node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
|
|
5786
|
+
function FromProperties12(properties, propertyKeys, options) {
|
|
5787
|
+
const result = {};
|
|
5788
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
5789
|
+
result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
|
|
5790
|
+
return result;
|
|
5791
|
+
}
|
|
5792
|
+
function FromMappedResult9(mappedResult, propertyKeys, options) {
|
|
5793
|
+
return FromProperties12(mappedResult.properties, propertyKeys, options);
|
|
5794
|
+
}
|
|
5795
|
+
function OmitFromMappedResult(mappedResult, propertyKeys, options) {
|
|
5796
|
+
const properties = FromMappedResult9(mappedResult, propertyKeys, options);
|
|
5797
|
+
return MappedResult(properties);
|
|
5798
|
+
}
|
|
5799
|
+
|
|
5800
|
+
// node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
|
|
5801
|
+
function FromIntersect6(types, propertyKeys) {
|
|
5802
|
+
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
5803
|
+
}
|
|
5804
|
+
function FromUnion8(types, propertyKeys) {
|
|
5805
|
+
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
5806
|
+
}
|
|
5807
|
+
function FromProperty3(properties, key) {
|
|
5808
|
+
const { [key]: _, ...R } = properties;
|
|
5809
|
+
return R;
|
|
5810
|
+
}
|
|
5811
|
+
function FromProperties13(properties, propertyKeys) {
|
|
5812
|
+
return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
|
|
5813
|
+
}
|
|
5814
|
+
function FromObject3(type, propertyKeys, properties) {
|
|
5815
|
+
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
5816
|
+
const mappedProperties = FromProperties13(properties, propertyKeys);
|
|
5817
|
+
return Object2(mappedProperties, options);
|
|
5818
|
+
}
|
|
5819
|
+
function UnionFromPropertyKeys(propertyKeys) {
|
|
5820
|
+
const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
|
|
5821
|
+
return Union(result);
|
|
5822
|
+
}
|
|
5823
|
+
function OmitResolve(type, propertyKeys) {
|
|
5824
|
+
return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
|
|
5825
|
+
}
|
|
5826
|
+
function Omit(type, key, options) {
|
|
5827
|
+
const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
|
|
5828
|
+
const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
5829
|
+
const isTypeRef = IsRef(type);
|
|
5830
|
+
const isKeyRef = IsRef(key);
|
|
5831
|
+
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 });
|
|
5832
|
+
}
|
|
5833
|
+
|
|
5834
|
+
// node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
|
|
5835
|
+
function FromPropertyKey2(type, key, options) {
|
|
5836
|
+
return { [key]: Omit(type, [key], Clone(options)) };
|
|
5837
|
+
}
|
|
5838
|
+
function FromPropertyKeys2(type, propertyKeys, options) {
|
|
5839
|
+
return propertyKeys.reduce((Acc, LK) => {
|
|
5840
|
+
return { ...Acc, ...FromPropertyKey2(type, LK, options) };
|
|
5841
|
+
}, {});
|
|
5842
|
+
}
|
|
5843
|
+
function FromMappedKey3(type, mappedKey, options) {
|
|
5844
|
+
return FromPropertyKeys2(type, mappedKey.keys, options);
|
|
5845
|
+
}
|
|
5846
|
+
function OmitFromMappedKey(type, mappedKey, options) {
|
|
5847
|
+
const properties = FromMappedKey3(type, mappedKey, options);
|
|
5848
|
+
return MappedResult(properties);
|
|
5849
|
+
}
|
|
5850
|
+
|
|
5851
|
+
// node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
|
|
5852
|
+
function FromProperties14(properties, propertyKeys, options) {
|
|
5853
|
+
const result = {};
|
|
5854
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
5855
|
+
result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
|
|
5856
|
+
return result;
|
|
5857
|
+
}
|
|
5858
|
+
function FromMappedResult10(mappedResult, propertyKeys, options) {
|
|
5859
|
+
return FromProperties14(mappedResult.properties, propertyKeys, options);
|
|
5860
|
+
}
|
|
5861
|
+
function PickFromMappedResult(mappedResult, propertyKeys, options) {
|
|
5862
|
+
const properties = FromMappedResult10(mappedResult, propertyKeys, options);
|
|
5863
|
+
return MappedResult(properties);
|
|
5864
|
+
}
|
|
5865
|
+
|
|
5866
|
+
// node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
|
|
5867
|
+
function FromIntersect7(types, propertyKeys) {
|
|
5868
|
+
return types.map((type) => PickResolve(type, propertyKeys));
|
|
5869
|
+
}
|
|
5870
|
+
function FromUnion9(types, propertyKeys) {
|
|
5871
|
+
return types.map((type) => PickResolve(type, propertyKeys));
|
|
5872
|
+
}
|
|
5873
|
+
function FromProperties15(properties, propertyKeys) {
|
|
5874
|
+
const result = {};
|
|
5875
|
+
for (const K2 of propertyKeys)
|
|
5876
|
+
if (K2 in properties)
|
|
5877
|
+
result[K2] = properties[K2];
|
|
5878
|
+
return result;
|
|
5879
|
+
}
|
|
5880
|
+
function FromObject4(Type2, keys, properties) {
|
|
5881
|
+
const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
|
|
5882
|
+
const mappedProperties = FromProperties15(properties, keys);
|
|
5883
|
+
return Object2(mappedProperties, options);
|
|
5884
|
+
}
|
|
5885
|
+
function UnionFromPropertyKeys2(propertyKeys) {
|
|
5886
|
+
const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
|
|
5887
|
+
return Union(result);
|
|
5888
|
+
}
|
|
5889
|
+
function PickResolve(type, propertyKeys) {
|
|
5890
|
+
return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
|
|
5891
|
+
}
|
|
5892
|
+
function Pick(type, key, options) {
|
|
5893
|
+
const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
|
|
5894
|
+
const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
|
|
5895
|
+
const isTypeRef = IsRef(type);
|
|
5896
|
+
const isKeyRef = IsRef(key);
|
|
5897
|
+
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 });
|
|
5898
|
+
}
|
|
5899
|
+
|
|
5900
|
+
// node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
|
|
5901
|
+
function FromPropertyKey3(type, key, options) {
|
|
5902
|
+
return {
|
|
5903
|
+
[key]: Pick(type, [key], Clone(options))
|
|
5904
|
+
};
|
|
5905
|
+
}
|
|
5906
|
+
function FromPropertyKeys3(type, propertyKeys, options) {
|
|
5907
|
+
return propertyKeys.reduce((result, leftKey) => {
|
|
5908
|
+
return { ...result, ...FromPropertyKey3(type, leftKey, options) };
|
|
5909
|
+
}, {});
|
|
5910
|
+
}
|
|
5911
|
+
function FromMappedKey4(type, mappedKey, options) {
|
|
5912
|
+
return FromPropertyKeys3(type, mappedKey.keys, options);
|
|
5913
|
+
}
|
|
5914
|
+
function PickFromMappedKey(type, mappedKey, options) {
|
|
5915
|
+
const properties = FromMappedKey4(type, mappedKey, options);
|
|
5916
|
+
return MappedResult(properties);
|
|
5917
|
+
}
|
|
5918
|
+
|
|
5919
|
+
// node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
|
|
5920
|
+
function FromComputed3(target, parameters) {
|
|
5921
|
+
return Computed("Partial", [Computed(target, parameters)]);
|
|
5922
|
+
}
|
|
5923
|
+
function FromRef3($ref) {
|
|
5924
|
+
return Computed("Partial", [Ref($ref)]);
|
|
5925
|
+
}
|
|
5926
|
+
function FromProperties16(properties) {
|
|
5927
|
+
const partialProperties = {};
|
|
5928
|
+
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
5929
|
+
partialProperties[K] = Optional(properties[K]);
|
|
5930
|
+
return partialProperties;
|
|
5931
|
+
}
|
|
5932
|
+
function FromObject5(type, properties) {
|
|
5933
|
+
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
5934
|
+
const mappedProperties = FromProperties16(properties);
|
|
5935
|
+
return Object2(mappedProperties, options);
|
|
5936
|
+
}
|
|
5937
|
+
function FromRest6(types) {
|
|
5938
|
+
return types.map((type) => PartialResolve(type));
|
|
5939
|
+
}
|
|
5940
|
+
function PartialResolve(type) {
|
|
5941
|
+
return (
|
|
5942
|
+
// Mappable
|
|
5943
|
+
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) : (
|
|
5944
|
+
// Intrinsic
|
|
5945
|
+
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 : (
|
|
5946
|
+
// Passthrough
|
|
5947
|
+
Object2({})
|
|
5948
|
+
)
|
|
5949
|
+
)
|
|
5950
|
+
);
|
|
5951
|
+
}
|
|
5952
|
+
function Partial(type, options) {
|
|
5953
|
+
if (IsMappedResult(type)) {
|
|
5954
|
+
return PartialFromMappedResult(type, options);
|
|
5955
|
+
} else {
|
|
5956
|
+
return CreateType({ ...PartialResolve(type), ...options });
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
|
|
5960
|
+
// node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
|
|
5961
|
+
function FromProperties17(K, options) {
|
|
5962
|
+
const Acc = {};
|
|
5963
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
5964
|
+
Acc[K2] = Partial(K[K2], Clone(options));
|
|
5965
|
+
return Acc;
|
|
5966
|
+
}
|
|
5967
|
+
function FromMappedResult11(R, options) {
|
|
5968
|
+
return FromProperties17(R.properties, options);
|
|
5969
|
+
}
|
|
5970
|
+
function PartialFromMappedResult(R, options) {
|
|
5971
|
+
const P = FromMappedResult11(R, options);
|
|
5972
|
+
return MappedResult(P);
|
|
5973
|
+
}
|
|
5974
|
+
|
|
5975
|
+
// node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
|
|
5976
|
+
function FromComputed4(target, parameters) {
|
|
5977
|
+
return Computed("Required", [Computed(target, parameters)]);
|
|
5978
|
+
}
|
|
5979
|
+
function FromRef4($ref) {
|
|
5980
|
+
return Computed("Required", [Ref($ref)]);
|
|
5981
|
+
}
|
|
5982
|
+
function FromProperties18(properties) {
|
|
5983
|
+
const requiredProperties = {};
|
|
5984
|
+
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
5985
|
+
requiredProperties[K] = Discard(properties[K], [OptionalKind]);
|
|
5986
|
+
return requiredProperties;
|
|
5987
|
+
}
|
|
5988
|
+
function FromObject6(type, properties) {
|
|
5989
|
+
const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
|
|
5990
|
+
const mappedProperties = FromProperties18(properties);
|
|
5991
|
+
return Object2(mappedProperties, options);
|
|
5992
|
+
}
|
|
5993
|
+
function FromRest7(types) {
|
|
5994
|
+
return types.map((type) => RequiredResolve(type));
|
|
5995
|
+
}
|
|
5996
|
+
function RequiredResolve(type) {
|
|
5997
|
+
return (
|
|
5998
|
+
// Mappable
|
|
5999
|
+
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) : (
|
|
6000
|
+
// Intrinsic
|
|
6001
|
+
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 : (
|
|
6002
|
+
// Passthrough
|
|
6003
|
+
Object2({})
|
|
6004
|
+
)
|
|
6005
|
+
)
|
|
6006
|
+
);
|
|
6007
|
+
}
|
|
6008
|
+
function Required(type, options) {
|
|
6009
|
+
if (IsMappedResult(type)) {
|
|
6010
|
+
return RequiredFromMappedResult(type, options);
|
|
6011
|
+
} else {
|
|
6012
|
+
return CreateType({ ...RequiredResolve(type), ...options });
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
|
|
6016
|
+
// node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
|
|
6017
|
+
function FromProperties19(P, options) {
|
|
6018
|
+
const Acc = {};
|
|
6019
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
6020
|
+
Acc[K2] = Required(P[K2], options);
|
|
6021
|
+
return Acc;
|
|
6022
|
+
}
|
|
6023
|
+
function FromMappedResult12(R, options) {
|
|
6024
|
+
return FromProperties19(R.properties, options);
|
|
6025
|
+
}
|
|
6026
|
+
function RequiredFromMappedResult(R, options) {
|
|
6027
|
+
const P = FromMappedResult12(R, options);
|
|
6028
|
+
return MappedResult(P);
|
|
6029
|
+
}
|
|
6030
|
+
|
|
6031
|
+
// node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
|
|
6032
|
+
function DereferenceParameters(moduleProperties, types) {
|
|
6033
|
+
return types.map((type) => {
|
|
6034
|
+
return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
|
|
6035
|
+
});
|
|
6036
|
+
}
|
|
6037
|
+
function Dereference(moduleProperties, ref) {
|
|
6038
|
+
return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
|
|
6039
|
+
}
|
|
6040
|
+
function FromAwaited(parameters) {
|
|
6041
|
+
return Awaited(parameters[0]);
|
|
6042
|
+
}
|
|
6043
|
+
function FromIndex(parameters) {
|
|
6044
|
+
return Index(parameters[0], parameters[1]);
|
|
6045
|
+
}
|
|
6046
|
+
function FromKeyOf(parameters) {
|
|
6047
|
+
return KeyOf(parameters[0]);
|
|
6048
|
+
}
|
|
6049
|
+
function FromPartial(parameters) {
|
|
6050
|
+
return Partial(parameters[0]);
|
|
6051
|
+
}
|
|
6052
|
+
function FromOmit(parameters) {
|
|
6053
|
+
return Omit(parameters[0], parameters[1]);
|
|
6054
|
+
}
|
|
6055
|
+
function FromPick(parameters) {
|
|
6056
|
+
return Pick(parameters[0], parameters[1]);
|
|
6057
|
+
}
|
|
6058
|
+
function FromRequired(parameters) {
|
|
6059
|
+
return Required(parameters[0]);
|
|
6060
|
+
}
|
|
6061
|
+
function FromComputed5(moduleProperties, target, parameters) {
|
|
6062
|
+
const dereferenced = DereferenceParameters(moduleProperties, parameters);
|
|
6063
|
+
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();
|
|
6064
|
+
}
|
|
6065
|
+
function FromArray6(moduleProperties, type) {
|
|
6066
|
+
return Array2(FromType2(moduleProperties, type));
|
|
6067
|
+
}
|
|
6068
|
+
function FromAsyncIterator3(moduleProperties, type) {
|
|
6069
|
+
return AsyncIterator(FromType2(moduleProperties, type));
|
|
6070
|
+
}
|
|
6071
|
+
function FromConstructor3(moduleProperties, parameters, instanceType) {
|
|
6072
|
+
return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
|
|
6073
|
+
}
|
|
6074
|
+
function FromFunction3(moduleProperties, parameters, returnType) {
|
|
6075
|
+
return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
|
|
6076
|
+
}
|
|
6077
|
+
function FromIntersect8(moduleProperties, types) {
|
|
6078
|
+
return Intersect(FromTypes2(moduleProperties, types));
|
|
6079
|
+
}
|
|
6080
|
+
function FromIterator3(moduleProperties, type) {
|
|
6081
|
+
return Iterator(FromType2(moduleProperties, type));
|
|
6082
|
+
}
|
|
6083
|
+
function FromObject7(moduleProperties, properties) {
|
|
6084
|
+
return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
|
|
6085
|
+
return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
|
|
6086
|
+
}, {}));
|
|
6087
|
+
}
|
|
6088
|
+
function FromRecord3(moduleProperties, type) {
|
|
6089
|
+
const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
|
|
6090
|
+
const result = CloneType(type);
|
|
6091
|
+
result.patternProperties[pattern] = value;
|
|
6092
|
+
return result;
|
|
6093
|
+
}
|
|
6094
|
+
function FromTransform(moduleProperties, transform) {
|
|
6095
|
+
return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
|
|
6096
|
+
}
|
|
6097
|
+
function FromTuple5(moduleProperties, types) {
|
|
6098
|
+
return Tuple(FromTypes2(moduleProperties, types));
|
|
6099
|
+
}
|
|
6100
|
+
function FromUnion10(moduleProperties, types) {
|
|
6101
|
+
return Union(FromTypes2(moduleProperties, types));
|
|
6102
|
+
}
|
|
6103
|
+
function FromTypes2(moduleProperties, types) {
|
|
6104
|
+
return types.map((type) => FromType2(moduleProperties, type));
|
|
6105
|
+
}
|
|
6106
|
+
function FromType2(moduleProperties, type) {
|
|
6107
|
+
return (
|
|
6108
|
+
// Modifiers
|
|
6109
|
+
IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
|
|
6110
|
+
// Transform
|
|
6111
|
+
IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
|
|
6112
|
+
// Types
|
|
6113
|
+
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
|
|
6114
|
+
)
|
|
6115
|
+
)
|
|
6116
|
+
);
|
|
6117
|
+
}
|
|
6118
|
+
function ComputeType(moduleProperties, key) {
|
|
6119
|
+
return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
|
|
6120
|
+
}
|
|
6121
|
+
function ComputeModuleProperties(moduleProperties) {
|
|
6122
|
+
return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
|
|
6123
|
+
return { ...result, [key]: ComputeType(moduleProperties, key) };
|
|
6124
|
+
}, {});
|
|
6125
|
+
}
|
|
6126
|
+
|
|
6127
|
+
// node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
|
|
6128
|
+
var TModule = class {
|
|
6129
|
+
constructor($defs) {
|
|
6130
|
+
const computed = ComputeModuleProperties($defs);
|
|
6131
|
+
const identified = this.WithIdentifiers(computed);
|
|
6132
|
+
this.$defs = identified;
|
|
6133
|
+
}
|
|
6134
|
+
/** `[Json]` Imports a Type by Key. */
|
|
6135
|
+
Import(key, options) {
|
|
6136
|
+
const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
|
|
6137
|
+
return CreateType({ [Kind]: "Import", $defs, $ref: key });
|
|
6138
|
+
}
|
|
6139
|
+
// prettier-ignore
|
|
6140
|
+
WithIdentifiers($defs) {
|
|
6141
|
+
return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
|
|
6142
|
+
return { ...result, [key]: { ...$defs[key], $id: key } };
|
|
6143
|
+
}, {});
|
|
6144
|
+
}
|
|
6145
|
+
};
|
|
6146
|
+
function Module(properties) {
|
|
6147
|
+
return new TModule(properties);
|
|
6148
|
+
}
|
|
6149
|
+
|
|
6150
|
+
// node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
|
|
6151
|
+
function Not(type, options) {
|
|
6152
|
+
return CreateType({ [Kind]: "Not", not: type }, options);
|
|
6153
|
+
}
|
|
6154
|
+
|
|
6155
|
+
// node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
|
|
6156
|
+
function Parameters(schema, options) {
|
|
6157
|
+
return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
|
|
6158
|
+
}
|
|
6159
|
+
|
|
6160
|
+
// node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
|
|
6161
|
+
var Ordinal = 0;
|
|
6162
|
+
function Recursive(callback, options = {}) {
|
|
6163
|
+
if (IsUndefined(options.$id))
|
|
6164
|
+
options.$id = `T${Ordinal++}`;
|
|
6165
|
+
const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
|
|
6166
|
+
thisType.$id = options.$id;
|
|
6167
|
+
return CreateType({ [Hint]: "Recursive", ...thisType }, options);
|
|
6168
|
+
}
|
|
6169
|
+
|
|
6170
|
+
// node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
|
|
6171
|
+
function RegExp2(unresolved, options) {
|
|
6172
|
+
const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
|
|
6173
|
+
return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
|
|
6174
|
+
}
|
|
6175
|
+
|
|
6176
|
+
// node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
|
|
6177
|
+
function RestResolve(T) {
|
|
6178
|
+
return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
|
|
6179
|
+
}
|
|
6180
|
+
function Rest(T) {
|
|
6181
|
+
return RestResolve(T);
|
|
6182
|
+
}
|
|
6183
|
+
|
|
6184
|
+
// node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
|
|
6185
|
+
function ReturnType(schema, options) {
|
|
6186
|
+
return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
|
|
6187
|
+
}
|
|
6188
|
+
|
|
6189
|
+
// node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
|
|
6190
|
+
var TransformDecodeBuilder = class {
|
|
6191
|
+
constructor(schema) {
|
|
6192
|
+
this.schema = schema;
|
|
6193
|
+
}
|
|
6194
|
+
Decode(decode) {
|
|
6195
|
+
return new TransformEncodeBuilder(this.schema, decode);
|
|
6196
|
+
}
|
|
6197
|
+
};
|
|
6198
|
+
var TransformEncodeBuilder = class {
|
|
6199
|
+
constructor(schema, decode) {
|
|
6200
|
+
this.schema = schema;
|
|
6201
|
+
this.decode = decode;
|
|
6202
|
+
}
|
|
6203
|
+
EncodeTransform(encode, schema) {
|
|
6204
|
+
const Encode = (value) => schema[TransformKind].Encode(encode(value));
|
|
6205
|
+
const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
|
|
6206
|
+
const Codec = { Encode, Decode };
|
|
6207
|
+
return { ...schema, [TransformKind]: Codec };
|
|
6208
|
+
}
|
|
6209
|
+
EncodeSchema(encode, schema) {
|
|
6210
|
+
const Codec = { Decode: this.decode, Encode: encode };
|
|
6211
|
+
return { ...schema, [TransformKind]: Codec };
|
|
6212
|
+
}
|
|
6213
|
+
Encode(encode) {
|
|
6214
|
+
return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
|
|
6215
|
+
}
|
|
6216
|
+
};
|
|
6217
|
+
function Transform(schema) {
|
|
6218
|
+
return new TransformDecodeBuilder(schema);
|
|
6219
|
+
}
|
|
6220
|
+
|
|
6221
|
+
// node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
|
|
6222
|
+
function Unsafe(options = {}) {
|
|
6223
|
+
return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
|
|
6224
|
+
}
|
|
6225
|
+
|
|
6226
|
+
// node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
|
|
6227
|
+
function Void(options) {
|
|
6228
|
+
return CreateType({ [Kind]: "Void", type: "void" }, options);
|
|
6229
|
+
}
|
|
6230
|
+
|
|
6231
|
+
// node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
|
|
6232
|
+
var type_exports2 = {};
|
|
6233
|
+
__export(type_exports2, {
|
|
6234
|
+
Any: () => Any,
|
|
6235
|
+
Argument: () => Argument2,
|
|
6236
|
+
Array: () => Array2,
|
|
6237
|
+
AsyncIterator: () => AsyncIterator,
|
|
6238
|
+
Awaited: () => Awaited,
|
|
6239
|
+
BigInt: () => BigInt,
|
|
6240
|
+
Boolean: () => Boolean2,
|
|
6241
|
+
Capitalize: () => Capitalize,
|
|
6242
|
+
Composite: () => Composite,
|
|
6243
|
+
Const: () => Const,
|
|
6244
|
+
Constructor: () => Constructor,
|
|
6245
|
+
ConstructorParameters: () => ConstructorParameters,
|
|
6246
|
+
Date: () => Date2,
|
|
6247
|
+
Enum: () => Enum,
|
|
6248
|
+
Exclude: () => Exclude,
|
|
6249
|
+
Extends: () => Extends,
|
|
6250
|
+
Extract: () => Extract,
|
|
6251
|
+
Function: () => Function,
|
|
6252
|
+
Index: () => Index,
|
|
6253
|
+
InstanceType: () => InstanceType,
|
|
6254
|
+
Instantiate: () => Instantiate,
|
|
6255
|
+
Integer: () => Integer,
|
|
6256
|
+
Intersect: () => Intersect,
|
|
6257
|
+
Iterator: () => Iterator,
|
|
6258
|
+
KeyOf: () => KeyOf,
|
|
6259
|
+
Literal: () => Literal,
|
|
6260
|
+
Lowercase: () => Lowercase,
|
|
6261
|
+
Mapped: () => Mapped,
|
|
6262
|
+
Module: () => Module,
|
|
6263
|
+
Never: () => Never,
|
|
6264
|
+
Not: () => Not,
|
|
6265
|
+
Null: () => Null,
|
|
6266
|
+
Number: () => Number2,
|
|
6267
|
+
Object: () => Object2,
|
|
6268
|
+
Omit: () => Omit,
|
|
6269
|
+
Optional: () => Optional,
|
|
6270
|
+
Parameters: () => Parameters,
|
|
6271
|
+
Partial: () => Partial,
|
|
6272
|
+
Pick: () => Pick,
|
|
6273
|
+
Promise: () => Promise2,
|
|
6274
|
+
Readonly: () => Readonly,
|
|
6275
|
+
ReadonlyOptional: () => ReadonlyOptional,
|
|
6276
|
+
Record: () => Record,
|
|
6277
|
+
Recursive: () => Recursive,
|
|
6278
|
+
Ref: () => Ref,
|
|
6279
|
+
RegExp: () => RegExp2,
|
|
6280
|
+
Required: () => Required,
|
|
6281
|
+
Rest: () => Rest,
|
|
6282
|
+
ReturnType: () => ReturnType,
|
|
6283
|
+
String: () => String2,
|
|
6284
|
+
Symbol: () => Symbol2,
|
|
6285
|
+
TemplateLiteral: () => TemplateLiteral,
|
|
6286
|
+
Transform: () => Transform,
|
|
6287
|
+
Tuple: () => Tuple,
|
|
6288
|
+
Uint8Array: () => Uint8Array2,
|
|
6289
|
+
Uncapitalize: () => Uncapitalize,
|
|
6290
|
+
Undefined: () => Undefined,
|
|
6291
|
+
Union: () => Union,
|
|
6292
|
+
Unknown: () => Unknown,
|
|
6293
|
+
Unsafe: () => Unsafe,
|
|
6294
|
+
Uppercase: () => Uppercase,
|
|
6295
|
+
Void: () => Void
|
|
6296
|
+
});
|
|
6297
|
+
|
|
6298
|
+
// node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
|
|
6299
|
+
var Type = type_exports2;
|
|
6300
|
+
|
|
6301
|
+
// src/protocol/pi-identity.ts
|
|
6302
|
+
var MANAGED_PI_ARTIFACT_ID = "@earendil-works/pi-coding-agent@0.80.10";
|
|
6303
|
+
var PiRuntimeIdentitySchema = Type.Union([
|
|
6304
|
+
Type.Object(
|
|
6305
|
+
{
|
|
6306
|
+
mode: Type.Literal("managed"),
|
|
6307
|
+
artifactId: Type.String({ minLength: 1 })
|
|
6308
|
+
},
|
|
6309
|
+
{ additionalProperties: false }
|
|
6310
|
+
),
|
|
6311
|
+
Type.Object(
|
|
6312
|
+
{
|
|
6313
|
+
mode: Type.Literal("external"),
|
|
6314
|
+
selectedPath: Type.String({ minLength: 1 }),
|
|
6315
|
+
nodePath: Type.String({ minLength: 1 }),
|
|
6316
|
+
realPath: Type.String({ minLength: 1 }),
|
|
6317
|
+
version: Type.String({ minLength: 1 }),
|
|
6318
|
+
fingerprint: Type.String({ minLength: 1 })
|
|
6319
|
+
},
|
|
6320
|
+
{ additionalProperties: false }
|
|
6321
|
+
)
|
|
6322
|
+
]);
|
|
6323
|
+
var MANAGED_PI_RUNTIME_IDENTITY = Object.freeze({
|
|
6324
|
+
mode: "managed",
|
|
6325
|
+
artifactId: MANAGED_PI_ARTIFACT_ID
|
|
6326
|
+
});
|
|
6327
|
+
|
|
6328
|
+
// src/client/socket-fleet-client.ts
|
|
6329
|
+
var SocketFleetClient = class {
|
|
6330
|
+
constructor(options) {
|
|
6331
|
+
this.options = options;
|
|
6332
|
+
}
|
|
6333
|
+
create(input, options) {
|
|
6334
|
+
return this.#request("agent.create", input, options);
|
|
6335
|
+
}
|
|
6336
|
+
send(input, options) {
|
|
6337
|
+
return this.#request("agent.send", input, options);
|
|
6338
|
+
}
|
|
6339
|
+
receive(input, options) {
|
|
6340
|
+
return this.#request("agent.receive", { ...input, timeoutMs: options.timeoutMs }, options);
|
|
6341
|
+
}
|
|
6342
|
+
status(input, options) {
|
|
6343
|
+
return this.#request("agent.status", input, options);
|
|
6344
|
+
}
|
|
6345
|
+
list(options) {
|
|
6346
|
+
return this.#request("agent.list", {}, options);
|
|
6347
|
+
}
|
|
6348
|
+
async *watch(input, options) {
|
|
6349
|
+
let socket;
|
|
6350
|
+
try {
|
|
6351
|
+
await this.options.beforeConnect?.();
|
|
6352
|
+
socket = await connect(this.options.socketPath, options.signal);
|
|
6353
|
+
} catch (error) {
|
|
6354
|
+
yield err(connectionError(error));
|
|
6355
|
+
return;
|
|
6356
|
+
}
|
|
6357
|
+
const requestId = randomUUID();
|
|
6358
|
+
const frames = frameIterator(socket, options.signal);
|
|
6359
|
+
writeJsonLine(socket, {
|
|
6360
|
+
v: PROTOCOL_VERSION,
|
|
6361
|
+
requestId,
|
|
6362
|
+
method: "agent.watch",
|
|
6363
|
+
params: input
|
|
6364
|
+
});
|
|
6365
|
+
let endedExplicitly = false;
|
|
6366
|
+
try {
|
|
6367
|
+
for await (const frame of frames) {
|
|
6368
|
+
if (!isRecord(frame) || frame.requestId !== requestId) continue;
|
|
6369
|
+
if (frame.v !== PROTOCOL_VERSION) {
|
|
6370
|
+
yield err({
|
|
6371
|
+
code: "protocol_incompatible",
|
|
6372
|
+
message: "The running pi-fleet runtime is incompatible with this client; repair or restart it."
|
|
6373
|
+
});
|
|
6374
|
+
return;
|
|
6375
|
+
}
|
|
6376
|
+
if (frame.stream === "ready") {
|
|
6377
|
+
yield ok({ type: "ready" });
|
|
6378
|
+
continue;
|
|
6379
|
+
}
|
|
6380
|
+
if (frame.stream === "end") {
|
|
6381
|
+
endedExplicitly = true;
|
|
6382
|
+
return;
|
|
6383
|
+
}
|
|
6384
|
+
if (frame.stream === "chunk" && typeof frame.data === "string") {
|
|
6385
|
+
yield ok({ type: "chunk", bytes: Buffer.from(frame.data, "base64") });
|
|
6386
|
+
continue;
|
|
6387
|
+
}
|
|
6388
|
+
if (frame.stream === "error" && isErrorRecord(frame.error)) {
|
|
6389
|
+
yield err(frame.error);
|
|
6390
|
+
return;
|
|
6391
|
+
}
|
|
6392
|
+
yield err({ code: "protocol_error", message: "Invalid watch stream frame." });
|
|
6393
|
+
return;
|
|
6394
|
+
}
|
|
6395
|
+
if (!endedExplicitly && !options.signal.aborted) {
|
|
6396
|
+
yield err({
|
|
6397
|
+
code: "runtime_unavailable",
|
|
6398
|
+
message: "Runtime connection closed before the watch stream ended."
|
|
6399
|
+
});
|
|
6400
|
+
}
|
|
6401
|
+
} catch (error) {
|
|
6402
|
+
if (!options.signal.aborted) yield err(connectionError(error));
|
|
6403
|
+
} finally {
|
|
6404
|
+
socket.destroy();
|
|
6405
|
+
}
|
|
6406
|
+
}
|
|
6407
|
+
destroy(input, options) {
|
|
6408
|
+
return this.#request("agent.destroy", input, options);
|
|
6409
|
+
}
|
|
6410
|
+
compact(input, options) {
|
|
6411
|
+
return this.#request("agent.compact", input, options);
|
|
6412
|
+
}
|
|
6413
|
+
async #request(method, params, options) {
|
|
6414
|
+
let socket;
|
|
6415
|
+
try {
|
|
6416
|
+
await this.options.beforeConnect?.();
|
|
6417
|
+
socket = await connect(this.options.socketPath, options.signal);
|
|
6418
|
+
} catch (error) {
|
|
6419
|
+
return err(connectionError(error));
|
|
6420
|
+
}
|
|
6421
|
+
const requestId = randomUUID();
|
|
6422
|
+
let piIdentity;
|
|
6423
|
+
try {
|
|
6424
|
+
piIdentity = requiresPiIdentity(method) ? await this.#piIdentity() : void 0;
|
|
6425
|
+
} catch (error) {
|
|
6426
|
+
socket.destroy();
|
|
6427
|
+
return err(piSelectionError(error));
|
|
6428
|
+
}
|
|
6429
|
+
const response = firstMatchingFrame(socket, requestId, options.signal);
|
|
6430
|
+
writeJsonLine(socket, {
|
|
6431
|
+
v: PROTOCOL_VERSION,
|
|
6432
|
+
requestId,
|
|
6433
|
+
method,
|
|
6434
|
+
params,
|
|
6435
|
+
...isMutationOptions(options) ? { operation: options.operation } : {},
|
|
6436
|
+
...piIdentity === void 0 ? {} : { runtime: { pi: piIdentity } }
|
|
6437
|
+
});
|
|
6438
|
+
try {
|
|
6439
|
+
const frame = await response;
|
|
6440
|
+
if (!isRecord(frame) || frame.requestId !== requestId || typeof frame.ok !== "boolean") {
|
|
6441
|
+
return err({ code: "protocol_error", message: "Invalid runtime response." });
|
|
6442
|
+
}
|
|
6443
|
+
if (frame.v !== PROTOCOL_VERSION) {
|
|
6444
|
+
return err({
|
|
6445
|
+
code: "protocol_incompatible",
|
|
6446
|
+
message: "The running pi-fleet runtime is incompatible with this client; repair or restart it."
|
|
6447
|
+
});
|
|
6448
|
+
}
|
|
6449
|
+
if (frame.ok) return ok(frame.result);
|
|
6450
|
+
if (method === "agent.compact" && isErrorRecord(frame.error) && frame.error.code === "invalid_request" && frame.error.message === "Invalid protocol request: /method") {
|
|
6451
|
+
return err({
|
|
6452
|
+
code: "protocol_incompatible",
|
|
6453
|
+
message: "The running pi-fleet runtime does not support compact; upgrade or repair it."
|
|
6454
|
+
});
|
|
6455
|
+
}
|
|
6456
|
+
if (isErrorRecord(frame.error)) return err(frame.error);
|
|
6457
|
+
return err({ code: "protocol_error", message: "Runtime returned an invalid error." });
|
|
6458
|
+
} catch (error) {
|
|
6459
|
+
return err(connectionError(error));
|
|
6460
|
+
} finally {
|
|
6461
|
+
socket.destroy();
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
async #piIdentity() {
|
|
6465
|
+
const configured = this.options.piIdentity;
|
|
6466
|
+
if (configured === void 0) return MANAGED_PI_RUNTIME_IDENTITY;
|
|
6467
|
+
return typeof configured === "function" ? configured() : configured;
|
|
6468
|
+
}
|
|
6469
|
+
};
|
|
6470
|
+
function piSelectionError(error) {
|
|
6471
|
+
const code = error.code;
|
|
6472
|
+
if (code === "pi_not_found" || code === "pi_not_executable" || code === "pi_version_unavailable" || code === "pi_version_unsupported" || code === "pi_installation_changed" || code === "pi_service_mismatch") {
|
|
6473
|
+
return { code, message: error instanceof Error ? error.message : "Pi is unavailable." };
|
|
6474
|
+
}
|
|
6475
|
+
return { code: "internal_error", message: "Pi selection failed." };
|
|
6476
|
+
}
|
|
6477
|
+
function isMutationOptions(options) {
|
|
6478
|
+
return "operation" in options;
|
|
6479
|
+
}
|
|
6480
|
+
function requiresPiIdentity(method) {
|
|
6481
|
+
return method === "agent.create" || method === "agent.send" || method === "agent.compact";
|
|
6482
|
+
}
|
|
6483
|
+
function connect(socketPath, signal) {
|
|
6484
|
+
return new Promise((resolveConnect, rejectConnect) => {
|
|
6485
|
+
if (signal.aborted) {
|
|
6486
|
+
rejectConnect(new Error("Request cancelled"));
|
|
6487
|
+
return;
|
|
6488
|
+
}
|
|
6489
|
+
const socket = createConnection(socketPath);
|
|
6490
|
+
const onAbort = () => socket.destroy(new Error("Request cancelled"));
|
|
6491
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
6492
|
+
socket.once("connect", () => {
|
|
6493
|
+
signal.removeEventListener("abort", onAbort);
|
|
6494
|
+
resolveConnect(socket);
|
|
6495
|
+
});
|
|
6496
|
+
socket.once("error", rejectConnect);
|
|
6497
|
+
});
|
|
6498
|
+
}
|
|
6499
|
+
function firstMatchingFrame(socket, requestId, signal) {
|
|
6500
|
+
return new Promise((resolveFrame, rejectFrame) => {
|
|
6501
|
+
let settled = false;
|
|
6502
|
+
const finish = (action) => {
|
|
6503
|
+
if (settled) return;
|
|
6504
|
+
settled = true;
|
|
6505
|
+
stop();
|
|
6506
|
+
signal.removeEventListener("abort", onAbort);
|
|
6507
|
+
action();
|
|
6508
|
+
};
|
|
6509
|
+
const stop = readJsonLines(
|
|
6510
|
+
socket,
|
|
6511
|
+
(frame) => {
|
|
6512
|
+
if (!isRecord(frame) || frame.requestId !== requestId) return;
|
|
6513
|
+
finish(() => resolveFrame(frame));
|
|
6514
|
+
},
|
|
6515
|
+
(error) => finish(() => rejectFrame(error))
|
|
6516
|
+
);
|
|
6517
|
+
const onAbort = () => finish(() => rejectFrame(new Error("Request cancelled")));
|
|
6518
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
6519
|
+
socket.once(
|
|
6520
|
+
"close",
|
|
6521
|
+
() => finish(() => rejectFrame(new Error("Runtime connection closed before responding")))
|
|
6522
|
+
);
|
|
6523
|
+
});
|
|
6524
|
+
}
|
|
6525
|
+
async function* frameIterator(socket, signal, maxQueuedBytes = 1024 * 1024) {
|
|
6526
|
+
const queue = [];
|
|
6527
|
+
let queuedBytes = 0;
|
|
6528
|
+
let paused = false;
|
|
6529
|
+
let ended = false;
|
|
6530
|
+
let failure = null;
|
|
6531
|
+
let wake = null;
|
|
3811
6532
|
const notify = () => {
|
|
3812
6533
|
wake?.();
|
|
3813
6534
|
wake = null;
|
|
@@ -3873,32 +6594,268 @@ function isErrorRecord(value) {
|
|
|
3873
6594
|
function connectionError(error) {
|
|
3874
6595
|
return {
|
|
3875
6596
|
code: "runtime_unavailable",
|
|
3876
|
-
message: error instanceof Error ? error.message : "Unable to connect to
|
|
6597
|
+
message: error instanceof Error ? error.message : "Unable to connect to pi-fleet runtime."
|
|
6598
|
+
};
|
|
6599
|
+
}
|
|
6600
|
+
|
|
6601
|
+
// src/pi/external-installation.ts
|
|
6602
|
+
import { spawn } from "node:child_process";
|
|
6603
|
+
import { createHash } from "node:crypto";
|
|
6604
|
+
import { constants } from "node:fs";
|
|
6605
|
+
import { createReadStream } from "node:fs";
|
|
6606
|
+
import { access, realpath, stat } from "node:fs/promises";
|
|
6607
|
+
import { delimiter, dirname, isAbsolute, join } from "node:path";
|
|
6608
|
+
var VERSION_TIMEOUT_MS = 3e3;
|
|
6609
|
+
var MAX_VERSION_OUTPUT_BYTES = 4 * 1024;
|
|
6610
|
+
var ExternalPiResolutionError = class extends Error {
|
|
6611
|
+
constructor(code, message) {
|
|
6612
|
+
super(message);
|
|
6613
|
+
this.code = code;
|
|
6614
|
+
this.name = "ExternalPiResolutionError";
|
|
6615
|
+
}
|
|
6616
|
+
};
|
|
6617
|
+
async function resolveExternalPiInstallation(options = {}) {
|
|
6618
|
+
const env = options.env ?? process.env;
|
|
6619
|
+
const selectedPath = await resolveSelectedPath(env);
|
|
6620
|
+
const nodePath = options.nodePath ?? await resolveNodePath(env);
|
|
6621
|
+
await inspectNode(nodePath);
|
|
6622
|
+
const executionEnv = externalPiExecutionEnvironment(env, selectedPath, nodePath);
|
|
6623
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
6624
|
+
const observation = await observeInstallation(selectedPath, executionEnv, options);
|
|
6625
|
+
if (observation !== null) {
|
|
6626
|
+
return {
|
|
6627
|
+
selectedPath,
|
|
6628
|
+
nodePath,
|
|
6629
|
+
...observation
|
|
6630
|
+
};
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
throw new ExternalPiResolutionError(
|
|
6634
|
+
"pi_installation_changed",
|
|
6635
|
+
"Pi changed while its installation was being observed."
|
|
6636
|
+
);
|
|
6637
|
+
}
|
|
6638
|
+
function externalPiExecutionEnvironment(env, selectedPath, nodePath) {
|
|
6639
|
+
return {
|
|
6640
|
+
...env,
|
|
6641
|
+
PATH: [dirname(nodePath), dirname(selectedPath), env.PATH].filter((value) => value !== void 0 && value.length > 0).join(delimiter)
|
|
6642
|
+
};
|
|
6643
|
+
}
|
|
6644
|
+
async function observeInstallation(selectedPath, env, options) {
|
|
6645
|
+
const beforeRealPath = await inspectExecutable(selectedPath, "Pi");
|
|
6646
|
+
const beforeHash = await hashFile(beforeRealPath);
|
|
6647
|
+
const versionOutput = await (options.versionCommand ?? ((executable) => readVersion(executable, env, options.versionTimeoutMs, options.maxVersionOutputBytes)))(selectedPath);
|
|
6648
|
+
const version = parseVersion(versionOutput);
|
|
6649
|
+
const afterRealPath = await inspectExecutable(selectedPath, "Pi");
|
|
6650
|
+
const afterHash = await hashFile(afterRealPath);
|
|
6651
|
+
if (beforeRealPath !== afterRealPath || beforeHash !== afterHash) return null;
|
|
6652
|
+
return {
|
|
6653
|
+
realPath: afterRealPath,
|
|
6654
|
+
version,
|
|
6655
|
+
fingerprint: createHash("sha256").update(JSON.stringify([selectedPath, afterRealPath, version, afterHash])).digest("hex")
|
|
6656
|
+
};
|
|
6657
|
+
}
|
|
6658
|
+
async function resolveSelectedPath(env) {
|
|
6659
|
+
const explicit = env.PIFLEET_PI_EXECUTABLE;
|
|
6660
|
+
if (explicit !== void 0) {
|
|
6661
|
+
if (!isAbsolute(explicit)) {
|
|
6662
|
+
throw new ExternalPiResolutionError(
|
|
6663
|
+
"invalid_arguments",
|
|
6664
|
+
"PIFLEET_PI_EXECUTABLE must be an absolute path."
|
|
6665
|
+
);
|
|
6666
|
+
}
|
|
6667
|
+
return explicit;
|
|
6668
|
+
}
|
|
6669
|
+
return resolvePathExecutable(env, "pi", "Pi", "pi_not_found");
|
|
6670
|
+
}
|
|
6671
|
+
async function resolveNodePath(env) {
|
|
6672
|
+
return resolvePathExecutable(env, "node", "Node", "pi_not_executable");
|
|
6673
|
+
}
|
|
6674
|
+
async function resolvePathExecutable(env, name, label, missingCode) {
|
|
6675
|
+
const path2 = env.PATH;
|
|
6676
|
+
if (path2 === void 0 || path2.length === 0) {
|
|
6677
|
+
throw new ExternalPiResolutionError(missingCode, `${label} was not found on PATH.`);
|
|
6678
|
+
}
|
|
6679
|
+
for (const directory of path2.split(delimiter)) {
|
|
6680
|
+
if (!isAbsolute(directory)) {
|
|
6681
|
+
throw new ExternalPiResolutionError(
|
|
6682
|
+
"invalid_arguments",
|
|
6683
|
+
`PATH entries used to select ${label} must be absolute paths.`
|
|
6684
|
+
);
|
|
6685
|
+
}
|
|
6686
|
+
const candidate = join(directory, name);
|
|
6687
|
+
try {
|
|
6688
|
+
await inspectExecutable(candidate, label);
|
|
6689
|
+
return candidate;
|
|
6690
|
+
} catch (error) {
|
|
6691
|
+
if (!(error instanceof ExternalPiResolutionError) || error.code !== "pi_not_executable" && error.code !== "pi_not_found") {
|
|
6692
|
+
throw error;
|
|
6693
|
+
}
|
|
6694
|
+
}
|
|
6695
|
+
}
|
|
6696
|
+
throw new ExternalPiResolutionError(missingCode, `${label} was not found on PATH.`);
|
|
6697
|
+
}
|
|
6698
|
+
async function inspectExecutable(path2, label) {
|
|
6699
|
+
try {
|
|
6700
|
+
const target = await realpath(path2);
|
|
6701
|
+
const metadata = await stat(target);
|
|
6702
|
+
if (!metadata.isFile()) {
|
|
6703
|
+
throw new ExternalPiResolutionError("pi_not_executable", `${label} is not a file: ${path2}`);
|
|
6704
|
+
}
|
|
6705
|
+
await access(path2, constants.X_OK);
|
|
6706
|
+
return target;
|
|
6707
|
+
} catch (error) {
|
|
6708
|
+
if (error instanceof ExternalPiResolutionError) throw error;
|
|
6709
|
+
if (error.code === "ENOENT") {
|
|
6710
|
+
throw new ExternalPiResolutionError("pi_not_found", `${label} was not found: ${path2}`);
|
|
6711
|
+
}
|
|
6712
|
+
throw new ExternalPiResolutionError("pi_not_executable", `${label} is not executable: ${path2}`);
|
|
6713
|
+
}
|
|
6714
|
+
}
|
|
6715
|
+
async function inspectNode(nodePath) {
|
|
6716
|
+
if (!isAbsolute(nodePath)) {
|
|
6717
|
+
throw new ExternalPiResolutionError("invalid_arguments", "Node must be an absolute path.");
|
|
6718
|
+
}
|
|
6719
|
+
try {
|
|
6720
|
+
await inspectExecutable(nodePath, "Node");
|
|
6721
|
+
} catch {
|
|
6722
|
+
throw new ExternalPiResolutionError("pi_not_executable", `Node is not executable: ${nodePath}`);
|
|
6723
|
+
}
|
|
6724
|
+
}
|
|
6725
|
+
async function hashFile(path2) {
|
|
6726
|
+
const hash = createHash("sha256");
|
|
6727
|
+
await new Promise((resolveHash, rejectHash) => {
|
|
6728
|
+
const stream = createReadStream(path2);
|
|
6729
|
+
stream.on("data", (chunk) => hash.update(chunk));
|
|
6730
|
+
stream.once("error", rejectHash);
|
|
6731
|
+
stream.once("end", resolveHash);
|
|
6732
|
+
});
|
|
6733
|
+
return hash.digest("hex");
|
|
6734
|
+
}
|
|
6735
|
+
async function readVersion(executable, env, timeoutMs = VERSION_TIMEOUT_MS, maxOutputBytes = MAX_VERSION_OUTPUT_BYTES) {
|
|
6736
|
+
const child = spawn(executable, ["--version"], {
|
|
6737
|
+
detached: process.platform !== "win32",
|
|
6738
|
+
env,
|
|
6739
|
+
shell: false,
|
|
6740
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
6741
|
+
});
|
|
6742
|
+
const chunks = [];
|
|
6743
|
+
let outputBytes = 0;
|
|
6744
|
+
let terminalError = null;
|
|
6745
|
+
let terminated = false;
|
|
6746
|
+
const terminate = () => {
|
|
6747
|
+
if (terminated) return;
|
|
6748
|
+
terminated = true;
|
|
6749
|
+
if (process.platform !== "win32" && child.pid !== void 0) {
|
|
6750
|
+
try {
|
|
6751
|
+
process.kill(-child.pid, "SIGKILL");
|
|
6752
|
+
return;
|
|
6753
|
+
} catch {
|
|
6754
|
+
}
|
|
6755
|
+
}
|
|
6756
|
+
child.kill("SIGKILL");
|
|
6757
|
+
};
|
|
6758
|
+
child.stdout.on("data", (chunk) => {
|
|
6759
|
+
if (terminalError !== null) return;
|
|
6760
|
+
outputBytes += chunk.byteLength;
|
|
6761
|
+
if (outputBytes > maxOutputBytes) {
|
|
6762
|
+
terminalError = new ExternalPiResolutionError(
|
|
6763
|
+
"pi_version_unavailable",
|
|
6764
|
+
"Pi version output exceeded its limit."
|
|
6765
|
+
);
|
|
6766
|
+
terminate();
|
|
6767
|
+
return;
|
|
6768
|
+
}
|
|
6769
|
+
chunks.push(chunk);
|
|
6770
|
+
});
|
|
6771
|
+
child.stderr.resume();
|
|
6772
|
+
return new Promise((resolveVersion, rejectVersion) => {
|
|
6773
|
+
const timer = setTimeout(() => {
|
|
6774
|
+
terminalError = new ExternalPiResolutionError(
|
|
6775
|
+
"pi_version_unavailable",
|
|
6776
|
+
"Pi version command timed out."
|
|
6777
|
+
);
|
|
6778
|
+
terminate();
|
|
6779
|
+
}, timeoutMs);
|
|
6780
|
+
child.once("error", () => {
|
|
6781
|
+
terminalError ??= new ExternalPiResolutionError(
|
|
6782
|
+
"pi_version_unavailable",
|
|
6783
|
+
"Pi version command failed."
|
|
6784
|
+
);
|
|
6785
|
+
});
|
|
6786
|
+
child.once("close", (code) => {
|
|
6787
|
+
clearTimeout(timer);
|
|
6788
|
+
if (terminalError !== null) {
|
|
6789
|
+
rejectVersion(terminalError);
|
|
6790
|
+
return;
|
|
6791
|
+
}
|
|
6792
|
+
if (code !== 0) {
|
|
6793
|
+
rejectVersion(
|
|
6794
|
+
new ExternalPiResolutionError("pi_version_unavailable", "Pi version command failed.")
|
|
6795
|
+
);
|
|
6796
|
+
return;
|
|
6797
|
+
}
|
|
6798
|
+
try {
|
|
6799
|
+
resolveVersion(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)));
|
|
6800
|
+
} catch {
|
|
6801
|
+
rejectVersion(
|
|
6802
|
+
new ExternalPiResolutionError(
|
|
6803
|
+
"pi_version_unavailable",
|
|
6804
|
+
"Pi version command returned invalid UTF-8."
|
|
6805
|
+
)
|
|
6806
|
+
);
|
|
6807
|
+
}
|
|
6808
|
+
});
|
|
6809
|
+
});
|
|
6810
|
+
}
|
|
6811
|
+
function parseVersion(output) {
|
|
6812
|
+
const match = /^(?:pi\s+)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\s*$/i.exec(output);
|
|
6813
|
+
if (match?.[1] === void 0) {
|
|
6814
|
+
throw new ExternalPiResolutionError(
|
|
6815
|
+
"pi_version_unavailable",
|
|
6816
|
+
"Pi version command returned an invalid version."
|
|
6817
|
+
);
|
|
6818
|
+
}
|
|
6819
|
+
return match[1];
|
|
6820
|
+
}
|
|
6821
|
+
|
|
6822
|
+
// src/pi/process.ts
|
|
6823
|
+
var DEFAULT_MAX_STDOUT_FRAME_BYTES = 8 * 1024 * 1024;
|
|
6824
|
+
|
|
6825
|
+
// src/pi/external-target.ts
|
|
6826
|
+
function installationIdentity(installation) {
|
|
6827
|
+
return {
|
|
6828
|
+
mode: "external",
|
|
6829
|
+
selectedPath: installation.selectedPath,
|
|
6830
|
+
nodePath: installation.nodePath,
|
|
6831
|
+
realPath: installation.realPath,
|
|
6832
|
+
version: installation.version,
|
|
6833
|
+
fingerprint: installation.fingerprint
|
|
3877
6834
|
};
|
|
3878
6835
|
}
|
|
3879
6836
|
|
|
3880
6837
|
// src/platform/client/start-runtime.ts
|
|
3881
|
-
import { execFile, spawn } from "node:child_process";
|
|
3882
|
-
import { access, readFile as readFile3 } from "node:fs/promises";
|
|
6838
|
+
import { execFile, spawn as spawn2 } from "node:child_process";
|
|
6839
|
+
import { access as access2, readFile as readFile3 } from "node:fs/promises";
|
|
3883
6840
|
import { createConnection as createConnection2 } from "node:net";
|
|
3884
6841
|
import { homedir as homedir2 } from "node:os";
|
|
3885
|
-
import { dirname, join as
|
|
6842
|
+
import { dirname as dirname2, join as join5, resolve as resolve5 } from "node:path";
|
|
3886
6843
|
import { fileURLToPath } from "node:url";
|
|
3887
6844
|
import { promisify } from "node:util";
|
|
3888
6845
|
|
|
3889
6846
|
// src/platform/install/runtime-release.ts
|
|
3890
|
-
import { createHash as
|
|
3891
|
-
import { chmod, cp, lstat as lstat2, mkdir, readFile as readFile2, rename, rm,
|
|
3892
|
-
import { join as
|
|
6847
|
+
import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
|
|
6848
|
+
import { chmod, cp, lstat as lstat2, mkdir, readFile as readFile2, rename, rm, writeFile } from "node:fs/promises";
|
|
6849
|
+
import { join as join3, posix, resolve as resolve3, sep as sep2 } from "node:path";
|
|
3893
6850
|
|
|
3894
6851
|
// src/platform/install/tree-integrity.ts
|
|
3895
|
-
import { createHash } from "node:crypto";
|
|
3896
|
-
import { lstat, readFile, readdir, stat } from "node:fs/promises";
|
|
3897
|
-
import { join, relative, resolve as resolve2, sep } from "node:path";
|
|
6852
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
6853
|
+
import { lstat, readFile, readdir, realpath as realpath2, stat as stat2 } from "node:fs/promises";
|
|
6854
|
+
import { join as join2, relative, resolve as resolve2, sep } from "node:path";
|
|
3898
6855
|
async function hashDirectoryTree(root, manifestPath) {
|
|
3899
6856
|
const resolvedRoot = resolve2(root);
|
|
3900
6857
|
const entries = await collectFiles(resolvedRoot, resolvedRoot);
|
|
3901
|
-
const hash =
|
|
6858
|
+
const hash = createHash2("sha256");
|
|
3902
6859
|
let bytes = 0;
|
|
3903
6860
|
for (const entry of entries) {
|
|
3904
6861
|
const contents = await readFile(entry.absolutePath);
|
|
@@ -3920,9 +6877,9 @@ async function hashDirectoryTree(root, manifestPath) {
|
|
|
3920
6877
|
async function collectFiles(root, directory) {
|
|
3921
6878
|
const output = [];
|
|
3922
6879
|
for (const name of (await readdir(directory)).sort()) {
|
|
3923
|
-
const absolutePath =
|
|
6880
|
+
const absolutePath = join2(directory, name);
|
|
3924
6881
|
const linkInfo = await lstat(absolutePath);
|
|
3925
|
-
const info = linkInfo.isSymbolicLink() ? await
|
|
6882
|
+
const info = linkInfo.isSymbolicLink() ? await stat2(absolutePath) : linkInfo;
|
|
3926
6883
|
if (info.isDirectory()) {
|
|
3927
6884
|
if (linkInfo.isSymbolicLink()) {
|
|
3928
6885
|
throw new Error(`Runtime dependency tree contains a directory symlink: ${absolutePath}`);
|
|
@@ -3933,6 +6890,14 @@ async function collectFiles(root, directory) {
|
|
|
3933
6890
|
if (!info.isFile()) {
|
|
3934
6891
|
throw new Error(`Runtime dependency tree contains an unsupported entry: ${absolutePath}`);
|
|
3935
6892
|
}
|
|
6893
|
+
if (linkInfo.isSymbolicLink()) {
|
|
6894
|
+
const target = await realpath2(absolutePath);
|
|
6895
|
+
if (target !== root && !target.startsWith(`${root}${sep}`)) {
|
|
6896
|
+
throw new Error(
|
|
6897
|
+
`Runtime dependency tree contains an external file symlink: ${absolutePath}`
|
|
6898
|
+
);
|
|
6899
|
+
}
|
|
6900
|
+
}
|
|
3936
6901
|
const relativePath = relative(root, absolutePath).split(sep).join("/");
|
|
3937
6902
|
if (relativePath.length === 0 || relativePath.startsWith("../")) {
|
|
3938
6903
|
throw new Error(`Runtime dependency path escapes its root: ${absolutePath}`);
|
|
@@ -3943,75 +6908,277 @@ async function collectFiles(root, directory) {
|
|
|
3943
6908
|
}
|
|
3944
6909
|
|
|
3945
6910
|
// src/platform/install/runtime-release.ts
|
|
6911
|
+
var requiredRuntimeArtifacts = /* @__PURE__ */ new Set([
|
|
6912
|
+
"package.json",
|
|
6913
|
+
"bin/pifleet.mjs",
|
|
6914
|
+
"bin/pifleet-runtime.mjs",
|
|
6915
|
+
"dist/cli.mjs",
|
|
6916
|
+
"dist/runtime.mjs",
|
|
6917
|
+
"dist/sqlite-worker.mjs"
|
|
6918
|
+
]);
|
|
6919
|
+
var dependencyTreePath = "node_modules";
|
|
3946
6920
|
async function materializeRuntime(options) {
|
|
3947
6921
|
const sourceRoot = resolve3(options.sourceRoot);
|
|
6922
|
+
const manifestBytes = await readFile2(join3(sourceRoot, "dist", "runtime-manifest.json"));
|
|
6923
|
+
const sourceManifest = await parseRuntimeManifest(manifestBytes, sourceRoot);
|
|
6924
|
+
if (sourceManifest.closure !== void 0) {
|
|
6925
|
+
await verifyRuntime(sourceRoot);
|
|
6926
|
+
return sourceRoot;
|
|
6927
|
+
}
|
|
6928
|
+
await verifyRuntimeFiles(sourceRoot, sourceManifest);
|
|
6929
|
+
await verifyDependencyIdentities(sourceRoot, sourceManifest.dependencies);
|
|
6930
|
+
const sourceTreeRoot = resolveInside(sourceRoot, dependencyTreePath);
|
|
6931
|
+
const sourceTreeBefore = await hashDirectoryTree(sourceTreeRoot, dependencyTreePath);
|
|
6932
|
+
const sourceManifestSha256 = createHash3("sha256").update(manifestBytes).digest("hex");
|
|
6933
|
+
const materializedManifest = {
|
|
6934
|
+
...sourceManifest,
|
|
6935
|
+
closure: { sourceManifestSha256, tree: sourceTreeBefore }
|
|
6936
|
+
};
|
|
6937
|
+
const materializedManifestBytes = serializeManifest(materializedManifest);
|
|
6938
|
+
const closureHash = createHash3("sha256").update(sourceManifestSha256).update("\0").update(JSON.stringify(sourceTreeBefore)).digest("hex").slice(0, 16);
|
|
3948
6939
|
const applicationRoot = resolve3(options.applicationRoot);
|
|
3949
6940
|
await ensurePrivateDirectory(applicationRoot);
|
|
3950
|
-
const
|
|
3951
|
-
const manifest = JSON.parse(manifestBytes.toString("utf8"));
|
|
3952
|
-
const manifestHash = createHash2("sha256").update(manifestBytes).digest("hex").slice(0, 16);
|
|
3953
|
-
const releasesRoot = join2(applicationRoot, "releases");
|
|
6941
|
+
const releasesRoot = join3(applicationRoot, "releases");
|
|
3954
6942
|
await ensurePrivateDirectory(releasesRoot);
|
|
3955
|
-
const destination =
|
|
6943
|
+
const destination = join3(releasesRoot, `${sourceManifest.package.version}-${closureHash}`);
|
|
3956
6944
|
if (await pathExists(destination)) {
|
|
3957
|
-
await
|
|
6945
|
+
await verifyExpectedRuntime(destination, materializedManifest, materializedManifestBytes);
|
|
3958
6946
|
return destination;
|
|
3959
6947
|
}
|
|
3960
|
-
const staging =
|
|
6948
|
+
const staging = join3(releasesRoot, `.staging-${randomUUID2()}`);
|
|
3961
6949
|
await mkdir(staging, { mode: 448 });
|
|
3962
6950
|
try {
|
|
3963
|
-
await cp(
|
|
6951
|
+
await cp(join3(sourceRoot, "dist"), join3(staging, "dist"), {
|
|
6952
|
+
recursive: true,
|
|
6953
|
+
dereference: true
|
|
6954
|
+
});
|
|
6955
|
+
await cp(join3(sourceRoot, "bin"), join3(staging, "bin"), {
|
|
3964
6956
|
recursive: true,
|
|
3965
6957
|
dereference: true
|
|
3966
6958
|
});
|
|
3967
|
-
await cp(
|
|
3968
|
-
await cp(
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
6959
|
+
await cp(join3(sourceRoot, "package.json"), join3(staging, "package.json"));
|
|
6960
|
+
await cp(sourceTreeRoot, join3(staging, dependencyTreePath), {
|
|
6961
|
+
recursive: true,
|
|
6962
|
+
dereference: true
|
|
6963
|
+
});
|
|
6964
|
+
await options.hooks?.afterDependencyCopy?.();
|
|
6965
|
+
const stagedTree = await hashDirectoryTree(
|
|
6966
|
+
join3(staging, dependencyTreePath),
|
|
6967
|
+
dependencyTreePath
|
|
6968
|
+
);
|
|
6969
|
+
assertSameTree(sourceTreeBefore, stagedTree, "copied dependency closure");
|
|
6970
|
+
const sourceTreeAfter = await hashDirectoryTree(sourceTreeRoot, dependencyTreePath);
|
|
6971
|
+
assertSameTree(sourceTreeBefore, sourceTreeAfter, "source dependency closure");
|
|
6972
|
+
await writeFile(join3(staging, "dist", "runtime-manifest.json"), materializedManifestBytes);
|
|
6973
|
+
await verifyExpectedRuntime(staging, materializedManifest, materializedManifestBytes);
|
|
3976
6974
|
await chmod(staging, 448);
|
|
3977
|
-
|
|
6975
|
+
try {
|
|
6976
|
+
await rename(staging, destination);
|
|
6977
|
+
} catch (error) {
|
|
6978
|
+
if (!isDestinationRace(error) || !await pathExists(destination)) throw error;
|
|
6979
|
+
await verifyExpectedRuntime(destination, materializedManifest, materializedManifestBytes);
|
|
6980
|
+
}
|
|
3978
6981
|
return destination;
|
|
3979
|
-
}
|
|
6982
|
+
} finally {
|
|
3980
6983
|
await rm(staging, { recursive: true, force: true });
|
|
3981
|
-
throw error;
|
|
3982
6984
|
}
|
|
3983
6985
|
}
|
|
3984
|
-
async function verifyRuntime(root
|
|
3985
|
-
const expected = manifest ?? JSON.parse(
|
|
3986
|
-
await readFile2(join2(root, "dist", "runtime-manifest.json"), "utf8")
|
|
3987
|
-
);
|
|
6986
|
+
async function verifyRuntime(root) {
|
|
3988
6987
|
const resolvedRoot = resolve3(root);
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
6988
|
+
const manifestBytes = await readFile2(join3(resolvedRoot, "dist", "runtime-manifest.json"));
|
|
6989
|
+
const manifest = await parseRuntimeManifest(manifestBytes, resolvedRoot);
|
|
6990
|
+
if (manifest.closure === void 0) {
|
|
6991
|
+
throw new Error("Runtime release manifest is missing its materialized closure");
|
|
6992
|
+
}
|
|
6993
|
+
await verifyRuntimeFiles(resolvedRoot, manifest);
|
|
6994
|
+
await verifyDependencyIdentities(resolvedRoot, manifest.dependencies);
|
|
6995
|
+
const actualTree = await hashDirectoryTree(
|
|
6996
|
+
resolveInside(resolvedRoot, dependencyTreePath),
|
|
6997
|
+
dependencyTreePath
|
|
6998
|
+
);
|
|
6999
|
+
assertSameTree(manifest.closure.tree, actualTree, "materialized dependency closure");
|
|
7000
|
+
}
|
|
7001
|
+
async function verifyExpectedRuntime(root, expected, expectedBytes) {
|
|
7002
|
+
const manifestPath = join3(root, "dist", "runtime-manifest.json");
|
|
7003
|
+
const actualBytes = await readFile2(manifestPath);
|
|
7004
|
+
if (!actualBytes.equals(expectedBytes)) {
|
|
7005
|
+
throw new Error("Materialized runtime manifest does not match the expected closure");
|
|
7006
|
+
}
|
|
7007
|
+
const actual = await parseRuntimeManifest(actualBytes, root);
|
|
7008
|
+
if (actual.closure === void 0 || expected.closure === void 0) {
|
|
7009
|
+
throw new Error("Materialized runtime manifest is missing its closure");
|
|
7010
|
+
}
|
|
7011
|
+
await verifyRuntimeFiles(root, actual);
|
|
7012
|
+
await verifyDependencyIdentities(root, actual.dependencies);
|
|
7013
|
+
const actualTree = await hashDirectoryTree(
|
|
7014
|
+
resolveInside(root, dependencyTreePath),
|
|
7015
|
+
dependencyTreePath
|
|
7016
|
+
);
|
|
7017
|
+
assertSameTree(expected.closure.tree, actualTree, "materialized dependency closure");
|
|
7018
|
+
}
|
|
7019
|
+
async function verifyRuntimeFiles(root, manifest) {
|
|
7020
|
+
for (const file of manifest.files) {
|
|
7021
|
+
const path2 = resolveInside(root, file.path);
|
|
7022
|
+
const info = await lstat2(path2);
|
|
7023
|
+
if (info.isSymbolicLink()) {
|
|
7024
|
+
throw new Error(`Runtime artifact ${file.path} must not be a symbolic link`);
|
|
7025
|
+
}
|
|
3992
7026
|
if (!info.isFile() || info.size !== file.bytes) {
|
|
3993
7027
|
throw new Error(`Runtime artifact ${file.path} has changed`);
|
|
3994
7028
|
}
|
|
3995
|
-
const hash =
|
|
7029
|
+
const hash = createHash3("sha256").update(await readFile2(path2)).digest("hex");
|
|
3996
7030
|
if (hash !== file.sha256) {
|
|
3997
7031
|
throw new Error(`Runtime artifact ${file.path} failed verification`);
|
|
3998
7032
|
}
|
|
3999
7033
|
}
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
7034
|
+
}
|
|
7035
|
+
async function verifyDependencyIdentities(root, dependencies) {
|
|
7036
|
+
const nodeModules = resolveInside(root, dependencyTreePath);
|
|
7037
|
+
const modulesInfo = await lstat2(nodeModules);
|
|
7038
|
+
if (!modulesInfo.isDirectory() || modulesInfo.isSymbolicLink()) {
|
|
7039
|
+
throw new Error("Runtime dependency closure must be a regular directory");
|
|
7040
|
+
}
|
|
7041
|
+
for (const dependency of dependencies) {
|
|
7042
|
+
const packageRoot = resolveInside(root, dependency.path);
|
|
7043
|
+
const packageInfo = await lstat2(packageRoot);
|
|
7044
|
+
if (!packageInfo.isDirectory() || packageInfo.isSymbolicLink()) {
|
|
7045
|
+
throw new Error(`Runtime dependency ${dependency.name} must be a regular directory`);
|
|
7046
|
+
}
|
|
7047
|
+
const packageJsonPath = join3(packageRoot, "package.json");
|
|
7048
|
+
const packageJsonInfo = await lstat2(packageJsonPath);
|
|
7049
|
+
if (!packageJsonInfo.isFile() || packageJsonInfo.isSymbolicLink()) {
|
|
7050
|
+
throw new Error(`Runtime dependency ${dependency.name} has an unsafe package.json`);
|
|
7051
|
+
}
|
|
7052
|
+
const identity = await readPackageMetadata(packageRoot);
|
|
7053
|
+
if (identity.name !== dependency.name || identity.version !== dependency.version) {
|
|
7054
|
+
throw new Error(`Runtime dependency ${dependency.name} has an unexpected identity`);
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
async function parseRuntimeManifest(bytes, root) {
|
|
7059
|
+
let candidate;
|
|
7060
|
+
try {
|
|
7061
|
+
candidate = JSON.parse(bytes.toString("utf8"));
|
|
7062
|
+
} catch {
|
|
7063
|
+
throw new Error("Runtime manifest is not valid JSON");
|
|
7064
|
+
}
|
|
7065
|
+
await validateRuntimeManifest(candidate, root);
|
|
7066
|
+
return candidate;
|
|
7067
|
+
}
|
|
7068
|
+
async function validateRuntimeManifest(candidate, root) {
|
|
7069
|
+
if (!isRecord2(candidate) || candidate.schemaVersion !== 4) {
|
|
7070
|
+
throw new Error("Runtime manifest has an unsupported schema version");
|
|
7071
|
+
}
|
|
7072
|
+
if (!isRecord2(candidate.package) || typeof candidate.package.name !== "string" || typeof candidate.package.version !== "string" || !isRecord2(candidate.piRuntime) || candidate.piRuntime.mode !== "external") {
|
|
7073
|
+
throw new Error("Runtime manifest has an invalid package identity");
|
|
7074
|
+
}
|
|
7075
|
+
const packageMetadata = await readPackageMetadata(root);
|
|
7076
|
+
if (candidate.package.name !== packageMetadata.name || candidate.package.version !== packageMetadata.version) {
|
|
7077
|
+
throw new Error("Runtime manifest package identity does not match package.json");
|
|
7078
|
+
}
|
|
7079
|
+
if (!Array.isArray(candidate.files) || !Array.isArray(candidate.dependencies)) {
|
|
7080
|
+
throw new Error("Runtime manifest has invalid artifact lists");
|
|
7081
|
+
}
|
|
7082
|
+
const filePaths = /* @__PURE__ */ new Set();
|
|
7083
|
+
for (const file of candidate.files) {
|
|
7084
|
+
if (!isRecord2(file) || !isManifestPath(file.path) || !isValidSize(file.bytes) || !isSha256(file.sha256)) {
|
|
7085
|
+
throw new Error("Runtime manifest contains an invalid artifact");
|
|
7086
|
+
}
|
|
7087
|
+
if (filePaths.has(file.path)) {
|
|
7088
|
+
throw new Error(`Runtime manifest has duplicate path ${file.path}`);
|
|
7089
|
+
}
|
|
7090
|
+
filePaths.add(file.path);
|
|
7091
|
+
}
|
|
7092
|
+
for (const required of requiredRuntimeArtifacts) {
|
|
7093
|
+
if (!filePaths.has(required)) {
|
|
7094
|
+
throw new Error(`Runtime manifest is missing required artifact ${required}`);
|
|
7095
|
+
}
|
|
7096
|
+
}
|
|
7097
|
+
const dependencyPaths = /* @__PURE__ */ new Set();
|
|
7098
|
+
const dependencyNames = /* @__PURE__ */ new Set();
|
|
7099
|
+
for (const dependency of candidate.dependencies) {
|
|
7100
|
+
if (!isRecord2(dependency) || !isManifestPath(dependency.path) || typeof dependency.name !== "string" || dependency.name.length === 0 || typeof dependency.version !== "string" || dependency.version.length === 0 || dependency.path !== `node_modules/${dependency.name}`) {
|
|
7101
|
+
throw new Error("Runtime manifest contains an invalid dependency declaration");
|
|
7102
|
+
}
|
|
7103
|
+
if (dependencyPaths.has(dependency.path) || dependencyNames.has(dependency.name)) {
|
|
7104
|
+
throw new Error(`Runtime manifest has duplicate dependency ${dependency.name}`);
|
|
7105
|
+
}
|
|
7106
|
+
dependencyPaths.add(dependency.path);
|
|
7107
|
+
dependencyNames.add(dependency.name);
|
|
7108
|
+
}
|
|
7109
|
+
const expectedDependencies = packageMetadata.dependencies;
|
|
7110
|
+
if (dependencyNames.size !== Object.keys(expectedDependencies).length || [...dependencyNames].some(
|
|
7111
|
+
(name) => expectedDependencies[name] !== candidate.dependencies.find(
|
|
7112
|
+
(dependency) => dependency.name === name
|
|
7113
|
+
)?.version
|
|
7114
|
+
)) {
|
|
7115
|
+
throw new Error("Runtime manifest dependencies do not match package.json");
|
|
7116
|
+
}
|
|
7117
|
+
for (const filePath of filePaths) {
|
|
7118
|
+
for (const dependencyPath of dependencyPaths) {
|
|
7119
|
+
if (filePath === dependencyPath || filePath.startsWith(`${dependencyPath}/`) || dependencyPath.startsWith(`${filePath}/`)) {
|
|
7120
|
+
throw new Error(`Runtime manifest has overlapping paths ${filePath} and ${dependencyPath}`);
|
|
7121
|
+
}
|
|
7122
|
+
}
|
|
7123
|
+
}
|
|
7124
|
+
if (candidate.closure !== void 0) {
|
|
7125
|
+
if (!isRecord2(candidate.closure) || !isSha256(candidate.closure.sourceManifestSha256) || !isTreeIntegrity(candidate.closure.tree) || candidate.closure.tree.path !== dependencyTreePath) {
|
|
7126
|
+
throw new Error("Runtime manifest contains an invalid materialized closure");
|
|
4005
7127
|
}
|
|
4006
7128
|
}
|
|
4007
7129
|
}
|
|
7130
|
+
async function readPackageMetadata(root) {
|
|
7131
|
+
let candidate;
|
|
7132
|
+
try {
|
|
7133
|
+
candidate = JSON.parse(await readFile2(join3(root, "package.json"), "utf8"));
|
|
7134
|
+
} catch {
|
|
7135
|
+
throw new Error("Runtime package.json is not valid JSON");
|
|
7136
|
+
}
|
|
7137
|
+
if (!isRecord2(candidate) || typeof candidate.name !== "string" || typeof candidate.version !== "string" || candidate.dependencies !== void 0 && !isRecord2(candidate.dependencies) || isRecord2(candidate.dependencies) && Object.values(candidate.dependencies).some((version) => typeof version !== "string")) {
|
|
7138
|
+
throw new Error("Runtime package.json has invalid package metadata");
|
|
7139
|
+
}
|
|
7140
|
+
return {
|
|
7141
|
+
name: candidate.name,
|
|
7142
|
+
version: candidate.version,
|
|
7143
|
+
dependencies: isRecord2(candidate.dependencies) ? candidate.dependencies : {}
|
|
7144
|
+
};
|
|
7145
|
+
}
|
|
7146
|
+
function serializeManifest(manifest) {
|
|
7147
|
+
return Buffer.from(`${JSON.stringify(manifest, null, 2)}
|
|
7148
|
+
`);
|
|
7149
|
+
}
|
|
7150
|
+
function assertSameTree(expected, actual, label) {
|
|
7151
|
+
if (expected.path !== actual.path || expected.files !== actual.files || expected.bytes !== actual.bytes || expected.sha256 !== actual.sha256) {
|
|
7152
|
+
throw new Error(`Runtime ${label} changed during materialization`);
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
4008
7155
|
function resolveInside(root, path2) {
|
|
7156
|
+
if (!isManifestPath(path2)) throw new Error(`Runtime manifest contains an unsafe path ${path2}`);
|
|
4009
7157
|
const resolved = resolve3(root, path2);
|
|
4010
7158
|
if (!resolved.startsWith(`${root}${sep2}`)) {
|
|
4011
7159
|
throw new Error(`Runtime manifest contains an unsafe path ${path2}`);
|
|
4012
7160
|
}
|
|
4013
7161
|
return resolved;
|
|
4014
7162
|
}
|
|
7163
|
+
function isRecord2(value) {
|
|
7164
|
+
return typeof value === "object" && value !== null;
|
|
7165
|
+
}
|
|
7166
|
+
function isManifestPath(value) {
|
|
7167
|
+
return typeof value === "string" && value.length > 0 && !value.includes("\\") && !value.startsWith("/") && posix.normalize(value) === value && value.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
7168
|
+
}
|
|
7169
|
+
function isValidSize(value) {
|
|
7170
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
7171
|
+
}
|
|
7172
|
+
function isSha256(value) {
|
|
7173
|
+
return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
7174
|
+
}
|
|
7175
|
+
function isTreeIntegrity(value) {
|
|
7176
|
+
return isRecord2(value) && isManifestPath(value.path) && isValidSize(value.files) && isValidSize(value.bytes) && isSha256(value.sha256);
|
|
7177
|
+
}
|
|
7178
|
+
function isDestinationRace(error) {
|
|
7179
|
+
const code = error.code;
|
|
7180
|
+
return code === "EEXIST" || code === "ENOTEMPTY";
|
|
7181
|
+
}
|
|
4015
7182
|
async function ensurePrivateDirectory(path2) {
|
|
4016
7183
|
await mkdir(path2, { recursive: true, mode: 448 });
|
|
4017
7184
|
const info = await lstat2(path2);
|
|
@@ -4035,9 +7202,9 @@ async function pathExists(path2) {
|
|
|
4035
7202
|
|
|
4036
7203
|
// src/platform/shared/paths.ts
|
|
4037
7204
|
import { homedir, tmpdir } from "node:os";
|
|
4038
|
-
import { join as
|
|
7205
|
+
import { join as join4, resolve as resolve4 } from "node:path";
|
|
4039
7206
|
function resolveApplicationRoot(env = process.env) {
|
|
4040
|
-
return env.PIFLEET_APPLICATION_ROOT ?? (process.platform === "darwin" ?
|
|
7207
|
+
return env.PIFLEET_APPLICATION_ROOT ?? (process.platform === "darwin" ? join4(homedir(), "Library", "Application Support", "pi-fleet", "runtime") : join4(env.XDG_DATA_HOME ?? join4(homedir(), ".local", "share"), "pi-fleet"));
|
|
4041
7208
|
}
|
|
4042
7209
|
function resolveFleetPaths(env = process.env) {
|
|
4043
7210
|
const explicitRoot = env.PIFLEET_STATE_ROOT;
|
|
@@ -4046,20 +7213,20 @@ function resolveFleetPaths(env = process.env) {
|
|
|
4046
7213
|
return {
|
|
4047
7214
|
runtimeRoot: root,
|
|
4048
7215
|
stateRoot: root,
|
|
4049
|
-
socketPath:
|
|
4050
|
-
databasePath:
|
|
7216
|
+
socketPath: join4(root, "control.sock"),
|
|
7217
|
+
databasePath: join4(root, "fleet.sqlite")
|
|
4051
7218
|
};
|
|
4052
7219
|
}
|
|
4053
|
-
const runtimeRoot =
|
|
7220
|
+
const runtimeRoot = join4(
|
|
4054
7221
|
env.XDG_RUNTIME_DIR ?? tmpdir(),
|
|
4055
7222
|
`pifleet-${process.getuid?.() ?? "user"}`
|
|
4056
7223
|
);
|
|
4057
|
-
const stateRoot = process.platform === "darwin" ?
|
|
7224
|
+
const stateRoot = process.platform === "darwin" ? join4(homedir(), "Library", "Application Support", "pi-fleet") : join4(env.XDG_STATE_HOME ?? join4(homedir(), ".local", "state"), "pi-fleet");
|
|
4058
7225
|
return {
|
|
4059
7226
|
runtimeRoot,
|
|
4060
7227
|
stateRoot,
|
|
4061
|
-
socketPath:
|
|
4062
|
-
databasePath:
|
|
7228
|
+
socketPath: join4(runtimeRoot, "control.sock"),
|
|
7229
|
+
databasePath: join4(stateRoot, "fleet.sqlite")
|
|
4063
7230
|
};
|
|
4064
7231
|
}
|
|
4065
7232
|
|
|
@@ -4067,19 +7234,27 @@ function resolveFleetPaths(env = process.env) {
|
|
|
4067
7234
|
var execFileAsync = promisify(execFile);
|
|
4068
7235
|
async function ensureRuntime(options) {
|
|
4069
7236
|
if (await canConnect(options.socketPath)) return;
|
|
4070
|
-
|
|
4071
|
-
const registered = env.PIFLEET_DISABLE_REGISTERED_SERVICE === "1" ? false : await startRegisteredRuntime({
|
|
7237
|
+
let env = { ...process.env, ...options.env };
|
|
7238
|
+
const registered = env.PIFLEET_DISABLE_REGISTERED_SERVICE === "1" ? false : options.registeredRuntimeStarter !== void 0 ? await options.registeredRuntimeStarter(env) : await startRegisteredRuntime({
|
|
4072
7239
|
env,
|
|
4073
7240
|
...options.home === void 0 ? {} : { home: options.home }
|
|
4074
7241
|
});
|
|
4075
7242
|
if (!registered) {
|
|
7243
|
+
if (options.piInstallation !== void 0) {
|
|
7244
|
+
const installation = await options.piInstallation();
|
|
7245
|
+
env = {
|
|
7246
|
+
...env,
|
|
7247
|
+
PIFLEET_PI_EXECUTABLE: installation.selectedPath,
|
|
7248
|
+
PIFLEET_PI_NODE: installation.nodePath
|
|
7249
|
+
};
|
|
7250
|
+
}
|
|
4076
7251
|
const sourceRoot = options.sourceRoot ?? await findPackageRoot(fileURLToPath(import.meta.url));
|
|
4077
7252
|
const release = await materializeRuntime({
|
|
4078
7253
|
sourceRoot,
|
|
4079
7254
|
applicationRoot: options.applicationRoot ?? resolveApplicationRoot(env)
|
|
4080
7255
|
});
|
|
4081
|
-
const runtimePath =
|
|
4082
|
-
const child =
|
|
7256
|
+
const runtimePath = join5(release, "bin", "pifleet-runtime.mjs");
|
|
7257
|
+
const child = spawn2(process.execPath, [runtimePath], {
|
|
4083
7258
|
detached: true,
|
|
4084
7259
|
env,
|
|
4085
7260
|
stdio: "ignore"
|
|
@@ -4091,19 +7266,19 @@ async function ensureRuntime(options) {
|
|
|
4091
7266
|
if (await canConnect(options.socketPath)) return;
|
|
4092
7267
|
await new Promise((resolveDelay) => setTimeout(resolveDelay, 25));
|
|
4093
7268
|
}
|
|
4094
|
-
throw new Error(`
|
|
7269
|
+
throw new Error(`pi-fleet runtime did not become ready at ${options.socketPath}`);
|
|
4095
7270
|
}
|
|
4096
7271
|
async function startRegisteredRuntime(options) {
|
|
4097
7272
|
const home = options.home ?? homedir2();
|
|
4098
7273
|
if (process.platform === "linux") {
|
|
4099
|
-
const unit =
|
|
7274
|
+
const unit = join5(home, ".config", "systemd", "user", "pi-fleet.service");
|
|
4100
7275
|
if (!await exists(unit)) return false;
|
|
4101
7276
|
await assertRegisteredStateRoot(unit, "linux", options.env);
|
|
4102
7277
|
await execFileAsync("systemctl", ["--user", "start", "pi-fleet.service"]);
|
|
4103
7278
|
return true;
|
|
4104
7279
|
}
|
|
4105
7280
|
if (process.platform === "darwin") {
|
|
4106
|
-
const plist =
|
|
7281
|
+
const plist = join5(home, "Library", "LaunchAgents", "works.elpapi.pifleet.plist");
|
|
4107
7282
|
if (!await exists(plist)) return false;
|
|
4108
7283
|
await assertRegisteredStateRoot(plist, "darwin", options.env);
|
|
4109
7284
|
const domain = `gui/${process.getuid?.() ?? 0}`;
|
|
@@ -4118,34 +7293,70 @@ function installedServiceStateRoot(contents, platform) {
|
|
|
4118
7293
|
if (platform === "linux") return encoded;
|
|
4119
7294
|
return encoded.replaceAll("'", "'").replaceAll(""", '"').replaceAll(">", ">").replaceAll("<", "<").replaceAll("&", "&");
|
|
4120
7295
|
}
|
|
7296
|
+
var PiServiceMismatchError = class extends Error {
|
|
7297
|
+
code = "pi_service_mismatch";
|
|
7298
|
+
constructor(message) {
|
|
7299
|
+
super(message);
|
|
7300
|
+
this.name = "PiServiceMismatchError";
|
|
7301
|
+
}
|
|
7302
|
+
};
|
|
7303
|
+
async function assertRegisteredPiSelection(options) {
|
|
7304
|
+
const home = options.home ?? homedir2();
|
|
7305
|
+
const platform = process.platform;
|
|
7306
|
+
if (platform !== "linux" && platform !== "darwin") return;
|
|
7307
|
+
const path2 = platform === "linux" ? join5(home, ".config", "systemd", "user", "pi-fleet.service") : join5(home, "Library", "LaunchAgents", "works.elpapi.pifleet.plist");
|
|
7308
|
+
if (!await exists(path2)) return;
|
|
7309
|
+
const contents = await readFile3(path2, "utf8");
|
|
7310
|
+
const installed = installedServicePiExecutable(contents, platform);
|
|
7311
|
+
const installedNode = installedServicePiNode(contents, platform);
|
|
7312
|
+
if (installed === void 0 || installedNode === void 0 || resolve5(installed) !== resolve5(options.selectedPath) || resolve5(installedNode) !== resolve5(options.nodePath)) {
|
|
7313
|
+
throw new PiServiceMismatchError(
|
|
7314
|
+
`The installed pi-fleet service uses a different Pi executable or Node interpreter; repair it from the environment selecting ${options.selectedPath}.`
|
|
7315
|
+
);
|
|
7316
|
+
}
|
|
7317
|
+
}
|
|
7318
|
+
function installedServicePiExecutable(contents, platform) {
|
|
7319
|
+
return installedServiceEnvironmentValue(contents, platform, "PIFLEET_PI_EXECUTABLE");
|
|
7320
|
+
}
|
|
7321
|
+
function installedServicePiNode(contents, platform) {
|
|
7322
|
+
return installedServiceEnvironmentValue(contents, platform, "PIFLEET_PI_NODE");
|
|
7323
|
+
}
|
|
7324
|
+
function installedServiceEnvironmentValue(contents, platform, key) {
|
|
7325
|
+
const encoded = platform === "linux" ? new RegExp(`Environment=(?:"${key}=([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|${key}=(.+))$`, "m").exec(contents)?.slice(1).find(Boolean) : new RegExp(`<key>${key}<\\/key><string>([^<]+)<\\/string>`).exec(contents)?.[1];
|
|
7326
|
+
if (encoded === void 0) return void 0;
|
|
7327
|
+
if (platform === "darwin") {
|
|
7328
|
+
return encoded.replaceAll("'", "'").replaceAll(""", '"').replaceAll(">", ">").replaceAll("<", "<").replaceAll("&", "&");
|
|
7329
|
+
}
|
|
7330
|
+
return encoded.replaceAll('\\"', '"').replaceAll("\\\\", "\\");
|
|
7331
|
+
}
|
|
4121
7332
|
async function assertRegisteredStateRoot(definitionPath, platform, env) {
|
|
4122
7333
|
const installed = installedServiceStateRoot(await readFile3(definitionPath, "utf8"), platform);
|
|
4123
7334
|
const requested = resolve5(resolveFleetPaths(env).stateRoot);
|
|
4124
7335
|
if (installed === void 0) {
|
|
4125
7336
|
if (env.PIFLEET_STATE_ROOT === void 0) return;
|
|
4126
7337
|
throw new Error(
|
|
4127
|
-
`Registered
|
|
7338
|
+
`Registered pi-fleet service uses the default state root, but this command requested ${requested}. Run the pi-fleet installer with PIFLEET_STATE_ROOT=${requested} to repair the service, or omit the override.`
|
|
4128
7339
|
);
|
|
4129
7340
|
}
|
|
4130
7341
|
if (resolve5(installed) !== requested) {
|
|
4131
7342
|
throw new Error(
|
|
4132
|
-
`Registered
|
|
7343
|
+
`Registered pi-fleet service uses state root ${installed}, but this command requested ${requested}. Repair the service with the intended PIFLEET_STATE_ROOT before retrying.`
|
|
4133
7344
|
);
|
|
4134
7345
|
}
|
|
4135
7346
|
}
|
|
4136
7347
|
async function findPackageRoot(modulePath) {
|
|
4137
|
-
let candidate =
|
|
7348
|
+
let candidate = dirname2(modulePath);
|
|
4138
7349
|
for (let depth = 0; depth < 6; depth += 1) {
|
|
4139
|
-
if (await exists(
|
|
4140
|
-
const parent =
|
|
7350
|
+
if (await exists(join5(candidate, "dist", "runtime-manifest.json"))) return candidate;
|
|
7351
|
+
const parent = dirname2(candidate);
|
|
4141
7352
|
if (parent === candidate) break;
|
|
4142
7353
|
candidate = parent;
|
|
4143
7354
|
}
|
|
4144
|
-
throw new Error("Unable to locate the
|
|
7355
|
+
throw new Error("Unable to locate the pi-fleet package runtime manifest.");
|
|
4145
7356
|
}
|
|
4146
7357
|
async function exists(path2) {
|
|
4147
7358
|
try {
|
|
4148
|
-
await
|
|
7359
|
+
await access2(path2);
|
|
4149
7360
|
return true;
|
|
4150
7361
|
} catch {
|
|
4151
7362
|
return false;
|
|
@@ -4174,10 +7385,27 @@ function canConnect(socketPath) {
|
|
|
4174
7385
|
function defaultDependencies() {
|
|
4175
7386
|
const abort = new AbortController();
|
|
4176
7387
|
const paths = resolveFleetPaths();
|
|
7388
|
+
let installation;
|
|
7389
|
+
const selectedPi = () => installation ??= resolveExternalPiInstallation({ env: process.env });
|
|
7390
|
+
const mutationPi = async () => {
|
|
7391
|
+
const selected = await selectedPi();
|
|
7392
|
+
if (process.env.PIFLEET_DISABLE_REGISTERED_SERVICE !== "1") {
|
|
7393
|
+
await assertRegisteredPiSelection({
|
|
7394
|
+
selectedPath: selected.selectedPath,
|
|
7395
|
+
nodePath: selected.nodePath
|
|
7396
|
+
});
|
|
7397
|
+
}
|
|
7398
|
+
return selected;
|
|
7399
|
+
};
|
|
4177
7400
|
return {
|
|
4178
7401
|
client: new SocketFleetClient({
|
|
4179
7402
|
socketPath: paths.socketPath,
|
|
4180
|
-
beforeConnect: () => ensureRuntime({
|
|
7403
|
+
beforeConnect: () => ensureRuntime({
|
|
7404
|
+
socketPath: paths.socketPath,
|
|
7405
|
+
env: process.env,
|
|
7406
|
+
piInstallation: selectedPi
|
|
7407
|
+
}),
|
|
7408
|
+
piIdentity: async () => installationIdentity(await mutationPi())
|
|
4181
7409
|
}),
|
|
4182
7410
|
cwd: process.cwd(),
|
|
4183
7411
|
stdin: process.stdin,
|