@caelo-cms/provisioning 0.11.15 → 0.11.17

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 (47) hide show
  1. package/dist/adopt-existing.d.ts +0 -56
  2. package/dist/adopt-existing.d.ts.map +1 -1
  3. package/dist/adopt-existing.js +58 -2
  4. package/dist/adopt-existing.js.map +1 -1
  5. package/dist/cloudsql-tls.d.ts.map +1 -1
  6. package/dist/cloudsql-tls.js +3 -3
  7. package/dist/cloudsql-tls.js.map +1 -1
  8. package/dist/deployed-release.d.ts.map +1 -1
  9. package/dist/deployed-release.js +8 -6
  10. package/dist/deployed-release.js.map +1 -1
  11. package/dist/gcloud.d.ts +2 -0
  12. package/dist/gcloud.d.ts.map +1 -1
  13. package/dist/gcloud.js +14 -0
  14. package/dist/gcloud.js.map +1 -1
  15. package/dist/mcp-auth-proxy-setup.d.ts.map +1 -1
  16. package/dist/mcp-auth-proxy-setup.js +3 -6
  17. package/dist/mcp-auth-proxy-setup.js.map +1 -1
  18. package/dist/ops-backend.d.ts.map +1 -1
  19. package/dist/ops-backend.js +4 -6
  20. package/dist/ops-backend.js.map +1 -1
  21. package/dist/remote-mcp.d.ts.map +1 -1
  22. package/dist/remote-mcp.js +4 -5
  23. package/dist/remote-mcp.js.map +1 -1
  24. package/dist/runtime-secrets.d.ts.map +1 -1
  25. package/dist/runtime-secrets.js +4 -5
  26. package/dist/runtime-secrets.js.map +1 -1
  27. package/dist/staging-gateway-setup.d.ts.map +1 -1
  28. package/dist/staging-gateway-setup.js +7 -8
  29. package/dist/staging-gateway-setup.js.map +1 -1
  30. package/dist/state-lock-lease.d.ts +1 -1
  31. package/dist/state-lock-lease.d.ts.map +1 -1
  32. package/dist/state-lock-lease.js +2 -2
  33. package/dist/state-lock-lease.js.map +1 -1
  34. package/package.json +2 -2
  35. package/src/adopt-existing.test.ts +36 -9
  36. package/src/adopt-existing.ts +2 -3
  37. package/src/cloudsql-tls.ts +3 -3
  38. package/src/deployed-release.test.ts +15 -0
  39. package/src/deployed-release.ts +8 -6
  40. package/src/gcloud.test.ts +24 -0
  41. package/src/gcloud.ts +17 -0
  42. package/src/mcp-auth-proxy-setup.ts +3 -7
  43. package/src/ops-backend.ts +4 -7
  44. package/src/remote-mcp.ts +4 -6
  45. package/src/runtime-secrets.ts +4 -5
  46. package/src/staging-gateway-setup.ts +7 -8
  47. package/src/state-lock-lease.ts +2 -4
@@ -22,7 +22,7 @@
22
22
  */
23
23
 
24
24
  import { randomBytes } from "node:crypto";
25
- import { gcloud as defaultGcloud } from "./gcloud.js";
25
+ import { gcloud as defaultGcloud, isGcloudNotFound } from "./gcloud.js";
26
26
  import { type GcloudRunner, realSleep, runWithRetry, type Sleep } from "./gcloud-retry.js";
27
27
  import {
28
28
  gatewayServiceAccountEmail,
@@ -86,7 +86,6 @@ export interface EnsureOutcome {
86
86
  readonly detail?: string;
87
87
  }
88
88
 
89
- const NOT_FOUND = /NOT_FOUND|not found|does not exist/i;
90
89
  const ALREADY_EXISTS = /ALREADY_EXISTS|already exists/i;
91
90
 
92
91
  // ===========================================================================
@@ -163,7 +162,7 @@ async function ensureServiceAccount(
163
162
  "--format=value(email)",
164
163
  ]);
165
164
  if (describe.ok) return { id, status: "present" };
166
- if (!NOT_FOUND.test(describe.stderr)) {
165
+ if (!isGcloudNotFound(describe.stderr)) {
167
166
  return { id, status: "failed", error: describe.stderr.trim() };
168
167
  }
169
168
  const create = await run([
@@ -292,7 +291,7 @@ export async function createInstallSecret(
292
291
  "--format=value(name)",
293
292
  ]);
294
293
  const read: { ok: true; replication: SecretReplication } | { ok: false; error: string } =
295
- !pg.ok && NOT_FOUND.test(pg.stderr)
294
+ !pg.ok && isGcloudNotFound(pg.stderr)
296
295
  ? { ok: true, replication: { kind: "user-managed", locations: [install.region] } }
297
296
  : await readSecretReplication(install, { run });
298
297
  if (!read.ok) return read;
@@ -360,7 +359,7 @@ export async function ensureGeneratedSecrets(
360
359
  const secretId = gcpSecretId(install.env, name);
361
360
  const id = `secret ${secretId}`;
362
361
  const describe = await run(["secrets", "describe", secretId, project, "--format=value(name)"]);
363
- if (!describe.ok && !NOT_FOUND.test(describe.stderr)) {
362
+ if (!describe.ok && !isGcloudNotFound(describe.stderr)) {
364
363
  outcomes.push({ id, status: "failed", error: describe.stderr.trim() });
365
364
  continue;
366
365
  }
@@ -39,7 +39,7 @@ import {
39
39
  GATEWAY_POOL_MAX,
40
40
  isIpLiteral,
41
41
  } from "@caelo-cms/shared";
42
- import { gcloud as defaultGcloud } from "./gcloud.js";
42
+ import { gcloud as defaultGcloud, isGcloudNotFound } from "./gcloud.js";
43
43
  import { type GcloudRunner, realSleep, runWithRetry, type Sleep } from "./gcloud-retry.js";
44
44
  import {
45
45
  firebaseStagingSiteId,
@@ -87,7 +87,6 @@ export interface StagingDnsRecord {
87
87
  readonly value: string;
88
88
  }
89
89
 
90
- const NOT_FOUND = /NOT_FOUND|not found|cannot find|does not exist|could not be found|404/i;
91
90
  const ALREADY_EXISTS = /ALREADY_EXISTS|already exists|409/i;
92
91
 
93
92
  /** The `gcp` staging host's managed certificate: the edge's prefix plus six hex of the host's SHA-256. */
@@ -269,7 +268,7 @@ async function ensureStagingBucket(
269
268
  "--format=value(name)",
270
269
  ]);
271
270
  if (described.ok) outcomes.push({ id, status: "present" });
272
- else if (!NOT_FOUND.test(described.stderr)) {
271
+ else if (!isGcloudNotFound(described.stderr)) {
273
272
  return [{ id, status: "failed", error: described.stderr.trim() }];
274
273
  } else {
275
274
  const created = await run([
@@ -352,7 +351,7 @@ async function ensureService(
352
351
  `--project=${inputs.projectId}`,
353
352
  "--format=value(metadata.name)",
354
353
  ]);
355
- if (!existing.ok && !NOT_FOUND.test(existing.stderr)) {
354
+ if (!existing.ok && !isGcloudNotFound(existing.stderr)) {
356
355
  return { id, status: "failed", error: existing.stderr.trim() };
357
356
  }
358
357
  if (!existing.ok) {
@@ -689,7 +688,7 @@ async function deleteStagingDomainMapping(
689
688
  "--format=value(metadata.name)",
690
689
  ]);
691
690
  if (!described.ok) {
692
- if (/\bNOT_FOUND\b|not found|could not be found/i.test(described.stderr)) {
691
+ if (isGcloudNotFound(described.stderr)) {
693
692
  return { ok: true, deleted: false };
694
693
  }
695
694
  return {
@@ -814,7 +813,7 @@ async function ensureGcpEdge(
814
813
  "--format=value(name)",
815
814
  ]);
816
815
  if (!neg.ok) {
817
- if (!NOT_FOUND.test(neg.stderr)) return fail(`describe ${names.neg}: ${neg.stderr.trim()}`);
816
+ if (!isGcloudNotFound(neg.stderr)) return fail(`describe ${names.neg}: ${neg.stderr.trim()}`);
818
817
  const created = await run([
819
818
  "compute",
820
819
  "network-endpoint-groups",
@@ -862,7 +861,7 @@ async function ensureGcpEdge(
862
861
  ]);
863
862
  let backendJson: { selfLink?: string; backends?: { group?: string }[] } = {};
864
863
  if (!backend.ok) {
865
- if (!NOT_FOUND.test(backend.stderr)) {
864
+ if (!isGcloudNotFound(backend.stderr)) {
866
865
  return fail(`describe ${names.backend}: ${backend.stderr.trim()}`);
867
866
  }
868
867
  const created = await run([
@@ -922,7 +921,7 @@ async function ensureGcpEdge(
922
921
  "--format=value(name)",
923
922
  ]);
924
923
  if (!cert.ok) {
925
- if (!NOT_FOUND.test(cert.stderr)) return fail(`describe ${certName}: ${cert.stderr.trim()}`);
924
+ if (!isGcloudNotFound(cert.stderr)) return fail(`describe ${certName}: ${cert.stderr.trim()}`);
926
925
  const created = await run([
927
926
  "compute",
928
927
  "ssl-certificates",
@@ -47,7 +47,7 @@ import { createHash, randomUUID } from "node:crypto";
47
47
  import { readlinkSync } from "node:fs";
48
48
  import { hostname, networkInterfaces } from "node:os";
49
49
  import { z } from "zod";
50
- import type { GcloudResult } from "./gcloud.js";
50
+ import { type GcloudResult, isGcloudNotFound } from "./gcloud.js";
51
51
 
52
52
  /** A Cloud Run job execution, fully addressed. */
53
53
  export interface CloudRunExecutionRef {
@@ -229,8 +229,6 @@ export type ExecutionState =
229
229
  /** Cloud Run could not be asked; `error` says why. */
230
230
  | { readonly kind: "unknown"; readonly error: string };
231
231
 
232
- const NOT_FOUND = /NOT_FOUND|not found|could not be found|does not exist/i;
233
-
234
232
  const executionStatusSchema = z.object({
235
233
  status: z
236
234
  .object({
@@ -257,7 +255,7 @@ const executionStatusSchema = z.object({
257
255
  */
258
256
  export function parseExecutionState(result: GcloudResult): ExecutionState {
259
257
  if (!result.ok) {
260
- if (NOT_FOUND.test(result.stderr)) return { kind: "not-found" };
258
+ if (isGcloudNotFound(result.stderr)) return { kind: "not-found" };
261
259
  return {
262
260
  kind: "unknown",
263
261
  error: result.stderr.trim() || `gcloud exited ${result.exitCode}`,