@supacloud/cli 0.92.0 → 0.93.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/dist/index.js CHANGED
@@ -10499,12 +10499,9 @@ function parseApplicationDeployPlan(value) {
10499
10499
  var closed3 = { additionalProperties: false };
10500
10500
  var sha256 = ApplicationReleaseIdSchema;
10501
10501
  var nullableActivation = Union([ApplicationActivationIdSchema, Null()]);
10502
- var ApplicationDeployWebRequestSchema = _Object_({
10502
+ var ApplicationDeployWebReleaseSchema = _Object_({
10503
10503
  deployment_id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
10504
- release_id: sha256,
10505
- expected_active_release_id: String2({ minLength: 1 }),
10506
- expected_activation_id: String2({ minLength: 1 }),
10507
- mutation_id: ApplicationActivationIdSchema
10504
+ release_id: sha256
10508
10505
  }, closed3);
10509
10506
  var ApplicationDeployRequestSchema = _Object_({
10510
10507
  mutation_id: ApplicationActivationIdSchema,
@@ -10513,7 +10510,7 @@ var ApplicationDeployRequestSchema = _Object_({
10513
10510
  configuration_write: Optional(ApplicationConfigurationWriteSchema),
10514
10511
  expected_plan_sha256: Optional(sha256),
10515
10512
  approved_migration_digest: Optional(sha256),
10516
- web: Optional(ApplicationDeployWebRequestSchema)
10513
+ web_release: Optional(ApplicationDeployWebReleaseSchema)
10517
10514
  }, closed3);
10518
10515
  var ApplicationBackendReceiptSchema = _Object_({
10519
10516
  schema: Literal("supacloud.application-backend-receipt.v1"),
@@ -10572,7 +10569,7 @@ function parseApplicationDeployResult(value, expected) {
10572
10569
  if (expected) {
10573
10570
  const { request } = expected;
10574
10571
  const configurationId = request.configuration_id ?? request.configuration_write?.configuration_id;
10575
- if (value.project_ref !== expected.project_ref || value.application_id !== expected.application_id || value.environment_id !== expected.environment_id || value.release_id !== request.release_id || value.mutation_id !== request.mutation_id || configurationId !== undefined && value.configuration_id !== configurationId || request.configuration_write !== undefined && value.configuration_id !== request.configuration_write.configuration_id || request.expected_plan_sha256 !== undefined && value.plan_sha256 !== request.expected_plan_sha256 || Boolean(value.web) !== Boolean(request.web) || request.web !== undefined && (value.web?.deployment_id !== request.web.deployment_id || value.web.release_id !== request.web.release_id)) {
10572
+ if (value.project_ref !== expected.project_ref || value.application_id !== expected.application_id || value.environment_id !== expected.environment_id || value.release_id !== request.release_id || value.mutation_id !== request.mutation_id || configurationId !== undefined && value.configuration_id !== configurationId || request.configuration_write !== undefined && value.configuration_id !== request.configuration_write.configuration_id || request.expected_plan_sha256 !== undefined && value.plan_sha256 !== request.expected_plan_sha256 || Boolean(value.web) !== Boolean(request.web_release) || request.web_release !== undefined && (value.web?.deployment_id !== request.web_release.deployment_id || value.web.release_id !== request.web_release.release_id)) {
10576
10573
  throw new Error("Application deploy receipt does not match request");
10577
10574
  }
10578
10575
  }
@@ -16355,6 +16352,60 @@ async function uploadFrontendRelease(http, projectRef, deploymentId, archivePath
16355
16352
  }
16356
16353
  return toolResponse({ project_ref: projectRef, deployment_id: deploymentId, release: verified });
16357
16354
  }
16355
+ async function uploadProjectWebRelease(http, projectRef, environmentId, deploymentId, archivePath) {
16356
+ const endpoint = `/v1/projects/${encodeURIComponent(projectRef)}/environments/${encodeURIComponent(environmentId)}/deployments/web-release?deployment_id=${encodeURIComponent(deploymentId)}`;
16357
+ const archive = await verifiedArchive(archivePath);
16358
+ const successPayload = (value) => {
16359
+ const release = value ? releaseRecord(value.release) : null;
16360
+ if (!value || value.ok !== true || value.project_ref !== projectRef || value.environment_id !== environmentId || value.deployment_id !== deploymentId || value.release_id !== archive.sha256 || release?.release_id !== archive.sha256 || release.tree_sha256.length !== 64)
16361
+ return null;
16362
+ return toolResponse({
16363
+ project_ref: projectRef,
16364
+ environment_id: environmentId,
16365
+ deployment_id: deploymentId,
16366
+ release_id: archive.sha256,
16367
+ release
16368
+ });
16369
+ };
16370
+ try {
16371
+ const response = await http.postBinary(endpoint, {
16372
+ stream: archiveStream(archive),
16373
+ byteLength: archive.sizeBytes
16374
+ }, {
16375
+ contentType: FRONTEND_ARCHIVE_CONTENT_TYPE,
16376
+ contentLength: archive.sizeBytes,
16377
+ contentSha256: archive.sha256,
16378
+ maxJsonBytes: RESPONSE_MAX_BYTES,
16379
+ timeoutMs: UPLOAD_REQUEST_TIMEOUT_MS,
16380
+ responseTimeoutMs: MUTATION_RESPONSE_TIMEOUT_MS
16381
+ });
16382
+ const value = response.data && typeof response.data === "object" && !Array.isArray(response.data) ? response.data : null;
16383
+ if (response.ok && response.status === 201) {
16384
+ const success = successPayload(value);
16385
+ if (success)
16386
+ return success;
16387
+ }
16388
+ if (response.transportError || response.responseReadError || response.status >= 500 || response.status === 202) {
16389
+ const readback = await getFrontendRelease(http, projectRef, deploymentId, archive.sha256);
16390
+ if (!readback.isError) {
16391
+ const readbackValue = JSON.parse(readback.content[0]?.text ?? "{}");
16392
+ const release = readbackValue.release;
16393
+ if (release && typeof release === "object" && !Array.isArray(release) && release.release_id === archive.sha256) {
16394
+ return toolResponse({
16395
+ project_ref: projectRef,
16396
+ environment_id: environmentId,
16397
+ deployment_id: deploymentId,
16398
+ release_id: archive.sha256,
16399
+ release
16400
+ });
16401
+ }
16402
+ }
16403
+ }
16404
+ return releaseFailure("frontend.upload_project_web_release", response.status >= 400 && response.status < 500 && !response.transportError ? "HTTP_ERROR" : "OUTCOME_UNKNOWN", response.status);
16405
+ } finally {
16406
+ await archive.handle.close();
16407
+ }
16408
+ }
16358
16409
  async function uploadFrontendSource(http, projectRef, deploymentId, archivePath) {
16359
16410
  const endpoint = `${deploymentEndpoint(projectRef, deploymentId)}/deploy/upload`;
16360
16411
  const archive = await verifiedArchive(archivePath);
@@ -16912,7 +16963,7 @@ var ApplicationRollbackSnapshotSchema2 = ApplicationRollbackSnapshotSchema;
16912
16963
  var ApplicationActivationHistoryCursorSchema2 = ApplicationActivationHistoryCursorSchema;
16913
16964
  var ApplicationPromotionPlanSchema2 = ApplicationPromotionPlanSchema;
16914
16965
  var ApplicationDeployRequestSchema2 = ApplicationDeployRequestSchema;
16915
- var ApplicationDeployWebRequestSchema2 = ApplicationDeployWebRequestSchema;
16966
+ var ApplicationDeployWebReleaseSchema2 = ApplicationDeployWebReleaseSchema;
16916
16967
 
16917
16968
  // src/shared/mutation-protocol.ts
16918
16969
  import { createHash as createHash6 } from "node:crypto";
@@ -17730,7 +17781,7 @@ var APPLICATION_TOOL_SCHEMA = {
17730
17781
  configuration_path: optional(String2(), "[put_configuration] Local configuration write JSON including revision and expected revision"),
17731
17782
  configuration_write: optional(Unknown(), "[deploy_application] Parsed immutable configuration write"),
17732
17783
  manifest_path: optional(String2(), "[upload_release] Local delivery.manifest.json"),
17733
- web: optional(ApplicationDeployWebRequestSchema2, "[deploy_application] Immutable staged Web release binding"),
17784
+ web_release: optional(ApplicationDeployWebReleaseSchema2, "[deploy_application] Immutable staged Web release uploaded by the deploy profile"),
17734
17785
  release_id: optional(ApplicationReleaseIdSchema2, "[get_release/get_deploy_plan/deploy_release/activate_release/reconcile_activation/rollback_release] Immutable application release ID; platform selects previous for default rollback"),
17735
17786
  source_ref: optional(String2({ pattern: "^[A-Za-z0-9_-]{1,20}$" }), "[get_release_transfer_plan/transfer_release] Source project ref"),
17736
17787
  source_release_id: optional(ApplicationReleaseIdSchema2, "[get_release_transfer_plan/transfer_release] Source immutable release ID"),
@@ -18109,7 +18160,7 @@ function registerApplicationTools(server, http) {
18109
18160
  ...configurationId === undefined ? {} : { configuration_id: configurationId },
18110
18161
  ...configurationWrite === undefined ? {} : { configuration_write: configurationWrite },
18111
18162
  ...typeof args["approved_migration_digest"] === "string" ? { approved_migration_digest: args["approved_migration_digest"] } : {},
18112
- ...args["web"] === undefined ? {} : { web: args["web"] }
18163
+ ...args["web_release"] === undefined ? {} : { web_release: args["web_release"] }
18113
18164
  };
18114
18165
  if (!Check2(ApplicationDeployRequestSchema2, body)) {
18115
18166
  throw new Error("Invalid application deploy request");
@@ -24587,7 +24638,7 @@ var REMOTE_APP_DESCRIPTIONS = {
24587
24638
  source_environment_id: "[promote-plan/diff/promote] Source environment ID",
24588
24639
  mutation_id: "[promote-status/promote-reconcile] Stable promotion mutation ID",
24589
24640
  approved_migration_digest: "[promote] Exact reviewed migration execution-plan digest",
24590
- web: "[release] Immutable staged Web release binding prepared by the deploy profile",
24641
+ web_release: "[release] Immutable staged Web release uploaded by the deploy profile",
24591
24642
  branch_ref: "[preview-plan] Preview branch identity",
24592
24643
  branch_name: "[preview/preview-create] Human-readable preview branch name",
24593
24644
  data_mode: "[preview-plan/preview/preview-create] schema_only or full_clone",
@@ -25630,10 +25681,13 @@ async function runAppRelease(request, options, delegate) {
25630
25681
  mutation_id: activationId,
25631
25682
  ...configurationId === undefined ? {} : { configuration_id: configurationId },
25632
25683
  ...configurationWrite === undefined ? {} : { configuration_write: configurationWrite },
25633
- ...request.web === undefined ? {} : { web: request.web }
25684
+ ...request.web_release === undefined ? {} : { web_release: request.web_release }
25634
25685
  };
25635
25686
  validateToolArguments(APPLICATION_TOOL_SCHEMA, deployArgs);
25636
- const deployed = options.projectDeployment ? await options.projectDeployment(deployArgs) : await delegate(deployArgs);
25687
+ if (!options.projectDeployment) {
25688
+ throw new Error("Application release requires the unified project deployment handler");
25689
+ }
25690
+ const deployed = await options.projectDeployment(deployArgs);
25637
25691
  const deployReceipt = resultObject(deployed);
25638
25692
  const resolvedConfigurationId = typeof deployReceipt?.configuration_id === "string" ? deployReceipt.configuration_id : undefined;
25639
25693
  if (resolvedConfigurationId !== undefined) {
@@ -28502,7 +28556,7 @@ function payload(response) {
28502
28556
  throw new Error("Deployment operation returned an invalid response");
28503
28557
  return parsed;
28504
28558
  }
28505
- async function stageApplicationWebRelease(http, projectRef, configRoot, skipBuild, json, environmentVariables) {
28559
+ async function stageApplicationWebRelease(http, projectRef, environmentId, configRoot, skipBuild, json, environmentVariables) {
28506
28560
  const target = selectFrontendTarget(configRoot, await readDeployConfig(configRoot));
28507
28561
  if (!target)
28508
28562
  return null;
@@ -28528,17 +28582,7 @@ async function stageApplicationWebRelease(http, projectRef, configRoot, skipBuil
28528
28582
  }
28529
28583
  const archive = await createFrontendArchive(outputDirectory);
28530
28584
  try {
28531
- const authority = payload(await readFrontendReleaseAuthority(http, projectRef, selected.id));
28532
- const activeReleaseId = typeof authority.active_release_id === "string" ? authority.active_release_id : null;
28533
- const activeActivationId = typeof authority.active_activation_id === "string" ? authority.active_activation_id : null;
28534
- const current = Array.isArray(authority.releases) ? record4(authority.releases[0]) : null;
28535
- if (archive.sha256 === activeReleaseId && archive.treeSha256 !== current?.tree_sha256) {
28536
- throw new Error("Active Web release tree does not match the local archive");
28537
- }
28538
- if (archive.treeSha256 === current?.tree_sha256) {
28539
- return {};
28540
- }
28541
- const uploaded = payload(await uploadFrontendRelease(http, projectRef, selected.id, archive.archivePath));
28585
+ const uploaded = payload(await uploadProjectWebRelease(http, projectRef, environmentId, selected.id, archive.archivePath));
28542
28586
  const release = record4(uploaded.release);
28543
28587
  const releaseId = requiredString(release?.release_id, "release.release_id");
28544
28588
  if (releaseId !== archive.sha256)
@@ -28548,10 +28592,7 @@ async function stageApplicationWebRelease(http, projectRef, configRoot, skipBuil
28548
28592
  return {
28549
28593
  request: {
28550
28594
  deployment_id: selected.id,
28551
- release_id: releaseId,
28552
- expected_active_release_id: activeReleaseId ?? "absent",
28553
- expected_activation_id: activeActivationId ?? "absent",
28554
- mutation_id: crypto.randomUUID()
28595
+ release_id: releaseId
28555
28596
  }
28556
28597
  };
28557
28598
  } finally {
@@ -28611,7 +28652,7 @@ function registerDeployTools(server, http, options = {}) {
28611
28652
  if (configurationPath && configurationId) {
28612
28653
  throw new Error("Application profile must set only one of SUPACLOUD_APPLICATION_CONFIGURATION_PATH or SUPACLOUD_APPLICATION_CONFIGURATION_ID");
28613
28654
  }
28614
- const stagedWeb = await stageApplicationWebRelease(http, projectRef, configRoot, args.skip_build === true, args.json === true, options.environmentVariables);
28655
+ const stagedWeb = await stageApplicationWebRelease(http, projectRef, environmentId, configRoot, args.skip_build === true, args.json === true, options.environmentVariables);
28615
28656
  const result = await options.applicationRelease({
28616
28657
  action: "release",
28617
28658
  ref: projectRef,
@@ -28622,7 +28663,7 @@ function registerDeployTools(server, http, options = {}) {
28622
28663
  ...configurationId ? { configuration_id: configurationId } : {},
28623
28664
  ...application.manifestPath ? { manifest_path: application.manifestPath } : {},
28624
28665
  ...args.skip_build === true ? { skip_build: true } : {},
28625
- ...stagedWeb?.request === undefined ? {} : { web: stagedWeb.request },
28666
+ ...stagedWeb?.request === undefined ? {} : { web_release: stagedWeb.request },
28626
28667
  ...args.json === true ? { format: "json", json: true } : {}
28627
28668
  });
28628
28669
  return result;
@@ -29466,7 +29507,7 @@ async function runProjectDeployment(http, args) {
29466
29507
  ...args.configuration_write === undefined ? {} : { configuration_write: args.configuration_write },
29467
29508
  ...args.expected_plan_sha256 === undefined ? {} : { expected_plan_sha256: args.expected_plan_sha256 },
29468
29509
  ...args.approved_migration_digest === undefined ? {} : { approved_migration_digest: args.approved_migration_digest },
29469
- ...args.web === undefined ? {} : { web: args.web }
29510
+ ...args.web_release === undefined ? {} : { web_release: args.web_release }
29470
29511
  };
29471
29512
  if (!Check2(scopeSchema, scope) || !Check2(ApplicationDeployRequestSchema, request) || request.configuration_id !== undefined && request.configuration_write !== undefined && request.configuration_id !== request.configuration_write.configuration_id) {
29472
29513
  return releaseControlFailure(operation, "INVALID_RESPONSE", null);
@@ -29520,7 +29561,7 @@ async function runProjectDeployment(http, args) {
29520
29561
  // package.json
29521
29562
  var package_default = {
29522
29563
  name: "@supacloud/cli",
29523
- version: "0.92.0",
29564
+ version: "0.93.0",
29524
29565
  description: "Project-scoped CLI for SupaCloud users",
29525
29566
  type: "module",
29526
29567
  main: "./dist/index.js",
@@ -29573,13 +29614,13 @@ var package_default = {
29573
29614
  },
29574
29615
  dependencies: {
29575
29616
  "@supacloud/compiler": "^0.44.1",
29576
- "@supacloud/delivery": "0.15.1",
29617
+ "@supacloud/delivery": "0.16.0",
29577
29618
  "@supacloud/db": "0.16.1",
29578
29619
  typebox: "1.3.36"
29579
29620
  },
29580
29621
  overrides: {
29581
29622
  "@supacloud/contracts": "0.8.1",
29582
- "@supacloud/delivery": "0.15.1",
29623
+ "@supacloud/delivery": "0.16.0",
29583
29624
  "@graphql-tools/utils": "^12.0.3"
29584
29625
  },
29585
29626
  devDependencies: {
@@ -55,7 +55,7 @@ export interface AppToolArguments {
55
55
  source_environment_id?: string;
56
56
  mutation_id?: string;
57
57
  approved_migration_digest?: string;
58
- web?: ApplicationDeployRequest["web"];
58
+ web_release?: ApplicationDeployRequest["web_release"];
59
59
  branch_ref?: string;
60
60
  branch_name?: string;
61
61
  data_mode?: "schema_only" | "full_clone";
@@ -171,12 +171,9 @@ export declare const ApplicationDeployRequestSchema: import("typebox").TObject<{
171
171
  }>>;
172
172
  expected_plan_sha256: import("typebox").TOptional<import("typebox").TString>;
173
173
  approved_migration_digest: import("typebox").TOptional<import("typebox").TString>;
174
- web: import("typebox").TOptional<import("typebox").TObject<{
174
+ web_release: import("typebox").TOptional<import("typebox").TObject<{
175
175
  deployment_id: import("typebox").TString;
176
176
  release_id: import("typebox").TString;
177
- expected_active_release_id: import("typebox").TString;
178
- expected_activation_id: import("typebox").TString;
179
- mutation_id: import("typebox").TString;
180
177
  }>>;
181
178
  }>;
182
179
  export declare const ApplicationDeployResultSchema: import("typebox").TObject<{
@@ -216,10 +213,7 @@ export declare const ApplicationDeployResultSchema: import("typebox").TObject<{
216
213
  replayed: import("typebox").TBoolean;
217
214
  }>>;
218
215
  }>;
219
- export declare const ApplicationDeployWebRequestSchema: import("typebox").TObject<{
216
+ export declare const ApplicationDeployWebReleaseSchema: import("typebox").TObject<{
220
217
  deployment_id: import("typebox").TString;
221
218
  release_id: import("typebox").TString;
222
- expected_active_release_id: import("typebox").TString;
223
- expected_activation_id: import("typebox").TString;
224
- mutation_id: import("typebox").TString;
225
219
  }>;
@@ -19,12 +19,9 @@ export declare const APPLICATION_TOOL_SCHEMA: {
19
19
  configuration_path: Type.TOptional<Type.TString>;
20
20
  configuration_write: Type.TOptional<Type.TUnknown>;
21
21
  manifest_path: Type.TOptional<Type.TString>;
22
- web: Type.TOptional<Type.TObject<{
22
+ web_release: Type.TOptional<Type.TObject<{
23
23
  deployment_id: Type.TString;
24
24
  release_id: Type.TString;
25
- expected_active_release_id: Type.TString;
26
- expected_activation_id: Type.TString;
27
- mutation_id: Type.TString;
28
25
  }>>;
29
26
  release_id: Type.TOptional<Type.TString>;
30
27
  source_ref: Type.TOptional<Type.TString>;
@@ -42,6 +42,7 @@ export interface FrontendReleaseRecord {
42
42
  export declare function listFrontendReleases(http: FrontendReleaseHttp, projectRef: string, deploymentId: string, cursor?: string, limit?: number): Promise<ToolResponse>;
43
43
  export declare function getFrontendRelease(http: FrontendReleaseHttp, projectRef: string, deploymentId: string, releaseId: string): Promise<ToolResponse>;
44
44
  export declare function uploadFrontendRelease(http: FrontendReleaseHttp, projectRef: string, deploymentId: string, archivePath: string): Promise<ToolResponse>;
45
+ export declare function uploadProjectWebRelease(http: FrontendReleaseHttp, projectRef: string, environmentId: string, deploymentId: string, archivePath: string): Promise<ToolResponse>;
45
46
  export declare function uploadFrontendSource(http: FrontendReleaseHttp, projectRef: string, deploymentId: string, archivePath: string): Promise<ToolResponse>;
46
47
  export declare function getActiveFrontendRelease(http: FrontendReleaseHttp, projectRef: string, deploymentId: string): Promise<ToolResponse>;
47
48
  export declare function readFrontendReleaseAuthority(http: FrontendReleaseHttp, projectRef: string, deploymentId: string): Promise<ToolResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.92.0",
3
+ "version": "0.93.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,13 +53,13 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@supacloud/compiler": "^0.44.1",
56
- "@supacloud/delivery": "0.15.1",
56
+ "@supacloud/delivery": "0.16.0",
57
57
  "@supacloud/db": "0.16.1",
58
58
  "typebox": "1.3.36"
59
59
  },
60
60
  "overrides": {
61
61
  "@supacloud/contracts": "0.8.1",
62
- "@supacloud/delivery": "0.15.1",
62
+ "@supacloud/delivery": "0.16.0",
63
63
  "@graphql-tools/utils": "^12.0.3"
64
64
  },
65
65
  "devDependencies": {