@supacloud/compiler 0.31.2 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/cli.js +355 -26
- package/dist/delivery-bundle-protocol.d.ts +34 -0
- package/dist/delivery-bundle-worker.js +71 -4
- package/dist/index.js +382 -53
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2244,6 +2244,8 @@ function renderClient(graph, options) {
|
|
|
2244
2244
|
const schemaLocals = new Map;
|
|
2245
2245
|
const usedTypeNames = new Set;
|
|
2246
2246
|
const allRoutes = [];
|
|
2247
|
+
const allProcedures = [];
|
|
2248
|
+
const commandByClassName = new Map(graph.modules.flatMap((module) => module.commands.map((command) => [command.className, command])));
|
|
2247
2249
|
let usesStatic = false;
|
|
2248
2250
|
let usesValue = false;
|
|
2249
2251
|
const uniqueTypeName = (candidate) => {
|
|
@@ -2374,8 +2376,21 @@ function renderClient(graph, options) {
|
|
|
2374
2376
|
const responseSchemaEntries = hasResponseMap ? Object.entries(responseSchemas).map(([status, ref]) => [status, ref.local]) : responseSchema ? [["200", responseSchema.local]] : [];
|
|
2375
2377
|
const responseSchemaArgument = responseSchemaEntries.length > 0 ? `{ ${responseSchemaEntries.map(([status, local]) => `${JSON.stringify(status)}: ${local}`).join(", ")} }` : "undefined";
|
|
2376
2378
|
const responseKindArgument = responseKind === undefined ? "undefined" : JSON.stringify(responseKind);
|
|
2379
|
+
const command = route.command === undefined ? undefined : commandByClassName.get(route.command);
|
|
2380
|
+
const procedureKind = route.method === "GET" || route.method === "HEAD" ? "query" : "mutation";
|
|
2381
|
+
const idempotencyMode = command?.idempotency ?? "none";
|
|
2382
|
+
allProcedures.push({
|
|
2383
|
+
method: route.method,
|
|
2384
|
+
path: fullPath,
|
|
2385
|
+
controller: controller.className,
|
|
2386
|
+
handler: route.handler,
|
|
2387
|
+
kind: procedureKind,
|
|
2388
|
+
...command?.name === undefined ? {} : { command: command.name },
|
|
2389
|
+
...command?.permission === undefined ? {} : { permission: command.permission },
|
|
2390
|
+
idempotency: idempotencyMode
|
|
2391
|
+
});
|
|
2377
2392
|
routeMethods.push(`
|
|
2378
|
-
${route.handler}: makeRoute<${requestTypeName}, ${responseType === "never" ? "never" : responseTypeName}>(${JSON.stringify(route.method)}, ${JSON.stringify(fullPath)}, ${responseSchemaArgument}, ${responseKindArgument}, ${route.parse === "none"}),`);
|
|
2393
|
+
${route.handler}: makeRoute<${requestTypeName}, ${responseType === "never" ? "never" : responseTypeName}, ${JSON.stringify(procedureKind)}, ${JSON.stringify(idempotencyMode)}>(${JSON.stringify(route.method)}, ${JSON.stringify(fullPath)}, ${responseSchemaArgument}, ${responseKindArgument}, ${route.parse === "none"}, ${JSON.stringify(procedureKind)}, ${JSON.stringify(idempotencyMode)}),`);
|
|
2379
2394
|
}
|
|
2380
2395
|
controllerEntries.push(`
|
|
2381
2396
|
${controllerKey}: {${routeMethods.join("")}
|
|
@@ -2406,6 +2421,43 @@ function renderClient(graph, options) {
|
|
|
2406
2421
|
"",
|
|
2407
2422
|
"export type ResponseDecoder<T> = (value: unknown) => T;",
|
|
2408
2423
|
"",
|
|
2424
|
+
'export type ProcedureKind = "query" | "mutation";',
|
|
2425
|
+
'export type IdempotencyMode = "required" | "none";',
|
|
2426
|
+
"",
|
|
2427
|
+
"export interface ProcedureExecutionOptions {",
|
|
2428
|
+
" /** Reuse the same key when retrying an uncertain mutation. */",
|
|
2429
|
+
" idempotencyKey?: string;",
|
|
2430
|
+
" signal?: AbortSignal;",
|
|
2431
|
+
"}",
|
|
2432
|
+
"",
|
|
2433
|
+
"export type RequiredProcedureExecutionOptions = ProcedureExecutionOptions & { idempotencyKey: string };",
|
|
2434
|
+
"",
|
|
2435
|
+
"type ProcedureResult<Result> = [Result] extends [never] ? unknown : Result;",
|
|
2436
|
+
"",
|
|
2437
|
+
"type ProcedureArgs<Options extends ClientRequestOptions, Idempotency extends IdempotencyMode> =",
|
|
2438
|
+
' Idempotency extends "required"',
|
|
2439
|
+
" ? {} extends Options",
|
|
2440
|
+
" ? [execution: RequiredProcedureExecutionOptions] | [input: Options, execution: RequiredProcedureExecutionOptions]",
|
|
2441
|
+
" : [input: Options, execution: RequiredProcedureExecutionOptions]",
|
|
2442
|
+
" : {} extends Options",
|
|
2443
|
+
" ? [input?: Options, execution?: ProcedureExecutionOptions]",
|
|
2444
|
+
" : [input: Options, execution?: ProcedureExecutionOptions];",
|
|
2445
|
+
"",
|
|
2446
|
+
"export type ProcedureCall<",
|
|
2447
|
+
" Options extends ClientRequestOptions = ClientRequestOptions,",
|
|
2448
|
+
" Result = never,",
|
|
2449
|
+
' Idempotency extends IdempotencyMode = "none",',
|
|
2450
|
+
"> = (...args: ProcedureArgs<Options, Idempotency>) => Promise<ProcedureResult<Result>>;",
|
|
2451
|
+
"",
|
|
2452
|
+
"export type ProcedureMember<",
|
|
2453
|
+
" Options extends ClientRequestOptions,",
|
|
2454
|
+
" Result,",
|
|
2455
|
+
" Kind extends ProcedureKind,",
|
|
2456
|
+
" Idempotency extends IdempotencyMode,",
|
|
2457
|
+
'> = Kind extends "query"',
|
|
2458
|
+
" ? { query: ProcedureCall<Options, Result, Idempotency> }",
|
|
2459
|
+
" : { mutate: ProcedureCall<Options, Result, Idempotency> };",
|
|
2460
|
+
"",
|
|
2409
2461
|
'export type ApiClientErrorCode = "API_HTTP_ERROR" | "API_RESPONSE_INVALID" | "API_RESPONSE_UNDECLARED";',
|
|
2410
2462
|
"",
|
|
2411
2463
|
"export interface ApiClientErrorDetails {",
|
|
@@ -2449,6 +2501,17 @@ function renderClient(graph, options) {
|
|
|
2449
2501
|
" : { (options: Options): Promise<Result>; <T>(options: Options, decode: ResponseDecoder<T>): Promise<T> }",
|
|
2450
2502
|
") & ((...args: {} extends Options ? [options?: Options] : [options: Options]) => Promise<[Result] extends [never] ? unknown : Result>);",
|
|
2451
2503
|
"",
|
|
2504
|
+
"export interface ApiProcedureDefinition {",
|
|
2505
|
+
" method: string;",
|
|
2506
|
+
" path: string;",
|
|
2507
|
+
" controller: string;",
|
|
2508
|
+
" handler: string;",
|
|
2509
|
+
" kind: ProcedureKind;",
|
|
2510
|
+
" command?: string;",
|
|
2511
|
+
" permission?: string;",
|
|
2512
|
+
" idempotency: IdempotencyMode;",
|
|
2513
|
+
"}",
|
|
2514
|
+
"",
|
|
2452
2515
|
...routeTypes,
|
|
2453
2516
|
...routeTypes.length > 0 ? [""] : [],
|
|
2454
2517
|
"export interface HttpInterceptorRequest {",
|
|
@@ -2456,6 +2519,7 @@ function renderClient(graph, options) {
|
|
|
2456
2519
|
" url: string;",
|
|
2457
2520
|
" headers: Record<string, string>;",
|
|
2458
2521
|
" body?: unknown;",
|
|
2522
|
+
" signal?: AbortSignal;",
|
|
2459
2523
|
"}",
|
|
2460
2524
|
"",
|
|
2461
2525
|
"export type HttpInterceptorFn = (",
|
|
@@ -2474,6 +2538,8 @@ function renderClient(graph, options) {
|
|
|
2474
2538
|
"",
|
|
2475
2539
|
"export const API_ROUTES = " + JSON.stringify(allRoutes, null, 2) + " as const;",
|
|
2476
2540
|
"",
|
|
2541
|
+
"export const API_PROCEDURES: readonly ApiProcedureDefinition[] = " + JSON.stringify(allProcedures, null, 2) + ";",
|
|
2542
|
+
"",
|
|
2477
2543
|
"export type AppRoutePath = typeof API_ROUTES[number]['path'];",
|
|
2478
2544
|
"",
|
|
2479
2545
|
"export const API_SCHEMAS = [",
|
|
@@ -2699,6 +2765,7 @@ function renderClient(graph, options) {
|
|
|
2699
2765
|
` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
|
|
2700
2766
|
" responseKind?: string,",
|
|
2701
2767
|
" raw?: boolean,",
|
|
2768
|
+
" execution?: ProcedureExecutionOptions,",
|
|
2702
2769
|
" ): Promise<T>;",
|
|
2703
2770
|
" async function request<T>(",
|
|
2704
2771
|
" method: string,",
|
|
@@ -2708,6 +2775,7 @@ function renderClient(graph, options) {
|
|
|
2708
2775
|
` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
|
|
2709
2776
|
" responseKind?: string,",
|
|
2710
2777
|
" raw?: boolean,",
|
|
2778
|
+
" execution?: ProcedureExecutionOptions,",
|
|
2711
2779
|
" ): Promise<T | unknown>;",
|
|
2712
2780
|
" async function request(",
|
|
2713
2781
|
" method: string,",
|
|
@@ -2722,6 +2790,7 @@ function renderClient(graph, options) {
|
|
|
2722
2790
|
` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
|
|
2723
2791
|
" responseKind?: string,",
|
|
2724
2792
|
" raw = false,",
|
|
2793
|
+
" execution?: ProcedureExecutionOptions,",
|
|
2725
2794
|
" ): Promise<T | unknown> {",
|
|
2726
2795
|
" const url = `${baseUrl}${buildRouteUrl(path, options.params, options.query)}`;",
|
|
2727
2796
|
' const customHeaders = typeof config.headers === "function" ? await config.headers() : config.headers;',
|
|
@@ -2747,9 +2816,10 @@ function renderClient(graph, options) {
|
|
|
2747
2816
|
" headers: reqPayload.headers,",
|
|
2748
2817
|
" ...(reqPayload.body === undefined ? {} : { body: raw ? rawBody(reqPayload.body) : JSON.stringify(reqPayload.body) }),",
|
|
2749
2818
|
' ...(raw && reqPayload.body instanceof ReadableStream ? { duplex: "half" } : {}),',
|
|
2819
|
+
" ...(reqPayload.signal === undefined ? {} : { signal: reqPayload.signal }),",
|
|
2750
2820
|
" });",
|
|
2751
2821
|
" };",
|
|
2752
|
-
" const response = await executeChain(0, { method, url, headers, body: options.body });",
|
|
2822
|
+
" const response = await executeChain(0, { method, url, headers, body: options.body, ...(execution?.signal === undefined ? {} : { signal: execution.signal }) });",
|
|
2753
2823
|
" const declaredSchema = responseSchemas ? selectResponseSchema(response.status, responseSchemas) : undefined;",
|
|
2754
2824
|
" const failure = (code: ApiClientErrorCode, message: string) => new ApiClientError(message, {",
|
|
2755
2825
|
' code, method, path, status: response.status, requestId: response.headers.get("x-request-id"),',
|
|
@@ -2787,7 +2857,44 @@ function renderClient(graph, options) {
|
|
|
2787
2857
|
" return decode ? decode(checked) : checked;",
|
|
2788
2858
|
" }",
|
|
2789
2859
|
"",
|
|
2790
|
-
|
|
2860
|
+
" function hasHeader(headers: Record<string, string>, name: string): boolean {",
|
|
2861
|
+
" return Object.keys(headers).some((key) => key.toLowerCase() === name.toLowerCase());",
|
|
2862
|
+
" }",
|
|
2863
|
+
"",
|
|
2864
|
+
" function withProcedureExecution(",
|
|
2865
|
+
" options: ClientRequestOptions,",
|
|
2866
|
+
" execution: ProcedureExecutionOptions | undefined,",
|
|
2867
|
+
" idempotency: IdempotencyMode,",
|
|
2868
|
+
" ): ClientRequestOptions {",
|
|
2869
|
+
" const headers = { ...(options.headers as Record<string, string> | undefined) };",
|
|
2870
|
+
" if (execution?.idempotencyKey !== undefined) {",
|
|
2871
|
+
" if (!/^[A-Za-z0-9._:-]{1,512}$/.test(execution.idempotencyKey)) {",
|
|
2872
|
+
' throw new TypeError("idempotencyKey must contain only safe header characters and be at most 512 characters");',
|
|
2873
|
+
" }",
|
|
2874
|
+
' headers["idempotency-key"] = execution.idempotencyKey;',
|
|
2875
|
+
" }",
|
|
2876
|
+
' if (idempotency === "required" && !hasHeader(headers, "idempotency-key")) {',
|
|
2877
|
+
' throw new TypeError("This mutation requires an idempotencyKey");',
|
|
2878
|
+
" }",
|
|
2879
|
+
" return Object.keys(headers).length === 0 ? options : { ...options, headers };",
|
|
2880
|
+
" }",
|
|
2881
|
+
"",
|
|
2882
|
+
" function isProcedureExecution(value: unknown): value is ProcedureExecutionOptions {",
|
|
2883
|
+
' if (value === null || typeof value !== "object" || Array.isArray(value)) return false;',
|
|
2884
|
+
' return Object.hasOwn(value, "idempotencyKey") || Object.hasOwn(value, "signal");',
|
|
2885
|
+
" }",
|
|
2886
|
+
"",
|
|
2887
|
+
` function makeProcedure<Options extends ClientRequestOptions, Result = never, Idempotency extends IdempotencyMode = "none">(method: string, path: string, responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>, responseKind?: string, raw = false, idempotency: Idempotency = "none" as Idempotency): ProcedureCall<Options, Result, Idempotency> {`,
|
|
2888
|
+
" const procedure = async (first?: Options | ProcedureExecutionOptions, second?: ProcedureExecutionOptions): Promise<unknown> => {",
|
|
2889
|
+
" const execution = second ?? (isProcedureExecution(first) ? first : undefined);",
|
|
2890
|
+
" const input = (execution === first ? undefined : first) ?? {};",
|
|
2891
|
+
" const requestOptions = withProcedureExecution(input as ClientRequestOptions, execution, idempotency);",
|
|
2892
|
+
" return request(method, path, requestOptions, undefined, responseSchemas, responseKind, raw, execution);",
|
|
2893
|
+
" };",
|
|
2894
|
+
" return procedure as ProcedureCall<Options, Result, Idempotency>;",
|
|
2895
|
+
" }",
|
|
2896
|
+
"",
|
|
2897
|
+
` function makeRoute<Options extends ClientRequestOptions, Result = never, Kind extends ProcedureKind = never, Idempotency extends IdempotencyMode = "none">(method: string, path: string, responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>, responseKind?: string, raw = false, kind?: Kind, idempotency: Idempotency = "none" as Idempotency): RouteMethod<Options, Result> & ProcedureMember<Options, Result, Kind, Idempotency> {`,
|
|
2791
2898
|
" function route<T>(options: Options, decode: ResponseDecoder<T>): Promise<T>;",
|
|
2792
2899
|
" function route(options: Options): Promise<Result>;",
|
|
2793
2900
|
" function route(options?: Options): Promise<unknown>;",
|
|
@@ -2795,13 +2902,16 @@ function renderClient(graph, options) {
|
|
|
2795
2902
|
" const requestOptions = options ?? {};",
|
|
2796
2903
|
" return request(method, path, requestOptions, decode, responseSchemas, responseKind, raw);",
|
|
2797
2904
|
" }",
|
|
2798
|
-
|
|
2905
|
+
' if (kind === "query") Object.assign(route, { query: makeProcedure<Options, Result, Idempotency>(method, path, responseSchemas, responseKind, raw, idempotency) });',
|
|
2906
|
+
' if (kind === "mutation") Object.assign(route, { mutate: makeProcedure<Options, Result, Idempotency>(method, path, responseSchemas, responseKind, raw, idempotency) });',
|
|
2907
|
+
" return route as RouteMethod<Options, Result> & ProcedureMember<Options, Result, Kind, Idempotency>;",
|
|
2799
2908
|
" }",
|
|
2800
2909
|
"",
|
|
2801
2910
|
" return {",
|
|
2802
2911
|
" request,",
|
|
2803
2912
|
" buildRouteUrl,",
|
|
2804
2913
|
" routes: API_ROUTES,",
|
|
2914
|
+
" procedures: API_PROCEDURES,",
|
|
2805
2915
|
...controllerEntries,
|
|
2806
2916
|
" };",
|
|
2807
2917
|
"}",
|
|
@@ -14164,6 +14274,65 @@ var init_value2 = __esm(() => {
|
|
|
14164
14274
|
init_shared();
|
|
14165
14275
|
});
|
|
14166
14276
|
|
|
14277
|
+
// node_modules/@supacloud/delivery/src/worker-execution.ts
|
|
14278
|
+
function parseWorkerExecutionGroup(value) {
|
|
14279
|
+
if (!Check2(WorkerExecutionGroupSchema, value) || value.replicas > value.maxReplicas || !value.queue.endsWith(`_v${value.definitionVersion}`) || value.lifecycle.visibilityTimeoutSeconds < value.lifecycle.executionTimeoutSeconds + value.lifecycle.shutdownGraceSeconds + 30) {
|
|
14280
|
+
throw new Error("WORKER_EXECUTION_INVALID");
|
|
14281
|
+
}
|
|
14282
|
+
return structuredClone(value);
|
|
14283
|
+
}
|
|
14284
|
+
function validateWorkerExecution(groups) {
|
|
14285
|
+
const names = new Set, targets = new Set, queues = new Set, routes = new Set;
|
|
14286
|
+
for (const candidate of groups) {
|
|
14287
|
+
const group = parseWorkerExecutionGroup(candidate);
|
|
14288
|
+
const route = `${group.taskKey}:${group.definitionVersion}`;
|
|
14289
|
+
if (names.has(group.name) || targets.has(group.target) || queues.has(group.queue) || routes.has(route)) {
|
|
14290
|
+
throw new Error("WORKER_EXECUTION_CONFLICT");
|
|
14291
|
+
}
|
|
14292
|
+
names.add(group.name);
|
|
14293
|
+
targets.add(group.target);
|
|
14294
|
+
queues.add(group.queue);
|
|
14295
|
+
routes.add(route);
|
|
14296
|
+
}
|
|
14297
|
+
}
|
|
14298
|
+
var closed, positive = (maximum) => Integer({ minimum: 1, maximum }), WorkerExecutionGroupSchema, WorkerExecutionSchema;
|
|
14299
|
+
var init_worker_execution = __esm(() => {
|
|
14300
|
+
init_build();
|
|
14301
|
+
init_value2();
|
|
14302
|
+
closed = { additionalProperties: false };
|
|
14303
|
+
WorkerExecutionGroupSchema = _Object_({
|
|
14304
|
+
name: String2({ pattern: "^[a-z][a-z0-9-]{0,47}$" }),
|
|
14305
|
+
target: String2({ pattern: "^[a-z][a-z0-9-]{0,53}$" }),
|
|
14306
|
+
workloadClass: Union([Literal("interactive"), Literal("batch")]),
|
|
14307
|
+
executor: Literal("pgflow-queue"),
|
|
14308
|
+
runtime: Literal("bun"),
|
|
14309
|
+
queue: String2({ pattern: "^scw_[a-z0-9_]{1,40}$" }),
|
|
14310
|
+
taskKey: String2({ pattern: "^[a-z][a-z0-9_.-]{0,99}$" }),
|
|
14311
|
+
definitionVersion: String2({ pattern: "^[1-9][0-9]{0,8}$" }),
|
|
14312
|
+
replicas: positive(16),
|
|
14313
|
+
maxReplicas: positive(16),
|
|
14314
|
+
concurrencyPerReplica: positive(32),
|
|
14315
|
+
resources: _Object_({
|
|
14316
|
+
cpuLimit: Number2({ minimum: 0.1, maximum: 64, multipleOf: 0.1 }),
|
|
14317
|
+
memoryLimitMiB: Integer({ minimum: 64, maximum: 262144 })
|
|
14318
|
+
}, closed),
|
|
14319
|
+
database: _Object_({
|
|
14320
|
+
engineConnectionsPerReplica: positive(16),
|
|
14321
|
+
handlerConnectionsPerReplica: positive(16)
|
|
14322
|
+
}, closed),
|
|
14323
|
+
lifecycle: _Object_({
|
|
14324
|
+
executionTimeoutSeconds: positive(3500),
|
|
14325
|
+
visibilityTimeoutSeconds: Integer({ minimum: 15, maximum: 3600 }),
|
|
14326
|
+
shutdownGraceSeconds: positive(300)
|
|
14327
|
+
}, closed),
|
|
14328
|
+
retry: _Object_({ maxAttempts: Integer({ minimum: 1, maximum: 10 }) }, closed),
|
|
14329
|
+
admission: _Object_({ maxOutstandingOperations: positive(1e6) }, closed)
|
|
14330
|
+
}, closed);
|
|
14331
|
+
WorkerExecutionSchema = _Object_({
|
|
14332
|
+
groups: _Array_(WorkerExecutionGroupSchema, { minItems: 1, maxItems: 32 })
|
|
14333
|
+
}, closed);
|
|
14334
|
+
});
|
|
14335
|
+
|
|
14167
14336
|
// node_modules/@supacloud/delivery/src/delivery-schema.ts
|
|
14168
14337
|
function parseDeliveryOptions(value) {
|
|
14169
14338
|
if (value === undefined)
|
|
@@ -14171,6 +14340,11 @@ function parseDeliveryOptions(value) {
|
|
|
14171
14340
|
if (!Check2(DeliveryOptionsSchema, value))
|
|
14172
14341
|
throw new DeliveryConfigurationError;
|
|
14173
14342
|
const migrations = value.build?.migrations ?? [];
|
|
14343
|
+
try {
|
|
14344
|
+
validateWorkerExecution(value.execution?.groups ?? []);
|
|
14345
|
+
} catch {
|
|
14346
|
+
throw new DeliveryConfigurationError;
|
|
14347
|
+
}
|
|
14174
14348
|
if (new Set(migrations.map((item) => item.version)).size !== migrations.length || new Set(migrations.map((item) => item.source)).size !== migrations.length || migrations.some((item) => BigInt(item.version) > 9223372036854775807n || !/\.sql$/i.test(item.source) || item.source.split("/").includes("node_modules"))) {
|
|
14175
14349
|
throw new DeliveryConfigurationError;
|
|
14176
14350
|
}
|
|
@@ -14185,6 +14359,7 @@ var objectOptions, reference, references, kind, isolation, DeliveryFilePathSchem
|
|
|
14185
14359
|
var init_delivery_schema = __esm(() => {
|
|
14186
14360
|
init_build();
|
|
14187
14361
|
init_value2();
|
|
14362
|
+
init_worker_execution();
|
|
14188
14363
|
objectOptions = { additionalProperties: false };
|
|
14189
14364
|
reference = String2({ minLength: 1, maxLength: 128, pattern: "^[A-Za-z][A-Za-z0-9_.:/-]*$" });
|
|
14190
14365
|
references = _Array_(reference, { uniqueItems: true });
|
|
@@ -14196,6 +14371,7 @@ var init_delivery_schema = __esm(() => {
|
|
|
14196
14371
|
});
|
|
14197
14372
|
DeliveryOptionsSchema = _Object_({
|
|
14198
14373
|
version: Literal(1),
|
|
14374
|
+
execution: Optional(WorkerExecutionSchema),
|
|
14199
14375
|
targets: Optional(_Array_(_Object_({
|
|
14200
14376
|
name: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
|
|
14201
14377
|
kind,
|
|
@@ -14268,6 +14444,7 @@ var init_delivery_schema = __esm(() => {
|
|
|
14268
14444
|
name: String2(),
|
|
14269
14445
|
kind,
|
|
14270
14446
|
isolation,
|
|
14447
|
+
execution: Optional(WorkerExecutionGroupSchema),
|
|
14271
14448
|
roots: _Array_(String2()),
|
|
14272
14449
|
modules: _Array_(_Object_({
|
|
14273
14450
|
name: String2(),
|
|
@@ -14483,6 +14660,15 @@ function deliveryObjectDigest(object) {
|
|
|
14483
14660
|
function parseDeliveryBuildManifest(value) {
|
|
14484
14661
|
if (!Check2(DeliveryBuildManifestSchema, value))
|
|
14485
14662
|
throw new Error("Invalid delivery build manifest.");
|
|
14663
|
+
validateWorkerExecution(value.plan.targets.flatMap((target) => target.execution ? [target.execution] : []));
|
|
14664
|
+
if (value.plan.targets.reduce((count, target) => count + (target.execution?.replicas ?? 1), 0) > 32) {
|
|
14665
|
+
throw new Error("Invalid delivery replica count.");
|
|
14666
|
+
}
|
|
14667
|
+
for (const target of value.plan.targets) {
|
|
14668
|
+
if (target.execution && (target.kind !== "jobs" || target.isolation !== "process" || target.execution.target !== target.name || target.jobs.length !== 1 || target.jobs[0]?.name !== target.execution.taskKey || value.objects.find((object) => object.name === target.name)?.entryKind !== "bun-worker-application")) {
|
|
14669
|
+
throw new Error("Invalid delivery execution binding.");
|
|
14670
|
+
}
|
|
14671
|
+
}
|
|
14486
14672
|
if (new Set(value.objects.map((item) => item.name)).size !== value.objects.length) {
|
|
14487
14673
|
throw new Error("Duplicate delivery object owner.");
|
|
14488
14674
|
}
|
|
@@ -14491,7 +14677,7 @@ function parseDeliveryBuildManifest(value) {
|
|
|
14491
14677
|
}
|
|
14492
14678
|
for (const object of value.objects) {
|
|
14493
14679
|
const target = value.plan.targets.find((target) => target.name === object.name);
|
|
14494
|
-
if (
|
|
14680
|
+
if (["bun-worker-application", "go-worker-application", "scriptc-worker-application"].includes(object.entryKind) && target?.kind !== "jobs" || object.entryKind === "bun-http-application" && target?.kind === "jobs") {
|
|
14495
14681
|
throw new Error("Delivery executable kind does not match its target.");
|
|
14496
14682
|
}
|
|
14497
14683
|
if (new Set(object.files.map((file) => file.path)).size !== object.files.length || !object.files.some((file) => file.path === object.entrypoint) || deliveryObjectDigest(object) !== object.objectId) {
|
|
@@ -14512,13 +14698,14 @@ function parseDeliveryBuildResult(value) {
|
|
|
14512
14698
|
parseDeliveryBuildManifest(value.manifest);
|
|
14513
14699
|
return value;
|
|
14514
14700
|
}
|
|
14515
|
-
var
|
|
14701
|
+
var closed2, digest2, DeliveryObjectSchema, DeliveryBuildManifestSchema, resultFields, DeliveryBuildResultSchema;
|
|
14516
14702
|
var init_delivery_build_schema = __esm(() => {
|
|
14517
14703
|
init_build();
|
|
14518
14704
|
init_value2();
|
|
14519
14705
|
init_delivery_schema();
|
|
14520
14706
|
init_delivery_files();
|
|
14521
|
-
|
|
14707
|
+
init_worker_execution();
|
|
14708
|
+
closed2 = { additionalProperties: false };
|
|
14522
14709
|
digest2 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
14523
14710
|
DeliveryObjectSchema = _Object_({
|
|
14524
14711
|
name: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
|
|
@@ -14528,15 +14715,17 @@ var init_delivery_build_schema = __esm(() => {
|
|
|
14528
14715
|
entryKind: Union([
|
|
14529
14716
|
Literal("compiled-module-factory"),
|
|
14530
14717
|
Literal("bun-http-application"),
|
|
14531
|
-
Literal("bun-worker-application")
|
|
14718
|
+
Literal("bun-worker-application"),
|
|
14719
|
+
Literal("go-worker-application"),
|
|
14720
|
+
Literal("scriptc-worker-application")
|
|
14532
14721
|
]),
|
|
14533
14722
|
runtimeImports: _Array_(String2()),
|
|
14534
14723
|
files: _Array_(_Object_({
|
|
14535
14724
|
path: DeliveryFilePathSchema,
|
|
14536
14725
|
sha256: digest2,
|
|
14537
14726
|
bytes: Integer({ minimum: 0 })
|
|
14538
|
-
},
|
|
14539
|
-
},
|
|
14727
|
+
}, closed2), { minItems: 1 })
|
|
14728
|
+
}, closed2);
|
|
14540
14729
|
DeliveryBuildManifestSchema = _Object_({
|
|
14541
14730
|
schemaVersion: Literal(1),
|
|
14542
14731
|
producer: Literal("@supacloud/compiler/delivery-build-v1"),
|
|
@@ -14547,9 +14736,9 @@ var init_delivery_build_schema = __esm(() => {
|
|
|
14547
14736
|
method: String2(),
|
|
14548
14737
|
path: String2(),
|
|
14549
14738
|
target: String2()
|
|
14550
|
-
},
|
|
14551
|
-
jobs: _Array_(_Object_({ name: String2(), target: String2() },
|
|
14552
|
-
},
|
|
14739
|
+
}, closed2)),
|
|
14740
|
+
jobs: _Array_(_Object_({ name: String2(), target: String2() }, closed2))
|
|
14741
|
+
}, closed2);
|
|
14553
14742
|
resultFields = {
|
|
14554
14743
|
diagnostics: _Array_(DeliveryDiagnosticSchema),
|
|
14555
14744
|
written: _Array_(String2()),
|
|
@@ -14563,13 +14752,13 @@ var init_delivery_build_schema = __esm(() => {
|
|
|
14563
14752
|
changedTargets: _Array_(String2()),
|
|
14564
14753
|
unchangedTargets: _Array_(String2()),
|
|
14565
14754
|
removedTargets: _Array_(String2())
|
|
14566
|
-
},
|
|
14755
|
+
}, closed2),
|
|
14567
14756
|
_Object_({
|
|
14568
14757
|
...resultFields,
|
|
14569
14758
|
written: _Array_(String2(), { maxItems: 0 }),
|
|
14570
14759
|
ok: Literal(false),
|
|
14571
14760
|
manifest: Null()
|
|
14572
|
-
},
|
|
14761
|
+
}, closed2)
|
|
14573
14762
|
]);
|
|
14574
14763
|
});
|
|
14575
14764
|
|
|
@@ -15037,12 +15226,12 @@ function serializedExecutionSnapshot(graph) {
|
|
|
15037
15226
|
parseExecutionSnapshot(wire);
|
|
15038
15227
|
return json;
|
|
15039
15228
|
}
|
|
15040
|
-
var
|
|
15229
|
+
var closed3, text, kind2, SnapshotSchema, EXECUTION_SNAPSHOT_MAX_BYTES = 1048576, indices, WireSnapshotSchema;
|
|
15041
15230
|
var init_execution_snapshot = __esm(() => {
|
|
15042
15231
|
init_build();
|
|
15043
15232
|
init_value2();
|
|
15044
15233
|
init_inspect();
|
|
15045
|
-
|
|
15234
|
+
closed3 = { additionalProperties: false };
|
|
15046
15235
|
text = String2({ minLength: 1, maxLength: 512, pattern: "^[^\\u0000-\\u001f\\u007f]+$" });
|
|
15047
15236
|
kind2 = Union([Literal("route"), Literal("command"), Literal("job")]);
|
|
15048
15237
|
SnapshotSchema = _Object_({
|
|
@@ -15053,12 +15242,12 @@ var init_execution_snapshot = __esm(() => {
|
|
|
15053
15242
|
name: text,
|
|
15054
15243
|
command: Optional(text),
|
|
15055
15244
|
stages: _Array_(text)
|
|
15056
|
-
},
|
|
15057
|
-
commandAliases: _Array_(_Object_({ module: text, name: text, alias: text },
|
|
15245
|
+
}, closed3)),
|
|
15246
|
+
commandAliases: _Array_(_Object_({ module: text, name: text, alias: text }, closed3)),
|
|
15058
15247
|
contexts: _Array_(_Object_({
|
|
15059
15248
|
subject: text,
|
|
15060
15249
|
aliases: _Array_(text),
|
|
15061
|
-
modules: _Array_(_Object_({ name: text, file: Optional(text) },
|
|
15250
|
+
modules: _Array_(_Object_({ name: text, file: Optional(text) }, closed3)),
|
|
15062
15251
|
files: _Array_(text),
|
|
15063
15252
|
diagnostics: _Array_(_Object_({
|
|
15064
15253
|
code: text,
|
|
@@ -15068,10 +15257,10 @@ var init_execution_snapshot = __esm(() => {
|
|
|
15068
15257
|
repair: Optional(_Object_({
|
|
15069
15258
|
type: text,
|
|
15070
15259
|
readiness: Union([Literal("preview"), Literal("input-required"), Literal("manual")])
|
|
15071
|
-
},
|
|
15072
|
-
},
|
|
15073
|
-
},
|
|
15074
|
-
},
|
|
15260
|
+
}, closed3))
|
|
15261
|
+
}, closed3))
|
|
15262
|
+
}, closed3))
|
|
15263
|
+
}, closed3);
|
|
15075
15264
|
indices = _Array_(Integer({ minimum: 0 }));
|
|
15076
15265
|
WireSnapshotSchema = _Object_({
|
|
15077
15266
|
version: Literal(1),
|
|
@@ -15086,8 +15275,8 @@ var init_execution_snapshot = __esm(() => {
|
|
|
15086
15275
|
modules: indices,
|
|
15087
15276
|
files: indices,
|
|
15088
15277
|
diagnostics: indices
|
|
15089
|
-
},
|
|
15090
|
-
},
|
|
15278
|
+
}, closed3))
|
|
15279
|
+
}, closed3);
|
|
15091
15280
|
});
|
|
15092
15281
|
|
|
15093
15282
|
// node_modules/@supacloud/delivery/src/application-development.ts
|
|
@@ -15121,7 +15310,7 @@ function parseDevelopmentContext(input) {
|
|
|
15121
15310
|
throw invalid();
|
|
15122
15311
|
}
|
|
15123
15312
|
}
|
|
15124
|
-
var APPLICATION_DEVELOPMENT_SCHEMA = "supacloud.application-development.v1", APPLICATION_DEVELOPMENT_ARCHIVE_MAX_BYTES = 524288, APPLICATION_DEVELOPMENT_LIMITS, DevelopmentContractError,
|
|
15313
|
+
var APPLICATION_DEVELOPMENT_SCHEMA = "supacloud.application-development.v1", APPLICATION_DEVELOPMENT_ARCHIVE_MAX_BYTES = 524288, APPLICATION_DEVELOPMENT_LIMITS, DevelopmentContractError, closed4, text2, texts, count, mode, operations2, resourceUse, schemaKind, stage, ContextSchema;
|
|
15125
15314
|
var init_application_development = __esm(() => {
|
|
15126
15315
|
init_build();
|
|
15127
15316
|
init_value2();
|
|
@@ -15145,13 +15334,13 @@ var init_application_development = __esm(() => {
|
|
|
15145
15334
|
this.name = "DevelopmentContractError";
|
|
15146
15335
|
}
|
|
15147
15336
|
};
|
|
15148
|
-
|
|
15337
|
+
closed4 = { additionalProperties: false };
|
|
15149
15338
|
text2 = String2({ minLength: 1, maxLength: 512, pattern: "^[^\\u0000-\\u001f\\u007f]+$" });
|
|
15150
15339
|
texts = _Array_(text2);
|
|
15151
15340
|
count = Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
|
|
15152
15341
|
mode = Union([Literal("required"), Literal("none")]);
|
|
15153
15342
|
operations2 = _Array_(Union([Literal("read"), Literal("write"), Literal("publish"), Literal("consume")]));
|
|
15154
|
-
resourceUse = _Object_({ resource: text2, operations: operations2 },
|
|
15343
|
+
resourceUse = _Object_({ resource: text2, operations: operations2 }, closed4);
|
|
15155
15344
|
schemaKind = Optional(Union([Literal("opaque"), Literal("declared")]));
|
|
15156
15345
|
stage = Union([
|
|
15157
15346
|
Union([Literal("commandExecutor"), Literal("jobExecutor"), Literal("authorize"), Literal("idempotency"), Literal("transaction"), Literal("handler"), Literal("audit")]),
|
|
@@ -15176,7 +15365,7 @@ var init_application_development = __esm(() => {
|
|
|
15176
15365
|
jobs: texts,
|
|
15177
15366
|
queries: texts,
|
|
15178
15367
|
resources: texts
|
|
15179
|
-
},
|
|
15368
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.modules }),
|
|
15180
15369
|
routes: _Array_(_Object_({
|
|
15181
15370
|
module: text2,
|
|
15182
15371
|
method: Union([Literal("GET"), Literal("POST"), Literal("PUT"), Literal("PATCH"), Literal("DELETE"), Literal("HEAD"), Literal("OPTIONS")]),
|
|
@@ -15192,8 +15381,8 @@ var init_application_development = __esm(() => {
|
|
|
15192
15381
|
headers: schemaKind,
|
|
15193
15382
|
cookie: schemaKind,
|
|
15194
15383
|
response: schemaKind
|
|
15195
|
-
},
|
|
15196
|
-
},
|
|
15384
|
+
}, closed4))
|
|
15385
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.routes }),
|
|
15197
15386
|
commands: _Array_(_Object_({
|
|
15198
15387
|
module: text2,
|
|
15199
15388
|
name: text2,
|
|
@@ -15202,28 +15391,28 @@ var init_application_development = __esm(() => {
|
|
|
15202
15391
|
idempotency: mode,
|
|
15203
15392
|
audit: Optional(text2),
|
|
15204
15393
|
resources: _Array_(resourceUse)
|
|
15205
|
-
},
|
|
15394
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.commands }),
|
|
15206
15395
|
jobs: _Array_(_Object_({
|
|
15207
15396
|
module: text2,
|
|
15208
15397
|
name: text2,
|
|
15209
15398
|
mode: Optional(Union([Literal("task"), Literal("workflow")])),
|
|
15210
15399
|
resources: _Array_(resourceUse)
|
|
15211
|
-
},
|
|
15212
|
-
resources: _Array_(_Object_({ name: text2, kind: Union([Literal("database"), Literal("bucket"), Literal("queue"), Literal("config"), Literal("secret")]) },
|
|
15400
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.jobs }),
|
|
15401
|
+
resources: _Array_(_Object_({ name: text2, kind: Union([Literal("database"), Literal("bucket"), Literal("queue"), Literal("config"), Literal("secret")]) }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resources }),
|
|
15213
15402
|
resourceUses: _Array_(_Object_({
|
|
15214
15403
|
module: text2,
|
|
15215
15404
|
owner: text2,
|
|
15216
15405
|
ownerKind: Union([Literal("command"), Literal("job")]),
|
|
15217
15406
|
resource: text2,
|
|
15218
15407
|
operations: operations2
|
|
15219
|
-
},
|
|
15408
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resourceUses }),
|
|
15220
15409
|
executionPlans: _Array_(_Object_({
|
|
15221
15410
|
module: text2,
|
|
15222
15411
|
kind: Union([Literal("route"), Literal("command"), Literal("job")]),
|
|
15223
15412
|
name: text2,
|
|
15224
15413
|
command: Optional(text2),
|
|
15225
15414
|
stages: _Array_(stage)
|
|
15226
|
-
},
|
|
15415
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.plans }),
|
|
15227
15416
|
diagnostics: _Array_(_Object_({
|
|
15228
15417
|
code: text2,
|
|
15229
15418
|
severity: Union([Literal("error"), Literal("warn")]),
|
|
@@ -15232,8 +15421,8 @@ var init_application_development = __esm(() => {
|
|
|
15232
15421
|
repair: Optional(_Object_({
|
|
15233
15422
|
type: Union([Literal("set_command_mode"), Literal("add_module_import"), Literal("add_provider"), Literal("mark_optional_dependency"), Literal("change_provider_scope"), Literal("add_command_permission"), Literal("add_route_parameter_binding"), Literal("remove_route_body_binding")]),
|
|
15234
15423
|
readiness: Union([Literal("preview"), Literal("input-required"), Literal("manual")])
|
|
15235
|
-
},
|
|
15236
|
-
},
|
|
15424
|
+
}, closed4))
|
|
15425
|
+
}, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.diagnostics }),
|
|
15237
15426
|
omitted: _Object_({
|
|
15238
15427
|
modules: count,
|
|
15239
15428
|
providers: count,
|
|
@@ -15244,7 +15433,7 @@ var init_application_development = __esm(() => {
|
|
|
15244
15433
|
resourceUses: count,
|
|
15245
15434
|
plans: count,
|
|
15246
15435
|
diagnostics: count
|
|
15247
|
-
},
|
|
15436
|
+
}, closed4),
|
|
15248
15437
|
limits: _Object_({
|
|
15249
15438
|
outputBytes: Literal(APPLICATION_DEVELOPMENT_LIMITS.outputBytes),
|
|
15250
15439
|
modules: Literal(APPLICATION_DEVELOPMENT_LIMITS.modules),
|
|
@@ -15256,8 +15445,8 @@ var init_application_development = __esm(() => {
|
|
|
15256
15445
|
resourceUses: Literal(APPLICATION_DEVELOPMENT_LIMITS.resourceUses),
|
|
15257
15446
|
plans: Literal(APPLICATION_DEVELOPMENT_LIMITS.plans),
|
|
15258
15447
|
diagnostics: Literal(APPLICATION_DEVELOPMENT_LIMITS.diagnostics)
|
|
15259
|
-
},
|
|
15260
|
-
},
|
|
15448
|
+
}, closed4)
|
|
15449
|
+
}, closed4);
|
|
15261
15450
|
});
|
|
15262
15451
|
|
|
15263
15452
|
// src/application-development.ts
|
|
@@ -15514,6 +15703,7 @@ var init_application_release = __esm(() => {
|
|
|
15514
15703
|
init_build();
|
|
15515
15704
|
init_value2();
|
|
15516
15705
|
init_delivery_files();
|
|
15706
|
+
init_worker_execution();
|
|
15517
15707
|
ApplicationIdSchema = String2({ pattern: "^[A-Za-z0-9_-]{1,64}$" });
|
|
15518
15708
|
ApplicationReleaseIdSchema = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
15519
15709
|
ApplicationReleaseRecordSchema = _Object_({
|
|
@@ -15527,7 +15717,8 @@ var init_application_release = __esm(() => {
|
|
|
15527
15717
|
name: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
|
|
15528
15718
|
object_id: ApplicationReleaseIdSchema,
|
|
15529
15719
|
kind: Union([Literal("http"), Literal("worker")]),
|
|
15530
|
-
entrypoint: Literal("bundle/index.js")
|
|
15720
|
+
entrypoint: Literal("bundle/index.js"),
|
|
15721
|
+
execution: Optional(WorkerExecutionGroupSchema)
|
|
15531
15722
|
}, { additionalProperties: false }), { minItems: 1, maxItems: 32 })
|
|
15532
15723
|
}, { additionalProperties: false });
|
|
15533
15724
|
});
|
|
@@ -15591,7 +15782,9 @@ var init_application_configuration = __esm(() => {
|
|
|
15591
15782
|
"SUPACLOUD_ACTIVATION_ID",
|
|
15592
15783
|
"SUPACLOUD_ENVIRONMENT_ID",
|
|
15593
15784
|
"SUPACLOUD_TARGET",
|
|
15594
|
-
"SUPACLOUD_OBJECT_ID"
|
|
15785
|
+
"SUPACLOUD_OBJECT_ID",
|
|
15786
|
+
"SUPACLOUD_WORKER_EXECUTION",
|
|
15787
|
+
"SUPACLOUD_WORKER_REPLICA"
|
|
15595
15788
|
]);
|
|
15596
15789
|
});
|
|
15597
15790
|
|
|
@@ -15625,6 +15818,107 @@ var init_application_activation = __esm(() => {
|
|
|
15625
15818
|
}, { additionalProperties: false });
|
|
15626
15819
|
});
|
|
15627
15820
|
|
|
15821
|
+
// node_modules/@supacloud/delivery/src/deployment-evidence.ts
|
|
15822
|
+
var closed6, sha256, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
|
|
15823
|
+
var init_deployment_evidence = __esm(() => {
|
|
15824
|
+
init_build();
|
|
15825
|
+
init_value2();
|
|
15826
|
+
init_application_configuration();
|
|
15827
|
+
init_application_release();
|
|
15828
|
+
closed6 = { additionalProperties: false };
|
|
15829
|
+
sha256 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
15830
|
+
isoDate = String2({ minLength: 20, maxLength: 40 });
|
|
15831
|
+
status = Union([
|
|
15832
|
+
Literal("confirmed"),
|
|
15833
|
+
Literal("failed"),
|
|
15834
|
+
Literal("unknown")
|
|
15835
|
+
]);
|
|
15836
|
+
evidenceStatus = Union([
|
|
15837
|
+
Literal("confirmed"),
|
|
15838
|
+
Literal("failed"),
|
|
15839
|
+
Literal("unknown"),
|
|
15840
|
+
Literal("incomplete")
|
|
15841
|
+
]);
|
|
15842
|
+
DatabaseProviderSchema = _Object_({
|
|
15843
|
+
provider: String2({ minLength: 1, maxLength: 64, pattern: "^[a-z][a-z0-9_.-]*$" }),
|
|
15844
|
+
version: String2({ minLength: 1, maxLength: 64 }),
|
|
15845
|
+
topology: Union([Literal("single-node"), Literal("distributed")]),
|
|
15846
|
+
migration: _Object_({
|
|
15847
|
+
status,
|
|
15848
|
+
inventory_sha256: Union([sha256, Null()]),
|
|
15849
|
+
compatibility: Union([
|
|
15850
|
+
Literal("verified"),
|
|
15851
|
+
Literal("not-proven"),
|
|
15852
|
+
Literal("failed")
|
|
15853
|
+
])
|
|
15854
|
+
}, closed6),
|
|
15855
|
+
backup: _Object_({
|
|
15856
|
+
status,
|
|
15857
|
+
latest_success_at: Union([isoDate, Null()]),
|
|
15858
|
+
freshness_seconds: Union([Integer({ minimum: 0 }), Null()])
|
|
15859
|
+
}, closed6),
|
|
15860
|
+
recovery: _Object_({
|
|
15861
|
+
status,
|
|
15862
|
+
drill_id: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
15863
|
+
rpo_seconds: Union([Integer({ minimum: 0 }), Null()]),
|
|
15864
|
+
rto_seconds: Union([Integer({ minimum: 0 }), Null()])
|
|
15865
|
+
}, closed6)
|
|
15866
|
+
}, closed6);
|
|
15867
|
+
componentName = Union([
|
|
15868
|
+
Literal("management-api"),
|
|
15869
|
+
Literal("web-console"),
|
|
15870
|
+
Literal("edge-runtime"),
|
|
15871
|
+
Literal("worker"),
|
|
15872
|
+
Literal("postgres"),
|
|
15873
|
+
Literal("postgrest"),
|
|
15874
|
+
Literal("gotrue"),
|
|
15875
|
+
Literal("storage"),
|
|
15876
|
+
Literal("realtime")
|
|
15877
|
+
]);
|
|
15878
|
+
DeploymentComponentEvidenceSchema = _Object_({
|
|
15879
|
+
name: componentName,
|
|
15880
|
+
version: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
15881
|
+
status,
|
|
15882
|
+
health_check: Union([String2({ minLength: 1, maxLength: 256 }), Null()]),
|
|
15883
|
+
checked_at: Union([isoDate, Null()])
|
|
15884
|
+
}, closed6);
|
|
15885
|
+
DeploymentEvidenceSchema = _Object_({
|
|
15886
|
+
schema: Literal(DEPLOYMENT_EVIDENCE_SCHEMA),
|
|
15887
|
+
status: evidenceStatus,
|
|
15888
|
+
recorded_at: isoDate,
|
|
15889
|
+
scope: _Object_({
|
|
15890
|
+
project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
|
|
15891
|
+
application_id: ApplicationIdSchema,
|
|
15892
|
+
environment_id: ApplicationIdSchema
|
|
15893
|
+
}, closed6),
|
|
15894
|
+
source: _Object_({
|
|
15895
|
+
commit_sha: Union([String2({ pattern: "^[0-9a-f]{7,64}$" }), Null()]),
|
|
15896
|
+
manifest_sha256: sha256,
|
|
15897
|
+
contract_schema: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
15898
|
+
environment_binding_version: Union([sha256, Null()])
|
|
15899
|
+
}, closed6),
|
|
15900
|
+
database: DatabaseProviderSchema,
|
|
15901
|
+
components: _Array_(DeploymentComponentEvidenceSchema, { minItems: 1, maxItems: 32 }),
|
|
15902
|
+
activation: _Object_({
|
|
15903
|
+
release_id: ApplicationReleaseIdSchema,
|
|
15904
|
+
configuration_id: ApplicationConfigurationIdSchema,
|
|
15905
|
+
activation_id: ApplicationConfigurationIdSchema
|
|
15906
|
+
}, closed6),
|
|
15907
|
+
health: _Object_({
|
|
15908
|
+
status,
|
|
15909
|
+
checked_at: Union([isoDate, Null()]),
|
|
15910
|
+
authenticated_smoke: status
|
|
15911
|
+
}, closed6),
|
|
15912
|
+
rollback: _Object_({
|
|
15913
|
+
release_id: Union([ApplicationReleaseIdSchema, Null()]),
|
|
15914
|
+
configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
|
|
15915
|
+
status: Union([Literal("ready"), Literal("not-ready"), Literal("unknown")]),
|
|
15916
|
+
result: Union([status, Null()])
|
|
15917
|
+
}, closed6),
|
|
15918
|
+
notes: _Array_(String2({ minLength: 1, maxLength: 512 }), { maxItems: 32 })
|
|
15919
|
+
}, closed6);
|
|
15920
|
+
});
|
|
15921
|
+
|
|
15628
15922
|
// node_modules/@supacloud/delivery/src/application-runtime-identity.ts
|
|
15629
15923
|
var APPLICATION_RUNTIME_PROBE_PATH = "/.well-known/supacloud/runtime", ApplicationRuntimeIdentitySchema, ApplicationReadinessReportSchema;
|
|
15630
15924
|
var init_application_runtime_identity = __esm(() => {
|
|
@@ -15743,9 +16037,11 @@ var init_delivery_migration_plan = () => {};
|
|
|
15743
16037
|
// node_modules/@supacloud/delivery/src/index.ts
|
|
15744
16038
|
var init_src = __esm(() => {
|
|
15745
16039
|
init_delivery_artifact();
|
|
16040
|
+
init_worker_execution();
|
|
15746
16041
|
init_application_activation();
|
|
15747
16042
|
init_application_release();
|
|
15748
16043
|
init_application_configuration();
|
|
16044
|
+
init_deployment_evidence();
|
|
15749
16045
|
init_application_runtime_identity();
|
|
15750
16046
|
init_delivery_build_schema();
|
|
15751
16047
|
init_delivery_migration_archive();
|
|
@@ -20412,6 +20708,17 @@ function createDeliveryPlan(graph, input) {
|
|
|
20412
20708
|
}
|
|
20413
20709
|
}
|
|
20414
20710
|
}
|
|
20711
|
+
for (const group of options.execution?.groups ?? []) {
|
|
20712
|
+
const target = targets.get(group.target);
|
|
20713
|
+
if (!target || target.kind !== "jobs" || target.isolation !== "process" || target.jobs.length !== 1 || target.jobs[0]?.name !== group.taskKey || !options.build?.workerApplications?.some((item) => item.target === group.target)) {
|
|
20714
|
+
fail("delivery-execution-binding-invalid", `Execution group "${group.name}" requires one matching compiled Job and a Worker host.`, "Bind one versioned queue/task to one process-isolated jobs target with build.workerApplications.");
|
|
20715
|
+
} else {
|
|
20716
|
+
target.execution = group;
|
|
20717
|
+
}
|
|
20718
|
+
}
|
|
20719
|
+
if ([...targets.values()].reduce((count, target) => count + (target.execution?.replicas ?? 1), 0) > 32) {
|
|
20720
|
+
fail("delivery-execution-replica-limit", "A release supports at most 32 runtime targets including replicas.", "Reduce the replica count or split independent applications.");
|
|
20721
|
+
}
|
|
20415
20722
|
const canonicalDiagnostics = [...new Map(diagnostics.map((item) => [JSON.stringify(item), item])).values()].sort((a, b) => compare2(JSON.stringify(a), JSON.stringify(b)));
|
|
20416
20723
|
if (canonicalDiagnostics.some((item) => item.severity === "error")) {
|
|
20417
20724
|
return parseDeliveryPlanResult({ ok: false, plan: null, diagnostics: canonicalDiagnostics, written: [] });
|
|
@@ -20590,7 +20897,7 @@ function staticDeliveryImports(path, contents) {
|
|
|
20590
20897
|
// src/delivery-bundle-protocol.ts
|
|
20591
20898
|
init_build();
|
|
20592
20899
|
init_value2();
|
|
20593
|
-
var
|
|
20900
|
+
var closed5 = { additionalProperties: false };
|
|
20594
20901
|
var requestSchema = _Object_({
|
|
20595
20902
|
parentPid: Integer({ minimum: 1 }),
|
|
20596
20903
|
name: String2(),
|
|
@@ -20598,15 +20905,15 @@ var requestSchema = _Object_({
|
|
|
20598
20905
|
project: String2(),
|
|
20599
20906
|
generatedDirectory: String2(),
|
|
20600
20907
|
options: DeliveryOptionsSchema
|
|
20601
|
-
},
|
|
20908
|
+
}, closed5);
|
|
20602
20909
|
var responseSchema = Union([
|
|
20603
20910
|
_Object_({
|
|
20604
20911
|
ok: Literal(true),
|
|
20605
20912
|
files: _Array_(Tuple([DeliveryFilePathSchema, String2({ pattern: "^[A-Za-z0-9+/]*={0,2}$" })])),
|
|
20606
20913
|
inputs: _Array_(Tuple([String2(), String2({ pattern: "^[a-f0-9]{64}$" })])),
|
|
20607
20914
|
runtimeImports: _Array_(String2())
|
|
20608
|
-
},
|
|
20609
|
-
_Object_({ ok: Literal(false) },
|
|
20915
|
+
}, closed5),
|
|
20916
|
+
_Object_({ ok: Literal(false) }, closed5)
|
|
20610
20917
|
]);
|
|
20611
20918
|
function parseDeliveryBundleRequest(input) {
|
|
20612
20919
|
if (!Check2(requestSchema, input))
|
|
@@ -20922,6 +21229,7 @@ function renderDeliveryWorkerEntry(generatedDirectory, hostPath) {
|
|
|
20922
21229
|
const specifier = relativeImportPath(generatedDirectory, hostPath);
|
|
20923
21230
|
return `
|
|
20924
21231
|
import deliveryProcess from "node:process";
|
|
21232
|
+
import { isDeepStrictEqual as deliveryPolicyEqual } from "node:util";
|
|
20925
21233
|
import { createDeliveryWorker } from ${JSON.stringify(specifier)};
|
|
20926
21234
|
${renderDeliveryRuntimeIdentity()}
|
|
20927
21235
|
|
|
@@ -20929,6 +21237,8 @@ interface DeliveryWorkerHost {
|
|
|
20929
21237
|
start(): void | Promise<void>;
|
|
20930
21238
|
close(): void | Promise<void>;
|
|
20931
21239
|
failure?: Promise<never>;
|
|
21240
|
+
execution?: unknown;
|
|
21241
|
+
health?(): Promise<{ ready: boolean; active: number; completed: number; failed: number; timedOut: number }>;
|
|
20932
21242
|
}
|
|
20933
21243
|
|
|
20934
21244
|
{
|
|
@@ -20940,6 +21250,7 @@ interface DeliveryWorkerHost {
|
|
|
20940
21250
|
let closing: Promise<void> | undefined;
|
|
20941
21251
|
let deadline: ReturnType<typeof setTimeout> | undefined;
|
|
20942
21252
|
let keepAlive: ReturnType<typeof setInterval> | undefined;
|
|
21253
|
+
let healthPending = false;
|
|
20943
21254
|
const finish = (failed: boolean) => {
|
|
20944
21255
|
clearTimeout(deadline);
|
|
20945
21256
|
clearInterval(keepAlive);
|
|
@@ -21000,6 +21311,13 @@ interface DeliveryWorkerHost {
|
|
|
21000
21311
|
const candidate = await createHost(createCompiledModules(), { signal: lifecycle.signal });
|
|
21001
21312
|
if (!candidate || typeof candidate.close !== "function") throw new Error("Invalid delivery worker host.");
|
|
21002
21313
|
host = candidate;
|
|
21314
|
+
const execution = deliveryProcess.env.SUPACLOUD_WORKER_EXECUTION;
|
|
21315
|
+
if (execution) {
|
|
21316
|
+
const expected: unknown = JSON.parse(Buffer.from(execution, "base64").toString("utf8"));
|
|
21317
|
+
if (!deliveryPolicyEqual(host.execution, expected) || typeof host.health !== "function" || !host.failure) {
|
|
21318
|
+
throw new Error("Delivery worker execution policy was not adopted.");
|
|
21319
|
+
}
|
|
21320
|
+
}
|
|
21003
21321
|
if (typeof host.start !== "function") throw new Error("Invalid delivery worker host.");
|
|
21004
21322
|
if (host.failure !== undefined) {
|
|
21005
21323
|
if (!host.failure || typeof host.failure.then !== "function") throw new Error("Invalid worker failure signal.");
|
|
@@ -21011,7 +21329,18 @@ interface DeliveryWorkerHost {
|
|
|
21011
21329
|
await finishShutdown();
|
|
21012
21330
|
} else {
|
|
21013
21331
|
running = true;
|
|
21014
|
-
|
|
21332
|
+
const health = async () => {
|
|
21333
|
+
if (!execution || !host?.health || healthPending || lifecycle.signal.aborted) return;
|
|
21334
|
+
healthPending = true;
|
|
21335
|
+
try {
|
|
21336
|
+
const status = await host.health();
|
|
21337
|
+
console.log(JSON.stringify({ event: "delivery-worker-health", identity, observedAt: new Date().toISOString(), ...status }));
|
|
21338
|
+
} catch {
|
|
21339
|
+
console.log(JSON.stringify({ event: "delivery-worker-health", identity, observedAt: new Date().toISOString(), ready: false }));
|
|
21340
|
+
} finally { healthPending = false; }
|
|
21341
|
+
};
|
|
21342
|
+
keepAlive = setInterval(() => { void health(); }, execution ? 5000 : 1000);
|
|
21343
|
+
await health();
|
|
21015
21344
|
console.log(JSON.stringify({ event: "delivery-worker-started", ...(identity ? { identity } : {}) }));
|
|
21016
21345
|
}
|
|
21017
21346
|
} catch {
|
|
@@ -23028,7 +23357,7 @@ function isRecord2(value) {
|
|
|
23028
23357
|
function arrayLength(value) {
|
|
23029
23358
|
return Array.isArray(value) ? value.length : undefined;
|
|
23030
23359
|
}
|
|
23031
|
-
async function
|
|
23360
|
+
async function sha2562(path) {
|
|
23032
23361
|
return createHash10("sha256").update(await readFile11(path)).digest("hex");
|
|
23033
23362
|
}
|
|
23034
23363
|
function overallStatus(findings) {
|
|
@@ -23102,7 +23431,7 @@ async function assessMigration(options) {
|
|
|
23102
23431
|
contractsManifest = {
|
|
23103
23432
|
path: contractsManifestPath,
|
|
23104
23433
|
present: true,
|
|
23105
|
-
sha256: await
|
|
23434
|
+
sha256: await sha2562(contractsManifestPath),
|
|
23106
23435
|
version: 1,
|
|
23107
23436
|
...arrayLength(parsed.commands) === undefined ? {} : { commands: arrayLength(parsed.commands) },
|
|
23108
23437
|
...arrayLength(parsed.routes) === undefined ? {} : { routes: arrayLength(parsed.routes) },
|
|
@@ -23125,9 +23454,9 @@ async function assessMigration(options) {
|
|
|
23125
23454
|
const diff = diffOpenApiDocuments(await readOpenApiJson(baselinePath), await readOpenApiJson(currentPath));
|
|
23126
23455
|
openApi = {
|
|
23127
23456
|
baselinePath,
|
|
23128
|
-
baselineSha256: await
|
|
23457
|
+
baselineSha256: await sha2562(baselinePath),
|
|
23129
23458
|
currentPath,
|
|
23130
|
-
currentSha256: await
|
|
23459
|
+
currentSha256: await sha2562(currentPath),
|
|
23131
23460
|
diff
|
|
23132
23461
|
};
|
|
23133
23462
|
if (!diff.ok) {
|