@supacloud/cli 0.64.4 → 0.65.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.
Files changed (2) hide show
  1. package/dist/index.js +412 -38
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -206650,7 +206650,7 @@ function resolveSupaCloudContext(env = process.env, cwd = process.cwd(), selecti
206650
206650
  var ACTION_POLICY = {
206651
206651
  deploy: { write: ["deploy"] },
206652
206652
  applications: {
206653
- read: ["list_releases", "get_release", "get_runtime", "get_configuration"],
206653
+ read: ["list_releases", "get_release", "get_runtime", "get_deployment_evidence", "get_configuration"],
206654
206654
  write: ["upload_release", "put_configuration", "activate_release", "reconcile_activation", "retire_activation"]
206655
206655
  },
206656
206656
  project: {
@@ -213741,6 +213741,131 @@ var ApplicationActivationRetirementResultSchema = _Object_2({
213741
213741
  activation_id: ApplicationActivationIdSchema,
213742
213742
  retired_at: String3()
213743
213743
  }, { additionalProperties: false });
213744
+ // node_modules/@supacloud/delivery/src/deployment-evidence.ts
213745
+ var closed3 = { additionalProperties: false };
213746
+ var sha256 = String3({ pattern: "^[a-f0-9]{64}$" });
213747
+ var isoDate = String3({ minLength: 20, maxLength: 40 });
213748
+ var status = Union3([
213749
+ Literal2("confirmed"),
213750
+ Literal2("failed"),
213751
+ Literal2("unknown")
213752
+ ]);
213753
+ var evidenceStatus = Union3([
213754
+ Literal2("confirmed"),
213755
+ Literal2("failed"),
213756
+ Literal2("unknown"),
213757
+ Literal2("incomplete")
213758
+ ]);
213759
+ var DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1";
213760
+ var DatabaseProviderSchema = _Object_2({
213761
+ provider: String3({ minLength: 1, maxLength: 64, pattern: "^[a-z][a-z0-9_.-]*$" }),
213762
+ version: String3({ minLength: 1, maxLength: 64 }),
213763
+ topology: Union3([Literal2("single-node"), Literal2("distributed")]),
213764
+ migration: _Object_2({
213765
+ status,
213766
+ inventory_sha256: Union3([sha256, Null2()]),
213767
+ compatibility: Union3([
213768
+ Literal2("verified"),
213769
+ Literal2("not-proven"),
213770
+ Literal2("failed")
213771
+ ])
213772
+ }, closed3),
213773
+ backup: _Object_2({
213774
+ status,
213775
+ latest_success_at: Union3([isoDate, Null2()]),
213776
+ freshness_seconds: Union3([Integer2({ minimum: 0 }), Null2()])
213777
+ }, closed3),
213778
+ recovery: _Object_2({
213779
+ status,
213780
+ drill_id: Union3([String3({ minLength: 1, maxLength: 128 }), Null2()]),
213781
+ rpo_seconds: Union3([Integer2({ minimum: 0 }), Null2()]),
213782
+ rto_seconds: Union3([Integer2({ minimum: 0 }), Null2()])
213783
+ }, closed3)
213784
+ }, closed3);
213785
+ var componentName = Union3([
213786
+ Literal2("management-api"),
213787
+ Literal2("web-console"),
213788
+ Literal2("edge-runtime"),
213789
+ Literal2("worker"),
213790
+ Literal2("postgres"),
213791
+ Literal2("postgrest"),
213792
+ Literal2("gotrue"),
213793
+ Literal2("storage"),
213794
+ Literal2("realtime")
213795
+ ]);
213796
+ var DeploymentComponentEvidenceSchema = _Object_2({
213797
+ name: componentName,
213798
+ version: Union3([String3({ minLength: 1, maxLength: 128 }), Null2()]),
213799
+ status,
213800
+ health_check: Union3([String3({ minLength: 1, maxLength: 256 }), Null2()]),
213801
+ checked_at: Union3([isoDate, Null2()])
213802
+ }, closed3);
213803
+ var DeploymentEvidenceSchema = _Object_2({
213804
+ schema: Literal2(DEPLOYMENT_EVIDENCE_SCHEMA),
213805
+ status: evidenceStatus,
213806
+ recorded_at: isoDate,
213807
+ scope: _Object_2({
213808
+ project_ref: String3({ pattern: "^[a-z0-9-]{1,20}$" }),
213809
+ application_id: ApplicationIdSchema,
213810
+ environment_id: ApplicationIdSchema
213811
+ }, closed3),
213812
+ source: _Object_2({
213813
+ commit_sha: Union3([String3({ pattern: "^[0-9a-f]{7,64}$" }), Null2()]),
213814
+ manifest_sha256: sha256,
213815
+ contract_schema: Union3([String3({ minLength: 1, maxLength: 128 }), Null2()]),
213816
+ environment_binding_version: Union3([sha256, Null2()])
213817
+ }, closed3),
213818
+ database: DatabaseProviderSchema,
213819
+ components: _Array_(DeploymentComponentEvidenceSchema, { minItems: 1, maxItems: 32 }),
213820
+ activation: _Object_2({
213821
+ release_id: ApplicationReleaseIdSchema,
213822
+ configuration_id: ApplicationConfigurationIdSchema,
213823
+ activation_id: ApplicationConfigurationIdSchema
213824
+ }, closed3),
213825
+ health: _Object_2({
213826
+ status,
213827
+ checked_at: Union3([isoDate, Null2()]),
213828
+ authenticated_smoke: status
213829
+ }, closed3),
213830
+ rollback: _Object_2({
213831
+ release_id: Union3([ApplicationReleaseIdSchema, Null2()]),
213832
+ configuration_id: Union3([ApplicationConfigurationIdSchema, Null2()]),
213833
+ status: Union3([Literal2("ready"), Literal2("not-ready"), Literal2("unknown")]),
213834
+ result: Union3([status, Null2()])
213835
+ }, closed3),
213836
+ notes: _Array_(String3({ minLength: 1, maxLength: 512 }), { maxItems: 32 })
213837
+ }, closed3);
213838
+ function isIsoDate(value) {
213839
+ return Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
213840
+ }
213841
+ function statusValues(evidence) {
213842
+ return [
213843
+ evidence.database.migration.status,
213844
+ evidence.database.backup.status,
213845
+ evidence.database.recovery.status,
213846
+ ...evidence.components.map((component) => component.status),
213847
+ evidence.health.status,
213848
+ evidence.health.authenticated_smoke,
213849
+ ...evidence.rollback.result === null ? [] : [evidence.rollback.result]
213850
+ ];
213851
+ }
213852
+ function deriveDeploymentEvidenceStatus(evidence) {
213853
+ const values = statusValues({ ...evidence, status: "incomplete" });
213854
+ if (values.includes("failed"))
213855
+ return "failed";
213856
+ if (values.includes("unknown"))
213857
+ return "unknown";
213858
+ if (evidence.database.migration.compatibility !== "verified" || evidence.rollback.status !== "ready" || evidence.components.some((component) => component.health_check === null || component.checked_at === null) || evidence.health.checked_at === null || evidence.health.authenticated_smoke !== "confirmed" || evidence.database.recovery.status !== "confirmed" || evidence.database.recovery.drill_id === null || evidence.database.recovery.rpo_seconds === null || evidence.database.recovery.rto_seconds === null) {
213859
+ return "incomplete";
213860
+ }
213861
+ return "confirmed";
213862
+ }
213863
+ function parseDeploymentEvidence(value) {
213864
+ if (!Check3(DeploymentEvidenceSchema, value) || !isIsoDate(value.recorded_at) || value.health.checked_at !== null && !isIsoDate(value.health.checked_at) || value.database.backup.latest_success_at !== null && !isIsoDate(value.database.backup.latest_success_at) || value.components.some((component) => component.checked_at !== null && !isIsoDate(component.checked_at)) || new Set(value.components.map((component) => component.name)).size !== value.components.length || deriveDeploymentEvidenceStatus(value) !== value.status) {
213865
+ throw new Error("Invalid deployment evidence.");
213866
+ }
213867
+ return structuredClone(value);
213868
+ }
213744
213869
  // node_modules/@supacloud/delivery/src/application-runtime-identity.ts
213745
213870
  var ApplicationRuntimeIdentitySchema = _Object_2({
213746
213871
  schema: Literal2("supacloud.application-runtime.v1"),
@@ -219174,6 +219299,7 @@ var APPLICATION_TOOL_SCHEMA = {
219174
219299
  "get_release",
219175
219300
  "upload_release",
219176
219301
  "get_runtime",
219302
+ "get_deployment_evidence",
219177
219303
  "get_configuration",
219178
219304
  "put_configuration",
219179
219305
  "activate_release",
@@ -219347,6 +219473,30 @@ function registerApplicationTools(server2, http) {
219347
219473
  return releaseControlFailure(operation, "INVALID_RESPONSE", result.status);
219348
219474
  }
219349
219475
  }
219476
+ if (action === "get_deployment_evidence") {
219477
+ const environmentId = text(args, "environment_id");
219478
+ if (!Check(ApplicationIdSchema2, environmentId))
219479
+ throw new Error("Invalid environment ID");
219480
+ const result = await http.get(`/v1/projects/${project}/applications/${encodeURIComponent(id)}/environments/${encodeURIComponent(environmentId)}/deployment-evidence`, { maxJsonBytes: 262144, responseTimeoutMs: 30000 });
219481
+ if (!result.ok)
219482
+ return releaseControlFailure(operation, "HTTP_ERROR", result.status);
219483
+ try {
219484
+ const data = result.data;
219485
+ if (!data || typeof data !== "object" || !("project_ref" in data) || data.project_ref !== ref || !("application_id" in data) || data.application_id !== id || !("environment_id" in data) || data.environment_id !== environmentId || !("evidence" in data))
219486
+ throw new Error;
219487
+ const evidence = data.evidence === null ? null : parseDeploymentEvidence(data.evidence);
219488
+ if (evidence && (evidence.scope.project_ref !== ref || evidence.scope.application_id !== id || evidence.scope.environment_id !== environmentId))
219489
+ throw new Error;
219490
+ return releaseControlSuccess(operation, {
219491
+ project_ref: ref,
219492
+ application_id: id,
219493
+ environment_id: environmentId,
219494
+ evidence
219495
+ });
219496
+ } catch {
219497
+ return releaseControlFailure(operation, "INVALID_RESPONSE", result.status);
219498
+ }
219499
+ }
219350
219500
  if (action === "list_releases") {
219351
219501
  const limit = args.limit ?? 50;
219352
219502
  if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1 || limit > 100 || args.cursor !== undefined && !Check(ApplicationReleaseIdSchema2, args.cursor)) {
@@ -229212,6 +229362,8 @@ function renderClient(graph, options) {
229212
229362
  const schemaLocals = new Map;
229213
229363
  const usedTypeNames = new Set;
229214
229364
  const allRoutes = [];
229365
+ const allProcedures = [];
229366
+ const commandByClassName = new Map(graph.modules.flatMap((module) => module.commands.map((command) => [command.className, command])));
229215
229367
  let usesStatic = false;
229216
229368
  let usesValue = false;
229217
229369
  const uniqueTypeName = (candidate) => {
@@ -229342,8 +229494,21 @@ function renderClient(graph, options) {
229342
229494
  const responseSchemaEntries = hasResponseMap ? Object.entries(responseSchemas).map(([status, ref]) => [status, ref.local]) : responseSchema ? [["200", responseSchema.local]] : [];
229343
229495
  const responseSchemaArgument = responseSchemaEntries.length > 0 ? `{ ${responseSchemaEntries.map(([status, local]) => `${JSON.stringify(status)}: ${local}`).join(", ")} }` : "undefined";
229344
229496
  const responseKindArgument = responseKind === undefined ? "undefined" : JSON.stringify(responseKind);
229497
+ const command = route.command === undefined ? undefined : commandByClassName.get(route.command);
229498
+ const procedureKind = route.method === "GET" || route.method === "HEAD" ? "query" : "mutation";
229499
+ const idempotencyMode = command?.idempotency ?? "none";
229500
+ allProcedures.push({
229501
+ method: route.method,
229502
+ path: fullPath,
229503
+ controller: controller.className,
229504
+ handler: route.handler,
229505
+ kind: procedureKind,
229506
+ ...command?.name === undefined ? {} : { command: command.name },
229507
+ ...command?.permission === undefined ? {} : { permission: command.permission },
229508
+ idempotency: idempotencyMode
229509
+ });
229345
229510
  routeMethods.push(`
229346
- ${route.handler}: makeRoute<${requestTypeName}, ${responseType === "never" ? "never" : responseTypeName}>(${JSON.stringify(route.method)}, ${JSON.stringify(fullPath)}, ${responseSchemaArgument}, ${responseKindArgument}, ${route.parse === "none"}),`);
229511
+ ${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)}),`);
229347
229512
  }
229348
229513
  controllerEntries.push(`
229349
229514
  ${controllerKey}: {${routeMethods.join("")}
@@ -229374,6 +229539,43 @@ function renderClient(graph, options) {
229374
229539
  "",
229375
229540
  "export type ResponseDecoder<T> = (value: unknown) => T;",
229376
229541
  "",
229542
+ 'export type ProcedureKind = "query" | "mutation";',
229543
+ 'export type IdempotencyMode = "required" | "none";',
229544
+ "",
229545
+ "export interface ProcedureExecutionOptions {",
229546
+ " /** Reuse the same key when retrying an uncertain mutation. */",
229547
+ " idempotencyKey?: string;",
229548
+ " signal?: AbortSignal;",
229549
+ "}",
229550
+ "",
229551
+ "export type RequiredProcedureExecutionOptions = ProcedureExecutionOptions & { idempotencyKey: string };",
229552
+ "",
229553
+ "type ProcedureResult<Result> = [Result] extends [never] ? unknown : Result;",
229554
+ "",
229555
+ "type ProcedureArgs<Options extends ClientRequestOptions, Idempotency extends IdempotencyMode> =",
229556
+ ' Idempotency extends "required"',
229557
+ " ? {} extends Options",
229558
+ " ? [execution: RequiredProcedureExecutionOptions] | [input: Options, execution: RequiredProcedureExecutionOptions]",
229559
+ " : [input: Options, execution: RequiredProcedureExecutionOptions]",
229560
+ " : {} extends Options",
229561
+ " ? [input?: Options, execution?: ProcedureExecutionOptions]",
229562
+ " : [input: Options, execution?: ProcedureExecutionOptions];",
229563
+ "",
229564
+ "export type ProcedureCall<",
229565
+ " Options extends ClientRequestOptions = ClientRequestOptions,",
229566
+ " Result = never,",
229567
+ ' Idempotency extends IdempotencyMode = "none",',
229568
+ "> = (...args: ProcedureArgs<Options, Idempotency>) => Promise<ProcedureResult<Result>>;",
229569
+ "",
229570
+ "export type ProcedureMember<",
229571
+ " Options extends ClientRequestOptions,",
229572
+ " Result,",
229573
+ " Kind extends ProcedureKind,",
229574
+ " Idempotency extends IdempotencyMode,",
229575
+ '> = Kind extends "query"',
229576
+ " ? { query: ProcedureCall<Options, Result, Idempotency> }",
229577
+ " : { mutate: ProcedureCall<Options, Result, Idempotency> };",
229578
+ "",
229377
229579
  'export type ApiClientErrorCode = "API_HTTP_ERROR" | "API_RESPONSE_INVALID" | "API_RESPONSE_UNDECLARED";',
229378
229580
  "",
229379
229581
  "export interface ApiClientErrorDetails {",
@@ -229417,6 +229619,17 @@ function renderClient(graph, options) {
229417
229619
  " : { (options: Options): Promise<Result>; <T>(options: Options, decode: ResponseDecoder<T>): Promise<T> }",
229418
229620
  ") & ((...args: {} extends Options ? [options?: Options] : [options: Options]) => Promise<[Result] extends [never] ? unknown : Result>);",
229419
229621
  "",
229622
+ "export interface ApiProcedureDefinition {",
229623
+ " method: string;",
229624
+ " path: string;",
229625
+ " controller: string;",
229626
+ " handler: string;",
229627
+ " kind: ProcedureKind;",
229628
+ " command?: string;",
229629
+ " permission?: string;",
229630
+ " idempotency: IdempotencyMode;",
229631
+ "}",
229632
+ "",
229420
229633
  ...routeTypes,
229421
229634
  ...routeTypes.length > 0 ? [""] : [],
229422
229635
  "export interface HttpInterceptorRequest {",
@@ -229424,6 +229637,7 @@ function renderClient(graph, options) {
229424
229637
  " url: string;",
229425
229638
  " headers: Record<string, string>;",
229426
229639
  " body?: unknown;",
229640
+ " signal?: AbortSignal;",
229427
229641
  "}",
229428
229642
  "",
229429
229643
  "export type HttpInterceptorFn = (",
@@ -229442,6 +229656,8 @@ function renderClient(graph, options) {
229442
229656
  "",
229443
229657
  "export const API_ROUTES = " + JSON.stringify(allRoutes, null, 2) + " as const;",
229444
229658
  "",
229659
+ "export const API_PROCEDURES: readonly ApiProcedureDefinition[] = " + JSON.stringify(allProcedures, null, 2) + ";",
229660
+ "",
229445
229661
  "export type AppRoutePath = typeof API_ROUTES[number]['path'];",
229446
229662
  "",
229447
229663
  "export const API_SCHEMAS = [",
@@ -229667,6 +229883,7 @@ function renderClient(graph, options) {
229667
229883
  ` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
229668
229884
  " responseKind?: string,",
229669
229885
  " raw?: boolean,",
229886
+ " execution?: ProcedureExecutionOptions,",
229670
229887
  " ): Promise<T>;",
229671
229888
  " async function request<T>(",
229672
229889
  " method: string,",
@@ -229676,6 +229893,7 @@ function renderClient(graph, options) {
229676
229893
  ` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
229677
229894
  " responseKind?: string,",
229678
229895
  " raw?: boolean,",
229896
+ " execution?: ProcedureExecutionOptions,",
229679
229897
  " ): Promise<T | unknown>;",
229680
229898
  " async function request(",
229681
229899
  " method: string,",
@@ -229690,6 +229908,7 @@ function renderClient(graph, options) {
229690
229908
  ` responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>,`,
229691
229909
  " responseKind?: string,",
229692
229910
  " raw = false,",
229911
+ " execution?: ProcedureExecutionOptions,",
229693
229912
  " ): Promise<T | unknown> {",
229694
229913
  " const url = `${baseUrl}${buildRouteUrl(path, options.params, options.query)}`;",
229695
229914
  ' const customHeaders = typeof config.headers === "function" ? await config.headers() : config.headers;',
@@ -229715,9 +229934,10 @@ function renderClient(graph, options) {
229715
229934
  " headers: reqPayload.headers,",
229716
229935
  " ...(reqPayload.body === undefined ? {} : { body: raw ? rawBody(reqPayload.body) : JSON.stringify(reqPayload.body) }),",
229717
229936
  ' ...(raw && reqPayload.body instanceof ReadableStream ? { duplex: "half" } : {}),',
229937
+ " ...(reqPayload.signal === undefined ? {} : { signal: reqPayload.signal }),",
229718
229938
  " });",
229719
229939
  " };",
229720
- " const response = await executeChain(0, { method, url, headers, body: options.body });",
229940
+ " const response = await executeChain(0, { method, url, headers, body: options.body, ...(execution?.signal === undefined ? {} : { signal: execution.signal }) });",
229721
229941
  " const declaredSchema = responseSchemas ? selectResponseSchema(response.status, responseSchemas) : undefined;",
229722
229942
  " const failure = (code: ApiClientErrorCode, message: string) => new ApiClientError(message, {",
229723
229943
  ' code, method, path, status: response.status, requestId: response.headers.get("x-request-id"),',
@@ -229755,7 +229975,44 @@ function renderClient(graph, options) {
229755
229975
  " return decode ? decode(checked) : checked;",
229756
229976
  " }",
229757
229977
  "",
229758
- ` function makeRoute<Options extends ClientRequestOptions, Result = never>(method: string, path: string, responseSchemas?: Readonly<Record<string, ${responseSchemaType}>>, responseKind?: string, raw = false): RouteMethod<Options, Result> {`,
229978
+ " function hasHeader(headers: Record<string, string>, name: string): boolean {",
229979
+ " return Object.keys(headers).some((key) => key.toLowerCase() === name.toLowerCase());",
229980
+ " }",
229981
+ "",
229982
+ " function withProcedureExecution(",
229983
+ " options: ClientRequestOptions,",
229984
+ " execution: ProcedureExecutionOptions | undefined,",
229985
+ " idempotency: IdempotencyMode,",
229986
+ " ): ClientRequestOptions {",
229987
+ " const headers = { ...(options.headers as Record<string, string> | undefined) };",
229988
+ " if (execution?.idempotencyKey !== undefined) {",
229989
+ " if (!/^[A-Za-z0-9._:-]{1,512}$/.test(execution.idempotencyKey)) {",
229990
+ ' throw new TypeError("idempotencyKey must contain only safe header characters and be at most 512 characters");',
229991
+ " }",
229992
+ ' headers["idempotency-key"] = execution.idempotencyKey;',
229993
+ " }",
229994
+ ' if (idempotency === "required" && !hasHeader(headers, "idempotency-key")) {',
229995
+ ' throw new TypeError("This mutation requires an idempotencyKey");',
229996
+ " }",
229997
+ " return Object.keys(headers).length === 0 ? options : { ...options, headers };",
229998
+ " }",
229999
+ "",
230000
+ " function isProcedureExecution(value: unknown): value is ProcedureExecutionOptions {",
230001
+ ' if (value === null || typeof value !== "object" || Array.isArray(value)) return false;',
230002
+ ' return Object.hasOwn(value, "idempotencyKey") || Object.hasOwn(value, "signal");',
230003
+ " }",
230004
+ "",
230005
+ ` 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> {`,
230006
+ " const procedure = async (first?: Options | ProcedureExecutionOptions, second?: ProcedureExecutionOptions): Promise<unknown> => {",
230007
+ " const execution = second ?? (isProcedureExecution(first) ? first : undefined);",
230008
+ " const input = (execution === first ? undefined : first) ?? {};",
230009
+ " const requestOptions = withProcedureExecution(input as ClientRequestOptions, execution, idempotency);",
230010
+ " return request(method, path, requestOptions, undefined, responseSchemas, responseKind, raw, execution);",
230011
+ " };",
230012
+ " return procedure as ProcedureCall<Options, Result, Idempotency>;",
230013
+ " }",
230014
+ "",
230015
+ ` 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> {`,
229759
230016
  " function route<T>(options: Options, decode: ResponseDecoder<T>): Promise<T>;",
229760
230017
  " function route(options: Options): Promise<Result>;",
229761
230018
  " function route(options?: Options): Promise<unknown>;",
@@ -229763,13 +230020,16 @@ function renderClient(graph, options) {
229763
230020
  " const requestOptions = options ?? {};",
229764
230021
  " return request(method, path, requestOptions, decode, responseSchemas, responseKind, raw);",
229765
230022
  " }",
229766
- " return route as RouteMethod<Options, Result>;",
230023
+ ' if (kind === "query") Object.assign(route, { query: makeProcedure<Options, Result, Idempotency>(method, path, responseSchemas, responseKind, raw, idempotency) });',
230024
+ ' if (kind === "mutation") Object.assign(route, { mutate: makeProcedure<Options, Result, Idempotency>(method, path, responseSchemas, responseKind, raw, idempotency) });',
230025
+ " return route as RouteMethod<Options, Result> & ProcedureMember<Options, Result, Kind, Idempotency>;",
229767
230026
  " }",
229768
230027
  "",
229769
230028
  " return {",
229770
230029
  " request,",
229771
230030
  " buildRouteUrl,",
229772
230031
  " routes: API_ROUTES,",
230032
+ " procedures: API_PROCEDURES,",
229773
230033
  ...controllerEntries,
229774
230034
  " };",
229775
230035
  "}",
@@ -239949,14 +240209,14 @@ function validateWorkerExecution2(groups) {
239949
240209
  routes.add(route);
239950
240210
  }
239951
240211
  }
239952
- var closed3;
240212
+ var closed4;
239953
240213
  var positive2 = (maximum) => Integer4({ minimum: 1, maximum });
239954
240214
  var WorkerExecutionGroupSchema2;
239955
240215
  var WorkerExecutionSchema2;
239956
240216
  var init_worker_execution = __esm2(() => {
239957
240217
  init_build();
239958
240218
  init_value2();
239959
- closed3 = { additionalProperties: false };
240219
+ closed4 = { additionalProperties: false };
239960
240220
  WorkerExecutionGroupSchema2 = _Object_3({
239961
240221
  name: String22({ pattern: "^[a-z][a-z0-9-]{0,47}$" }),
239962
240222
  target: String22({ pattern: "^[a-z][a-z0-9-]{0,53}$" }),
@@ -239972,22 +240232,22 @@ var init_worker_execution = __esm2(() => {
239972
240232
  resources: _Object_3({
239973
240233
  cpuLimit: Number22({ minimum: 0.1, maximum: 64, multipleOf: 0.1 }),
239974
240234
  memoryLimitMiB: Integer4({ minimum: 64, maximum: 262144 })
239975
- }, closed3),
240235
+ }, closed4),
239976
240236
  database: _Object_3({
239977
240237
  engineConnectionsPerReplica: positive2(16),
239978
240238
  handlerConnectionsPerReplica: positive2(16)
239979
- }, closed3),
240239
+ }, closed4),
239980
240240
  lifecycle: _Object_3({
239981
240241
  executionTimeoutSeconds: positive2(3500),
239982
240242
  visibilityTimeoutSeconds: Integer4({ minimum: 15, maximum: 3600 }),
239983
240243
  shutdownGraceSeconds: positive2(300)
239984
- }, closed3),
239985
- retry: _Object_3({ maxAttempts: Integer4({ minimum: 1, maximum: 10 }) }, closed3),
239986
- admission: _Object_3({ maxOutstandingOperations: positive2(1e6) }, closed3)
239987
- }, closed3);
240244
+ }, closed4),
240245
+ retry: _Object_3({ maxAttempts: Integer4({ minimum: 1, maximum: 10 }) }, closed4),
240246
+ admission: _Object_3({ maxOutstandingOperations: positive2(1e6) }, closed4)
240247
+ }, closed4);
239988
240248
  WorkerExecutionSchema2 = _Object_3({
239989
240249
  groups: _Array_2(WorkerExecutionGroupSchema2, { minItems: 1, maxItems: 32 })
239990
- }, closed3);
240250
+ }, closed4);
239991
240251
  });
239992
240252
  function parseDeliveryOptions(value) {
239993
240253
  if (value === undefined)
@@ -240321,6 +240581,9 @@ function parseDeliveryBuildManifest2(value) {
240321
240581
  if (!Check22(DeliveryBuildManifestSchema2, value))
240322
240582
  throw new Error("Invalid delivery build manifest.");
240323
240583
  validateWorkerExecution2(value.plan.targets.flatMap((target) => target.execution ? [target.execution] : []));
240584
+ if (value.plan.targets.reduce((count, target) => count + (target.execution?.replicas ?? 1), 0) > 32) {
240585
+ throw new Error("Invalid delivery replica count.");
240586
+ }
240324
240587
  for (const target of value.plan.targets) {
240325
240588
  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")) {
240326
240589
  throw new Error("Invalid delivery execution binding.");
@@ -240334,7 +240597,7 @@ function parseDeliveryBuildManifest2(value) {
240334
240597
  }
240335
240598
  for (const object of value.objects) {
240336
240599
  const target = value.plan.targets.find((target) => target.name === object.name);
240337
- if (object.entryKind === "bun-worker-application" && target?.kind !== "jobs" || object.entryKind === "bun-http-application" && target?.kind === "jobs") {
240600
+ if (["bun-worker-application", "go-worker-application", "scriptc-worker-application"].includes(object.entryKind) && target?.kind !== "jobs" || object.entryKind === "bun-http-application" && target?.kind === "jobs") {
240338
240601
  throw new Error("Delivery executable kind does not match its target.");
240339
240602
  }
240340
240603
  if (new Set(object.files.map((file) => file.path)).size !== object.files.length || !object.files.some((file) => file.path === object.entrypoint) || deliveryObjectDigest2(object) !== object.objectId) {
@@ -240377,7 +240640,9 @@ var init_delivery_build_schema = __esm2(() => {
240377
240640
  entryKind: Union4([
240378
240641
  Literal3("compiled-module-factory"),
240379
240642
  Literal3("bun-http-application"),
240380
- Literal3("bun-worker-application")
240643
+ Literal3("bun-worker-application"),
240644
+ Literal3("go-worker-application"),
240645
+ Literal3("scriptc-worker-application")
240381
240646
  ]),
240382
240647
  runtimeImports: _Array_2(String22()),
240383
240648
  files: _Array_2(_Object_3({
@@ -240865,7 +241130,7 @@ var APPLICATION_DEVELOPMENT_SCHEMA = "supacloud.application-development.v1";
240865
241130
  var APPLICATION_DEVELOPMENT_ARCHIVE_MAX_BYTES = 524288;
240866
241131
  var APPLICATION_DEVELOPMENT_LIMITS;
240867
241132
  var DevelopmentContractError;
240868
- var closed4;
241133
+ var closed42;
240869
241134
  var text22;
240870
241135
  var texts;
240871
241136
  var count;
@@ -240898,13 +241163,13 @@ var init_application_development = __esm2(() => {
240898
241163
  this.name = "DevelopmentContractError";
240899
241164
  }
240900
241165
  };
240901
- closed4 = { additionalProperties: false };
241166
+ closed42 = { additionalProperties: false };
240902
241167
  text22 = String22({ minLength: 1, maxLength: 512, pattern: "^[^\\u0000-\\u001f\\u007f]+$" });
240903
241168
  texts = _Array_2(text22);
240904
241169
  count = Integer4({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
240905
241170
  mode = Union4([Literal3("required"), Literal3("none")]);
240906
241171
  operations2 = _Array_2(Union4([Literal3("read"), Literal3("write"), Literal3("publish"), Literal3("consume")]));
240907
- resourceUse = _Object_3({ resource: text22, operations: operations2 }, closed4);
241172
+ resourceUse = _Object_3({ resource: text22, operations: operations2 }, closed42);
240908
241173
  schemaKind = Optional4(Union4([Literal3("opaque"), Literal3("declared")]));
240909
241174
  stage = Union4([
240910
241175
  Union4([Literal3("commandExecutor"), Literal3("jobExecutor"), Literal3("authorize"), Literal3("idempotency"), Literal3("transaction"), Literal3("handler"), Literal3("audit")]),
@@ -240929,7 +241194,7 @@ var init_application_development = __esm2(() => {
240929
241194
  jobs: texts,
240930
241195
  queries: texts,
240931
241196
  resources: texts
240932
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.modules }),
241197
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.modules }),
240933
241198
  routes: _Array_2(_Object_3({
240934
241199
  module: text22,
240935
241200
  method: Union4([Literal3("GET"), Literal3("POST"), Literal3("PUT"), Literal3("PATCH"), Literal3("DELETE"), Literal3("HEAD"), Literal3("OPTIONS")]),
@@ -240945,8 +241210,8 @@ var init_application_development = __esm2(() => {
240945
241210
  headers: schemaKind,
240946
241211
  cookie: schemaKind,
240947
241212
  response: schemaKind
240948
- }, closed4))
240949
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.routes }),
241213
+ }, closed42))
241214
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.routes }),
240950
241215
  commands: _Array_2(_Object_3({
240951
241216
  module: text22,
240952
241217
  name: text22,
@@ -240955,28 +241220,28 @@ var init_application_development = __esm2(() => {
240955
241220
  idempotency: mode,
240956
241221
  audit: Optional4(text22),
240957
241222
  resources: _Array_2(resourceUse)
240958
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.commands }),
241223
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.commands }),
240959
241224
  jobs: _Array_2(_Object_3({
240960
241225
  module: text22,
240961
241226
  name: text22,
240962
241227
  mode: Optional4(Union4([Literal3("task"), Literal3("workflow")])),
240963
241228
  resources: _Array_2(resourceUse)
240964
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.jobs }),
240965
- resources: _Array_2(_Object_3({ name: text22, kind: Union4([Literal3("database"), Literal3("bucket"), Literal3("queue"), Literal3("config"), Literal3("secret")]) }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resources }),
241229
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.jobs }),
241230
+ resources: _Array_2(_Object_3({ name: text22, kind: Union4([Literal3("database"), Literal3("bucket"), Literal3("queue"), Literal3("config"), Literal3("secret")]) }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resources }),
240966
241231
  resourceUses: _Array_2(_Object_3({
240967
241232
  module: text22,
240968
241233
  owner: text22,
240969
241234
  ownerKind: Union4([Literal3("command"), Literal3("job")]),
240970
241235
  resource: text22,
240971
241236
  operations: operations2
240972
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resourceUses }),
241237
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resourceUses }),
240973
241238
  executionPlans: _Array_2(_Object_3({
240974
241239
  module: text22,
240975
241240
  kind: Union4([Literal3("route"), Literal3("command"), Literal3("job")]),
240976
241241
  name: text22,
240977
241242
  command: Optional4(text22),
240978
241243
  stages: _Array_2(stage)
240979
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.plans }),
241244
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.plans }),
240980
241245
  diagnostics: _Array_2(_Object_3({
240981
241246
  code: text22,
240982
241247
  severity: Union4([Literal3("error"), Literal3("warn")]),
@@ -240985,8 +241250,8 @@ var init_application_development = __esm2(() => {
240985
241250
  repair: Optional4(_Object_3({
240986
241251
  type: Union4([Literal3("set_command_mode"), Literal3("add_module_import"), Literal3("add_provider"), Literal3("mark_optional_dependency"), Literal3("change_provider_scope"), Literal3("add_command_permission"), Literal3("add_route_parameter_binding"), Literal3("remove_route_body_binding")]),
240987
241252
  readiness: Union4([Literal3("preview"), Literal3("input-required"), Literal3("manual")])
240988
- }, closed4))
240989
- }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.diagnostics }),
241253
+ }, closed42))
241254
+ }, closed42), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.diagnostics }),
240990
241255
  omitted: _Object_3({
240991
241256
  modules: count,
240992
241257
  providers: count,
@@ -240997,7 +241262,7 @@ var init_application_development = __esm2(() => {
240997
241262
  resourceUses: count,
240998
241263
  plans: count,
240999
241264
  diagnostics: count
241000
- }, closed4),
241265
+ }, closed42),
241001
241266
  limits: _Object_3({
241002
241267
  outputBytes: Literal3(APPLICATION_DEVELOPMENT_LIMITS.outputBytes),
241003
241268
  modules: Literal3(APPLICATION_DEVELOPMENT_LIMITS.modules),
@@ -241009,8 +241274,8 @@ var init_application_development = __esm2(() => {
241009
241274
  resourceUses: Literal3(APPLICATION_DEVELOPMENT_LIMITS.resourceUses),
241010
241275
  plans: Literal3(APPLICATION_DEVELOPMENT_LIMITS.plans),
241011
241276
  diagnostics: Literal3(APPLICATION_DEVELOPMENT_LIMITS.diagnostics)
241012
- }, closed4)
241013
- }, closed4);
241277
+ }, closed42)
241278
+ }, closed42);
241014
241279
  });
241015
241280
  function parseApplicationDevelopmentContext(input) {
241016
241281
  try {
@@ -241312,6 +241577,114 @@ var init_application_activation = __esm2(() => {
241312
241577
  retired_at: String22()
241313
241578
  }, { additionalProperties: false });
241314
241579
  });
241580
+ var closed6;
241581
+ var sha2562;
241582
+ var isoDate2;
241583
+ var status2;
241584
+ var evidenceStatus2;
241585
+ var DEPLOYMENT_EVIDENCE_SCHEMA2 = "supacloud.deployment-evidence.v1";
241586
+ var DatabaseProviderSchema2;
241587
+ var componentName2;
241588
+ var DeploymentComponentEvidenceSchema2;
241589
+ var DeploymentEvidenceSchema2;
241590
+ var init_deployment_evidence = __esm2(() => {
241591
+ init_build();
241592
+ init_value2();
241593
+ init_application_configuration();
241594
+ init_application_release();
241595
+ closed6 = { additionalProperties: false };
241596
+ sha2562 = String22({ pattern: "^[a-f0-9]{64}$" });
241597
+ isoDate2 = String22({ minLength: 20, maxLength: 40 });
241598
+ status2 = Union4([
241599
+ Literal3("confirmed"),
241600
+ Literal3("failed"),
241601
+ Literal3("unknown")
241602
+ ]);
241603
+ evidenceStatus2 = Union4([
241604
+ Literal3("confirmed"),
241605
+ Literal3("failed"),
241606
+ Literal3("unknown"),
241607
+ Literal3("incomplete")
241608
+ ]);
241609
+ DatabaseProviderSchema2 = _Object_3({
241610
+ provider: String22({ minLength: 1, maxLength: 64, pattern: "^[a-z][a-z0-9_.-]*$" }),
241611
+ version: String22({ minLength: 1, maxLength: 64 }),
241612
+ topology: Union4([Literal3("single-node"), Literal3("distributed")]),
241613
+ migration: _Object_3({
241614
+ status: status2,
241615
+ inventory_sha256: Union4([sha2562, Null3()]),
241616
+ compatibility: Union4([
241617
+ Literal3("verified"),
241618
+ Literal3("not-proven"),
241619
+ Literal3("failed")
241620
+ ])
241621
+ }, closed6),
241622
+ backup: _Object_3({
241623
+ status: status2,
241624
+ latest_success_at: Union4([isoDate2, Null3()]),
241625
+ freshness_seconds: Union4([Integer4({ minimum: 0 }), Null3()])
241626
+ }, closed6),
241627
+ recovery: _Object_3({
241628
+ status: status2,
241629
+ drill_id: Union4([String22({ minLength: 1, maxLength: 128 }), Null3()]),
241630
+ rpo_seconds: Union4([Integer4({ minimum: 0 }), Null3()]),
241631
+ rto_seconds: Union4([Integer4({ minimum: 0 }), Null3()])
241632
+ }, closed6)
241633
+ }, closed6);
241634
+ componentName2 = Union4([
241635
+ Literal3("management-api"),
241636
+ Literal3("web-console"),
241637
+ Literal3("edge-runtime"),
241638
+ Literal3("worker"),
241639
+ Literal3("postgres"),
241640
+ Literal3("postgrest"),
241641
+ Literal3("gotrue"),
241642
+ Literal3("storage"),
241643
+ Literal3("realtime")
241644
+ ]);
241645
+ DeploymentComponentEvidenceSchema2 = _Object_3({
241646
+ name: componentName2,
241647
+ version: Union4([String22({ minLength: 1, maxLength: 128 }), Null3()]),
241648
+ status: status2,
241649
+ health_check: Union4([String22({ minLength: 1, maxLength: 256 }), Null3()]),
241650
+ checked_at: Union4([isoDate2, Null3()])
241651
+ }, closed6);
241652
+ DeploymentEvidenceSchema2 = _Object_3({
241653
+ schema: Literal3(DEPLOYMENT_EVIDENCE_SCHEMA2),
241654
+ status: evidenceStatus2,
241655
+ recorded_at: isoDate2,
241656
+ scope: _Object_3({
241657
+ project_ref: String22({ pattern: "^[a-z0-9-]{1,20}$" }),
241658
+ application_id: ApplicationIdSchema3,
241659
+ environment_id: ApplicationIdSchema3
241660
+ }, closed6),
241661
+ source: _Object_3({
241662
+ commit_sha: Union4([String22({ pattern: "^[0-9a-f]{7,64}$" }), Null3()]),
241663
+ manifest_sha256: sha2562,
241664
+ contract_schema: Union4([String22({ minLength: 1, maxLength: 128 }), Null3()]),
241665
+ environment_binding_version: Union4([sha2562, Null3()])
241666
+ }, closed6),
241667
+ database: DatabaseProviderSchema2,
241668
+ components: _Array_2(DeploymentComponentEvidenceSchema2, { minItems: 1, maxItems: 32 }),
241669
+ activation: _Object_3({
241670
+ release_id: ApplicationReleaseIdSchema3,
241671
+ configuration_id: ApplicationConfigurationIdSchema3,
241672
+ activation_id: ApplicationConfigurationIdSchema3
241673
+ }, closed6),
241674
+ health: _Object_3({
241675
+ status: status2,
241676
+ checked_at: Union4([isoDate2, Null3()]),
241677
+ authenticated_smoke: status2
241678
+ }, closed6),
241679
+ rollback: _Object_3({
241680
+ release_id: Union4([ApplicationReleaseIdSchema3, Null3()]),
241681
+ configuration_id: Union4([ApplicationConfigurationIdSchema3, Null3()]),
241682
+ status: Union4([Literal3("ready"), Literal3("not-ready"), Literal3("unknown")]),
241683
+ result: Union4([status2, Null3()])
241684
+ }, closed6),
241685
+ notes: _Array_2(String22({ minLength: 1, maxLength: 512 }), { maxItems: 32 })
241686
+ }, closed6);
241687
+ });
241315
241688
  var APPLICATION_RUNTIME_PROBE_PATH2 = "/.well-known/supacloud/runtime";
241316
241689
  var ApplicationRuntimeIdentitySchema2;
241317
241690
  var ApplicationReadinessReportSchema2;
@@ -241389,6 +241762,7 @@ var init_src = __esm2(() => {
241389
241762
  init_application_activation();
241390
241763
  init_application_release();
241391
241764
  init_application_configuration();
241765
+ init_deployment_evidence();
241392
241766
  init_application_runtime_identity();
241393
241767
  init_delivery_build_schema();
241394
241768
  init_delivery_migration_archive();
@@ -246856,7 +247230,7 @@ var starter_metadata_default = {
246856
247230
  generatedBy: "supacloud/starter-metadata-v1",
246857
247231
  packages: {
246858
247232
  compiler: {
246859
- version: "0.32.0"
247233
+ version: "0.33.0"
246860
247234
  },
246861
247235
  app: {
246862
247236
  version: "0.22.0",
@@ -246883,7 +247257,7 @@ var starter_metadata_default = {
246883
247257
  }
246884
247258
  },
246885
247259
  sdk: {
246886
- version: "0.36.1",
247260
+ version: "0.37.0",
246887
247261
  peerDependencies: {
246888
247262
  "@supabase/supabase-js": "^2.115.0"
246889
247263
  }
@@ -254587,7 +254961,7 @@ function registerRemoteDevTools(server2, options = {}) {
254587
254961
  // package.json
254588
254962
  var package_default = {
254589
254963
  name: "@supacloud/cli",
254590
- version: "0.64.4",
254964
+ version: "0.65.0",
254591
254965
  description: "Project-scoped CLI for SupaCloud users",
254592
254966
  type: "module",
254593
254967
  main: "./dist/index.js",
@@ -254622,14 +254996,14 @@ var package_default = {
254622
254996
  },
254623
254997
  dependencies: {
254624
254998
  "@sinclair/typebox": "^0.34.52",
254625
- "@supacloud/compiler": "^0.32.0",
254626
- "@supacloud/delivery": "0.6.0",
254999
+ "@supacloud/compiler": "^0.33.0",
255000
+ "@supacloud/delivery": "0.7.0",
254627
255001
  "@supacloud/db": "^0.2.0",
254628
255002
  fflate: "^0.8.3",
254629
255003
  typebox: "1.3.34"
254630
255004
  },
254631
255005
  overrides: {
254632
- "@supacloud/delivery": "0.6.0"
255006
+ "@supacloud/delivery": "0.7.0"
254633
255007
  },
254634
255008
  devDependencies: {
254635
255009
  "@supacloud/elysia": "^0.23.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.64.4",
3
+ "version": "0.65.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@sinclair/typebox": "^0.34.52",
38
- "@supacloud/compiler": "^0.32.0",
39
- "@supacloud/delivery": "0.6.0",
38
+ "@supacloud/compiler": "^0.33.0",
39
+ "@supacloud/delivery": "0.7.0",
40
40
  "@supacloud/db": "^0.2.0",
41
41
  "fflate": "^0.8.3",
42
42
  "typebox": "1.3.34"
43
43
  },
44
44
  "overrides": {
45
- "@supacloud/delivery": "0.6.0"
45
+ "@supacloud/delivery": "0.7.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@supacloud/elysia": "^0.23.1",