Repository navigation
refactor(bindings)!: remove Binding.Policy and align all bindings to a single convention - #690
Conversation
…ervice Collapse the legacy `Binding.ServiceClass` + `Binding.Policy` pair into a single combined `Binding.Service` identifier (tag + callable + type), matching the `Resource.ts` pattern. The deploy-time IAM/native-binding registration is inlined into each impl layer under `if (!globalThis.__ALCHEMY_RUNTIME__)`, resolving the host via `yield* Binding.host`. - Capabilities are now directly callable: `GetItem(table)` (no `.bind`) - Impl layers renamed `*Live` -> `*Binding` - Cloudflare resources/capabilities are namespaced and permission-split (`Cloudflare.R2.ReadBucket`, `Cloudflare.SecretsStore.Store`) - `Binding.ServiceClass` retired Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/d26f87a@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/d26f87a@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/d26f87a |
Bring Cloudflare/index.ts to the AWS standard: every resource-bearing service is `export * as <Service>`, mirroring `Cloudflare.R2.Bucket`, `Cloudflare.Dns.ReadDns`, `Cloudflare.Email.CatchAll`. Cross-cutting utilities stay flat. - Container/ -> Containers/ (Cloudflare.Containers.*), Container re-exported at root - Browser + RateLimit folded into Workers (binding-only primitives), re-exported at root - Email symbols drop the redundant Email prefix (EmailCatchAll -> Cloudflare.Email.CatchAll) - Dns/Tunnel capabilities renamed verb-first (DnsRead -> ReadDns, TunnelRead -> ReadTunnel) - new Access/ and Gateway/ barrels - convenience root re-exports: Worker, Container, Browser, RateLimit, DurableObject*, Rpc*, InferEnv, Workflow, WorkerLoader - all consumers + JSDoc + generated docs updated Co-Authored-By: Claude Opus 4.8 <[email protected]>
`Binding` is a Cloudflare native-worker concept. AWS runtime impls call the distilled HTTP API authenticated by the Lambda's IAM role, so the impl layer is `*Http` (e.g. DynamoDB.PutItemHttp, SQS.SendMessageBatchHttp, S3.GetObjectHttp), matching the Cloudflare HTTP-impl convention. - 117 AWS `<Op>Binding.ts` -> `<Op>Http.ts` (file + layer symbol) - consumers, indexes, Providers registrations updated - Cloudflare native `*Binding` layers (e.g. Hyperdrive.ConnectBinding) unchanged Co-Authored-By: Claude Opus 4.8 <[email protected]>
| return Effect.fn(function* (queue: Queue) { | ||
| const QueueUrl = yield* queue.queueUrl; | ||
| if (!globalThis.__ALCHEMY_RUNTIME__) { | ||
| const host = yield* Binding.host; |
There was a problem hiding this comment.
nit: rename this to Binding.Host
| }); | ||
| } | ||
| } | ||
| return Effect.fn(function* (request: DeleteMessageRequest) { |
There was a problem hiding this comment.
I think each of the binding functions should add an identifier
Effect.fn(AWS.SQS.DeleteMessage(${host.LogicalId}), ${queue.LogicalId})(function*(...)
Whatever makes sense for the binding?
| }, | ||
| Effect.gen(function* () { | ||
| const artifacts = yield* Cloudflare.Artifacts.bind(Repos); | ||
| const artifacts = yield* Cloudflare.Artifacts.Artifacts(Repos); |
There was a problem hiding this comment.
This should be Cloudflare.Artifacts.ReadStore, Cloudflare.Artifacts.WriteStore, ReadWriteStore, etc.
| // then receives and persists it via its `queue(batch)` handler — end-to-end | ||
| // regression guard for the Queue, QueueWrite, and QueueConsumer resources. | ||
| export const Queue = Cloudflare.Queue("Queue"); | ||
| export const Queue = Cloudflare.Queue.Queue("Queue"); |
There was a problem hiding this comment.
It should be Cloudflare.Queues.Queue, Cloudflare.Queues.Consumer, Cloudflare.Queues.ReadQueue(queue)
| // Register the same worker script as a consumer of Queue. The worker's | ||
| // `queue(batch)` handler (see src/worker.ts) receives each message batch. | ||
| yield* Cloudflare.QueueConsumer("QueueConsumer", { | ||
| yield* Cloudflare.Queue.QueueConsumer("QueueConsumer", { |
There was a problem hiding this comment.
rename to Cloudflare.Queue.Consumer
| ); | ||
| } else if (request.method === "POST" || request.method === "PUT") { | ||
| // const request = yield* Cloudflare.Request | ||
| // const request = yield* Cloudflare.Workers.Request |
There was a problem hiding this comment.
Hoist Request to Cloudflare.Request
| import * as Cloudflare from "alchemy/Cloudflare"; | ||
|
|
||
| export const Bucket = Cloudflare.R2Bucket("Bucket"); | ||
| export const Bucket = Cloudflare.R2.R2Bucket("Bucket"); |
There was a problem hiding this comment.
Rename R2Bucket to Bucket so it's Cloudflare.R2.Bucket(..)
There was a problem hiding this comment.
Same for D1Database, rename to Cloudflare.D1.Database
Apply consistent suffixless convention for each of the namespaces. You'll have to audit each of the cloudflare resources for this problem. All files with a redundant suffix in the name or in the class name need to be removed
D1Database.ts -> Database.ts
class D1Database -> class Database
| import * as Cloudflare from "alchemy/Cloudflare"; | ||
|
|
||
| export const KV = Cloudflare.KVNamespace("KV"); | ||
| export const KV = Cloudflare.KV.KVNamespace("KV"); |
There was a problem hiding this comment.
Rename to Cloudflare.KV.Namespace
| const { roomId, message } = input; | ||
|
|
||
| const stored = yield* Cloudflare.task( | ||
| const stored = yield* Cloudflare.Workers.task( |
There was a problem hiding this comment.
Should be Cloudflare.Workflows.task(..). Move workflow stuff to its own Workflows/ folder
There was a problem hiding this comment.
I also want each of these namespaces to be importable directly, just liek effect
two options:
import * as Cloudflare from "alchemy/Cloudflare";
Cloudflare.Workflows.taskor
import * as Workflows from "alchemy/Cloudflare/Workflows";
Workflows.taskConsistent for all namespaces in src/Cloudflare and src/AWS
| const state = yield* Cloudflare.DurableObjectState; | ||
| return Effect.gen(function* () { | ||
| const sessions = new Map<string, Cloudflare.DurableWebSocket>(); | ||
| const sessions = new Map<string, Cloudflare.Workers.DurableWebSocket>(); |
There was a problem hiding this comment.
Rename to Cloudflare.WebSocket.Socket
Every Cloudflare resource symbol/class/type/file drops the redundant namespace prefix (PR #690 review, comment 14): R2Bucket -> Cloudflare.R2.Bucket, KVNamespace -> Cloudflare.KV.Namespace, D1Database -> Cloudflare.D1.Database, QueueConsumer -> Cloudflare.Queue.Consumer, AccessPolicy -> Cloudflare.Access.Policy, PagesProject -> Cloudflare.Pages.Project, etc. (~900 symbols across ~77 services). - internal types (*Props/*Attributes/*Provider) stripped too where unambiguous - names colliding with JS globals (Object/Error) or the core Binding/Provider modules kept prefixed; workers-types globals (R2Bucket, KVNamespace, …) rewritten only on alchemy uses, never on `runtime.*`/`cf.*` references - all consumers, Providers.ts, and generated docs updated Co-Authored-By: Claude Opus 4.8 <[email protected]>
Per PR #690 review: the alchemy DO binding is now Cloudflare.Workers.DurableObject (root re-export Cloudflare.DurableObject); RpcDurableObjectNamespace -> RpcDurableObject. workers-types/distilled DurableObjectNamespace references are left intact. Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Cloudflare.Containers.layerContainer -> Cloudflare.Containers.layer (comment 7) - hoist Workers Request to a root re-export Cloudflare.Request (comment 9) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Cloudflare.Queue.* -> Cloudflare.Queues.* (Cloudflare's product name; comment 4). Dir Queue/ -> Queues/; resource/symbols unchanged (Queues.Queue, Queues.Consumer, …). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Capitalize the deploy-time host resolver (PR #690 review, comment 1). Updated across all ~120 AWS + Cloudflare binding impl layers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Workflow.ts + WorkflowBridge.ts move from Workers/ to a new Workflows/ namespace (comment 12): Cloudflare.Workflows.task, Cloudflare.Workflows.Workflow, etc.; Cloudflare.Workflow stays as a root re-export. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Move Workers/WebSocket.ts to a WebSocket/ namespace (comments 6, 13): DurableWebSocket -> Cloudflare.WebSocket.Socket, Cloudflare.Workers.upgrade() -> Cloudflare.WebSocket.upgradeConnection(). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ReadWrite Cloudflare.Artifacts.ReadStore (get/list/raw), WriteStore (create/delete/import), ReadWriteStore (both) — same native binding typed to each subset, least-privilege by construction (comment 3). Drops the stray Cloudflare.Artifacts.Artifacts callable. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ibe) Replace `X(resource, props?).subscribe(handler)` with `X(resource, handler)` / `X(resource, props, handler)` across every event source (comment 8): Cloudflare Queues.messages + Workers.cron, GitHub events, AWS SQS/S3/SNS/EventBridge. The handler's runtime requirements are dropped at the source boundary (satisfied at dispatch), so explicit Body type args no longer break inference. Consumers, JSDoc, tutorials, and generated docs updated. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…uides Co-Authored-By: Claude Opus 4.8 <[email protected]>
Each binding's runtime Effect.fn now carries a tracing label derived from its tag-id + bound resource LogicalIds (PR #690 review, comment 2), e.g. `AWS.SQS.DeleteMessage(${queue.LogicalId})`, `Cloudflare.R2.ReadBucket(${bucket.LogicalId})`. Account/service-scoped ops use the bare tag; variadic ops list the sorted resources. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The generated Worker entry imports `makeWorkerBridge`, `makeDurableObjectBridge`, and `makeWorkflowBridge` from "alchemy/Cloudflare" (Workers/WorkerBundle.ts), but the namespace refactor moved them under Cloudflare.Workers.* / Cloudflare.Workflows.*, breaking worker bundling at runtime (tsgo couldn't catch it — the virtual entry is bundled, not type-checked). Re-export them top-level. Co-Authored-By: Claude Opus 4.8 <[email protected]>
After folding RateLimit into Workers/, the inline `import { type RateLimitClient }`
back-edge in RateLimit.ts (→ RateLimitBinding.ts) wasn't erased in the rolldown
worker bundle, closing a RateLimitBinding → Worker → WorkerAsyncBindings → RateLimit
cycle so `Layer.effect(RateLimit, …)` captured an undefined tag. Use a statement-level
`import type` (guaranteed erased) to break the cycle.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-suite contention Cloudflare serializes zone client-cert mutations per zone, so under full-suite load the deleted-cert tombstone lags past the old ~60s poll budget, flaking `waitForGone` with CertificateNotDeleted (passes in isolation). Widen the poll to ~135s and the test timeouts to 200s. Delete logic is unchanged — the cert does settle to deleted, just slower under contention. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The async-worker D1 surface test's `retryRows` reused the ~60s `ready` schedule; under full-suite concurrency the freshly-deployed worker's writes lag past it (RowsMismatch), though it passes in isolation. Widen to ~90s (within the 120s test timeout). Co-Authored-By: Claude Opus 4.8 <[email protected]>
The integration suites hit real cloud APIs at high concurrency; a few tests per run flake on transient network/edge-propagation issues (read ETIMEDOUT, D1 replica lag, cert tombstone lag) that pass on re-run. Add `retry: 2` so flakes self-heal while deterministic failures still surface (the test body retries; deploys live in beforeAll and are not re-run). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reorder binding impl files so the significant definition (the `*Http`/`*Binding` Layer export) sits at the top, right after imports, and helper utilities/types move below it — each file's primary focus reads first. Pure reordering: helpers moved below are only referenced inside the Layer's Effect.gen/Effect.fn closures (or are hoisted type aliases), so no use-before-declaration. 15 files across CloudWatch/DynamoDB/Kinesis (AWS) and Dns/Flagship/KV/Queues/R2/Tunnel/Workers (CF). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…, handler) Rename every event source to a universal verb-prefixed, resource-named callable. Handler is the last positional arg, props optional in the middle. - Cloudflare.Queues.messages -> consumeQueue - AWS.SQS.messages -> consumeQueue - AWS.S3.notifications -> consumeBucket - AWS.SNS.notifications -> consumeTopic - GitHub.events -> consumeRepository - AWS.Kinesis.records(s,p).process(h) -> consumeStream(s, p?, h) (flattened) - AWS.DynamoDB.stream(t,p).process(h) -> consumeStream(t, p?, h) (flattened) - AWS.EventBridge.events(...,h) -> consumeEventBus (routing-builder events(...).toLambda/.toQueue/.toEcsTask kept as events) Also re-export Cloudflare.Workers.cron at the root as Cloudflare.cron. DynamoDB consumeStream drops the redundant `T extends Table` generic so the row type is the first explicit type arg: consumeStream<Row>(table, ...). Updates all call sites, JSDoc, generated provider docs, and the website tutorials/guides (binding concept, kinesis/dynamodb-streams/sqs/ s3-events/queue-consumer tutorials, llms.txt). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Make each consume callable name the event element it yields, not just the resource: - consumeQueue -> consumeQueueMessages (AWS.SQS, Cloudflare.Queues) - consumeBucket -> consumeBucketEvents (AWS.S3) - consumeTopic -> consumeTopicNotifications (AWS.SNS) - consumeRepository -> consumeRepositoryEvents (GitHub) - consumeStream -> consumeStreamRecords (AWS.Kinesis) - consumeStream -> consumeTableChanges (AWS.DynamoDB) - consumeEventBus -> consumeBusEvents (AWS.EventBridge) Updates all call sites, JSDoc, generated provider docs, website tutorials/guides, llms.txt, and the AWS bring-up process docs. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…the runtime guard Every binding now lives in a single `Binding.Service`/`Layer.effect`. The deploy-time wiring (IAM, native bindings, sub-resource creation like `EventSourceMapping`) moves behind `if (!globalThis.__ALCHEMY_RUNTIME__)`, matching the capability bindings. The two-layer `*Policy` + `*PolicyLive` split and `Binding.Policy` itself are deleted. Migrated event sources / routing helpers: - AWS Lambda: Bucket / Table / Stream / Queue / Topic / EventBridge - AWS EventBridge routing: ToLambda / ToQueue - Cloudflare: Queues consumer / Cron / GitHub repository - Server: S3 bucket Plan-time resource constructors are resolved at the outer layer; the guarded deploy block is wrapped in `Namespace.push(host.LogicalId)` so each EventSourceMapping/subscription keeps the exact logical identity the old Binding.Policy produced (no resource churn on existing stacks). Runtime `host.listen` / `ctx.listen` stays outside the guard. Also: - Delete dead `BindWorkerPolicy` (never consumed; live path is `bindWorker`). - Excise `Policy` / `PolicyLike` / `PolicyShape` from the core (Binding.ts, Provider.ts, Stack.ts, Platform.ts, index.ts) and both `Providers.ts`. - AWS Providers test now provides `ArtifactStore` (mirrors the Cloudflare test; it was previously masked by Layer.mergeAll variadic inference). - Rewrite the binding/phases concept docs to describe the single-layer guard. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eAndQueue The deploy effect did `yield* TableAndQueue` but only provided `DynamoDBStreamFunctionLive`, which consumes `TableAndQueueLive` internally (via Effect.provide in the function body) and does not re-expose it — so the test failed in ~40ms with `Service not found: TableAndQueue` before any deploy. Pre-existing; never caught because creds were expired. Export `TableAndQueueLive` and provide it in the test's deploy scope. The deterministic logical ids (StreamSourceTable / StreamSinkQueue) dedupe to one physical Table/Queue, so the function's binding and the test's reads share the same resources. Verified live: real Lambda + DynamoDB stream + SQS sink, a written item flows through as a change record. Co-Authored-By: Claude Opus 4.8 <[email protected]>
a0658fa to
2d51473
Compare
… merge Main renamed DurableObjectNamespace -> DurableObject (#690) and moved the worker provider into WorkerProvider.ts. Re-apply the adoption fallback there, and fix the merged test/JSDoc to the current API. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
…PI surface - rework ConnectionBinding to the single binding convention (alchemy-run#690): combined tag/callable + Binding.Host dispatch inside ConnectionBindingLive, drop Binding.Policy machinery and its Providers registrations - replace the removed Build/Command helper (alchemy-run#673) with a local spawner-based runBuildCommand in ComputeBuild - update shape-typed class forms to the id-only + .make(props, impl) Platform API - add the /v1/apps, /v1/deployments, and build-logs surface to the client, operation helpers, and route-parity tests (96-route coverage) - add ScmInstallation.connected/connectedAt, the connected list filter, and connectScmInstallation for the new SCM connect endpoint; unreleased routes are allowlisted until they ship to the production OpenAPI doc
…a single convention (alchemy-run#690)
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
Port of the original Binding.Policy implementation to the post-#690 event-source convention (Layer resolves the Worker host directly; sibling Email.Routing + Email.Rule are yielded under Namespace.push guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive). - Cloudflare.email({ zone, matchers }).subscribe(handler) wires the runtime email listener and auto-creates Email.Routing (retained on destroy) + Email.Rule targeting the host Worker - Effect-native ForwardableEmailMessage wrapper (forward/reply/ setReject as Effects, raw escape hatch) - e2e test + fixture gated on CLOUDFLARE_TEST_ZONE / CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM - doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir no longer exists) - example updated to the Email.Send / Email.SendBinding API Co-authored-by: Michael (Pear) <[email protected]>
A coordinated naming-alignment release: every Cloudflare service is now a proper namespace, every binding across AWS and Cloudflare follows one
{Verb}{Resource}convention, and the two-layerBinding.Policysplit is gone — folded into a single runtime-guardedLayer. Almost no new behavior; a rename across ~900 symbols and ~1200 files so the API reads the same everywhere.Breaking changes
Cloudflare.KVNamespace→Cloudflare.KV.Namespace,Cloudflare.Worker→Cloudflare.Workers.Worker(common ones re-exported at the root).AiGateway/AiSearch/AiSecuritycollapse intoAI—Cloudflare.AiGateway→Cloudflare.AI.Gateway.R2Bucket.bind(b)→Cloudflare.R2.ReadBucket(b),DynamoDB.GetItem.bind(t)→AWS.DynamoDB.GetItem(t).Binding.Policyis removed — deploy-time wiring moves behind anif (!globalThis.__ALCHEMY_RUNTIME__)guard in one Layer.*Live→*Binding(Cloudflare native worker binding) or*Http(HTTP-client binding, all AWS + Cloudflare HTTP impls).consume<Resource><Event>(resource, handler)—Queues.messages(q).subscribe(fn)→Queues.consumeQueueMessages(q, fn).Images({ name: "X" })→Images("X"); native layers drop*Live/*Layer(BrowserBindingLive→BrowserBinding).Artifacts.Store→Artifacts.Namespace(andReadWriteStore→ReadWriteNamespace).Every Cloudflare service is a namespace
Cloudflare/index.tswas a flatexport *; it now mirrors the AWS barrel — oneexport * as <Service>per service, with the redundant prefix stripped:Common building blocks stay at the root (
Cloudflare.Worker,Container,DurableObject,Workflow,RateLimit,cron). The DO base class loses its suffix (DurableObjectNamespace→DurableObject). Folder reshuffles:Container/→Containers/,Queue→Queues, workflow code →Workflows/, plus a newCloudflare.WebSockettype for hibernatable handlers.Ai*becomes oneAInamespaceThe three AI services collapse into
Cloudflare.AI, dropping theAiprefix:AiGatewayDataset→AI.Dataset,AiSearchInstance→AI.SearchInstance,AiSecuritySettings→AI.SecuritySettings.One binding convention, everywhere
AWS and Cloudflare bindings now read identically — the capability is the noun, prefixed by the verb (access level), called directly (
.bindis gone):Where the API distinguishes access levels, the capability splits into
Read/Write/ReadWritefor least privilege:*Bindingvs*HttpEach capability ships two interchangeable impl Layers; the suffix is the transport:
*Http— emits a least-privilege IAM policy statement on the Lambda role, then calls the distilled HTTP API with it. (AWS has no native binding, so every AWS impl was renamed*Live→*Http.)*Http— mints a scopedAccountApiTokenwith only the needed permission groups, binds its value as a secret, and calls the REST API through distilled.The client interface is identical regardless of which Layer you provide — a Worker over its native binding and a Container over a token run the same code.
More Cloudflare
*HttpbindingsR2, KV, and Queues already had
*Httpimpls; DNS joins them this release, all sharing one mechanism and the verb-first naming:An
*HttpLayer provisions its own credential: at deploy time it mints anAccountApiTokenscoped to only the permission groups that access level needs (aReadNamespacemints a read-only KV token, aWriteNamespacea write-only one) and binds its value into the host as a secret, behind the__ALCHEMY_RUNTIME__guard. At runtime the client reads the token'svalue/accountIdand calls the REST API — no account-wide key, a different scoped token per capability.Binding.Policyis goneBindings were two pieces: a runtime
Binding.Serviceplus a separate deploy-timeBinding.Policy(with its own*PolicyLivelayer). They collapse into a singleBinding.Servicewhose setup Effect does the deploy-time wiring inline, guarded so it only runs at plan time:At plan time the guard is open and
bindrecords what the function needs; at runtime the branch is skipped, so the runtime bundle stays small. Every binding — including event sources — now follows this.Binding.Policy,Binding.ServiceClass, and thePolicy/PolicyLiketypes are removed from the core.Worker-only bindings take a string id
The bindings with no backing resource (
Images,Browser,VersionMetadata,RateLimit) take a string id first instead of a{ name }object, and their native layers drop*Live/*Layer:Artifacts.Store→Artifacts.Namespace(access viaReadNamespace/WriteNamespace/ReadWriteNamespace).Event sources:
consume<Resource><Event>Event sources are bindings too. The old
X(resource, props?).subscribe(handler)shape becomes a single verb-prefixed, resource-and-event-named callable taking the handler last:SQS.messages(q).subscribeSQS.consumeQueueMessages(q, fn)S3.notifications(b).subscribeS3.consumeBucketEvents(b, fn)SNS.notifications(t).subscribeSNS.consumeTopicNotifications(t, fn)Kinesis.records(s).processKinesis.consumeStreamRecords(s, fn)DynamoDB.stream(t).processDynamoDB.consumeTableChanges(t, fn)GitHub.events(r).subscribeGitHub.consumeRepositoryEvents(r, fn)Dropping
.subscribealso drops the handler's runtime requirements at the source boundary, so explicitBodytype arguments no longer break inference.