@supacloud/compiler 0.32.0 → 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 +227 -10
- package/dist/index.js +227 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -495,6 +495,11 @@ route 会自动按 HTTP status 执行内置 response decoder,并返回 schema
|
|
|
495
495
|
OpenAPI。`buildRouteUrl` 和 `createApiClient` 可直接复用,也支持动态 headers
|
|
496
496
|
和请求拦截器。
|
|
497
497
|
|
|
498
|
+
每个生成 route 还会按 HTTP 方法暴露 `.query()` 或 `.mutate()` procedure
|
|
499
|
+
facade,并在 `API_PROCEDURES` 中输出 Command/幂等元数据。声明
|
|
500
|
+
`idempotency: "required"` 的 mutation 必须显式传入稳定的 `idempotencyKey`;
|
|
501
|
+
客户端不会静默生成新 key。
|
|
502
|
+
|
|
498
503
|
### Migration from manual decoders
|
|
499
504
|
|
|
500
505
|
旧版本要求调用方为每个有响应 schema 的 route 传入 decoder。升级后删除该
|
package/dist/cli.js
CHANGED
|
@@ -2245,6 +2245,8 @@ function renderClient(graph, options) {
|
|
|
2245
2245
|
const schemaLocals = new Map;
|
|
2246
2246
|
const usedTypeNames = new Set;
|
|
2247
2247
|
const allRoutes = [];
|
|
2248
|
+
const allProcedures = [];
|
|
2249
|
+
const commandByClassName = new Map(graph.modules.flatMap((module) => module.commands.map((command) => [command.className, command])));
|
|
2248
2250
|
let usesStatic = false;
|
|
2249
2251
|
let usesValue = false;
|
|
2250
2252
|
const uniqueTypeName = (candidate) => {
|
|
@@ -2375,8 +2377,21 @@ function renderClient(graph, options) {
|
|
|
2375
2377
|
const responseSchemaEntries = hasResponseMap ? Object.entries(responseSchemas).map(([status, ref]) => [status, ref.local]) : responseSchema ? [["200", responseSchema.local]] : [];
|
|
2376
2378
|
const responseSchemaArgument = responseSchemaEntries.length > 0 ? `{ ${responseSchemaEntries.map(([status, local]) => `${JSON.stringify(status)}: ${local}`).join(", ")} }` : "undefined";
|
|
2377
2379
|
const responseKindArgument = responseKind === undefined ? "undefined" : JSON.stringify(responseKind);
|
|
2380
|
+
const command = route.command === undefined ? undefined : commandByClassName.get(route.command);
|
|
2381
|
+
const procedureKind = route.method === "GET" || route.method === "HEAD" ? "query" : "mutation";
|
|
2382
|
+
const idempotencyMode = command?.idempotency ?? "none";
|
|
2383
|
+
allProcedures.push({
|
|
2384
|
+
method: route.method,
|
|
2385
|
+
path: fullPath,
|
|
2386
|
+
controller: controller.className,
|
|
2387
|
+
handler: route.handler,
|
|
2388
|
+
kind: procedureKind,
|
|
2389
|
+
...command?.name === undefined ? {} : { command: command.name },
|
|
2390
|
+
...command?.permission === undefined ? {} : { permission: command.permission },
|
|
2391
|
+
idempotency: idempotencyMode
|
|
2392
|
+
});
|
|
2378
2393
|
routeMethods.push(`
|
|
2379
|
-
${route.handler}: makeRoute<${requestTypeName}, ${responseType === "never" ? "never" : responseTypeName}>(${JSON.stringify(route.method)}, ${JSON.stringify(fullPath)}, ${responseSchemaArgument}, ${responseKindArgument}, ${route.parse === "none"}),`);
|
|
2394
|
+
${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)}),`);
|
|
2380
2395
|
}
|
|
2381
2396
|
controllerEntries.push(`
|
|
2382
2397
|
${controllerKey}: {${routeMethods.join("")}
|
|
@@ -2407,6 +2422,43 @@ function renderClient(graph, options) {
|
|
|
2407
2422
|
"",
|
|
2408
2423
|
"export type ResponseDecoder<T> = (value: unknown) => T;",
|
|
2409
2424
|
"",
|
|
2425
|
+
'export type ProcedureKind = "query" | "mutation";',
|
|
2426
|
+
'export type IdempotencyMode = "required" | "none";',
|
|
2427
|
+
"",
|
|
2428
|
+
"export interface ProcedureExecutionOptions {",
|
|
2429
|
+
" /** Reuse the same key when retrying an uncertain mutation. */",
|
|
2430
|
+
" idempotencyKey?: string;",
|
|
2431
|
+
" signal?: AbortSignal;",
|
|
2432
|
+
"}",
|
|
2433
|
+
"",
|
|
2434
|
+
"export type RequiredProcedureExecutionOptions = ProcedureExecutionOptions & { idempotencyKey: string };",
|
|
2435
|
+
"",
|
|
2436
|
+
"type ProcedureResult<Result> = [Result] extends [never] ? unknown : Result;",
|
|
2437
|
+
"",
|
|
2438
|
+
"type ProcedureArgs<Options extends ClientRequestOptions, Idempotency extends IdempotencyMode> =",
|
|
2439
|
+
' Idempotency extends "required"',
|
|
2440
|
+
" ? {} extends Options",
|
|
2441
|
+
" ? [execution: RequiredProcedureExecutionOptions] | [input: Options, execution: RequiredProcedureExecutionOptions]",
|
|
2442
|
+
" : [input: Options, execution: RequiredProcedureExecutionOptions]",
|
|
2443
|
+
" : {} extends Options",
|
|
2444
|
+
" ? [input?: Options, execution?: ProcedureExecutionOptions]",
|
|
2445
|
+
" : [input: Options, execution?: ProcedureExecutionOptions];",
|
|
2446
|
+
"",
|
|
2447
|
+
"export type ProcedureCall<",
|
|
2448
|
+
" Options extends ClientRequestOptions = ClientRequestOptions,",
|
|
2449
|
+
" Result = never,",
|
|
2450
|
+
' Idempotency extends IdempotencyMode = "none",',
|
|
2451
|
+
"> = (...args: ProcedureArgs<Options, Idempotency>) => Promise<ProcedureResult<Result>>;",
|
|
2452
|
+
"",
|
|
2453
|
+
"export type ProcedureMember<",
|
|
2454
|
+
" Options extends ClientRequestOptions,",
|
|
2455
|
+
" Result,",
|
|
2456
|
+
" Kind extends ProcedureKind,",
|
|
2457
|
+
" Idempotency extends IdempotencyMode,",
|
|
2458
|
+
'> = Kind extends "query"',
|
|
2459
|
+
" ? { query: ProcedureCall<Options, Result, Idempotency> }",
|
|
2460
|
+
" : { mutate: ProcedureCall<Options, Result, Idempotency> };",
|
|
2461
|
+
"",
|
|
2410
2462
|
'export type ApiClientErrorCode = "API_HTTP_ERROR" | "API_RESPONSE_INVALID" | "API_RESPONSE_UNDECLARED";',
|
|
2411
2463
|
"",
|
|
2412
2464
|
"export interface ApiClientErrorDetails {",
|
|
@@ -2450,6 +2502,17 @@ function renderClient(graph, options) {
|
|
|
2450
2502
|
" : { (options: Options): Promise<Result>; <T>(options: Options, decode: ResponseDecoder<T>): Promise<T> }",
|
|
2451
2503
|
") & ((...args: {} extends Options ? [options?: Options] : [options: Options]) => Promise<[Result] extends [never] ? unknown : Result>);",
|
|
2452
2504
|
"",
|
|
2505
|
+
"export interface ApiProcedureDefinition {",
|
|
2506
|
+
" method: string;",
|
|
2507
|
+
" path: string;",
|
|
2508
|
+
" controller: string;",
|
|
2509
|
+
" handler: string;",
|
|
2510
|
+
" kind: ProcedureKind;",
|
|
2511
|
+
" command?: string;",
|
|
2512
|
+
" permission?: string;",
|
|
2513
|
+
" idempotency: IdempotencyMode;",
|
|
2514
|
+
"}",
|
|
2515
|
+
"",
|
|
2453
2516
|
...routeTypes,
|
|
2454
2517
|
...routeTypes.length > 0 ? [""] : [],
|
|
2455
2518
|
"export interface HttpInterceptorRequest {",
|
|
@@ -2457,6 +2520,7 @@ function renderClient(graph, options) {
|
|
|
2457
2520
|
" url: string;",
|
|
2458
2521
|
" headers: Record<string, string>;",
|
|
2459
2522
|
" body?: unknown;",
|
|
2523
|
+
" signal?: AbortSignal;",
|
|
2460
2524
|
"}",
|
|
2461
2525
|
"",
|
|
2462
2526
|
"export type HttpInterceptorFn = (",
|
|
@@ -2475,6 +2539,8 @@ function renderClient(graph, options) {
|
|
|
2475
2539
|
"",
|
|
2476
2540
|
"export const API_ROUTES = " + JSON.stringify(allRoutes, null, 2) + " as const;",
|
|
2477
2541
|
"",
|
|
2542
|
+
"export const API_PROCEDURES: readonly ApiProcedureDefinition[] = " + JSON.stringify(allProcedures, null, 2) + ";",
|
|
2543
|
+
"",
|
|
2478
2544
|
"export type AppRoutePath = typeof API_ROUTES[number]['path'];",
|
|
2479
2545
|
"",
|
|
2480
2546
|
"export const API_SCHEMAS = [",
|
|
@@ -2700,6 +2766,7 @@ function renderClient(graph, options) {
|
|
|
2700
2766
|
` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
|
|
2701
2767
|
" responseKind?: string,",
|
|
2702
2768
|
" raw?: boolean,",
|
|
2769
|
+
" execution?: ProcedureExecutionOptions,",
|
|
2703
2770
|
" ): Promise<T>;",
|
|
2704
2771
|
" async function request<T>(",
|
|
2705
2772
|
" method: string,",
|
|
@@ -2709,6 +2776,7 @@ function renderClient(graph, options) {
|
|
|
2709
2776
|
` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
|
|
2710
2777
|
" responseKind?: string,",
|
|
2711
2778
|
" raw?: boolean,",
|
|
2779
|
+
" execution?: ProcedureExecutionOptions,",
|
|
2712
2780
|
" ): Promise<T | unknown>;",
|
|
2713
2781
|
" async function request(",
|
|
2714
2782
|
" method: string,",
|
|
@@ -2723,6 +2791,7 @@ function renderClient(graph, options) {
|
|
|
2723
2791
|
` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
|
|
2724
2792
|
" responseKind?: string,",
|
|
2725
2793
|
" raw = false,",
|
|
2794
|
+
" execution?: ProcedureExecutionOptions,",
|
|
2726
2795
|
" ): Promise<T | unknown> {",
|
|
2727
2796
|
" const url = `${baseUrl}${buildRouteUrl(path, options.params, options.query)}`;",
|
|
2728
2797
|
' const customHeaders = typeof config.headers === "function" ? await config.headers() : config.headers;',
|
|
@@ -2748,9 +2817,10 @@ function renderClient(graph, options) {
|
|
|
2748
2817
|
" headers: reqPayload.headers,",
|
|
2749
2818
|
" ...(reqPayload.body === undefined ? {} : { body: raw ? rawBody(reqPayload.body) : JSON.stringify(reqPayload.body) }),",
|
|
2750
2819
|
' ...(raw && reqPayload.body instanceof ReadableStream ? { duplex: "half" } : {}),',
|
|
2820
|
+
" ...(reqPayload.signal === undefined ? {} : { signal: reqPayload.signal }),",
|
|
2751
2821
|
" });",
|
|
2752
2822
|
" };",
|
|
2753
|
-
" const response = await executeChain(0, { method, url, headers, body: options.body });",
|
|
2823
|
+
" const response = await executeChain(0, { method, url, headers, body: options.body, ...(execution?.signal === undefined ? {} : { signal: execution.signal }) });",
|
|
2754
2824
|
" const declaredSchema = responseSchemas ? selectResponseSchema(response.status, responseSchemas) : undefined;",
|
|
2755
2825
|
" const failure = (code: ApiClientErrorCode, message: string) => new ApiClientError(message, {",
|
|
2756
2826
|
' code, method, path, status: response.status, requestId: response.headers.get("x-request-id"),',
|
|
@@ -2788,7 +2858,44 @@ function renderClient(graph, options) {
|
|
|
2788
2858
|
" return decode ? decode(checked) : checked;",
|
|
2789
2859
|
" }",
|
|
2790
2860
|
"",
|
|
2791
|
-
|
|
2861
|
+
" function hasHeader(headers: Record<string, string>, name: string): boolean {",
|
|
2862
|
+
" return Object.keys(headers).some((key) => key.toLowerCase() === name.toLowerCase());",
|
|
2863
|
+
" }",
|
|
2864
|
+
"",
|
|
2865
|
+
" function withProcedureExecution(",
|
|
2866
|
+
" options: ClientRequestOptions,",
|
|
2867
|
+
" execution: ProcedureExecutionOptions | undefined,",
|
|
2868
|
+
" idempotency: IdempotencyMode,",
|
|
2869
|
+
" ): ClientRequestOptions {",
|
|
2870
|
+
" const headers = { ...(options.headers as Record<string, string> | undefined) };",
|
|
2871
|
+
" if (execution?.idempotencyKey !== undefined) {",
|
|
2872
|
+
" if (!/^[A-Za-z0-9._:-]{1,512}$/.test(execution.idempotencyKey)) {",
|
|
2873
|
+
' throw new TypeError("idempotencyKey must contain only safe header characters and be at most 512 characters");',
|
|
2874
|
+
" }",
|
|
2875
|
+
' headers["idempotency-key"] = execution.idempotencyKey;',
|
|
2876
|
+
" }",
|
|
2877
|
+
' if (idempotency === "required" && !hasHeader(headers, "idempotency-key")) {',
|
|
2878
|
+
' throw new TypeError("This mutation requires an idempotencyKey");',
|
|
2879
|
+
" }",
|
|
2880
|
+
" return Object.keys(headers).length === 0 ? options : { ...options, headers };",
|
|
2881
|
+
" }",
|
|
2882
|
+
"",
|
|
2883
|
+
" function isProcedureExecution(value: unknown): value is ProcedureExecutionOptions {",
|
|
2884
|
+
' if (value === null || typeof value !== "object" || Array.isArray(value)) return false;',
|
|
2885
|
+
' return Object.hasOwn(value, "idempotencyKey") || Object.hasOwn(value, "signal");',
|
|
2886
|
+
" }",
|
|
2887
|
+
"",
|
|
2888
|
+
` 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> {`,
|
|
2889
|
+
" const procedure = async (first?: Options | ProcedureExecutionOptions, second?: ProcedureExecutionOptions): Promise<unknown> => {",
|
|
2890
|
+
" const execution = second ?? (isProcedureExecution(first) ? first : undefined);",
|
|
2891
|
+
" const input = (execution === first ? undefined : first) ?? {};",
|
|
2892
|
+
" const requestOptions = withProcedureExecution(input as ClientRequestOptions, execution, idempotency);",
|
|
2893
|
+
" return request(method, path, requestOptions, undefined, responseSchemas, responseKind, raw, execution);",
|
|
2894
|
+
" };",
|
|
2895
|
+
" return procedure as ProcedureCall<Options, Result, Idempotency>;",
|
|
2896
|
+
" }",
|
|
2897
|
+
"",
|
|
2898
|
+
` 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> {`,
|
|
2792
2899
|
" function route<T>(options: Options, decode: ResponseDecoder<T>): Promise<T>;",
|
|
2793
2900
|
" function route(options: Options): Promise<Result>;",
|
|
2794
2901
|
" function route(options?: Options): Promise<unknown>;",
|
|
@@ -2796,13 +2903,16 @@ function renderClient(graph, options) {
|
|
|
2796
2903
|
" const requestOptions = options ?? {};",
|
|
2797
2904
|
" return request(method, path, requestOptions, decode, responseSchemas, responseKind, raw);",
|
|
2798
2905
|
" }",
|
|
2799
|
-
|
|
2906
|
+
' if (kind === "query") Object.assign(route, { query: makeProcedure<Options, Result, Idempotency>(method, path, responseSchemas, responseKind, raw, idempotency) });',
|
|
2907
|
+
' if (kind === "mutation") Object.assign(route, { mutate: makeProcedure<Options, Result, Idempotency>(method, path, responseSchemas, responseKind, raw, idempotency) });',
|
|
2908
|
+
" return route as RouteMethod<Options, Result> & ProcedureMember<Options, Result, Kind, Idempotency>;",
|
|
2800
2909
|
" }",
|
|
2801
2910
|
"",
|
|
2802
2911
|
" return {",
|
|
2803
2912
|
" request,",
|
|
2804
2913
|
" buildRouteUrl,",
|
|
2805
2914
|
" routes: API_ROUTES,",
|
|
2915
|
+
" procedures: API_PROCEDURES,",
|
|
2806
2916
|
...controllerEntries,
|
|
2807
2917
|
" };",
|
|
2808
2918
|
"}",
|
|
@@ -15670,6 +15780,9 @@ function parseDeliveryBuildManifest(value) {
|
|
|
15670
15780
|
if (!Check2(DeliveryBuildManifestSchema, value))
|
|
15671
15781
|
throw new Error("Invalid delivery build manifest.");
|
|
15672
15782
|
validateWorkerExecution(value.plan.targets.flatMap((target) => target.execution ? [target.execution] : []));
|
|
15783
|
+
if (value.plan.targets.reduce((count, target) => count + (target.execution?.replicas ?? 1), 0) > 32) {
|
|
15784
|
+
throw new Error("Invalid delivery replica count.");
|
|
15785
|
+
}
|
|
15673
15786
|
for (const target of value.plan.targets) {
|
|
15674
15787
|
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")) {
|
|
15675
15788
|
throw new Error("Invalid delivery execution binding.");
|
|
@@ -15683,7 +15796,7 @@ function parseDeliveryBuildManifest(value) {
|
|
|
15683
15796
|
}
|
|
15684
15797
|
for (const object of value.objects) {
|
|
15685
15798
|
const target = value.plan.targets.find((target) => target.name === object.name);
|
|
15686
|
-
if (
|
|
15799
|
+
if (["bun-worker-application", "go-worker-application", "scriptc-worker-application"].includes(object.entryKind) && target?.kind !== "jobs" || object.entryKind === "bun-http-application" && target?.kind === "jobs") {
|
|
15687
15800
|
throw new Error("Delivery executable kind does not match its target.");
|
|
15688
15801
|
}
|
|
15689
15802
|
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) {
|
|
@@ -15721,7 +15834,9 @@ var init_delivery_build_schema = __esm(() => {
|
|
|
15721
15834
|
entryKind: Union([
|
|
15722
15835
|
Literal("compiled-module-factory"),
|
|
15723
15836
|
Literal("bun-http-application"),
|
|
15724
|
-
Literal("bun-worker-application")
|
|
15837
|
+
Literal("bun-worker-application"),
|
|
15838
|
+
Literal("go-worker-application"),
|
|
15839
|
+
Literal("scriptc-worker-application")
|
|
15725
15840
|
]),
|
|
15726
15841
|
runtimeImports: _Array_(String2()),
|
|
15727
15842
|
files: _Array_(_Object_({
|
|
@@ -16252,6 +16367,107 @@ var init_application_activation = __esm(() => {
|
|
|
16252
16367
|
}, { additionalProperties: false });
|
|
16253
16368
|
});
|
|
16254
16369
|
|
|
16370
|
+
// node_modules/@supacloud/delivery/src/deployment-evidence.ts
|
|
16371
|
+
var closed6, sha256, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
|
|
16372
|
+
var init_deployment_evidence = __esm(() => {
|
|
16373
|
+
init_build();
|
|
16374
|
+
init_value2();
|
|
16375
|
+
init_application_configuration();
|
|
16376
|
+
init_application_release();
|
|
16377
|
+
closed6 = { additionalProperties: false };
|
|
16378
|
+
sha256 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
16379
|
+
isoDate = String2({ minLength: 20, maxLength: 40 });
|
|
16380
|
+
status = Union([
|
|
16381
|
+
Literal("confirmed"),
|
|
16382
|
+
Literal("failed"),
|
|
16383
|
+
Literal("unknown")
|
|
16384
|
+
]);
|
|
16385
|
+
evidenceStatus = Union([
|
|
16386
|
+
Literal("confirmed"),
|
|
16387
|
+
Literal("failed"),
|
|
16388
|
+
Literal("unknown"),
|
|
16389
|
+
Literal("incomplete")
|
|
16390
|
+
]);
|
|
16391
|
+
DatabaseProviderSchema = _Object_({
|
|
16392
|
+
provider: String2({ minLength: 1, maxLength: 64, pattern: "^[a-z][a-z0-9_.-]*$" }),
|
|
16393
|
+
version: String2({ minLength: 1, maxLength: 64 }),
|
|
16394
|
+
topology: Union([Literal("single-node"), Literal("distributed")]),
|
|
16395
|
+
migration: _Object_({
|
|
16396
|
+
status,
|
|
16397
|
+
inventory_sha256: Union([sha256, Null()]),
|
|
16398
|
+
compatibility: Union([
|
|
16399
|
+
Literal("verified"),
|
|
16400
|
+
Literal("not-proven"),
|
|
16401
|
+
Literal("failed")
|
|
16402
|
+
])
|
|
16403
|
+
}, closed6),
|
|
16404
|
+
backup: _Object_({
|
|
16405
|
+
status,
|
|
16406
|
+
latest_success_at: Union([isoDate, Null()]),
|
|
16407
|
+
freshness_seconds: Union([Integer({ minimum: 0 }), Null()])
|
|
16408
|
+
}, closed6),
|
|
16409
|
+
recovery: _Object_({
|
|
16410
|
+
status,
|
|
16411
|
+
drill_id: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
16412
|
+
rpo_seconds: Union([Integer({ minimum: 0 }), Null()]),
|
|
16413
|
+
rto_seconds: Union([Integer({ minimum: 0 }), Null()])
|
|
16414
|
+
}, closed6)
|
|
16415
|
+
}, closed6);
|
|
16416
|
+
componentName = Union([
|
|
16417
|
+
Literal("management-api"),
|
|
16418
|
+
Literal("web-console"),
|
|
16419
|
+
Literal("edge-runtime"),
|
|
16420
|
+
Literal("worker"),
|
|
16421
|
+
Literal("postgres"),
|
|
16422
|
+
Literal("postgrest"),
|
|
16423
|
+
Literal("gotrue"),
|
|
16424
|
+
Literal("storage"),
|
|
16425
|
+
Literal("realtime")
|
|
16426
|
+
]);
|
|
16427
|
+
DeploymentComponentEvidenceSchema = _Object_({
|
|
16428
|
+
name: componentName,
|
|
16429
|
+
version: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
16430
|
+
status,
|
|
16431
|
+
health_check: Union([String2({ minLength: 1, maxLength: 256 }), Null()]),
|
|
16432
|
+
checked_at: Union([isoDate, Null()])
|
|
16433
|
+
}, closed6);
|
|
16434
|
+
DeploymentEvidenceSchema = _Object_({
|
|
16435
|
+
schema: Literal(DEPLOYMENT_EVIDENCE_SCHEMA),
|
|
16436
|
+
status: evidenceStatus,
|
|
16437
|
+
recorded_at: isoDate,
|
|
16438
|
+
scope: _Object_({
|
|
16439
|
+
project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
|
|
16440
|
+
application_id: ApplicationIdSchema,
|
|
16441
|
+
environment_id: ApplicationIdSchema
|
|
16442
|
+
}, closed6),
|
|
16443
|
+
source: _Object_({
|
|
16444
|
+
commit_sha: Union([String2({ pattern: "^[0-9a-f]{7,64}$" }), Null()]),
|
|
16445
|
+
manifest_sha256: sha256,
|
|
16446
|
+
contract_schema: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
16447
|
+
environment_binding_version: Union([sha256, Null()])
|
|
16448
|
+
}, closed6),
|
|
16449
|
+
database: DatabaseProviderSchema,
|
|
16450
|
+
components: _Array_(DeploymentComponentEvidenceSchema, { minItems: 1, maxItems: 32 }),
|
|
16451
|
+
activation: _Object_({
|
|
16452
|
+
release_id: ApplicationReleaseIdSchema,
|
|
16453
|
+
configuration_id: ApplicationConfigurationIdSchema,
|
|
16454
|
+
activation_id: ApplicationConfigurationIdSchema
|
|
16455
|
+
}, closed6),
|
|
16456
|
+
health: _Object_({
|
|
16457
|
+
status,
|
|
16458
|
+
checked_at: Union([isoDate, Null()]),
|
|
16459
|
+
authenticated_smoke: status
|
|
16460
|
+
}, closed6),
|
|
16461
|
+
rollback: _Object_({
|
|
16462
|
+
release_id: Union([ApplicationReleaseIdSchema, Null()]),
|
|
16463
|
+
configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
|
|
16464
|
+
status: Union([Literal("ready"), Literal("not-ready"), Literal("unknown")]),
|
|
16465
|
+
result: Union([status, Null()])
|
|
16466
|
+
}, closed6),
|
|
16467
|
+
notes: _Array_(String2({ minLength: 1, maxLength: 512 }), { maxItems: 32 })
|
|
16468
|
+
}, closed6);
|
|
16469
|
+
});
|
|
16470
|
+
|
|
16255
16471
|
// node_modules/@supacloud/delivery/src/application-runtime-identity.ts
|
|
16256
16472
|
var APPLICATION_RUNTIME_PROBE_PATH = "/.well-known/supacloud/runtime", ApplicationRuntimeIdentitySchema, ApplicationReadinessReportSchema;
|
|
16257
16473
|
var init_application_runtime_identity = __esm(() => {
|
|
@@ -16374,6 +16590,7 @@ var init_src = __esm(() => {
|
|
|
16374
16590
|
init_application_activation();
|
|
16375
16591
|
init_application_release();
|
|
16376
16592
|
init_application_configuration();
|
|
16593
|
+
init_deployment_evidence();
|
|
16377
16594
|
init_application_runtime_identity();
|
|
16378
16595
|
init_delivery_build_schema();
|
|
16379
16596
|
init_delivery_migration_archive();
|
|
@@ -23408,7 +23625,7 @@ function isRecord2(value) {
|
|
|
23408
23625
|
function arrayLength(value) {
|
|
23409
23626
|
return Array.isArray(value) ? value.length : undefined;
|
|
23410
23627
|
}
|
|
23411
|
-
async function
|
|
23628
|
+
async function sha2562(path) {
|
|
23412
23629
|
return createHash10("sha256").update(await readFile11(path)).digest("hex");
|
|
23413
23630
|
}
|
|
23414
23631
|
function overallStatus(findings) {
|
|
@@ -23482,7 +23699,7 @@ async function assessMigration(options) {
|
|
|
23482
23699
|
contractsManifest = {
|
|
23483
23700
|
path: contractsManifestPath,
|
|
23484
23701
|
present: true,
|
|
23485
|
-
sha256: await
|
|
23702
|
+
sha256: await sha2562(contractsManifestPath),
|
|
23486
23703
|
version: 1,
|
|
23487
23704
|
...arrayLength(parsed.commands) === undefined ? {} : { commands: arrayLength(parsed.commands) },
|
|
23488
23705
|
...arrayLength(parsed.routes) === undefined ? {} : { routes: arrayLength(parsed.routes) },
|
|
@@ -23505,9 +23722,9 @@ async function assessMigration(options) {
|
|
|
23505
23722
|
const diff = diffOpenApiDocuments(await readOpenApiJson(baselinePath), await readOpenApiJson(currentPath));
|
|
23506
23723
|
openApi = {
|
|
23507
23724
|
baselinePath,
|
|
23508
|
-
baselineSha256: await
|
|
23725
|
+
baselineSha256: await sha2562(baselinePath),
|
|
23509
23726
|
currentPath,
|
|
23510
|
-
currentSha256: await
|
|
23727
|
+
currentSha256: await sha2562(currentPath),
|
|
23511
23728
|
diff
|
|
23512
23729
|
};
|
|
23513
23730
|
if (!diff.ok) {
|
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
|
"}",
|
|
@@ -14551,6 +14661,9 @@ function parseDeliveryBuildManifest(value) {
|
|
|
14551
14661
|
if (!Check2(DeliveryBuildManifestSchema, value))
|
|
14552
14662
|
throw new Error("Invalid delivery build manifest.");
|
|
14553
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
|
+
}
|
|
14554
14667
|
for (const target of value.plan.targets) {
|
|
14555
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")) {
|
|
14556
14669
|
throw new Error("Invalid delivery execution binding.");
|
|
@@ -14564,7 +14677,7 @@ function parseDeliveryBuildManifest(value) {
|
|
|
14564
14677
|
}
|
|
14565
14678
|
for (const object of value.objects) {
|
|
14566
14679
|
const target = value.plan.targets.find((target) => target.name === object.name);
|
|
14567
|
-
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") {
|
|
14568
14681
|
throw new Error("Delivery executable kind does not match its target.");
|
|
14569
14682
|
}
|
|
14570
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) {
|
|
@@ -14602,7 +14715,9 @@ var init_delivery_build_schema = __esm(() => {
|
|
|
14602
14715
|
entryKind: Union([
|
|
14603
14716
|
Literal("compiled-module-factory"),
|
|
14604
14717
|
Literal("bun-http-application"),
|
|
14605
|
-
Literal("bun-worker-application")
|
|
14718
|
+
Literal("bun-worker-application"),
|
|
14719
|
+
Literal("go-worker-application"),
|
|
14720
|
+
Literal("scriptc-worker-application")
|
|
14606
14721
|
]),
|
|
14607
14722
|
runtimeImports: _Array_(String2()),
|
|
14608
14723
|
files: _Array_(_Object_({
|
|
@@ -15703,6 +15818,107 @@ var init_application_activation = __esm(() => {
|
|
|
15703
15818
|
}, { additionalProperties: false });
|
|
15704
15819
|
});
|
|
15705
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
|
+
|
|
15706
15922
|
// node_modules/@supacloud/delivery/src/application-runtime-identity.ts
|
|
15707
15923
|
var APPLICATION_RUNTIME_PROBE_PATH = "/.well-known/supacloud/runtime", ApplicationRuntimeIdentitySchema, ApplicationReadinessReportSchema;
|
|
15708
15924
|
var init_application_runtime_identity = __esm(() => {
|
|
@@ -15825,6 +16041,7 @@ var init_src = __esm(() => {
|
|
|
15825
16041
|
init_application_activation();
|
|
15826
16042
|
init_application_release();
|
|
15827
16043
|
init_application_configuration();
|
|
16044
|
+
init_deployment_evidence();
|
|
15828
16045
|
init_application_runtime_identity();
|
|
15829
16046
|
init_delivery_build_schema();
|
|
15830
16047
|
init_delivery_migration_archive();
|
|
@@ -23140,7 +23357,7 @@ function isRecord2(value) {
|
|
|
23140
23357
|
function arrayLength(value) {
|
|
23141
23358
|
return Array.isArray(value) ? value.length : undefined;
|
|
23142
23359
|
}
|
|
23143
|
-
async function
|
|
23360
|
+
async function sha2562(path) {
|
|
23144
23361
|
return createHash10("sha256").update(await readFile11(path)).digest("hex");
|
|
23145
23362
|
}
|
|
23146
23363
|
function overallStatus(findings) {
|
|
@@ -23214,7 +23431,7 @@ async function assessMigration(options) {
|
|
|
23214
23431
|
contractsManifest = {
|
|
23215
23432
|
path: contractsManifestPath,
|
|
23216
23433
|
present: true,
|
|
23217
|
-
sha256: await
|
|
23434
|
+
sha256: await sha2562(contractsManifestPath),
|
|
23218
23435
|
version: 1,
|
|
23219
23436
|
...arrayLength(parsed.commands) === undefined ? {} : { commands: arrayLength(parsed.commands) },
|
|
23220
23437
|
...arrayLength(parsed.routes) === undefined ? {} : { routes: arrayLength(parsed.routes) },
|
|
@@ -23237,9 +23454,9 @@ async function assessMigration(options) {
|
|
|
23237
23454
|
const diff = diffOpenApiDocuments(await readOpenApiJson(baselinePath), await readOpenApiJson(currentPath));
|
|
23238
23455
|
openApi = {
|
|
23239
23456
|
baselinePath,
|
|
23240
|
-
baselineSha256: await
|
|
23457
|
+
baselineSha256: await sha2562(baselinePath),
|
|
23241
23458
|
currentPath,
|
|
23242
|
-
currentSha256: await
|
|
23459
|
+
currentSha256: await sha2562(currentPath),
|
|
23243
23460
|
diff
|
|
23244
23461
|
};
|
|
23245
23462
|
if (!diff.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"directory": "packages/compiler"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@supacloud/delivery": "0.
|
|
57
|
+
"@supacloud/delivery": "0.7.0",
|
|
58
58
|
"typebox": "1.3.34",
|
|
59
59
|
"@graphql-codegen/core": "^6.2.0",
|
|
60
60
|
"@graphql-codegen/typed-document-node": "^7.1.0",
|