@alchemy.run/planetscale 0.0.0 → 2.0.0-beta.84
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.
- package/LICENSE +201 -0
- package/README.md +83 -4
- package/lib/AuthProvider.d.ts +64 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +384 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/Branch.d.ts +128 -0
- package/lib/Branch.d.ts.map +1 -0
- package/lib/Branch.js +420 -0
- package/lib/Branch.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/Credentials.d.ts +33 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +65 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/Database.d.ts +138 -0
- package/lib/Database.d.ts.map +1 -0
- package/lib/Database.js +1 -0
- package/lib/Database.js.map +1 -0
- package/lib/MySQL/MySQLBranch.d.ts +87 -0
- package/lib/MySQL/MySQLBranch.d.ts.map +1 -0
- package/lib/MySQL/MySQLBranch.js +15 -0
- package/lib/MySQL/MySQLBranch.js.map +1 -0
- package/lib/MySQL/MySQLClusterSize.d.ts +32 -0
- package/lib/MySQL/MySQLClusterSize.d.ts.map +1 -0
- package/lib/MySQL/MySQLClusterSize.js +111 -0
- package/lib/MySQL/MySQLClusterSize.js.map +1 -0
- package/lib/MySQL/MySQLDatabase.d.ts +141 -0
- package/lib/MySQL/MySQLDatabase.d.ts.map +1 -0
- package/lib/MySQL/MySQLDatabase.js +294 -0
- package/lib/MySQL/MySQLDatabase.js.map +1 -0
- package/lib/MySQL/MySQLMigrations.d.ts +24 -0
- package/lib/MySQL/MySQLMigrations.d.ts.map +1 -0
- package/lib/MySQL/MySQLMigrations.js +106 -0
- package/lib/MySQL/MySQLMigrations.js.map +1 -0
- package/lib/MySQL/MySQLOrigin.d.ts +15 -0
- package/lib/MySQL/MySQLOrigin.d.ts.map +1 -0
- package/lib/MySQL/MySQLOrigin.js +2 -0
- package/lib/MySQL/MySQLOrigin.js.map +1 -0
- package/lib/MySQL/MySQLPassword.d.ts +116 -0
- package/lib/MySQL/MySQLPassword.d.ts.map +1 -0
- package/lib/MySQL/MySQLPassword.js +212 -0
- package/lib/MySQL/MySQLPassword.js.map +1 -0
- package/lib/MySQL/index.d.ts +6 -0
- package/lib/MySQL/index.d.ts.map +1 -0
- package/lib/MySQL/index.js +6 -0
- package/lib/MySQL/index.js.map +1 -0
- package/lib/OAuthClient.d.ts +32 -0
- package/lib/OAuthClient.d.ts.map +1 -0
- package/lib/OAuthClient.js +52 -0
- package/lib/OAuthClient.js.map +1 -0
- package/lib/Postgres/PostgresBranch.d.ts +75 -0
- package/lib/Postgres/PostgresBranch.d.ts.map +1 -0
- package/lib/Postgres/PostgresBranch.js +15 -0
- package/lib/Postgres/PostgresBranch.js.map +1 -0
- package/lib/Postgres/PostgresClusterSize.d.ts +77 -0
- package/lib/Postgres/PostgresClusterSize.d.ts.map +1 -0
- package/lib/Postgres/PostgresClusterSize.js +89 -0
- package/lib/Postgres/PostgresClusterSize.js.map +1 -0
- package/lib/Postgres/PostgresDatabase.d.ts +95 -0
- package/lib/Postgres/PostgresDatabase.d.ts.map +1 -0
- package/lib/Postgres/PostgresDatabase.js +294 -0
- package/lib/Postgres/PostgresDatabase.js.map +1 -0
- package/lib/Postgres/PostgresDefaultRole.d.ts +94 -0
- package/lib/Postgres/PostgresDefaultRole.d.ts.map +1 -0
- package/lib/Postgres/PostgresDefaultRole.js +187 -0
- package/lib/Postgres/PostgresDefaultRole.js.map +1 -0
- package/lib/Postgres/PostgresMigrations.d.ts +24 -0
- package/lib/Postgres/PostgresMigrations.d.ts.map +1 -0
- package/lib/Postgres/PostgresMigrations.js +116 -0
- package/lib/Postgres/PostgresMigrations.js.map +1 -0
- package/lib/Postgres/PostgresOrigin.d.ts +15 -0
- package/lib/Postgres/PostgresOrigin.d.ts.map +1 -0
- package/lib/Postgres/PostgresOrigin.js +2 -0
- package/lib/Postgres/PostgresOrigin.js.map +1 -0
- package/lib/Postgres/PostgresRole.d.ts +142 -0
- package/lib/Postgres/PostgresRole.d.ts.map +1 -0
- package/lib/Postgres/PostgresRole.js +268 -0
- package/lib/Postgres/PostgresRole.js.map +1 -0
- package/lib/Postgres/index.d.ts +7 -0
- package/lib/Postgres/index.d.ts.map +1 -0
- package/lib/Postgres/index.js +7 -0
- package/lib/Postgres/index.js.map +1 -0
- package/lib/Providers.d.ts +24 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +40 -0
- package/lib/Providers.js.map +1 -0
- package/lib/Util.d.ts +93 -0
- package/lib/Util.d.ts.map +1 -0
- package/lib/Util.js +135 -0
- package/lib/Util.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/package.json +79 -3
- package/src/AuthProvider.ts +571 -0
- package/src/Branch.ts +657 -0
- package/src/Contributions.ts +9 -0
- package/src/Credentials.ts +116 -0
- package/src/Database.ts +152 -0
- package/src/MySQL/MySQLBranch.ts +109 -0
- package/src/MySQL/MySQLClusterSize.ts +185 -0
- package/src/MySQL/MySQLDatabase.ts +521 -0
- package/src/MySQL/MySQLMigrations.ts +182 -0
- package/src/MySQL/MySQLOrigin.ts +15 -0
- package/src/MySQL/MySQLPassword.ts +428 -0
- package/src/MySQL/index.ts +5 -0
- package/src/OAuthClient.ts +59 -0
- package/src/Postgres/PostgresBranch.ts +97 -0
- package/src/Postgres/PostgresClusterSize.ts +262 -0
- package/src/Postgres/PostgresDatabase.ts +469 -0
- package/src/Postgres/PostgresDefaultRole.ts +340 -0
- package/src/Postgres/PostgresMigrations.ts +193 -0
- package/src/Postgres/PostgresOrigin.ts +15 -0
- package/src/Postgres/PostgresRole.ts +547 -0
- package/src/Postgres/index.ts +6 -0
- package/src/Providers.ts +67 -0
- package/src/Util.ts +205 -0
- package/src/index.ts +14 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import * as planetscale from "@distilled.cloud/planetscale";
|
|
2
|
+
import { Credentials } from "@distilled.cloud/planetscale/Credentials";
|
|
3
|
+
import { deepEqual, isResolved } from "alchemy/Diff";
|
|
4
|
+
import { createPhysicalName } from "alchemy/PhysicalName";
|
|
5
|
+
import * as Provider from "alchemy/Provider";
|
|
6
|
+
import { Resource } from "alchemy/Resource";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Redacted from "effect/Redacted";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
import { isKnownError, PlanetscaleConflict, waitForBranchReady } from "../Util.js";
|
|
11
|
+
/** @resource */
|
|
12
|
+
export const PostgresRole = Resource("Planetscale.PostgresRole");
|
|
13
|
+
export const PostgresRoleProvider = () => Provider.succeed(PostgresRole, {
|
|
14
|
+
stables: ["id"],
|
|
15
|
+
diff: Effect.fn(function* ({ id, news, olds, output }) {
|
|
16
|
+
if (!isResolved(news))
|
|
17
|
+
return undefined;
|
|
18
|
+
// Successor is the only updatable property — everything else
|
|
19
|
+
// requires replacement.
|
|
20
|
+
if (news.ttl !== olds.ttl) {
|
|
21
|
+
return { action: "replace" };
|
|
22
|
+
}
|
|
23
|
+
const newDb = resolveDatabaseName(news.database);
|
|
24
|
+
const oldDb = olds.database ? resolveDatabaseName(olds.database) : undefined;
|
|
25
|
+
if (oldDb && newDb !== oldDb) {
|
|
26
|
+
return { action: "replace" };
|
|
27
|
+
}
|
|
28
|
+
const newBranch = resolveBranchName(news.branch);
|
|
29
|
+
const oldBranch = resolveBranchName(olds.branch);
|
|
30
|
+
if (newBranch !== oldBranch) {
|
|
31
|
+
return { action: "replace" };
|
|
32
|
+
}
|
|
33
|
+
const newRoles = [...resolveInheritedRoles(news.inheritedRoles)].sort();
|
|
34
|
+
const oldRoles = [...(output?.inheritedRoles ?? [])].sort();
|
|
35
|
+
if (!deepEqual(newRoles, oldRoles)) {
|
|
36
|
+
return { action: "replace" };
|
|
37
|
+
}
|
|
38
|
+
if ((news.withReplication ?? false) !== (output?.withReplication ?? false)) {
|
|
39
|
+
return { action: "replace" };
|
|
40
|
+
}
|
|
41
|
+
const oldName = output?.name ?? (yield* resolveName(id, olds?.name));
|
|
42
|
+
const newName = yield* resolveName(id, news.name);
|
|
43
|
+
if (newName !== oldName) {
|
|
44
|
+
return { action: "update" };
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}),
|
|
48
|
+
read: Effect.fn(function* ({ output }) {
|
|
49
|
+
if (!output?.id)
|
|
50
|
+
return undefined;
|
|
51
|
+
return yield* planetscale
|
|
52
|
+
.getRole({
|
|
53
|
+
branch: output.branch,
|
|
54
|
+
database: output.database,
|
|
55
|
+
organization: output.organization,
|
|
56
|
+
id: output.id,
|
|
57
|
+
})
|
|
58
|
+
.pipe(Effect.map((token) => buildAttributes(token, output.password, {
|
|
59
|
+
inheritedRoles: token.inherited_roles,
|
|
60
|
+
successor: output.successor,
|
|
61
|
+
organization: output.organization,
|
|
62
|
+
database: output.database,
|
|
63
|
+
branch: token.branch.name,
|
|
64
|
+
})), Effect.catchTags({
|
|
65
|
+
Forbidden: () => Effect.succeed(undefined),
|
|
66
|
+
NotFound: () => Effect.succeed(undefined),
|
|
67
|
+
}));
|
|
68
|
+
}),
|
|
69
|
+
reconcile: Effect.fn(function* ({ id, news, output }) {
|
|
70
|
+
const { organization: envOrg } = yield* yield* Credentials;
|
|
71
|
+
const organization = resolveDatabaseOrg(news.database) ?? envOrg;
|
|
72
|
+
const databaseName = resolveDatabaseName(news.database);
|
|
73
|
+
const branchName = resolveBranchName(news.branch);
|
|
74
|
+
const inheritedRoles = resolveInheritedRoles(news.inheritedRoles);
|
|
75
|
+
const successor = resolveSuccessorName(news.successor);
|
|
76
|
+
const desiredName = yield* resolveName(id, news.name);
|
|
77
|
+
// 1. Observe — fetch live state if we know the role id. Roles
|
|
78
|
+
// can only be looked up by id; without a cached id there is
|
|
79
|
+
// no way to find the live role, so we fall through to ensure.
|
|
80
|
+
const observed = output?.id
|
|
81
|
+
? yield* planetscale
|
|
82
|
+
.getRole({
|
|
83
|
+
id: output.id,
|
|
84
|
+
branch: branchName,
|
|
85
|
+
organization,
|
|
86
|
+
database: databaseName,
|
|
87
|
+
})
|
|
88
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.succeed(undefined)))
|
|
89
|
+
: undefined;
|
|
90
|
+
// 2. Ensure — create if missing. Single branch covers both
|
|
91
|
+
// greenfield (no output) and out-of-band-deletion (output
|
|
92
|
+
// cached but cloud lost it). The latter is structurally a
|
|
93
|
+
// rotation: the new role has fresh id/host/username/plaintext
|
|
94
|
+
// that propagate downstream through the dependency graph.
|
|
95
|
+
// There is no path to recover the original plaintext, so
|
|
96
|
+
// recreating is the only way to converge.
|
|
97
|
+
//
|
|
98
|
+
// Planetscale returns the plaintext password value exactly
|
|
99
|
+
// once on create; on an observe-hit we re-use the cached
|
|
100
|
+
// plaintext from output (which is why adoption requires
|
|
101
|
+
// pre-existing state — see `read`).
|
|
102
|
+
let live;
|
|
103
|
+
let plaintext;
|
|
104
|
+
if (observed) {
|
|
105
|
+
live = observed;
|
|
106
|
+
plaintext = output.password;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const branchInfo = yield* planetscale.getBranch({
|
|
110
|
+
organization,
|
|
111
|
+
database: databaseName,
|
|
112
|
+
branch: branchName,
|
|
113
|
+
});
|
|
114
|
+
if (branchInfo.kind !== "postgresql") {
|
|
115
|
+
return yield* new PlanetscaleConflict({
|
|
116
|
+
message: `Cannot create a Role on MySQL database "${databaseName}". Roles are only supported on PostgreSQL. Use Password for MySQL.`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!branchInfo.ready) {
|
|
120
|
+
yield* waitForBranchReady(organization, databaseName, branchName);
|
|
121
|
+
}
|
|
122
|
+
const created = yield* planetscale.createRole({
|
|
123
|
+
name: desiredName,
|
|
124
|
+
branch: branchName,
|
|
125
|
+
organization,
|
|
126
|
+
database: databaseName,
|
|
127
|
+
ttl: news.ttl,
|
|
128
|
+
inherited_roles: inheritedRoles,
|
|
129
|
+
with_replication: news.withReplication,
|
|
130
|
+
});
|
|
131
|
+
if (!created.password) {
|
|
132
|
+
return yield* Effect.die(`Planetscale did not return a password for Role "${desiredName}".`);
|
|
133
|
+
}
|
|
134
|
+
plaintext = created.password;
|
|
135
|
+
live = created;
|
|
136
|
+
}
|
|
137
|
+
// 3. Sync — only `name` is mutable in place; diff observed
|
|
138
|
+
// against desired and skip the API call when nothing
|
|
139
|
+
// changed. Everything else triggers a replace via diff().
|
|
140
|
+
if (live.name !== desiredName) {
|
|
141
|
+
live = yield* planetscale.updateRole({
|
|
142
|
+
id: live.id,
|
|
143
|
+
branch: branchName,
|
|
144
|
+
organization,
|
|
145
|
+
database: databaseName,
|
|
146
|
+
name: desiredName,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// 4. Return — fresh attrs sourced from observed cloud state,
|
|
150
|
+
// with cached or freshly-issued plaintext.
|
|
151
|
+
return buildAttributes(live, plaintext, {
|
|
152
|
+
inheritedRoles: live.inherited_roles,
|
|
153
|
+
successor,
|
|
154
|
+
organization,
|
|
155
|
+
database: databaseName,
|
|
156
|
+
branch: branchName,
|
|
157
|
+
});
|
|
158
|
+
}),
|
|
159
|
+
delete: Effect.fn(function* ({ output }) {
|
|
160
|
+
yield* planetscale
|
|
161
|
+
.deleteRole({
|
|
162
|
+
organization: output.organization,
|
|
163
|
+
database: output.database,
|
|
164
|
+
branch: output.branch,
|
|
165
|
+
id: output.id,
|
|
166
|
+
successor: output.successor,
|
|
167
|
+
})
|
|
168
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.void),
|
|
169
|
+
// 422 (UnprocessableEntity): role is still referenced. Log a
|
|
170
|
+
// warning rather than failing — the role will be cleaned up
|
|
171
|
+
// when the database/branch is deleted.
|
|
172
|
+
Effect.catchIf(isKnownError("UnprocessableEntity", "Role is still referenced and cannot be dropped."), () => Effect.void));
|
|
173
|
+
}),
|
|
174
|
+
list: Effect.fn(function* () {
|
|
175
|
+
const { organization } = yield* yield* Credentials;
|
|
176
|
+
const databases = yield* planetscale.listDatabases.pages({ organization }).pipe(Stream.runCollect, Effect.map((chunk) => Array.from(chunk).flatMap((page) => page.data.filter((db) => db.kind === "postgresql"))));
|
|
177
|
+
const rows = yield* Effect.forEach(databases, (db) => planetscale.listBranches.pages({ organization, database: db.name }).pipe(Stream.runCollect, Effect.map((branchPages) => Array.from(branchPages).flatMap((page) => page.data.filter((branch) => branch.kind === "postgresql"))), Effect.catchTag("NotFound", () => Effect.succeed([{ name: db.default_branch ?? "main" }])), Effect.flatMap((branches) => Effect.forEach(branches, (branch) => planetscale.listRoles
|
|
178
|
+
.pages({
|
|
179
|
+
organization,
|
|
180
|
+
database: db.name,
|
|
181
|
+
branch: branch.name,
|
|
182
|
+
})
|
|
183
|
+
.pipe(Stream.runCollect, Effect.map((rolePages) => Array.from(rolePages).flatMap((page) => page.data
|
|
184
|
+
.filter((role) => !role.default)
|
|
185
|
+
.map((role) => buildAttributes(role, Redacted.make(""), {
|
|
186
|
+
inheritedRoles: role.inherited_roles,
|
|
187
|
+
successor: "postgres",
|
|
188
|
+
organization,
|
|
189
|
+
database: db.name,
|
|
190
|
+
branch: branch.name,
|
|
191
|
+
})))), Effect.catchTags({
|
|
192
|
+
NotFound: () => Effect.succeed([]),
|
|
193
|
+
Forbidden: () => Effect.succeed([]),
|
|
194
|
+
})), { concurrency: 10 }).pipe(Effect.map((perBranch) => perBranch.flat())))), { concurrency: 10 });
|
|
195
|
+
return rows.flat();
|
|
196
|
+
}),
|
|
197
|
+
});
|
|
198
|
+
const resolveDatabaseName = (database) => {
|
|
199
|
+
const ref = database;
|
|
200
|
+
return typeof ref === "string" ? ref : ref.name;
|
|
201
|
+
};
|
|
202
|
+
const resolveDatabaseOrg = (database) => {
|
|
203
|
+
const ref = database;
|
|
204
|
+
return typeof ref === "string" ? undefined : ref.organization;
|
|
205
|
+
};
|
|
206
|
+
const resolveBranchName = (branch) => {
|
|
207
|
+
const ref = branch;
|
|
208
|
+
return !ref ? "main" : typeof ref === "string" ? ref : ref.name;
|
|
209
|
+
};
|
|
210
|
+
const resolveSuccessorName = (successor) => {
|
|
211
|
+
const ref = successor;
|
|
212
|
+
return !ref ? "postgres" : typeof ref === "string" ? ref : ref.name;
|
|
213
|
+
};
|
|
214
|
+
const resolveInheritedRoles = (inheritedRoles) => {
|
|
215
|
+
if (Array.isArray(inheritedRoles)) {
|
|
216
|
+
return inheritedRoles;
|
|
217
|
+
}
|
|
218
|
+
// At runtime, a Role passed in is its resolved attributes (with
|
|
219
|
+
// `inheritedRoles` as a plain array); statically `Role.inheritedRoles`
|
|
220
|
+
// is `Output<InheritedRole[]>`.
|
|
221
|
+
return inheritedRoles
|
|
222
|
+
.inheritedRoles;
|
|
223
|
+
};
|
|
224
|
+
const resolveName = (id, name) => Effect.gen(function* () {
|
|
225
|
+
return name ?? (yield* createPhysicalName({ id, lowercase: true, maxLength: 63 }));
|
|
226
|
+
});
|
|
227
|
+
const buildAttributes = (role, password, context) => {
|
|
228
|
+
const passwordValue = Redacted.value(password);
|
|
229
|
+
const connectionUrl = `postgresql://${role.username}:${passwordValue}@${role.access_host_url}:5432/${role.database_name}?sslmode=verify-full`;
|
|
230
|
+
const connectionUrlPooled = `postgresql://${role.username}:${passwordValue}@${role.access_host_url}:6432/${role.database_name}?sslmode=verify-full`;
|
|
231
|
+
return {
|
|
232
|
+
id: role.id,
|
|
233
|
+
name: role.name,
|
|
234
|
+
expiresAt: role.expires_at,
|
|
235
|
+
host: role.access_host_url,
|
|
236
|
+
username: role.username,
|
|
237
|
+
password,
|
|
238
|
+
connectionUrl: Redacted.make(connectionUrl),
|
|
239
|
+
connectionUrlPooled: Redacted.make(connectionUrlPooled),
|
|
240
|
+
privateHost: role.private_access_host_url,
|
|
241
|
+
privateConnectionServiceName: role.private_connection_service_name,
|
|
242
|
+
inheritedRoles: context.inheritedRoles,
|
|
243
|
+
withReplication: role.with_replication,
|
|
244
|
+
successor: context.successor,
|
|
245
|
+
organization: context.organization,
|
|
246
|
+
database: context.database,
|
|
247
|
+
databaseName: role.database_name,
|
|
248
|
+
origin: {
|
|
249
|
+
scheme: "postgres",
|
|
250
|
+
host: role.access_host_url,
|
|
251
|
+
port: 5432,
|
|
252
|
+
database: role.database_name,
|
|
253
|
+
user: role.username,
|
|
254
|
+
password,
|
|
255
|
+
},
|
|
256
|
+
pooledOrigin: {
|
|
257
|
+
scheme: "postgres",
|
|
258
|
+
host: role.access_host_url,
|
|
259
|
+
port: 6432,
|
|
260
|
+
database: role.database_name,
|
|
261
|
+
user: role.username,
|
|
262
|
+
password,
|
|
263
|
+
},
|
|
264
|
+
branch: context.branch,
|
|
265
|
+
ttl: role.ttl,
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
//# sourceMappingURL=PostgresRole.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresRole.js","sourceRoot":"","sources":["../../src/Postgres/PostgresRole.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB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,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;QAC3C,mBAAmB,EAAE,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC;QACvD,WAAW,EAAE,IAAI,CAAC,uBAAuB;QACzC,4BAA4B,EAAE,IAAI,CAAC,+BAA+B;QAClE,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,eAAe,EAAE,IAAI,CAAC,gBAAgB;QACtC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,YAAY,EAAE,IAAI,CAAC,aAAa;QAChC,MAAM,EAAE;YACN,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,IAAI,CAAC,eAAe;YAC1B,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,IAAI,CAAC,aAAa;YAC5B,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,QAAQ;SACT;QACD,YAAY,EAAE;YACZ,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,IAAI,CAAC,eAAe;YAC1B,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,IAAI,CAAC,aAAa;YAC5B,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,QAAQ;SACT;QACD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./PostgresClusterSize.ts";
|
|
2
|
+
export * from "./PostgresBranch.ts";
|
|
3
|
+
export * from "./PostgresDatabase.ts";
|
|
4
|
+
export * from "./PostgresDefaultRole.ts";
|
|
5
|
+
export * from "./PostgresOrigin.ts";
|
|
6
|
+
export * from "./PostgresRole.ts";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Postgres/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./PostgresClusterSize.js";
|
|
2
|
+
export * from "./PostgresBranch.js";
|
|
3
|
+
export * from "./PostgresDatabase.js";
|
|
4
|
+
export * from "./PostgresDefaultRole.js";
|
|
5
|
+
export * from "./PostgresOrigin.js";
|
|
6
|
+
export * from "./PostgresRole.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Postgres/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as Provider from "alchemy/Provider";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Credentials from "./Credentials.ts";
|
|
4
|
+
declare const Providers_base: Provider.ProviderCollection<Providers, "Planetscale">;
|
|
5
|
+
/**
|
|
6
|
+
* Service tag bundling all PlanetScale providers + auth + credentials. Use
|
|
7
|
+
* `Planetscale.providers()` to materialize the full layer.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Providers extends Providers_base {
|
|
10
|
+
}
|
|
11
|
+
export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>;
|
|
12
|
+
/**
|
|
13
|
+
* Build the complete PlanetScale providers Layer. Provide this on a Stack
|
|
14
|
+
* (or via `Effect.provide` at test time) to enable all PlanetScale
|
|
15
|
+
* resources, the AuthProvider registration, and credential resolution.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* Effect.provide(Planetscale.providers())
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const providers: () => Layer.Layer<Credentials.Credentials | import("alchemy/Auth/Credentials").CredentialsStore | import("effect/http/HttpClient").HttpClient | import("alchemy/Auth/Profile").ProfileStore | Providers, never, import("alchemy/Auth/AuthProvider").AuthProviders | import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/Crypto").Crypto | import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("alchemy/Stack").Stack | import("alchemy/Stage").Stage>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Providers.d.ts","sourceRoot":"","sources":["../src/Providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;;AAYhD;;;GAGG;AACH,qBAAa,SAAU,SAAQ,cAAuD;CAAG;AAEzF,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;AAEhF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,8eA8BnB,CAAC"}
|
package/lib/Providers.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CredentialsStoreLive } from "alchemy/Auth/Credentials";
|
|
2
|
+
import { ProfileStoreLive } from "alchemy/Auth/Profile";
|
|
3
|
+
import * as Provider from "alchemy/Provider";
|
|
4
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import { PlanetscaleAuth } from "./AuthProvider.js";
|
|
7
|
+
import * as Credentials from "./Credentials.js";
|
|
8
|
+
import { MySQLBranch, MySQLBranchProvider } from "./MySQL/MySQLBranch.js";
|
|
9
|
+
import { MySQLDatabase, MySQLDatabaseProvider } from "./MySQL/MySQLDatabase.js";
|
|
10
|
+
import { MySQLPassword, MySQLPasswordProvider } from "./MySQL/MySQLPassword.js";
|
|
11
|
+
import { PostgresBranch, PostgresBranchProvider } from "./Postgres/PostgresBranch.js";
|
|
12
|
+
import { PostgresDatabase, PostgresDatabaseProvider } from "./Postgres/PostgresDatabase.js";
|
|
13
|
+
import { PostgresDefaultRole, PostgresDefaultRoleProvider, } from "./Postgres/PostgresDefaultRole.js";
|
|
14
|
+
import { PostgresRole, PostgresRoleProvider } from "./Postgres/PostgresRole.js";
|
|
15
|
+
/**
|
|
16
|
+
* Service tag bundling all PlanetScale providers + auth + credentials. Use
|
|
17
|
+
* `Planetscale.providers()` to materialize the full layer.
|
|
18
|
+
*/
|
|
19
|
+
export class Providers extends Provider.ProviderCollection()("Planetscale") {
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build the complete PlanetScale providers Layer. Provide this on a Stack
|
|
23
|
+
* (or via `Effect.provide` at test time) to enable all PlanetScale
|
|
24
|
+
* resources, the AuthProvider registration, and credential resolution.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* Effect.provide(Planetscale.providers())
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const providers = () => Layer.effect(Providers, Provider.collection([
|
|
32
|
+
MySQLDatabase,
|
|
33
|
+
PostgresDatabase,
|
|
34
|
+
MySQLBranch,
|
|
35
|
+
PostgresBranch,
|
|
36
|
+
MySQLPassword,
|
|
37
|
+
PostgresRole,
|
|
38
|
+
PostgresDefaultRole,
|
|
39
|
+
])).pipe(Layer.provide(Layer.mergeAll(MySQLDatabaseProvider(), PostgresDatabaseProvider(), MySQLBranchProvider(), PostgresBranchProvider(), MySQLPasswordProvider(), PostgresRoleProvider(), PostgresDefaultRoleProvider())), Layer.provideMerge(Credentials.fromAuthProvider()), Layer.provideMerge(FetchHttpClient.layer), Layer.provideMerge(PlanetscaleAuth), Layer.provideMerge(ProfileStoreLive), Layer.provideMerge(CredentialsStoreLive), Layer.orDie);
|
|
40
|
+
//# sourceMappingURL=Providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Providers.js","sourceRoot":"","sources":["../src/Providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,QAAQ,CAAC,kBAAkB,EAAa,CAAC,aAAa,CAAC;CAAG;AAIzF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAC5B,KAAK,CAAC,MAAM,CACV,SAAS,EACT,QAAQ,CAAC,UAAU,CAAC;IAClB,aAAa;IACb,gBAAgB;IAChB,WAAW;IACX,cAAc;IACd,aAAa;IACb,YAAY;IACZ,mBAAmB;CACpB,CAAC,CACH,CAAC,IAAI,CACJ,KAAK,CAAC,OAAO,CACX,KAAK,CAAC,QAAQ,CACZ,qBAAqB,EAAE,EACvB,wBAAwB,EAAE,EAC1B,mBAAmB,EAAE,EACrB,sBAAsB,EAAE,EACxB,qBAAqB,EAAE,EACvB,oBAAoB,EAAE,EACtB,2BAA2B,EAAE,CAC9B,CACF,EACD,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,EAClD,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,EACzC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,EACnC,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,EACpC,KAAK,CAAC,YAAY,CAAC,oBAAoB,CAAC,EACxC,KAAK,CAAC,KAAK,CACZ,CAAC"}
|
package/lib/Util.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as ps from "@distilled.cloud/planetscale";
|
|
2
|
+
import type { ScopedPlanStatusSession } from "alchemy/Report";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schedule from "effect/Schedule";
|
|
5
|
+
declare const NotReady_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly _tag: "Planetscale::NotReady";
|
|
7
|
+
} & Readonly<A>;
|
|
8
|
+
/**
|
|
9
|
+
* Tagged error raised when polling for a state predicate that has not yet
|
|
10
|
+
* been reached. Used internally with `Effect.retry` to drive long-running
|
|
11
|
+
* status waits.
|
|
12
|
+
*/
|
|
13
|
+
export declare class NotReady extends NotReady_base<{
|
|
14
|
+
description: string;
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
declare const PlanetscaleConflict_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
18
|
+
readonly _tag: "Planetscale::Conflict";
|
|
19
|
+
} & Readonly<A>;
|
|
20
|
+
/**
|
|
21
|
+
* Tagged error raised by reconcilers when an immutable property of a live
|
|
22
|
+
* PlanetScale resource does not match the desired configuration (e.g.
|
|
23
|
+
* region, kind, parent_branch). User-recoverable: change the config to
|
|
24
|
+
* match, or replace/delete the existing resource and retry.
|
|
25
|
+
*/
|
|
26
|
+
export declare class PlanetscaleConflict extends PlanetscaleConflict_base<{
|
|
27
|
+
message: string;
|
|
28
|
+
}> {
|
|
29
|
+
}
|
|
30
|
+
declare const PlanetscaleDeletionProtected_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
31
|
+
readonly _tag: "Planetscale::DeletionProtected";
|
|
32
|
+
} & Readonly<A>;
|
|
33
|
+
/**
|
|
34
|
+
* Tagged error raised when deleting a database that has deletion
|
|
35
|
+
* protection enabled. Alchemy never turns protection off on its own:
|
|
36
|
+
* set `deletionProtection: false`, deploy, then delete.
|
|
37
|
+
*/
|
|
38
|
+
export declare class PlanetscaleDeletionProtected extends PlanetscaleDeletionProtected_base<{
|
|
39
|
+
message: string;
|
|
40
|
+
organization: string;
|
|
41
|
+
database: string;
|
|
42
|
+
}> {
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Deletes a database unless it has deletion protection enabled, in which
|
|
46
|
+
* case it fails with {@link PlanetscaleDeletionProtected}. A database that
|
|
47
|
+
* no longer exists counts as deleted.
|
|
48
|
+
*/
|
|
49
|
+
export declare const deleteUnprotectedDatabase: (organization: string, database: string) => Effect.Effect<undefined, ps.BadGateway | ps.BadRequest | ps.ConfigError | ps.Conflict | ps.Forbidden | ps.Services.planetscale.Forbidden | ps.GatewayTimeout | import("effect/http/HttpClientError").HttpClientError | ps.InternalServerError | ps.Locked | ps.PlanetScaleParseError | PlanetscaleDeletionProtected | ps.ServiceUnavailable | ps.TooManyRequests | ps.Unauthorized | ps.UnknownPlanetScaleError | ps.UnprocessableEntity | ps.Services.planetscale.UnprocessableEntity, ps.PlanetScaleOpContext>;
|
|
50
|
+
/**
|
|
51
|
+
* Plans a database replacement. A replacement creates the new database
|
|
52
|
+
* before deleting the old one, so an explicit `name` that stays the same
|
|
53
|
+
* would make both generations the same database: reconcile would converge
|
|
54
|
+
* onto the old database and the cleanup of the old generation would then
|
|
55
|
+
* delete it. That plan fails with {@link PlanetscaleConflict} instead.
|
|
56
|
+
*/
|
|
57
|
+
export declare const replaceDatabase: (news: {
|
|
58
|
+
name?: string;
|
|
59
|
+
}, output: {
|
|
60
|
+
name: string;
|
|
61
|
+
} | undefined, change: string) => Effect.Effect<never, PlanetscaleConflict, never> | Effect.Effect<{
|
|
62
|
+
readonly action: "replace";
|
|
63
|
+
}, never, never>;
|
|
64
|
+
/**
|
|
65
|
+
* Generic polling helper that retries until `predicate(value)` returns true
|
|
66
|
+
* (or until the schedule is exhausted). Engine-specific helpers (e.g.
|
|
67
|
+
* `waitForKeyspaceReady`, `waitForPendingPostgresChanges`) are built on top
|
|
68
|
+
* of this primitive.
|
|
69
|
+
*/
|
|
70
|
+
export declare const pollUntil: <A, E, R>(description: string, fn: Effect.Effect<A, E, R>, predicate: (value: A) => boolean, schedule?: Schedule.Schedule<unknown, unknown, never>) => Effect.Effect<A, E, R>;
|
|
71
|
+
/**
|
|
72
|
+
* Polls a branch via `getBranch` until it reports `ready === true`. Returns
|
|
73
|
+
* the final branch shape. `NotFound` during polling is treated as
|
|
74
|
+
* not-yet-ready (the branch is being provisioned by an upstream operation).
|
|
75
|
+
*
|
|
76
|
+
* If a `session` is supplied, each poll emits a note with elapsed seconds and
|
|
77
|
+
* expectation-setting so the CLI surfaces progress while we sit in the spaced
|
|
78
|
+
* retry loop.
|
|
79
|
+
*/
|
|
80
|
+
export declare const waitForBranchReady: (organization: string, database: string, branch: string, session?: ScopedPlanStatusSession | undefined) => Effect.Effect<ps.DatabaseBranch, ps.BadGateway | ps.BadRequest | ps.ConfigError | ps.Conflict | ps.Forbidden | ps.Services.planetscale.Forbidden | ps.GatewayTimeout | import("effect/http/HttpClientError").HttpClientError | ps.InternalServerError | ps.Locked | NotReady | ps.PlanetScaleParseError | ps.ServiceUnavailable | ps.TooManyRequests | ps.Unauthorized | ps.UnknownPlanetScaleError | ps.UnprocessableEntity | ps.Services.planetscale.UnprocessableEntity, ps.PlanetScaleOpContext>;
|
|
81
|
+
/**
|
|
82
|
+
* Polls a database via `getDatabase` until it reports `ready === true`.
|
|
83
|
+
* `NotFound` during polling is treated as not-yet-ready (the database is
|
|
84
|
+
* being provisioned by an upstream operation).
|
|
85
|
+
*
|
|
86
|
+
* If a `session` is supplied, each poll emits a note with elapsed seconds and
|
|
87
|
+
* expectation-setting so the CLI surfaces progress while we sit in the spaced
|
|
88
|
+
* retry loop.
|
|
89
|
+
*/
|
|
90
|
+
export declare const waitForDatabaseReady: (organization: string, database: string, session?: ScopedPlanStatusSession | undefined) => Effect.Effect<ps.Database, ps.BadGateway | ps.BadRequest | ps.ConfigError | ps.Conflict | ps.Forbidden | ps.Services.planetscale.Forbidden | ps.GatewayTimeout | import("effect/http/HttpClientError").HttpClientError | ps.InternalServerError | ps.Locked | NotReady | ps.PlanetScaleParseError | ps.ServiceUnavailable | ps.TooManyRequests | ps.Unauthorized | ps.UnknownPlanetScaleError | ps.UnprocessableEntity | ps.Services.planetscale.UnprocessableEntity, ps.PlanetScaleOpContext>;
|
|
91
|
+
export declare const isKnownError: (tag: string, message: string) => (error: unknown) => boolean;
|
|
92
|
+
export {};
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AAC,EAAE,CAAC,EAAE,CAAC,CAUK,CAAC;AAE9B;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,ilBAyB7B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,2jBA4B/B,CAAC;AAEH,eAAO,MAAM,YAAY,QAAS,MAAM,WAAW,MAAM,aAAa,OAAO,YAId,CAAC"}
|
package/lib/Util.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as ps from "@distilled.cloud/planetscale";
|
|
2
|
+
import * as Clock from "effect/Clock";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schedule from "effect/Schedule";
|
|
6
|
+
/**
|
|
7
|
+
* Tagged error raised when polling for a state predicate that has not yet
|
|
8
|
+
* been reached. Used internally with `Effect.retry` to drive long-running
|
|
9
|
+
* status waits.
|
|
10
|
+
*/
|
|
11
|
+
export class NotReady extends Data.TaggedError("Planetscale::NotReady") {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tagged error raised by reconcilers when an immutable property of a live
|
|
15
|
+
* PlanetScale resource does not match the desired configuration (e.g.
|
|
16
|
+
* region, kind, parent_branch). User-recoverable: change the config to
|
|
17
|
+
* match, or replace/delete the existing resource and retry.
|
|
18
|
+
*/
|
|
19
|
+
export class PlanetscaleConflict extends Data.TaggedError("Planetscale::Conflict") {
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Tagged error raised when deleting a database that has deletion
|
|
23
|
+
* protection enabled. Alchemy never turns protection off on its own:
|
|
24
|
+
* set `deletionProtection: false`, deploy, then delete.
|
|
25
|
+
*/
|
|
26
|
+
export class PlanetscaleDeletionProtected extends Data.TaggedError("Planetscale::DeletionProtected") {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a database unless it has deletion protection enabled, in which
|
|
30
|
+
* case it fails with {@link PlanetscaleDeletionProtected}. A database that
|
|
31
|
+
* no longer exists counts as deleted.
|
|
32
|
+
*/
|
|
33
|
+
export const deleteUnprotectedDatabase = Effect.fn(function* (organization, database) {
|
|
34
|
+
const live = yield* ps
|
|
35
|
+
.getDatabase({ organization, database })
|
|
36
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.succeed(undefined)));
|
|
37
|
+
if (!live)
|
|
38
|
+
return;
|
|
39
|
+
if (live.deletion_protected) {
|
|
40
|
+
return yield* new PlanetscaleDeletionProtected({
|
|
41
|
+
message: `Planetscale database "${database}" has deletion protection enabled. ` +
|
|
42
|
+
"Set `deletionProtection: false` and deploy before deleting it. " +
|
|
43
|
+
"If it is the old database of a replacement, the resource now " +
|
|
44
|
+
"manages the new database, so turn protection off on this one in " +
|
|
45
|
+
"PlanetScale directly, then deploy again.",
|
|
46
|
+
organization,
|
|
47
|
+
database,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
yield* ps
|
|
51
|
+
.deleteDatabase({ organization, database })
|
|
52
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Plans a database replacement. A replacement creates the new database
|
|
56
|
+
* before deleting the old one, so an explicit `name` that stays the same
|
|
57
|
+
* would make both generations the same database: reconcile would converge
|
|
58
|
+
* onto the old database and the cleanup of the old generation would then
|
|
59
|
+
* delete it. That plan fails with {@link PlanetscaleConflict} instead.
|
|
60
|
+
*/
|
|
61
|
+
export const replaceDatabase = (news, output, change) => news.name !== undefined && news.name === output?.name
|
|
62
|
+
? Effect.fail(new PlanetscaleConflict({
|
|
63
|
+
message: `Changing the ${change} of Planetscale database "${news.name}" ` +
|
|
64
|
+
"requires a new database, but its explicit `name` is unchanged. " +
|
|
65
|
+
"Give the replacement a different `name`, or omit `name` to let " +
|
|
66
|
+
"Alchemy generate one.",
|
|
67
|
+
}))
|
|
68
|
+
: Effect.succeed({ action: "replace" });
|
|
69
|
+
/**
|
|
70
|
+
* Default polling schedule: 5s spaced retries with a 30-minute total
|
|
71
|
+
* budget (360 × 5s). Avoids the exponential-blowup trap where later
|
|
72
|
+
* iterations would wait hours, indistinguishable from a hang. Postgres
|
|
73
|
+
* database creates routinely run 10-12 minutes, so a 10-minute budget
|
|
74
|
+
* regularly false-positives as "stuck".
|
|
75
|
+
*/
|
|
76
|
+
const defaultSchedule = Schedule.max([Schedule.spaced("5 seconds"), Schedule.recurs(360)]);
|
|
77
|
+
/**
|
|
78
|
+
* Generic polling helper that retries until `predicate(value)` returns true
|
|
79
|
+
* (or until the schedule is exhausted). Engine-specific helpers (e.g.
|
|
80
|
+
* `waitForKeyspaceReady`, `waitForPendingPostgresChanges`) are built on top
|
|
81
|
+
* of this primitive.
|
|
82
|
+
*/
|
|
83
|
+
export const pollUntil = (description, fn, predicate, schedule = defaultSchedule) =>
|
|
84
|
+
// oxlint-disable-next-line effecttsgo/unsafe-effect-type-assertion -- NotReady only escapes once the poll schedule is exhausted
|
|
85
|
+
fn.pipe(Effect.flatMap((value) => predicate(value) ? Effect.succeed(value) : Effect.fail(new NotReady({ description }))), Effect.retry({
|
|
86
|
+
while: (e) => e?._tag === "Planetscale::NotReady",
|
|
87
|
+
schedule,
|
|
88
|
+
}));
|
|
89
|
+
/**
|
|
90
|
+
* Polls a branch via `getBranch` until it reports `ready === true`. Returns
|
|
91
|
+
* the final branch shape. `NotFound` during polling is treated as
|
|
92
|
+
* not-yet-ready (the branch is being provisioned by an upstream operation).
|
|
93
|
+
*
|
|
94
|
+
* If a `session` is supplied, each poll emits a note with elapsed seconds and
|
|
95
|
+
* expectation-setting so the CLI surfaces progress while we sit in the spaced
|
|
96
|
+
* retry loop.
|
|
97
|
+
*/
|
|
98
|
+
export const waitForBranchReady = Effect.fn(function* (organization, database, branch, session) {
|
|
99
|
+
const startedAt = yield* Clock.currentTimeMillis;
|
|
100
|
+
return yield* pollUntil(`branch "${branch}" ready`, Effect.gen(function* () {
|
|
101
|
+
if (session) {
|
|
102
|
+
const now = yield* Clock.currentTimeMillis;
|
|
103
|
+
const seconds = Math.floor((now - startedAt) / 1000);
|
|
104
|
+
yield* session.note(`Waiting for branch to be ready... (${seconds} seconds elapsed; this can take a few minutes)`);
|
|
105
|
+
}
|
|
106
|
+
return yield* ps.getBranch({ organization, database, branch });
|
|
107
|
+
}).pipe(Effect.catchTag("NotFound", () => Effect.fail(new NotReady({ description: `branch "${branch}" not found yet` })))), (data) => data.ready);
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Polls a database via `getDatabase` until it reports `ready === true`.
|
|
111
|
+
* `NotFound` during polling is treated as not-yet-ready (the database is
|
|
112
|
+
* being provisioned by an upstream operation).
|
|
113
|
+
*
|
|
114
|
+
* If a `session` is supplied, each poll emits a note with elapsed seconds and
|
|
115
|
+
* expectation-setting so the CLI surfaces progress while we sit in the spaced
|
|
116
|
+
* retry loop.
|
|
117
|
+
*/
|
|
118
|
+
export const waitForDatabaseReady = Effect.fn(function* (organization, database, session) {
|
|
119
|
+
const startedAt = yield* Clock.currentTimeMillis;
|
|
120
|
+
return yield* pollUntil(`database "${database}" ready`, Effect.gen(function* () {
|
|
121
|
+
if (session) {
|
|
122
|
+
const now = yield* Clock.currentTimeMillis;
|
|
123
|
+
const seconds = Math.floor((now - startedAt) / 1000);
|
|
124
|
+
yield* session.note(`Waiting for database to be ready... (${seconds} seconds elapsed; this can take a few minutes)`);
|
|
125
|
+
}
|
|
126
|
+
return yield* ps.getDatabase({ organization, database });
|
|
127
|
+
}).pipe(Effect.catchTag("NotFound", () => Effect.fail(new NotReady({
|
|
128
|
+
description: `database "${database}" not found yet`,
|
|
129
|
+
})))), (data) => data.ready);
|
|
130
|
+
});
|
|
131
|
+
export const isKnownError = (tag, message) => (error) => typeof error === "object" &&
|
|
132
|
+
error !== null &&
|
|
133
|
+
error._tag === tag &&
|
|
134
|
+
error.message === message;
|
|
135
|
+
//# sourceMappingURL=Util.js.map
|
package/lib/Util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
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Provider.ts";
|
|
2
|
+
export { type BaseBranchAttributes, type BaseBranchProps, makeBranchProvider } from "./Branch.ts";
|
|
3
|
+
export { Credentials, CredentialsFromEnv, DEFAULT_API_BASE_URL, fromAuthProvider, fromToken, } from "./Credentials.ts";
|
|
4
|
+
export * from "./Database.ts";
|
|
5
|
+
export * from "./MySQL/index.ts";
|
|
6
|
+
export * from "./Postgres/index.ts";
|
|
7
|
+
export * from "./Providers.ts";
|
|
8
|
+
export * from "./Util.ts";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|