alchemy 0.12.21 → 0.13.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.
Files changed (269) hide show
  1. package/lib/ai/client.d.ts.map +1 -1
  2. package/lib/ai/client.js +3 -5
  3. package/lib/ai/client.js.map +1 -1
  4. package/lib/alchemy.d.ts +2 -1
  5. package/lib/alchemy.d.ts.map +1 -1
  6. package/lib/alchemy.js +87 -92
  7. package/lib/alchemy.js.map +1 -1
  8. package/lib/apply.d.ts.map +1 -1
  9. package/lib/apply.js +6 -0
  10. package/lib/apply.js.map +1 -1
  11. package/lib/aws/bucket.d.ts.map +1 -1
  12. package/lib/aws/bucket.js +55 -57
  13. package/lib/aws/bucket.js.map +1 -1
  14. package/lib/aws/function.d.ts.map +1 -1
  15. package/lib/aws/function.js +250 -252
  16. package/lib/aws/function.js.map +1 -1
  17. package/lib/aws/policy-attachment.d.ts.map +1 -1
  18. package/lib/aws/policy-attachment.js +4 -6
  19. package/lib/aws/policy-attachment.js.map +1 -1
  20. package/lib/aws/policy.d.ts.map +1 -1
  21. package/lib/aws/policy.js +63 -65
  22. package/lib/aws/policy.js.map +1 -1
  23. package/lib/aws/queue.js +88 -90
  24. package/lib/aws/queue.js.map +1 -1
  25. package/lib/aws/table.d.ts.map +1 -1
  26. package/lib/aws/table.js +95 -99
  27. package/lib/aws/table.js.map +1 -1
  28. package/lib/cloudflare/account-api-token.d.ts +1 -1
  29. package/lib/cloudflare/account-api-token.d.ts.map +1 -1
  30. package/lib/cloudflare/account-api-token.js +0 -1
  31. package/lib/cloudflare/account-api-token.js.map +1 -1
  32. package/lib/cloudflare/ai-gateway.js.map +1 -1
  33. package/lib/cloudflare/ai.d.ts +1 -1
  34. package/lib/cloudflare/ai.d.ts.map +1 -1
  35. package/lib/cloudflare/ai.js.map +1 -1
  36. package/lib/cloudflare/api.js +1 -5
  37. package/lib/cloudflare/api.js.map +1 -1
  38. package/lib/cloudflare/bucket.d.ts +2 -2
  39. package/lib/cloudflare/bucket.d.ts.map +1 -1
  40. package/lib/cloudflare/bucket.js +22 -24
  41. package/lib/cloudflare/bucket.js.map +1 -1
  42. package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts +0 -3
  43. package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts.map +1 -1
  44. package/lib/cloudflare/bundle/hybrid-nodejs-compat.js +3 -4
  45. package/lib/cloudflare/bundle/hybrid-nodejs-compat.js.map +1 -1
  46. package/lib/cloudflare/custom-domain.d.ts.map +1 -1
  47. package/lib/cloudflare/custom-domain.js +3 -5
  48. package/lib/cloudflare/custom-domain.js.map +1 -1
  49. package/lib/cloudflare/d1-database.d.ts +1 -1
  50. package/lib/cloudflare/d1-database.d.ts.map +1 -1
  51. package/lib/cloudflare/d1-database.js +70 -72
  52. package/lib/cloudflare/d1-database.js.map +1 -1
  53. package/lib/cloudflare/d1-migrations.d.ts +1 -1
  54. package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
  55. package/lib/cloudflare/d1-migrations.js +2 -3
  56. package/lib/cloudflare/d1-migrations.js.map +1 -1
  57. package/lib/cloudflare/dns-records.d.ts.map +1 -1
  58. package/lib/cloudflare/dns-records.js +2 -4
  59. package/lib/cloudflare/dns-records.js.map +1 -1
  60. package/lib/cloudflare/kv-namespace.d.ts +1 -1
  61. package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
  62. package/lib/cloudflare/kv-namespace.js +24 -27
  63. package/lib/cloudflare/kv-namespace.js.map +1 -1
  64. package/lib/cloudflare/pipeline.d.ts +1 -1
  65. package/lib/cloudflare/pipeline.d.ts.map +1 -1
  66. package/lib/cloudflare/pipeline.js +32 -34
  67. package/lib/cloudflare/pipeline.js.map +1 -1
  68. package/lib/cloudflare/queue-consumer.d.ts +1 -1
  69. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  70. package/lib/cloudflare/queue-consumer.js +31 -33
  71. package/lib/cloudflare/queue-consumer.js.map +1 -1
  72. package/lib/cloudflare/queue.d.ts +1 -1
  73. package/lib/cloudflare/queue.d.ts.map +1 -1
  74. package/lib/cloudflare/queue.js +36 -38
  75. package/lib/cloudflare/queue.js.map +1 -1
  76. package/lib/cloudflare/r2-rest-state-store.js +4 -8
  77. package/lib/cloudflare/r2-rest-state-store.js.map +1 -1
  78. package/lib/cloudflare/types.d.ts.map +1 -1
  79. package/lib/cloudflare/types.js +1 -3
  80. package/lib/cloudflare/types.js.map +1 -1
  81. package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
  82. package/lib/cloudflare/vectorize-index.js +37 -39
  83. package/lib/cloudflare/vectorize-index.js.map +1 -1
  84. package/lib/cloudflare/vectorize-metadata-index.d.ts +1 -1
  85. package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
  86. package/lib/cloudflare/vectorize-metadata-index.js +10 -13
  87. package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
  88. package/lib/cloudflare/worker.js +6 -12
  89. package/lib/cloudflare/worker.js.map +1 -1
  90. package/lib/cloudflare/workflow.d.ts +1 -1
  91. package/lib/cloudflare/workflow.d.ts.map +1 -1
  92. package/lib/cloudflare/workflow.js.map +1 -1
  93. package/lib/cloudflare/zone.d.ts.map +1 -1
  94. package/lib/cloudflare/zone.js +48 -50
  95. package/lib/cloudflare/zone.js.map +1 -1
  96. package/lib/dns/godaddy.js +1 -1
  97. package/lib/dns/import-dns.js +1 -1
  98. package/lib/dns/import-dns.js.map +1 -1
  99. package/lib/env.js +7 -9
  100. package/lib/env.js.map +1 -1
  101. package/lib/esbuild/bundle.js +8 -10
  102. package/lib/esbuild/bundle.js.map +1 -1
  103. package/lib/fs/copy-file.d.ts.map +1 -1
  104. package/lib/fs/copy-file.js +27 -29
  105. package/lib/fs/copy-file.js.map +1 -1
  106. package/lib/fs/file.d.ts +1 -1
  107. package/lib/fs/file.d.ts.map +1 -1
  108. package/lib/fs/file.js +1 -1
  109. package/lib/fs/file.js.map +1 -1
  110. package/lib/fs/folder.d.ts.map +1 -1
  111. package/lib/fs/folder.js +1 -3
  112. package/lib/fs/folder.js.map +1 -1
  113. package/lib/github/client.d.ts.map +1 -1
  114. package/lib/github/client.js +3 -5
  115. package/lib/github/client.js.map +1 -1
  116. package/lib/github/repository-environment.d.ts.map +1 -1
  117. package/lib/github/repository-environment.js +173 -176
  118. package/lib/github/repository-environment.js.map +1 -1
  119. package/lib/github/secret.d.ts.map +1 -1
  120. package/lib/github/secret.js +97 -99
  121. package/lib/github/secret.js.map +1 -1
  122. package/lib/internal/docs/providers.d.ts.map +1 -1
  123. package/lib/internal/docs/providers.js +5 -7
  124. package/lib/internal/docs/providers.js.map +1 -1
  125. package/lib/neon/api.js +1 -2
  126. package/lib/neon/api.js.map +1 -1
  127. package/lib/neon/project.js +2 -2
  128. package/lib/neon/project.js.map +1 -1
  129. package/lib/os/exec.d.ts +5 -0
  130. package/lib/os/exec.d.ts.map +1 -1
  131. package/lib/os/exec.js +88 -56
  132. package/lib/os/exec.js.map +1 -1
  133. package/lib/scope.d.ts +3 -0
  134. package/lib/scope.d.ts.map +1 -1
  135. package/lib/scope.js +10 -3
  136. package/lib/scope.js.map +1 -1
  137. package/lib/secret.d.ts.map +1 -1
  138. package/lib/secret.js +1 -3
  139. package/lib/secret.js.map +1 -1
  140. package/lib/serde.d.ts.map +1 -1
  141. package/lib/serde.js +13 -15
  142. package/lib/serde.js.map +1 -1
  143. package/lib/stripe/price.d.ts.map +1 -1
  144. package/lib/stripe/price.js +69 -73
  145. package/lib/stripe/price.js.map +1 -1
  146. package/lib/stripe/product.d.ts.map +1 -1
  147. package/lib/stripe/product.js +50 -52
  148. package/lib/stripe/product.js.map +1 -1
  149. package/lib/stripe/webhook.d.ts.map +1 -1
  150. package/lib/stripe/webhook.js +51 -53
  151. package/lib/stripe/webhook.js.map +1 -1
  152. package/lib/test/bun.d.ts +1 -1
  153. package/lib/test/bun.d.ts.map +1 -1
  154. package/lib/test/bun.js +1 -0
  155. package/lib/test/bun.js.map +1 -1
  156. package/lib/test/prune.d.ts.map +1 -1
  157. package/lib/test/prune.js.map +1 -1
  158. package/lib/util/dedent.js +4 -4
  159. package/lib/util/dedent.js.map +1 -1
  160. package/lib/web/astro.js +1 -1
  161. package/lib/web/shadcn.js +4 -4
  162. package/lib/web/shadcn.js.map +1 -1
  163. package/lib/web/tailwind.d.ts.map +1 -1
  164. package/lib/web/tailwind.js +0 -1
  165. package/lib/web/tailwind.js.map +1 -1
  166. package/lib/web/vite.js +3 -3
  167. package/lib/web/vitepress/home-page.d.ts.map +1 -1
  168. package/lib/web/vitepress/home-page.js +6 -8
  169. package/lib/web/vitepress/home-page.js.map +1 -1
  170. package/lib/web/vitepress/process-front-matter-files.js +1 -1
  171. package/lib/web/vitepress/process-front-matter-files.js.map +1 -1
  172. package/lib/web/vitepress/vitepress.js +2 -2
  173. package/lib/web/vitepress/vitepress.js.map +1 -1
  174. package/package.json +1 -1
  175. package/src/ai/astro-file.ts +4 -4
  176. package/src/ai/client.ts +4 -5
  177. package/src/ai/css-file.ts +4 -4
  178. package/src/ai/document.ts +3 -3
  179. package/src/ai/html-file.ts +4 -4
  180. package/src/ai/json-file.ts +1 -1
  181. package/src/ai/typescript-file.ts +4 -4
  182. package/src/ai/vue-file.ts +4 -4
  183. package/src/ai/yaml-file.ts +1 -1
  184. package/src/alchemy.ts +111 -104
  185. package/src/apply.ts +13 -5
  186. package/src/aws/bucket.ts +72 -75
  187. package/src/aws/function.ts +296 -297
  188. package/src/aws/oidc/github-oidc-provider.ts +1 -1
  189. package/src/aws/oidc/oidc-provider.ts +15 -15
  190. package/src/aws/policy-attachment.ts +10 -11
  191. package/src/aws/policy.ts +91 -94
  192. package/src/aws/queue.ts +111 -111
  193. package/src/aws/role.ts +24 -24
  194. package/src/aws/ses.ts +17 -17
  195. package/src/aws/table.ts +114 -115
  196. package/src/cloudflare/account-api-token.ts +11 -11
  197. package/src/cloudflare/account-id.ts +1 -1
  198. package/src/cloudflare/ai-gateway.ts +4 -4
  199. package/src/cloudflare/ai.ts +1 -1
  200. package/src/cloudflare/api-error.ts +1 -1
  201. package/src/cloudflare/api.ts +7 -11
  202. package/src/cloudflare/assets.ts +4 -4
  203. package/src/cloudflare/auth.ts +13 -13
  204. package/src/cloudflare/bucket.ts +62 -63
  205. package/src/cloudflare/bundle/hybrid-nodejs-compat.ts +13 -14
  206. package/src/cloudflare/custom-domain.ts +27 -28
  207. package/src/cloudflare/d1-database.ts +101 -102
  208. package/src/cloudflare/d1-migrations.ts +10 -10
  209. package/src/cloudflare/dns-records.ts +23 -24
  210. package/src/cloudflare/durable-object-namespace.ts +1 -1
  211. package/src/cloudflare/event-source.ts +1 -1
  212. package/src/cloudflare/hyperdrive.ts +3 -3
  213. package/src/cloudflare/kv-namespace.ts +36 -37
  214. package/src/cloudflare/nuxt.ts +1 -1
  215. package/src/cloudflare/permission-groups.ts +7 -7
  216. package/src/cloudflare/pipeline.ts +55 -56
  217. package/src/cloudflare/queue-consumer.ts +53 -54
  218. package/src/cloudflare/queue.ts +56 -57
  219. package/src/cloudflare/r2-rest-state-store.ts +11 -11
  220. package/src/cloudflare/redwood.ts +1 -1
  221. package/src/cloudflare/tanstack-start.ts +1 -1
  222. package/src/cloudflare/types.ts +1 -2
  223. package/src/cloudflare/vectorize-index.ts +60 -61
  224. package/src/cloudflare/vectorize-metadata-index.ts +25 -25
  225. package/src/cloudflare/vite.ts +1 -1
  226. package/src/cloudflare/website.ts +3 -3
  227. package/src/cloudflare/worker.ts +61 -61
  228. package/src/cloudflare/workflow.ts +4 -4
  229. package/src/cloudflare/wrangler.json.ts +4 -4
  230. package/src/cloudflare/zone.ts +69 -70
  231. package/src/destroy.ts +4 -4
  232. package/src/dns/godaddy.ts +1 -1
  233. package/src/dns/import-dns.ts +5 -5
  234. package/src/encrypt.ts +6 -6
  235. package/src/env.ts +10 -10
  236. package/src/esbuild/bundle.ts +14 -14
  237. package/src/fs/copy-file.ts +35 -36
  238. package/src/fs/file-system-state-store.ts +4 -4
  239. package/src/fs/file.ts +9 -8
  240. package/src/fs/folder.ts +6 -7
  241. package/src/github/client.ts +15 -14
  242. package/src/github/repository-environment.ts +206 -210
  243. package/src/github/secret.ts +111 -116
  244. package/src/internal/docs/providers.ts +16 -17
  245. package/src/neon/api-error.ts +1 -1
  246. package/src/neon/api.ts +6 -6
  247. package/src/neon/project.ts +18 -17
  248. package/src/os/exec.ts +107 -66
  249. package/src/resource.ts +3 -3
  250. package/src/scope.ts +14 -4
  251. package/src/secret.ts +2 -3
  252. package/src/serde.ts +30 -22
  253. package/src/stripe/price.ts +74 -77
  254. package/src/stripe/product.ts +55 -56
  255. package/src/stripe/webhook.ts +56 -57
  256. package/src/test/bun.ts +7 -6
  257. package/src/test/prune.ts +4 -4
  258. package/src/util/dedent.ts +4 -4
  259. package/src/web/astro.ts +10 -10
  260. package/src/web/shadcn-component.ts +4 -4
  261. package/src/web/shadcn.ts +10 -10
  262. package/src/web/tailwind.ts +2 -3
  263. package/src/web/vite.ts +11 -11
  264. package/src/web/vitepress/config.ts +2 -2
  265. package/src/web/vitepress/custom-theme.ts +7 -7
  266. package/src/web/vitepress/dependencies.ts +4 -4
  267. package/src/web/vitepress/home-page.ts +8 -9
  268. package/src/web/vitepress/process-front-matter-files.ts +5 -5
  269. package/src/web/vitepress/vitepress.ts +7 -7
@@ -341,7 +341,7 @@ export const Worker = Resource(
341
341
  async function <const B extends Bindings>(
342
342
  this: Context<Worker<NoInfer<B>>>,
343
343
  id: string,
344
- props: WorkerProps<B>
344
+ props: WorkerProps<B>,
345
345
  ): Promise<Worker<B>> {
346
346
  // Create Cloudflare API client with automatic account discovery
347
347
  const api = await createCloudflareApi(props);
@@ -357,7 +357,8 @@ export const Worker = Resource(
357
357
  if (this.phase === "delete") {
358
358
  await deleteWorker(this, api, workerName);
359
359
  return this.destroy();
360
- } else if (this.phase === "create") {
360
+ }
361
+ if (this.phase === "create") {
361
362
  if (!props.adopt) {
362
363
  await assertWorkerDoesNotExist(this, api, workerName);
363
364
  }
@@ -400,7 +401,7 @@ export const Worker = Resource(
400
401
  api,
401
402
  workerName,
402
403
  assetBinding.assets,
403
- props.assets
404
+ props.assets,
404
405
  );
405
406
  }
406
407
 
@@ -413,7 +414,7 @@ export const Worker = Resource(
413
414
  compatibilityDate,
414
415
  compatibilityFlags,
415
416
  },
416
- assetUploadResult
417
+ assetUploadResult,
417
418
  );
418
419
 
419
420
  await putWorker(api, workerName, scriptContent, scriptMetadata);
@@ -438,10 +439,9 @@ export const Worker = Resource(
438
439
  ? eventSource.settings
439
440
  : undefined,
440
441
  });
441
- } else {
442
- throw new Error(`Unsupported event source type: ${eventSource}`);
443
442
  }
444
- }) ?? []
443
+ throw new Error(`Unsupported event source type: ${eventSource}`);
444
+ }) ?? [],
445
445
  );
446
446
 
447
447
  // TODO: it is less than ideal that this can fail, resulting in state problem
@@ -452,7 +452,7 @@ export const Worker = Resource(
452
452
  this,
453
453
  api,
454
454
  workerName,
455
- props.url ?? false
455
+ props.url ?? false,
456
456
  );
457
457
 
458
458
  // Get current timestamp
@@ -462,7 +462,7 @@ export const Worker = Resource(
462
462
  if (props.crons) {
463
463
  const res = await api.put(
464
464
  `/accounts/${api.accountId}/workers/scripts/${workerName}/schedules`,
465
- props.crons.map((cron) => ({ cron }))
465
+ props.crons.map((cron) => ({ cron })),
466
466
  );
467
467
 
468
468
  if (!res.ok) {
@@ -470,7 +470,7 @@ export const Worker = Resource(
470
470
  res,
471
471
  "updating cron triggers",
472
472
  "worker",
473
- workerName
473
+ workerName,
474
474
  );
475
475
  }
476
476
  }
@@ -500,20 +500,20 @@ export const Worker = Resource(
500
500
  // phantom property
501
501
  Env: undefined!,
502
502
  });
503
- }
503
+ },
504
504
  );
505
505
 
506
506
  async function deleteWorker<B extends Bindings>(
507
507
  ctx: Context<Worker<B>>,
508
508
  api: CloudflareApi,
509
- workerName: string
509
+ workerName: string,
510
510
  ) {
511
511
  // Delete any queue consumers attached to this worker first
512
512
  await deleteQueueConsumers(ctx, api, workerName);
513
513
 
514
514
  // Delete worker
515
515
  const deleteResponse = await api.delete(
516
- `/accounts/${api.accountId}/workers/scripts/${workerName}`
516
+ `/accounts/${api.accountId}/workers/scripts/${workerName}`,
517
517
  );
518
518
 
519
519
  // Check for success (2xx status code)
@@ -523,7 +523,7 @@ async function deleteWorker<B extends Bindings>(
523
523
  .catch(() => ({ errors: [{ message: deleteResponse.statusText }] }));
524
524
  console.error(
525
525
  "Error deleting worker:",
526
- errorData.errors?.[0]?.message || deleteResponse.statusText
526
+ errorData.errors?.[0]?.message || deleteResponse.statusText,
527
527
  );
528
528
  }
529
529
 
@@ -535,7 +535,7 @@ async function deleteWorker<B extends Bindings>(
535
535
  JSON.stringify({ enabled: false }),
536
536
  {
537
537
  headers: { "Content-Type": "application/json" },
538
- }
538
+ },
539
539
  );
540
540
  } catch (error) {
541
541
  console.warn("Failed to disable worker URL during deletion:", error);
@@ -550,7 +550,7 @@ async function putWorker(
550
550
  api: CloudflareApi,
551
551
  workerName: string,
552
552
  scriptContent: string,
553
- scriptMetadata: WorkerMetadata
553
+ scriptMetadata: WorkerMetadata,
554
554
  ) {
555
555
  return withExponentialBackoff(
556
556
  async () => {
@@ -568,7 +568,7 @@ async function putWorker(
568
568
  ? "application/javascript+module"
569
569
  : "application/javascript",
570
570
  }),
571
- scriptName
571
+ scriptName,
572
572
  );
573
573
 
574
574
  // Add metadata as JSON
@@ -576,7 +576,7 @@ async function putWorker(
576
576
  "metadata",
577
577
  new Blob([JSON.stringify(scriptMetadata)], {
578
578
  type: "application/json",
579
- })
579
+ }),
580
580
  );
581
581
 
582
582
  // Upload worker script with bindings
@@ -587,7 +587,7 @@ async function putWorker(
587
587
  headers: {
588
588
  "Content-Type": "multipart/form-data",
589
589
  },
590
- }
590
+ },
591
591
  );
592
592
 
593
593
  // Check if the upload was successful
@@ -596,7 +596,7 @@ async function putWorker(
596
596
  uploadResponse,
597
597
  "uploading worker script",
598
598
  "worker",
599
- workerName
599
+ workerName,
600
600
  );
601
601
  }
602
602
 
@@ -604,7 +604,7 @@ async function putWorker(
604
604
  },
605
605
  (err) => err.status === 404 || err.status === 500 || err.status === 503,
606
606
  10,
607
- 100
607
+ 100,
608
608
  );
609
609
  }
610
610
 
@@ -679,7 +679,7 @@ async function prepareWorkerMetadata<B extends Bindings>(
679
679
  compatibilityDate: string;
680
680
  compatibilityFlags: string[];
681
681
  },
682
- assetUploadResult?: AssetUploadResult
682
+ assetUploadResult?: AssetUploadResult,
683
683
  ): Promise<WorkerMetadata> {
684
684
  // Prepare metadata with bindings
685
685
  const meta: WorkerMetadata = {
@@ -838,14 +838,14 @@ async function prepareWorkerMetadata<B extends Bindings>(
838
838
  function configureClassMigration(
839
839
  binding: DurableObjectNamespace | Workflow,
840
840
  stableId: string,
841
- className: string
841
+ className: string,
842
842
  ) {
843
843
  const oldBinding: DurableObjectNamespace | Workflow | undefined =
844
844
  Object.values(oldBindings ?? {})
845
845
  ?.filter(
846
846
  (b) =>
847
847
  typeof b === "object" &&
848
- (b.type === "durable_object_namespace" || b.type === "workflow")
848
+ (b.type === "durable_object_namespace" || b.type === "workflow"),
849
849
  )
850
850
  ?.find((b) => b.id === stableId);
851
851
 
@@ -895,10 +895,10 @@ async function prepareWorkerMetadata<B extends Bindings>(
895
895
  async function assertWorkerDoesNotExist<B extends Bindings>(
896
896
  ctx: Context<Worker<B>>,
897
897
  api: CloudflareApi,
898
- workerName: string
898
+ workerName: string,
899
899
  ) {
900
900
  const response = await api.get(
901
- `/accounts/${api.accountId}/workers/scripts/${workerName}`
901
+ `/accounts/${api.accountId}/workers/scripts/${workerName}`,
902
902
  );
903
903
  if (response.status === 404) {
904
904
  return true;
@@ -908,31 +908,30 @@ async function assertWorkerDoesNotExist<B extends Bindings>(
908
908
 
909
909
  if (!metadata) {
910
910
  throw new Error(
911
- `Worker exists but failed to fetch metadata: ${response.status} ${response.statusText}`
911
+ `Worker exists but failed to fetch metadata: ${response.status} ${response.statusText}`,
912
912
  );
913
913
  }
914
914
 
915
915
  if (
916
916
  metadata.default_environment?.script.tags.includes(
917
- `alchemy:id:${slugify(ctx.fqn)}`
917
+ `alchemy:id:${slugify(ctx.fqn)}`,
918
918
  )
919
919
  ) {
920
920
  return true;
921
921
  }
922
922
 
923
923
  throw new Error(
924
- `Worker with name '${workerName}' already exists. Please use a unique name.`
925
- );
926
- } else {
927
- throw new Error(
928
- `Error checking if worker exists: ${response.status} ${response.statusText} ${await response.text()}`
924
+ `Worker with name '${workerName}' already exists. Please use a unique name.`,
929
925
  );
930
926
  }
927
+ throw new Error(
928
+ `Error checking if worker exists: ${response.status} ${response.statusText} ${await response.text()}`,
929
+ );
931
930
  }
932
931
 
933
932
  async function bundleWorkerScript<B extends Bindings>(
934
933
  compatibilityDate: string,
935
- props: WorkerProps<B>
934
+ props: WorkerProps<B>,
936
935
  ) {
937
936
  const bundle = await Bundle("bundle", {
938
937
  entryPoint: props.entrypoint!,
@@ -964,11 +963,11 @@ async function bundleWorkerScript<B extends Bindings>(
964
963
  try {
965
964
  if (bundle.content) {
966
965
  return bundle.content;
967
- } else if (bundle.path) {
966
+ }
967
+ if (bundle.path) {
968
968
  return await fs.readFile(bundle.path, "utf-8");
969
- } else {
970
- throw new Error("Failed to create bundle");
971
969
  }
970
+ throw new Error("Failed to create bundle");
972
971
  } catch (error) {
973
972
  console.error("Error reading bundle:", error);
974
973
  throw new Error("Error reading bundle");
@@ -979,7 +978,7 @@ async function configureURL<B extends Bindings>(
979
978
  ctx: Context<Worker<B>>,
980
979
  api: CloudflareApi,
981
980
  workerName: string,
982
- url: boolean
981
+ url: boolean,
983
982
  ) {
984
983
  let workerUrl;
985
984
  if (url) {
@@ -989,17 +988,17 @@ async function configureURL<B extends Bindings>(
989
988
  { enabled: true, previews_enabled: true },
990
989
  {
991
990
  headers: { "Content-Type": "application/json" },
992
- }
991
+ },
993
992
  );
994
993
 
995
994
  // Get the account's workers.dev subdomain
996
995
  const subdomainResponse = await api.get(
997
- `/accounts/${api.accountId}/workers/subdomain`
996
+ `/accounts/${api.accountId}/workers/subdomain`,
998
997
  );
999
998
 
1000
999
  if (!subdomainResponse.ok) {
1001
1000
  throw new Error(
1002
- `Could not fetch workers.dev subdomain: ${subdomainResponse.status} ${subdomainResponse.statusText}`
1001
+ `Could not fetch workers.dev subdomain: ${subdomainResponse.status} ${subdomainResponse.statusText}`,
1003
1002
  );
1004
1003
  }
1005
1004
  const subdomainData: {
@@ -1026,11 +1025,11 @@ async function configureURL<B extends Bindings>(
1026
1025
  JSON.stringify({ enabled: false }),
1027
1026
  {
1028
1027
  headers: { "Content-Type": "application/json" },
1029
- }
1028
+ },
1030
1029
  );
1031
1030
  if (!response.ok) {
1032
1031
  throw new Error(
1033
- `Failed to disable worker URL: ${response.status} ${response.statusText}`
1032
+ `Failed to disable worker URL: ${response.status} ${response.statusText}`,
1034
1033
  );
1035
1034
  }
1036
1035
  }
@@ -1039,17 +1038,17 @@ async function configureURL<B extends Bindings>(
1039
1038
 
1040
1039
  async function getWorkerScriptMetadata(
1041
1040
  api: CloudflareApi,
1042
- workerName: string
1041
+ workerName: string,
1043
1042
  ): Promise<WorkerScriptMetadata | undefined> {
1044
1043
  const response = await api.get(
1045
- `/accounts/${api.accountId}/workers/services/${workerName}`
1044
+ `/accounts/${api.accountId}/workers/services/${workerName}`,
1046
1045
  );
1047
1046
  if (response.status === 404) {
1048
1047
  return undefined;
1049
1048
  }
1050
1049
  if (!response.ok) {
1051
1050
  throw new Error(
1052
- `Error getting worker script metadata: ${response.status} ${response.statusText}`
1051
+ `Error getting worker script metadata: ${response.status} ${response.statusText}`,
1053
1052
  );
1054
1053
  }
1055
1054
  return ((await response.json()) as any).result as WorkerScriptMetadata;
@@ -1058,7 +1057,7 @@ async function getWorkerScriptMetadata(
1058
1057
  async function getWorkerBindings(
1059
1058
  api: CloudflareApi,
1060
1059
  workerName: string,
1061
- environment = "production"
1060
+ environment = "production",
1062
1061
  ) {
1063
1062
  const response = await api.get(
1064
1063
  `/accounts/${api.accountId}/workers/services/${workerName}/environments/${environment}/bindings`,
@@ -1067,7 +1066,7 @@ async function getWorkerBindings(
1067
1066
  Authorization: `Bearer ${process.env.CLOUDFLARE_API_TOKEN}`,
1068
1067
  "Content-Type": "application/json",
1069
1068
  },
1070
- }
1069
+ },
1071
1070
  );
1072
1071
 
1073
1072
  if (response.status === 404) {
@@ -1076,7 +1075,7 @@ async function getWorkerBindings(
1076
1075
 
1077
1076
  if (!response.ok) {
1078
1077
  throw new Error(
1079
- `Failed to fetch bindings: ${response.status} ${response.statusText}`
1078
+ `Failed to fetch bindings: ${response.status} ${response.statusText}`,
1080
1079
  );
1081
1080
  }
1082
1081
 
@@ -1132,7 +1131,7 @@ async function uploadAssets(
1132
1131
  api: CloudflareApi,
1133
1132
  workerName: string,
1134
1133
  assets: Assets,
1135
- assetConfig?: WorkerProps["assets"]
1134
+ assetConfig?: WorkerProps["assets"],
1136
1135
  ): Promise<AssetUploadResult> {
1137
1136
  // Process the assets configuration once at the beginning
1138
1137
  const processedConfig = createAssetConfig(assetConfig);
@@ -1155,12 +1154,12 @@ async function uploadAssets(
1155
1154
  JSON.stringify({ manifest: fileMetadata }),
1156
1155
  {
1157
1156
  headers: { "Content-Type": "application/json" },
1158
- }
1157
+ },
1159
1158
  );
1160
1159
 
1161
1160
  if (!uploadSessionResponse.ok) {
1162
1161
  throw new Error(
1163
- `Failed to start assets upload session: ${uploadSessionResponse.status} ${uploadSessionResponse.statusText}`
1162
+ `Failed to start assets upload session: ${uploadSessionResponse.status} ${uploadSessionResponse.statusText}`,
1164
1163
  );
1165
1164
  }
1166
1165
 
@@ -1220,12 +1219,12 @@ async function uploadAssets(
1220
1219
  Authorization: `Bearer ${completionToken}`,
1221
1220
  "Content-Type": "multipart/form-data",
1222
1221
  },
1223
- }
1222
+ },
1224
1223
  );
1225
1224
 
1226
1225
  if (!uploadResponse.ok) {
1227
1226
  throw new Error(
1228
- `Failed to upload asset files: ${uploadResponse.status} ${uploadResponse.statusText}`
1227
+ `Failed to upload asset files: ${uploadResponse.status} ${uploadResponse.statusText}`,
1229
1228
  );
1230
1229
  }
1231
1230
 
@@ -1250,7 +1249,7 @@ async function uploadAssets(
1250
1249
  * @returns Hash (first 32 chars of SHA-256) and size of the file
1251
1250
  */
1252
1251
  async function calculateFileMetadata(
1253
- filePath: string
1252
+ filePath: string,
1254
1253
  ): Promise<{ hash: string; size: number }> {
1255
1254
  const hash = crypto.createHash("sha256");
1256
1255
  const fileContent = await fs.readFile(filePath);
@@ -1273,7 +1272,7 @@ async function calculateFileMetadata(
1273
1272
  async function deleteQueueConsumers<B extends Bindings>(
1274
1273
  ctx: Context<Worker<B>>,
1275
1274
  api: CloudflareApi,
1276
- workerName: string
1275
+ workerName: string,
1277
1276
  ): Promise<void> {
1278
1277
  const eventSources = ctx.output?.eventSources || [];
1279
1278
 
@@ -1281,7 +1280,8 @@ async function deleteQueueConsumers<B extends Bindings>(
1281
1280
  const queueIds = eventSources.flatMap((eventSource) => {
1282
1281
  if (isQueue(eventSource)) {
1283
1282
  return [eventSource.id];
1284
- } else if (isQueueEventSource(eventSource)) {
1283
+ }
1284
+ if (isQueueEventSource(eventSource)) {
1285
1285
  return [eventSource.queue.id];
1286
1286
  }
1287
1287
  return [];
@@ -1296,18 +1296,18 @@ async function deleteQueueConsumers<B extends Bindings>(
1296
1296
 
1297
1297
  // Filter consumers by worker name
1298
1298
  const workerConsumers = consumers.filter(
1299
- (consumer) => consumer.scriptName === workerName
1299
+ (consumer) => consumer.scriptName === workerName,
1300
1300
  );
1301
1301
 
1302
1302
  // Delete all consumers for this worker in parallel
1303
1303
  await Promise.all(
1304
1304
  workerConsumers.map(async (consumer) => {
1305
1305
  console.log(
1306
- `Deleting queue consumer ${consumer.id} for worker ${workerName}`
1306
+ `Deleting queue consumer ${consumer.id} for worker ${workerName}`,
1307
1307
  );
1308
1308
  // Use the deleteQueueConsumer function from queue-consumer.ts
1309
1309
  await deleteQueueConsumer(api, consumer.queueId, consumer.id);
1310
- })
1310
+ }),
1311
1311
  );
1312
1312
  } catch (err) {
1313
1313
  if (err instanceof CloudflareApiError && err.status === 404) {
@@ -1316,6 +1316,6 @@ async function deleteQueueConsumers<B extends Bindings>(
1316
1316
  throw err;
1317
1317
  }
1318
1318
  }
1319
- })
1319
+ }),
1320
1320
  );
1321
1321
  }
@@ -21,7 +21,7 @@ export interface WorkflowProps {
21
21
  }
22
22
 
23
23
  export class Workflow<PARAMS = unknown> {
24
- public readonly type: "workflow" = "workflow";
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 }[] = [];