@alchemy.run/planetscale 0.0.0 → 2.0.0-beta.85

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 (123) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +83 -4
  3. package/lib/AuthProvider.d.ts +64 -0
  4. package/lib/AuthProvider.d.ts.map +1 -0
  5. package/lib/AuthProvider.js +395 -0
  6. package/lib/AuthProvider.js.map +1 -0
  7. package/lib/Branch.d.ts +128 -0
  8. package/lib/Branch.d.ts.map +1 -0
  9. package/lib/Branch.js +420 -0
  10. package/lib/Branch.js.map +1 -0
  11. package/lib/Contributions.d.ts +7 -0
  12. package/lib/Contributions.d.ts.map +1 -0
  13. package/lib/Contributions.js +6 -0
  14. package/lib/Contributions.js.map +1 -0
  15. package/lib/Credentials.d.ts +33 -0
  16. package/lib/Credentials.d.ts.map +1 -0
  17. package/lib/Credentials.js +59 -0
  18. package/lib/Credentials.js.map +1 -0
  19. package/lib/Database.d.ts +138 -0
  20. package/lib/Database.d.ts.map +1 -0
  21. package/lib/Database.js +1 -0
  22. package/lib/Database.js.map +1 -0
  23. package/lib/MySQL/MySQLBranch.d.ts +87 -0
  24. package/lib/MySQL/MySQLBranch.d.ts.map +1 -0
  25. package/lib/MySQL/MySQLBranch.js +15 -0
  26. package/lib/MySQL/MySQLBranch.js.map +1 -0
  27. package/lib/MySQL/MySQLClusterSize.d.ts +32 -0
  28. package/lib/MySQL/MySQLClusterSize.d.ts.map +1 -0
  29. package/lib/MySQL/MySQLClusterSize.js +111 -0
  30. package/lib/MySQL/MySQLClusterSize.js.map +1 -0
  31. package/lib/MySQL/MySQLDatabase.d.ts +141 -0
  32. package/lib/MySQL/MySQLDatabase.d.ts.map +1 -0
  33. package/lib/MySQL/MySQLDatabase.js +294 -0
  34. package/lib/MySQL/MySQLDatabase.js.map +1 -0
  35. package/lib/MySQL/MySQLMigrations.d.ts +20 -0
  36. package/lib/MySQL/MySQLMigrations.d.ts.map +1 -0
  37. package/lib/MySQL/MySQLMigrations.js +72 -0
  38. package/lib/MySQL/MySQLMigrations.js.map +1 -0
  39. package/lib/MySQL/MySQLOrigin.d.ts +15 -0
  40. package/lib/MySQL/MySQLOrigin.d.ts.map +1 -0
  41. package/lib/MySQL/MySQLOrigin.js +2 -0
  42. package/lib/MySQL/MySQLOrigin.js.map +1 -0
  43. package/lib/MySQL/MySQLPassword.d.ts +116 -0
  44. package/lib/MySQL/MySQLPassword.d.ts.map +1 -0
  45. package/lib/MySQL/MySQLPassword.js +212 -0
  46. package/lib/MySQL/MySQLPassword.js.map +1 -0
  47. package/lib/MySQL/index.d.ts +6 -0
  48. package/lib/MySQL/index.d.ts.map +1 -0
  49. package/lib/MySQL/index.js +6 -0
  50. package/lib/MySQL/index.js.map +1 -0
  51. package/lib/OAuthClient.d.ts +32 -0
  52. package/lib/OAuthClient.d.ts.map +1 -0
  53. package/lib/OAuthClient.js +52 -0
  54. package/lib/OAuthClient.js.map +1 -0
  55. package/lib/Postgres/PostgresBranch.d.ts +75 -0
  56. package/lib/Postgres/PostgresBranch.d.ts.map +1 -0
  57. package/lib/Postgres/PostgresBranch.js +15 -0
  58. package/lib/Postgres/PostgresBranch.js.map +1 -0
  59. package/lib/Postgres/PostgresClusterSize.d.ts +77 -0
  60. package/lib/Postgres/PostgresClusterSize.d.ts.map +1 -0
  61. package/lib/Postgres/PostgresClusterSize.js +89 -0
  62. package/lib/Postgres/PostgresClusterSize.js.map +1 -0
  63. package/lib/Postgres/PostgresDatabase.d.ts +95 -0
  64. package/lib/Postgres/PostgresDatabase.d.ts.map +1 -0
  65. package/lib/Postgres/PostgresDatabase.js +294 -0
  66. package/lib/Postgres/PostgresDatabase.js.map +1 -0
  67. package/lib/Postgres/PostgresDefaultRole.d.ts +94 -0
  68. package/lib/Postgres/PostgresDefaultRole.d.ts.map +1 -0
  69. package/lib/Postgres/PostgresDefaultRole.js +187 -0
  70. package/lib/Postgres/PostgresDefaultRole.js.map +1 -0
  71. package/lib/Postgres/PostgresMigrations.d.ts +16 -0
  72. package/lib/Postgres/PostgresMigrations.d.ts.map +1 -0
  73. package/lib/Postgres/PostgresMigrations.js +65 -0
  74. package/lib/Postgres/PostgresMigrations.js.map +1 -0
  75. package/lib/Postgres/PostgresOrigin.d.ts +15 -0
  76. package/lib/Postgres/PostgresOrigin.d.ts.map +1 -0
  77. package/lib/Postgres/PostgresOrigin.js +2 -0
  78. package/lib/Postgres/PostgresOrigin.js.map +1 -0
  79. package/lib/Postgres/PostgresRole.d.ts +142 -0
  80. package/lib/Postgres/PostgresRole.d.ts.map +1 -0
  81. package/lib/Postgres/PostgresRole.js +268 -0
  82. package/lib/Postgres/PostgresRole.js.map +1 -0
  83. package/lib/Postgres/index.d.ts +7 -0
  84. package/lib/Postgres/index.d.ts.map +1 -0
  85. package/lib/Postgres/index.js +7 -0
  86. package/lib/Postgres/index.js.map +1 -0
  87. package/lib/Providers.d.ts +24 -0
  88. package/lib/Providers.d.ts.map +1 -0
  89. package/lib/Providers.js +40 -0
  90. package/lib/Providers.js.map +1 -0
  91. package/lib/Util.d.ts +93 -0
  92. package/lib/Util.d.ts.map +1 -0
  93. package/lib/Util.js +135 -0
  94. package/lib/Util.js.map +1 -0
  95. package/lib/index.d.ts +9 -0
  96. package/lib/index.d.ts.map +1 -0
  97. package/lib/index.js +9 -0
  98. package/lib/index.js.map +1 -0
  99. package/package.json +79 -3
  100. package/src/AuthProvider.ts +584 -0
  101. package/src/Branch.ts +657 -0
  102. package/src/Contributions.ts +9 -0
  103. package/src/Credentials.ts +92 -0
  104. package/src/Database.ts +152 -0
  105. package/src/MySQL/MySQLBranch.ts +109 -0
  106. package/src/MySQL/MySQLClusterSize.ts +185 -0
  107. package/src/MySQL/MySQLDatabase.ts +521 -0
  108. package/src/MySQL/MySQLMigrations.ts +133 -0
  109. package/src/MySQL/MySQLOrigin.ts +15 -0
  110. package/src/MySQL/MySQLPassword.ts +428 -0
  111. package/src/MySQL/index.ts +5 -0
  112. package/src/OAuthClient.ts +59 -0
  113. package/src/Postgres/PostgresBranch.ts +97 -0
  114. package/src/Postgres/PostgresClusterSize.ts +262 -0
  115. package/src/Postgres/PostgresDatabase.ts +469 -0
  116. package/src/Postgres/PostgresDefaultRole.ts +340 -0
  117. package/src/Postgres/PostgresMigrations.ts +122 -0
  118. package/src/Postgres/PostgresOrigin.ts +15 -0
  119. package/src/Postgres/PostgresRole.ts +547 -0
  120. package/src/Postgres/index.ts +6 -0
  121. package/src/Providers.ts +67 -0
  122. package/src/Util.ts +205 -0
  123. package/src/index.ts +14 -0
package/lib/Branch.js ADDED
@@ -0,0 +1,420 @@
1
+ import { classifyMigrationHistory, describeRewrittenHistory, migrationsAttrs, migrationsInputOf, RewrittenMigrationHistoryError, stampedOf, } from "@alchemy.run/sql/Migrations";
2
+ import { hashImports } from "@alchemy.run/sql/SqlFile";
3
+ import * as planetscale from "@distilled.cloud/planetscale";
4
+ import { Credentials } from "@distilled.cloud/planetscale/Credentials";
5
+ import { Unowned } from "alchemy/AdoptPolicy";
6
+ import { havePropsChanged, isResolved } from "alchemy/Diff";
7
+ import { createPhysicalName } from "alchemy/PhysicalName";
8
+ import * as Provider from "alchemy/Provider";
9
+ import { recordsEqual } from "alchemy/Util/equal";
10
+ import * as Effect from "effect/Effect";
11
+ import * as Schedule from "effect/Schedule";
12
+ import * as Stream from "effect/Stream";
13
+ import { ensureMySQLProductionBranchClusterSize } from "./MySQL/MySQLClusterSize.js";
14
+ import { ensurePostgresProductionBranchClusterSize, toPostgresClusterArch, toPostgresClusterSku, waitForPendingPostgresChanges, } from "./Postgres/PostgresClusterSize.js";
15
+ import { PlanetscaleConflict, isKnownError, waitForBranchReady } from "./Util.js";
16
+ const resolveDatabase = (database) => {
17
+ const ref = database;
18
+ if (!ref)
19
+ return { name: "" };
20
+ return typeof ref === "string"
21
+ ? { name: ref }
22
+ : { name: ref.name, organization: ref.organization };
23
+ };
24
+ const resolveParent = (parent) => {
25
+ const ref = parent;
26
+ return !ref ? "main" : typeof ref === "string" ? ref : ref.name;
27
+ };
28
+ const createBranchName = (id, name) => Effect.gen(function* () {
29
+ return name ?? (yield* createPhysicalName({ id, lowercase: true, maxLength: 63 }));
30
+ });
31
+ const rootDir = Effect.sync(() => process.cwd());
32
+ /**
33
+ * Matches the UnprocessableEntity errors PlanetScale returns when a
34
+ * branch promotion/demotion races an in-flight cluster resize, e.g.
35
+ * "Branches with a cluster resize in progress cannot be demoted."
36
+ */
37
+ const isResizeInProgress = (error) => typeof error === "object" &&
38
+ error !== null &&
39
+ error._tag === "UnprocessableEntity" &&
40
+ typeof error.message === "string" &&
41
+ error.message.includes("cluster resize in progress");
42
+ /**
43
+ * Build a branch provider for a specific PlanetScale engine. The
44
+ * caller supplies the typed `Resource` token and the engine's migration
45
+ * runners; everything else (observe / ensure / sync / delete) is shared.
46
+ */
47
+ export const makeBranchProvider = (opts) => Provider.succeed(opts.resource, {
48
+ stables: ["organization", "database"],
49
+ // PARENT FAN-OUT: PlanetScale branches are nested under a database within
50
+ // an organization, so there is no flat per-org branch enumeration API.
51
+ // Enumerate every database in the credentialed org, then list each
52
+ // database's branches concurrently (bounded), exhaustively paginating
53
+ // both levels, and keep only the branches whose engine kind matches this
54
+ // resource. Each item is hydrated into the exact `read` Attributes shape.
55
+ list: Effect.fn(function* () {
56
+ const { organization } = yield* yield* Credentials;
57
+ const databases = yield* planetscale.listDatabases.pages({ organization }).pipe(Stream.runCollect, Effect.map((chunk) => Array.from(chunk).flatMap((page) => page.data)));
58
+ const rows = yield* Effect.forEach(databases, (db) => planetscale.listBranches.pages({ organization, database: db.name }).pipe(Stream.runCollect, Effect.map((chunk) => Array.from(chunk).flatMap((page) => page.data
59
+ .filter((branch) => branch.kind === opts.expectedKind)
60
+ .map((branch) => ({
61
+ name: branch.name,
62
+ organization,
63
+ database: db.name,
64
+ parentBranch: branch.parent_branch ?? "main",
65
+ production: branch.production,
66
+ createdAt: branch.created_at,
67
+ updatedAt: branch.updated_at,
68
+ htmlUrl: branch.html_url,
69
+ region: { slug: branch.region.slug },
70
+ migrationsDir: undefined,
71
+ migrationsTable: undefined,
72
+ migrationsHashes: {},
73
+ importHashes: {},
74
+ desiredReplicas: undefined,
75
+ hasReplicas: branch.has_replicas,
76
+ hasReadOnlyReplicas: branch.has_read_only_replicas,
77
+ })))),
78
+ // A database can be deleted between enumeration and the
79
+ // per-database branch list — skip it rather than fail.
80
+ Effect.catchTag("NotFound", () => Effect.succeed([]))), { concurrency: 10 });
81
+ return rows.flat();
82
+ }),
83
+ diff: Effect.fn(function* ({ news, olds, output }) {
84
+ if (!isResolved(news))
85
+ return undefined;
86
+ // Branch names are rename-mutable (reconcile syncs `news.name` in
87
+ // place), so `name` cannot live in the provider-level stables. But
88
+ // almost no update is a rename — for those, advertise `name` as
89
+ // stable on the update so downstream consumers referencing this
90
+ // branch still resolve `branch.name` at plan time. Without it, a
91
+ // metadata-only update (e.g. an embedded database ref whose
92
+ // `migrationsHashes` moved) resolves consumer refs to just
93
+ // `{ organization, database }`, and identity-sensitive consumers
94
+ // (PostgresRole) falsely plan a replacement against `name: undefined`.
95
+ //
96
+ // The name only changes when the `name` prop itself changes: an
97
+ // explicit name renames iff it differs from the observed name, and
98
+ // an omitted name is engine-generated deterministically (stable
99
+ // across updates — the instance id only rotates on replacement).
100
+ const nameIsStable = output?.name !== undefined &&
101
+ (news.name !== undefined ? news.name === output.name : olds?.name === undefined);
102
+ const stables = nameIsStable ? ["organization", "database", "name"] : undefined;
103
+ const newDb = resolveDatabase(news.database).name;
104
+ const oldDbRef = output?.database ?? olds.database;
105
+ if (oldDbRef) {
106
+ const oldDb = resolveDatabase(oldDbRef).name;
107
+ if (newDb !== oldDb) {
108
+ return { action: "replace" };
109
+ }
110
+ }
111
+ const newParent = resolveParent(news.parentBranch);
112
+ const oldParent = output?.parentBranch ?? resolveParent(olds.parentBranch);
113
+ if (newParent !== oldParent) {
114
+ return { action: "replace" };
115
+ }
116
+ if (news.region?.slug && output?.region?.slug && news.region.slug !== output.region.slug) {
117
+ return { action: "replace" };
118
+ }
119
+ if (news.replicas !== undefined) {
120
+ if (output?.desiredReplicas !== news.replicas) {
121
+ return { action: "update", stables };
122
+ }
123
+ const desiredHasReplicas = news.replicas > 0;
124
+ if (output?.hasReplicas !== undefined && output.hasReplicas !== desiredHasReplicas) {
125
+ return { action: "update", stables };
126
+ }
127
+ }
128
+ const migrationChange = yield* classifyMigrationHistory({
129
+ news,
130
+ output,
131
+ });
132
+ if (migrationChange.kind === "rewritten") {
133
+ // Editing or deleting an already-applied file cannot be replayed
134
+ // in place (apply is name-keyed). Development branches re-fork
135
+ // from the parent and apply from scratch; production must add a
136
+ // forward migration instead.
137
+ const production = output?.production === true || news.isProduction === true;
138
+ if (production) {
139
+ return yield* new RewrittenMigrationHistoryError({
140
+ changed: migrationChange.changed,
141
+ removed: migrationChange.removed,
142
+ message: `Cannot rewrite applied migration history on production PlanetScale branch ` +
143
+ `"${output?.name ?? news.name ?? "unknown"}" ` +
144
+ `(${describeRewrittenHistory(migrationChange)}). ` +
145
+ "Add a new forward migration instead of editing or deleting already-applied files.",
146
+ });
147
+ }
148
+ return { action: "replace" };
149
+ }
150
+ if (migrationChange.kind === "pending") {
151
+ return { action: "update", stables };
152
+ }
153
+ if (news.importFiles?.length) {
154
+ const newHashes = yield* hashImports(news.importFiles, yield* rootDir);
155
+ if (!recordsEqual(newHashes, output?.importHashes ?? {})) {
156
+ return { action: "update", stables };
157
+ }
158
+ }
159
+ // Remaining prop changes (rename, safeMigrations, clusterSize,
160
+ // metadata embedded in resource refs) are all in-place updates.
161
+ // Decide them here instead of falling back to the engine's default
162
+ // deep-compare so the conditional `name` stable above is attached —
163
+ // the default path uses the provider-level stables, which strip
164
+ // `name` from downstream plan resolution.
165
+ if (havePropsChanged(olds, news)) {
166
+ return { action: "update", stables };
167
+ }
168
+ // Nothing changed. Still advertise the conditional `name` stable so
169
+ // a `--force` deploy (which upgrades this noop to an update) keeps
170
+ // `name` resolvable downstream instead of falsely replacing
171
+ // consumers such as roles and passwords (#1832).
172
+ return stables ? { action: "noop", stables } : undefined;
173
+ }),
174
+ read: Effect.fn(function* ({ id, olds, output }) {
175
+ // If we have neither a cached output nor a usable `olds.database`
176
+ // there's no way to identify which branch to refresh — most often
177
+ // this is destroy of a partially-created resource whose props
178
+ // never got fully persisted. Return `undefined` so the engine
179
+ // treats it as already-gone and drops the state entry.
180
+ if (!output && !olds?.database) {
181
+ return undefined;
182
+ }
183
+ const dbInfo = output
184
+ ? { name: output.database, organization: output.organization }
185
+ : resolveDatabase(olds.database);
186
+ const { organization: envOrg } = yield* yield* Credentials;
187
+ const organization = output?.organization ?? dbInfo.organization ?? envOrg;
188
+ const databaseName = output?.database ?? dbInfo.name;
189
+ const branchName = output?.name ?? (yield* createBranchName(id, olds.name));
190
+ return yield* planetscale
191
+ .getBranch({
192
+ organization,
193
+ database: databaseName,
194
+ branch: branchName,
195
+ })
196
+ .pipe(Effect.map((data) => {
197
+ const attrs = {
198
+ name: data.name,
199
+ organization,
200
+ database: databaseName,
201
+ parentBranch: data.parent_branch ?? "main",
202
+ production: data.production,
203
+ createdAt: data.created_at,
204
+ // PlanetScale bumps `updated_at` asynchronously (e.g. seconds
205
+ // after a deploy, on role creation, maintenance) without any
206
+ // config change, so the observed value is volatile. Keep the
207
+ // value recorded by the last reconcile so drift detection only
208
+ // flags real configuration changes (#1955).
209
+ updatedAt: output?.updatedAt ?? data.updated_at,
210
+ htmlUrl: data.html_url,
211
+ region: { slug: data.region.slug },
212
+ migrationsDir: output?.migrationsDir ?? olds?.migrationsDir,
213
+ migrationsTable: output?.migrationsTable ?? olds?.migrationsTable,
214
+ migrationsHashes: output?.migrationsHashes ?? {},
215
+ importHashes: output?.importHashes ?? {},
216
+ desiredReplicas: output?.desiredReplicas ?? olds?.desiredReplicas ?? olds?.replicas,
217
+ hasReplicas: data.has_replicas,
218
+ hasReadOnlyReplicas: data.has_read_only_replicas,
219
+ };
220
+ return output ? attrs : Unowned(attrs);
221
+ }), Effect.catchTag("NotFound", () => Effect.undefined));
222
+ }),
223
+ reconcile: Effect.fn(function* ({ id, news, output, session }) {
224
+ const { organization: envOrg } = yield* yield* Credentials;
225
+ const dbInfo = resolveDatabase(news.database);
226
+ const organization = output?.organization ?? dbInfo.organization ?? envOrg;
227
+ const databaseName = output?.database ?? dbInfo.name;
228
+ const desiredBranchName = yield* createBranchName(id, news.name);
229
+ const observedBranchName = output?.name ?? desiredBranchName;
230
+ const parentBranchName = resolveParent(news.parentBranch);
231
+ // If parentBranch is a plain string (an unmanaged branch reference),
232
+ // wait for it to be ready before we touch the child branch. When it
233
+ // is a Branch resource, Alchemy's resource graph already guarantees
234
+ // readiness before this resource's inputs are resolved.
235
+ if (news.parentBranch && typeof news.parentBranch === "string") {
236
+ yield* waitForBranchReady(organization, databaseName, parentBranchName, session);
237
+ }
238
+ // Observe — fetch the live branch state.
239
+ let current = yield* planetscale
240
+ .getBranch({
241
+ organization,
242
+ database: databaseName,
243
+ branch: observedBranchName,
244
+ })
245
+ .pipe(Effect.catchTag("NotFound", () => Effect.undefined));
246
+ // Ensure — if missing, create. The parent must be ready before
247
+ // the child can fork from it. PostgreSQL short cluster sizes need
248
+ // to be expanded against the parent's region so the API call lands
249
+ // with a valid sku.
250
+ if (!current) {
251
+ const parent = yield* waitForBranchReady(organization, databaseName, parentBranchName, session);
252
+ const parentClusterSize = news.clusterSize
253
+ ? parent.kind === "postgresql"
254
+ ? toPostgresClusterSku({
255
+ size: news.clusterSize,
256
+ arch: toPostgresClusterArch(parent.cluster_architecture),
257
+ region: parent.region.slug,
258
+ })
259
+ : news.clusterSize
260
+ : undefined;
261
+ yield* session.note("Creating branch...");
262
+ current = yield* planetscale.createBranch({
263
+ organization,
264
+ database: databaseName,
265
+ name: desiredBranchName,
266
+ parent_branch: parentBranchName,
267
+ backup_id: news.backupId,
268
+ seed_data: news.seedData,
269
+ region: news.region?.slug,
270
+ cluster_size: parentClusterSize,
271
+ });
272
+ }
273
+ if (current.kind !== opts.expectedKind) {
274
+ return yield* new PlanetscaleConflict({
275
+ message: `Planetscale branch "${current.name}" (database "${databaseName}") has kind ` +
276
+ `"${current.kind}" but this resource is a ${opts.engineLabel}. ` +
277
+ `Use the matching ${current.kind === "mysql" ? "MySQLBranch" : "PostgresBranch"} ` +
278
+ `resource instead.`,
279
+ });
280
+ }
281
+ yield* waitForBranchReady(organization, databaseName, current.name, session);
282
+ // Sync name — branch names are mutable. Continue subsequent syncs
283
+ // under the name returned by the API.
284
+ if (current.name !== desiredBranchName) {
285
+ current = yield* planetscale.updateBranch({
286
+ organization,
287
+ database: databaseName,
288
+ branch: current.name,
289
+ new_name: desiredBranchName,
290
+ });
291
+ }
292
+ const branchName = current.name;
293
+ // Sync production status before branch settings that depend on it.
294
+ // PlanetScale only supports explicit branch promotion/demotion for MySQL.
295
+ if (opts.expectedKind === "mysql") {
296
+ const desiredProduction = news.isProduction ?? false;
297
+ if (current.production !== desiredProduction) {
298
+ // A keyspace can report `resizing: false` while the resize
299
+ // workflow is still finalizing, during which promote/demote is
300
+ // rejected with an UnprocessableEntity. Retry until it clears.
301
+ const retryWhileResizing = Effect.retry({
302
+ while: isResizeInProgress,
303
+ schedule: Schedule.max([Schedule.spaced("5 seconds"), Schedule.recurs(120)]),
304
+ });
305
+ current = desiredProduction
306
+ ? yield* planetscale
307
+ .promoteBranch({
308
+ organization,
309
+ database: databaseName,
310
+ branch: branchName,
311
+ })
312
+ .pipe(retryWhileResizing)
313
+ : yield* planetscale
314
+ .demoteBranch({
315
+ organization,
316
+ database: databaseName,
317
+ branch: branchName,
318
+ })
319
+ .pipe(retryWhileResizing);
320
+ }
321
+ }
322
+ // Sync safeMigrations — observed via `current.safe_migrations`,
323
+ // skip the API call entirely on no-op.
324
+ if (news.safeMigrations !== undefined && current.safe_migrations !== news.safeMigrations) {
325
+ if (news.safeMigrations) {
326
+ yield* planetscale.enableSafeMigrations({
327
+ organization,
328
+ database: databaseName,
329
+ branch: branchName,
330
+ });
331
+ }
332
+ else {
333
+ yield* planetscale.disableSafeMigrations({
334
+ organization,
335
+ database: databaseName,
336
+ branch: branchName,
337
+ });
338
+ }
339
+ }
340
+ if (opts.expectedKind === "postgresql" && news.replicas !== undefined) {
341
+ const desiredReplicas = news.replicas;
342
+ const desiredHasReplicas = desiredReplicas > 0;
343
+ const shouldApplyReplicaChange = current.has_replicas !== desiredHasReplicas ||
344
+ (desiredHasReplicas && output?.desiredReplicas !== desiredReplicas);
345
+ if (shouldApplyReplicaChange) {
346
+ yield* waitForPendingPostgresChanges(organization, databaseName, branchName);
347
+ const change = yield* planetscale.updateBranchChangeRequest({
348
+ organization,
349
+ database: databaseName,
350
+ branch: branchName,
351
+ replicas: desiredReplicas,
352
+ });
353
+ yield* waitForPendingPostgresChanges(organization, databaseName, branchName, change.id);
354
+ current = yield* planetscale.getBranch({
355
+ organization,
356
+ database: databaseName,
357
+ branch: branchName,
358
+ });
359
+ }
360
+ }
361
+ // Sync clusterSize — only meaningful on production branches.
362
+ if (news.clusterSize) {
363
+ if (current.kind === "postgresql") {
364
+ yield* ensurePostgresProductionBranchClusterSize(organization, databaseName, branchName, news.clusterSize);
365
+ }
366
+ else {
367
+ yield* ensureMySQLProductionBranchClusterSize(organization, databaseName, branchName, news.clusterSize);
368
+ }
369
+ }
370
+ // Re-read so the returned attributes reflect any mutation.
371
+ const updated = yield* planetscale.getBranch({
372
+ organization,
373
+ database: databaseName,
374
+ branch: branchName,
375
+ });
376
+ const migrationTarget = {
377
+ organization,
378
+ database: databaseName,
379
+ branch: updated.name,
380
+ };
381
+ const migrationsInput = migrationsInputOf(news);
382
+ const migrations = migrationsInput
383
+ ? yield* opts.runners.runMigrations(migrationTarget, migrationsInput, stampedOf(output))
384
+ : undefined;
385
+ const importHashes = news.importFiles?.length
386
+ ? yield* opts.runners.runImports(migrationTarget, news.importFiles, yield* rootDir, output?.importHashes ?? {})
387
+ : {};
388
+ return {
389
+ name: updated.name,
390
+ organization,
391
+ database: databaseName,
392
+ parentBranch: updated.parent_branch ?? parentBranchName,
393
+ production: updated.production,
394
+ createdAt: updated.created_at,
395
+ updatedAt: updated.updated_at,
396
+ htmlUrl: updated.html_url,
397
+ region: { slug: updated.region.slug },
398
+ ...migrationsAttrs({ input: migrationsInput, run: migrations, output }),
399
+ importHashes,
400
+ desiredReplicas: news.replicas ?? output?.desiredReplicas,
401
+ hasReplicas: updated.has_replicas,
402
+ hasReadOnlyReplicas: updated.has_read_only_replicas,
403
+ };
404
+ }),
405
+ delete: Effect.fn(function* ({ output }) {
406
+ // If `read` returned undefined (e.g. destroy of a partially-
407
+ // created branch whose props never finished persisting), there
408
+ // is nothing addressable to delete. Drop the state entry.
409
+ if (!output)
410
+ return;
411
+ yield* planetscale
412
+ .deleteBranch({
413
+ organization: output.organization,
414
+ database: output.database,
415
+ branch: output.name,
416
+ })
417
+ .pipe(Effect.catchTag("NotFound", () => Effect.void), Effect.catchIf(isKnownError("UnprocessableEntity", "The default branch cannot be deleted."), () => Effect.void));
418
+ }),
419
+ });
420
+ //# sourceMappingURL=Branch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Branch.js","sourceRoot":"","sources":["../src/Branch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,eAAe,EACf,iBAAiB,EACjB,8BAA8B,EAC9B,SAAS,GAKV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,E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/Contributions";
2
+ declare const _default: {
3
+ readonly name: "planetscale";
4
+ readonly auth: Contributions.Lazy<import("effect/Layer").Layer<never, never, import("alchemy/Auth/Registry").AuthProviders | import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/crypto/Digest").Digest | import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("effect/crypto/SecureRandom").SecureRandom>>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=Contributions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Contributions.d.ts","sourceRoot":"","sources":["../src/Contributions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,uBAAuB,CAAC;;;;;AAEvD,wBAMG"}
@@ -0,0 +1,6 @@
1
+ import * as Contributions from "alchemy/Contributions";
2
+ export default Contributions.make({
3
+ name: "planetscale",
4
+ auth: Contributions.lazy(() => import("./AuthProvider.js"), (module) => module.PlanetscaleAuth),
5
+ });
6
+ //# sourceMappingURL=Contributions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Contributions.js","sourceRoot":"","sources":["../src/Contributions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,uBAAuB,CAAC;AAEvD,eAAe,aAAa,CAAC,IAAI,CAAC;IAChC,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa,CAAC,IAAI,CACtB,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,EACjC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CACnC;CACF,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { Credentials } from "@distilled.cloud/planetscale/Credentials";
2
+ import * as Config from "effect/Config";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Redacted from "effect/Redacted";
5
+ export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, } from "@distilled.cloud/planetscale/Credentials";
6
+ /**
7
+ * Build a PlanetScale `Credentials` Layer from an explicit token. Useful for
8
+ * tests or when the caller already has credentials in hand.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * Effect.provide(
13
+ * Planetscale.fromToken({
14
+ * tokenId: "abcd1234",
15
+ * token: "api-token-secret",
16
+ * organization: "my-org",
17
+ * }),
18
+ * )
19
+ * ```
20
+ */
21
+ export declare const fromToken: (input: {
22
+ tokenId: string | Redacted.Redacted<string>;
23
+ token: string | Redacted.Redacted<string>;
24
+ organization: string;
25
+ apiBaseUrl?: string;
26
+ }) => Layer.Layer<Credentials, never, never>;
27
+ /**
28
+ * Build a PlanetScale `Credentials` Layer that resolves credentials via the
29
+ * Alchemy AuthProvider using the configured profile (defaults to "default",
30
+ * selected by the current Alchemy profile).
31
+ */
32
+ export declare const fromAuthProvider: () => Layer.Layer<Credentials, Config.ConfigError, import("alchemy/Auth/Registry").AuthProviders | import("alchemy/Auth/Profile").ProfileStore>;
33
+ //# sourceMappingURL=Credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../src/Credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EAEZ,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAM5C,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,UAAW;IAC/B,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,2CASE,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,iJAiC1B,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { ConfigError } from "@distilled.cloud/core/errors";
2
+ import { Credentials, DEFAULT_API_BASE_URL, } from "@distilled.cloud/planetscale/Credentials";
3
+ import { lazyCredentials } from "alchemy/Auth/Resolve";
4
+ import * as Config from "effect/Config";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Layer from "effect/Layer";
7
+ import * as Redacted from "effect/Redacted";
8
+ import { PLANETSCALE_AUTH_PROVIDER_NAME, } from "./AuthProvider.js";
9
+ export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, } from "@distilled.cloud/planetscale/Credentials";
10
+ /**
11
+ * Build a PlanetScale `Credentials` Layer from an explicit token. Useful for
12
+ * tests or when the caller already has credentials in hand.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * Effect.provide(
17
+ * Planetscale.fromToken({
18
+ * tokenId: "abcd1234",
19
+ * token: "api-token-secret",
20
+ * organization: "my-org",
21
+ * }),
22
+ * )
23
+ * ```
24
+ */
25
+ export const fromToken = (input) => Layer.succeed(Credentials, Effect.succeed({
26
+ tokenId: typeof input.tokenId === "string" ? Redacted.make(input.tokenId) : input.tokenId,
27
+ token: typeof input.token === "string" ? Redacted.make(input.token) : input.token,
28
+ organization: input.organization,
29
+ apiBaseUrl: input.apiBaseUrl ?? DEFAULT_API_BASE_URL,
30
+ }));
31
+ /**
32
+ * Build a PlanetScale `Credentials` Layer that resolves credentials via the
33
+ * Alchemy AuthProvider using the configured profile (defaults to "default",
34
+ * selected by the current Alchemy profile).
35
+ */
36
+ export const fromAuthProvider = () => Layer.effect(Credentials, Effect.gen(function* () {
37
+ const apiBaseUrl = yield* Config.String("PLANETSCALE_API_BASE_URL").pipe(Config.withDefault(DEFAULT_API_BASE_URL));
38
+ // Cache until shortly before the OAuth token expires (service tokens
39
+ // never expire) so a long `alchemy dev` session re-resolves — and
40
+ // thereby refreshes — the token instead of keeping the first, by then
41
+ // dead, resolution forever.
42
+ return yield* lazyCredentials()(PLANETSCALE_AUTH_PROVIDER_NAME, (creds) => creds.type === "oauth"
43
+ ? {
44
+ type: "oauth",
45
+ accessToken: creds.accessToken,
46
+ organization: creds.organization,
47
+ apiBaseUrl,
48
+ }
49
+ : {
50
+ type: "serviceToken",
51
+ tokenId: creds.tokenId,
52
+ token: creds.token,
53
+ organization: creds.organization,
54
+ apiBaseUrl,
55
+ }, {
56
+ expiresAt: (creds) => (creds.type === "oauth" ? creds.expires : undefined),
57
+ });
58
+ }));
59
+ //# sourceMappingURL=Credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../src/Credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAEL,WAAW,EACX,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,8BAA8B,GAE/B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,0CAA0C,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAKzB,EAAE,EAAE,CACH,KAAK,CAAC,OAAO,CACX,WAAW,EACX,MAAM,CAAC,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO;IACzF,KA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