@microagi/alchemy-gcp 0.2.1 → 0.5.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 (107) hide show
  1. package/CHANGELOG.md +165 -0
  2. package/README.md +54 -2
  3. package/lib/ArtifactRegistry/Operations.d.ts +47 -0
  4. package/lib/ArtifactRegistry/Operations.d.ts.map +1 -0
  5. package/lib/ArtifactRegistry/Operations.js +47 -0
  6. package/lib/ArtifactRegistry/Operations.js.map +1 -0
  7. package/lib/ArtifactRegistry/Repository.d.ts +263 -0
  8. package/lib/ArtifactRegistry/Repository.d.ts.map +1 -0
  9. package/lib/ArtifactRegistry/Repository.js +257 -0
  10. package/lib/ArtifactRegistry/Repository.js.map +1 -0
  11. package/lib/ArtifactRegistry/Types.d.ts +32 -0
  12. package/lib/ArtifactRegistry/Types.d.ts.map +1 -0
  13. package/lib/ArtifactRegistry/Types.js +12 -0
  14. package/lib/ArtifactRegistry/Types.js.map +1 -0
  15. package/lib/ArtifactRegistry/Validation.d.ts +43 -0
  16. package/lib/ArtifactRegistry/Validation.d.ts.map +1 -0
  17. package/lib/ArtifactRegistry/Validation.js +95 -0
  18. package/lib/ArtifactRegistry/Validation.js.map +1 -0
  19. package/lib/ArtifactRegistry/index.d.ts +4 -0
  20. package/lib/ArtifactRegistry/index.d.ts.map +1 -0
  21. package/lib/ArtifactRegistry/index.js +2 -0
  22. package/lib/ArtifactRegistry/index.js.map +1 -0
  23. package/lib/Providers.d.ts.map +1 -1
  24. package/lib/Providers.js +13 -1
  25. package/lib/Providers.js.map +1 -1
  26. package/lib/Run/IamMember.d.ts +70 -0
  27. package/lib/Run/IamMember.d.ts.map +1 -0
  28. package/lib/Run/IamMember.js +65 -0
  29. package/lib/Run/IamMember.js.map +1 -0
  30. package/lib/Run/IamSync.d.ts +80 -0
  31. package/lib/Run/IamSync.d.ts.map +1 -0
  32. package/lib/Run/IamSync.js +73 -0
  33. package/lib/Run/IamSync.js.map +1 -0
  34. package/lib/Run/Job.d.ts +167 -0
  35. package/lib/Run/Job.d.ts.map +1 -0
  36. package/lib/Run/Job.js +199 -0
  37. package/lib/Run/Job.js.map +1 -0
  38. package/lib/Run/Operations.d.ts +47 -0
  39. package/lib/Run/Operations.d.ts.map +1 -0
  40. package/lib/Run/Operations.js +46 -0
  41. package/lib/Run/Operations.js.map +1 -0
  42. package/lib/Run/Service.d.ts +193 -0
  43. package/lib/Run/Service.d.ts.map +1 -0
  44. package/lib/Run/Service.js +247 -0
  45. package/lib/Run/Service.js.map +1 -0
  46. package/lib/Run/Validation.d.ts +54 -0
  47. package/lib/Run/Validation.d.ts.map +1 -0
  48. package/lib/Run/Validation.js +129 -0
  49. package/lib/Run/Validation.js.map +1 -0
  50. package/lib/Run/index.d.ts +51 -0
  51. package/lib/Run/index.d.ts.map +1 -0
  52. package/lib/Run/index.js +4 -0
  53. package/lib/Run/index.js.map +1 -0
  54. package/lib/Sqladmin/Database.d.ts +82 -0
  55. package/lib/Sqladmin/Database.d.ts.map +1 -0
  56. package/lib/Sqladmin/Database.js +87 -0
  57. package/lib/Sqladmin/Database.js.map +1 -0
  58. package/lib/Sqladmin/Instance.d.ts +234 -0
  59. package/lib/Sqladmin/Instance.d.ts.map +1 -0
  60. package/lib/Sqladmin/Instance.js +251 -0
  61. package/lib/Sqladmin/Instance.js.map +1 -0
  62. package/lib/Sqladmin/Operations.d.ts +41 -0
  63. package/lib/Sqladmin/Operations.d.ts.map +1 -0
  64. package/lib/Sqladmin/Operations.js +42 -0
  65. package/lib/Sqladmin/Operations.js.map +1 -0
  66. package/lib/Sqladmin/Types.d.ts +82 -0
  67. package/lib/Sqladmin/Types.d.ts.map +1 -0
  68. package/lib/Sqladmin/Types.js +28 -0
  69. package/lib/Sqladmin/Types.js.map +1 -0
  70. package/lib/Sqladmin/User.d.ts +110 -0
  71. package/lib/Sqladmin/User.d.ts.map +1 -0
  72. package/lib/Sqladmin/User.js +156 -0
  73. package/lib/Sqladmin/User.js.map +1 -0
  74. package/lib/Sqladmin/Validation.d.ts +60 -0
  75. package/lib/Sqladmin/Validation.d.ts.map +1 -0
  76. package/lib/Sqladmin/Validation.js +125 -0
  77. package/lib/Sqladmin/Validation.js.map +1 -0
  78. package/lib/Sqladmin/index.d.ts +9 -0
  79. package/lib/Sqladmin/index.d.ts.map +1 -0
  80. package/lib/Sqladmin/index.js +5 -0
  81. package/lib/Sqladmin/index.js.map +1 -0
  82. package/lib/index.d.ts +3 -0
  83. package/lib/index.d.ts.map +1 -1
  84. package/lib/index.js +3 -0
  85. package/lib/index.js.map +1 -1
  86. package/package.json +5 -4
  87. package/src/ArtifactRegistry/Operations.ts +79 -0
  88. package/src/ArtifactRegistry/Repository.ts +624 -0
  89. package/src/ArtifactRegistry/Types.ts +49 -0
  90. package/src/ArtifactRegistry/Validation.ts +112 -0
  91. package/src/ArtifactRegistry/index.ts +10 -0
  92. package/src/Providers.ts +21 -0
  93. package/src/Run/IamMember.ts +79 -0
  94. package/src/Run/IamSync.ts +134 -0
  95. package/src/Run/Job.ts +453 -0
  96. package/src/Run/Operations.ts +77 -0
  97. package/src/Run/Service.ts +541 -0
  98. package/src/Run/Validation.ts +153 -0
  99. package/src/Run/index.ts +52 -0
  100. package/src/Sqladmin/Database.ts +209 -0
  101. package/src/Sqladmin/Instance.ts +620 -0
  102. package/src/Sqladmin/Operations.ts +73 -0
  103. package/src/Sqladmin/Types.ts +101 -0
  104. package/src/Sqladmin/User.ts +333 -0
  105. package/src/Sqladmin/Validation.ts +148 -0
  106. package/src/Sqladmin/index.ts +19 -0
  107. package/src/index.ts +3 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Bind a single `(role, member)` IAM grant onto a Cloud Run
3
+ * {@link Service}.
4
+ *
5
+ * Target-side binding — see
6
+ * {@link import("../Compute/SubnetworkIamMember.ts").subnetworkIamMember}
7
+ * for the pattern, the SID-collision pitfall, and why `key` exists.
8
+ * Service's `reconcile` merges all bindings into a single
9
+ * `setIamPolicy` call against the service, preserving foreign roles
10
+ * and members on the policy. To remove a binding, drop the call and
11
+ * re-deploy — the provider is additive within the bindings we
12
+ * declared, but does NOT prune.
13
+ *
14
+ * The most common usage:
15
+ *
16
+ * - **Public invoker:** `{ role: "roles/run.invoker", member: "allUsers" }`
17
+ * makes the service publicly reachable. Prefer this over
18
+ * `invokerIamDisabled: true` on the {@link Service} props — declarative
19
+ * IAM is auditable in `setIamPolicy` history; `invokerIamDisabled`
20
+ * is a flag with no audit trail.
21
+ * - **Service-to-service:** a downstream service's runtime SA bound
22
+ * to `roles/run.invoker` on the upstream service.
23
+ *
24
+ * @example Public Cloud Run service
25
+ * ```typescript
26
+ * const api = yield* GCP.Service("PublicApi", { ... });
27
+ * yield* GCP.serviceIamMember(api, "PublicInvoker", {
28
+ * role: "roles/run.invoker",
29
+ * member: "allUsers",
30
+ * });
31
+ * ```
32
+ *
33
+ * @example Service-to-service auth
34
+ * ```typescript
35
+ * const upstream = yield* GCP.Service("Upstream", { ... });
36
+ * yield* GCP.serviceIamMember(upstream, "DownstreamCaller", {
37
+ * role: "roles/run.invoker",
38
+ * member: `serviceAccount:${downstreamSa.email}`,
39
+ * });
40
+ * ```
41
+ */
42
+ export const serviceIamMember = (service, key, args) => service.bind `IamMember(${service}, ${key})`({
43
+ iamBindings: [{ role: args.role, members: [args.member] }],
44
+ });
45
+ /**
46
+ * Bind a single `(role, member)` IAM grant onto a Cloud Run {@link Job}.
47
+ *
48
+ * Same target-side pattern as {@link serviceIamMember}. The most
49
+ * common Job binding is `roles/run.invoker` on the service account
50
+ * that triggers the job (Cloud Scheduler, Eventarc, Workflows, or a
51
+ * developer's user identity).
52
+ *
53
+ * @example Letting a Cloud Scheduler SA trigger the job
54
+ * ```typescript
55
+ * const nightly = yield* GCP.Job("Nightly", { ... });
56
+ * yield* GCP.jobIamMember(nightly, "SchedulerInvoker", {
57
+ * role: "roles/run.invoker",
58
+ * member: `serviceAccount:${schedulerSa.email}`,
59
+ * });
60
+ * ```
61
+ */
62
+ export const jobIamMember = (job, key, args) => job.bind `IamMember(${job}, ${key})`({
63
+ iamBindings: [{ role: args.role, members: [args.member] }],
64
+ });
65
+ //# sourceMappingURL=IamMember.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IamMember.js","sourceRoot":"","sources":["../../src/Run/IamMember.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAgB,EAChB,GAAW,EACX,IAAsC,EACjB,EAAE,CACvB,OAAO,CAAC,IAAI,CAAA,aAAa,OAAO,KAAK,GAAG,GAAG,CAAC;IAC1C,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;CAC3D,CAAmC,CAAC;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAQ,EACR,GAAW,EACX,IAAsC,EACjB,EAAE,CACvB,GAAG,CAAC,IAAI,CAAA,aAAa,GAAG,KAAK,GAAG,GAAG,CAAC;IAClC,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;CAC3D,CAAmC,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type * as run from "@distilled.cloud/gcp/run-v2";
2
+ import type { ResourceBinding } from "alchemy/Resource";
3
+ import * as Effect from "effect/Effect";
4
+ /**
5
+ * Common shape of Cloud Run's `getIamPolicy` / `setIamPolicy` request
6
+ * inputs — Service and Job declare nominally distinct request types,
7
+ * but both reduce to `{ resource, body? }` plus the version query for
8
+ * get. We model the operation surface generically so {@link makeSyncIam}
9
+ * can serve both targets without duplication.
10
+ *
11
+ * @internal
12
+ */
13
+ type GetIamPolicyOp = (input: {
14
+ resource: string;
15
+ "options.requestedPolicyVersion"?: number;
16
+ }) => Effect.Effect<run.GoogleIamV1Policy, unknown, never>;
17
+ type SetIamPolicyOp = (input: {
18
+ resource: string;
19
+ body?: run.GoogleIamV1SetIamPolicyRequest;
20
+ }) => Effect.Effect<run.GoogleIamV1Policy, unknown, never>;
21
+ /**
22
+ * Single `(role, members)` entry on a Cloud Run target's IAM policy.
23
+ * Identical shape between Service and Job — both Cloud Run resources
24
+ * speak the same `iam.v1.Policy`, so the binding contract is shared.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * yield* GCP.serviceIamMember(svc, "PublicInvoker", {
29
+ * role: "roles/run.invoker",
30
+ * member: "allUsers",
31
+ * });
32
+ * ```
33
+ */
34
+ export type RunIamBinding = {
35
+ /** IAM role, e.g. `"roles/run.invoker"`. */
36
+ role: string;
37
+ /** Principals, e.g. `["allUsers"]` or `["serviceAccount:foo@bar.iam.gserviceaccount.com"]`. */
38
+ members: ReadonlyArray<string>;
39
+ };
40
+ /**
41
+ * Binding contract for a Cloud Run target — services and jobs both
42
+ * accept a list of `iamBindings` records via the alchemy `.bind`
43
+ * mechanism. The reconciler reads `bindings` from its arguments and
44
+ * routes them through {@link makeSyncIam}.
45
+ */
46
+ export type RunIamBindingContract = {
47
+ iamBindings: ReadonlyArray<RunIamBinding>;
48
+ };
49
+ /**
50
+ * Build a reusable `syncIam` step parametrised by the resolved
51
+ * `getIamPolicy` / `setIamPolicy` callables. Cloud Run's Service and
52
+ * Job IAM endpoints have identical request/response shapes (both
53
+ * `resource: "projects/{p}/locations/{l}/{kind}/{n}"`), so the same
54
+ * helper works for both — the caller just hands in the right pair of
55
+ * callables.
56
+ *
57
+ * Semantics, mirroring `Compute/Subnetwork.ts`:
58
+ *
59
+ * - **Union bindings per role across all `.bind` callers.** Multiple
60
+ * capabilities granting the same role get their members merged into
61
+ * a single binding.
62
+ * - **Preserve foreign roles and members verbatim.** We never displace
63
+ * bindings we didn't author. The provider is additive — to remove a
64
+ * binding, drop the `.bind` call and re-deploy (a future revision
65
+ * could narrow this; for now it matches the existing idiom).
66
+ * - **Etag round-trip.** `getIamPolicy` returns an etag; we pass it
67
+ * through `setIamPolicy` so a concurrent edit racing us surfaces as
68
+ * `Conflict`. We retry exponentially up to ~1.5 min — enough to
69
+ * absorb normal CI/human contention without masking real failures.
70
+ */
71
+ export declare const makeSyncIam: (api: {
72
+ getIamPolicy: GetIamPolicyOp;
73
+ setIamPolicy: SetIamPolicyOp;
74
+ }) => (args: {
75
+ /** Fully-qualified resource name: `projects/{p}/locations/{l}/{kind}/{n}`. */
76
+ resource: string;
77
+ bindings: ReadonlyArray<ResourceBinding<RunIamBindingContract>>;
78
+ }) => Effect.Effect<void, unknown, never>;
79
+ export {};
80
+ //# sourceMappingURL=IamSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IamSync.d.ts","sourceRoot":"","sources":["../../src/Run/IamSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,6BAA6B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC;;;;;;;;GAQG;AACH,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC,CAAC,EAAE,MAAM,CAAC;CAC3C,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE3D,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC,8BAA8B,CAAC;CAC3C,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GACrB,KAAK;IAAE,YAAY,EAAE,cAAc,CAAC;IAAC,YAAY,EAAE,cAAc,CAAA;CAAE,MACnE,MAAM;IACL,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACjE,wCAkDE,CAAC"}
@@ -0,0 +1,73 @@
1
+ import * as Duration from "effect/Duration";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Schedule from "effect/Schedule";
4
+ /**
5
+ * Build a reusable `syncIam` step parametrised by the resolved
6
+ * `getIamPolicy` / `setIamPolicy` callables. Cloud Run's Service and
7
+ * Job IAM endpoints have identical request/response shapes (both
8
+ * `resource: "projects/{p}/locations/{l}/{kind}/{n}"`), so the same
9
+ * helper works for both — the caller just hands in the right pair of
10
+ * callables.
11
+ *
12
+ * Semantics, mirroring `Compute/Subnetwork.ts`:
13
+ *
14
+ * - **Union bindings per role across all `.bind` callers.** Multiple
15
+ * capabilities granting the same role get their members merged into
16
+ * a single binding.
17
+ * - **Preserve foreign roles and members verbatim.** We never displace
18
+ * bindings we didn't author. The provider is additive — to remove a
19
+ * binding, drop the `.bind` call and re-deploy (a future revision
20
+ * could narrow this; for now it matches the existing idiom).
21
+ * - **Etag round-trip.** `getIamPolicy` returns an etag; we pass it
22
+ * through `setIamPolicy` so a concurrent edit racing us surfaces as
23
+ * `Conflict`. We retry exponentially up to ~1.5 min — enough to
24
+ * absorb normal CI/human contention without masking real failures.
25
+ */
26
+ export const makeSyncIam = (api) => (args) => Effect.gen(function* () {
27
+ const desiredByRole = new Map();
28
+ for (const b of args.bindings) {
29
+ for (const ib of b.data.iamBindings) {
30
+ const set = desiredByRole.get(ib.role) ?? new Set();
31
+ for (const m of ib.members)
32
+ set.add(m);
33
+ desiredByRole.set(ib.role, set);
34
+ }
35
+ }
36
+ if (desiredByRole.size === 0)
37
+ return;
38
+ const current = yield* api.getIamPolicy({
39
+ resource: args.resource,
40
+ "options.requestedPolicyVersion": 3,
41
+ });
42
+ const bindings = (current.bindings ?? []).map((b) => ({
43
+ ...b,
44
+ members: [...(b.members ?? [])],
45
+ }));
46
+ let mutated = false;
47
+ for (const [role, members] of desiredByRole) {
48
+ let existing = bindings.find((b) => b.role === role && !b.condition);
49
+ if (!existing) {
50
+ existing = { role, members: [] };
51
+ bindings.push(existing);
52
+ }
53
+ const merged = new Set([...(existing.members ?? []), ...members]);
54
+ if (merged.size !== (existing.members?.length ?? 0))
55
+ mutated = true;
56
+ existing.members = [...merged];
57
+ }
58
+ if (!mutated)
59
+ return;
60
+ yield* api.setIamPolicy({
61
+ resource: args.resource,
62
+ body: {
63
+ policy: {
64
+ ...current,
65
+ bindings,
66
+ version: 3,
67
+ },
68
+ },
69
+ });
70
+ }).pipe(Effect.retry({
71
+ schedule: Schedule.exponential(Duration.seconds(2)).pipe(Schedule.both(Schedule.recurs(8))),
72
+ }));
73
+ //# sourceMappingURL=IamSync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IamSync.js","sourceRoot":"","sources":["../../src/Run/IamSync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAmD5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,CAAC,GAAmE,EAAE,EAAE,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AC,CAAC,SAAS,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;QAClE,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC;YAAE,OAAO,GAAG,IAAI,CAAC;QACpE,QAAQ,CAAC,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,KAAK,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC;QACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,GAAG,OAAO;gBACV,QAAQ;gBACR,OAAO,EAAE,CAAC;aACX;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,KAAK,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CACtD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAClC;CACF,CAAC,CACH,CAAC"}
@@ -0,0 +1,167 @@
1
+ import * as run from "@distilled.cloud/gcp/run-v2";
2
+ import { Resource } from "alchemy";
3
+ import * as Provider from "alchemy/Provider";
4
+ import type * as GCP from "../Providers.ts";
5
+ import { type RunIamBindingContract } from "./IamSync.ts";
6
+ /**
7
+ * A Cloud Run v2 Job — a managed batch workload. A Job holds an
8
+ * `ExecutionTemplate` (parallelism + a `TaskTemplate` containing
9
+ * containers); invoking the Job via `runProjectsLocationsJobs` creates
10
+ * an immutable Execution that runs the configured number of tasks to
11
+ * completion.
12
+ *
13
+ * **Declarative vs imperative.** This resource models the Job
14
+ * *definition* — its template, parallelism, task count, IAM. The act
15
+ * of *running* the Job is event-shaped (does not fit the
16
+ * converge-to-desired-state model) and is left to user-side code:
17
+ *
18
+ * ```typescript
19
+ * import * as run from "@distilled.cloud/gcp/run-v2";
20
+ * const job = yield* GCP.Job("Nightly", { ... });
21
+ * const runJob = yield* run.runProjectsLocationsJobs;
22
+ * yield* runJob({
23
+ * name: `projects/${job.project}/locations/${job.location}/jobs/${job.name}`,
24
+ * });
25
+ * // returns an LRO; poll if you want to wait for completion
26
+ * ```
27
+ *
28
+ * **Lifecycle.** observe → ensure (create, retrying the API-enable
29
+ * race) → sync (patch full body if anything changed; Job's patch has
30
+ * no `updateMask` — server diffs the body itself) → sync IAM bindings
31
+ * → return.
32
+ *
33
+ * **Replace triggers.** Only identity fields (project, location, name)
34
+ * force replacement. Everything else is in-place via `patch`. New
35
+ * Executions are created independently by `runProjectsLocationsJobs`.
36
+ *
37
+ * **Optimistic concurrency.** Delete passes through the observed
38
+ * `etag`; patch passes etag in the body so concurrent edits surface
39
+ * as `Conflict` instead of silently overwriting.
40
+ *
41
+ * **Adoption.** Label-gated, same as {@link import("./Service.ts").Service}.
42
+ *
43
+ * **IAM.** Use {@link import("./IamMember.ts").jobIamMember} to bind
44
+ * `(role, member)` grants — typically `roles/run.invoker` on the
45
+ * service account that triggers the job.
46
+ *
47
+ * @section Creating a Cloud Run Job
48
+ * @example Single-shot batch job
49
+ * ```typescript
50
+ * const job = yield* GCP.Job("ProcessBatch", {
51
+ * project: project.projectId,
52
+ * location: "europe-west4",
53
+ * template: {
54
+ * taskCount: 1,
55
+ * template: {
56
+ * maxRetries: 3,
57
+ * containers: [{
58
+ * image: "europe-west4-docker.pkg.dev/proj/repo/worker:latest",
59
+ * }],
60
+ * },
61
+ * },
62
+ * });
63
+ * ```
64
+ *
65
+ * @example Parallel job with custom service account and GPU
66
+ * ```typescript
67
+ * const train = yield* GCP.Job("Train", {
68
+ * project: project.projectId,
69
+ * location: "europe-west4",
70
+ * launchStage: "BETA",
71
+ * template: {
72
+ * taskCount: 8,
73
+ * parallelism: 8,
74
+ * template: {
75
+ * serviceAccount: sa.email,
76
+ * maxRetries: 0,
77
+ * timeout: "21600s",
78
+ * containers: [{
79
+ * image: "europe-west4-docker.pkg.dev/proj/repo/train:v2",
80
+ * resources: { limits: { cpu: "4", memory: "16Gi", "nvidia.com/gpu": "1" } },
81
+ * }],
82
+ * nodeSelector: { accelerator: "nvidia-l4" },
83
+ * },
84
+ * },
85
+ * });
86
+ * ```
87
+ */
88
+ export type JobProps = {
89
+ /** GCP project ID hosting the Job. Immutable — replace if changed. */
90
+ project: string;
91
+ /** Cloud Run region. Immutable — replace if changed. */
92
+ location: string;
93
+ /**
94
+ * Job name. Defaults to `createPhysicalName({ id, lowercase: true,
95
+ * maxLength: 49 })`. Lowercase letters/digits/hyphens; must begin
96
+ * with a letter and not end with a hyphen; **fewer than 50 characters**.
97
+ * Immutable — replace if changed.
98
+ */
99
+ name?: string;
100
+ /** User-visible description. Mutable via `patch`. */
101
+ description?: string;
102
+ /**
103
+ * Resource labels. Alchemy internal labels are merged on top
104
+ * automatically. Cloud Run rejects reserved namespaces (same as
105
+ * Service). Mutable via `patch`.
106
+ */
107
+ labels?: Record<string, string>;
108
+ /** Free-form annotations. Mutable via `patch`. */
109
+ annotations?: Record<string, string>;
110
+ /**
111
+ * Launch stage — `BETA` (or higher) required for preview features
112
+ * (GPU node selectors, Direct VPC). Mutable via `patch`.
113
+ */
114
+ launchStage?: "ALPHA" | "BETA" | "GA" | "EARLY_ACCESS" | "PRELAUNCH" | "DEPRECATED";
115
+ /** Binary Authorization policy. Mutable via `patch`. */
116
+ binaryAuthorization?: run.GoogleCloudRunV2BinaryAuthorization;
117
+ /**
118
+ * Token-suffix used to compose Execution names when the Job is
119
+ * started via the GCP UI or `gcloud run jobs execute`. Required to
120
+ * keep distinct from Job name + 63 chars. Mutable.
121
+ */
122
+ startExecutionToken?: string;
123
+ /** Same as `startExecutionToken` but used on run completion. Mutable. */
124
+ runExecutionToken?: string;
125
+ /**
126
+ * The Execution template — describes parallelism, task count, and
127
+ * the inner `TaskTemplate` (containers, volumes, retry policy).
128
+ * **Required at create.** Mutable via `patch`.
129
+ */
130
+ template: run.GoogleCloudRunV2ExecutionTemplate;
131
+ };
132
+ export type JobAttributes = {
133
+ /** Job name (bare). */
134
+ name: string;
135
+ /** Server-assigned UID. */
136
+ uid: string;
137
+ /** Fully-qualified resource name. */
138
+ resourceName: string;
139
+ /** GCP project ID. */
140
+ project: string;
141
+ /** Region. */
142
+ location: string;
143
+ /** Monotonically increasing generation, bumped on every patch. */
144
+ generation: string | undefined;
145
+ /** Generation reflected in the latest reconciled state. */
146
+ observedGeneration: string | undefined;
147
+ /** Overall readiness condition. */
148
+ terminalCondition: run.GoogleCloudRunV2Condition | undefined;
149
+ /** Number of Executions created for this Job. */
150
+ executionCount: number | undefined;
151
+ /** Reference to the most recently created Execution, if any. */
152
+ latestCreatedExecution: run.GoogleCloudRunV2ExecutionReference | undefined;
153
+ /** True while Cloud Run is reconciling toward the desired state. */
154
+ reconciling: boolean | undefined;
155
+ /** Optimistic-concurrency etag. */
156
+ etag: string | undefined;
157
+ /** Labels currently set, including internals. */
158
+ labels: Record<string, string>;
159
+ /** Creation time. */
160
+ createTime: string | undefined;
161
+ /** Last-modified time. */
162
+ updateTime: string | undefined;
163
+ };
164
+ export type Job = Resource<"GCP.Job", JobProps, JobAttributes, RunIamBindingContract, GCP.Providers>;
165
+ export declare const Job: import("alchemy").ResourceClass<Job>;
166
+ export declare const JobProvider: () => import("effect/Layer").Layer<Provider.Provider<Job>, never, import("effect/unstable/http/HttpClient").HttpClient | import("alchemy").Stage | import("alchemy").Stack | import("@distilled.cloud/gcp").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AM,MAAM,aAAa,GAAG;IAC1B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,2DAA2D;IAC3D,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,mCAAmC;IACnC,iBAAiB,EAAE,GAAG,CAAC,yBAAyB,GAAG,SAAS,CAAC;IAC7D,iDAAiD;IACjD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,gEAAgE;IAChE,sBAAsB,EAAE,GAAG,CAAC,kCAAkC,GAAG,SAAS,CAAC;IAC3E,oEAAoE;IACpE,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,mCAAmC;IACnC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,qBAAqB;IACrB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,0BAA0B;IAC1B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG,QAAQ,CACxB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,qBAAqB,EACrB,GAAG,CAAC,SAAS,CACd,CAAC;AACF,eAAO,MAAM,GAAG,sCAA2B,CAAC;AAgG5C,eAAO,MAAM,WAAW,0NAgKrB,CAAC"}
package/lib/Run/Job.js ADDED
@@ -0,0 +1,199 @@
1
+ import * as run from "@distilled.cloud/gcp/run-v2";
2
+ import { Resource } from "alchemy";
3
+ import { Unowned } from "alchemy/AdoptPolicy";
4
+ import { deepEqual, isResolved, somePropsAreDifferent } from "alchemy/Diff";
5
+ import { createPhysicalName } from "alchemy/PhysicalName";
6
+ import * as Provider from "alchemy/Provider";
7
+ import { diffTags } from "alchemy/Tags";
8
+ import * as Duration from "effect/Duration";
9
+ import * as Effect from "effect/Effect";
10
+ import * as Schedule from "effect/Schedule";
11
+ import { gcpInternalLabels, hasAlchemyLabels } from "../Tags.js";
12
+ import { makeSyncIam } from "./IamSync.js";
13
+ import { makeAwaitOperation } from "./Operations.js";
14
+ import { reshapeBadRequest, validateAnnotations, validateContainers, validateLabels, validateRunName, } from "./Validation.js";
15
+ export const Job = Resource("GCP.Job");
16
+ const fqName = (project, location, name) => `projects/${project}/locations/${location}/jobs/${name}`;
17
+ const toJobBody = (news, desiredLabels) => ({
18
+ labels: desiredLabels,
19
+ ...(news.annotations ? { annotations: news.annotations } : {}),
20
+ ...(news.launchStage ? { launchStage: news.launchStage } : {}),
21
+ ...(news.binaryAuthorization
22
+ ? { binaryAuthorization: news.binaryAuthorization }
23
+ : {}),
24
+ ...(news.startExecutionToken
25
+ ? { startExecutionToken: news.startExecutionToken }
26
+ : {}),
27
+ ...(news.runExecutionToken
28
+ ? { runExecutionToken: news.runExecutionToken }
29
+ : {}),
30
+ template: news.template,
31
+ });
32
+ const toAttributes = (j, parent) => ({
33
+ name: parent.name,
34
+ uid: j.uid ?? "",
35
+ resourceName: j.name ?? fqName(parent.project, parent.location, parent.name),
36
+ project: parent.project,
37
+ location: parent.location,
38
+ generation: j.generation,
39
+ observedGeneration: j.observedGeneration,
40
+ terminalCondition: j.terminalCondition,
41
+ executionCount: j.executionCount,
42
+ latestCreatedExecution: j.latestCreatedExecution,
43
+ reconciling: j.reconciling,
44
+ etag: j.etag,
45
+ labels: { ...(j.labels ?? {}) },
46
+ createTime: j.createTime,
47
+ updateTime: j.updateTime,
48
+ });
49
+ /**
50
+ * Decide whether anything mutable on the Job changed since the last
51
+ * reconcile. Job's `patch` has no `updateMask` parameter — the server
52
+ * diffs the full body — so we just emit a single "changed / unchanged"
53
+ * verdict and re-send the whole body if it differs.
54
+ *
55
+ * Labels go through `diffTags` (consistent with every other GCP
56
+ * resource here); everything else is a `deepEqual` on the relevant
57
+ * field. The `template` deep-equal is the load-bearing check —
58
+ * Cloud Run injects server-side defaults into `template.template`
59
+ * (e.g. `maxRetries: 3` when omitted), so the observed template may
60
+ * have keys we never sent. Deep-equal on the OBSERVED side ⊆ NEWS
61
+ * side is too strict; we rely on the user re-sending equivalent
62
+ * inputs across reconciles so observed==news after the first patch.
63
+ */
64
+ const jobMutated = (observed, news, desiredLabels) => {
65
+ const labelDiff = diffTags({ ...(observed.labels ?? {}) }, desiredLabels);
66
+ if (labelDiff.removed.length > 0 || labelDiff.upsert.length > 0)
67
+ return true;
68
+ if (!deepEqual(observed.annotations ?? {}, news.annotations ?? {}))
69
+ return true;
70
+ if (news.launchStage !== undefined && observed.launchStage !== news.launchStage) {
71
+ return true;
72
+ }
73
+ if (news.binaryAuthorization &&
74
+ !deepEqual(observed.binaryAuthorization, news.binaryAuthorization)) {
75
+ return true;
76
+ }
77
+ if (news.startExecutionToken !== undefined &&
78
+ observed.startExecutionToken !== news.startExecutionToken) {
79
+ return true;
80
+ }
81
+ if (news.runExecutionToken !== undefined &&
82
+ observed.runExecutionToken !== news.runExecutionToken) {
83
+ return true;
84
+ }
85
+ if (!deepEqual(observed.template, news.template))
86
+ return true;
87
+ return false;
88
+ };
89
+ export const JobProvider = () => Provider.effect(Job, Effect.gen(function* () {
90
+ const getJob = yield* run.getProjectsLocationsJobs;
91
+ const createJob = yield* run.createProjectsLocationsJobs;
92
+ const patchJob = yield* run.patchProjectsLocationsJobs;
93
+ const deleteJob = yield* run.deleteProjectsLocationsJobs;
94
+ const getOperation = yield* run.getProjectsLocationsOperations;
95
+ const getIamPolicy = yield* run.getIamPolicyProjectsLocationsJobs;
96
+ const setIamPolicy = yield* run.setIamPolicyProjectsLocationsJobs;
97
+ const awaitOperation = makeAwaitOperation(getOperation);
98
+ const syncIam = makeSyncIam({ getIamPolicy, setIamPolicy });
99
+ const observe = (project, location, name) => getJob({ name: fqName(project, location, name) }).pipe(Effect.catchTag("NotFound", () => Effect.succeed(undefined)), Effect.catchTag("Forbidden", () => Effect.succeed(undefined)));
100
+ const syncMutable = Effect.fn(function* (args) {
101
+ if (!jobMutated(args.observed, args.news, args.desiredLabels))
102
+ return;
103
+ const bodyWithEtag = {
104
+ ...toJobBody(args.news, args.desiredLabels),
105
+ ...(args.observed.etag ? { etag: args.observed.etag } : {}),
106
+ };
107
+ const op = yield* patchJob({
108
+ name: args.name,
109
+ body: bodyWithEtag,
110
+ }).pipe(Effect.catchTag("BadRequest", reshapeBadRequest("Job", "patch")));
111
+ if (op.name)
112
+ yield* awaitOperation(op.name, args.session);
113
+ });
114
+ return {
115
+ stables: ["name", "uid", "resourceName", "project", "location"],
116
+ diff: Effect.fn(function* ({ news, olds = {} }) {
117
+ if (!isResolved(news))
118
+ return undefined;
119
+ if (somePropsAreDifferent(olds, news, [
120
+ "project",
121
+ "location",
122
+ "name",
123
+ ])) {
124
+ return { action: "replace" };
125
+ }
126
+ return undefined;
127
+ }),
128
+ reconcile: Effect.fn(function* ({ id, news, session, bindings }) {
129
+ const internalLabels = yield* gcpInternalLabels(id);
130
+ const desiredName = news.name ??
131
+ (yield* createPhysicalName({ id, maxLength: 49 })).toLowerCase();
132
+ yield* validateRunName("Job", desiredName);
133
+ yield* validateLabels(news.labels);
134
+ yield* validateAnnotations(news.annotations);
135
+ // Job container constraint lives one level deeper (inside the
136
+ // ExecutionTemplate's TaskTemplate).
137
+ yield* validateContainers("Job", news.template.template?.containers);
138
+ const parent = `projects/${news.project}/locations/${news.location}`;
139
+ const name = fqName(news.project, news.location, desiredName);
140
+ const desiredLabels = {
141
+ ...(news.labels ?? {}),
142
+ ...internalLabels,
143
+ };
144
+ let observed = yield* observe(news.project, news.location, desiredName);
145
+ if (!observed) {
146
+ const op = yield* createJob({
147
+ parent,
148
+ jobId: desiredName,
149
+ body: toJobBody(news, desiredLabels),
150
+ }).pipe(Effect.retry({
151
+ while: (e) => e?._tag === "Forbidden" &&
152
+ /enabled this API recently|has not been used/i.test(e.message ?? ""),
153
+ schedule: Schedule.spaced(Duration.seconds(15)).pipe(Schedule.both(Schedule.recurs(20)), Schedule.tapOutput(() => session.note("Waiting for Cloud Run API enablement to propagate…"))),
154
+ }), Effect.catchTag("Conflict", () => Effect.succeed(undefined)), Effect.catchTag("BadRequest", reshapeBadRequest("Job", "create")));
155
+ if (op?.name)
156
+ yield* awaitOperation(op.name, session);
157
+ observed = yield* getJob({ name });
158
+ }
159
+ yield* syncMutable({
160
+ name,
161
+ observed,
162
+ news,
163
+ desiredLabels,
164
+ session,
165
+ });
166
+ yield* syncIam({ resource: name, bindings });
167
+ const final = yield* getJob({ name });
168
+ return toAttributes(final, {
169
+ project: news.project,
170
+ location: news.location,
171
+ name: desiredName,
172
+ });
173
+ }),
174
+ delete: Effect.fn(function* ({ output, session }) {
175
+ const name = fqName(output.project, output.location, output.name);
176
+ yield* deleteJob({
177
+ name,
178
+ ...(output.etag ? { etag: output.etag } : {}),
179
+ }).pipe(Effect.flatMap((op) => op.name ? awaitOperation(op.name, session) : Effect.succeed(op)), Effect.catchTag("NotFound", () => Effect.void));
180
+ }),
181
+ read: Effect.fn(function* ({ id, output, olds }) {
182
+ const project = output?.project ?? olds?.project;
183
+ const location = output?.location ?? olds?.location;
184
+ if (!project || !location)
185
+ return undefined;
186
+ const name = output?.name ??
187
+ olds?.name ??
188
+ (yield* createPhysicalName({ id, maxLength: 49 })).toLowerCase();
189
+ const observed = yield* observe(project, location, name);
190
+ if (!observed)
191
+ return undefined;
192
+ const attrs = toAttributes(observed, { project, location, name });
193
+ return (yield* hasAlchemyLabels(id, observed.labels))
194
+ ? attrs
195
+ : Unowned(attrs);
196
+ }),
197
+ };
198
+ }));
199
+ //# sourceMappingURL=Job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Job.js","sourceRoot":"","sources":["../../src/Run/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