@sanoma-ai/connector-cloudflare 0.3.2 → 0.5.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/README.md CHANGED
@@ -29,6 +29,7 @@ export const host = cloudflare.container({
29
29
  source: repo, // a declared github.repository, or a clone URL
30
30
  ref: "main",
31
31
  port: 3000,
32
+ hostname: "app.acme.example", // optional: the app at its own domain, instead of workers.dev
32
33
  secrets: {
33
34
  SANOMA_DATABASE_URL: secret("DATABASE_URL"),
34
35
  SANOMA_SECRETS_KEY: secret("SECRETS_KEY"),
@@ -38,19 +39,20 @@ export const host = cloudflare.container({
38
39
  export const wakeup = cloudflare.alarm({ host });
39
40
  ```
40
41
 
41
- | Field | What it is |
42
- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
43
- | `name` | The company's name, its identity: lowercase letters, digits and dashes, up to 56; the Worker and its application are `sanoma-<name>` |
44
- | `image` | The Sanoma runtime image, pinned to a tag or digest, never `latest`: any registry's, which apply copies into the account's and pins by digest ([The image](#the-image)) |
45
- | `source` | The company repository: a clone URL, or a declared `github.repository` |
46
- | `ref` | The branch it runs, never a commit: apply resolves it and sets the hidden `revision`, so a merge is drift on the container |
47
- | `configurationRevision` | Optional non-secret configuration version: 1–63 ASCII letters, digits, `.`, `_` or `-`; advance it to restart with rotated bootstrap or environment values at the same source revision and image |
48
- | `port` | The port the runtime listens on in the container (its `PORT`) |
49
- | `secrets` | Environment variables, each a `secret(...)`: the Worker's secret bindings, write-only, never in an output, the ledger or a checkpoint |
50
- | `domains` | Optional: a public site's domain, by site name, passed as `SANOMA_DOMAINS` and attached to the Worker by apply as a custom domain ([Custom domains](#custom-domains)) |
51
- | `id`, `url`, `healthy` | Cloudflare's: the application's id, the Worker's workers.dev URL, and whether it answers |
52
-
53
- The host's outputs are `{ url, revision, healthy }`. Its capabilities: stops when quiet, a public URL, it runs an image rather than building one, no fixed egress. `healthy` is the application existing and the Worker answering `/__sanoma/health`, which does not start a stopped container: a stopped host is healthy, and a read or a drift check leaves it stopped.
42
+ | Field | What it is |
43
+ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
44
+ | `name` | The company's name, its identity: lowercase letters, digits and dashes, up to 56; the Worker and its application are `sanoma-<name>` |
45
+ | `image` | The Sanoma runtime image, pinned to a tag or digest, never `latest`: any registry's, which apply copies into the account's and pins by digest ([The image](#the-image)) |
46
+ | `source` | The company repository: a clone URL, or a declared `github.repository` |
47
+ | `ref` | The branch it runs, never a commit: apply resolves it and sets the hidden `revision`, so a merge is drift on the container |
48
+ | `configurationRevision` | Optional non-secret configuration version: 1–63 ASCII letters, digits, `.`, `_` or `-`; advance it to restart with rotated bootstrap or environment values at the same source revision and image |
49
+ | `port` | The port the runtime listens on in the container (its `PORT`) |
50
+ | `secrets` | Environment variables, each a `secret(...)`: the Worker's secret bindings, write-only, never in an output, the ledger or a checkpoint |
51
+ | `domains` | Optional: a public site's domain, by site name, passed as `SANOMA_DOMAINS` and attached to the Worker by apply as a custom domain ([Custom domains](#custom-domains)) |
52
+ | `hostname` | Optional: the hostname the app is served at (`internal.acme.example`), attached like a site's domain; the host's `url` is then `https://<hostname>` |
53
+ | `id`, `url`, `worker_url`, `healthy` | Cloudflare's: the application's id, where the app answers (`https://<hostname>` once attached, else the Worker's workers.dev URL), the workers.dev URL, and whether it answers |
54
+
55
+ The host's outputs are `{ url, wakeUrl, revision, healthy }` (`wakeUrl` its `worker_url`). Its capabilities: stops when quiet, a public URL, it runs an image rather than building one, no fixed egress. `healthy` is the application existing and the Worker answering `/__sanoma/health`, which does not start a stopped container: a stopped host is healthy, and a read or a drift check leaves it stopped.
54
56
 
55
57
  `configurationRevision` participates in plans and reads. Change it when delivering new secret values without changing the source or image; for example, a managed lifecycle can derive it from its deployment and credential generation (`d1-g2`). The connector sends it as the reserved plain-text binding `SANOMA_CONFIG_REVISION`, and startup waits for that configuration revision as well as the source revision. It must contain no secret value. Secret values remain write-only: changing a stored value alone with the same configuration revision is not detected by a plan.
56
58
 
@@ -62,13 +64,14 @@ The logo is Cloudflare's cloud from [Simple Icons](https://simpleicons.org/?q=cl
62
64
 
63
65
  The package ships the Worker it uploads, `worker/`: `index.js`, which exports the Durable Object class `SanomaInstance` over `DurableObject` from `cloudflare:workers`, and `instance.js`, the object's code with no imports (typed by `instance.d.ts`), which the fake runs in Node so both kits check the code Cloudflare runs. Every request to the Worker goes to its one object, which:
64
66
 
65
- - starts the container on a request at the Worker's source revision, configuration revision and uploaded image (`ctx.container.images.runtime`: the copy, pinned by digest), as a `standard-1` instance (½ vCPU, 4 GiB: the policy refuses `basic`), with the Worker's text bindings (plain and secret) as its environment. Container labels hold the two non-secret revisions and an image hash; a running container with different labels is destroyed and started again. Secret values never enter these labels;
67
+ - starts the container on a request at the Worker's source revision, configuration revision and uploaded image (`ctx.container.images.runtime`: the copy, pinned by digest), as a `standard-1` instance (½ vCPU, 4 GiB: the policy refuses `basic`), with the Worker's text bindings (plain and secret) as its environment. Container labels hold the two non-secret revisions, an image hash and a hash of `SANOMA_DOMAINS` (so a change of the sites' domains alone starts it again, its environment and its sites bundle with them); a running container with different labels is destroyed and started again. Secret values never enter these labels;
66
68
  - waits for the container's `/healthz` (up to ten minutes, the clone and install included), sets its inactivity timeout to ten minutes, and proxies the request to its `port` with the Host it was asked for and `x-forwarded-proto` (the port's fetch reaches the container whatever the URL's host, which becomes the request's Host header: so the company serves the public site declared on a domain);
67
69
  - answers `GET /__sanoma/health` with the source revision, configuration revision when set, and running/readiness state without starting the container. With `?start=1`, it waits until the container answers; a create or update checks both revisions before completing;
68
70
  - holds the company's one wake at `/__sanoma/wake`, with `Authorization: Bearer <SANOMA_WAKEUP_TOKEN>`: `GET` shows `{ at, rang? }`, `PUT { at }` replaces it and sets the object's alarm, `DELETE` clears it. Without the token among the host's secrets it answers 404, with another one 401;
69
- - at the alarm, starts the container and calls its `/wake`, then notes when (`rang`); a failure throws, so Cloudflare rings the alarm again.
71
+ - at the alarm, starts the container and calls its `/wake`, then notes when (`rang`); a failure throws, so Cloudflare rings the alarm again;
72
+ - over RPC, `startNow()` (the sites router's call, [Public sites on the Worker](#public-sites-on-the-worker)): sets the alarm now, unless one is due sooner, and the alarm starts the container without the caller waiting and sends it `/wake` (its worker may have stopped itself while the container stayed up); a wake held for later is set again once the start is made, and one that rang never rings twice.
70
73
 
71
- Cloudflare stops the container after ten quiet minutes; the object, its storage and its alarm stay, and the next request or alarm starts the container again. The application is of the `durable_object` scheduling policy (public beta, the one Cloudflare documents for new applications; it refused `default` on the account the connector was first run on): the object starts its container, with the image and the instance type it names, so the application is only a name and the object's namespace, and has no image, versions or rollouts. A create, in Wrangler's order, copies and pins the image and waits until Cloudflare prepared it ([The image](#the-image)), uploads the Worker with the object's migration (`new_sqlite_classes`) and its class as a container's with that image (`containers: [{ name, class_name, images: { runtime } }]`, as Wrangler sends it), turns its workers.dev URL on, makes the application for the object's namespace (`{ name, scheduling_policy: "durable_object", durable_objects: { namespace_id } }`, the `namespace_id` the Worker's settings then show), and uploads the Worker once more: the object learns which application backs its namespace only from a deployment made after the application exists, and without that upload every start answers "There is no container application assigned to this Durable Object namespace", for good (found on the first real deploy, 2026-10-29); an update does the same, except that it leaves the application as it is: a new image is a new upload naming it, and the object destroys a container started at another and starts it again at the next request. Either waits for the Worker to answer at the requested source and configuration revisions. The policy is fixed once an application is made, and the object cannot start a container under another: one of the `default` policy under that name (none can be made any more) is deleted by hand before the apply. A plan compares secret binding names, never values: the Worker's settings never show them. Advance `configurationRevision` to upload rotated values and restart a running container with them; a value change alone does not trigger an update. A delete detaches the custom domains the Worker was declared to serve, deletes the application, then the Worker with its object's storage. A Worker of that name that is not Sanoma's (no `SANOMA_INSTANCE` binding) reads as gone, and a create or a delete refuses to touch it.
74
+ Cloudflare stops the container after ten quiet minutes; the object, its storage and its alarm stay, and the next request or alarm starts the container again. The application is of the `durable_object` scheduling policy (public beta, the one Cloudflare documents for new applications; it refused `default` on the account the connector was first run on): the object starts its container, with the image and the instance type it names, so the application is only a name and the object's namespace, and has no image, versions or rollouts. A create, in Wrangler's order, copies and pins the image and waits until Cloudflare prepared it ([The image](#the-image)), uploads the Worker with the object's migration (`new_sqlite_classes`) and its class as a container's with that image (`containers: [{ name, class_name, images: { runtime } }]`, as Wrangler sends it), turns its workers.dev URL on, makes the application for the object's namespace (`{ name, scheduling_policy: "durable_object", durable_objects: { namespace_id } }`, the `namespace_id` the Worker's settings then show), and uploads the Worker once more: the object learns which application backs its namespace only from a deployment made after the application exists, and without that upload every start answers "There is no container application assigned to this Durable Object namespace", for good (found on the first real deploy, 2026-10-29); an update does the same, except that it leaves the application as it is: a new image is a new upload naming it, and the object destroys a container started at another and starts it again at the next request. Either waits for the Worker to answer at the requested source and configuration revisions. The policy is fixed once an application is made, and the object cannot start a container under another: one of the `default` policy under that name (none can be made any more) is deleted by hand before the apply. A plan compares secret binding names, never values: the Worker's settings never show them. Advance `configurationRevision` to upload rotated values and restart a running container with them; a value change alone does not trigger an update. A delete detaches the custom domains the Worker was declared to serve (its `hostname` too), deletes the application, then the Worker with its object's storage. A Worker of that name that is not Sanoma's (no `SANOMA_INSTANCE` binding) reads as gone, and a create or a delete refuses to touch it.
72
75
 
73
76
  ## The image
74
77
 
@@ -87,7 +90,15 @@ To stop scaling to zero, delete the `wakeup` line and `SANOMA_WAKEUP_TOKEN` from
87
90
 
88
91
  ## Custom domains
89
92
 
90
- Each hostname in `domains` is attached to the Worker as a [Workers custom domain](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/) by a create or an update: Cloudflare then makes its DNS record and certificate and routes it to the Worker. The zone is the hostname's last two labels (`www.acme.example` is in `acme.example`), looked up in the account once per apex when a domain is to be attached (`GET /zones?name=&account.id=`); a hostname whose zone the account does not hold, or the token cannot read, is refused, naming the hostname and the zone, before anything changes. An update lists the Worker's attached domains first (`GET …/workers/domains?service=`), and only a missing one's zone is looked up; after the upload, each missing one is attached (`PUT …/workers/domains { zone_id, hostname, service }`), then the ones declared before and no longer are detached (`DELETE …/workers/domains/{id}`). A domain attached by hand and never declared is left alone. A read lists the Worker's attached domains too and shows only the declared ones attached, so a domain whose attach failed, or one detached by hand, is drift that the next apply attaches again. A delete detaches every declared one before the Worker goes. A container without `domains` makes none of these requests, unless it served some before, which are then detached. A zone such as `acme.co.uk`, whose apex is three labels, is not found yet.
93
+ Each hostname in `domains` is attached to the Worker as a [Workers custom domain](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/) by a create or an update: Cloudflare then makes its DNS record and certificate and routes it to the Worker. The zone is the hostname's last two labels (`www.acme.example` is in `acme.example`), looked up in the account once per apex when a domain is to be attached (`GET /zones?name=&account.id=`); a hostname whose zone the account does not hold, or the token cannot read, is refused, naming the hostname and the zone, before anything changes. An update lists the Worker's attached domains first (`GET …/workers/domains?service=`), and only a missing one's zone is looked up; before the upload, the ones declared before and no longer are detached (`DELETE …/workers/domains/{id}`), while the Worker's bindings still record them, and after it each missing one is attached (`PUT …/workers/domains { zone_id, hostname, service }`), once they record it. Whatever fails in between, no domain is left attached that the bindings do not record, and the next apply attaches what is still missing; a site's domain never reaches a Worker that would serve the app there, and a renamed one is down from the detach to the attach. A domain attached by hand and never declared is left alone. A read lists the Worker's attached domains too and shows only the declared ones attached, so a domain whose attach failed, or one detached by hand, is drift that the next apply attaches again. A delete detaches every declared one before the Worker goes. A container without `domains` makes none of these requests, unless it served some before, which are then detached. A zone such as `acme.co.uk`, whose apex is three labels, is not found yet.
94
+
95
+ `hostname`, the app's own domain, is attached, detached and read the same way, in the same zone lookup, and the Worker's `SANOMA_HOSTNAME` binding records it (as `SANOMA_DOMAINS` records the sites'), so one no longer declared is detached and one detached by hand is drift. With it attached, the host's `url` is `https://<hostname>` (a read of one not attached gives the workers.dev URL, so a failed attach or one detached by hand never points at a name that does not route). The wake path stays on workers.dev, which stays on: the Worker's `SANOMA_HOST_URL` binding, the host's `wakeUrl` (its `worker_url`, which apply gives the alarm as its `host`) and the health checks, so a wake never waits on the hostname's DNS or certificate, and declaring or dropping a hostname leaves the alarm as it is. A `hostname` that is also one of `domains`' values is refused, `invalid`, at a plan and a create, before any request: the app answers at every hostname that is not a site's. A renamed `hostname` is detached before the upload and the new one attached after it, as a site's domain is: in between, a short window, no hostname is attached and the app answers on workers.dev alone (the host's `url` reads as it), and a failure there leaves the bindings naming the old one, detached, or the new one, not yet attached, which the next apply attaches.
96
+
97
+ ## Public sites on the Worker
98
+
99
+ A public site without a login, on a declared domain, is served by the Worker itself, so a visitor never waits for a cold container (forty seconds to minutes). With `domains` and `SANOMA_WAKEUP_TOKEN` among the host's secrets, a create or an update, once the Worker answers at the new revision, asks the container for its sites bundle (`GET /__sanoma/sites-bundle` with `Authorization: Bearer <SANOMA_WAKEUP_TOKEN>`): the runtime builds it on that first ask (`buildWorker` in `@sanoma-ai/app/build`: the sites' pages, `callFn` and `getActor`, the company's workflows and the runtime bundled for `workerd`, the pages no call is made from prerendered), answering 202 until it is built (each answer marked `x-sanoma-sites-bundle`), asked again every poll for up to the start's ten minutes, and through the object's 503 while the container starts again; a 401 or a 404 without the mark is a runtime from before the route (its staff login's sign-in page, or its app's not-found), and any other answer without it (an error of Cloudflare's, a 5xx), or a body cut off, is asked again too, until the start's time is up, which fails the apply, retryably. Then the bundle's assets (the client build and the prerendered pages) go in through an [assets upload session](https://developers.cloudflare.com/workers/static-assets/direct-upload/) (`POST …/scripts/{name}/assets-upload-session { manifest }`, then each bucket it asks for to `POST …/workers/assets/upload?base64=true` with the session's jwt), and the Worker is uploaded again as it was, plus `worker/sites.js` as its entry, the bundle's modules under `sites/`, the `ASSETS` binding and `assets: { jwt, config }`: `run_worker_first: ["/*", "!/assets/*"]` (the client build straight from the assets), `html_handling` and `not_found_handling` `none`. Its revision, image and bindings are the deploy's, so the container keeps running.
100
+
101
+ The router hands a request the bundle serves (a site's page on its domain, but `/__sanoma`, `/api`, `/auth`, `/webhooks`, `/setup`, `/wake` and `/healthz`) to it: a file of the client build at its path, the page prerendered for it when the request has no query, else the page rendered on the Worker over the company's database (`SANOMA_DATABASE_URL`, the Worker's binding), a run it starts queued for the container's worker, which `startNow` starts. Everything else goes to the object, as before. A container with no such site answers 404, and the Worker is uploaded again as the deploy uploaded it; one whose build failed answers 500 with why, which fails the apply (the Worker then serves the sites from the container until the next apply). The deploy's upload carries a `SANOMA_SITES_PENDING` binding, which either upload after it leaves out: a Worker whose sites upload failed keeps it, a read sees it, and the next plan is an update, which, when the Worker otherwise runs what is declared, makes the sites' upload alone (no upload of the Worker as deployed, no domain attached, no wait for its revision). A site with a login stays on the container: Better Auth needs its database adapter on the Worker first.
91
102
 
92
103
  ## DNS records
93
104
 
@@ -123,7 +134,7 @@ export const mailDns = cloudflare.records({ zone: "sanoma.work", name: "resend",
123
134
 
124
135
  `./driver` (`cloudflareDriver`; `cloudflareDriver({ timeoutMs, startTimeoutMs, pollMs })`: 30 s a request, ten minutes for the Worker to answer at a new revision, two seconds between tries; each request of the image's copy may take ten minutes) and `./fake` (`fakeCloudflare`) are internal entries, for tests.
125
136
 
126
- A read is the Worker's settings (its bindings: what it runs is its plain-text bindings, never a secret's value), the application of its name (whether it exists, its id) and the account's subdomain (its URL); a plan compares the declared image, source, ref, revision, port, domains (left out too) and secret names with them. The requests are made one after another, in the order the fixtures hold.
137
+ A read is the Worker's settings (its bindings: what it runs is its plain-text bindings, never a secret's value), the application of its name (whether it exists, its id) and the account's subdomain (its URL); a plan compares the declared image, source, ref, revision, port, domains and hostname (each left out too) and secret names with them, and plans an update for a Worker still marked `SANOMA_SITES_PENDING`. The requests are made one after another, in the order the fixtures hold.
127
138
 
128
139
  ### Environment
129
140
 
@@ -138,7 +149,7 @@ When either is unset, a call fails, not retryable, naming it. The driver declare
138
149
 
139
150
  ### Errors and retries
140
151
 
141
- A 429, a 5xx, a timeout or no reply is retryable, the image's copy's requests too; any other 4xx is not. `status` and `vendorCode` (Cloudflare's first error `code`) are kept. The driver's own refusals are not retryable: `exists` (a Worker of that name that is not Sanoma's, which is neither overwritten nor deleted), `plan_changed` (an update whose plan changed since it was approved, or is not an update: a new name is a delete and a create), `no_token` and `token` (a host without the company's `SANOMA_WAKEUP_TOKEN`, or with another one), `no_zone` (a domain or a record set whose zone the account does not hold), `conflict` (a record in the way of a declared one), `no_dns_permission` (a token without Zone → DNS → Edit), `not_known` (records given as `null`), `invalid` (a record the shared shape refuses, an MX one without a priority, one outside the zone, a CNAME or a second SPF policy beside another declared record, or a set's mark longer than 100 characters), and a Worker that did not answer at its revision in time, which says what it answered.
152
+ A 429, a 5xx, a timeout or no reply is retryable, the image's copy's requests too; any other 4xx is not. `status` and `vendorCode` (Cloudflare's first error `code`) are kept. The driver's own refusals are not retryable: `exists` (a Worker of that name that is not Sanoma's, which is neither overwritten nor deleted), `plan_changed` (an update whose plan changed since it was approved, or is not an update: a new name is a delete and a create), `no_token` and `token` (a host without the company's `SANOMA_WAKEUP_TOKEN`, or with another one), `no_zone` (a domain or a record set whose zone the account does not hold), `conflict` (a record in the way of a declared one), `no_dns_permission` (a token without Zone → DNS → Edit), `not_known` (records given as `null`), `invalid` (a container's `hostname` that is one of its `domains`, a record the shared shape refuses, an MX one without a priority, one outside the zone, a CNAME or a second SPF policy beside another declared record, or a set's mark longer than 100 characters), and a Worker that did not answer at its revision in time, which says what it answered.
142
153
 
143
154
  ### Plan
144
155
 
@@ -146,7 +157,7 @@ Containers need the Workers Paid plan. An instance is billed while it runs, by i
146
157
 
147
158
  ### Testing the driver
148
159
 
149
- `test/driver.test.ts`, `test/records.test.ts` and the features replay Cloudflare's replies (`test/fixtures`) with [`@sanoma-ai/testing/replay`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#replaying-a-vendors-api): `pnpm vitest run connectors/cloudflare` needs no account. The fixtures are **written from Cloudflare's API reference, not recorded**: no account was at hand when the connector was written. A recording replaces them (`SANOMA_LIVE=1 SANOMA_RECORD=1` on the features test), losing the account's id and subdomain, ids and tokens; until then, a reply the reference gets wrong is wrong here too. The upload's `containers` field (its `name`, `class_name` and `images`) is Wrangler's and not in the reference or the SDK's types, and the object's `ctx.container.images` and `start({ image, instance })` are the policy's: the live run is what checks them. The DNS records' fixtures (`records-*`) are written from the [DNS records reference](https://developers.cloudflare.com/api/resources/dns/subresources/records/) the same way, on `sanoma.work` with a set named `check` (`check-*.sanoma.work`), to be recorded on their first live run: Cloudflare's TXT content is quoted in them, which a read takes off. That Cloudflare shows a TXT record written unquoted with quotes is the reference's examples', not checked; a read compares it either way. The image's copy is tested against two small registries in this process (`test/registry.test.ts`), and the driver's call for its credentials over replies written from the SDK's types and the OCI distribution spec; that Cloudflare's registry takes the copy as written is what the live run checks. The driver tests only replay.
160
+ `test/driver.test.ts`, `test/records.test.ts` and the features replay Cloudflare's replies (`test/fixtures`) with [`@sanoma-ai/testing/replay`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#replaying-a-vendors-api): `pnpm vitest run connectors/cloudflare` needs no account. The fixtures are **written from Cloudflare's API reference, not recorded**: no account was at hand when the connector was written. A recording replaces them (`SANOMA_LIVE=1 SANOMA_RECORD=1` on the features test), losing the account's id and subdomain, ids and tokens; until then, a reply the reference gets wrong is wrong here too. The upload's `containers` field (its `name`, `class_name` and `images`) is Wrangler's and not in the reference or the SDK's types, and the object's `ctx.container.images` and `start({ image, instance })` are the policy's: the live run is what checks them. The DNS records' fixtures (`records-*`) are written from the [DNS records reference](https://developers.cloudflare.com/api/resources/dns/subresources/records/) the same way, on `sanoma.work` with a set named `check` (`check-*.sanoma.work`), to be recorded on their first live run: Cloudflare's TXT content is quoted in them, which a read takes off. That Cloudflare shows a TXT record written unquoted with quotes is the reference's examples', not checked; a read compares it either way. The `sites` fixture's assets session and bucket upload are written from the [direct upload guide](https://developers.cloudflare.com/workers/static-assets/direct-upload/) and the SDK's types the same way, with the guide's example hash (sha256 over an asset's base64 and its extension, 32 hex digits) and each part's type from its extension; that Cloudflare takes them, and serves `/assets/*` before the Worker, is the live run's to check. The image's copy is tested against two small registries in this process (`test/registry.test.ts`), and the driver's call for its credentials over replies written from the SDK's types and the OCI distribution spec; that Cloudflare's registry takes the copy as written is what the live run checks. The driver tests only replay.
150
161
 
151
162
  ### Running it live
152
163
 
@@ -182,7 +193,7 @@ The connector carries steps for [scenarios](https://github.com/Sanoma-AI/sanoma/
182
193
 
183
194
  ## Testing
184
195
 
185
- `@sanoma-ai/connector-cloudflare/fake` is an in-memory Cloudflare account, the fake the connector carries: each sandbox run makes one of its own. Its registry is in memory too: a copy records the image under its reference there and pulls nothing. Its custom domains are in `state.domains` (hostname, Worker and zone), each zone's DNS records in `state.dns`, by the zone's name (a test adds one by hand there; a batch is all or nothing, and refuses a record identical to one the zone holds (its type, content and priority) or one beside a CNAME, as Cloudflare does), and it holds every zone asked for unless `fakeCloudflare({ zones })` names the ones it holds. A copy pins the image by a made-up digest, and a preparation answers ready for an image pinned in its registry. Its Workers answer on ports of this machine, one per Worker name, and run the package's own object code over a `ctx` in this process: storage in memory, an alarm on a timer (again after a throw), `ctx.container.images` from the upload's `containers[].images`, and a container that runs what `start` returns for the image (the one its pinned copy was copied from) and revision it was started at (by default a stub that answers `/healthz` and `/wake`); `start` refuses an image the upload did not name or an instance type that is not Cloudflare's. An upload restarts the object over its new bindings and images: a new image starts the container again at the next request, as the object finds its label changed.
196
+ `@sanoma-ai/connector-cloudflare/fake` is an in-memory Cloudflare account, the fake the connector carries: each sandbox run makes one of its own. Its registry is in memory too: a copy records the image under its reference there and pulls nothing. Its custom domains are in `state.domains` (hostname, Worker and zone), each zone's DNS records in `state.dns`, by the zone's name (a test adds one by hand there; a batch is all or nothing, and refuses a record identical to one the zone holds (its type, content and priority) or one beside a CNAME, as Cloudflare does), and it holds every zone asked for unless `fakeCloudflare({ zones })` names the ones it holds. A copy pins the image by a made-up digest, and a preparation answers ready for an image pinned in its registry. Its Workers answer on ports of this machine, one per Worker name, and run the package's own object code over a `ctx` in this process: storage in memory, an alarm on a timer (again after a throw), `ctx.container.images` from the upload's `containers[].images`, and a container that runs what `start` returns for the image (the one its pinned copy was copied from) and revision it was started at (by default a stub that answers `/healthz` and `/wake`); `start` refuses an image the upload did not name or an instance type that is not Cloudflare's. An upload restarts the object over its new bindings and images: a new image starts the container again at the next request, as the object finds its label changed. Its assets upload session asks, in one bucket, for the hashes `state.assets` lacks, and an upload that redeems the completion jwt keeps each path's hash on the Worker (`state.scripts[name].assets`, beside its `main_module` and `modules`); its Workers still send every request to the object, as it runs no sites bundle.
186
197
 
187
198
  ```ts
188
199
  import { fakeCloudflare } from "@sanoma-ai/connector-cloudflare/fake";
@@ -20,7 +20,9 @@ export declare const container: import("@sanoma-ai/workflows").Resource<z.ZodObj
20
20
  secrets: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
21
21
  port: z.ZodNumber;
22
22
  domains: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
23
+ hostname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
24
  url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ worker_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
26
  healthy: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
25
27
  }, z.core.$strip>, "cloudflare.container", {
26
28
  readonly source: {
@@ -46,7 +48,7 @@ export declare const alarm: import("@sanoma-ai/workflows").Resource<z.ZodObject<
46
48
  }, z.core.$strip>, "cloudflare.alarm", {
47
49
  readonly host: {
48
50
  readonly type: readonly ["cloudflare.container"];
49
- readonly by: readonly ["url"];
51
+ readonly by: readonly ["worker_url", "url"];
50
52
  };
51
53
  }, true>;
52
54
  /** A CAA record's content, `0 issue "letsencrypt.org"`, as the fields Cloudflare takes; undefined when it is not one. */
package/dist/connector.js CHANGED
@@ -39,7 +39,19 @@ const containerSchema = z.object({
39
39
  .refine((domains) => Object.keys(domains).length > 0, "leave `domains` out rather than empty")
40
40
  .nullish()
41
41
  .describe("A public site's domain, by site name"),
42
- url: z.string().nullish().describe("The Worker's URL on workers.dev, which Cloudflare sets"),
42
+ hostname: z
43
+ .string()
44
+ .regex(DOMAIN_NAME)
45
+ .nullish()
46
+ .describe("The hostname the app is served at, such as `internal.acme.example`: attached to the Worker as a custom domain, and its `url`"),
47
+ url: z
48
+ .string()
49
+ .nullish()
50
+ .describe("Where the app answers: `https://<hostname>` once attached, or the Worker's URL on workers.dev"),
51
+ worker_url: z
52
+ .string()
53
+ .nullish()
54
+ .describe("The Worker's URL on workers.dev, which Cloudflare sets: where its alarm and health checks reach it"),
43
55
  healthy: z
44
56
  .boolean()
45
57
  .nullish()
@@ -62,7 +74,7 @@ export const container = defineResource({
62
74
  schema: containerSchema,
63
75
  fields: {
64
76
  immutable: ["name"],
65
- vendorOwned: ["id", "url", "healthy"],
77
+ vendorOwned: ["id", "url", "worker_url", "healthy"],
66
78
  writeOnly: ["secrets"],
67
79
  references: { source: { type: "github.repository", by: ["http_clone_url"] } },
68
80
  },
@@ -71,10 +83,19 @@ export const container = defineResource({
71
83
  writable: true,
72
84
  host: {
73
85
  capabilities: { lifetime: "stops-when-quiet", publicUrl: true, buildsFromGit: false, staticEgress: false },
74
- inputs: { source: "source", ref: "ref", secrets: "secrets", port: "port", domains: "domains" },
86
+ inputs: {
87
+ source: "source",
88
+ ref: "ref",
89
+ secrets: "secrets",
90
+ port: "port",
91
+ domains: "domains",
92
+ hostname: "hostname",
93
+ },
75
94
  revision: "revision",
76
95
  outputs: (state) => ({
77
96
  url: String(state.url ?? ""),
97
+ // The alarm reaches the Worker on workers.dev, whatever hostname the app is served at.
98
+ ...(typeof state.worker_url === "string" && { wakeUrl: state.worker_url }),
78
99
  ...(typeof state.revision === "string" && { revision: state.revision }),
79
100
  healthy: state.healthy === true,
80
101
  }),
@@ -114,7 +135,8 @@ export const alarm = defineResource({
114
135
  immutable: ["host"],
115
136
  vendorOwned: ["at", "rang", "healthy"],
116
137
  writeOnly: ["token"],
117
- references: { host: { type: ["cloudflare.container"], by: ["url"] } },
138
+ // The host's wake URL (`worker_url`, its outputs' `wakeUrl`), as apply gives it: its `url` is its hostname once attached.
139
+ references: { host: { type: ["cloudflare.container"], by: ["worker_url", "url"] } },
118
140
  },
119
141
  bindingId: (state) => String(state.host),
120
142
  writable: true,
@@ -1 +1 @@
1
- {"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,eAAe,EACf,cAAc,EAEd,SAAS,EAGT,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AAEH,8GAA8G;AAC9G,MAAM,IAAI,GAAG,wCAAwC,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,uDAAuD,CAAC;IAC1F,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,KAAK,CAAC,IAAI,EAAE,mDAAmD,CAAC;SAChE,QAAQ,CACP,0GAA0G,CAC3G;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,KAAK,CAAC,oDAAoD,EAAE,oCAAoC,CAAC;SACjG,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,0CAA0C,CAAC;SACzF,QAAQ,CACP,8IAA8I,CAC/I;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qEAAqE,CAAC;IACzG,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IACrF,QAAQ,EAAE,CAAC,CAAC,MA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AAE,OAAO,EAAE,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAExG,uFAAuF;AACvF,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE;QACR,MAAM,EAAE,OAAO;QACf,qEAAqE;QACrE,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,+EAA+E;QAC5F,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC,EAAE,CAAC;QACrG,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;KACrB;CAC+B,CAAC;AAEnC,MAAM,QAAQ,GAAG,eAAe,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AASxE;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,GAAG,KAAK;IACR,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE;CACU,CAAC"}
package/dist/driver.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { defineDriver, DriverError, retryableStatus } from "@sanoma-ai/workflows";
2
2
  import { z } from "zod";
3
3
  import { cloudflareOps } from "./connector.js";
4
- import { alarmOps, containerOps, refused } from "./ops.js";
4
+ import { refused } from "./errors.js";
5
+ import { alarmOps, containerOps } from "./ops.js";
5
6
  import { recordsOps } from "./records.js";
6
7
  import { CLOUDFLARE_REGISTRY, copyImage } from "./registry.js";
7
8
  /** The environment variables the driver reads, on every call. */
@@ -40,6 +41,13 @@ function failure(what, { APIError, APIConnectionTimeoutError }, timeoutMs, error
40
41
  }
41
42
  return new DriverError(`cloudflare: ${what}: no reply`, { retryable: true, cause: error });
42
43
  }
44
+ /** How an upload types each kind of module's part. */
45
+ const MODULE_TYPES = {
46
+ esm: "application/javascript+module",
47
+ wasm: "application/wasm",
48
+ text: "text/plain",
49
+ data: "application/octet-stream",
50
+ };
43
51
  const isStatus = (error, status) => error instanceof DriverError && error.status === status;
44
52
  /** A request to a Worker, with a timeout: a redirect is no answer of the Worker's, and would carry the token elsewhere. */
45
53
  const sender = (timeoutMs) => (url, init) => fetch(url, { ...init, redirect: "manual", signal: AbortSignal.timeout(timeoutMs) });
@@ -104,12 +112,33 @@ function accountApi(timeoutMs, subdomains) {
104
112
  // which the SDK's type does not have yet.
105
113
  const form = new FormData();
106
114
  form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" }), "metadata.json");
107
- for (const { name, content } of modules) {
108
- form.append(name, new Blob([content], { type: "application/javascript+module" }), name);
115
+ for (const { name, content, type = "esm" } of modules) {
116
+ form.append(name, new Blob([content], { type: MODULE_TYPES[type] }), name);
109
117
  }
110
118
  await cf.put(`/accounts/${account_id}/workers/scripts/${script}`, { body: form });
111
119
  });
112
120
  },
121
+ async assetsSession(script, manifest) {
122
+ const { jwt, buckets } = await calling(`POST workers/scripts/${script}/assets-upload-session`, (cf) => cf.workers.scripts.assets.upload.create(script, { account_id, manifest }));
123
+ if (!jwt)
124
+ throw refused(`${script}: the assets upload session answered no jwt`);
125
+ return { jwt, buckets: buckets ?? [] };
126
+ },
127
+ async uploadAssets(jwt, files) {
128
+ // One part per asset, named by its hash, its base64 the content and its type the one it is
129
+ // served with, as the API reference's example sends them; the session's jwt, not the
130
+ // account's token, authorizes it.
131
+ const form = new FormData();
132
+ for (const { hash, base64, contentType } of files) {
133
+ form.append(hash, new File([base64], hash, { type: contentType }), hash);
134
+ }
135
+ const answer = await calling("POST workers/assets/upload", (cf) => cf.post(`/accounts/${account_id}/workers/assets/upload`, {
136
+ query: { base64: true },
137
+ body: form,
138
+ headers: { authorization: `Bearer ${jwt}` },
139
+ }));
140
+ return answer.result?.jwt ?? undefined;
141
+ },
113
142
  async enableSubdomain(script) {
114
143
  await calling(`POST workers/scripts/${script}/subdomain`, (cf) => cf.workers.scripts.subdomain.create(script, { account_id, enabled: true }));
115
144
  },
@@ -1 +1 @@
1
- {"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAsB,YAAY,EAAoB,OAAO,EAAmB,MAAM,UAAU,CAAC;AAClH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAiB/D,iEAAiE;AACjE,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,oBAAoB,EAAE,CAAC;SACpB,MAAM,EAAE;SACR,QAAQ,CACP,wJAAwJ,CACzJ;IACH,qBAAqB,EAAE,CAAC;SACrB,MAAM,EAAE;SACR,KAAK,CAAC,gBAAgB,EAAE,wCAAwC,CAAC;SACjE,QAAQ,CAAC,+CAA+C,CAAC;CAC7D,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAGvC;;;GAGG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,EAAE,QAAQ,EAAE,yBAAyB,EAAO,EAAE,SAAiB,EAAE,KAAc;IAC5G,IAAI,KAAK,YAAY,yBAAyB,EAAE,CAAC;QAC/C,OAAO,IAAI,WAAW,CAAC,eAAe,IAAI,iBAAiB,SAAS,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,IAAI,KAAK,YAAY,QAAQ,IAAI,OAAO,KAAK,CAAC,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EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;IAC3C,OAAO,YAAY,CACjB,aAAa,EACb;QACE,SAAS,EAAE,YAAY,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;QACxD,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;QAC7B,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC;KACzB,EACD,EAAE,GAAG,EAAE,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { DriverError } from "@sanoma-ai/workflows";
2
+ /** The driver's own refusal, before or instead of a call: never retried. */
3
+ export declare const refused: (message: string, vendorCode?: string) => DriverError;
package/dist/errors.js ADDED
@@ -0,0 +1,4 @@
1
+ import { DriverError } from "@sanoma-ai/workflows";
2
+ /** The driver's own refusal, before or instead of a call: never retried. */
3
+ export const refused = (message, vendorCode) => new DriverError(`cloudflare: ${message}`, { retryable: false, ...(vendorCode && { vendorCode }) });
4
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,UAAmB,EAAE,EAAE,CAC9D,IAAI,WAAW,CAAC,eAAe,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,UAAU,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC"}
package/dist/fake.d.ts CHANGED
@@ -25,12 +25,21 @@ export interface FakeCloudflareOptions extends FakeOptions {
25
25
  }
26
26
  export interface FakeCloudflareState extends Record<string, unknown> {
27
27
  seq: number;
28
- /** The Workers, by script name: their bindings, a secret's without its text, and the images their object may start, by name. */
28
+ /**
29
+ * The Workers, by script name: their bindings, a secret's without its text, the images their
30
+ * object may start, by name, their entry and modules' names, and the assets their last upload
31
+ * redeemed, each path's hash.
32
+ */
29
33
  scripts: Record<string, {
30
34
  bindings: ReadBinding[];
31
35
  subdomain: boolean;
32
36
  images: Record<string, string>;
37
+ main_module?: string;
38
+ modules?: string[];
39
+ assets?: Record<string, string>;
33
40
  }>;
41
+ /** The account's assets, by hash: the type each was uploaded with (the content is not kept). */
42
+ assets: Record<string, string>;
34
43
  /** The container applications, by id. */
35
44
  applications: Record<string, Application & {
36
45
  name: string;
@@ -63,7 +72,10 @@ export interface FakeCloudflareState extends Record<string, unknown> {
63
72
  * An upload restarts the object over the new bindings and images, its container, storage and
64
73
  * alarm kept: a new image starts the container again at the next request, as the object finds its
65
74
  * label changed. `copyImage` pins its copy by a made-up digest, and `prepareImage` answers ready
66
- * for an image pinned in the account's registry. `stop(name)` stops a company's
75
+ * for an image pinned in the account's registry. An assets upload session asks for the hashes
76
+ * `state.assets` lacks, in one bucket, and an upload that redeems its completion jwt keeps each
77
+ * path's hash on the Worker (`state.scripts[…].assets`); the Worker's requests still go to its
78
+ * object, as the fake runs no sites bundle. `stop(name)` stops a company's
67
79
  * container as ten quiet minutes would, `fire()` rings every alarm now, `wakes()` lists the
68
80
  * `/wake`s the containers answered, `close()` (and `reset()`) stops everything.
69
81
  */
package/dist/fake.js CHANGED
@@ -198,6 +198,7 @@ function fakeObject(start, images, source, started) {
198
198
  get: async (key) => structuredClone(storage.get(key)),
199
199
  put: async (key, value) => void storage.set(key, structuredClone(value)),
200
200
  delete: async (key) => storage.delete(key),
201
+ getAlarm: async () => alarm?.at ?? null,
201
202
  async setAlarm(at) {
202
203
  disarm();
203
204
  alarm = { at };
@@ -214,6 +215,7 @@ function fakeObject(start, images, source, started) {
214
215
  instance = made;
215
216
  },
216
217
  fetch: (request) => active(() => instance.fetch(request)),
218
+ startNow: () => instance.startNow(),
217
219
  /** Stops its container, as Cloudflare does once the object is quiet; its storage and alarm stay. */
218
220
  stop: destroy,
219
221
  /** Rings its alarm now, whatever its time; resolves once it rang. */
@@ -247,7 +249,10 @@ function fakeObject(start, images, source, started) {
247
249
  * An upload restarts the object over the new bindings and images, its container, storage and
248
250
  * alarm kept: a new image starts the container again at the next request, as the object finds its
249
251
  * label changed. `copyImage` pins its copy by a made-up digest, and `prepareImage` answers ready
250
- * for an image pinned in the account's registry. `stop(name)` stops a company's
252
+ * for an image pinned in the account's registry. An assets upload session asks for the hashes
253
+ * `state.assets` lacks, in one bucket, and an upload that redeems its completion jwt keeps each
254
+ * path's hash on the Worker (`state.scripts[…].assets`); the Worker's requests still go to its
255
+ * object, as the fake runs no sites bundle. `stop(name)` stops a company's
251
256
  * container as ten quiet minutes would, `fire()` rings every alarm now, `wakes()` lists the
252
257
  * `/wake`s the containers answered, `close()` (and `reset()`) stops everything.
253
258
  */
@@ -258,6 +263,10 @@ export function fakeCloudflare(options = {}) {
258
263
  /** Each Worker's env: its bindings' text, the secrets' with it, which the state does not keep. */
259
264
  const envs = new Map();
260
265
  const started = [];
266
+ /** The open assets upload sessions, by jwt: the Worker's name, its manifest and the hashes still to upload. */
267
+ const sessions = new Map();
268
+ /** The completion jwts an upload may redeem: the Worker's name and its manifest, each path's hash. */
269
+ const completed = new Map();
261
270
  /** The request to the Worker named `script`, as workers.dev passes it on. */
262
271
  const dispatch = async (state, script, request) => {
263
272
  const env = envs.get(script);
@@ -303,9 +312,16 @@ export function fakeCloudflare(options = {}) {
303
312
  async bindings(script) {
304
313
  return structuredClone(state.scripts[script]?.bindings);
305
314
  },
306
- async upload(script, { modules, main_module, bindings, containers, migrations }) {
315
+ async upload(script, { modules, main_module, bindings, containers, migrations, assets }) {
307
316
  if (!modules.some((m) => m.name === main_module))
308
317
  throw fail(400, 10021, `no module named ${main_module}`);
318
+ const redeemed = assets && completed.get(assets.jwt);
319
+ if (assets && redeemed?.script !== script) {
320
+ throw fail(400, 10203, "the assets' completion jwt is not one this Worker's upload session gave");
321
+ }
322
+ if (bindings.some((b) => b.type === "assets") !== Boolean(assets)) {
323
+ throw fail(400, 10021, "an assets binding needs assets, and assets an assets binding");
324
+ }
309
325
  const runs = containers.find((c) => c.class_name === OBJECT_CLASS);
310
326
  if (!runs)
311
327
  throw fail(400, 10021, `${OBJECT_CLASS} is no container's: its object would have no ctx.container`);
@@ -321,10 +337,13 @@ export function fakeCloudflare(options = {}) {
321
337
  for (const binding of bindings) {
322
338
  if (binding.type === "durable_object_namespace") {
323
339
  env[binding.name] = {
324
- getByName: () => ({ fetch: (request) => objects.get(script).fetch(request) }),
340
+ getByName: () => ({
341
+ fetch: (request) => objects.get(script).fetch(request),
342
+ startNow: () => objects.get(script).startNow(),
343
+ }),
325
344
  };
326
345
  }
327
- else
346
+ else if (binding.type !== "assets")
328
347
  env[binding.name] = binding.text;
329
348
  }
330
349
  envs.set(script, env);
@@ -338,7 +357,12 @@ export function fakeCloudflare(options = {}) {
338
357
  : { type, name, ...("text" in rest && { text: rest.text }) }),
339
358
  subdomain: state.scripts[script]?.subdomain ?? false,
340
359
  images: { ...runs.images },
360
+ main_module,
361
+ modules: modules.map((m) => m.name),
362
+ ...(redeemed && { assets: { ...redeemed.manifest } }),
341
363
  };
364
+ if (assets)
365
+ completed.delete(assets.jwt);
342
366
  const object = objects.get(script) ??
343
367
  fakeObject(start, () => state.scripts[script]?.images ?? {}, (image) => appOf(script) && (state.images[image] ?? image), started);
344
368
  objects.set(script, object);
@@ -455,6 +479,35 @@ export function fakeCloudflare(options = {}) {
455
479
  state.dns[zone] = held;
456
480
  return structuredClone({ patches: patched, posts: posted });
457
481
  },
482
+ async assetsSession(script, manifest) {
483
+ const jwt = `session-${++state.seq}`;
484
+ // A state saved before the fake kept assets has none.
485
+ state.assets ??= {};
486
+ const hashes = Object.fromEntries(Object.entries(manifest).map(([path, { hash }]) => [path, hash]));
487
+ const missing = new Set(Object.values(hashes).filter((hash) => !(hash in state.assets)));
488
+ if (!missing.size) {
489
+ completed.set(jwt, { script, manifest: hashes });
490
+ return { jwt, buckets: [] };
491
+ }
492
+ sessions.set(jwt, { script, manifest: hashes, missing });
493
+ return { jwt, buckets: [[...missing]] };
494
+ },
495
+ async uploadAssets(jwt, files) {
496
+ const session = sessions.get(jwt);
497
+ if (!session)
498
+ throw fail(401, 10000, "workers/assets/upload: the jwt is no open upload session's");
499
+ for (const { hash, contentType } of files) {
500
+ if (!session.missing.delete(hash))
501
+ throw fail(400, 10203, `workers/assets/upload: ${hash} is not asked for`);
502
+ (state.assets ??= {})[hash] = contentType;
503
+ }
504
+ if (session.missing.size)
505
+ return undefined;
506
+ sessions.delete(jwt);
507
+ const completion = `completion-${++state.seq}`;
508
+ completed.set(completion, { script: session.script, manifest: session.manifest });
509
+ return completion;
510
+ },
458
511
  async send(url, init) {
459
512
  const script = scriptAt(url);
460
513
  if (!script)
@@ -467,6 +520,7 @@ export function fakeCloudflare(options = {}) {
467
520
  initial: () => ({
468
521
  seq: 0,
469
522
  scripts: {},
523
+ assets: {},
470
524
  applications: {},
471
525
  images: {},
472
526
  zones: {},
@@ -485,6 +539,8 @@ export function fakeCloudflare(options = {}) {
485
539
  await object.remove();
486
540
  objects.clear();
487
541
  envs.clear();
542
+ sessions.clear();
543
+ completed.clear();
488
544
  for (const { server } of servers.values()) {
489
545
  server.closeAllConnections();
490
546
  await new Promise((done) => server.close(() => done()));