@sanoma-ai/connector-cloudflare 0.6.4 → 0.6.5

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
@@ -82,13 +82,13 @@ The logo is Cloudflare's cloud from [Simple Icons](https://simpleicons.org/?q=cl
82
82
 
83
83
  ## The Worker
84
84
 
85
- The Worker script is the company's app. The package ships what it uploads, `worker/`: `index.js`, the entry, and `instance.js`, its logic with no imports (typed by `instance.d.ts`), which the fake runs in Node so both kits check the code Cloudflare runs. Beside them goes the app bundle under `app/` ([The deploy](#the-deploy)), or, until a create's first bundle, `no-app.js` in its place, which answers 503 "being set up". The entry's fetch:
85
+ The Worker script is the company's app. The package ships what it uploads, `worker/`: `index.js`, the entry, and `instance.js`, its logic with no imports (typed by `instance.d.ts`), which the fake runs in Node so both kits check the code Cloudflare runs. Beside them goes the app bundle under `app/` ([The deploy](#the-deploy)), or, on a Worker that never served an app (a create's uploads before its first bundle), `no-app.js` in its place, which answers 503 "being set up": nobody was served there yet. The entry's fetch:
86
86
 
87
87
  - sends `/__sanoma/health`, `/__sanoma/wake` and `/__sanoma/app-bundle` to the Worker's one Durable Object, `SanomaInstance` (`DurableObject` from `cloudflare:workers`);
88
88
  - answers `GET /wake`, the Host contract's wake, by having the object start the container now (204);
89
89
  - hands every other request to the app bundle's `fetch(request, env, ctx, host)`, imported on the first request, with `x-sanoma-client-ip` set from `cf-connecting-ip` over any copy the client sent, and `host.startNow()` the object's, over RPC (the app's call when it queues a run). A page, an API call, a webhook and a sign-in are all the app's, on the Worker, so a visitor never waits for a cold container (forty seconds to minutes), and the app reaches the company's database through [Hyperdrive](#the-database).
90
90
 
91
- The object runs the company's worker in its container and never sees a visitor's request. It:
91
+ The object runs the company's worker in its container and never sees a visitor's request. It marks each of its answers with `x-sanoma-deployment`, the id of the Worker version that answered (its `CF_VERSION_METADATA` binding's, the `deployment_id` an upload answers with), so a deploy tells the version it uploaded from an earlier one still answering, and the object's answers from anyone else's. It:
92
92
 
93
93
  - starts the container 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, and waits for its `/healthz` (up to ten minutes, the clone and install included). Container labels hold the two non-secret revisions, an image hash and a hash of `SANOMA_DOMAINS`; secret values never enter them. A container running with other labels is drained: sent SIGTERM, so its worker stops dequeuing and exits, given thirty seconds, then destroyed if it still runs, and started again at the Worker's labels;
94
94
  - answers `GET /__sanoma/health` with the source revision, configuration revision when set, and whether the container runs and answered, without starting it. With `?start=1` and `Authorization: Bearer <SANOMA_WAKEUP_TOKEN>`, it starts the container at the Worker's revisions, answering 202 until it answers, then 200;
@@ -105,11 +105,15 @@ The application is of the `durable_object` scheduling policy (public beta, the o
105
105
 
106
106
  A create, in Wrangler's order, copies and pins the image and waits until Cloudflare prepared it ([The image](#the-image)), makes or updates the [database's config](#the-database), and, the first time, uploads the Worker without an app (`no-app.js`) with the object's migration (`new_sqlite_classes`) and its class as a container's with that image (`containers: [{ name, class_name, images: { runtime } }]`), turns its workers.dev URL on, makes the application for the object's namespace (`{ name, scheduling_policy: "durable_object", durable_objects: { namespace_id } }`), and uploads that Worker once more: the object learns which application backs its namespace only from a deployment made after the application exists (without it every start answers "There is no container application assigned to this Durable Object namespace", found on the first real deploy, 2026-10-29). Then every create and update deploys in three steps:
107
107
 
108
- 1. **The bundle.** `GET /__sanoma/app-bundle?revision=R` on the workers.dev URL with the instance token, asked every poll: the object starts the container at the Worker's current revision if it is stopped (202, unmarked), and the worker there checks out `R` and builds the app bundle for `workerd` (`@sanoma-ai/app`'s `AppBundle`: its modules, its assets, its compatibility date and flags), answering 202 until it is built, then 200 with it, each answer marked `x-sanoma-app-bundle`. The bundle has its own budget, `startTimeoutMs` (ten minutes): still none after it fails the apply retryably, "still building the app bundle at R after 600 s", saying what the last ask saw. A marked answer other than 200 or 202 (a failed build, a revision the route refuses) is a refusal. A deployment that cannot build it, a 401 (the deployed Worker or its container holds another token), an `exit` (its worker ends at startup) or an unmarked 404 (a runtime without the route), is recovered once: the Worker at R without its app (`no-app.js`) is uploaded, so the object starts the container at R, and the bundle is asked of it, the app's pages saying it is being set up until step 2; the same answer again is a refusal. Anything else (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL not routed yet) is asked again; one ask may take the whole budget, as a bundle is large. Its assets (the client build and the prerendered pages) then 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, one after another, to `POST …/workers/assets/upload?base64=true` with the session's jwt).
109
- 2. **One upload.** The domains no longer declared are detached, then the Worker is uploaded once with everything: `index.js`, `instance.js` and the bundle's modules under `app/`, its compatibility date and flags, the bindings (the declared ones, the namespace, `DATABASE` as Hyperdrive, `ASSETS`) and `assets: { jwt, config }` (`run_worker_first: ["/*", "!/assets/*"]`, the client build straight from the assets; `html_handling` and `not_found_handling` `none`). From here visitors get the new app; the container is still the old revision's. Then the missing domains are attached.
110
- 3. **The restart.** `GET /__sanoma/health?start=1` with the token, asked every poll until the object answers 200 at `R` and the configuration revision: the object drains the old container (SIGTERM, thirty seconds, then destroyed) and starts one at `R`. Its own budget, the same `startTimeoutMs`: still not after it fails the apply retryably, "still starting at R after 600 s". The step is idempotent: the next apply plans none, and an explicit update whose plan is none runs it alone, uploading nothing.
108
+ 1. **The bundle.** `GET /__sanoma/app-bundle?revision=R` on the workers.dev URL with the instance token, asked every poll: the object starts the container if it is stopped (202, unmarked), and the worker there checks out `R` and builds the app bundle for `workerd` (`@sanoma-ai/app`'s `AppBundle`: its modules, its assets, its compatibility date and flags), answering 202 until it is built, then 200 with it, each answer marked `x-sanoma-app-bundle`. It is asked of the Worker deployed, whose container still runs R-1, when that runs the declared image; a deployment that cannot build it is stale: a 401 (the deployed Worker or its container holds another token), an `exit` (its worker ends at startup) or an unmarked 404 (a Worker without the route). A new image, a stale deployment and a create have R's own container build it instead: the Worker at R is uploaded first (R's bindings and image, this package's `index.js` and `instance.js`), serving visitors what they are served now: the app deployed, its modules read back (`GET …/scripts/{name}/content/v2`), its compatibility date and flags and its assets kept (`keep_assets`), untagged; a Worker that never served an app gets `no-app.js`. Its object starts the container at R, and once that version is [live](#live-before-asked) the bundle is asked of it: an answer without its version's id is an earlier version's, asked again whatever its status, and its own `exit` (R's worker ends at startup) is a refusal. A marked answer other than 200 or 202 (a failed build, a revision the route refuses) is a refusal. Anything else (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL not routed yet) is asked again; one ask may take the whole budget, as a bundle is large. The bundle has its own budget, `startTimeoutMs` (ten minutes): still none after it fails the apply retryably, "still building the app bundle at R after 600 s", saying what the last ask saw. Its assets (the client build and the prerendered pages) then 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, one after another, to `POST …/workers/assets/upload?base64=true` with the session's jwt).
109
+ 2. **One upload.** The Worker is uploaded once with everything: `index.js`, `instance.js` and the bundle's modules under `app/`, its compatibility date and flags, the bindings (the declared ones, the namespace, `CF_VERSION_METADATA`, `DATABASE` as Hyperdrive, `ASSETS`), `assets: { jwt, config }` (`run_worker_first: ["/*", "!/assets/*"]`, the client build straight from the assets; `html_handling` and `not_found_handling` `none`) and its version tagged with `R` (`annotations: { "workers/tag": R }`). From here visitors get the new app. Then the missing domains are attached, and the upload is waited for until it is [live](#live-before-asked).
110
+ 3. **The restart.** `GET /__sanoma/health?start=1` with the token, asked every poll until the object answers 200 at `R` and the configuration revision: the object drains a container at another revision or image (SIGTERM, thirty seconds, then destroyed) and starts one at `R`; one R's build started already is kept. Its own budget, the same `startTimeoutMs`: still not after it fails the apply retryably, "still starting at R after 600 s". The step is idempotent: the next apply plans none, and an explicit update whose plan is none runs it alone, uploading nothing.
111
111
 
112
- No step answers a visitor 503 (but a recovered deployment's, above): the old app answers until the upload, the new one after it, and neither needs the container. A built-in workflow's runs on R-1 carry to R when its code is unchanged (`builtInCode` in `@sanoma-ai/workflows`), so the restart strands none of them. 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, the Worker with its object's storage, then the database's config.
112
+ ### Live before asked
113
+
114
+ An upload takes a while to reach every Cloudflare location, and until then the version before answers (on a new Worker, workers.dev's 404). After its last upload before a step asks the object, a deploy asks `GET /__sanoma/health`, without `start` so an earlier version starts nothing, every poll until the object answers with the uploaded version's id in `x-sanoma-deployment`, within the step's `startTimeoutMs`: any other answer, a 401, a 404 or a 503 among them, is "not yet", never "stale". The step's own asks then count only that version's answers.
115
+
116
+ No step answers a visitor 503 or an error: the app deployed answers until the upload of the new one, while R's container builds it too, and the new one after it, and neither needs the container; only a Worker that never served an app answers `no-app.js`. A domain declared before and no longer is detached before the first upload of R's bindings, while they still record it, and a missing one attached once the upload with the app records it: whatever fails in between, none is left attached and unrecorded. A plan compares the version's tag with the revision, so a deploy that ended between its two uploads (the app deployed still served under R's bindings, untagged) plans an update, and one whose version was not tagged (a deploy before tags) plans one once. A built-in workflow's runs on R-1 carry to R when its code is unchanged (`builtInCode` in `@sanoma-ai/workflows`), so the restart strands none of them. 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, the Worker with its object's storage, then the database's config.
113
117
 
114
118
  ## The database
115
119
 
@@ -168,9 +172,9 @@ export const mailDns = cloudflare.records({ zone: "sanoma.work", name: "resend",
168
172
 
169
173
  `@sanoma-ai/connector-cloudflare/driver` calls Cloudflare through its official SDK, [`cloudflare`](https://www.npmjs.com/package/cloudflare) (Stainless), with its own retries off (the runtime retries what is retryable), and calls the company's Worker with `fetch`. The `cloudflare` connector the package root exports carries it and its fake (`withSetup` from `@sanoma-ai/workflows`), so a config names the connector alone and workflows never import the driver (the lint refuses that).
170
174
 
171
- `./driver` (`cloudflareDriver`; `cloudflareDriver({ timeoutMs, startTimeoutMs, pollMs })`: 30 s a request, ten minutes for each of the deploy's two waits, the bundle and the restart, two seconds between tries; each request of the image's copy may take ten minutes) and `./fake` (`fakeCloudflare`) are internal entries, for tests.
175
+ `./driver` (`cloudflareDriver`; `cloudflareDriver({ timeoutMs, startTimeoutMs, pollMs })`: 30 s a request, ten minutes for each of the deploy's waits (an upload live, the bundle, the restart), two seconds between tries; each request of the image's copy may take ten minutes) and `./fake` (`fakeCloudflare`) are internal entries, for tests.
172
176
 
173
- 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 that serves no app yet (no `DATABASE` binding: a create cut off before its upload). The requests are made one after another, in the order the fixtures hold.
177
+ 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 whose version is not tagged with its revision (`workers/tag`: a create cut off before its upload with the app, a deploy cut off between its two uploads, or a Worker deployed before tags, once). The requests are made one after another, in the order the fixtures hold.
174
178
 
175
179
  ### Environment
176
180
 
@@ -229,7 +233,7 @@ The connector carries steps for [scenarios](https://github.com/Sanoma-AI/sanoma/
229
233
 
230
234
  ## Testing
231
235
 
232
- `@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`, `modules` and `compatibility_flags`). Its Hyperdrive configs are in `state.hyperdrives`, their passwords left out, and its `DATABASE` binding's `connectionString` is the direct URL. Its Workers run the package's own `serve` over the upload's modules, written to a folder and `app/index.js` imported from there; the bundle the container's worker answers is `fakeCloudflare({ bundle })`'s, by default `stubAppBundle`, a plain ES module that answers pages and `/healthz` and serves `/assets/`, since the real bundle is built for `workerd` (`nodejs_compat`, WebAssembly) and Node cannot import it.
236
+ `@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 answers with its version's id (its object's `CF_VERSION_METADATA.id`), and is live at once, or after `fakeCloudflare({ propagation: N })` more requests to the version before (workers.dev's 404 for a new Worker), as Cloudflare's takes a while to reach every location; it then 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 settings and content give the latest upload back (its bindings, compatibility date and flags, version tag and modules), and an upload with `keep_assets` serves the assets of the version before. 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`, `modules`, compatibility date and flags and `tag`). Its Hyperdrive configs are in `state.hyperdrives`, their passwords left out, and its `DATABASE` binding's `connectionString` is the direct URL. Its Workers run the package's own `serve` over the upload's modules, written to a folder and `app/index.js` imported from there; the bundle the container's worker answers is `fakeCloudflare({ bundle })`'s, by default `stubAppBundle`, a plain ES module that answers pages and `/healthz` and serves `/assets/`, since the real bundle is built for `workerd` (`nodejs_compat`, WebAssembly) and Node cannot import it.
233
237
 
234
238
  ```ts
235
239
  import { fakeCloudflare } from "@sanoma-ai/connector-cloudflare/fake";
package/dist/deploy.d.ts CHANGED
@@ -4,6 +4,8 @@ import type { CloudflareApi, ContainerOptions } from "./ops.ts";
4
4
  export declare const MAIN_MODULE = "index.js";
5
5
  /** The Durable Object class the Worker exports, which the container application runs behind. */
6
6
  export declare const OBJECT_CLASS = "SanomaInstance";
7
+ /** Where the app bundle's modules go in the upload: the entry imports `app/index.js`. */
8
+ export declare const APP = "app/";
7
9
  /** One module of the Worker: its name in the upload, its source, and its kind (an ES module unless it says). */
8
10
  export interface WorkerModule {
9
11
  name: string;
@@ -41,24 +43,34 @@ export declare function waitFor<T>(doing: string, { startTimeoutMs, pollMs }: Po
41
43
  } | {
42
44
  last: string;
43
45
  }>): Promise<T>;
44
- /**
45
- * The app bundle at `revision`, asked of the Worker at `url` with the instance token until it
46
- * gives it: the object starts its container when it is stopped, and both it and the worker answer
47
- * 202 meanwhile. A failed build or a revision the route refuses is a refusal. A deployment that
48
- * cannot build it is `{ stale }`, why: a token refused (the deployed Worker or its container holds
49
- * another), a container that ended, or, from an earlier deployment (`earlier`), a 404 the route
50
- * did not mark (a runtime without it). Any other answer (no answer, an error of Cloudflare's, a
51
- * body cut off, a workers.dev URL not routed yet) is asked again. Still none
52
- * after `startTimeoutMs` is a retryable `DriverError` that says what the last ask saw. One ask
53
- * may take the whole budget: a bundle is large.
54
- */
55
- export declare function appBundle(cf: CloudflareApi, { script, url, token, revision, earlier, }: {
46
+ interface BundleAsk {
56
47
  script: string;
57
48
  url: string;
58
49
  token: string;
59
50
  revision: string;
60
- earlier: boolean;
61
- }, polling: Polling): Promise<AppBundle | {
51
+ /**
52
+ * The id of the Worker version this deploy uploaded, whose answers alone count; undefined to
53
+ * ask whichever version is deployed, which may be `{ stale }`.
54
+ */
55
+ deployment?: string;
56
+ }
57
+ /**
58
+ * The app bundle at `revision`, asked of the Worker at `url` with the instance token until it
59
+ * gives it: the object starts its container when it is stopped, and both it and the worker answer
60
+ * 202 meanwhile. A failed build, a revision the route refuses or, from the version this deploy
61
+ * uploaded, a container that ended is a refusal. Asked of whichever version is deployed, one that
62
+ * cannot build it is `{ stale }`, why: a token refused (the Worker or its container holds another),
63
+ * a container that ended, or a 404 the route did not mark (a Worker without it). Asked of the
64
+ * version uploaded (`deployment`), an answer without its deployment is an earlier version's, still
65
+ * answering while the upload reaches every location: asked again, whatever its status. Any other
66
+ * answer (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL not routed yet) is
67
+ * asked again. Still none after `startTimeoutMs` is a retryable `DriverError` that says what the
68
+ * last ask saw. One ask may take the whole budget: a bundle is large.
69
+ */
70
+ export declare function appBundle(cf: CloudflareApi, ask: BundleAsk & {
71
+ deployment: string;
72
+ }, polling: Polling): Promise<AppBundle>;
73
+ export declare function appBundle(cf: CloudflareApi, ask: BundleAsk, polling: Polling): Promise<AppBundle | {
62
74
  stale: string;
63
75
  }>;
64
76
  /** Puts the bundle's assets in through an upload session for `script`'s next upload: the completion jwt that upload redeems. */
package/dist/deploy.js CHANGED
@@ -4,6 +4,7 @@ import { DriverError, errorMessage } from "@sanoma-ai/workflows";
4
4
  import { APP_BUNDLE_HEADER, APP_BUNDLE_PATH } from "@sanoma-ai/workflows/shared";
5
5
  import mime from "mime";
6
6
  import { refused } from "./errors.js";
7
+ import { DEPLOYMENT_HEADER } from "../worker/instance.js";
7
8
  // What a deploy uploads as the company's Worker script: the package's `worker/` (the entry and the
8
9
  // object's code) and the app bundle under `app/`, which the worker at the new revision's checkout
9
10
  // builds and the object passes on (`appBundle`), its assets through an upload session.
@@ -13,7 +14,7 @@ export const MAIN_MODULE = "index.js";
13
14
  /** The Durable Object class the Worker exports, which the container application runs behind. */
14
15
  export const OBJECT_CLASS = "SanomaInstance";
15
16
  /** Where the app bundle's modules go in the upload: the entry imports `app/index.js`. */
16
- const APP = "app/";
17
+ export const APP = "app/";
17
18
  let modules;
18
19
  const read = (file, name = file) => readFile(new URL(file, WORKER), "utf8").then((content) => ({ name, content }));
19
20
  /**
@@ -69,18 +70,7 @@ export async function waitFor(doing, { startTimeoutMs, pollMs }, ask) {
69
70
  await delay(pollMs);
70
71
  }
71
72
  }
72
- /**
73
- * The app bundle at `revision`, asked of the Worker at `url` with the instance token until it
74
- * gives it: the object starts its container when it is stopped, and both it and the worker answer
75
- * 202 meanwhile. A failed build or a revision the route refuses is a refusal. A deployment that
76
- * cannot build it is `{ stale }`, why: a token refused (the deployed Worker or its container holds
77
- * another), a container that ended, or, from an earlier deployment (`earlier`), a 404 the route
78
- * did not mark (a runtime without it). Any other answer (no answer, an error of Cloudflare's, a
79
- * body cut off, a workers.dev URL not routed yet) is asked again. Still none
80
- * after `startTimeoutMs` is a retryable `DriverError` that says what the last ask saw. One ask
81
- * may take the whole budget: a bundle is large.
82
- */
83
- export async function appBundle(cf, { script, url, token, revision, earlier, }, polling) {
73
+ export function appBundle(cf, { script, url, token, revision, deployment }, polling) {
84
74
  return waitFor(`${script}: still building the app bundle at ${revision}`, polling, async () => {
85
75
  try {
86
76
  const res = await cf.send(`${url}${APP_BUNDLE_PATH}?revision=${encodeURIComponent(revision)}`, {
@@ -89,16 +79,22 @@ export async function appBundle(cf, { script, url, token, revision, earlier, },
89
79
  signal: AbortSignal.timeout(polling.startTimeoutMs),
90
80
  });
91
81
  const route = res.headers.has(APP_BUNDLE_HEADER);
82
+ const by = res.headers.get(DEPLOYMENT_HEADER);
83
+ if (deployment !== undefined && by !== deployment) {
84
+ await res.body?.cancel();
85
+ return { last: `an earlier version (${by || "unmarked"}) answered ${res.status}` };
86
+ }
92
87
  // Undefined when it is none (a body cut off where the JSON is).
93
88
  const body = (await res.json().catch(() => undefined));
94
89
  if (route && res.status === 200 && body !== undefined)
95
90
  return { value: body };
96
91
  const said = typeof body?.error === "string" ? body.error : `${APP_BUNDLE_PATH} answered ${res.status}`;
97
- if (res.status === 401 || typeof body?.exit === "string" || (earlier && !route && res.status === 404)) {
92
+ const exit = typeof body?.exit === "string";
93
+ if (deployment === undefined && (res.status === 401 || exit || (!route && res.status === 404))) {
98
94
  return { value: { stale: said } };
99
95
  }
100
- // The worker's own refusal: the build's failure, a revision it refuses.
101
- if (route && res.status !== 200 && res.status !== 202)
96
+ // The worker's own refusal (the build's failure, a revision it refuses), or the uploaded version's container ended.
97
+ if (exit || (route && res.status !== 200 && res.status !== 202))
102
98
  throw refused(`${script}: no app bundle at ${revision}: ${said}`);
103
99
  return {
104
100
  last: res.status === 202 ? (route ? "the worker is building it" : "its container is starting") : said,
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,6BAA6B,C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EAA8E,CAAC,CAAC;IACzG,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/dist/driver.d.ts CHANGED
@@ -2,8 +2,8 @@ export interface CloudflareDriverOptions {
2
2
  /** How long one request may take, in milliseconds. Default 30 000. */
3
3
  timeoutMs?: number;
4
4
  /**
5
- * How long a deploy waits for the app bundle at its revision, and then again for the container
6
- * restarted at it. Default 10 minutes each: a cold start clones and installs, and a bundle is a
5
+ * How long a deploy waits for each upload to be live, for the app bundle at its revision, and
6
+ * then again for the container restarted at it. Default 10 minutes each: a cold start clones and installs, and a bundle is a
7
7
  * build of the app.
8
8
  */
9
9
  startTimeoutMs?: number;
package/dist/driver.js CHANGED
@@ -2,7 +2,7 @@ import { defineDriver, DriverError, retryableStatus } from "@sanoma-ai/workflows
2
2
  import { z } from "zod";
3
3
  import { cloudflareOps, host } from "./connector.js";
4
4
  import { refused } from "./errors.js";
5
- import { alarmOps, containerOps } from "./ops.js";
5
+ import { alarmOps, containerOps, } from "./ops.js";
6
6
  import { recordsOps } from "./records.js";
7
7
  import { CLOUDFLARE_REGISTRY, copyImage } from "./registry.js";
8
8
  /** The environment variables the driver reads, on every call. */
@@ -48,6 +48,8 @@ const MODULE_TYPES = {
48
48
  text: "text/plain",
49
49
  data: "application/octet-stream",
50
50
  };
51
+ /** A module's kind from its part's type, as the content of a Worker gives it back. */
52
+ const TYPE_OF = new Map(Object.entries(MODULE_TYPES).map(([type, part]) => [part, type]));
51
53
  const isStatus = (error, status) => error instanceof DriverError && error.status === status;
52
54
  /** A request to a Worker, with a timeout: a redirect is no answer of the Worker's, and would carry the token elsewhere. */
53
55
  /** `fetch` within `timeoutMs`, unless the caller gives its own signal (a large body's). */
@@ -100,12 +102,28 @@ function accountApi(timeoutMs, subdomains) {
100
102
  }
101
103
  return `https://${script}.${await subdomain}.workers.dev`;
102
104
  },
103
- bindings: (script) => found(`GET workers/scripts/${script}/settings`, async (cf) => {
105
+ settings: (script) => found(`GET workers/scripts/${script}/settings`, async (cf) => {
104
106
  const settings = await cf.workers.scripts.scriptAndVersionSettings.get(script, { account_id });
105
- return (settings.bindings ?? []);
107
+ return { ...settings, bindings: (settings.bindings ?? []) };
106
108
  }),
109
+ async content(script) {
110
+ // One part per module, named after it and typed as an upload types it, as Wrangler reads a
111
+ // Worker back (its `init --from-dash`).
112
+ const form = await calling(`GET workers/scripts/${script}/content/v2`, async (cf) => (await cf.workers.scripts.content.get(script, { account_id })).formData());
113
+ const modules = [];
114
+ for (const [name, part] of form) {
115
+ // A part without a file is a module whose type is unknown: refused, not dropped from the app.
116
+ if (typeof part === "string")
117
+ throw refused(`${script}: its module ${name} came back without its type`);
118
+ const type = TYPE_OF.get(part.type.split(";")[0].trim());
119
+ if (!type)
120
+ throw refused(`${script}: its module ${name} is of a type an upload does not make: ${part.type}`);
121
+ modules.push({ name, type, content: new Uint8Array(await part.arrayBuffer()) });
122
+ }
123
+ return modules;
124
+ },
107
125
  async upload(script, { modules, ...metadata }) {
108
- await calling(`PUT workers/scripts/${script}`, async (cf) => {
126
+ const answer = await calling(`PUT workers/scripts/${script}`, async (cf) => {
109
127
  // The form as Cloudflare reads it (and Wrangler sends it): one part `metadata`, the JSON, and
110
128
  // one part per module, named after it. The SDK's `workers.scripts.update` flattens the
111
129
  // metadata into `metadata[main_module]` parts instead, which Cloudflare refuses ("Could not
@@ -116,8 +134,14 @@ function accountApi(timeoutMs, subdomains) {
116
134
  for (const { name, content, type = "esm" } of modules) {
117
135
  form.append(name, new Blob([content], { type: MODULE_TYPES[type] }), name);
118
136
  }
119
- await cf.put(`/accounts/${account_id}/workers/scripts/${script}`, { body: form });
137
+ return (await cf.put(`/accounts/${account_id}/workers/scripts/${script}`, { body: form }));
120
138
  });
139
+ // The version's id, which Cloudflare names `deployment_id` and may give without its hyphens
140
+ // (as Wrangler reads it); the object's `CF_VERSION_METADATA` has them.
141
+ const id = answer.result?.deployment_id;
142
+ if (!id)
143
+ throw refused(`${script}: its upload answered no version id`);
144
+ return id.includes("-") ? id : id.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
121
145
  },
122
146
  async assetsSession(script, manifest) {
123
147
  const { jwt, buckets } = await calling(`POST workers/scripts/${script}/assets-upload-session`, (cf) => cf.workers.scripts.assets.upload.create(script, { account_id, manifest }));
@@ -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,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAsB,YAAY,EAAqC,MAAM,UAAU,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAqB/D,iEAAiE;AACjE,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,oBAAoB,EAAE,CAAC;SACpB,MAAM,EAAE;SACR,QAAQ,CACP,yKAAyK,CAC1K;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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AU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACpD,2DAA2D;IAC3D,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;IAC3C,OAAO,YAAY,CACjB,aAAa,EACb;QACE,IAAI,EAAE,YAAY,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC;QACzD,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"}
package/dist/fake.d.ts CHANGED
@@ -30,6 +30,12 @@ export interface FakeCloudflareOptions extends FakeOptions {
30
30
  bundle?: (revision: string) => AppBundle;
31
31
  /** The zones the account holds, by name. Default: every one asked for, as a sandbox's account holds its domains. */
32
32
  zones?: readonly string[];
33
+ /**
34
+ * How many requests to a Worker the version before an upload still answers once it is made (none
35
+ * for a new Worker: workers.dev's 404), as an upload takes a while to reach every location.
36
+ * Default 0: the next request runs it.
37
+ */
38
+ propagation?: number;
33
39
  }
34
40
  export interface FakeCloudflareState extends Record<string, unknown> {
35
41
  seq: number;
@@ -44,8 +50,11 @@ export interface FakeCloudflareState extends Record<string, unknown> {
44
50
  images: Record<string, string>;
45
51
  main_module?: string;
46
52
  modules?: string[];
53
+ compatibility_date?: string;
47
54
  compatibility_flags?: string[];
48
55
  assets?: Record<string, string>;
56
+ /** The latest version's tag (`annotations["workers/tag"]`). */
57
+ tag?: string;
49
58
  }>;
50
59
  /** The account's Hyperdrive configs, by id: each one's name and its origin, its password left out. */
51
60
  hyperdrives: Record<string, {
@@ -97,9 +106,12 @@ export declare function stubAppBundle(revision: string): AppBundle;
97
106
  * process: its container runs `start`'s runtime (the image and the revision label it was started
98
107
  * at, the Worker's text bindings as its environment), its port's `/__sanoma/app-bundle` answers
99
108
  * `bundle`'s as the runtime's route does, SIGTERM stops the runtime, its storage is in memory, and
100
- * its alarm rings on a timer, again after a throw. An upload restarts the object over the new
109
+ * its alarm rings on a timer, again after a throw. An upload answers once `propagation` more
110
+ * requests went to the version before (none: at once), and then restarts the object over the new
101
111
  * bindings and images, its container, storage and alarm kept: the object finds the labels changed
102
- * at the next start, and drains and replaces it. `copyImage` pins its copy by a made-up digest,
112
+ * at the next start, and drains and replaces it. `settings` and `content` give the latest upload
113
+ * back, its tag and its modules, and an upload that keeps its assets (`keep_assets`) serves the
114
+ * version before's. `copyImage` pins its copy by a made-up digest,
103
115
  * and `prepareImage` answers ready for an image pinned in the account's registry. An assets upload
104
116
  * session asks for the hashes `state.assets` lacks, in one bucket, and an upload that redeems its
105
117
  * completion jwt keeps each path's hash on the Worker (`state.scripts[…].assets`). `stop(name)`
package/dist/fake.js CHANGED
@@ -358,9 +358,12 @@ function fakeObject(start, bundle, images, source, started) {
358
358
  * process: its container runs `start`'s runtime (the image and the revision label it was started
359
359
  * at, the Worker's text bindings as its environment), its port's `/__sanoma/app-bundle` answers
360
360
  * `bundle`'s as the runtime's route does, SIGTERM stops the runtime, its storage is in memory, and
361
- * its alarm rings on a timer, again after a throw. An upload restarts the object over the new
361
+ * its alarm rings on a timer, again after a throw. An upload answers once `propagation` more
362
+ * requests went to the version before (none: at once), and then restarts the object over the new
362
363
  * bindings and images, its container, storage and alarm kept: the object finds the labels changed
363
- * at the next start, and drains and replaces it. `copyImage` pins its copy by a made-up digest,
364
+ * at the next start, and drains and replaces it. `settings` and `content` give the latest upload
365
+ * back, its tag and its modules, and an upload that keeps its assets (`keep_assets`) serves the
366
+ * version before's. `copyImage` pins its copy by a made-up digest,
364
367
  * and `prepareImage` answers ready for an image pinned in the account's registry. An assets upload
365
368
  * session asks for the hashes `state.assets` lacks, in one bucket, and an upload that redeems its
366
369
  * completion jwt keeps each path's hash on the Worker (`state.scripts[…].assets`). `stop(name)`
@@ -373,9 +376,11 @@ export function fakeCloudflare(options = {}) {
373
376
  const servers = new Map();
374
377
  const objects = new Map();
375
378
  /**
376
- * Each Worker as its last upload runs it: its env (its bindings' text, the secrets' with it,
377
- * which the state does not keep, its database, assets and object), and its app, the upload's
378
- * `app/index.js` imported from a folder of its own on the first request.
379
+ * Each Worker's versions: the one that answers (`live`), and the latest upload until it does
380
+ * (`next`, after `after` more requests). A version as it runs: its env (its bindings' text, the
381
+ * secrets' with it, which the state does not keep, its database, assets and object), its app,
382
+ * the upload's `app/index.js` imported from a folder of its own on the first request, the images
383
+ * its object may start, its assets (each path's hash) and its modules, as its content gives them.
379
384
  */
380
385
  const workers = new Map();
381
386
  /** Where each upload's modules are written, to be imported as files. */
@@ -389,12 +394,26 @@ export function fakeCloudflare(options = {}) {
389
394
  const sessions = new Map();
390
395
  /** The completion jwts an upload may redeem: the Worker's name and its manifest, each path's hash. */
391
396
  const completed = new Map();
392
- /** The asset of the Worker named `script` at the request's path, if its last upload has one. */
393
- const assetOf = (state, script, request) => {
394
- const hash = state.scripts[script]?.assets?.[new URL(request.url).pathname];
397
+ /** The asset at the request's path among `assets` (each path's hash), if it is one. */
398
+ const assetOf = (assets, request) => {
399
+ const hash = assets?.[new URL(request.url).pathname];
395
400
  const found = hash === undefined ? undefined : contents.get(hash);
396
401
  return found && new Response(found.content, { headers: { "content-type": found.contentType } });
397
402
  };
403
+ /** Makes the Worker's latest upload the version that answers: its object made again over its env, as a deploy restarts it. */
404
+ const promote = (script, versions) => {
405
+ const object = objects.get(script);
406
+ versions.live = versions.next;
407
+ versions.next = undefined;
408
+ object.restart(new Instance(object.ctx, versions.live.env));
409
+ };
410
+ /** The version that answers the Worker's next request: its latest upload's once that has waited its requests out. */
411
+ const answering = (script) => {
412
+ const versions = workers.get(script);
413
+ if (versions?.next && versions.after-- <= 0)
414
+ promote(script, versions);
415
+ return versions?.live;
416
+ };
398
417
  /**
399
418
  * The request to the Worker named `script`, as workers.dev passes it on: a path under
400
419
  * `/assets/` its assets have straight from them (`run_worker_first`), anything else to the
@@ -402,11 +421,11 @@ export function fakeCloudflare(options = {}) {
402
421
  * `cf-connecting-ip` set from the visitor's address.
403
422
  */
404
423
  const dispatch = async (state, script, request, visitor = "127.0.0.1") => {
405
- const worker = workers.get(script);
424
+ const worker = answering(script);
406
425
  if (!worker || !state.scripts[script]?.subdomain)
407
426
  return nothingHere();
408
427
  if (new URL(request.url).pathname.startsWith("/assets/")) {
409
- const asset = assetOf(state, script, request);
428
+ const asset = assetOf(worker.assets, request);
410
429
  if (asset)
411
430
  return asset;
412
431
  }
@@ -473,19 +492,34 @@ export function fakeCloudflare(options = {}) {
473
492
  const recordsOf = (zoneId) => state.dns[zoneNamed(zoneId)] ?? [];
474
493
  return {
475
494
  workerUrl: (script) => listenAt(state, script),
476
- async bindings(script) {
477
- return structuredClone(state.scripts[script]?.bindings);
495
+ async settings(script) {
496
+ const found = state.scripts[script];
497
+ return (found && {
498
+ bindings: structuredClone(found.bindings),
499
+ compatibility_date: found.compatibility_date,
500
+ compatibility_flags: [...(found.compatibility_flags ?? [])],
501
+ ...(found.tag !== undefined && { annotations: { "workers/tag": found.tag } }),
502
+ });
503
+ },
504
+ async content(script) {
505
+ const versions = workers.get(script);
506
+ const latest = versions?.next ?? versions?.live;
507
+ if (!latest)
508
+ throw fail(404, 10007, `workers/scripts/${script}: This Worker does not exist on your account.`);
509
+ return structuredClone(latest.modules);
478
510
  },
479
- async upload(script, { modules, main_module, bindings, containers, migrations, assets, compatibility_flags }) {
511
+ async upload(script, { modules, main_module, bindings, containers, migrations, assets, keep_assets, annotations, compatibility_date, compatibility_flags, }) {
480
512
  if (!modules.some((m) => m.name === main_module))
481
513
  throw fail(400, 10021, `no module named ${main_module}`);
482
514
  if (!modules.some((m) => m.name === "app/index.js"))
483
515
  throw fail(400, 10021, "no module named app/index.js");
484
- const redeemed = assets && completed.get(assets.jwt);
485
- if (assets && redeemed?.script !== script) {
516
+ const redeemed = assets?.jwt === undefined ? undefined : completed.get(assets.jwt);
517
+ if (assets?.jwt !== undefined && redeemed?.script !== script) {
486
518
  throw fail(400, 10203, "the assets' completion jwt is not one this Worker's upload session gave");
487
519
  }
488
- if (bindings.some((b) => b.type === "assets") !== Boolean(assets)) {
520
+ // The assets redeemed, else with `keep_assets` the version before's.
521
+ const manifest = redeemed?.manifest ?? (keep_assets ? state.scripts[script]?.assets : undefined);
522
+ if (bindings.some((b) => b.type === "assets") !== Boolean(manifest)) {
489
523
  throw fail(400, 10021, "an assets binding needs assets, and assets an assets binding");
490
524
  }
491
525
  const runs = containers.find((c) => c.class_name === OBJECT_CLASS);
@@ -499,6 +533,8 @@ export function fakeCloudflare(options = {}) {
499
533
  if (!known && !migrations?.new_sqlite_classes.includes(OBJECT_CLASS)) {
500
534
  throw fail(400, 10061, `Cannot create binding for class ${OBJECT_CLASS}: it is not a Durable Object yet`);
501
535
  }
536
+ // The version's id, as Cloudflare answers an upload and the version's metadata binding names it.
537
+ const version = `00000000-0000-4000-9000-${String(++state.seq).padStart(12, "0")}`;
502
538
  const env = {};
503
539
  for (const binding of bindings) {
504
540
  if (binding.type === "durable_object_namespace") {
@@ -516,15 +552,17 @@ export function fakeCloudflare(options = {}) {
516
552
  // The direct URL: Hyperdrive's pooled one is Cloudflare's own.
517
553
  env[binding.name] = { connectionString: url };
518
554
  }
555
+ else if (binding.type === "version_metadata") {
556
+ env[binding.name] = { id: version, tag: annotations?.["workers/tag"] ?? "", timestamp: "" };
557
+ }
519
558
  else if (binding.type === "assets") {
520
559
  env[binding.name] = {
521
- fetch: async (request) => assetOf(state, script, request) ?? new Response(null, { status: 404 }),
560
+ fetch: async (request) => assetOf(manifest, request) ?? new Response(null, { status: 404 }),
522
561
  };
523
562
  }
524
563
  else
525
564
  env[binding.name] = binding.text;
526
565
  }
527
- workers.set(script, { env, loadApp: written(modules) });
528
566
  // The namespace the first upload made, kept across uploads as Cloudflare keeps it.
529
567
  const namespace_id = state.scripts[script]?.bindings.find((b) => b.namespace_id)?.namespace_id ?? nextId();
530
568
  state.scripts[script] = {
@@ -537,15 +575,29 @@ export function fakeCloudflare(options = {}) {
537
575
  images: { ...runs.images },
538
576
  main_module,
539
577
  modules: modules.map((m) => m.name),
578
+ compatibility_date,
540
579
  ...(compatibility_flags.length > 0 && { compatibility_flags: [...compatibility_flags] }),
541
- ...(redeemed && { assets: { ...redeemed.manifest } }),
580
+ ...(manifest && { assets: { ...manifest } }),
581
+ ...(annotations && { tag: annotations["workers/tag"] }),
542
582
  };
543
- if (assets)
583
+ if (redeemed)
544
584
  completed.delete(assets.jwt);
545
- const object = objects.get(script) ??
546
- fakeObject(start, bundle, () => state.scripts[script]?.images ?? {}, (image) => appOf(script) && (state.images[image] ?? image), started);
547
- objects.set(script, object);
548
- object.restart(new Instance(object.ctx, env));
585
+ if (!objects.has(script)) {
586
+ objects.set(script, fakeObject(start, bundle, () => workers.get(script)?.live?.images ?? {}, (image) => appOf(script) && (state.images[image] ?? image), started));
587
+ }
588
+ const versions = workers.get(script) ?? { after: 0 };
589
+ versions.next = {
590
+ env,
591
+ loadApp: written(modules),
592
+ images: { ...runs.images },
593
+ ...(manifest && { assets: { ...manifest } }),
594
+ modules: structuredClone(modules),
595
+ };
596
+ versions.after = options.propagation ?? 0;
597
+ workers.set(script, versions);
598
+ if (!versions.after)
599
+ promote(script, versions);
600
+ return version;
549
601
  },
550
602
  async enableSubdomain(script) {
551
603
  const found = state.scripts[script];