@supacloud/cli 0.78.0 → 0.79.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
@@ -179093,11 +179093,12 @@ function resolveSupaCloudContext(env = process.env, cwd = process.cwd(), selecti
179093
179093
  var ACTION_POLICY = {
179094
179094
  deploy: { write: ["deploy"] },
179095
179095
  applications: {
179096
- read: ["list_releases", "get_release", "get_runtime", "get_deployment_evidence", "get_configuration", "logs", "get_preview_plan"],
179096
+ read: ["list_releases", "get_release", "get_runtime", "get_deployment_evidence", "get_configuration", "get_rollback_snapshot", "logs", "get_preview_plan"],
179097
179097
  write: [
179098
179098
  "upload_release",
179099
179099
  "put_configuration",
179100
179100
  "activate_release",
179101
+ "rollback_release",
179101
179102
  "reconcile_activation",
179102
179103
  "retire_activation",
179103
179104
  "create_preview",
@@ -179199,7 +179200,7 @@ var ACTION_POLICY = {
179199
179200
  ai: { local: ["show_skill", "install_skill"] },
179200
179201
  app: {
179201
179202
  local: ["init", "generate", "dev", "watch", "verify-plan", "compile", "check", "graph", "explain", "export-tools", "context", "doctor", "fix", "plan", "build"],
179202
- read: ["status", "logs", "preview-plan"],
179203
+ read: ["status", "logs", "rollback-plan", "preview-plan"],
179203
179204
  write: ["upload", "configure", "deploy", "rollback", "reconcile", "retire", "preview", "previews", "preview-status", "preview-cleanup"]
179204
179205
  },
179205
179206
  db: {
@@ -180280,6 +180281,19 @@ var ApplicationActivationRetirementResultSchema = _Object_({
180280
180281
  activation_id: ApplicationActivationIdSchema,
180281
180282
  retired_at: String2()
180282
180283
  }, { additionalProperties: false });
180284
+ var RollbackActivationSchema = _Object_({
180285
+ release_id: ApplicationReleaseIdSchema,
180286
+ configuration_id: ApplicationConfigurationIdSchema,
180287
+ activation_id: ApplicationActivationIdSchema
180288
+ }, { additionalProperties: false });
180289
+ var ApplicationRollbackSnapshotSchema = _Object_({
180290
+ schema: Literal("supacloud.application-rollback-snapshot.v1"),
180291
+ project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
180292
+ application_id: ApplicationIdSchema,
180293
+ environment_id: ApplicationIdSchema,
180294
+ active: Union([RollbackActivationSchema, Null()]),
180295
+ previous: Union([RollbackActivationSchema, Null()])
180296
+ }, { additionalProperties: false });
180283
180297
  // node_modules/@supacloud/delivery/src/deployment-evidence.ts
180284
180298
  var closed3 = { additionalProperties: false };
180285
180299
  var sha256 = String2({ pattern: "^[a-f0-9]{64}$" });
@@ -187252,6 +187266,7 @@ var ApplicationActivationIdSchema2 = ApplicationActivationIdSchema;
187252
187266
  var ApplicationActivationWriteSchema2 = ApplicationActivationWriteSchema;
187253
187267
  var ApplicationActivationResultSchema2 = ApplicationActivationResultSchema;
187254
187268
  var ApplicationActivationRetirementResultSchema2 = ApplicationActivationRetirementResultSchema;
187269
+ var ApplicationRollbackSnapshotSchema2 = ApplicationRollbackSnapshotSchema;
187255
187270
 
187256
187271
  // src/shared/tools/application-preview-tools.ts
187257
187272
  var APPLICATION_PREVIEW_ACTIONS = [
@@ -187590,6 +187605,8 @@ var APPLICATION_TOOL_SCHEMA = {
187590
187605
  "get_configuration",
187591
187606
  "put_configuration",
187592
187607
  "activate_release",
187608
+ "rollback_release",
187609
+ "get_rollback_snapshot",
187593
187610
  "reconcile_activation",
187594
187611
  "retire_activation",
187595
187612
  ...APPLICATION_PREVIEW_ACTIONS,
@@ -187597,13 +187614,13 @@ var APPLICATION_TOOL_SCHEMA = {
187597
187614
  ]), "Action"),
187598
187615
  ref: withDescription(String2(), "Project ref"),
187599
187616
  id: withDescription(ApplicationIdSchema2, "Application ID"),
187600
- environment_id: optional(withDescription(ApplicationIdSchema2, "[get_runtime/get_configuration/put_configuration] Environment ID")),
187601
- configuration_id: optional(ApplicationConfigurationIdSchema2, "[get_configuration/activate_release] Immutable revision; required for activation"),
187602
- activation_id: optional(ApplicationActivationIdSchema2, "[activate_release/reconcile_activation/retire_activation] Explicit stable activation ID"),
187603
- expected_activation_id: optional(Union([ApplicationActivationIdSchema2, Null(), Literal("absent")]), "[activate_release] Current activation ID, or absent for first activation"),
187617
+ environment_id: optional(withDescription(ApplicationIdSchema2, "[get_runtime/get_configuration/put_configuration/get_rollback_snapshot/rollback_release] Environment ID")),
187618
+ configuration_id: optional(ApplicationConfigurationIdSchema2, "[get_configuration/activate_release/rollback_release] Immutable revision; required for explicit activation"),
187619
+ activation_id: optional(ApplicationActivationIdSchema2, "[activate_release/reconcile_activation/retire_activation/rollback_release] Explicit stable activation ID; generated for rollback if omitted"),
187620
+ expected_activation_id: optional(Union([ApplicationActivationIdSchema2, Null(), Literal("absent")]), "[activate_release/rollback_release] Current activation ID, or absent for first activation; selected by platform for default rollback"),
187604
187621
  configuration_path: optional(String2(), "[put_configuration] Local configuration write JSON including revision and expected revision"),
187605
187622
  manifest_path: optional(String2(), "[upload_release] Local delivery.manifest.json"),
187606
- release_id: optional(ApplicationReleaseIdSchema2, "[get_release/activate_release/reconcile_activation] Immutable application release ID"),
187623
+ release_id: optional(ApplicationReleaseIdSchema2, "[get_release/activate_release/reconcile_activation/rollback_release] Immutable application release ID; platform selects previous for default rollback"),
187607
187624
  cursor: optional(ApplicationReleaseIdSchema2, "[list_releases] Last release ID"),
187608
187625
  limit: optional(Integer({ minimum: 1, maximum: 100 }), "[list_releases] Page size, default 50"),
187609
187626
  offset: optional(Integer({ minimum: 0, maximum: 1e6 }), "[logs] Result offset"),
@@ -187682,7 +187699,7 @@ async function configurationAction(http, args, project) {
187682
187699
  return releaseControlFailure(operation, action === "put_configuration" ? "OUTCOME_UNKNOWN" : "INVALID_RESPONSE", result.status, identity);
187683
187700
  }
187684
187701
  }
187685
- async function activationAction(http, args, project) {
187702
+ async function activationAction(http, args, project, rollback) {
187686
187703
  const action = text(args, "action"), ref = text(args, "ref"), id = text(args, "id");
187687
187704
  const environmentId = text(args, "environment_id"), activationId = text(args, "activation_id");
187688
187705
  const releaseId = args["release_id"] === undefined ? undefined : text(args, "release_id");
@@ -187692,7 +187709,7 @@ async function activationAction(http, args, project) {
187692
187709
  if (!Check2(ApplicationIdSchema2, environmentId) || !Check2(ApplicationActivationIdSchema2, activationId) || action !== "retire_activation" && !Check2(ApplicationReleaseIdSchema2, releaseId)) {
187693
187710
  throw new Error("Invalid application activation identity");
187694
187711
  }
187695
- const operation = `applications.${action}`;
187712
+ const operation = rollback ? "applications.rollback_release" : `applications.${action}`;
187696
187713
  const path = `/v1/projects/${project}/applications/${encodeURIComponent(id)}/environments/${encodeURIComponent(environmentId)}/activations`;
187697
187714
  const identity = {
187698
187715
  project_ref: ref,
@@ -187701,6 +187718,7 @@ async function activationAction(http, args, project) {
187701
187718
  activation_id: activationId,
187702
187719
  ...releaseId ? { release_id: releaseId } : {}
187703
187720
  };
187721
+ const safeState = { ...identity, ...rollback ?? {} };
187704
187722
  let body = {};
187705
187723
  if (action === "activate_release") {
187706
187724
  body = {
@@ -187715,7 +187733,9 @@ async function activationAction(http, args, project) {
187715
187733
  const endpoint = action === "activate_release" ? path : `${path}/${activationId}/${action === "retire_activation" ? "retire" : "reconcile"}`;
187716
187734
  const result = await http.post(endpoint, body, { timeoutMs: 120000, maxJsonBytes: 65536, responseTimeoutMs: 30000 });
187717
187735
  if (!result.ok)
187718
- return releaseControlMutationFailure(operation, result, identity);
187736
+ return releaseControlMutationFailure(operation, result, safeState);
187737
+ if (result.status !== 200)
187738
+ return releaseControlFailure(operation, "OUTCOME_UNKNOWN", result.status, safeState);
187719
187739
  if (action === "retire_activation") {
187720
187740
  if (!Check2(ApplicationActivationRetirementResultSchema2, result.data) || Object.entries(identity).some(([key, value]) => Reflect.get(result.data, key) !== value)) {
187721
187741
  return releaseControlFailure(operation, "OUTCOME_UNKNOWN", result.status, identity);
@@ -187723,9 +187743,60 @@ async function activationAction(http, args, project) {
187723
187743
  return releaseControlSuccess(operation, result.data);
187724
187744
  }
187725
187745
  if (!Check2(ApplicationActivationResultSchema2, result.data) || Object.entries(identity).some(([key, value]) => Reflect.get(result.data, key) !== value) || action === "reconcile_activation" && !result.data.replayed) {
187726
- return releaseControlFailure(operation, "OUTCOME_UNKNOWN", result.status, identity);
187746
+ return releaseControlFailure(operation, "OUTCOME_UNKNOWN", result.status, safeState);
187747
+ }
187748
+ return releaseControlSuccess(operation, { ...result.data, ...rollback ?? {} });
187749
+ }
187750
+ async function rollbackAction(http, args, project) {
187751
+ const ref = text(args, "ref"), id = text(args, "id"), environmentId = text(args, "environment_id");
187752
+ if (!Check2(ApplicationIdSchema2, environmentId))
187753
+ throw new Error("Invalid environment ID");
187754
+ const operation = `applications.${text(args, "action")}`;
187755
+ const identity = { project_ref: ref, application_id: id, environment_id: environmentId };
187756
+ let activationId = args["activation_id"];
187757
+ if (activationId !== undefined && !Check2(ApplicationActivationIdSchema2, activationId)) {
187758
+ throw new Error("Invalid application activation ID");
187759
+ }
187760
+ let releaseId = args["release_id"], configurationId = args["configuration_id"];
187761
+ let expectedActivationId = args["expected_activation_id"];
187762
+ if (releaseId === undefined || args["action"] === "get_rollback_snapshot") {
187763
+ if (releaseId !== undefined || configurationId !== undefined || expectedActivationId !== undefined) {
187764
+ throw new Error("Default rollback selection cannot mix explicit release/configuration/CAS flags");
187765
+ }
187766
+ const response = await http.get(`/v1/projects/${project}/applications/${encodeURIComponent(id)}/environments/${encodeURIComponent(environmentId)}/rollback-snapshot`, { maxJsonBytes: 65536, responseTimeoutMs: 30000 });
187767
+ if (!response.ok)
187768
+ return releaseControlFailure(operation, "HTTP_ERROR", response.transportError ? null : response.status, identity);
187769
+ const snapshot = response.data;
187770
+ if (response.status !== 200 || !Check2(ApplicationRollbackSnapshotSchema2, snapshot) || snapshot.project_ref !== ref || snapshot.application_id !== id || snapshot.environment_id !== environmentId || snapshot.previous !== null && (snapshot.active === null || snapshot.previous.activation_id === snapshot.active.activation_id)) {
187771
+ return releaseControlFailure(operation, "INVALID_RESPONSE", response.status, identity);
187772
+ }
187773
+ if (args["action"] === "get_rollback_snapshot")
187774
+ return releaseControlSuccess(operation, { ...identity, snapshot });
187775
+ if (!snapshot.active || !snapshot.previous) {
187776
+ return releaseControlFailure(operation, "MUTATION_NOT_SUCCEEDED", response.status, {
187777
+ ...identity,
187778
+ reason: "NO_PREVIOUS_ACTIVATION"
187779
+ });
187780
+ }
187781
+ if (activationId === snapshot.active.activation_id || activationId === snapshot.previous.activation_id) {
187782
+ throw new Error("Rollback requires a new activation ID");
187783
+ }
187784
+ releaseId = snapshot.previous.release_id;
187785
+ configurationId = snapshot.previous.configuration_id;
187786
+ expectedActivationId = snapshot.active.activation_id;
187727
187787
  }
187728
- return releaseControlSuccess(operation, result.data);
187788
+ activationId ??= crypto.randomUUID();
187789
+ return activationAction(http, {
187790
+ ...args,
187791
+ action: "activate_release",
187792
+ activation_id: activationId,
187793
+ release_id: releaseId,
187794
+ configuration_id: configurationId,
187795
+ expected_activation_id: expectedActivationId
187796
+ }, project, {
187797
+ configuration_id: configurationId,
187798
+ expected_activation_id: expectedActivationId === "absent" ? null : expectedActivationId
187799
+ });
187729
187800
  }
187730
187801
  function registerApplicationTools(server2, http) {
187731
187802
  registerTool(server2, "applications", "Store, inspect and explicitly activate immutable HTTP/Worker application releases. Upload does not activate a release.", APPLICATION_TOOL_SCHEMA, async (args) => {
@@ -187735,6 +187806,9 @@ function registerApplicationTools(server2, http) {
187735
187806
  throw new Error("Invalid application ID");
187736
187807
  const path = `/v1/projects/${project}/applications/${encodeURIComponent(id)}/releases`;
187737
187808
  const operation = `applications.${action}`;
187809
+ if (action === "rollback_release" || action === "get_rollback_snapshot") {
187810
+ return rollbackAction(http, args, project);
187811
+ }
187738
187812
  if (APPLICATION_PREVIEW_ACTIONS.some((value) => value === action)) {
187739
187813
  return applicationPreviewAction(http, args, project);
187740
187814
  }
@@ -193981,7 +194055,8 @@ var REMOTE_APP_ACTIONS = {
193981
194055
  configure: "put_configuration",
193982
194056
  deploy: "activate_release",
193983
194057
  status: "get_runtime",
193984
- rollback: "activate_release",
194058
+ rollback: "rollback_release",
194059
+ "rollback-plan": "get_rollback_snapshot",
193985
194060
  reconcile: "reconcile_activation",
193986
194061
  retire: "retire_activation",
193987
194062
  logs: "logs",
@@ -193992,15 +194067,15 @@ var REMOTE_APP_ACTIONS = {
193992
194067
  "preview-cleanup": "cleanup_preview"
193993
194068
  };
193994
194069
  var REMOTE_APP_DESCRIPTIONS = {
193995
- ref: "[upload/configure/deploy/status/rollback/reconcile/retire/preview-plan/preview/previews/preview-status/preview-cleanup] Project ref (defaults to context)",
193996
- id: "[upload/configure/deploy/status/rollback/reconcile/retire/preview-plan/preview/previews/preview-status/preview-cleanup] Application ID",
193997
- environment_id: "[configure/deploy/status/rollback/reconcile/retire/preview-plan/preview/previews/preview-status/preview-cleanup] Environment ID",
193998
- configuration_id: "[deploy/rollback/preview] Required immutable configuration revision",
193999
- activation_id: "[deploy/rollback/reconcile/retire] Required explicit activation ID",
194000
- expected_activation_id: "[deploy/rollback] Required current activation ID, or absent for first activation",
194070
+ ref: "[upload/configure/deploy/status/rollback/rollback-plan/reconcile/retire/preview-plan/preview/previews/preview-status/preview-cleanup] Project ref (defaults to context)",
194071
+ id: "[upload/configure/deploy/status/rollback/rollback-plan/reconcile/retire/preview-plan/preview/previews/preview-status/preview-cleanup] Application ID",
194072
+ environment_id: "[configure/deploy/status/rollback/rollback-plan/reconcile/retire/preview-plan/preview/previews/preview-status/preview-cleanup] Environment ID",
194073
+ configuration_id: "[deploy/rollback/preview] Required for deploy/preview/explicit rollback; platform selects for default rollback",
194074
+ activation_id: "[deploy/rollback/reconcile/retire] Required explicit activation ID; generated for rollback if omitted",
194075
+ expected_activation_id: "[deploy/rollback] Required for deploy/explicit rollback; platform selects current CAS for default rollback",
194001
194076
  configuration_path: "[configure] Configuration write JSON including revision and expected revision",
194002
194077
  manifest_path: "[upload] Local delivery.manifest.json",
194003
- release_id: "[deploy/rollback/reconcile/preview-plan/preview] Required immutable application release ID",
194078
+ release_id: "[deploy/rollback/reconcile/preview-plan/preview] Required for deploy/reconcile/preview; defaults to journal-selected previous for rollback",
194004
194079
  preview_id: "[preview-status/preview-cleanup] Preview receipt ID",
194005
194080
  branch_ref: "[preview-plan] Proposed branch ref; preview assigns its own",
194006
194081
  branch_name: "[preview] Branch display name",
@@ -195010,6 +195085,7 @@ function registerAppTools(server2, options = {}) {
195010
195085
  "deploy",
195011
195086
  "status",
195012
195087
  "rollback",
195088
+ "rollback-plan",
195013
195089
  "reconcile",
195014
195090
  "retire",
195015
195091
  "logs",
@@ -195018,7 +195094,7 @@ function registerAppTools(server2, options = {}) {
195018
195094
  "previews",
195019
195095
  "preview-status",
195020
195096
  "preview-cleanup"
195021
- ]), "App action; upload/configure only prepare, rollback activates an explicit old release without schema downgrade"),
195097
+ ]), "App action; upload/configure only prepare, rollback activates the journal-selected previous release without schema downgrade"),
195022
195098
  kind: optional(stringEnum(["module", "command", "query", "controller", "job", "contract", "resource"]), "[generate] Scaffold kind"),
195023
195099
  template: optional(stringEnum(["minimal", "http", "command", "edge"]), "[init] Minimal application by default; explicit http/command/edge recipes"),
195024
195100
  name: optional(String2(), "[init/generate] Project or object name"),
@@ -198585,7 +198661,7 @@ function registerRemoteDevTools(server2, options = {}) {
198585
198661
  // package.json
198586
198662
  var package_default = {
198587
198663
  name: "@supacloud/cli",
198588
- version: "0.78.0",
198664
+ version: "0.79.0",
198589
198665
  description: "Project-scoped CLI for SupaCloud users",
198590
198666
  type: "module",
198591
198667
  main: "./dist/index.js",
@@ -198637,14 +198713,14 @@ var package_default = {
198637
198713
  },
198638
198714
  dependencies: {
198639
198715
  "@supacloud/compiler": "^0.43.0",
198640
- "@supacloud/delivery": "0.8.0",
198716
+ "@supacloud/delivery": "0.9.0",
198641
198717
  "@supacloud/db": "0.16.0",
198642
198718
  fflate: "^0.8.3",
198643
198719
  typebox: "1.3.34"
198644
198720
  },
198645
198721
  overrides: {
198646
198722
  "@supacloud/contracts": "0.8.0",
198647
- "@supacloud/delivery": "0.8.0",
198723
+ "@supacloud/delivery": "0.9.0",
198648
198724
  "@graphql-tools/utils": "^12.0.3"
198649
198725
  },
198650
198726
  devDependencies: {
@@ -5,7 +5,8 @@ declare const REMOTE_APP_ACTIONS: {
5
5
  readonly configure: "put_configuration";
6
6
  readonly deploy: "activate_release";
7
7
  readonly status: "get_runtime";
8
- readonly rollback: "activate_release";
8
+ readonly rollback: "rollback_release";
9
+ readonly "rollback-plan": "get_rollback_snapshot";
9
10
  readonly reconcile: "reconcile_activation";
10
11
  readonly retire: "retire_activation";
11
12
  readonly logs: "logs";
@@ -73,3 +73,19 @@ export declare const ApplicationActivationRetirementResultSchema: import("typebo
73
73
  activation_id: import("typebox").TString;
74
74
  retired_at: import("typebox").TString;
75
75
  }>;
76
+ export declare const ApplicationRollbackSnapshotSchema: import("typebox").TObject<{
77
+ schema: import("typebox").TLiteral<"supacloud.application-rollback-snapshot.v1">;
78
+ project_ref: import("typebox").TString;
79
+ application_id: import("typebox").TString;
80
+ environment_id: import("typebox").TString;
81
+ active: import("typebox").TUnion<[import("typebox").TObject<{
82
+ release_id: import("typebox").TString;
83
+ configuration_id: import("typebox").TString;
84
+ activation_id: import("typebox").TString;
85
+ }>, import("typebox").TNull]>;
86
+ previous: import("typebox").TUnion<[import("typebox").TObject<{
87
+ release_id: import("typebox").TString;
88
+ configuration_id: import("typebox").TString;
89
+ activation_id: import("typebox").TString;
90
+ }>, import("typebox").TNull]>;
91
+ }>;
@@ -9,7 +9,7 @@ export declare const APPLICATION_TOOL_SCHEMA: {
9
9
  ttl_seconds: Type.TOptional<Type.TInteger>;
10
10
  wait: Type.TOptional<Type.TBoolean>;
11
11
  timeout_seconds: Type.TOptional<Type.TInteger>;
12
- action: Type.TEnum<("list_releases" | "get_release" | "upload_release" | "activate_release" | "logs" | "get_runtime" | "get_deployment_evidence" | "get_configuration" | "get_preview_plan" | "put_configuration" | "reconcile_activation" | "retire_activation" | "create_preview" | "list_previews" | "get_preview" | "cleanup_preview")[]>;
12
+ action: Type.TEnum<("list_releases" | "get_release" | "upload_release" | "activate_release" | "logs" | "get_runtime" | "get_deployment_evidence" | "get_configuration" | "get_rollback_snapshot" | "get_preview_plan" | "put_configuration" | "rollback_release" | "reconcile_activation" | "retire_activation" | "create_preview" | "list_previews" | "get_preview" | "cleanup_preview")[]>;
13
13
  ref: Type.TString;
14
14
  id: Type.TString;
15
15
  environment_id: Type.TOptional<Type.TString>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.78.0",
3
+ "version": "0.79.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,14 +52,14 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@supacloud/compiler": "^0.43.0",
55
- "@supacloud/delivery": "0.8.0",
55
+ "@supacloud/delivery": "0.9.0",
56
56
  "@supacloud/db": "0.16.0",
57
57
  "fflate": "^0.8.3",
58
58
  "typebox": "1.3.34"
59
59
  },
60
60
  "overrides": {
61
61
  "@supacloud/contracts": "0.8.0",
62
- "@supacloud/delivery": "0.8.0",
62
+ "@supacloud/delivery": "0.9.0",
63
63
  "@graphql-tools/utils": "^12.0.3"
64
64
  },
65
65
  "devDependencies": {