alchemy 0.71.1 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/alchemy.js +2 -4
- package/lib/cloudflare/bound.d.ts +1 -2
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/container.d.ts +1 -0
- package/lib/cloudflare/container.d.ts.map +1 -1
- package/lib/cloudflare/container.js +3 -0
- package/lib/cloudflare/container.js.map +1 -1
- package/lib/cloudflare/index.d.ts +1 -1
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +2 -1
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +2 -2
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +23 -4
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/redwood/redwood.js +2 -2
- package/lib/cloudflare/redwood/redwood.js.map +1 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +1 -6
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/planetscale/api.d.ts +0 -4
- package/lib/planetscale/api.d.ts.map +1 -1
- package/lib/planetscale/api.js.map +1 -1
- package/lib/planetscale/branch.d.ts +12 -11
- package/lib/planetscale/branch.d.ts.map +1 -1
- package/lib/planetscale/branch.js +40 -23
- package/lib/planetscale/branch.js.map +1 -1
- package/lib/planetscale/database.d.ts +10 -5
- package/lib/planetscale/database.d.ts.map +1 -1
- package/lib/planetscale/database.js +30 -18
- package/lib/planetscale/database.js.map +1 -1
- package/lib/planetscale/index.d.ts +1 -0
- package/lib/planetscale/index.d.ts.map +1 -1
- package/lib/planetscale/index.js +1 -0
- package/lib/planetscale/index.js.map +1 -1
- package/lib/planetscale/organization.d.ts +5 -0
- package/lib/planetscale/organization.d.ts.map +1 -0
- package/lib/planetscale/organization.js +11 -0
- package/lib/planetscale/organization.js.map +1 -0
- package/lib/planetscale/password.d.ts +10 -9
- package/lib/planetscale/password.d.ts.map +1 -1
- package/lib/planetscale/password.js +28 -13
- package/lib/planetscale/password.js.map +1 -1
- package/lib/planetscale/role.d.ts +2 -1
- package/lib/planetscale/role.d.ts.map +1 -1
- package/lib/planetscale/role.js +11 -8
- package/lib/planetscale/role.js.map +1 -1
- package/package.json +2 -6
- package/src/cloudflare/bound.ts +1 -22
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/container.ts +9 -0
- package/src/cloudflare/index.ts +3 -1
- package/src/cloudflare/queue-consumer.ts +28 -7
- package/src/cloudflare/redwood/redwood.ts +2 -2
- package/src/cloudflare/worker.ts +1 -6
- package/src/planetscale/api.ts +0 -4
- package/src/planetscale/branch.ts +51 -35
- package/src/planetscale/database.ts +40 -20
- package/src/planetscale/index.ts +1 -0
- package/src/planetscale/organization.ts +17 -0
- package/src/planetscale/password.ts +34 -16
- package/src/planetscale/role.ts +16 -9
- package/workers/tunnel-proxy.js +1 -1
|
@@ -22,8 +22,9 @@ export interface PasswordProps extends PlanetScaleProps {
|
|
|
22
22
|
/**
|
|
23
23
|
* The organization ID where the password will be created
|
|
24
24
|
* Required when using string database name, optional when using Database or Branch resource
|
|
25
|
+
* @default process.env.PLANETSCALE_ORGANIZATION
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
organization?: string;
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* The database where the password will be created
|
|
@@ -114,7 +115,7 @@ export interface Password extends PasswordProps {
|
|
|
114
115
|
*
|
|
115
116
|
* const readerPassword = await Password("app-reader", {
|
|
116
117
|
* name: "app-reader",
|
|
117
|
-
*
|
|
118
|
+
* organization: "my-org",
|
|
118
119
|
* database: "my-app-db",
|
|
119
120
|
* branch: "main",
|
|
120
121
|
* role: "reader"
|
|
@@ -136,7 +137,7 @@ export interface Password extends PasswordProps {
|
|
|
136
137
|
*
|
|
137
138
|
* const writerPassword = await Password("app-writer", {
|
|
138
139
|
* name: "app-writer",
|
|
139
|
-
*
|
|
140
|
+
* organization: "my-org",
|
|
140
141
|
* database: "my-app-db",
|
|
141
142
|
* branch: "development",
|
|
142
143
|
* role: "writer",
|
|
@@ -157,7 +158,7 @@ export interface Password extends PasswordProps {
|
|
|
157
158
|
*
|
|
158
159
|
* const adminPassword = await Password("admin-access", {
|
|
159
160
|
* name: "admin-access",
|
|
160
|
-
*
|
|
161
|
+
* organization: "my-org",
|
|
161
162
|
* database: "my-app-db",
|
|
162
163
|
* branch: "main",
|
|
163
164
|
* role: "admin",
|
|
@@ -176,7 +177,7 @@ export interface Password extends PasswordProps {
|
|
|
176
177
|
*
|
|
177
178
|
* const password = await Password("custom-auth", {
|
|
178
179
|
* name: "custom-auth",
|
|
179
|
-
*
|
|
180
|
+
* organization: "my-org",
|
|
180
181
|
* database: "my-app-db",
|
|
181
182
|
* branch: "main",
|
|
182
183
|
* role: "readwriter",
|
|
@@ -194,7 +195,7 @@ export interface Password extends PasswordProps {
|
|
|
194
195
|
*
|
|
195
196
|
* const replicaPassword = await Password("replica-reader", {
|
|
196
197
|
* name: "replica-reader",
|
|
197
|
-
*
|
|
198
|
+
* organization: "my-org",
|
|
198
199
|
* database: "my-app-db",
|
|
199
200
|
* branch: "main",
|
|
200
201
|
* role: "reader",
|
|
@@ -211,7 +212,7 @@ export interface Password extends PasswordProps {
|
|
|
211
212
|
*
|
|
212
213
|
* const database = await Database("my-db", {
|
|
213
214
|
* name: "my-app-db",
|
|
214
|
-
*
|
|
215
|
+
* organization: "my-org",
|
|
215
216
|
* clusterSize: "PS_10"
|
|
216
217
|
* });
|
|
217
218
|
*
|
|
@@ -232,13 +233,13 @@ export interface Password extends PasswordProps {
|
|
|
232
233
|
*
|
|
233
234
|
* const database = await Database("my-db", {
|
|
234
235
|
* name: "my-app-db",
|
|
235
|
-
*
|
|
236
|
+
* organization: "my-org",
|
|
236
237
|
* clusterSize: "PS_10"
|
|
237
238
|
* });
|
|
238
239
|
*
|
|
239
240
|
* const branch = await Branch("feature-branch", {
|
|
240
241
|
* name: "feature-branch",
|
|
241
|
-
*
|
|
242
|
+
* organization: "my-org",
|
|
242
243
|
* databaseName: "my-app-db",
|
|
243
244
|
* parentBranch: "main",
|
|
244
245
|
* isProduction: false
|
|
@@ -266,19 +267,36 @@ export const Password = Resource(
|
|
|
266
267
|
const name = `${(props.name ?? this.output?.name ?? this.scope.createPhysicalName(id)).toLowerCase()}-${nameSlug}`;
|
|
267
268
|
|
|
268
269
|
const api = createPlanetScaleClient(props);
|
|
270
|
+
if (!props.organization && typeof props.database === "string") {
|
|
271
|
+
throw new Error(
|
|
272
|
+
"Organization ID is required when using string database name",
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const organization =
|
|
277
|
+
// @ts-expect-error - organizationId is a legacy thing, we keep this so we can destroy
|
|
278
|
+
this.output?.organizationId ??
|
|
279
|
+
props.organization ??
|
|
280
|
+
(typeof props.database !== "string"
|
|
281
|
+
? props.database.organization
|
|
282
|
+
: typeof props.branch !== "string" && props.branch
|
|
283
|
+
? props.branch.organization
|
|
284
|
+
: (process.env.PLANETSCALE_ORGANIZATION ??
|
|
285
|
+
process.env.PLANETSCALE_ORG_ID));
|
|
269
286
|
const database =
|
|
270
|
-
|
|
287
|
+
// @ts-expect-error - databaseName is a legacy thing, we keep this so we can destroy
|
|
288
|
+
this.output?.databaseName ??
|
|
289
|
+
(typeof props.database === "string"
|
|
290
|
+
? props.database
|
|
291
|
+
: props.database.name);
|
|
271
292
|
const branch =
|
|
272
293
|
typeof props.branch === "string"
|
|
273
294
|
? props.branch
|
|
274
295
|
: (props.branch?.name ?? "main");
|
|
275
|
-
const organization =
|
|
276
|
-
props.organizationId ??
|
|
277
|
-
((typeof props.branch !== "string" && props.branch?.organizationId) ||
|
|
278
|
-
(typeof props.database !== "string" && props.database.organizationId));
|
|
279
|
-
|
|
280
296
|
if (!organization) {
|
|
281
|
-
throw new Error(
|
|
297
|
+
throw new Error(
|
|
298
|
+
"PlanetScale organization is required. Please set the `organization` property or the `PLANETSCALE_ORGANIZATION` environment variable.",
|
|
299
|
+
);
|
|
282
300
|
}
|
|
283
301
|
|
|
284
302
|
if (this.phase === "delete") {
|
package/src/planetscale/role.ts
CHANGED
|
@@ -16,8 +16,9 @@ export interface RoleProps extends PlanetScaleProps {
|
|
|
16
16
|
/**
|
|
17
17
|
* The organization ID where the role will be created
|
|
18
18
|
* Required when using string database name, optional when using Database resource
|
|
19
|
+
* @default process.env.PLANETSCALE_ORGANIZATION
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
organization?: string;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* The database where the role will be created
|
|
@@ -164,12 +165,21 @@ export const Role = Resource(
|
|
|
164
165
|
props: RoleProps,
|
|
165
166
|
): Promise<Role> {
|
|
166
167
|
const api = createPlanetScaleClient(props);
|
|
168
|
+
|
|
167
169
|
const organization =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
// @ts-expect-error - organizationId is a legacy thing, we keep this so we can destroy
|
|
171
|
+
this.output?.organizationId ??
|
|
172
|
+
props.organization ??
|
|
173
|
+
(typeof props.database !== "string"
|
|
174
|
+
? props.database.organization
|
|
175
|
+
: (process.env.PLANETSCALE_ORGANIZATION ??
|
|
176
|
+
process.env.PLANETSCALE_ORG_ID));
|
|
177
|
+
if (!organization) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
"PlanetScale organization is required. Please set the `organization` property or the `PLANETSCALE_ORGANIZATION` environment variable.",
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
173
183
|
const database =
|
|
174
184
|
typeof props.database === "string" ? props.database : props.database.name;
|
|
175
185
|
const branch =
|
|
@@ -179,9 +189,6 @@ export const Role = Resource(
|
|
|
179
189
|
const inheritedRoles = Array.isArray(props.inheritedRoles)
|
|
180
190
|
? props.inheritedRoles
|
|
181
191
|
: props.inheritedRoles.inheritedRoles;
|
|
182
|
-
if (!organization) {
|
|
183
|
-
throw new Error("Organization ID is required");
|
|
184
|
-
}
|
|
185
192
|
|
|
186
193
|
switch (this.phase) {
|
|
187
194
|
case "delete": {
|
package/workers/tunnel-proxy.js
CHANGED
|
@@ -34,7 +34,7 @@ var h={async fetch(e,r){let n=new URL(e.url);n.host=r.TUNNEL_HOST;let l=new Head
|
|
|
34
34
|
Alchemy</a>.</p>
|
|
35
35
|
</div>
|
|
36
36
|
<div class="bg-slate-200 px-5 py-3 flex flex-col w-full max-w-lg">
|
|
37
|
-
<p class="text-sm text-slate-500">Alchemy 0.
|
|
37
|
+
<p class="text-sm text-slate-500">Alchemy 0.73.0</p>
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
</body>
|