@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,129 @@
1
+ import { ConfigError } from "@distilled.cloud/gcp";
2
+ import * as Effect from "effect/Effect";
3
+ /**
4
+ * Plan-time validation for Cloud Run resource props. Failing fast with
5
+ * a typed `ConfigError` is much friendlier than letting the user wait
6
+ * 30 s for the server to reject the request — and unlike server-side
7
+ * errors, these surface before any state mutation happens.
8
+ *
9
+ * Used by both `Service` and `Job` since the constraints are shared:
10
+ * resource naming, label namespacing, and the "at least one container"
11
+ * rule on the template.
12
+ */
13
+ /**
14
+ * Cloud Run resource names must match the
15
+ * [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123) label
16
+ * subset:
17
+ * - lowercase letters, digits, and hyphens
18
+ * - begin with a letter, not end with a hyphen
19
+ * - <50 chars (server hard cap, distinct from the wider 63-char label
20
+ * limit other GCP resources use)
21
+ *
22
+ * @internal
23
+ */
24
+ const RUN_NAME_RE = /^[a-z]([-a-z0-9]{0,47}[a-z0-9])?$/;
25
+ /**
26
+ * Cloud Run rejects labels and annotations with keys in any of these
27
+ * namespaces. Listed in `vendor/distilled/packages/gcp/src/services/run-v2.ts`
28
+ * doc comments next to every `labels` / `annotations` field. Failing
29
+ * fast here saves a 400 round-trip from the server.
30
+ */
31
+ const RESERVED_LABEL_NAMESPACES = [
32
+ "run.googleapis.com/",
33
+ "cloud.googleapis.com/",
34
+ "serving.knative.dev/",
35
+ "autoscaling.knative.dev/",
36
+ ];
37
+ const reservedNamespaceFor = (key) => RESERVED_LABEL_NAMESPACES.find((ns) => key.startsWith(ns));
38
+ /**
39
+ * Validate a Cloud Run resource name (Service or Job). Returns a
40
+ * `ConfigError` Effect on the failure channel if the name is invalid,
41
+ * otherwise succeeds.
42
+ *
43
+ * The name comes from `props.name` (when the user supplied one) or
44
+ * `createPhysicalName({ id, maxLength: 49 })` (when defaulted). The
45
+ * defaulted path is already capped at 49; this guard mostly protects
46
+ * the user-supplied path against a server-side reject after a long
47
+ * deploy.
48
+ */
49
+ export const validateRunName = (kind, name) => {
50
+ if (RUN_NAME_RE.test(name) && name.length < 50)
51
+ return Effect.void;
52
+ return Effect.fail(new ConfigError({
53
+ message: `Cloud Run ${kind} name ${JSON.stringify(name)} is invalid: must match /^[a-z]([-a-z0-9]{0,47}[a-z0-9])?$/ (lowercase letters/digits/hyphens, starts with letter, no trailing hyphen, <50 chars).`,
54
+ }));
55
+ };
56
+ /**
57
+ * Reject user labels in any of the Cloud Run reserved namespaces — the
58
+ * server's 400 message ("Labels with run.googleapis.com namespace are
59
+ * not allowed") is clear enough, but failing at plan time means the
60
+ * stack never starts a deploy that's guaranteed to fail.
61
+ *
62
+ * Alchemy internals are merged *on top* of user labels and are NOT
63
+ * subject to this check — they use the un-namespaced `alchemy_*` keys.
64
+ */
65
+ export const validateLabels = (labels) => {
66
+ if (!labels)
67
+ return Effect.void;
68
+ for (const key of Object.keys(labels)) {
69
+ const ns = reservedNamespaceFor(key);
70
+ if (ns) {
71
+ return Effect.fail(new ConfigError({
72
+ message: `Label key ${JSON.stringify(key)} uses reserved namespace ${JSON.stringify(ns)} — Cloud Run will reject this on create/patch. Strip the prefix or pick a different key.`,
73
+ }));
74
+ }
75
+ }
76
+ return Effect.void;
77
+ };
78
+ /** Same check, applied to annotations (server has the same reservation). */
79
+ export const validateAnnotations = (annotations) => validateLabels(annotations);
80
+ /**
81
+ * Cloud Run requires every Service template and Job task template to
82
+ * declare at least one container. A `containers: []` body sails through
83
+ * client-side type checks but the server rejects with a generic 400.
84
+ */
85
+ export const validateContainers = (kind, containers) => {
86
+ if (containers && containers.length > 0)
87
+ return Effect.void;
88
+ return Effect.fail(new ConfigError({
89
+ message: `Cloud Run ${kind} template must declare at least one container. Did you forget \`template.containers: [{ image: "…" }]\`?`,
90
+ }));
91
+ };
92
+ /**
93
+ * Reshape a `BadRequest` from a Cloud Run create or patch into a
94
+ * `ConfigError` with a remediation hint for the top failure modes:
95
+ *
96
+ * 1. **Billing not enabled** — the project's billing-account attach
97
+ * was missing or detached. Common after a fresh project + ApiEnable
98
+ * before billing reconciles.
99
+ * 2. **Image not in an approved registry** — Cloud Run defaults reject
100
+ * Docker Hub and most non-Google registries when Binary Authorization
101
+ * is on. Surface the registry-allow-list pointer.
102
+ * 3. **Reserved label/annotation namespace** — we catch user-supplied
103
+ * cases in `validateLabels`, but server-side checks also fire for
104
+ * fields nested inside `template` (we don't recurse) so leave this
105
+ * as a passthrough hint.
106
+ *
107
+ * Anything else propagates verbatim — the underlying GCP message is
108
+ * usually clear ("invalid image reference", "memory limit too low").
109
+ */
110
+ export const reshapeBadRequest = (kind, op) => (e) => {
111
+ const underlying = e.message ?? `unknown 400 from ${kind} ${op}`;
112
+ let hint = "";
113
+ if (/billing/i.test(underlying)) {
114
+ hint =
115
+ " Cloud Run requires billing to be enabled on the project. Attach a billing account (see `GCP.Project({ billingAccount })`) and retry.";
116
+ }
117
+ else if (/registry|image.*not.*allowed|disallowed.*image/i.test(underlying)) {
118
+ hint =
119
+ " Cloud Run rejects images from non-Google registries when Binary Authorization is on. Push to Artifact Registry (`*-docker.pkg.dev`) or relax the binary-auth policy.";
120
+ }
121
+ else if (/run\.googleapis\.com|knative\.dev|cloud\.googleapis\.com/i.test(underlying)) {
122
+ hint =
123
+ " A reserved label/annotation namespace is in use. Cloud Run forbids `run.googleapis.com/*`, `cloud.googleapis.com/*`, `serving.knative.dev/*`, and `autoscaling.knative.dev/*` on user fields.";
124
+ }
125
+ return Effect.fail(new ConfigError({
126
+ message: `Cloud Run ${kind} ${op} rejected: ${underlying}.${hint}`,
127
+ }));
128
+ };
129
+ //# sourceMappingURL=Validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validation.js","sourceRoot":"","sources":["../../src/Run/Validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;;;;;;;GASG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,WAAW,GAAG,mCAAmC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG;IAChC,qBAAqB;IACrB,uBAAuB;IACvB,sBAAsB;IACtB,0BAA0B;CAC3B,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAsB,EAAE,CAC/D,yBAAyB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAA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I,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IAC5D,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,WAAW,CAAC;QACd,OAAO,EAAE,aAAa,IAAI,0GAA0G;KACrI,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,CAAC,IAAuB,EAAE,EAAsB,EAAE,EAAE,CACpD,CAAC,CAAuB,EAAqC,EAAE;IAC7D,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,IAAI,oBAAoB,IAAI,IAAI,EAAE,EAAE,CAAC;IACjE,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,IAAI;YACF,uIAAuI,CAAC;IAC5I,CAAC;SAAM,IAAI,iDAAiD,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9E,IAAI;YACF,uKAAuK,CAAC;IAC5K,CAAC;SAAM,IAAI,2DAA2D,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACxF,IAAI;YACF,gMAAgM,CAAC;IACrM,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,WAAW,CAAC;QACd,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,cAAc,UAAU,IAAI,IAAI,EAAE;KACnE,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type * as run from "@distilled.cloud/gcp/run-v2";
2
+ export { Job, JobProvider } from "./Job.ts";
3
+ export type { JobAttributes, JobProps } from "./Job.ts";
4
+ export { jobIamMember, serviceIamMember } from "./IamMember.ts";
5
+ export type { RunIamBinding, RunIamBindingContract } from "./IamSync.ts";
6
+ export { Service, ServiceProvider } from "./Service.ts";
7
+ export type { ServiceAttributes, ServiceProps } from "./Service.ts";
8
+ /**
9
+ * Clean aliases for the most commonly-used Cloud Run v2 SDK types,
10
+ * re-exported from `@distilled.cloud/gcp/run-v2` so consumers don't
11
+ * need to import from the underlying SDK directly. The aliases are
12
+ * type-only — they share identity with the distilled types, so values
13
+ * are interchangeable.
14
+ *
15
+ * The `GoogleCloudRunV2*` prefix on the SDK types is generated from
16
+ * the GCP Discovery Document and is awkward to consume; these aliases
17
+ * mirror the casing the GCP REST docs use ("RevisionTemplate",
18
+ * "Container", "TrafficTarget"), which is what most users will
19
+ * already have in their heads.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import * as GCP from "@microagi/alchemy-gcp";
24
+ *
25
+ * const template: GCP.RevisionTemplate = {
26
+ * containers: [{ image: "..." }],
27
+ * };
28
+ * ```
29
+ */
30
+ export type RevisionTemplate = run.GoogleCloudRunV2RevisionTemplate;
31
+ export type ExecutionTemplate = run.GoogleCloudRunV2ExecutionTemplate;
32
+ export type TaskTemplate = run.GoogleCloudRunV2TaskTemplate;
33
+ export type Container = run.GoogleCloudRunV2Container;
34
+ export type ContainerPort = run.GoogleCloudRunV2ContainerPort;
35
+ export type EnvVar = run.GoogleCloudRunV2EnvVar;
36
+ export type EnvVarSource = run.GoogleCloudRunV2EnvVarSource;
37
+ export type ResourceRequirements = run.GoogleCloudRunV2ResourceRequirements;
38
+ export type Probe = run.GoogleCloudRunV2Probe;
39
+ export type VpcAccess = run.GoogleCloudRunV2VpcAccess;
40
+ export type NetworkInterface = run.GoogleCloudRunV2NetworkInterface;
41
+ export type NodeSelector = run.GoogleCloudRunV2NodeSelector;
42
+ export type TrafficTarget = run.GoogleCloudRunV2TrafficTarget;
43
+ export type TrafficTargetStatus = run.GoogleCloudRunV2TrafficTargetStatus;
44
+ export type ServiceScaling = run.GoogleCloudRunV2ServiceScaling;
45
+ export type BinaryAuthorization = run.GoogleCloudRunV2BinaryAuthorization;
46
+ export type Volume = run.GoogleCloudRunV2Volume;
47
+ export type VolumeMount = run.GoogleCloudRunV2VolumeMount;
48
+ export type Condition = run.GoogleCloudRunV2Condition;
49
+ export type ExecutionReference = run.GoogleCloudRunV2ExecutionReference;
50
+ export type SecretKeySelector = run.GoogleCloudRunV2SecretKeySelector;
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Run/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,gCAAgC,CAAC;AACpE,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,iCAAiC,CAAC;AACtE,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,4BAA4B,CAAC;AAC5D,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,yBAAyB,CAAC;AACtD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,6BAA6B,CAAC;AAC9D,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,sBAAsB,CAAC;AAChD,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,4BAA4B,CAAC;AAC5D,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,oCAAoC,CAAC;AAC5E,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,qBAAqB,CAAC;AAC9C,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,yBAAyB,CAAC;AACtD,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,gCAAgC,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,4BAA4B,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,6BAA6B,CAAC;AAC9D,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,mCAAmC,CAAC;AAC1E,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,8BAA8B,CAAC;AAChE,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,mCAAmC,CAAC;AAC1E,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,sBAAsB,CAAC;AAChD,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,2BAA2B,CAAC;AAC1D,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,yBAAyB,CAAC;AACtD,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,kCAAkC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,iCAAiC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Job, JobProvider } from "./Job.js";
2
+ export { jobIamMember, serviceIamMember } from "./IamMember.js";
3
+ export { Service, ServiceProvider } from "./Service.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Run/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { Resource } from "alchemy";
2
+ import * as Provider from "alchemy/Provider";
3
+ import type * as GCP from "../Providers.ts";
4
+ /**
5
+ * A logical Postgres database inside a Cloud SQL instance.
6
+ *
7
+ * Cloud SQL `databases` resources are extremely thin — name, charset,
8
+ * collation, parent instance. Use this resource to declaratively
9
+ * create a tenant database (one per app, one per team, etc.) and let
10
+ * alchemy track its lifecycle.
11
+ *
12
+ * **Adoption.** Cloud SQL databases carry NO labels. There is no
13
+ * server-side adoption marker we can stamp without polluting the
14
+ * collation field, so `read` is best-effort: it returns the observed
15
+ * shape if the database exists at the same logical address, and
16
+ * `undefined` otherwise. The caller is responsible for `--adopt` if
17
+ * they want to take over an existing physical database; we do not
18
+ * gate on labels here.
19
+ *
20
+ * **Replace triggers.** `project`, `instance`, `name`. Charset and
21
+ * collation are immutable post-create in practice — the API accepts
22
+ * a `patch` but ignores collation/charset drift, so we treat them as
23
+ * "set once, then forgotten" and only diff name/parent.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const db = yield* GCP.SqlDatabase("AppDb", {
28
+ * project: instance.project,
29
+ * instance: instance.name,
30
+ * name: "app",
31
+ * });
32
+ * ```
33
+ *
34
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/databases
35
+ */
36
+ export type SqlDatabaseProps = {
37
+ /**
38
+ * GCP project ID hosting the parent instance. Immutable — replace.
39
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/databases#Database
40
+ */
41
+ project: string;
42
+ /**
43
+ * Parent Cloud SQL instance name (NOT the fully-qualified resource
44
+ * name; just the bare `name`). Immutable — replace.
45
+ */
46
+ instance: string;
47
+ /**
48
+ * Database name. 1–64 chars; Postgres-specific naming applies (no
49
+ * reserved words, etc.). Immutable — replace if changed.
50
+ */
51
+ name: string;
52
+ /**
53
+ * Server-side character set. Postgres-default is `UTF8`. Set at
54
+ * create; not honoured on patch.
55
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/databases#Database.FIELDS.charset
56
+ */
57
+ charset?: string;
58
+ /**
59
+ * Collation. Postgres-default is `en_US.UTF8`. Set at create; not
60
+ * honoured on patch.
61
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/databases#Database.FIELDS.collation
62
+ */
63
+ collation?: string;
64
+ };
65
+ export type SqlDatabaseAttributes = {
66
+ /** Database name. */
67
+ name: string;
68
+ /** Parent instance name. */
69
+ instance: string;
70
+ /** Project ID. */
71
+ project: string;
72
+ /** Server-defined URL. */
73
+ selfLink: string;
74
+ /** Effective charset (server may default to `UTF8`). */
75
+ charset: string | undefined;
76
+ /** Effective collation. */
77
+ collation: string | undefined;
78
+ };
79
+ export type SqlDatabase = Resource<"GCP.SqlDatabase", SqlDatabaseProps, SqlDatabaseAttributes, never, GCP.Providers>;
80
+ export declare const SqlDatabase: import("alchemy").ResourceClass<SqlDatabase>;
81
+ export declare const SqlDatabaseProvider: () => import("effect/Layer").Layer<Provider.Provider<SqlDatabase>, never, import("effect/unstable/http/HttpClient").HttpClient | import("@distilled.cloud/gcp").Credentials>;
82
+ //# sourceMappingURL=Database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../src/Sqladmin/Database.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAChC,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,EACL,GAAG,CAAC,SAAS,CACd,CAAC;AACF,eAAO,MAAM,WAAW,8CAA2C,CAAC;AAcpE,eAAO,MAAM,mBAAmB,8KAqG7B,CAAC"}
@@ -0,0 +1,87 @@
1
+ import * as sql from "@distilled.cloud/gcp/sqladmin-v1";
2
+ import { Resource } from "alchemy";
3
+ import { isResolved, somePropsAreDifferent } from "alchemy/Diff";
4
+ import * as Provider from "alchemy/Provider";
5
+ import * as Effect from "effect/Effect";
6
+ import { makeAwaitOperation } from "./Operations.js";
7
+ import { reshapeBadRequest, validateDatabaseName } from "./Validation.js";
8
+ export const SqlDatabase = Resource("GCP.SqlDatabase");
9
+ const toAttributes = (d, parent) => ({
10
+ name: parent.name,
11
+ instance: parent.instance,
12
+ project: parent.project,
13
+ selfLink: d.selfLink ?? "",
14
+ charset: d.charset,
15
+ collation: d.collation,
16
+ });
17
+ export const SqlDatabaseProvider = () => Provider.effect(SqlDatabase, Effect.gen(function* () {
18
+ const getDatabases = yield* sql.getDatabases;
19
+ const insertDatabases = yield* sql.insertDatabases;
20
+ const deleteDatabases = yield* sql.deleteDatabases;
21
+ const getOperations = yield* sql.getOperations;
22
+ const awaitOperation = makeAwaitOperation(getOperations);
23
+ const observe = (project, instance, database) => getDatabases({ project, instance, database }).pipe(Effect.catchTag("NotFound", () => Effect.succeed(undefined)), Effect.catchTag("Forbidden", () => Effect.succeed(undefined)));
24
+ return {
25
+ stables: ["name", "instance", "project", "selfLink"],
26
+ diff: Effect.fn(function* ({ news, olds = {} }) {
27
+ if (!isResolved(news))
28
+ return undefined;
29
+ if (somePropsAreDifferent(olds, news, [
30
+ "project",
31
+ "instance",
32
+ "name",
33
+ ])) {
34
+ return { action: "replace" };
35
+ }
36
+ return undefined;
37
+ }),
38
+ reconcile: Effect.fn(function* ({ news, session }) {
39
+ yield* validateDatabaseName(news.name);
40
+ let observed = yield* observe(news.project, news.instance, news.name);
41
+ if (!observed) {
42
+ const op = yield* insertDatabases({
43
+ project: news.project,
44
+ instance: news.instance,
45
+ body: {
46
+ name: news.name,
47
+ ...(news.charset ? { charset: news.charset } : {}),
48
+ ...(news.collation ? { collation: news.collation } : {}),
49
+ },
50
+ }).pipe(Effect.catchTag("Conflict", () => Effect.succeed(undefined)), Effect.catchTag("BadRequest", reshapeBadRequest("Database", "insert")));
51
+ if (op?.name)
52
+ yield* awaitOperation(news.project, op.name, session);
53
+ observed = yield* getDatabases({
54
+ project: news.project,
55
+ instance: news.instance,
56
+ database: news.name,
57
+ });
58
+ }
59
+ return toAttributes(observed, {
60
+ project: news.project,
61
+ instance: news.instance,
62
+ name: news.name,
63
+ });
64
+ }),
65
+ delete: Effect.fn(function* ({ output, session }) {
66
+ yield* deleteDatabases({
67
+ project: output.project,
68
+ instance: output.instance,
69
+ database: output.name,
70
+ }).pipe(Effect.flatMap((op) => op.name
71
+ ? awaitOperation(output.project, op.name, session)
72
+ : Effect.succeed(op)), Effect.catchTag("NotFound", () => Effect.void), Effect.catchTag("BadRequest", reshapeBadRequest("Database", "delete")));
73
+ }),
74
+ read: Effect.fn(function* ({ output, olds }) {
75
+ const project = output?.project ?? olds?.project;
76
+ const instance = output?.instance ?? olds?.instance;
77
+ const name = output?.name ?? olds?.name;
78
+ if (!project || !instance || !name)
79
+ return undefined;
80
+ const observed = yield* observe(project, instance, name);
81
+ if (!observed)
82
+ return undefined;
83
+ return toAttributes(observed, { project, instance, name });
84
+ }),
85
+ };
86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;gBAAE,OAAO,SAAS,CAAC;YAChC,OAAO,YAAY,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,234 @@
1
+ import { Resource } from "alchemy";
2
+ import * as Provider from "alchemy/Provider";
3
+ import * as Redacted from "effect/Redacted";
4
+ import type * as GCP from "../Providers.ts";
5
+ import type { PostgresVersion, SqlActivationPolicy, SqlAvailabilityType, SqlDataDiskType, SqlEdition } from "./Types.ts";
6
+ /**
7
+ * A Cloud SQL for Postgres instance.
8
+ *
9
+ * **Resource model.** A Cloud SQL instance bundles the storage volume,
10
+ * compute tier, networking (public IP / VPC private IP via PSA), and
11
+ * managed backups. Databases (`GCP.SqlDatabase`) and users
12
+ * (`GCP.SqlUser`) hang off it and are modelled as separate resources.
13
+ *
14
+ * **Lifecycle.** observe → ensure (insert; retry on the "API not yet
15
+ * enabled" 403 propagation race) → sync (patch top-level fields, with
16
+ * `settingsVersion` round-trip for optimistic concurrency) → return.
17
+ *
18
+ * **Replace triggers.** `project`, `region`, `name`, `databaseVersion`.
19
+ * Everything else — tier, disk size, IP config, backup config — is
20
+ * in-place via `patch`.
21
+ *
22
+ * **Optimistic concurrency.** Cloud SQL uses `settings.settingsVersion`
23
+ * (NOT `etag` — etag is deprecated). Every patch reads the live
24
+ * instance and threads the observed `settingsVersion` through the
25
+ * body. Concurrent edits surface as `Conflict`.
26
+ *
27
+ * **Adoption.** Label-gated: an instance whose `settings.userLabels`
28
+ * lack our `alchemy_*` keys is wrapped in `Unowned(attrs)` from
29
+ * `read`, forcing `--adopt` before takeover.
30
+ *
31
+ * **Deletion protection.** When `settings.deletionProtectionEnabled`
32
+ * is `true`, alchemy `destroy` will fail with a `BadRequest`. Set the
33
+ * flag to `false` in a separate deploy (which patches the instance),
34
+ * then re-run destroy.
35
+ *
36
+ * @example Minimal private-IP Postgres 17 instance on a Shared VPC
37
+ * ```typescript
38
+ * const db = yield* GCP.SqlInstance("Primary", {
39
+ * project: project.projectId,
40
+ * region: "europe-west4",
41
+ * databaseVersion: "POSTGRES_17",
42
+ * settings: {
43
+ * tier: "db-custom-2-7680",
44
+ * edition: "ENTERPRISE",
45
+ * dataDiskSizeGb: 50,
46
+ * ipConfiguration: {
47
+ * ipv4Enabled: false,
48
+ * privateNetwork: hostVpc.selfLink,
49
+ * },
50
+ * backupConfiguration: { enabled: true, pointInTimeRecoveryEnabled: true },
51
+ * },
52
+ * });
53
+ * ```
54
+ *
55
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances
56
+ */
57
+ export type SqlInstanceProps = {
58
+ /**
59
+ * GCP project ID hosting the instance. Immutable — replace if changed.
60
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances#SqlInstance
61
+ */
62
+ project: string;
63
+ /**
64
+ * Cloud SQL region (e.g. `europe-west4`). Cloud SQL is regional;
65
+ * zonality is configured inside `settings.availabilityType`.
66
+ * Immutable — replace if changed.
67
+ * @see https://cloud.google.com/sql/docs/postgres/locations
68
+ */
69
+ region: string;
70
+ /**
71
+ * Instance name. Defaults to `createPhysicalName({ id, lowercase:
72
+ * true, maxLength: 98 })`. Lowercase letters/digits/hyphens; begin
73
+ * with a letter, no trailing hyphen; 1–98 chars. Immutable — replace.
74
+ * @see https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances#SqlInstance
75
+ */
76
+ name?: string;
77
+ /**
78
+ * Postgres engine version. Immutable — Cloud SQL exposes major
79
+ * version *upgrades* via a separate `upgrade` operation, not via
80
+ * `patch`. Surfacing it as immutable here forces an explicit replace
81
+ * (or out-of-band upgrade) for clarity.
82
+ * @see https://cloud.google.com/sql/docs/postgres/db-versions
83
+ */
84
+ databaseVersion: PostgresVersion;
85
+ /**
86
+ * Initial Postgres `postgres` superuser password. Only set on
87
+ * insert; ignored on subsequent patches (Cloud SQL silently drops
88
+ * `rootPassword` on patch). Typically omitted on IAM-only stacks
89
+ * since the `postgres` role is unused.
90
+ * @see https://cloud.google.com/sql/docs/postgres/create-manage-users#user-root
91
+ */
92
+ rootPassword?: Redacted.Redacted<string>;
93
+ /**
94
+ * Resource labels. Alchemy internal labels (`alchemy_app`,
95
+ * `alchemy_stage`, `alchemy_id`) are merged on top automatically.
96
+ * Cloud SQL stores user labels under `settings.userLabels`; we
97
+ * surface them at the top level for symmetry with other GCP
98
+ * resources. Mutable via `patch`.
99
+ * @see https://cloud.google.com/sql/docs/postgres/label-instance
100
+ */
101
+ labels?: Record<string, string>;
102
+ /** Instance settings (tier, disk, IP, backups, …). Mostly mutable via `patch`. */
103
+ settings: {
104
+ /**
105
+ * Machine tier (`db-custom-{vCPU}-{memMiB}`, `db-f1-micro`,
106
+ * `db-perf-optimized-*`). Mutable via `patch` (causes a restart).
107
+ * @see https://cloud.google.com/sql/docs/postgres/instance-settings
108
+ */
109
+ tier: string;
110
+ /**
111
+ * Cloud SQL edition. `ENTERPRISE_PLUS` is required for
112
+ * Data Cache + the `db-perf-optimized-*` tiers. Mutable via
113
+ * `patch` (some transitions require a restart).
114
+ * @see https://cloud.google.com/sql/docs/postgres/editions-intro
115
+ */
116
+ edition?: SqlEdition;
117
+ /**
118
+ * Storage size in GB. Mutable via `patch`; can only grow, not
119
+ * shrink (shrink requires a side-channel operation).
120
+ * @see https://cloud.google.com/sql/docs/postgres/instance-settings#storage-capacity-2ndgen
121
+ */
122
+ dataDiskSizeGb?: number;
123
+ /**
124
+ * Disk type. `PD_SSD` is the default; `PD_HDD` is legacy.
125
+ * Immutable in practice — Cloud SQL rejects type changes on patch.
126
+ * @see https://cloud.google.com/sql/docs/postgres/instance-settings#storage-type-2ndgen
127
+ */
128
+ dataDiskType?: SqlDataDiskType;
129
+ /** Auto-grow the data disk when nearing full. Mutable via `patch`. */
130
+ diskAutoresize?: boolean;
131
+ /** Cap on auto-grown size, in GB. Mutable via `patch`. */
132
+ diskAutoresizeLimit?: number;
133
+ /** Networking — public IP, private IP via PSA, or both. Mutable via `patch`. */
134
+ ipConfiguration?: {
135
+ /**
136
+ * VPC selfLink (`https://www.googleapis.com/compute/v1/projects/{p}/global/networks/{n}`)
137
+ * to attach the private IP to. The VPC must already have a PSA
138
+ * peering with `servicenetworking.googleapis.com`. Immutable
139
+ * after first set (Cloud SQL refuses to change the private network).
140
+ * @see https://cloud.google.com/sql/docs/postgres/private-ip
141
+ */
142
+ privateNetwork?: string;
143
+ /** Enable a public IPv4 endpoint. Mutable via `patch`. */
144
+ ipv4Enabled?: boolean;
145
+ /**
146
+ * Allow Google-managed services (BigQuery, Vertex AI, etc.) to
147
+ * reach the private IP over Google's backbone. Mutable via `patch`.
148
+ */
149
+ enablePrivatePathForGoogleCloudServices?: boolean;
150
+ /** Require SSL/TLS on all connections. Mutable via `patch`. */
151
+ requireSsl?: boolean;
152
+ };
153
+ /** Backup window + retention settings. Mutable via `patch`. */
154
+ backupConfiguration?: {
155
+ /** Enable automated daily backups. Mutable via `patch`. */
156
+ enabled?: boolean;
157
+ /** Enable PITR (write-ahead log archiving). Mutable via `patch`. */
158
+ pointInTimeRecoveryEnabled?: boolean;
159
+ /** Backup start time in UTC, `HH:MM` 24-hour. Mutable via `patch`. */
160
+ startTime?: string;
161
+ /** WAL retention window (1–7 days). Mutable via `patch`. */
162
+ transactionLogRetentionDays?: number;
163
+ };
164
+ /**
165
+ * Postgres flags (e.g. `shared_buffers`, `max_connections`).
166
+ * Mutable via `patch`; some flags trigger a restart.
167
+ * @see https://cloud.google.com/sql/docs/postgres/flags
168
+ */
169
+ databaseFlags?: ReadonlyArray<{
170
+ name: string;
171
+ value: string;
172
+ }>;
173
+ /**
174
+ * Block alchemy from deleting the instance via the API. Disable
175
+ * before running destroy.
176
+ * @see https://cloud.google.com/sql/docs/postgres/deletion-protection
177
+ */
178
+ deletionProtectionEnabled?: boolean;
179
+ /** Park (`NEVER`) or run (`ALWAYS`) the instance. Mutable via `patch`. */
180
+ activationPolicy?: SqlActivationPolicy;
181
+ /**
182
+ * `ZONAL` = single zone; `REGIONAL` = HA standby in a second zone.
183
+ * Mutable via `patch` (transitions to/from `REGIONAL` take ~10 min).
184
+ * @see https://cloud.google.com/sql/docs/postgres/high-availability
185
+ */
186
+ availabilityType?: SqlAvailabilityType;
187
+ };
188
+ };
189
+ export type SqlInstanceIpAddress = {
190
+ /** Address class — `PRIMARY` (public), `PRIVATE`, or `OUTGOING`. */
191
+ type: string | undefined;
192
+ /** The IP itself. */
193
+ ipAddress: string | undefined;
194
+ };
195
+ export type SqlInstanceAttributes = {
196
+ /** Bare instance name (no `projects/.../instances/` prefix). */
197
+ name: string;
198
+ /** Server-defined URL for the instance. */
199
+ selfLink: string;
200
+ /** GCP project ID. */
201
+ project: string;
202
+ /** Region. */
203
+ region: string;
204
+ /**
205
+ * `project:region:name` — the canonical identifier the Cloud SQL
206
+ * Auth Proxy and the IAM authn token exchange both consume.
207
+ */
208
+ connectionName: string;
209
+ /** Echoed Postgres version (e.g. `POSTGRES_17`). */
210
+ databaseVersion: string;
211
+ /** Lifecycle state — `RUNNABLE` once ready. */
212
+ state: string;
213
+ /** All IPs Cloud SQL has assigned. */
214
+ ipAddresses: ReadonlyArray<SqlInstanceIpAddress>;
215
+ /** Convenience: first `PRIVATE` IP, if any. */
216
+ privateIpAddress: string | undefined;
217
+ /** Convenience: first `PRIMARY` (public) IP, if any. */
218
+ publicIpAddress: string | undefined;
219
+ /** Server CA cert; useful for pinning TLS roots from a client. */
220
+ serverCaCert: {
221
+ cert: string | undefined;
222
+ commonName: string | undefined;
223
+ expirationTime: string | undefined;
224
+ sha1Fingerprint: string | undefined;
225
+ } | undefined;
226
+ /** Monotonic optimistic-concurrency token — round-tripped on patch. */
227
+ settingsVersion: string | undefined;
228
+ /** Labels currently set, including alchemy internals. */
229
+ labels: Record<string, string>;
230
+ };
231
+ export type SqlInstance = Resource<"GCP.SqlInstance", SqlInstanceProps, SqlInstanceAttributes, never, GCP.Providers>;
232
+ export declare const SqlInstance: import("alchemy").ResourceClass<SqlInstance>;
233
+ export declare const SqlInstanceProvider: () => import("effect/Layer").Layer<Provider.Provider<SqlInstance>, never, import("effect/unstable/http/HttpClient").HttpClient | import("alchemy").Stage | import("alchemy").Stack | import("@distilled.cloud/gcp").Credentials>;
234
+ //# sourceMappingURL=Instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/Sqladmin/Instance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAI7C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAG5C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,eAAe,EAAE,eAAe,CAAC;IACjC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,kFAAkF;IAClF,QAAQ,EAAE;QACR;;;;WAIG;QACH,IAAI,EAAE,MAAM,CAAC;QACb;;;;;WAKG;QACH,OAAO,CAAC,EAAE,UAAU,CAAC;QACrB;;;;WAIG;QACH,cAAc,C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