alchemy 0.12.21 → 0.14.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/lib/ai/client.d.ts.map +1 -1
- package/lib/ai/client.js +3 -5
- package/lib/ai/client.js.map +1 -1
- package/lib/alchemy.d.ts +2 -1
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +87 -92
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +6 -1
- package/lib/apply.js.map +1 -1
- package/lib/aws/bucket.d.ts.map +1 -1
- package/lib/aws/bucket.js +55 -57
- package/lib/aws/bucket.js.map +1 -1
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +250 -252
- package/lib/aws/function.js.map +1 -1
- package/lib/aws/policy-attachment.d.ts.map +1 -1
- package/lib/aws/policy-attachment.js +4 -6
- package/lib/aws/policy-attachment.js.map +1 -1
- package/lib/aws/policy.d.ts.map +1 -1
- package/lib/aws/policy.js +63 -65
- package/lib/aws/policy.js.map +1 -1
- package/lib/aws/queue.js +88 -90
- package/lib/aws/queue.js.map +1 -1
- package/lib/aws/table.d.ts.map +1 -1
- package/lib/aws/table.js +95 -99
- package/lib/aws/table.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +0 -1
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/ai.d.ts +1 -1
- package/lib/cloudflare/ai.d.ts.map +1 -1
- package/lib/cloudflare/ai.js.map +1 -1
- package/lib/cloudflare/api.d.ts +5 -5
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +52 -15
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/auth.d.ts +24 -55
- package/lib/cloudflare/auth.d.ts.map +1 -1
- package/lib/cloudflare/auth.js +15 -72
- package/lib/cloudflare/auth.js.map +1 -1
- package/lib/cloudflare/bucket.d.ts +2 -2
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +22 -24
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bundle/alias-plugin.d.ts +6 -0
- package/lib/cloudflare/bundle/alias-plugin.d.ts.map +1 -0
- package/lib/cloudflare/bundle/alias-plugin.js +36 -0
- package/lib/cloudflare/bundle/alias-plugin.js.map +1 -0
- package/lib/cloudflare/bundle/build-failures.d.ts +12 -0
- package/lib/cloudflare/bundle/build-failures.d.ts.map +1 -0
- package/lib/cloudflare/bundle/build-failures.js +45 -0
- package/lib/cloudflare/bundle/build-failures.js.map +1 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts +7 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -0
- package/lib/cloudflare/bundle/bundle-worker.js +69 -0
- package/lib/cloudflare/bundle/bundle-worker.js.map +1 -0
- package/lib/cloudflare/bundle/external.d.ts +1 -0
- package/lib/cloudflare/bundle/external.d.ts.map +1 -1
- package/lib/cloudflare/bundle/external.js +8 -1
- package/lib/cloudflare/bundle/external.js.map +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts.map +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js +6 -6
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts +17 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.js +27 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -0
- package/lib/cloudflare/bundle/{hybrid-nodejs-compat.d.ts → nodejs-compat.d.ts} +2 -2
- package/lib/cloudflare/bundle/nodejs-compat.d.ts.map +1 -0
- package/lib/cloudflare/bundle/{hybrid-nodejs-compat.js → nodejs-compat.js} +2 -2
- package/lib/cloudflare/bundle/nodejs-compat.js.map +1 -0
- package/lib/cloudflare/custom-domain.d.ts.map +1 -1
- package/lib/cloudflare/custom-domain.js +3 -5
- package/lib/cloudflare/custom-domain.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts +1 -1
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +70 -72
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/d1-migrations.d.ts +1 -1
- package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
- package/lib/cloudflare/d1-migrations.js +2 -3
- package/lib/cloudflare/d1-migrations.js.map +1 -1
- package/lib/cloudflare/dns-records.d.ts.map +1 -1
- package/lib/cloudflare/dns-records.js +2 -4
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +1 -1
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +24 -27
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +1 -1
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +32 -34
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +1 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +27 -33
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/queue.d.ts +1 -1
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +36 -38
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/r2-rest-state-store.js +4 -8
- package/lib/cloudflare/r2-rest-state-store.js.map +1 -1
- package/lib/cloudflare/types.d.ts.map +1 -1
- package/lib/cloudflare/types.js +1 -3
- package/lib/cloudflare/types.js.map +1 -1
- package/lib/cloudflare/user.d.ts +51 -0
- package/lib/cloudflare/user.d.ts.map +1 -0
- package/lib/cloudflare/user.js +62 -0
- package/lib/cloudflare/user.js.map +1 -0
- package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-index.js +37 -39
- package/lib/cloudflare/vectorize-index.js.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.js +10 -13
- package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +18 -3
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +11 -54
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/workflow.d.ts +1 -1
- package/lib/cloudflare/workflow.d.ts.map +1 -1
- package/lib/cloudflare/workflow.js.map +1 -1
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +48 -50
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/dns/godaddy.js +1 -1
- package/lib/dns/import-dns.js +1 -1
- package/lib/dns/import-dns.js.map +1 -1
- package/lib/env.js +7 -9
- package/lib/env.js.map +1 -1
- package/lib/esbuild/bundle.d.ts.map +1 -1
- package/lib/esbuild/bundle.js +8 -11
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/fs/copy-file.d.ts.map +1 -1
- package/lib/fs/copy-file.js +27 -29
- package/lib/fs/copy-file.js.map +1 -1
- package/lib/fs/file.d.ts +1 -1
- package/lib/fs/file.d.ts.map +1 -1
- package/lib/fs/file.js +1 -1
- package/lib/fs/file.js.map +1 -1
- package/lib/fs/folder.d.ts.map +1 -1
- package/lib/fs/folder.js +1 -3
- package/lib/fs/folder.js.map +1 -1
- package/lib/github/client.d.ts.map +1 -1
- package/lib/github/client.js +3 -5
- package/lib/github/client.js.map +1 -1
- package/lib/github/repository-environment.d.ts.map +1 -1
- package/lib/github/repository-environment.js +173 -176
- package/lib/github/repository-environment.js.map +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js +97 -99
- package/lib/github/secret.js.map +1 -1
- package/lib/internal/docs/providers.d.ts.map +1 -1
- package/lib/internal/docs/providers.js +5 -7
- package/lib/internal/docs/providers.js.map +1 -1
- package/lib/neon/api.js +1 -2
- package/lib/neon/api.js.map +1 -1
- package/lib/neon/project.js +2 -2
- package/lib/neon/project.js.map +1 -1
- package/lib/os/exec.d.ts +5 -0
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js +88 -56
- package/lib/os/exec.js.map +1 -1
- package/lib/scope.d.ts +3 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +10 -3
- package/lib/scope.js.map +1 -1
- package/lib/secret.d.ts.map +1 -1
- package/lib/secret.js +1 -3
- package/lib/secret.js.map +1 -1
- package/lib/serde.d.ts.map +1 -1
- package/lib/serde.js +13 -15
- package/lib/serde.js.map +1 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +69 -73
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +50 -52
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +51 -53
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.d.ts +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +3 -8
- package/lib/test/bun.js.map +1 -1
- package/lib/test/prune.d.ts.map +1 -1
- package/lib/test/prune.js.map +1 -1
- package/lib/util/dedent.js +4 -4
- package/lib/util/dedent.js.map +1 -1
- package/lib/web/astro.js +1 -1
- package/lib/web/shadcn.js +4 -4
- package/lib/web/shadcn.js.map +1 -1
- package/lib/web/tailwind.d.ts.map +1 -1
- package/lib/web/tailwind.js +0 -1
- package/lib/web/tailwind.js.map +1 -1
- package/lib/web/vite.js +3 -3
- package/lib/web/vitepress/home-page.d.ts.map +1 -1
- package/lib/web/vitepress/home-page.js +6 -8
- package/lib/web/vitepress/home-page.js.map +1 -1
- package/lib/web/vitepress/process-front-matter-files.js +1 -1
- package/lib/web/vitepress/process-front-matter-files.js.map +1 -1
- package/lib/web/vitepress/vitepress.js +2 -2
- package/lib/web/vitepress/vitepress.js.map +1 -1
- package/package.json +4 -1
- package/src/ai/astro-file.ts +4 -4
- package/src/ai/client.ts +4 -5
- package/src/ai/css-file.ts +4 -4
- package/src/ai/document.ts +3 -3
- package/src/ai/html-file.ts +4 -4
- package/src/ai/json-file.ts +1 -1
- package/src/ai/typescript-file.ts +4 -4
- package/src/ai/vue-file.ts +4 -4
- package/src/ai/yaml-file.ts +1 -1
- package/src/alchemy.ts +111 -104
- package/src/apply.ts +13 -6
- package/src/aws/bucket.ts +72 -75
- package/src/aws/function.ts +296 -297
- package/src/aws/oidc/github-oidc-provider.ts +1 -1
- package/src/aws/oidc/oidc-provider.ts +15 -15
- package/src/aws/policy-attachment.ts +10 -11
- package/src/aws/policy.ts +91 -94
- package/src/aws/queue.ts +111 -111
- package/src/aws/role.ts +24 -24
- package/src/aws/ses.ts +17 -17
- package/src/aws/table.ts +114 -115
- package/src/cloudflare/account-api-token.ts +11 -11
- package/src/cloudflare/ai-gateway.ts +4 -4
- package/src/cloudflare/ai.ts +1 -1
- package/src/cloudflare/api-error.ts +1 -1
- package/src/cloudflare/api.ts +70 -25
- package/src/cloudflare/assets.ts +4 -4
- package/src/cloudflare/auth.ts +49 -164
- package/src/cloudflare/bucket.ts +62 -63
- package/src/cloudflare/bundle/alias-plugin.ts +48 -0
- package/src/cloudflare/bundle/build-failures.ts +55 -0
- package/src/cloudflare/bundle/bundle-worker.ts +89 -0
- package/src/cloudflare/bundle/external.ts +9 -1
- package/src/cloudflare/bundle/local-dev-cloudflare-shim.ts +7 -6
- package/src/cloudflare/bundle/nodejs-compat-mode.ts +49 -0
- package/src/cloudflare/bundle/{hybrid-nodejs-compat.ts → nodejs-compat.ts} +10 -10
- package/src/cloudflare/custom-domain.ts +27 -28
- package/src/cloudflare/d1-database.ts +101 -102
- package/src/cloudflare/d1-migrations.ts +10 -10
- package/src/cloudflare/dns-records.ts +23 -24
- package/src/cloudflare/durable-object-namespace.ts +1 -1
- package/src/cloudflare/event-source.ts +1 -1
- package/src/cloudflare/hyperdrive.ts +3 -3
- package/src/cloudflare/kv-namespace.ts +36 -37
- package/src/cloudflare/nuxt.ts +1 -1
- package/src/cloudflare/permission-groups.ts +7 -7
- package/src/cloudflare/pipeline.ts +55 -56
- package/src/cloudflare/queue-consumer.ts +46 -53
- package/src/cloudflare/queue.ts +56 -57
- package/src/cloudflare/r2-rest-state-store.ts +11 -11
- package/src/cloudflare/redwood.ts +1 -1
- package/src/cloudflare/tanstack-start.ts +1 -1
- package/src/cloudflare/types.ts +1 -2
- package/src/cloudflare/user.ts +142 -0
- package/src/cloudflare/vectorize-index.ts +60 -61
- package/src/cloudflare/vectorize-metadata-index.ts +25 -25
- package/src/cloudflare/vite.ts +1 -1
- package/src/cloudflare/website.ts +3 -3
- package/src/cloudflare/worker.ts +83 -108
- package/src/cloudflare/workflow.ts +4 -4
- package/src/cloudflare/wrangler.json.ts +4 -4
- package/src/cloudflare/zone.ts +69 -70
- package/src/destroy.ts +4 -4
- package/src/dns/godaddy.ts +1 -1
- package/src/dns/import-dns.ts +5 -5
- package/src/encrypt.ts +6 -6
- package/src/env.ts +10 -10
- package/src/esbuild/bundle.ts +14 -15
- package/src/fs/copy-file.ts +35 -36
- package/src/fs/file-system-state-store.ts +4 -4
- package/src/fs/file.ts +9 -8
- package/src/fs/folder.ts +6 -7
- package/src/github/client.ts +15 -14
- package/src/github/repository-environment.ts +206 -210
- package/src/github/secret.ts +111 -116
- package/src/internal/docs/providers.ts +16 -17
- package/src/neon/api-error.ts +1 -1
- package/src/neon/api.ts +6 -6
- package/src/neon/project.ts +18 -17
- package/src/os/exec.ts +107 -66
- package/src/resource.ts +3 -3
- package/src/scope.ts +14 -4
- package/src/secret.ts +2 -3
- package/src/serde.ts +30 -22
- package/src/stripe/price.ts +74 -77
- package/src/stripe/product.ts +55 -56
- package/src/stripe/webhook.ts +56 -57
- package/src/test/bun.ts +9 -13
- package/src/test/prune.ts +4 -4
- package/src/util/dedent.ts +4 -4
- package/src/web/astro.ts +10 -10
- package/src/web/shadcn-component.ts +4 -4
- package/src/web/shadcn.ts +10 -10
- package/src/web/tailwind.ts +2 -3
- package/src/web/vite.ts +11 -11
- package/src/web/vitepress/config.ts +2 -2
- package/src/web/vitepress/custom-theme.ts +7 -7
- package/src/web/vitepress/dependencies.ts +4 -4
- package/src/web/vitepress/home-page.ts +8 -9
- package/src/web/vitepress/process-front-matter-files.ts +5 -5
- package/src/web/vitepress/vitepress.ts +7 -7
- package/lib/cloudflare/account-id.d.ts +0 -6
- package/lib/cloudflare/account-id.d.ts.map +0 -1
- package/lib/cloudflare/account-id.js +0 -6
- package/lib/cloudflare/account-id.js.map +0 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts.map +0 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.js.map +0 -1
- package/src/cloudflare/account-id.ts +0 -12
package/src/cloudflare/worker.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import type { Context } from "../context.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { BundleProps } from "../esbuild/bundle.js";
|
|
5
5
|
import { Resource } from "../resource.js";
|
|
6
6
|
import { getContentType } from "../util/content-type.js";
|
|
7
7
|
import { withExponentialBackoff } from "../util/retry.js";
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
import type { Assets } from "./assets.js";
|
|
16
16
|
import type { Bindings, WorkerBindingSpec } from "./bindings.js";
|
|
17
17
|
import type { Bound } from "./bound.js";
|
|
18
|
-
import {
|
|
19
|
-
import { nodejsHybridPlugin } from "./bundle/hybrid-nodejs-compat.js";
|
|
18
|
+
import { bundleWorkerScript } from "./bundle/bundle-worker.js";
|
|
20
19
|
import type { DurableObjectNamespace } from "./durable-object-namespace.js";
|
|
21
20
|
import { type EventSource, isQueueEventSource } from "./event-source.js";
|
|
22
21
|
import {
|
|
@@ -86,21 +85,31 @@ export interface WorkerProps<B extends Bindings = Bindings>
|
|
|
86
85
|
|
|
87
86
|
/**
|
|
88
87
|
* Path to the entry point file
|
|
88
|
+
*
|
|
89
89
|
* Will be bundled using esbuild
|
|
90
|
+
*
|
|
90
91
|
* One of script, entryPoint, or bundle must be provided
|
|
91
92
|
*/
|
|
92
93
|
entrypoint?: string;
|
|
93
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The project root directory used to resolve aliases.
|
|
97
|
+
*
|
|
98
|
+
* @default process.cwd()
|
|
99
|
+
*/
|
|
100
|
+
projectRoot?: string;
|
|
101
|
+
|
|
94
102
|
/**
|
|
95
103
|
* Bundle options when using entryPoint
|
|
104
|
+
*
|
|
96
105
|
* Ignored if bundle is provided
|
|
97
106
|
*/
|
|
98
107
|
bundle?: Omit<BundleProps, "entryPoint">;
|
|
99
108
|
|
|
100
109
|
/**
|
|
101
110
|
* Module format for the worker script
|
|
102
|
-
* 'esm' - ECMAScript modules (default)
|
|
103
|
-
* 'cjs' - CommonJS modules
|
|
111
|
+
* - 'esm' - ECMAScript modules (default)
|
|
112
|
+
* - 'cjs' - CommonJS modules
|
|
104
113
|
* @default 'esm'
|
|
105
114
|
*/
|
|
106
115
|
format?: "esm" | "cjs";
|
|
@@ -119,6 +128,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
|
|
|
119
128
|
|
|
120
129
|
/**
|
|
121
130
|
* Environment variables to attach to the worker
|
|
131
|
+
*
|
|
122
132
|
* These will be converted to plain_text bindings
|
|
123
133
|
*/
|
|
124
134
|
env?: {
|
|
@@ -127,6 +137,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
|
|
|
127
137
|
|
|
128
138
|
/**
|
|
129
139
|
* Whether to enable a workers.dev URL for this worker
|
|
140
|
+
*
|
|
130
141
|
* If true, the worker will be available at {name}.{subdomain}.workers.dev
|
|
131
142
|
* @default false
|
|
132
143
|
*/
|
|
@@ -134,6 +145,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
|
|
|
134
145
|
|
|
135
146
|
/**
|
|
136
147
|
* Observability configuration for the worker
|
|
148
|
+
*
|
|
137
149
|
* Controls whether worker logs are enabled
|
|
138
150
|
* @default { enabled: true }
|
|
139
151
|
*/
|
|
@@ -173,7 +185,9 @@ export interface WorkerProps<B extends Bindings = Bindings>
|
|
|
173
185
|
|
|
174
186
|
/**
|
|
175
187
|
* Cron expressions for the trigger.
|
|
188
|
+
*
|
|
176
189
|
* Uses standard cron syntax (e.g. "0 0 * * *" for daily at midnight)
|
|
190
|
+
*
|
|
177
191
|
* To clear all cron triggers, pass an empty array.
|
|
178
192
|
*
|
|
179
193
|
* @see https://developers.cloudflare.com/workers/configuration/cron-triggers/#examples
|
|
@@ -182,6 +196,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
|
|
|
182
196
|
|
|
183
197
|
/**
|
|
184
198
|
* Event sources that this worker will consume.
|
|
199
|
+
*
|
|
185
200
|
* Can include queues, streams, or other event sources.
|
|
186
201
|
*/
|
|
187
202
|
eventSources?: EventSource[];
|
|
@@ -341,7 +356,7 @@ export const Worker = Resource(
|
|
|
341
356
|
async function <const B extends Bindings>(
|
|
342
357
|
this: Context<Worker<NoInfer<B>>>,
|
|
343
358
|
id: string,
|
|
344
|
-
props: WorkerProps<B
|
|
359
|
+
props: WorkerProps<B>,
|
|
345
360
|
): Promise<Worker<B>> {
|
|
346
361
|
// Create Cloudflare API client with automatic account discovery
|
|
347
362
|
const api = await createCloudflareApi(props);
|
|
@@ -357,7 +372,8 @@ export const Worker = Resource(
|
|
|
357
372
|
if (this.phase === "delete") {
|
|
358
373
|
await deleteWorker(this, api, workerName);
|
|
359
374
|
return this.destroy();
|
|
360
|
-
}
|
|
375
|
+
}
|
|
376
|
+
if (this.phase === "create") {
|
|
361
377
|
if (!props.adopt) {
|
|
362
378
|
await assertWorkerDoesNotExist(this, api, workerName);
|
|
363
379
|
}
|
|
@@ -370,7 +386,12 @@ export const Worker = Resource(
|
|
|
370
386
|
|
|
371
387
|
// Get the script content - either from props.script, or by bundling
|
|
372
388
|
const scriptContent =
|
|
373
|
-
props.script ??
|
|
389
|
+
props.script ??
|
|
390
|
+
(await bundleWorkerScript({
|
|
391
|
+
...props,
|
|
392
|
+
compatibilityDate,
|
|
393
|
+
compatibilityFlags,
|
|
394
|
+
}));
|
|
374
395
|
|
|
375
396
|
// Find any assets bindings
|
|
376
397
|
const assetsBindings: { name: string; assets: Assets }[] = [];
|
|
@@ -400,7 +421,7 @@ export const Worker = Resource(
|
|
|
400
421
|
api,
|
|
401
422
|
workerName,
|
|
402
423
|
assetBinding.assets,
|
|
403
|
-
props.assets
|
|
424
|
+
props.assets,
|
|
404
425
|
);
|
|
405
426
|
}
|
|
406
427
|
|
|
@@ -413,7 +434,7 @@ export const Worker = Resource(
|
|
|
413
434
|
compatibilityDate,
|
|
414
435
|
compatibilityFlags,
|
|
415
436
|
},
|
|
416
|
-
assetUploadResult
|
|
437
|
+
assetUploadResult,
|
|
417
438
|
);
|
|
418
439
|
|
|
419
440
|
await putWorker(api, workerName, scriptContent, scriptMetadata);
|
|
@@ -438,10 +459,9 @@ export const Worker = Resource(
|
|
|
438
459
|
? eventSource.settings
|
|
439
460
|
: undefined,
|
|
440
461
|
});
|
|
441
|
-
} else {
|
|
442
|
-
throw new Error(`Unsupported event source type: ${eventSource}`);
|
|
443
462
|
}
|
|
444
|
-
|
|
463
|
+
throw new Error(`Unsupported event source type: ${eventSource}`);
|
|
464
|
+
}) ?? [],
|
|
445
465
|
);
|
|
446
466
|
|
|
447
467
|
// TODO: it is less than ideal that this can fail, resulting in state problem
|
|
@@ -452,7 +472,7 @@ export const Worker = Resource(
|
|
|
452
472
|
this,
|
|
453
473
|
api,
|
|
454
474
|
workerName,
|
|
455
|
-
props.url ?? false
|
|
475
|
+
props.url ?? false,
|
|
456
476
|
);
|
|
457
477
|
|
|
458
478
|
// Get current timestamp
|
|
@@ -462,7 +482,7 @@ export const Worker = Resource(
|
|
|
462
482
|
if (props.crons) {
|
|
463
483
|
const res = await api.put(
|
|
464
484
|
`/accounts/${api.accountId}/workers/scripts/${workerName}/schedules`,
|
|
465
|
-
props.crons.map((cron) => ({ cron }))
|
|
485
|
+
props.crons.map((cron) => ({ cron })),
|
|
466
486
|
);
|
|
467
487
|
|
|
468
488
|
if (!res.ok) {
|
|
@@ -470,7 +490,7 @@ export const Worker = Resource(
|
|
|
470
490
|
res,
|
|
471
491
|
"updating cron triggers",
|
|
472
492
|
"worker",
|
|
473
|
-
workerName
|
|
493
|
+
workerName,
|
|
474
494
|
);
|
|
475
495
|
}
|
|
476
496
|
}
|
|
@@ -500,20 +520,20 @@ export const Worker = Resource(
|
|
|
500
520
|
// phantom property
|
|
501
521
|
Env: undefined!,
|
|
502
522
|
});
|
|
503
|
-
}
|
|
523
|
+
},
|
|
504
524
|
);
|
|
505
525
|
|
|
506
526
|
async function deleteWorker<B extends Bindings>(
|
|
507
527
|
ctx: Context<Worker<B>>,
|
|
508
528
|
api: CloudflareApi,
|
|
509
|
-
workerName: string
|
|
529
|
+
workerName: string,
|
|
510
530
|
) {
|
|
511
531
|
// Delete any queue consumers attached to this worker first
|
|
512
532
|
await deleteQueueConsumers(ctx, api, workerName);
|
|
513
533
|
|
|
514
534
|
// Delete worker
|
|
515
535
|
const deleteResponse = await api.delete(
|
|
516
|
-
`/accounts/${api.accountId}/workers/scripts/${workerName}
|
|
536
|
+
`/accounts/${api.accountId}/workers/scripts/${workerName}`,
|
|
517
537
|
);
|
|
518
538
|
|
|
519
539
|
// Check for success (2xx status code)
|
|
@@ -523,7 +543,7 @@ async function deleteWorker<B extends Bindings>(
|
|
|
523
543
|
.catch(() => ({ errors: [{ message: deleteResponse.statusText }] }));
|
|
524
544
|
console.error(
|
|
525
545
|
"Error deleting worker:",
|
|
526
|
-
errorData.errors?.[0]?.message || deleteResponse.statusText
|
|
546
|
+
errorData.errors?.[0]?.message || deleteResponse.statusText,
|
|
527
547
|
);
|
|
528
548
|
}
|
|
529
549
|
|
|
@@ -535,7 +555,7 @@ async function deleteWorker<B extends Bindings>(
|
|
|
535
555
|
JSON.stringify({ enabled: false }),
|
|
536
556
|
{
|
|
537
557
|
headers: { "Content-Type": "application/json" },
|
|
538
|
-
}
|
|
558
|
+
},
|
|
539
559
|
);
|
|
540
560
|
} catch (error) {
|
|
541
561
|
console.warn("Failed to disable worker URL during deletion:", error);
|
|
@@ -550,7 +570,7 @@ async function putWorker(
|
|
|
550
570
|
api: CloudflareApi,
|
|
551
571
|
workerName: string,
|
|
552
572
|
scriptContent: string,
|
|
553
|
-
scriptMetadata: WorkerMetadata
|
|
573
|
+
scriptMetadata: WorkerMetadata,
|
|
554
574
|
) {
|
|
555
575
|
return withExponentialBackoff(
|
|
556
576
|
async () => {
|
|
@@ -568,7 +588,7 @@ async function putWorker(
|
|
|
568
588
|
? "application/javascript+module"
|
|
569
589
|
: "application/javascript",
|
|
570
590
|
}),
|
|
571
|
-
scriptName
|
|
591
|
+
scriptName,
|
|
572
592
|
);
|
|
573
593
|
|
|
574
594
|
// Add metadata as JSON
|
|
@@ -576,7 +596,7 @@ async function putWorker(
|
|
|
576
596
|
"metadata",
|
|
577
597
|
new Blob([JSON.stringify(scriptMetadata)], {
|
|
578
598
|
type: "application/json",
|
|
579
|
-
})
|
|
599
|
+
}),
|
|
580
600
|
);
|
|
581
601
|
|
|
582
602
|
// Upload worker script with bindings
|
|
@@ -587,7 +607,7 @@ async function putWorker(
|
|
|
587
607
|
headers: {
|
|
588
608
|
"Content-Type": "multipart/form-data",
|
|
589
609
|
},
|
|
590
|
-
}
|
|
610
|
+
},
|
|
591
611
|
);
|
|
592
612
|
|
|
593
613
|
// Check if the upload was successful
|
|
@@ -596,7 +616,7 @@ async function putWorker(
|
|
|
596
616
|
uploadResponse,
|
|
597
617
|
"uploading worker script",
|
|
598
618
|
"worker",
|
|
599
|
-
workerName
|
|
619
|
+
workerName,
|
|
600
620
|
);
|
|
601
621
|
}
|
|
602
622
|
|
|
@@ -604,7 +624,7 @@ async function putWorker(
|
|
|
604
624
|
},
|
|
605
625
|
(err) => err.status === 404 || err.status === 500 || err.status === 503,
|
|
606
626
|
10,
|
|
607
|
-
100
|
|
627
|
+
100,
|
|
608
628
|
);
|
|
609
629
|
}
|
|
610
630
|
|
|
@@ -679,7 +699,7 @@ async function prepareWorkerMetadata<B extends Bindings>(
|
|
|
679
699
|
compatibilityDate: string;
|
|
680
700
|
compatibilityFlags: string[];
|
|
681
701
|
},
|
|
682
|
-
assetUploadResult?: AssetUploadResult
|
|
702
|
+
assetUploadResult?: AssetUploadResult,
|
|
683
703
|
): Promise<WorkerMetadata> {
|
|
684
704
|
// Prepare metadata with bindings
|
|
685
705
|
const meta: WorkerMetadata = {
|
|
@@ -838,14 +858,14 @@ async function prepareWorkerMetadata<B extends Bindings>(
|
|
|
838
858
|
function configureClassMigration(
|
|
839
859
|
binding: DurableObjectNamespace | Workflow,
|
|
840
860
|
stableId: string,
|
|
841
|
-
className: string
|
|
861
|
+
className: string,
|
|
842
862
|
) {
|
|
843
863
|
const oldBinding: DurableObjectNamespace | Workflow | undefined =
|
|
844
864
|
Object.values(oldBindings ?? {})
|
|
845
865
|
?.filter(
|
|
846
866
|
(b) =>
|
|
847
867
|
typeof b === "object" &&
|
|
848
|
-
(b.type === "durable_object_namespace" || b.type === "workflow")
|
|
868
|
+
(b.type === "durable_object_namespace" || b.type === "workflow"),
|
|
849
869
|
)
|
|
850
870
|
?.find((b) => b.id === stableId);
|
|
851
871
|
|
|
@@ -895,10 +915,10 @@ async function prepareWorkerMetadata<B extends Bindings>(
|
|
|
895
915
|
async function assertWorkerDoesNotExist<B extends Bindings>(
|
|
896
916
|
ctx: Context<Worker<B>>,
|
|
897
917
|
api: CloudflareApi,
|
|
898
|
-
workerName: string
|
|
918
|
+
workerName: string,
|
|
899
919
|
) {
|
|
900
920
|
const response = await api.get(
|
|
901
|
-
`/accounts/${api.accountId}/workers/scripts/${workerName}
|
|
921
|
+
`/accounts/${api.accountId}/workers/scripts/${workerName}`,
|
|
902
922
|
);
|
|
903
923
|
if (response.status === 404) {
|
|
904
924
|
return true;
|
|
@@ -908,78 +928,32 @@ async function assertWorkerDoesNotExist<B extends Bindings>(
|
|
|
908
928
|
|
|
909
929
|
if (!metadata) {
|
|
910
930
|
throw new Error(
|
|
911
|
-
`Worker exists but failed to fetch metadata: ${response.status} ${response.statusText}
|
|
931
|
+
`Worker exists but failed to fetch metadata: ${response.status} ${response.statusText}`,
|
|
912
932
|
);
|
|
913
933
|
}
|
|
914
934
|
|
|
915
935
|
if (
|
|
916
936
|
metadata.default_environment?.script.tags.includes(
|
|
917
|
-
`alchemy:id:${slugify(ctx.fqn)}
|
|
937
|
+
`alchemy:id:${slugify(ctx.fqn)}`,
|
|
918
938
|
)
|
|
919
939
|
) {
|
|
920
940
|
return true;
|
|
921
941
|
}
|
|
922
942
|
|
|
923
943
|
throw new Error(
|
|
924
|
-
`Worker with name '${workerName}' already exists. Please use a unique name
|
|
944
|
+
`Worker with name '${workerName}' already exists. Please use a unique name.`,
|
|
925
945
|
);
|
|
926
|
-
} else {
|
|
927
|
-
throw new Error(
|
|
928
|
-
`Error checking if worker exists: ${response.status} ${response.statusText} ${await response.text()}`
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
async function bundleWorkerScript<B extends Bindings>(
|
|
934
|
-
compatibilityDate: string,
|
|
935
|
-
props: WorkerProps<B>
|
|
936
|
-
) {
|
|
937
|
-
const bundle = await Bundle("bundle", {
|
|
938
|
-
entryPoint: props.entrypoint!,
|
|
939
|
-
format: props.format === "cjs" ? "cjs" : "esm", // Use the specified format or default to ESM
|
|
940
|
-
target: "esnext",
|
|
941
|
-
platform: "neutral",
|
|
942
|
-
minify: false,
|
|
943
|
-
...(props.bundle || {}),
|
|
944
|
-
options: {
|
|
945
|
-
...(props.bundle?.options || {}),
|
|
946
|
-
keepNames: true, // Important for Durable Object classes
|
|
947
|
-
loader: {
|
|
948
|
-
".sql": "text",
|
|
949
|
-
".json": "json",
|
|
950
|
-
},
|
|
951
|
-
plugins:
|
|
952
|
-
compatibilityDate >= "2024-09-23" &&
|
|
953
|
-
props.compatibilityFlags?.find((flag) => flag === "nodejs_compat")
|
|
954
|
-
? [await nodejsHybridPlugin()]
|
|
955
|
-
: [],
|
|
956
|
-
},
|
|
957
|
-
external: [
|
|
958
|
-
...external,
|
|
959
|
-
...(props.bundle?.external ?? []),
|
|
960
|
-
...(props.bundle?.options?.external ?? []),
|
|
961
|
-
],
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
try {
|
|
965
|
-
if (bundle.content) {
|
|
966
|
-
return bundle.content;
|
|
967
|
-
} else if (bundle.path) {
|
|
968
|
-
return await fs.readFile(bundle.path, "utf-8");
|
|
969
|
-
} else {
|
|
970
|
-
throw new Error("Failed to create bundle");
|
|
971
|
-
}
|
|
972
|
-
} catch (error) {
|
|
973
|
-
console.error("Error reading bundle:", error);
|
|
974
|
-
throw new Error("Error reading bundle");
|
|
975
946
|
}
|
|
947
|
+
throw new Error(
|
|
948
|
+
`Error checking if worker exists: ${response.status} ${response.statusText} ${await response.text()}`,
|
|
949
|
+
);
|
|
976
950
|
}
|
|
977
951
|
|
|
978
952
|
async function configureURL<B extends Bindings>(
|
|
979
953
|
ctx: Context<Worker<B>>,
|
|
980
954
|
api: CloudflareApi,
|
|
981
955
|
workerName: string,
|
|
982
|
-
url: boolean
|
|
956
|
+
url: boolean,
|
|
983
957
|
) {
|
|
984
958
|
let workerUrl;
|
|
985
959
|
if (url) {
|
|
@@ -989,17 +963,17 @@ async function configureURL<B extends Bindings>(
|
|
|
989
963
|
{ enabled: true, previews_enabled: true },
|
|
990
964
|
{
|
|
991
965
|
headers: { "Content-Type": "application/json" },
|
|
992
|
-
}
|
|
966
|
+
},
|
|
993
967
|
);
|
|
994
968
|
|
|
995
969
|
// Get the account's workers.dev subdomain
|
|
996
970
|
const subdomainResponse = await api.get(
|
|
997
|
-
`/accounts/${api.accountId}/workers/subdomain
|
|
971
|
+
`/accounts/${api.accountId}/workers/subdomain`,
|
|
998
972
|
);
|
|
999
973
|
|
|
1000
974
|
if (!subdomainResponse.ok) {
|
|
1001
975
|
throw new Error(
|
|
1002
|
-
`Could not fetch workers.dev subdomain: ${subdomainResponse.status} ${subdomainResponse.statusText}
|
|
976
|
+
`Could not fetch workers.dev subdomain: ${subdomainResponse.status} ${subdomainResponse.statusText}`,
|
|
1003
977
|
);
|
|
1004
978
|
}
|
|
1005
979
|
const subdomainData: {
|
|
@@ -1026,11 +1000,11 @@ async function configureURL<B extends Bindings>(
|
|
|
1026
1000
|
JSON.stringify({ enabled: false }),
|
|
1027
1001
|
{
|
|
1028
1002
|
headers: { "Content-Type": "application/json" },
|
|
1029
|
-
}
|
|
1003
|
+
},
|
|
1030
1004
|
);
|
|
1031
1005
|
if (!response.ok) {
|
|
1032
1006
|
throw new Error(
|
|
1033
|
-
`Failed to disable worker URL: ${response.status} ${response.statusText}
|
|
1007
|
+
`Failed to disable worker URL: ${response.status} ${response.statusText}`,
|
|
1034
1008
|
);
|
|
1035
1009
|
}
|
|
1036
1010
|
}
|
|
@@ -1039,17 +1013,17 @@ async function configureURL<B extends Bindings>(
|
|
|
1039
1013
|
|
|
1040
1014
|
async function getWorkerScriptMetadata(
|
|
1041
1015
|
api: CloudflareApi,
|
|
1042
|
-
workerName: string
|
|
1016
|
+
workerName: string,
|
|
1043
1017
|
): Promise<WorkerScriptMetadata | undefined> {
|
|
1044
1018
|
const response = await api.get(
|
|
1045
|
-
`/accounts/${api.accountId}/workers/services/${workerName}
|
|
1019
|
+
`/accounts/${api.accountId}/workers/services/${workerName}`,
|
|
1046
1020
|
);
|
|
1047
1021
|
if (response.status === 404) {
|
|
1048
1022
|
return undefined;
|
|
1049
1023
|
}
|
|
1050
1024
|
if (!response.ok) {
|
|
1051
1025
|
throw new Error(
|
|
1052
|
-
`Error getting worker script metadata: ${response.status} ${response.statusText}
|
|
1026
|
+
`Error getting worker script metadata: ${response.status} ${response.statusText}`,
|
|
1053
1027
|
);
|
|
1054
1028
|
}
|
|
1055
1029
|
return ((await response.json()) as any).result as WorkerScriptMetadata;
|
|
@@ -1058,7 +1032,7 @@ async function getWorkerScriptMetadata(
|
|
|
1058
1032
|
async function getWorkerBindings(
|
|
1059
1033
|
api: CloudflareApi,
|
|
1060
1034
|
workerName: string,
|
|
1061
|
-
environment = "production"
|
|
1035
|
+
environment = "production",
|
|
1062
1036
|
) {
|
|
1063
1037
|
const response = await api.get(
|
|
1064
1038
|
`/accounts/${api.accountId}/workers/services/${workerName}/environments/${environment}/bindings`,
|
|
@@ -1067,7 +1041,7 @@ async function getWorkerBindings(
|
|
|
1067
1041
|
Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}`,
|
|
1068
1042
|
"Content-Type": "application/json",
|
|
1069
1043
|
},
|
|
1070
|
-
}
|
|
1044
|
+
},
|
|
1071
1045
|
);
|
|
1072
1046
|
|
|
1073
1047
|
if (response.status === 404) {
|
|
@@ -1076,7 +1050,7 @@ async function getWorkerBindings(
|
|
|
1076
1050
|
|
|
1077
1051
|
if (!response.ok) {
|
|
1078
1052
|
throw new Error(
|
|
1079
|
-
`Failed to fetch bindings: ${response.status} ${response.statusText}
|
|
1053
|
+
`Failed to fetch bindings: ${response.status} ${response.statusText}`,
|
|
1080
1054
|
);
|
|
1081
1055
|
}
|
|
1082
1056
|
|
|
@@ -1132,7 +1106,7 @@ async function uploadAssets(
|
|
|
1132
1106
|
api: CloudflareApi,
|
|
1133
1107
|
workerName: string,
|
|
1134
1108
|
assets: Assets,
|
|
1135
|
-
assetConfig?: WorkerProps["assets"]
|
|
1109
|
+
assetConfig?: WorkerProps["assets"],
|
|
1136
1110
|
): Promise<AssetUploadResult> {
|
|
1137
1111
|
// Process the assets configuration once at the beginning
|
|
1138
1112
|
const processedConfig = createAssetConfig(assetConfig);
|
|
@@ -1155,12 +1129,12 @@ async function uploadAssets(
|
|
|
1155
1129
|
JSON.stringify({ manifest: fileMetadata }),
|
|
1156
1130
|
{
|
|
1157
1131
|
headers: { "Content-Type": "application/json" },
|
|
1158
|
-
}
|
|
1132
|
+
},
|
|
1159
1133
|
);
|
|
1160
1134
|
|
|
1161
1135
|
if (!uploadSessionResponse.ok) {
|
|
1162
1136
|
throw new Error(
|
|
1163
|
-
`Failed to start assets upload session: ${uploadSessionResponse.status} ${uploadSessionResponse.statusText}
|
|
1137
|
+
`Failed to start assets upload session: ${uploadSessionResponse.status} ${uploadSessionResponse.statusText}`,
|
|
1164
1138
|
);
|
|
1165
1139
|
}
|
|
1166
1140
|
|
|
@@ -1220,12 +1194,12 @@ async function uploadAssets(
|
|
|
1220
1194
|
Authorization: `Bearer ${completionToken}`,
|
|
1221
1195
|
"Content-Type": "multipart/form-data",
|
|
1222
1196
|
},
|
|
1223
|
-
}
|
|
1197
|
+
},
|
|
1224
1198
|
);
|
|
1225
1199
|
|
|
1226
1200
|
if (!uploadResponse.ok) {
|
|
1227
1201
|
throw new Error(
|
|
1228
|
-
`Failed to upload asset files: ${uploadResponse.status} ${uploadResponse.statusText}
|
|
1202
|
+
`Failed to upload asset files: ${uploadResponse.status} ${uploadResponse.statusText}`,
|
|
1229
1203
|
);
|
|
1230
1204
|
}
|
|
1231
1205
|
|
|
@@ -1250,7 +1224,7 @@ async function uploadAssets(
|
|
|
1250
1224
|
* @returns Hash (first 32 chars of SHA-256) and size of the file
|
|
1251
1225
|
*/
|
|
1252
1226
|
async function calculateFileMetadata(
|
|
1253
|
-
filePath: string
|
|
1227
|
+
filePath: string,
|
|
1254
1228
|
): Promise<{ hash: string; size: number }> {
|
|
1255
1229
|
const hash = crypto.createHash("sha256");
|
|
1256
1230
|
const fileContent = await fs.readFile(filePath);
|
|
@@ -1273,7 +1247,7 @@ async function calculateFileMetadata(
|
|
|
1273
1247
|
async function deleteQueueConsumers<B extends Bindings>(
|
|
1274
1248
|
ctx: Context<Worker<B>>,
|
|
1275
1249
|
api: CloudflareApi,
|
|
1276
|
-
workerName: string
|
|
1250
|
+
workerName: string,
|
|
1277
1251
|
): Promise<void> {
|
|
1278
1252
|
const eventSources = ctx.output?.eventSources || [];
|
|
1279
1253
|
|
|
@@ -1281,7 +1255,8 @@ async function deleteQueueConsumers<B extends Bindings>(
|
|
|
1281
1255
|
const queueIds = eventSources.flatMap((eventSource) => {
|
|
1282
1256
|
if (isQueue(eventSource)) {
|
|
1283
1257
|
return [eventSource.id];
|
|
1284
|
-
}
|
|
1258
|
+
}
|
|
1259
|
+
if (isQueueEventSource(eventSource)) {
|
|
1285
1260
|
return [eventSource.queue.id];
|
|
1286
1261
|
}
|
|
1287
1262
|
return [];
|
|
@@ -1296,18 +1271,18 @@ async function deleteQueueConsumers<B extends Bindings>(
|
|
|
1296
1271
|
|
|
1297
1272
|
// Filter consumers by worker name
|
|
1298
1273
|
const workerConsumers = consumers.filter(
|
|
1299
|
-
(consumer) => consumer.scriptName === workerName
|
|
1274
|
+
(consumer) => consumer.scriptName === workerName,
|
|
1300
1275
|
);
|
|
1301
1276
|
|
|
1302
1277
|
// Delete all consumers for this worker in parallel
|
|
1303
1278
|
await Promise.all(
|
|
1304
1279
|
workerConsumers.map(async (consumer) => {
|
|
1305
1280
|
console.log(
|
|
1306
|
-
`Deleting queue consumer ${consumer.id} for worker ${workerName}
|
|
1281
|
+
`Deleting queue consumer ${consumer.id} for worker ${workerName}`,
|
|
1307
1282
|
);
|
|
1308
1283
|
// Use the deleteQueueConsumer function from queue-consumer.ts
|
|
1309
1284
|
await deleteQueueConsumer(api, consumer.queueId, consumer.id);
|
|
1310
|
-
})
|
|
1285
|
+
}),
|
|
1311
1286
|
);
|
|
1312
1287
|
} catch (err) {
|
|
1313
1288
|
if (err instanceof CloudflareApiError && err.status === 404) {
|
|
@@ -1316,6 +1291,6 @@ async function deleteQueueConsumers<B extends Bindings>(
|
|
|
1316
1291
|
throw err;
|
|
1317
1292
|
}
|
|
1318
1293
|
}
|
|
1319
|
-
})
|
|
1294
|
+
}),
|
|
1320
1295
|
);
|
|
1321
1296
|
}
|
|
@@ -21,7 +21,7 @@ export interface WorkflowProps {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class Workflow<PARAMS = unknown> {
|
|
24
|
-
public readonly type
|
|
24
|
+
public readonly type = "workflow";
|
|
25
25
|
/**
|
|
26
26
|
* Phantom property to preserve workflow params at the type level.
|
|
27
27
|
*
|
|
@@ -34,7 +34,7 @@ export class Workflow<PARAMS = unknown> {
|
|
|
34
34
|
|
|
35
35
|
constructor(
|
|
36
36
|
public readonly id: string,
|
|
37
|
-
props: WorkflowProps = {}
|
|
37
|
+
props: WorkflowProps = {},
|
|
38
38
|
) {
|
|
39
39
|
this.workflowName = props.workflowName ?? props.className ?? id;
|
|
40
40
|
this.className = props.className ?? this.workflowName;
|
|
@@ -57,14 +57,14 @@ export async function upsertWorkflow(
|
|
|
57
57
|
props: WorkflowProps & {
|
|
58
58
|
workflowName: string;
|
|
59
59
|
scriptName: string;
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
61
|
) {
|
|
62
62
|
const response = await api.put(
|
|
63
63
|
`/accounts/${api.accountId}/workflows/${props.workflowName}`,
|
|
64
64
|
{
|
|
65
65
|
class_name: props.className,
|
|
66
66
|
script_name: props.scriptName,
|
|
67
|
-
}
|
|
67
|
+
},
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
if (!response.ok) {
|
|
@@ -67,7 +67,7 @@ export const WranglerJson = Resource(
|
|
|
67
67
|
async function (
|
|
68
68
|
this: Context<WranglerJson>,
|
|
69
69
|
id: string,
|
|
70
|
-
props: WranglerJsonProps
|
|
70
|
+
props: WranglerJsonProps,
|
|
71
71
|
): Promise<WranglerJson> {
|
|
72
72
|
// Default path is wrangler.json in current directory
|
|
73
73
|
const filePath = props.path || "wrangler.jsonc";
|
|
@@ -78,7 +78,7 @@ export const WranglerJson = Resource(
|
|
|
78
78
|
|
|
79
79
|
if (props.worker.entrypoint === undefined) {
|
|
80
80
|
throw new Error(
|
|
81
|
-
"Worker must have an entrypoint to generate a wrangler.json"
|
|
81
|
+
"Worker must have an entrypoint to generate a wrangler.json",
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -113,7 +113,7 @@ export const WranglerJson = Resource(
|
|
|
113
113
|
createdAt: Date.now(),
|
|
114
114
|
updatedAt: Date.now(),
|
|
115
115
|
});
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
/**
|
|
@@ -278,7 +278,7 @@ export interface WranglerJsonSpec {
|
|
|
278
278
|
function processBindings(
|
|
279
279
|
spec: WranglerJsonSpec,
|
|
280
280
|
bindings: Bindings,
|
|
281
|
-
eventSources: EventSource[] | undefined
|
|
281
|
+
eventSources: EventSource[] | undefined,
|
|
282
282
|
): void {
|
|
283
283
|
// Arrays to collect different binding types
|
|
284
284
|
const kvNamespaces: { binding: string; id: string }[] = [];
|