@naturali/cli 0.83.2 → 0.83.4

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.mjs +46 -6
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ var __exportAll = (all, no_symbols) => {
14
14
  };
15
15
  //#endregion
16
16
  //#region package.json
17
- var version = "0.83.2";
17
+ var version = "0.83.4";
18
18
  //#endregion
19
19
  //#region ../sdk/src/generated/core/bodySerializer.gen.ts
20
20
  const serializeFormDataPair = (data, key, value) => {
@@ -2528,7 +2528,7 @@ var Formations = class {
2528
2528
  *
2529
2529
  * Validates the template, creates the formation record, then provisions all declared resources in dependency order.
2530
2530
  *
2531
- * A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `201` and `status: "failed"`, and `error` explains why (the resources created before the failure are rolled back). Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `builtin` CLI exits non-zero on that body so `create-formation && …` does not lie.
2531
+ * A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `201` and `status: "failed"`, and `error` explains why (the resources created before the failure are rolled back). Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `naturali` CLI exits non-zero on that body so `create-formation && …` does not lie.
2532
2532
  *
2533
2533
  */
2534
2534
  static createFormation(options) {
@@ -2573,7 +2573,7 @@ var Formations = class {
2573
2573
  *
2574
2574
  * Applies a new template to the formation. Resources are created, updated, or deleted to reconcile the current state with the desired state.
2575
2575
  *
2576
- * A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `200` and `status: "failed"`, and `error` explains why. Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `builtin` CLI exits non-zero on that body so `update-formation && …` does not lie.
2576
+ * A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `200` and `status: "failed"`, and `error` explains why. Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `naturali` CLI exits non-zero on that body so `update-formation && …` does not lie.
2577
2577
  *
2578
2578
  */
2579
2579
  static updateFormation(options) {
@@ -4843,11 +4843,43 @@ const buildCallOptions = (args) => {
4843
4843
  return callOptions;
4844
4844
  };
4845
4845
  /**
4846
+ * Operations that report the outcome of the thing just asked for *in the body*,
4847
+ * as `status: "failed"` under a `2xx`.
4848
+ *
4849
+ * A deploy failure is not a request failure: the template was accepted, the
4850
+ * resources were attempted, and the rollback ran — so the API answers `201`/`200`
4851
+ * with the formation record and `status: "failed"`. Exiting `0` on that makes
4852
+ * `naturali create-formation && naturali get-agent …` claim a deploy that did
4853
+ * not happen, which is what the formations spec already promises this CLI does
4854
+ * not do.
4855
+ *
4856
+ * Deliberately an explicit list, not a general rule over any `status` field: a
4857
+ * read that returns a formation left `failed` by an earlier deploy is a
4858
+ * **successful read**, and `list-formations` would exit 1 for anyone with one
4859
+ * broken stack. Only these two report an outcome the caller just caused.
4860
+ * `tests/commands.test.ts` pins each id against the generated manifest, so a
4861
+ * renamed operation fails a test instead of silently disarming this.
4862
+ */
4863
+ const OUTCOME_IN_BODY = /* @__PURE__ */ new Set(["createFormation", "updateFormation"]);
4864
+ /**
4865
+ * The stderr line for a `2xx` body that reports its own failure, or `undefined`
4866
+ * when there is nothing to report.
4867
+ */
4868
+ const bodyReportedFailure = (args) => {
4869
+ const { route, data } = args;
4870
+ if (!OUTCOME_IN_BODY.has(route.operationId)) return void 0;
4871
+ if (typeof data !== "object" || data === null) return void 0;
4872
+ const body = data;
4873
+ if (body["status"] !== "failed") return void 0;
4874
+ return `Deploy failed: ${typeof body["error"] === "string" && body["error"].length > 0 ? body["error"] : "no reason given"}`;
4875
+ };
4876
+ /**
4846
4877
  * Runs one generated command: parses its flags, resolves credentials, calls the
4847
4878
  * matching SDK method, and prints the result.
4848
4879
  *
4849
4880
  * Exits non-zero — after printing the error envelope — on an unresolved path
4850
- * parameter, a missing SDK method, or a non-2xx response.
4881
+ * parameter, a missing SDK method, or a non-2xx response, and after printing
4882
+ * the body on a `2xx` that reports its own failure (see `OUTCOME_IN_BODY`).
4851
4883
  */
4852
4884
  const dispatchCommand = async (args) => {
4853
4885
  const { commandName, route, rawArgs } = args;
@@ -4883,6 +4915,14 @@ const dispatchCommand = async (args) => {
4883
4915
  process.exit(1);
4884
4916
  }
4885
4917
  console.log(await formatResultData(result.data));
4918
+ const failure = bodyReportedFailure({
4919
+ route,
4920
+ data: result.data
4921
+ });
4922
+ if (failure !== void 0) {
4923
+ console.error(failure);
4924
+ process.exit(1);
4925
+ }
4886
4926
  };
4887
4927
  //#endregion
4888
4928
  //#region src/generated/routes.ts
@@ -10323,7 +10363,7 @@ const routes = {
10323
10363
  "create-formation": {
10324
10364
  serviceClass: "Formations",
10325
10365
  operationId: "createFormation",
10326
- description: "Validates the template, creates the formation record, then provisions all declared resources in dependency order. A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `201` and `status: \"failed\"`, and `error` explains why (the resources created before the failure are rolled back). Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `builtin` CLI exits non-zero on that body so `create-formation && …` does not lie.",
10366
+ description: "Validates the template, creates the formation record, then provisions all declared resources in dependency order. A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `201` and `status: \"failed\"`, and `error` explains why (the resources created before the failure are rolled back). Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `naturali` CLI exits non-zero on that body so `create-formation && …` does not lie.",
10327
10367
  moduleDocsUrl: "https://docs.naturali.ai/docs/modules/formations",
10328
10368
  httpMethod: "post",
10329
10369
  pathParams: ["project_id"],
@@ -10391,7 +10431,7 @@ const routes = {
10391
10431
  "update-formation": {
10392
10432
  serviceClass: "Formations",
10393
10433
  operationId: "updateFormation",
10394
- description: "Applies a new template to the formation. Resources are created, updated, or deleted to reconcile the current state with the desired state. A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `200` and `status: \"failed\"`, and `error` explains why. Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `builtin` CLI exits non-zero on that body so `update-formation && …` does not lie.",
10434
+ description: "Applies a new template to the formation. Resources are created, updated, or deleted to reconcile the current state with the desired state. A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `200` and `status: \"failed\"`, and `error` explains why. Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `naturali` CLI exits non-zero on that body so `update-formation && …` does not lie.",
10395
10435
  moduleDocsUrl: "https://docs.naturali.ai/docs/modules/formations",
10396
10436
  httpMethod: "put",
10397
10437
  pathParams: ["project_id", "formation_id"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturali/cli",
3
- "version": "0.83.2",
3
+ "version": "0.83.4",
4
4
  "description": "Command-line interface for the naturali.ai API, generated from its OpenAPI specs",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "tsx": "^4.23.1",
31
31
  "typescript": "~6.0.3",
32
32
  "vitest": "^4.1.10",
33
- "@naturali/sdk": "0.83.2"
33
+ "@naturali/sdk": "0.83.4"
34
34
  },
35
35
  "scripts": {
36
36
  "generate": "tsx scripts/generate.ts",