@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.
- 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 +395 -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 +59 -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 +20 -0
- package/lib/MySQL/MySQLMigrations.d.ts.map +1 -0
- package/lib/MySQL/MySQLMigrations.js +72 -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 +16 -0
- package/lib/Postgres/PostgresMigrations.d.ts.map +1 -0
- package/lib/Postgres/PostgresMigrations.js +65 -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 +584 -0
- package/src/Branch.ts +657 -0
- package/src/Contributions.ts +9 -0
- package/src/Credentials.ts +92 -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 +133 -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 +122 -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,294 @@
|
|
|
1
|
+
import { diffMigrations, migrationsAttrs, migrationsInputOf, 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 { havePropsChanged, isResolved } from "alchemy/Diff";
|
|
6
|
+
import { createPhysicalName } from "alchemy/PhysicalName";
|
|
7
|
+
import * as Provider from "alchemy/Provider";
|
|
8
|
+
import { Resource } from "alchemy/Resource";
|
|
9
|
+
import { recordsEqual } from "alchemy/Util/equal";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Stream from "effect/Stream";
|
|
12
|
+
import { deleteUnprotectedDatabase, PlanetscaleConflict, replaceDatabase, waitForBranchReady, waitForDatabaseReady, } from "../Util.js";
|
|
13
|
+
import { ensureMySQLProductionBranchClusterSize, observeDefaultKeyspaceReplicas, } from "./MySQLClusterSize.js";
|
|
14
|
+
import { runMySQLImports, runMySQLMigrations } from "./MySQLMigrations.js";
|
|
15
|
+
/** @resource */
|
|
16
|
+
export const MySQLDatabase = Resource("Planetscale.MySQLDatabase");
|
|
17
|
+
export const MySQLDatabaseProvider = () => Provider.succeed(MySQLDatabase, {
|
|
18
|
+
stables: ["id", "organization", "region"],
|
|
19
|
+
diff: Effect.fn(function* ({ news, olds, output }) {
|
|
20
|
+
if (!isResolved(news))
|
|
21
|
+
return undefined;
|
|
22
|
+
// Database names are rename-mutable (reconcile folds `new_name`
|
|
23
|
+
// into the settings sync), so `name` cannot live in the
|
|
24
|
+
// provider-level stables. Almost no update is a rename though —
|
|
25
|
+
// for those, advertise `name` as stable on the update so
|
|
26
|
+
// downstream consumers (branches, passwords) still resolve
|
|
27
|
+
// `database.name` at plan time instead of seeing `undefined` and
|
|
28
|
+
// falsely planning a replacement. The name only changes when the
|
|
29
|
+
// `name` prop itself changes: an explicit name renames iff it
|
|
30
|
+
// differs from the observed name, and an omitted name is
|
|
31
|
+
// engine-generated deterministically (stable across updates).
|
|
32
|
+
const nameIsStable = output?.name !== undefined &&
|
|
33
|
+
(news.name !== undefined ? news.name === output.name : olds?.name === undefined);
|
|
34
|
+
const stables = nameIsStable ? ["id", "organization", "region", "name"] : undefined;
|
|
35
|
+
if (news.region?.slug !== undefined &&
|
|
36
|
+
output?.region?.slug !== undefined &&
|
|
37
|
+
news.region.slug !== output.region.slug) {
|
|
38
|
+
return yield* replaceDatabase(news, output, "region");
|
|
39
|
+
}
|
|
40
|
+
// Replicas reconcile in place via a keyspace resize — never a
|
|
41
|
+
// replacement. Diff against the observed keyspace replica count so
|
|
42
|
+
// an adopted database whose live state already matches plans no-op.
|
|
43
|
+
if (news.replicas !== undefined && news.replicas !== (output?.replicas ?? olds.replicas)) {
|
|
44
|
+
return { action: "update", stables };
|
|
45
|
+
}
|
|
46
|
+
if (yield* diffMigrations({ news, output })) {
|
|
47
|
+
return { action: "update", stables };
|
|
48
|
+
}
|
|
49
|
+
if (news.importFiles?.length) {
|
|
50
|
+
const newHashes = yield* hashImports(news.importFiles, yield* rootDir);
|
|
51
|
+
if (!recordsEqual(newHashes, output?.importHashes ?? {})) {
|
|
52
|
+
return { action: "update", stables };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Remaining prop changes (rename, settings, clusterSize, …) are
|
|
56
|
+
// in-place updates. Decide them here instead of falling back to
|
|
57
|
+
// the engine's default deep-compare so the conditional `name`
|
|
58
|
+
// stable above is attached — the default path uses the
|
|
59
|
+
// provider-level stables, which strip `name` from downstream plan
|
|
60
|
+
// resolution.
|
|
61
|
+
if (havePropsChanged(olds, news)) {
|
|
62
|
+
return { action: "update", stables };
|
|
63
|
+
}
|
|
64
|
+
// Nothing changed. Still advertise the conditional `name` stable so
|
|
65
|
+
// a `--force` deploy (which upgrades this noop to an update) keeps
|
|
66
|
+
// `name` resolvable downstream instead of falsely replacing
|
|
67
|
+
// consumers such as roles and passwords (#1832).
|
|
68
|
+
return stables ? { action: "noop", stables } : undefined;
|
|
69
|
+
}),
|
|
70
|
+
read: Effect.fn(function* ({ id, output, olds }) {
|
|
71
|
+
const { organization } = yield* yield* Credentials;
|
|
72
|
+
const databaseName = output?.name ?? (yield* createDatabaseName(id, olds?.name));
|
|
73
|
+
return yield* planetscale
|
|
74
|
+
.getDatabase({
|
|
75
|
+
organization,
|
|
76
|
+
database: databaseName,
|
|
77
|
+
})
|
|
78
|
+
.pipe(Effect.flatMap(Effect.fn(function* (data) {
|
|
79
|
+
if (data.kind !== "mysql") {
|
|
80
|
+
return yield* new PlanetscaleConflict({
|
|
81
|
+
message: `Planetscale database "${data.name}" has kind "${data.kind}" but this resource ` +
|
|
82
|
+
`is a MySQLDatabase. Use Planetscale.${data.kind === "postgresql" ? "PostgresDatabase" : data.kind}() instead, ` +
|
|
83
|
+
`or delete the existing database and retry.`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// Observe the default keyspace's live replica configuration
|
|
87
|
+
// so adopted databases diff against reality.
|
|
88
|
+
const replicas = yield* observeDefaultKeyspaceReplicas(organization, data.name, data.default_branch ?? "main");
|
|
89
|
+
return {
|
|
90
|
+
id: data.id,
|
|
91
|
+
name: data.name,
|
|
92
|
+
organization,
|
|
93
|
+
state: data.state,
|
|
94
|
+
defaultBranch: data.default_branch ?? "main",
|
|
95
|
+
replicas,
|
|
96
|
+
plan: data.plan ?? "hobby",
|
|
97
|
+
createdAt: data.created_at,
|
|
98
|
+
updatedAt: data.updated_at,
|
|
99
|
+
htmlUrl: data.html_url,
|
|
100
|
+
region: { slug: data.region.slug },
|
|
101
|
+
migrationsDir: output?.migrationsDir ?? (olds && migrationsInputOf(olds))?.dir,
|
|
102
|
+
migrationsTable: output?.migrationsTable ?? (olds && migrationsInputOf(olds))?.table,
|
|
103
|
+
migrationsHashes: output?.migrationsHashes ?? {},
|
|
104
|
+
importHashes: output?.importHashes ?? {},
|
|
105
|
+
clusterSize: output?.clusterSize ?? "",
|
|
106
|
+
requireApprovalForDeploy: data.require_approval_for_deploy ?? false,
|
|
107
|
+
restrictBranchRegion: data.restrict_branch_region ?? false,
|
|
108
|
+
insightsRawQueries: data.insights_raw_queries ?? false,
|
|
109
|
+
productionBranchWebConsole: data.production_branch_web_console ?? false,
|
|
110
|
+
deletionProtection: data.deletion_protected ?? false,
|
|
111
|
+
automaticMigrations: data.automatic_migrations ?? false,
|
|
112
|
+
migrationFramework: data.migration_framework ?? undefined,
|
|
113
|
+
migrationTableName: data.migration_table_name ?? undefined,
|
|
114
|
+
allowDataBranching: data.allow_data_branching ?? false,
|
|
115
|
+
allowForeignKeyConstraints: data.foreign_keys_enabled ?? false,
|
|
116
|
+
};
|
|
117
|
+
})), Effect.catchTag("NotFound", () => Effect.undefined));
|
|
118
|
+
}),
|
|
119
|
+
reconcile: Effect.fn(function* ({ id, news, output, session }) {
|
|
120
|
+
const { organization } = yield* yield* Credentials;
|
|
121
|
+
const newName = yield* createDatabaseName(id, news.name);
|
|
122
|
+
const clusterSize = news.clusterSize;
|
|
123
|
+
// Observe — read live state under either the cached name (rename
|
|
124
|
+
// / refresh) or the freshly-derived name (greenfield). Observing
|
|
125
|
+
// unconditionally absorbs the race between `read` and `reconcile`
|
|
126
|
+
// — if a foreign actor (or a previously-failed-to-persist
|
|
127
|
+
// create) produced a database under the desired name in the
|
|
128
|
+
// meantime, we'll find it here and skip the duplicate create.
|
|
129
|
+
// Adoption routing has already been gated by `read` returning
|
|
130
|
+
// `Unowned`, so by the time we reach reconcile any observed
|
|
131
|
+
// database is fair game.
|
|
132
|
+
const observedName = output?.name ?? newName;
|
|
133
|
+
let observed = yield* planetscale
|
|
134
|
+
.getDatabase({
|
|
135
|
+
organization,
|
|
136
|
+
database: observedName,
|
|
137
|
+
})
|
|
138
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.undefined));
|
|
139
|
+
// Ensure — if missing, create.
|
|
140
|
+
if (!observed) {
|
|
141
|
+
yield* session.note("Creating database...");
|
|
142
|
+
// Note: the API rejects the `replicas` param for mysql databases;
|
|
143
|
+
// replicas are converged below via the keyspace resize lifecycle.
|
|
144
|
+
observed = yield* planetscale.createDatabase({
|
|
145
|
+
organization,
|
|
146
|
+
name: newName,
|
|
147
|
+
region: news.region?.slug,
|
|
148
|
+
kind: "mysql",
|
|
149
|
+
cluster_size: clusterSize,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// Wait for the database to finish provisioning before any
|
|
153
|
+
// downstream sync runs. PlanetScale reports `state: "pending"`
|
|
154
|
+
// for a while after createDatabase returns, during which branch
|
|
155
|
+
// operations on this database (including our own settings PATCH)
|
|
156
|
+
// race against the provisioning fiber.
|
|
157
|
+
yield* waitForDatabaseReady(organization, observed.name, session);
|
|
158
|
+
if (observed.kind !== "mysql") {
|
|
159
|
+
return yield* new PlanetscaleConflict({
|
|
160
|
+
message: `Planetscale database "${observed.name}" has kind "${observed.kind}" but this resource ` +
|
|
161
|
+
`is a MySQLDatabase. Use Planetscale.${observed.kind === "postgresql" ? "PostgresDatabase" : observed.kind}() instead, ` +
|
|
162
|
+
`or delete the existing database and retry.`,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// Sync — ensure a non-`main` default branch exists before
|
|
166
|
+
// referencing it via `default_branch`. The branch is created
|
|
167
|
+
// empty (no cluster size yet); we'll size it below.
|
|
168
|
+
if (news.defaultBranch && news.defaultBranch !== "main") {
|
|
169
|
+
yield* waitForDatabaseReady(organization, observed.name, session);
|
|
170
|
+
const branchExists = yield* planetscale
|
|
171
|
+
.getBranch({
|
|
172
|
+
organization,
|
|
173
|
+
database: observed.name,
|
|
174
|
+
branch: news.defaultBranch,
|
|
175
|
+
})
|
|
176
|
+
.pipe(Effect.map(() => true), Effect.catchTag("NotFound", () => Effect.succeed(false)));
|
|
177
|
+
if (!branchExists) {
|
|
178
|
+
yield* planetscale.createBranch({
|
|
179
|
+
organization,
|
|
180
|
+
database: observed.name,
|
|
181
|
+
name: news.defaultBranch,
|
|
182
|
+
parent_branch: "main",
|
|
183
|
+
// create branch with cluster size to skip resizing when promoting the branch
|
|
184
|
+
cluster_size: clusterSize,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Sync settings — `updateSettings` is upsert-shaped, so we can
|
|
189
|
+
// call it with the full desired payload on every reconcile.
|
|
190
|
+
const updated = yield* planetscale.updateDatabaseSettings({
|
|
191
|
+
organization,
|
|
192
|
+
database: observed.name,
|
|
193
|
+
new_name: newName !== observed.name ? newName : undefined,
|
|
194
|
+
automatic_migrations: news.automaticMigrations,
|
|
195
|
+
migration_framework: news.migrationFramework,
|
|
196
|
+
migration_table_name: news.migrationTableName,
|
|
197
|
+
allow_foreign_key_constraints: news.allowForeignKeyConstraints,
|
|
198
|
+
allow_data_branching: news.allowDataBranching,
|
|
199
|
+
require_approval_for_deploy: news.requireApprovalForDeploy,
|
|
200
|
+
restrict_branch_region: news.restrictBranchRegion,
|
|
201
|
+
insights_raw_queries: news.insightsRawQueries,
|
|
202
|
+
production_branch_web_console: news.productionBranchWebConsole,
|
|
203
|
+
deletion_protected: news.deletionProtection,
|
|
204
|
+
default_branch: news.defaultBranch,
|
|
205
|
+
});
|
|
206
|
+
// Sync cluster size and replicas on the active default branch —
|
|
207
|
+
// both converge in place via PlanetScale's keyspace resize
|
|
208
|
+
// lifecycle, diffed against the observed default keyspace.
|
|
209
|
+
const branch = news.defaultBranch ?? updated.default_branch ?? "main";
|
|
210
|
+
const keyspace = yield* ensureMySQLProductionBranchClusterSize(organization, updated.name, branch, news.clusterSize, news.replicas);
|
|
211
|
+
const migrationTarget = {
|
|
212
|
+
organization,
|
|
213
|
+
database: updated.name,
|
|
214
|
+
branch,
|
|
215
|
+
};
|
|
216
|
+
const migrationsInput = migrationsInputOf(news);
|
|
217
|
+
if (migrationsInput || news.importFiles?.length) {
|
|
218
|
+
yield* waitForBranchReady(organization, updated.name, branch, session);
|
|
219
|
+
}
|
|
220
|
+
const migrations = migrationsInput
|
|
221
|
+
? yield* runMySQLMigrations(migrationTarget, migrationsInput, stampedOf(output))
|
|
222
|
+
: undefined;
|
|
223
|
+
const importHashes = news.importFiles?.length
|
|
224
|
+
? yield* runMySQLImports(migrationTarget, news.importFiles, yield* rootDir, output?.importHashes ?? {})
|
|
225
|
+
: {};
|
|
226
|
+
return {
|
|
227
|
+
id: updated.id,
|
|
228
|
+
name: updated.name,
|
|
229
|
+
organization,
|
|
230
|
+
state: updated.state,
|
|
231
|
+
defaultBranch: updated.default_branch ?? branch,
|
|
232
|
+
plan: updated.plan ?? output?.plan ?? "hobby",
|
|
233
|
+
createdAt: updated.created_at,
|
|
234
|
+
updatedAt: updated.updated_at,
|
|
235
|
+
htmlUrl: updated.html_url,
|
|
236
|
+
region: { slug: updated.region.slug },
|
|
237
|
+
clusterSize,
|
|
238
|
+
replicas: keyspace.replicas,
|
|
239
|
+
...migrationsAttrs({ input: migrationsInput, run: migrations, output }),
|
|
240
|
+
importHashes,
|
|
241
|
+
requireApprovalForDeploy: updated.require_approval_for_deploy ?? false,
|
|
242
|
+
restrictBranchRegion: updated.restrict_branch_region ?? false,
|
|
243
|
+
insightsRawQueries: updated.insights_raw_queries ?? false,
|
|
244
|
+
productionBranchWebConsole: updated.production_branch_web_console ?? false,
|
|
245
|
+
deletionProtection: updated.deletion_protected ?? false,
|
|
246
|
+
automaticMigrations: updated.automatic_migrations ?? false,
|
|
247
|
+
migrationFramework: updated.migration_framework ?? undefined,
|
|
248
|
+
migrationTableName: updated.migration_table_name ?? undefined,
|
|
249
|
+
allowDataBranching: updated.allow_data_branching ?? false,
|
|
250
|
+
allowForeignKeyConstraints: updated.foreign_keys_enabled ?? false,
|
|
251
|
+
};
|
|
252
|
+
}),
|
|
253
|
+
delete: Effect.fn(function* ({ output }) {
|
|
254
|
+
yield* deleteUnprotectedDatabase(output.organization, output.name);
|
|
255
|
+
}),
|
|
256
|
+
list: Effect.fn(function* () {
|
|
257
|
+
const { organization } = yield* yield* Credentials;
|
|
258
|
+
return yield* planetscale.listDatabases.pages({ organization }).pipe(Stream.runCollect, Effect.map((chunk) => Array.from(chunk).flatMap((page) => page.data
|
|
259
|
+
.filter((db) => db.kind === "mysql")
|
|
260
|
+
.map((data) => ({
|
|
261
|
+
id: data.id,
|
|
262
|
+
name: data.name,
|
|
263
|
+
organization,
|
|
264
|
+
state: data.state,
|
|
265
|
+
defaultBranch: data.default_branch ?? "main",
|
|
266
|
+
plan: data.plan ?? "hobby",
|
|
267
|
+
createdAt: data.created_at,
|
|
268
|
+
updatedAt: data.updated_at,
|
|
269
|
+
htmlUrl: data.html_url,
|
|
270
|
+
region: { slug: data.region.slug },
|
|
271
|
+
migrationsDir: undefined,
|
|
272
|
+
migrationsTable: undefined,
|
|
273
|
+
migrationsHashes: {},
|
|
274
|
+
importHashes: {},
|
|
275
|
+
clusterSize: "",
|
|
276
|
+
replicas: undefined,
|
|
277
|
+
requireApprovalForDeploy: data.require_approval_for_deploy ?? false,
|
|
278
|
+
restrictBranchRegion: data.restrict_branch_region ?? false,
|
|
279
|
+
insightsRawQueries: data.insights_raw_queries ?? false,
|
|
280
|
+
productionBranchWebConsole: data.production_branch_web_console ?? false,
|
|
281
|
+
deletionProtection: data.deletion_protected ?? false,
|
|
282
|
+
automaticMigrations: data.automatic_migrations ?? false,
|
|
283
|
+
migrationFramework: data.migration_framework ?? undefined,
|
|
284
|
+
migrationTableName: data.migration_table_name ?? undefined,
|
|
285
|
+
allowDataBranching: data.allow_data_branching ?? false,
|
|
286
|
+
allowForeignKeyConstraints: data.foreign_keys_enabled ?? false,
|
|
287
|
+
})))));
|
|
288
|
+
}),
|
|
289
|
+
});
|
|
290
|
+
const createDatabaseName = (id, name) => Effect.gen(function* () {
|
|
291
|
+
return name ?? (yield* createPhysicalName({ id, lowercase: true, maxLength: 63 }));
|
|
292
|
+
});
|
|
293
|
+
const rootDir = Effect.sync(() => process.cwd());
|
|
294
|
+
//# sourceMappingURL=MySQLDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLDatabase.js","sourceRoot":"","sources":["../../src/MySQL/MySQLDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,SAAS,GACV,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,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,sCAAsC,EACtC,8BAA8B,GAE/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA2J3E,gBAAgB;AAChB,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAgB,2BAA2B,CAAC,CAAC;AAElF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CACxC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,E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IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type NormalizedMigrationsInput, type StampedMigrationsState } from "@alchemy.run/sql/Migrations";
|
|
2
|
+
import * as ps from "@distilled.cloud/planetscale";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
export interface MySQLMigrationTarget {
|
|
5
|
+
organization: string;
|
|
6
|
+
database: string;
|
|
7
|
+
branch: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* PlanetScale MySQL's migration adaptation is exactly this: the shared
|
|
11
|
+
* pipeline with a temp-password-scoped mysql2 connection as its executor.
|
|
12
|
+
*/
|
|
13
|
+
export declare const runMySQLMigrations: (target: MySQLMigrationTarget, input: NormalizedMigrationsInput, stamped: StampedMigrationsState) => Effect.Effect<import("@alchemy.run/sql/Migrations").MigrationRun, import("@alchemy.run/sql/Migrations").DrizzleV0LayoutError | ps.CreatePasswordError | import("@alchemy.run/sql/Migrations").MigrationApplyError, import("effect/FileSystem").FileSystem | import("effect/Path").Path | ps.PlanetScaleOpContext>;
|
|
14
|
+
/**
|
|
15
|
+
* Apply `importFiles`, each once and again only when it changes. Vitess
|
|
16
|
+
* rejects drizzle-kit's `--> statement-breakpoint` markers, so statements
|
|
17
|
+
* run one at a time.
|
|
18
|
+
*/
|
|
19
|
+
export declare const runMySQLImports: (target: MySQLMigrationTarget, importFiles: ReadonlyArray<string>, rootDir: string, previous: Record<string, string>) => Effect.Effect<Record<string, string>, import("@alchemy.run/sql/Migrations").MigrationError | import("effect/PlatformError").PlatformError | ps.CreatePasswordError, import("effect/FileSystem").FileSystem | import("effect/Path").Path | ps.PlanetScaleOpContext>;
|
|
20
|
+
//# sourceMappingURL=MySQLMigrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLMigrations.d.ts","sourceRoot":"","sources":["../../src/MySQL/MySQLMigrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,yBAAyB,EAE9B,KAAK,sBAAsB,EAC5B,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,WACrB,oBAAoB,SACrB,yBAAyB,WACvB,sBAAsB,sTAM7B,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAClB,oBAAoB,eACf,aAAa,CAAC,MAAM,CAAC,WACzB,MAAM,YACL,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,uQAY9B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { runMigrations, withMySqlExecutor, } from "@alchemy.run/sql/Migrations";
|
|
2
|
+
import { applySqlImports, splitSqlStatements } from "@alchemy.run/sql/SqlFile";
|
|
3
|
+
import * as ps from "@distilled.cloud/planetscale";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Redacted from "effect/Redacted";
|
|
6
|
+
import * as Schedule from "effect/Schedule";
|
|
7
|
+
const MIGRATION_PASSWORD_TTL_SECONDS = 600;
|
|
8
|
+
/**
|
|
9
|
+
* PlanetScale MySQL's migration adaptation is exactly this: the shared
|
|
10
|
+
* pipeline with a temp-password-scoped mysql2 connection as its executor.
|
|
11
|
+
*/
|
|
12
|
+
export const runMySQLMigrations = (target, input, stamped) => runMigrations({
|
|
13
|
+
input,
|
|
14
|
+
stamped,
|
|
15
|
+
withExecutor: (apply) => withMySQLExecutor(target, apply),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Apply `importFiles`, each once and again only when it changes. Vitess
|
|
19
|
+
* rejects drizzle-kit's `--> statement-breakpoint` markers, so statements
|
|
20
|
+
* run one at a time.
|
|
21
|
+
*/
|
|
22
|
+
export const runMySQLImports = (target, importFiles, rootDir, previous) => applySqlImports({
|
|
23
|
+
importFiles,
|
|
24
|
+
rootDir,
|
|
25
|
+
previous,
|
|
26
|
+
apply: (file) => withMySQLExecutor(target, (executor) => Effect.forEach(splitSqlStatements(file.sql), (statement) => executor.query(statement), {
|
|
27
|
+
discard: true,
|
|
28
|
+
})),
|
|
29
|
+
});
|
|
30
|
+
/** A verified-TLS `mysql2` session as a short-lived admin password. */
|
|
31
|
+
const withMySQLExecutor = (target, use) => withTemporaryMySQLPassword(target, (password) => withMySqlExecutor({
|
|
32
|
+
host: password.host,
|
|
33
|
+
user: password.username,
|
|
34
|
+
password: Redacted.value(password.password),
|
|
35
|
+
database: target.database,
|
|
36
|
+
multipleStatements: true,
|
|
37
|
+
ssl: { rejectUnauthorized: true },
|
|
38
|
+
}, use));
|
|
39
|
+
const withTemporaryMySQLPassword = (target, use) => Effect.acquireUseRelease(Effect.gen(function* () {
|
|
40
|
+
const created = yield* ps.createPassword({
|
|
41
|
+
organization: target.organization,
|
|
42
|
+
database: target.database,
|
|
43
|
+
branch: target.branch,
|
|
44
|
+
role: "admin",
|
|
45
|
+
ttl: MIGRATION_PASSWORD_TTL_SECONDS,
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
id: created.id,
|
|
49
|
+
host: created.access_host_url,
|
|
50
|
+
username: created.username,
|
|
51
|
+
password: created.plain_text,
|
|
52
|
+
};
|
|
53
|
+
}), use, (password) => ps
|
|
54
|
+
.deletePassword({
|
|
55
|
+
organization: target.organization,
|
|
56
|
+
database: target.database,
|
|
57
|
+
branch: target.branch,
|
|
58
|
+
id: password.id,
|
|
59
|
+
})
|
|
60
|
+
.pipe(
|
|
61
|
+
// Already-deleted passwords are a success: nothing to clean up.
|
|
62
|
+
Effect.catchTag("NotFound", () => Effect.void), Effect.retry({
|
|
63
|
+
schedule: Schedule.max([Schedule.exponential("500 millis"), Schedule.recurs(5)]),
|
|
64
|
+
}),
|
|
65
|
+
// Migrations succeeded; don't fail the parent over a release-step
|
|
66
|
+
// hiccup. The password's TTL bounds the orphan window; log loudly
|
|
67
|
+
// so an operator can clean it up manually if needed.
|
|
68
|
+
Effect.catch((cause) => Effect.logWarning(`Failed to delete temporary Planetscale migration password after retries. ` +
|
|
69
|
+
`It will expire via TTL (~${MIGRATION_PASSWORD_TTL_SECONDS}s). ` +
|
|
70
|
+
`organization=${target.organization} database=${target.database} ` +
|
|
71
|
+
`branch=${target.branch} id=${password.id}`, cause))));
|
|
72
|
+
//# sourceMappingURL=MySQLMigrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLMigrations.js","sourceRoot":"","sources":["../../src/MySQL/MySQLMigrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,GAIlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAQ3C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAA4B,EAC5B,KAAgC,EAChC,OAA+B,EAC/B,EAAE,CACF,aAAa,CAAC;IACZ,KAAK;IACL,OAAO;IACP,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC;CAC1D,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAA4B,EAC5B,WAAkC,EAClC,OAAe,EAC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,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,eAAe;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,OAAO,CAAC,UAAU;KAC7B,CAAC;AACJ,CAAC,CAAC,EACF,GAAG,EACH,CAAC,QAAQ,EAAE,EAAE,CACX,EAAE;KACC,cAAc,CAAC;IACd,YAAY,EAAE,MAAM,CAAC,YAAY;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,EAAE,EAAE,QAAQ,CAAC,EAAE;CAChB,CAAC;KACD,IAAI;AACH,gEAAgE;AAChE,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAC9C,MAAM,CAAC,KAAK,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACjF,CAAC;AACF,kEAAkE;AAClE,kEAAkE;AAClE,qDAAqD;AACrD,MAAM,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAC9B,MAAM,CAAC,UAAU,CACf,2EAA2E;IACzE,4BAA4B,8BAA8B,MAAM;IAChE,gBAAgB,MAAM,CAAC,YAAY,aAAa,MAAM,CAAC,QAAQ,GAAG;IAClE,UAAU,MAAM,CAAC,MAAM,OAAO,QAAQ,CAAC,EAAE,EAAE,EAC7C,KAAK,CACN,CACF,CACF,CACN,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Redacted from "effect/Redacted";
|
|
2
|
+
/**
|
|
3
|
+
* The shape `Cloudflare.Hyperdrive` and other MySQL consumers accept as an
|
|
4
|
+
* origin. Materialized on `Planetscale.MySQLPassword` so callers can wire
|
|
5
|
+
* password credentials into Hyperdrive directly.
|
|
6
|
+
*/
|
|
7
|
+
export type MySQLOrigin = {
|
|
8
|
+
scheme: "mysql";
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
database: string;
|
|
12
|
+
user: string;
|
|
13
|
+
password: Redacted.Redacted<string>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=MySQLOrigin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLOrigin.d.ts","sourceRoot":"","sources":["../../src/MySQL/MySQLOrigin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLOrigin.js","sourceRoot":"","sources":["../../src/MySQL/MySQLOrigin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as planetscale from "@distilled.cloud/planetscale";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
|
+
import type { Providers } from "../Providers.ts";
|
|
6
|
+
import type { MySQLBranch } from "./MySQLBranch.ts";
|
|
7
|
+
import type { MySQLDatabase } from "./MySQLDatabase.ts";
|
|
8
|
+
import type { MySQLOrigin } from "./MySQLOrigin.ts";
|
|
9
|
+
/**
|
|
10
|
+
* Properties for creating or updating a PlanetScale MySQL password.
|
|
11
|
+
*
|
|
12
|
+
* Passwords are only meant for MySQL databases. For PostgreSQL,
|
|
13
|
+
* use {@link PostgresRole} instead.
|
|
14
|
+
*/
|
|
15
|
+
export interface MySQLPasswordProps {
|
|
16
|
+
/**
|
|
17
|
+
* Password name. If omitted, a unique name is generated from
|
|
18
|
+
* `${app}-${stage}-${id}`.
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
/**
|
|
22
|
+
* MySQL database — string name or {@link MySQLDatabase} resource.
|
|
23
|
+
*/
|
|
24
|
+
database: string | MySQLDatabase;
|
|
25
|
+
/**
|
|
26
|
+
* Branch — string name or {@link MySQLBranch} resource.
|
|
27
|
+
* @default "main"
|
|
28
|
+
*/
|
|
29
|
+
branch?: string | MySQLBranch;
|
|
30
|
+
/**
|
|
31
|
+
* The MySQL role granted to the password.
|
|
32
|
+
*/
|
|
33
|
+
role: "reader" | "writer" | "admin" | "readwriter";
|
|
34
|
+
/**
|
|
35
|
+
* Whether the password is for a read replica.
|
|
36
|
+
*/
|
|
37
|
+
replica?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Time to live (seconds). The password is invalidated after this period.
|
|
40
|
+
*/
|
|
41
|
+
ttl?: number;
|
|
42
|
+
/**
|
|
43
|
+
* IP CIDR ranges allowed to use this password.
|
|
44
|
+
*/
|
|
45
|
+
cidrs?: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Output attributes of a deployed PlanetScale password.
|
|
49
|
+
*/
|
|
50
|
+
export interface MySQLPasswordAttributes {
|
|
51
|
+
/** Unique identifier for the password (stable). */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Password name. If omitted, a unique name is generated from `${app}-${stage}-${id}`. */
|
|
54
|
+
name: string;
|
|
55
|
+
/** ISO 8601 timestamp at which the password expires. `null` if no TTL. */
|
|
56
|
+
expiresAt: string | null;
|
|
57
|
+
/** Hostname for the database connection. */
|
|
58
|
+
host: string;
|
|
59
|
+
/** Username for database authentication. */
|
|
60
|
+
username: string;
|
|
61
|
+
/** Password for database authentication (Redacted). */
|
|
62
|
+
password: Redacted.Redacted<string>;
|
|
63
|
+
/** Parsed connection components ready to feed into Cloudflare Hyperdrive. */
|
|
64
|
+
origin: MySQLOrigin;
|
|
65
|
+
/** Resolved organization slug. */
|
|
66
|
+
organization: string;
|
|
67
|
+
/** Resolved database name. */
|
|
68
|
+
database: string;
|
|
69
|
+
/** Resolved branch name. */
|
|
70
|
+
branch: string;
|
|
71
|
+
/** The role granted. */
|
|
72
|
+
role: "reader" | "writer" | "admin" | "readwriter" | (string & {});
|
|
73
|
+
/** Whether this password is for a read replica. */
|
|
74
|
+
replica: boolean | undefined;
|
|
75
|
+
/** TTL in seconds (if set). */
|
|
76
|
+
ttl: number | undefined;
|
|
77
|
+
/** IP CIDR ranges allowed to use this password. */
|
|
78
|
+
cidrs: readonly string[] | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A PlanetScale password for accessing a MySQL database branch.
|
|
82
|
+
*
|
|
83
|
+
* For PostgreSQL databases, use {@link PostgresRole} instead.
|
|
84
|
+
*
|
|
85
|
+
* ### Creating a Password
|
|
86
|
+
* **Example:** Reader password
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const reader = yield* Planetscale.MySQLPassword("AppReader", {
|
|
89
|
+
* database: "my-db",
|
|
90
|
+
* role: "reader",
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* **Example:** Writer password with TTL
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const writer = yield* Planetscale.MySQLPassword("AppWriter", {
|
|
97
|
+
* database: "my-db",
|
|
98
|
+
* role: "writer",
|
|
99
|
+
* ttl: 86400,
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* **Example:** Admin password with IP allowlist
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const admin = yield* Planetscale.MySQLPassword("Admin", {
|
|
106
|
+
* database: "my-db",
|
|
107
|
+
* role: "admin",
|
|
108
|
+
* cidrs: ["203.0.113.0/24", "198.51.100.0/24"],
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export type MySQLPassword = Resource<"Planetscale.MySQLPassword", MySQLPasswordProps, MySQLPasswordAttributes, never, Providers>;
|
|
113
|
+
/** @resource */
|
|
114
|
+
export declare const MySQLPassword: import("alchemy/Resource").ResourceClass<MySQLPassword>;
|
|
115
|
+
export declare const MySQLPasswordProvider: () => import("effect/Layer").Layer<Provider.Provider<MySQLPassword>, never, import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | planetscale.PlanetScaleOpContext>;
|
|
116
|
+
//# sourceMappingURL=MySQLPassword.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLPassword.d.ts","sourceRoot":"","sources":["../../src/MySQL/MySQLPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAI5D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC;IAEjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAE9B;;OAEG;IACH,IAAI,EA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