alchemy 0.75.0 → 0.76.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 +302 -287
- package/bin/commands/util.ts +8 -4
- package/bin/services/execute-alchemy.ts +4 -2
- package/bin/services/github-workflow.ts +2 -3
- package/bin/services/package-manager.ts +1 -5
- package/lib/alchemy.d.ts +1 -1
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +1 -1
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.js +10 -0
- package/lib/apply.js.map +1 -1
- package/lib/aws/control/types.d.ts.map +1 -1
- package/lib/aws/control/types.js.map +1 -1
- package/lib/clickhouse/api/sdk.gen.d.ts.map +1 -1
- package/lib/clickhouse/api/sdk.gen.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +1 -1
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +1 -1
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.d.ts.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.js +3 -3
- package/lib/cloudflare/cloudflare-env-proxy.js.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/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +0 -4
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/hyperdrive.d.ts +0 -1
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/miniflare/delete.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/delete.js +3 -0
- package/lib/cloudflare/miniflare/delete.js.map +1 -1
- package/lib/cloudflare/miniflare/paths.d.ts +0 -1
- package/lib/cloudflare/miniflare/paths.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/paths.js +4 -17
- package/lib/cloudflare/miniflare/paths.js.map +1 -1
- package/lib/cloudflare/nuxt/plugin.d.ts.map +1 -1
- package/lib/cloudflare/nuxt/plugin.js +2 -2
- package/lib/cloudflare/nuxt/plugin.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +0 -2
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/react-router/plugin.d.ts.map +1 -1
- package/lib/cloudflare/react-router/plugin.js +0 -1
- package/lib/cloudflare/react-router/plugin.js.map +1 -1
- package/lib/cloudflare/vite/plugin.d.ts.map +1 -1
- package/lib/cloudflare/vite/plugin.js +3 -3
- package/lib/cloudflare/vite/plugin.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +0 -4
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts +1 -1
- package/lib/cloudflare/worker-assets.d.ts.map +1 -1
- package/lib/cloudflare/worker-assets.js +1 -1
- package/lib/cloudflare/worker-assets.js.map +1 -1
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker-tail.d.ts.map +1 -1
- package/lib/cloudflare/worker-tail.js.map +1 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +3 -1
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.js +0 -1
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts +1 -1
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +3 -28
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/coinbase/evm-account.d.ts.map +1 -1
- package/lib/coinbase/evm-account.js.map +1 -1
- package/lib/coinbase/evm-smart-account.d.ts.map +1 -1
- package/lib/coinbase/evm-smart-account.js.map +1 -1
- package/lib/docker/api.d.ts.map +1 -1
- package/lib/docker/api.js.map +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js.map +1 -1
- package/lib/neon/api/sdk.gen.d.ts.map +1 -1
- package/lib/neon/api/sdk.gen.js.map +1 -1
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js.map +1 -1
- package/lib/planetscale/api/sdk.gen.d.ts.map +1 -1
- package/lib/planetscale/api/sdk.gen.js.map +1 -1
- package/lib/prisma-postgres/api/sdk.gen.d.ts.map +1 -1
- package/lib/prisma-postgres/api/sdk.gen.js.map +1 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +2 -2
- package/lib/scope.js.map +1 -1
- package/lib/sentry/client-key.js +1 -1
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js.map +1 -1
- package/lib/util/api/client/client.gen.d.ts +1 -1
- package/lib/util/api/client/client.gen.js +45 -45
- package/lib/util/api/client/types.gen.d.ts +22 -22
- package/lib/util/api/client/utils.gen.d.ts +3 -3
- package/lib/util/api/client/utils.gen.d.ts.map +1 -1
- package/lib/util/api/client/utils.gen.js +34 -34
- package/lib/util/api/client/utils.gen.js.map +1 -1
- package/lib/util/api/core/auth.gen.d.ts +3 -3
- package/lib/util/api/core/auth.gen.js +3 -3
- package/lib/util/api/core/bodySerializer.gen.d.ts +1 -1
- package/lib/util/api/core/bodySerializer.gen.js +3 -3
- package/lib/util/api/core/params.gen.d.ts +3 -3
- package/lib/util/api/core/params.gen.js +7 -7
- package/lib/util/api/core/pathSerializer.gen.d.ts +3 -3
- package/lib/util/api/core/pathSerializer.gen.js +36 -36
- package/lib/util/api/core/serverSentEvents.gen.d.ts +3 -3
- package/lib/util/api/core/serverSentEvents.gen.js +18 -18
- package/lib/util/api/core/types.gen.d.ts +4 -4
- package/lib/util/api/core/utils.gen.d.ts +1 -1
- package/lib/util/api/core/utils.gen.js +17 -17
- package/lib/util/camel-to-snake.d.ts.map +1 -1
- package/lib/util/find-workspace-root.d.ts +3 -0
- package/lib/util/find-workspace-root.d.ts.map +1 -0
- package/lib/util/find-workspace-root.js +94 -0
- package/lib/util/find-workspace-root.js.map +1 -0
- package/lib/util/idempotent-spawn.d.ts.map +1 -1
- package/lib/util/idempotent-spawn.js +1 -1
- package/lib/util/idempotent-spawn.js.map +1 -1
- package/lib/util/peer.d.ts.map +1 -1
- package/lib/util/peer.js.map +1 -1
- package/package.json +1 -1
- package/src/alchemy.ts +4 -3
- package/src/apply.ts +16 -1
- package/src/aws/control/types.ts +87107 -85281
- package/src/clickhouse/api/sdk.gen.ts +1 -3
- package/src/cloudflare/account-api-token.ts +3 -1
- package/src/cloudflare/bound.ts +64 -65
- package/src/cloudflare/bucket.ts +4 -7
- package/src/cloudflare/cloudflare-env-proxy.ts +2 -4
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/d1-database.ts +0 -9
- package/src/cloudflare/dns-records.ts +3 -1
- package/src/cloudflare/hyperdrive.ts +0 -1
- package/src/cloudflare/miniflare/delete.ts +3 -0
- package/src/cloudflare/miniflare/paths.ts +4 -25
- package/src/cloudflare/nuxt/plugin.ts +1 -4
- package/src/cloudflare/queue-consumer.ts +0 -2
- package/src/cloudflare/react-router/plugin.ts +0 -1
- package/src/cloudflare/vite/plugin.ts +1 -3
- package/src/cloudflare/website.ts +0 -5
- package/src/cloudflare/worker-assets.ts +1 -6
- package/src/cloudflare/worker-metadata.ts +5 -3
- package/src/cloudflare/worker-tail.ts +3 -1
- package/src/cloudflare/worker.ts +3 -1
- package/src/cloudflare/wrangler.json.ts +0 -1
- package/src/cloudflare/zone.ts +6 -38
- package/src/coinbase/evm-account.ts +3 -1
- package/src/coinbase/evm-smart-account.ts +3 -1
- package/src/docker/api.ts +3 -1
- package/src/github/secret.ts +5 -1
- package/src/neon/api/sdk.gen.ts +1 -3
- package/src/os/exec.ts +3 -1
- package/src/planetscale/api/sdk.gen.ts +1 -3
- package/src/prisma-postgres/api/sdk.gen.ts +1 -3
- package/src/scope.ts +2 -2
- package/src/sentry/client-key.ts +1 -5
- package/src/test/bun.ts +3 -1
- package/src/test/vitest.ts +3 -1
- package/src/util/api/client/client.gen.ts +49 -49
- package/src/util/api/client/types.gen.ts +43 -43
- package/src/util/api/client/utils.gen.ts +47 -42
- package/src/util/api/core/auth.gen.ts +6 -6
- package/src/util/api/core/bodySerializer.gen.ts +4 -4
- package/src/util/api/core/params.gen.ts +10 -10
- package/src/util/api/core/pathSerializer.gen.ts +39 -39
- package/src/util/api/core/serverSentEvents.gen.ts +22 -22
- package/src/util/api/core/types.gen.ts +12 -12
- package/src/util/api/core/utils.gen.ts +18 -18
- package/src/util/camel-to-snake.ts +12 -10
- package/src/util/find-workspace-root.ts +112 -0
- package/src/util/idempotent-spawn.ts +1 -5
- package/src/util/peer.ts +3 -1
- package/templates/astro/astro.config.mjs +3 -3
- package/templates/astro/src/pages/api/hello.ts +16 -13
- package/templates/bun-spa/bun-env.d.ts +0 -1
- package/templates/bun-spa/eslint.config.js +11 -12
- package/templates/bun-spa/src/App.tsx +0 -1
- package/templates/bun-spa/src/frontend.tsx +0 -1
- package/templates/hono/src/index.ts +13 -13
- package/templates/nextjs/alchemy.run.ts +1 -1
- package/templates/nextjs/eslint.config.mjs +1 -1
- package/templates/nextjs/next-env.d.ts +1 -1
- package/templates/nextjs/next.config.ts +1 -1
- package/templates/nextjs/open-next.config.ts +1 -1
- package/templates/nextjs/src/app/api/hello/route.ts +2 -2
- package/templates/nextjs/src/app/layout.tsx +1 -1
- package/templates/nextjs/src/app/page.tsx +14 -15
- package/templates/nextjs/types/env.d.ts +4 -4
- package/templates/nuxt/server/middleware/auth.ts +1 -1
- package/templates/nuxt/server/middleware/hello.ts +2 -2
- package/templates/react-router/app/entry.server.tsx +2 -2
- package/templates/react-router/vite.config.ts +1 -1
- package/templates/react-router/workers/app.ts +2 -2
- package/templates/rwsdk/alchemy.run.ts +6 -3
- package/templates/sveltekit/src/app.d.ts +7 -7
- package/templates/sveltekit/svelte.config.js +4 -4
- package/templates/sveltekit/vite.config.ts +3 -3
- package/templates/tanstack-start/src/components/Header.tsx +2 -2
- package/templates/tanstack-start/src/router.tsx +4 -4
- package/templates/tanstack-start/src/routes/__root.tsx +10 -10
- package/templates/tanstack-start/src/routes/api.demo-names.ts +6 -6
- package/templates/tanstack-start/src/routes/demo.start.api-request.tsx +11 -11
- package/templates/tanstack-start/src/routes/demo.start.server-funcs.tsx +30 -30
- package/templates/tanstack-start/src/routes/index.tsx +5 -5
- package/templates/tanstack-start/vite.config.ts +9 -9
- package/templates/typescript/src/worker.ts +5 -1
- package/templates/vite/eslint.config.js +12 -12
- package/templates/vite/src/App.tsx +7 -7
- package/templates/vite/src/main.tsx +6 -6
- package/templates/vite/src/worker.ts +11 -12
- package/templates/vite/vite.config.ts +2 -2
- package/workers/tunnel-proxy.js +1 -1
- package/bin/services/find-workspace-root.ts +0 -48
- package/lib/cloudflare/miniflare/symlink-miniflare-state.d.ts +0 -2
- package/lib/cloudflare/miniflare/symlink-miniflare-state.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/symlink-miniflare-state.js +0 -18
- package/lib/cloudflare/miniflare/symlink-miniflare-state.js.map +0 -1
- package/src/cloudflare/miniflare/symlink-miniflare-state.ts +0 -18
|
@@ -200,9 +200,7 @@ export type Options<
|
|
|
200
200
|
class _HeyApiClient {
|
|
201
201
|
protected _client: Client = client;
|
|
202
202
|
|
|
203
|
-
constructor(args?: {
|
|
204
|
-
client?: Client;
|
|
205
|
-
}) {
|
|
203
|
+
constructor(args?: { client?: Client }) {
|
|
206
204
|
if (args?.client) {
|
|
207
205
|
this._client = args.client;
|
|
208
206
|
}
|
|
@@ -360,7 +360,9 @@ export const AccountApiToken = Resource(
|
|
|
360
360
|
}));
|
|
361
361
|
|
|
362
362
|
throw new Error(
|
|
363
|
-
`Error ${
|
|
363
|
+
`Error ${
|
|
364
|
+
this.phase === "update" ? "updating" : "creating"
|
|
365
|
+
} token '${tokenName}': ${
|
|
364
366
|
errorData.errors?.[0]?.message || response.statusText
|
|
365
367
|
}`,
|
|
366
368
|
);
|
package/src/cloudflare/bound.ts
CHANGED
|
@@ -37,69 +37,68 @@ type BoundWorker<
|
|
|
37
37
|
>]: Rpc.Provider<RPC, "fetch" | "connect">[property];
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export type Bound<T extends Binding> =
|
|
41
|
-
infer O
|
|
42
|
-
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
: T extends WorkerStub<infer RPC>
|
|
47
|
-
? BoundWorker<RPC>
|
|
48
|
-
: T extends _Worker<any, infer RPC> | WorkerRef<infer RPC>
|
|
40
|
+
export type Bound<T extends Binding> =
|
|
41
|
+
T extends _DurableObjectNamespace<infer O>
|
|
42
|
+
? DurableObjectNamespace<O & Rpc.DurableObjectBranded>
|
|
43
|
+
: T extends { type: "kv_namespace" }
|
|
44
|
+
? KVNamespace
|
|
45
|
+
: T extends WorkerStub<infer RPC>
|
|
49
46
|
? BoundWorker<RPC>
|
|
50
|
-
: T extends
|
|
51
|
-
?
|
|
52
|
-
: T extends
|
|
53
|
-
?
|
|
54
|
-
: T extends
|
|
55
|
-
?
|
|
56
|
-
: T extends
|
|
57
|
-
?
|
|
58
|
-
: T extends
|
|
59
|
-
?
|
|
60
|
-
: T extends
|
|
61
|
-
?
|
|
62
|
-
: T extends
|
|
63
|
-
?
|
|
64
|
-
: T extends
|
|
65
|
-
?
|
|
66
|
-
: T extends
|
|
67
|
-
?
|
|
68
|
-
: T extends
|
|
69
|
-
?
|
|
70
|
-
: T extends
|
|
71
|
-
?
|
|
72
|
-
: T extends
|
|
73
|
-
?
|
|
74
|
-
: T extends
|
|
75
|
-
?
|
|
76
|
-
: T extends
|
|
77
|
-
?
|
|
78
|
-
: T extends
|
|
79
|
-
?
|
|
80
|
-
: T extends
|
|
81
|
-
?
|
|
82
|
-
: T extends
|
|
83
|
-
?
|
|
84
|
-
: T extends
|
|
85
|
-
?
|
|
86
|
-
: T extends
|
|
87
|
-
?
|
|
88
|
-
: T extends
|
|
89
|
-
?
|
|
90
|
-
: T extends
|
|
91
|
-
?
|
|
92
|
-
: T extends
|
|
93
|
-
?
|
|
94
|
-
: T extends
|
|
95
|
-
?
|
|
96
|
-
: T extends
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
:
|
|
47
|
+
: T extends _Worker<any, infer RPC> | WorkerRef<infer RPC>
|
|
48
|
+
? BoundWorker<RPC>
|
|
49
|
+
: T extends { type: "service" }
|
|
50
|
+
? Service
|
|
51
|
+
: T extends _R2Bucket
|
|
52
|
+
? R2Bucket
|
|
53
|
+
: T extends _Hyperdrive | HyperdriveRef
|
|
54
|
+
? Hyperdrive
|
|
55
|
+
: T extends Secret
|
|
56
|
+
? string
|
|
57
|
+
: T extends CloudflareSecret | CloudflareSecretRef
|
|
58
|
+
? SecretsStoreSecret
|
|
59
|
+
: T extends SecretKey
|
|
60
|
+
? CryptoKey
|
|
61
|
+
: T extends Assets
|
|
62
|
+
? Service
|
|
63
|
+
: T extends _Workflow<infer P>
|
|
64
|
+
? Workflow<P>
|
|
65
|
+
: T extends _D1Database
|
|
66
|
+
? D1Database
|
|
67
|
+
: T extends DispatchNamespace
|
|
68
|
+
? DispatchNamespace
|
|
69
|
+
: T extends _WorkerLoader
|
|
70
|
+
? WorkerLoader
|
|
71
|
+
: T extends _VectorizeIndex
|
|
72
|
+
? VectorizeIndex
|
|
73
|
+
: T extends _Queue<infer Body>
|
|
74
|
+
? Queue<Body>
|
|
75
|
+
: T extends _AnalyticsEngineDataset
|
|
76
|
+
? AnalyticsEngineDataset
|
|
77
|
+
: T extends _Pipeline<infer R>
|
|
78
|
+
? Pipeline<R>
|
|
79
|
+
: T extends _RateLimit
|
|
80
|
+
? RateLimit
|
|
81
|
+
: T extends string
|
|
82
|
+
? T
|
|
83
|
+
: T extends BrowserRendering
|
|
84
|
+
? Fetcher
|
|
85
|
+
: T extends _Ai<infer M>
|
|
86
|
+
? Ai<M>
|
|
87
|
+
: T extends _Images
|
|
88
|
+
? ImagesBinding
|
|
89
|
+
: T extends _VersionMetadata
|
|
90
|
+
? WorkerVersionMetadata
|
|
91
|
+
: T extends Self
|
|
92
|
+
? Service
|
|
93
|
+
: T extends Json<infer T>
|
|
94
|
+
? T
|
|
95
|
+
: T extends _Container<
|
|
96
|
+
infer Obj
|
|
97
|
+
>
|
|
98
|
+
? DurableObjectNamespace<
|
|
99
|
+
Obj &
|
|
100
|
+
Rpc.DurableObjectBranded
|
|
101
|
+
>
|
|
102
|
+
: T extends undefined
|
|
103
|
+
? undefined
|
|
104
|
+
: Service;
|
package/src/cloudflare/bucket.ts
CHANGED
|
@@ -1007,7 +1007,9 @@ export async function listBuckets(
|
|
|
1007
1007
|
}
|
|
1008
1008
|
|
|
1009
1009
|
// Build URL with query parameters
|
|
1010
|
-
const path = `/accounts/${api.accountId}/r2/buckets${
|
|
1010
|
+
const path = `/accounts/${api.accountId}/r2/buckets${
|
|
1011
|
+
params.toString() ? `?${params.toString()}` : ""
|
|
1012
|
+
}`;
|
|
1011
1013
|
|
|
1012
1014
|
// Make the API request
|
|
1013
1015
|
const result = await extractCloudflareResult<{
|
|
@@ -1262,12 +1264,7 @@ function mapHeadersToHttpMetadata(headers: Headers): R2HTTPMetadata {
|
|
|
1262
1264
|
|
|
1263
1265
|
export async function putObject(
|
|
1264
1266
|
api: CloudflareApi,
|
|
1265
|
-
{
|
|
1266
|
-
bucketName,
|
|
1267
|
-
key,
|
|
1268
|
-
object,
|
|
1269
|
-
options,
|
|
1270
|
-
}: {
|
|
1267
|
+
{ bucketName, key, object, options }: {
|
|
1271
1268
|
bucketName: string;
|
|
1272
1269
|
key: string;
|
|
1273
1270
|
object: PutObjectObject;
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
getDefaultConfigPath,
|
|
4
4
|
getDefaultPersistPath,
|
|
5
5
|
validateConfigPath,
|
|
6
|
-
validatePersistPath,
|
|
7
6
|
} from "./miniflare/paths.ts";
|
|
8
7
|
|
|
9
8
|
export const getCloudflareEnvProxy = async <E>(
|
|
@@ -22,12 +21,11 @@ export const getPlatformProxyOptions = (
|
|
|
22
21
|
input.persist === false
|
|
23
22
|
? false
|
|
24
23
|
: {
|
|
25
|
-
path:
|
|
24
|
+
path:
|
|
26
25
|
typeof input.persist === "object" &&
|
|
27
|
-
|
|
26
|
+
typeof input.persist.path === "string"
|
|
28
27
|
? input.persist.path
|
|
29
28
|
: getDefaultPersistPath(),
|
|
30
|
-
),
|
|
31
29
|
};
|
|
32
30
|
if (!persist) {
|
|
33
31
|
const message =
|
|
@@ -318,7 +318,6 @@ const _D1Database = Resource(
|
|
|
318
318
|
// after that, the ID will remain the UUID for the lifetime of the database
|
|
319
319
|
!this.output?.id
|
|
320
320
|
) {
|
|
321
|
-
logger.log("Creating D1 database:", databaseName);
|
|
322
321
|
try {
|
|
323
322
|
dbData = await createDatabase(api, databaseName, props);
|
|
324
323
|
|
|
@@ -354,9 +353,6 @@ const _D1Database = Resource(
|
|
|
354
353
|
|
|
355
354
|
// Update the database with the provided properties
|
|
356
355
|
if (props.readReplication) {
|
|
357
|
-
logger.log(
|
|
358
|
-
`Updating adopted database ${databaseName} with new properties`,
|
|
359
|
-
);
|
|
360
356
|
dbData = await updateDatabase(api, existingDb.id, props);
|
|
361
357
|
}
|
|
362
358
|
} else {
|
|
@@ -374,15 +370,10 @@ const _D1Database = Resource(
|
|
|
374
370
|
`Cannot update primaryLocationHint from '${this.output.primaryLocationHint}' to '${props.primaryLocationHint}' after database creation.`,
|
|
375
371
|
);
|
|
376
372
|
}
|
|
377
|
-
logger.log("Updating D1 database:", databaseName);
|
|
378
373
|
// Update the database with new properties
|
|
379
374
|
dbData = await updateDatabase(api, this.output.id, props);
|
|
380
375
|
} else {
|
|
381
376
|
// If no ID exists, fall back to creating a new database
|
|
382
|
-
logger.log(
|
|
383
|
-
"No existing database ID found, creating new D1 database:",
|
|
384
|
-
databaseName,
|
|
385
|
-
);
|
|
386
377
|
dbData = await createDatabase(api, databaseName, props);
|
|
387
378
|
}
|
|
388
379
|
|
|
@@ -314,7 +314,9 @@ async function createOrUpdateRecord(
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
throw new Error(
|
|
317
|
-
`Failed to ${
|
|
317
|
+
`Failed to ${
|
|
318
|
+
existingId ? "update" : "create"
|
|
319
|
+
} DNS record ${record.name}: ${response.statusText}\nResponse: ${errorBody}`,
|
|
318
320
|
);
|
|
319
321
|
}
|
|
320
322
|
|
|
@@ -167,7 +167,6 @@ export interface HyperdriveProps extends CloudflareApiOptions {
|
|
|
167
167
|
/**
|
|
168
168
|
* UUID of the hyperdrive (only used for update/delete operations)
|
|
169
169
|
* This is provided by Cloudflare and is different from the resource ID
|
|
170
|
-
* @internal
|
|
171
170
|
*/
|
|
172
171
|
hyperdriveId?: string;
|
|
173
172
|
|
|
@@ -38,6 +38,9 @@ export async function deleteMiniflareBinding(
|
|
|
38
38
|
.catch(() => []);
|
|
39
39
|
await Promise.all(files.map((file) => fs.rm(path.join(bindingPath, file))));
|
|
40
40
|
|
|
41
|
+
// if running E2E tests, do not delete the data directory to prevent race conditions in smoke tests
|
|
42
|
+
if (process.env.ALCHEMY_E2E) return;
|
|
43
|
+
|
|
41
44
|
// delete data directory, if present
|
|
42
45
|
await removeDirectory(path.join(persistRoot, type, id), {
|
|
43
46
|
recursive: true,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
// biome-ignore lint/style/noRestrictedImports: I/O is acceptable here
|
|
3
|
-
import { existsSync
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
4
|
import path from "pathe";
|
|
5
|
+
import { findWorkspaceRootSync } from "../../util/find-workspace-root.ts";
|
|
5
6
|
import { ALCHEMY_ROOT } from "../../util/root-dir.ts";
|
|
6
7
|
|
|
7
8
|
const dynamicImportContext = new AsyncLocalStorage<boolean>();
|
|
@@ -18,7 +19,8 @@ export const getDefaultConfigPath = (rootDir: string = process.cwd()) => {
|
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export const getDefaultPersistPath = (rootDir: string = ALCHEMY_ROOT) => {
|
|
21
|
-
|
|
22
|
+
const workspaceRoot = findWorkspaceRootSync(rootDir);
|
|
23
|
+
return path.join(workspaceRoot, ".alchemy", "miniflare", "v3");
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export const validateConfigPath = (path: string, throws = true) => {
|
|
@@ -31,29 +33,6 @@ export const validateConfigPath = (path: string, throws = true) => {
|
|
|
31
33
|
return path;
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
const DEFAULT_VALIDATE_PERSIST =
|
|
35
|
-
process.env.NODE_ENV === "development" ||
|
|
36
|
-
!process.argv.some((arg) => ["build", "prepare", "typegen"].includes(arg));
|
|
37
|
-
|
|
38
|
-
export const validatePersistPath = (
|
|
39
|
-
path: string,
|
|
40
|
-
throws = DEFAULT_VALIDATE_PERSIST,
|
|
41
|
-
) => {
|
|
42
|
-
try {
|
|
43
|
-
const stat = statSync(path);
|
|
44
|
-
if (stat.isSymbolicLink()) {
|
|
45
|
-
return readlinkSync(path);
|
|
46
|
-
}
|
|
47
|
-
return path;
|
|
48
|
-
} catch {
|
|
49
|
-
warnOrThrow(
|
|
50
|
-
`The Alchemy data path, "${path}", could not be resolved. This is required for Cloudflare bindings during development. Please run \`alchemy dev\` to create it.`,
|
|
51
|
-
throws,
|
|
52
|
-
);
|
|
53
|
-
return path;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
36
|
const warned = new Set<string>();
|
|
58
37
|
|
|
59
38
|
const warnOrThrow = (message: string, throws: boolean) => {
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
getDefaultConfigPath,
|
|
4
4
|
getDefaultPersistPath,
|
|
5
5
|
validateConfigPath,
|
|
6
|
-
validatePersistPath,
|
|
7
6
|
} from "../miniflare/paths.ts";
|
|
8
7
|
|
|
9
8
|
const alchemy = (
|
|
@@ -15,9 +14,7 @@ const alchemy = (
|
|
|
15
14
|
configPath: validateConfigPath(
|
|
16
15
|
options.dev?.configPath ?? getDefaultConfigPath(),
|
|
17
16
|
),
|
|
18
|
-
persistDir:
|
|
19
|
-
options.dev?.persistDir ?? getDefaultPersistPath(),
|
|
20
|
-
),
|
|
17
|
+
persistDir: options.dev?.persistDir ?? getDefaultPersistPath(),
|
|
21
18
|
...options.dev,
|
|
22
19
|
},
|
|
23
20
|
...options,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Context } from "../context.ts";
|
|
2
2
|
import { Resource } from "../resource.ts";
|
|
3
|
-
import { logger } from "../util/logger.ts";
|
|
4
3
|
import { CloudflareApiError, handleApiError } from "./api-error.ts";
|
|
5
4
|
import {
|
|
6
5
|
createCloudflareApi,
|
|
@@ -174,7 +173,6 @@ export const QueueConsumer = Resource(
|
|
|
174
173
|
const api = await createCloudflareApi(props);
|
|
175
174
|
|
|
176
175
|
if (this.phase === "delete") {
|
|
177
|
-
logger.log(`Deleting Queue Consumer for queue ${queueId}`);
|
|
178
176
|
if (props.delete !== false && this.output?.id) {
|
|
179
177
|
// Delete the consumer
|
|
180
178
|
await deleteQueueConsumer(api, queueId, this.output.id);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PluginConfig } from "@cloudflare/vite-plugin";
|
|
2
|
-
// biome-ignore lint/style/noRestrictedImports: I/O is acceptable here
|
|
3
2
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { dirname } from "pathe";
|
|
5
4
|
import { getDefaultConfigPath } from "../miniflare/paths.ts";
|
|
@@ -5,17 +5,15 @@ import {
|
|
|
5
5
|
getDefaultConfigPath,
|
|
6
6
|
getDefaultPersistPath,
|
|
7
7
|
validateConfigPath,
|
|
8
|
-
validatePersistPath,
|
|
9
8
|
} from "../miniflare/paths.ts";
|
|
10
9
|
|
|
11
10
|
const alchemy = (config?: PluginConfig): PluginOption => {
|
|
12
11
|
const persistState = config?.persistState ?? {
|
|
13
|
-
path:
|
|
12
|
+
path:
|
|
14
13
|
typeof config?.persistState === "object"
|
|
15
14
|
? config.persistState.path
|
|
16
15
|
: // persist path should default to the /.alchemy/miniflare/v3
|
|
17
16
|
getDefaultPersistPath(),
|
|
18
|
-
),
|
|
19
17
|
};
|
|
20
18
|
if (typeof persistState === "object" && persistState.path.endsWith("v3")) {
|
|
21
19
|
persistState.path = path.dirname(persistState.path);
|
|
@@ -9,7 +9,6 @@ import { Assets } from "./assets.ts";
|
|
|
9
9
|
import type { Bindings } from "./bindings.ts";
|
|
10
10
|
import { DEFAULT_COMPATIBILITY_DATE } from "./compatibility-date.gen.ts";
|
|
11
11
|
import { unionCompatibilityFlags } from "./compatibility-presets.ts";
|
|
12
|
-
import { writeMiniflareSymlink } from "./miniflare/symlink-miniflare-state.ts";
|
|
13
12
|
import {
|
|
14
13
|
extractStringAndSecretBindings,
|
|
15
14
|
unencryptSecrets,
|
|
@@ -263,10 +262,6 @@ export async function Website<B extends Bindings>(
|
|
|
263
262
|
await fs.writeFile(paths.entrypoint, content);
|
|
264
263
|
}
|
|
265
264
|
|
|
266
|
-
if (Scope.current.local) {
|
|
267
|
-
await writeMiniflareSymlink(Scope.current.rootDir, paths.cwd);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
265
|
await WranglerJson({
|
|
271
266
|
path: path.relative(paths.cwd, paths.wrangler.path),
|
|
272
267
|
worker,
|
|
@@ -30,12 +30,7 @@ interface FileMetadata {
|
|
|
30
30
|
*/
|
|
31
31
|
export async function uploadAssets(
|
|
32
32
|
api: CloudflareApi,
|
|
33
|
-
{
|
|
34
|
-
workerName,
|
|
35
|
-
assets,
|
|
36
|
-
assetConfig,
|
|
37
|
-
namespace,
|
|
38
|
-
}: {
|
|
33
|
+
{ workerName, assets, assetConfig, namespace }: {
|
|
39
34
|
workerName: string;
|
|
40
35
|
assets: Assets;
|
|
41
36
|
assetConfig?: WorkerProps["assets"];
|
|
@@ -239,9 +239,11 @@ export async function prepareWorkerMetadata(
|
|
|
239
239
|
};
|
|
240
240
|
},
|
|
241
241
|
): Promise<WorkerMetadata> {
|
|
242
|
-
const oldSettings = await (
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
const oldSettings = await (
|
|
243
|
+
props.unstable_cacheWorkerSettings
|
|
244
|
+
? getWorkerSettingsWithCache
|
|
245
|
+
: getWorkerSettings
|
|
246
|
+
)(api, props.workerName);
|
|
245
247
|
const oldTags: string[] | undefined = Array.from(
|
|
246
248
|
new Set([
|
|
247
249
|
...(oldSettings?.default_environment?.script?.tags ?? []),
|
|
@@ -110,7 +110,9 @@ class TailClient {
|
|
|
110
110
|
const status = event.response?.status ?? 500;
|
|
111
111
|
// TODO: make this look nicer
|
|
112
112
|
logger.log(
|
|
113
|
-
`${prefix} ${pc.gray(event.request.method)} ${url.pathname} ${pc.dim(">")} ${
|
|
113
|
+
`${prefix} ${pc.gray(event.request.method)} ${url.pathname} ${pc.dim(">")} ${
|
|
114
|
+
status >= 200 && status < 300 ? pc.green(status) : pc.red(status)
|
|
115
|
+
} ${pc.gray(`(cpu: ${Math.round(data.cpuTime)}ms, wall: ${Math.round(data.wallTime)}ms)`)}`,
|
|
114
116
|
);
|
|
115
117
|
}
|
|
116
118
|
for (const log of data.logs) {
|
package/src/cloudflare/worker.ts
CHANGED
|
@@ -831,7 +831,9 @@ const _Worker = Resource(
|
|
|
831
831
|
) {
|
|
832
832
|
let adopt = props.adopt ?? this.scope.adopt;
|
|
833
833
|
const workerName =
|
|
834
|
-
props.name ??
|
|
834
|
+
props.name ??
|
|
835
|
+
this.output?.name ??
|
|
836
|
+
this.scope.createPhysicalName(id).toLowerCase();
|
|
835
837
|
if (this.phase === "create" && !props.adopt) {
|
|
836
838
|
// it is possible that this worker already exists and was created by the old Website wrapper with a nested scope
|
|
837
839
|
// we need to detect this and set adopt=true so that the previous version will be adopted seamlessly
|
package/src/cloudflare/zone.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Context } from "../context.ts";
|
|
|
2
2
|
import { Resource } from "../resource.ts";
|
|
3
3
|
import { logger } from "../util/logger.ts";
|
|
4
4
|
import { handleApiError } from "./api-error.ts";
|
|
5
|
+
import { extractCloudflareResult } from "./api-response.ts";
|
|
5
6
|
import {
|
|
6
7
|
createCloudflareApi,
|
|
7
8
|
type CloudflareApi,
|
|
@@ -568,45 +569,12 @@ async function getZoneSettings(
|
|
|
568
569
|
export async function getZoneByDomain(
|
|
569
570
|
api: CloudflareApi,
|
|
570
571
|
domainName: string,
|
|
571
|
-
): Promise<
|
|
572
|
-
const
|
|
573
|
-
|
|
572
|
+
): Promise<CloudflareZone | undefined> {
|
|
573
|
+
const [zone] = await extractCloudflareResult<CloudflareZone[]>(
|
|
574
|
+
`get zone for ${domainName}`,
|
|
575
|
+
api.get(`/zones?name=${encodeURIComponent(domainName)}`),
|
|
574
576
|
);
|
|
575
|
-
|
|
576
|
-
if (!response.ok) {
|
|
577
|
-
throw new Error(
|
|
578
|
-
`Error fetching zone for '${domainName}': ${response.statusText}`,
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const zones = ((await response.json()) as { result: CloudflareZone[] })
|
|
583
|
-
.result;
|
|
584
|
-
|
|
585
|
-
if (zones.length === 0) {
|
|
586
|
-
return null;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
const zoneData = zones[0];
|
|
590
|
-
|
|
591
|
-
// Get zone settings
|
|
592
|
-
const settings = await getZoneSettings(api, zoneData.id);
|
|
593
|
-
|
|
594
|
-
return {
|
|
595
|
-
id: zoneData.id,
|
|
596
|
-
name: zoneData.name,
|
|
597
|
-
type: zoneData.type,
|
|
598
|
-
status: zoneData.status,
|
|
599
|
-
paused: zoneData.paused,
|
|
600
|
-
accountId: zoneData.account.id,
|
|
601
|
-
nameservers: zoneData.name_servers,
|
|
602
|
-
originalNameservers: zoneData.original_name_servers,
|
|
603
|
-
createdAt: new Date(zoneData.created_on).getTime(),
|
|
604
|
-
modifiedAt: new Date(zoneData.modified_on).getTime(),
|
|
605
|
-
activatedAt: zoneData.activated_on
|
|
606
|
-
? new Date(zoneData.activated_on).getTime()
|
|
607
|
-
: null,
|
|
608
|
-
settings,
|
|
609
|
-
};
|
|
577
|
+
return zone;
|
|
610
578
|
}
|
|
611
579
|
|
|
612
580
|
/**
|
|
@@ -207,7 +207,9 @@ export const EvmAccount = Resource(
|
|
|
207
207
|
);
|
|
208
208
|
|
|
209
209
|
console.log(
|
|
210
|
-
`💧 Requested ${toFund.length} new faucet fund${
|
|
210
|
+
`💧 Requested ${toFund.length} new faucet fund${
|
|
211
|
+
toFund.length === 1 ? "" : "s"
|
|
212
|
+
} for ${this.output.address}`,
|
|
211
213
|
);
|
|
212
214
|
}
|
|
213
215
|
} catch (error: any) {
|
|
@@ -234,7 +234,9 @@ export const EvmSmartAccount = Resource(
|
|
|
234
234
|
);
|
|
235
235
|
|
|
236
236
|
console.log(
|
|
237
|
-
`💧 Requested ${toFund.length} new faucet fund${
|
|
237
|
+
`💧 Requested ${toFund.length} new faucet fund${
|
|
238
|
+
toFund.length === 1 ? "" : "s"
|
|
239
|
+
} for smart account ${this.output.address}`,
|
|
238
240
|
);
|
|
239
241
|
}
|
|
240
242
|
} catch (error: any) {
|
package/src/docker/api.ts
CHANGED
|
@@ -159,7 +159,9 @@ export class DockerApi {
|
|
|
159
159
|
return true;
|
|
160
160
|
} catch (error) {
|
|
161
161
|
console.log(
|
|
162
|
-
`Docker daemon not running: ${
|
|
162
|
+
`Docker daemon not running: ${
|
|
163
|
+
error instanceof Error ? error.message : String(error)
|
|
164
|
+
}`,
|
|
163
165
|
);
|
|
164
166
|
return false;
|
|
165
167
|
}
|
package/src/github/secret.ts
CHANGED
|
@@ -190,7 +190,11 @@ export const GitHubSecret = Resource(
|
|
|
190
190
|
// If secret type changed, we need to delete the old one first
|
|
191
191
|
if (secretTypeChanged) {
|
|
192
192
|
logger.log(
|
|
193
|
-
`Secret type changed from ${
|
|
193
|
+
`Secret type changed from ${
|
|
194
|
+
wasEnvironmentSecret ? "environment" : "repository"
|
|
195
|
+
} to ${
|
|
196
|
+
isEnvironmentSecret ? "environment" : "repository"
|
|
197
|
+
} secret. Deleting the old secret first.`,
|
|
194
198
|
);
|
|
195
199
|
|
|
196
200
|
try {
|
package/src/neon/api/sdk.gen.ts
CHANGED
|
@@ -338,9 +338,7 @@ export type Options<
|
|
|
338
338
|
class _HeyApiClient {
|
|
339
339
|
protected _client: Client = client;
|
|
340
340
|
|
|
341
|
-
constructor(args?: {
|
|
342
|
-
client?: Client;
|
|
343
|
-
}) {
|
|
341
|
+
constructor(args?: { client?: Client }) {
|
|
344
342
|
if (args?.client) {
|
|
345
343
|
this._client = args.client;
|
|
346
344
|
}
|
package/src/os/exec.ts
CHANGED
|
@@ -355,9 +355,7 @@ export type Options<
|
|
|
355
355
|
class _HeyApiClient {
|
|
356
356
|
protected _client: Client = client;
|
|
357
357
|
|
|
358
|
-
constructor(args?: {
|
|
359
|
-
client?: Client;
|
|
360
|
-
}) {
|
|
358
|
+
constructor(args?: { client?: Client }) {
|
|
361
359
|
if (args?.client) {
|
|
362
360
|
this._client = args.client;
|
|
363
361
|
}
|
package/src/scope.ts
CHANGED
|
@@ -173,8 +173,8 @@ export class Scope {
|
|
|
173
173
|
|
|
174
174
|
public static readonly KIND = "alchemy::Scope" as const;
|
|
175
175
|
|
|
176
|
-
public static storage =
|
|
177
|
-
new AsyncLocalStorage<Scope>()
|
|
176
|
+
public static storage = globalThis.__ALCHEMY_STORAGE__ ??=
|
|
177
|
+
new AsyncLocalStorage<Scope>();
|
|
178
178
|
|
|
179
179
|
public static getScope(): Scope | undefined {
|
|
180
180
|
return Scope.storage.getStore();
|