diff --git a/README.md b/README.md index 483122e..e9125d8 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ writes. ## Status -Phase 2 is implemented in source. The repository contains the -`@pegma/scheduler` contracts, validated task registry, durable runner -(`createScheduler`), Memory Store and Azurite adversarial tests, and design -documentation. No package has been published. +Phase 3 is implemented in source. The repository contains +`@pegma/scheduler` (contracts, durable runner), `@pegma/scheduler-cloudflare` +(explicit Cron Trigger dispatch), Memory Store / Azurite / local D1 tests, and +design documentation. No package has been published. The first consumers are: @@ -23,12 +23,10 @@ The first consumers are: ## Packages -| Package | Status | Responsibility | -| ----------------------------- | --------------- | ------------------------------------------- | -| `@pegma/scheduler` | Phase 2 source | Contracts, durable task state, and runner | -| `@pegma/scheduler-cloudflare` | Planned Phase 3 | Thin explicit Cron Trigger dispatch adapter | - -Do not create the Cloudflare package directory until its implementation starts. +| Package | Status | Responsibility | +| ----------------------------- | -------------- | ------------------------------------------- | +| `@pegma/scheduler` | Phase 3 source | Contracts, durable task state, and runner | +| `@pegma/scheduler-cloudflare` | Phase 3 source | Thin explicit Cron Trigger dispatch adapter | ## Development @@ -37,6 +35,9 @@ npm ci npm run format:check npm run check npm test +# or separately: +npm run test:node +npm run test:d1 ``` See [docs/PROJECT_PLAN.md](docs/PROJECT_PLAN.md) for the delivery sequence. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index b1e2675..dddd96b 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -21,10 +21,10 @@ and business-safe storage transitions. `@pegma/scheduler` is runtime-neutral and takes an injected Storage Core `Store`, Spine `Clock`, and Spine `Logger` through `createScheduler`. -`@pegma/scheduler-cloudflare` is deferred until Phase 3. It will translate a -Cloudflare `ScheduledController` into the core invocation contract and route -`controller.cron` through an explicit host-supplied map. It will not own D1, -Wrangler configuration, or task discovery. +`@pegma/scheduler-cloudflare` translates a Cloudflare `ScheduledController` +into the core invocation contract and routes `controller.cron` through an +explicit host-supplied map. It does not own D1, Wrangler configuration, or +task discovery. Azure begins as a tested composition example. A package is justified only after repeated adapter behavior appears in a second Azure consumer. diff --git a/docs/CLOUDFLARE.md b/docs/CLOUDFLARE.md index 823da1d..4d49992 100644 --- a/docs/CLOUDFLARE.md +++ b/docs/CLOUDFLARE.md @@ -6,19 +6,35 @@ Cloudflare owns Cron Trigger delivery and the host owns `wrangler.jsonc`. Production cron expressions have five fields and one-minute resolution. A 30-second production cadence is therefore outside Cloudflare Cron Triggers. -The planned adapter receives a `ScheduledController` and dispatches its `cron` -value through a static host map. Multiple tasks may intentionally share one -cron expression; each retains independent durable state. +`@pegma/scheduler-cloudflare` receives a `ScheduledController` and dispatches +its `cron` value through a static host map. Multiple tasks may intentionally +share one cron expression; each retains independent durable state. ```ts -const routes = { - "* * * * *": ["health.probe-targets"], - "*/10 * * * *": ["github.sync-orgs"], -} as const; +import { createCloudflareSchedulerDispatch } from "@pegma/scheduler-cloudflare"; + +const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { + "* * * * *": ["health.probe-targets"], + "*/10 * * * *": ["github.sync-orgs"], + }, +}); + +export default { + async scheduled(controller, env, ctx) { + // waitUntil is registered inside the adapter when ctx is passed. + await dispatch.scheduled(controller, ctx); + }, +}; ``` The same expression must appear in Wrangler configuration. The adapter does -not mutate deployment configuration or discover it. +not mutate deployment configuration or discover it. Unmapped cron values fail +closed. + +`controller.scheduledTime` (Unix milliseconds) becomes the trusted +`scheduledFor` ISO timestamp for durable occurrence suppression. ## Local Docker @@ -44,10 +60,18 @@ survive restarts. Do not treat Memory Store as durability evidence. ## Test layers -1. Core tests invoke tasks directly against Memory Store. -2. Adapter tests construct scheduled controller inputs without a network. -3. Wrangler integration tests call `/__scheduled` against local D1. -4. A green Ops Hub fixture proves Docker volume and repeated trigger behavior. +1. Core tests invoke tasks directly against Memory Store (and Azurite). +2. Adapter unit tests construct scheduled controller inputs without a network. +3. Cloudflare Vitest pool tests run against real local D1 + (`packages/scheduler-cloudflare/src/fixture.d1.test.ts`). +4. A green Ops Hub fixture (Phase 4) proves Docker volume and repeated trigger + behavior. + +Run the D1 suite alone: + +```sh +npm run test:d1 +``` References: diff --git a/docs/PROJECT_PLAN.md b/docs/PROJECT_PLAN.md index d819290..5cef65f 100644 --- a/docs/PROJECT_PLAN.md +++ b/docs/PROJECT_PLAN.md @@ -2,9 +2,9 @@ ## Status -**Stage:** Phase 0 requirements validation, Phase 1 repository foundation, and -Phase 2 durable runner are complete in source. No package is published or -production-usable. +**Stage:** Phases 0–3 are complete in source (contracts, durable runner, and +Cloudflare Cron Trigger adapter with local D1 tests). No package is published +or production-usable. **Trigger:** Ops Hub and Support Desk independently need the same explicit, durable coordination boundary for recurring work. @@ -79,7 +79,7 @@ registrations and state fail closed, and the full local gate passes. **Exit criterion:** concurrency, crash, replay, stale-worker, and checkpoint tests pass against Memory Store and Azurite. -### Phase 3 — Cloudflare adapter and local story +### Phase 3 — Cloudflare adapter and local story (complete) - Implement `@pegma/scheduler-cloudflare` only when work begins. - Dispatch `ScheduledController.cron` through an explicit typed route map. diff --git a/docs/TESTING.md b/docs/TESTING.md index bcfddff..c9bf38b 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -50,11 +50,28 @@ checkpoint cycle, occurrence suppression, and concurrent claim fencing on a real Table Storage protocol endpoint. Vitest starts Azurite via `test/azurite.ts` for the full suite. +## Phase 3 Cloudflare adapter coverage + +Adapter unit tests cover: + +- cron route dispatch and multi-task routes; +- `scheduledTime` → `scheduledFor` conversion; +- `waitUntil` registration; +- unmapped cron fail-closed behavior; +- overlap suppression and checkpoint cycles through the adapter. + +Real local D1 tests (`npm run test:d1`) through +`@pegma/storage-cloudflare-d1` and the Cloudflare Workers Vitest pool cover: + +- a complete checkpoint cycle with occurrence suppression; +- durable state surviving a re-composed “restart”; +- concurrent claim fencing on the same task; +- `waitUntil` wiring on the execution context. + ## Adapter and consumer matrix Before publication, also run: -- real local Cloudflare D1 through Wrangler (Phase 3); - an Ops Hub health and GitHub-sync fixture (Phase 4); - Support Desk mail-send, reconciliation, terminal sweep, queue repair, and inactive-sweep fixtures (Phase 4). diff --git a/package-lock.json b/package-lock.json index 860c08d..d714eab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,10 @@ ], "devDependencies": { "@azure/data-tables": "^13.3.2", + "@cloudflare/vitest-pool-workers": "^0.18.8", + "@cloudflare/workers-types": "^5.20260731.1", "@pegma/storage-azure-tables": "^0.4.0", + "@pegma/storage-cloudflare-d1": "0.4.1", "@types/node": "^26.1.1", "azurite": "^3.36.0", "prettier": "^3.9.6", @@ -391,6 +394,193 @@ "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, + "node_modules/@cloudflare/kv-asset-handler": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz", + "integrity": "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@cloudflare/unenv-preset": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.1.tgz", + "integrity": "sha512-ECxObrMfyTl5bhQf/lZCXwo5G6xX9IAUo+nDMKK4SZ8m4Jvvxp52vilxyySSWh2YTZz8+HQ07qGH/2rEom1vDw==", + "dev": true, + "license": "MIT OR Apache-2.0", + "peerDependencies": { + "unenv": "2.0.0-rc.24", + "workerd": ">1.20260305.0 <2.0.0-0" + }, + "peerDependenciesMeta": { + "workerd": { + "optional": true + } + } + }, + "node_modules/@cloudflare/vitest-pool-workers": { + "version": "0.18.8", + "resolved": "https://registry.npmjs.org/@cloudflare/vitest-pool-workers/-/vitest-pool-workers-0.18.8.tgz", + "integrity": "sha512-O1kOMZqapidlezNFiBZ7Lbd+8mMEpkGmWwPj+nPLvOngxSL11lmWq7xl7vxyjDxbeD/7l22KqgvRGM7XFaYd9w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cjs-module-lexer": "1.2.3", + "esbuild": "0.28.1", + "miniflare": "4.20260722.0", + "wrangler": "4.114.0", + "zod": "3.25.76" + }, + "peerDependencies": { + "@vitest/runner": "^4.1.0", + "@vitest/snapshot": "^4.1.0", + "vitest": "^4.1.0" + } + }, + "node_modules/@cloudflare/vitest-pool-workers/node_modules/cjs-module-lexer": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cloudflare/vitest-pool-workers/node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cloudflare/vitest-pool-workers/node_modules/wrangler": { + "version": "4.114.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.114.0.tgz", + "integrity": "sha512-M65P25t5UHA1TIJfgZXDcj+YzVobgKdRguM2QPz0xnxLFuOcuE3ErgllDht0iaho7MS4o0g/Bb4YK2+GT+bibg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.5.0", + "@cloudflare/unenv-preset": "2.16.1", + "blake3-wasm": "2.1.5", + "esbuild": "0.28.1", + "miniflare": "4.20260722.0", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20260722.1" + }, + "bin": { + "cf-wrangler": "bin/cf-wrangler.js", + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=22.0.0" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^5.20260722.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20260722.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260722.1.tgz", + "integrity": "sha512-vZOP8vIS3NwnuaO+gz0FZ7kIGeiO3bZmxV35Ph9zOXKSREhDFlH7wQ7mkCdhW3O4jnXsew+XT7b+DNEI2CcJGQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20260722.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260722.1.tgz", + "integrity": "sha512-EmIQymihDq6WNdER4+LF8Qn80yqayBUpJ+tkOO7wmY8pmgfyXjIUFNXotl21AHovTeu2seR7HdVUgeN/BilCWw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20260722.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260722.1.tgz", + "integrity": "sha512-jvZ3k9fxcnEn04s80CgIYxQfpOyAiz/8qC42DP8EBa9tR27qWyg9wmm31zIobVlrgBZn/+8NfdP73avRGcQOjQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20260722.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260722.1.tgz", + "integrity": "sha512-BOSB55SMNdy+DA5uj2WirgiNanpHGis5PVvXH1wSfvjRKr4JGgWK+EZzxz0RFUo6QjjQQC/NimEzNZ7va7jmKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20260722.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260722.1.tgz", + "integrity": "sha512-sYM8YgUpKnRz2xjvdJLX1Ojzoi4MlA4gk8WTTExhGydjYB2UTs5NIbv0ZmpKgMoK9io3ixgmiW56ZnTbcWOdiA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workers-types": { + "version": "5.20260731.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-5.20260731.1.tgz", + "integrity": "sha512-ly+eua642FCR2nbQGi/OxqlVaJI3fNdyqK7G4u6jWCAZ4WYhOBvZWyf0M7s5zurWbNQW3YjelOxuKqR0zYK90w==", + "dev": true, + "license": "MIT OR Apache-2.0" + }, "node_modules/@colors/colors": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", @@ -401,50 +591,1101 @@ "node": ">=0.1.90" } }, - "node_modules/@dabh/diagnostics": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.8.tgz", - "integrity": "sha512-R4MSXTVnuMzGD7bzHdW2ZhhdPC/igELENcq5IjEverBvq5hn1SXCWcsi6eSsdWP0/Ur+SItRRjAktmdoX/8R/Q==", + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@dabh/diagnostics": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.8.tgz", + "integrity": "sha512-R4MSXTVnuMzGD7bzHdW2ZhhdPC/igELENcq5IjEverBvq5hn1SXCWcsi6eSsdWP0/Ur+SItRRjAktmdoX/8R/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@so-ric/colorspace": "^1.1.6", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } + }, + "node_modules/@emnapi/core": { + "version": "2.0.0-alpha.3", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-alpha.3.tgz", + "integrity": "sha512-AZypUeJ/yByuxyS7BlSNRDOMLMlROYtjYdIAuBmJssVz1UJDSeYxLrdizhXCFYhedC5bqd/ASy8EuNXbVVXp9g==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.0.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-alpha.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-alpha.3.tgz", + "integrity": "sha512-hFPAhMUjJD9BSyCANEISPOogeXC9Zo9ZQl7L6vKnaVsMkCtzznaW/naYypeyl0Gv5rYfWYsZbpixTMpjDJzQeA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.0.1.tgz", + "integrity": "sha512-9DsSk+o5NBX0CCJT8s0EROGSGxjR/tKu6aBTaVyq+SjAEQH4XcdcRxPBRzsBLizTTJ49MJjF+jgu3qnO9GLQcQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", + "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz", + "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz", + "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz", + "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz", + "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz", + "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz", + "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz", + "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz", + "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz", + "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz", + "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz", + "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz", + "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz", + "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz", + "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz", + "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz", + "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz", + "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz", + "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz", + "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz", + "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz", + "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz", + "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz", + "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz", + "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz", + "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.2.tgz", + "integrity": "sha512-eEieHsMksAW4IiO5NzauESRl2D2qz3J/kwUxUrSfV06A93eEaRfMpHXyUb1mAqrR7i8U9A0GRqE9pjn6u1Jjpg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.1" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.2.tgz", + "integrity": "sha512-BaktuGPCeHJMARpodR8jK4uKiZrPAy9WrfQW0sdI37clracq8Bp01AYS3SZgi5FS/y5twa9t4+LIuuxQjqRrWw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.1" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.2.tgz", + "integrity": "sha512-YoAxdnd8hPUkvLHd3bWY+YA8nw3xM/RyRopYucNsWHVSan8NLVM3X2volsfoRDcXdUJPg6tXahSd7HXPK7lRnw==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.2" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.1.tgz", + "integrity": "sha512-4V/M3roRMTYjiwZY9IOVQOE8OyeCxFAkYmyZDrZl51uOKjibm3oeEJ4WAmLxutAfzFbC9jqUiPs2gbnGflH+7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.1.tgz", + "integrity": "sha512-c0/DxItpJv2+dGhgycJBBgotdqruGYDvA79drdh0MD1dFpy7JzJ/PlXwi1H4rFf0eTy8tgbI91aHDnZIceY3jQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.1.tgz", + "integrity": "sha512-aGGy9aWzXgHBG7HNyQPWorZthlp7+x6fDRoPAQbGO3ThcttuTyKIx3NuSHb6zb4gBNq6/yNn9f1cy9nFKS/Vmg==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.1.tgz", + "integrity": "sha512-JznefmcK9j1JKPz8AkQDh89kjojubyfOasWBPKfzMIhPwsgDy9evpE/naJTXXXmghS1iFwR8u/kTwh/I2/+GCw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.1.tgz", + "integrity": "sha512-1EkwGNCZk6iWNCMWqrvdJ+r1j0PT1zIz60CNPhYnJlK/zyeWqlsPZIe+ocBVqPF8k/Ssee/NCk+tE9Ryrko6ng==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.1.tgz", + "integrity": "sha512-Ilays+w2bXdnxzxtQdmXR62u8o8GYa3eL4+Gr+1KiE4xperMZUslRaVPJwwPkzlHEjGfXAfRVAa/7CYCtSqsBw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.1.tgz", + "integrity": "sha512-VfBwVHQTbRoj4XlpA/KLZ7ltgMpz+4WSejFzQ+GnoImjo1PtEJ59QB2qR1xQEeRPYIkNrPIm2L4cICMvz4C2ew==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.1.tgz", + "integrity": "sha512-+c8ukgwU62DS54nCAjw7keOfHUkmr0B5QHEdcOqRnodF/MNXJbVI8Eopoj4B/0H8Asr65I+A4Amrn7a85/md6A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.1.tgz", + "integrity": "sha512-qlKb/pwbkAi1WMsJrYHk7CuDrd12s27U2QnRhFYUoJNrRCmkosMTttuRFat/DDB3IlDm5qE1TJgZ4JDnHX8Ldw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.1.tgz", + "integrity": "sha512-yO21HwoUVLN8Qa+/SBjQLMYwBWAVJjeGPNe+hc0OUeMeifEtJqu5a1c4HayE1nNpDih9y3/KkoltfkDodmKAlg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.2.tgz", + "integrity": "sha512-SE4kzF2mepn6z+6E7L6lsV8FzuLL6IPQdyX8ZiwROAG/G8td+hP/m7FsFPwidtrF19gvajuC9l6TxAVcsA4S7A==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.1" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.2.tgz", + "integrity": "sha512-af12Pnd0ZGu2HfP8NayB0kk6eC/lrfbQE6HlR4jD+34wdJ1Vw9TF6TMn6ZvffT+WgqVsl0hRbmNvz2u/23VmwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.1" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.2.tgz", + "integrity": "sha512-hYSBm7zcNtDCozCxQHYZJiu63b/bXsgRZuOxCIBZsStMM9Vap47iFHdbX4kCvQsblPB/k+clhELpdQJHQLSHvg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.1" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.2.tgz", + "integrity": "sha512-qQt0Kc13+Hoan/Awq/qMSQw3L+RI1NCRPgD5cUJ/1WSSmIoysLOc72jlRM3E0OHN9Yr313jgeQ2T+zW+F03QFA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.1" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.2.tgz", + "integrity": "sha512-E4fLLfRPzDLlEeDaTzI98OFLcv++WL5ChLLMwPoVd0CIoZQqupBSNbOisPL5am9XsbQ9T84+iiMpUvbFtkunbA==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.1" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.2.tgz", + "integrity": "sha512-gi0zFJJRLswfCZmHtJdikXPOc5u7qamSOS3NHedLqLd4W8Q0NqjdBr6TTRIgsfFjqfTsHFgdfvJ9LwqSgcHiAA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.1" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.2.tgz", + "integrity": "sha512-siWbOW1u6HFnFLrp0waKyW7VEf7jYvcDWdrXEFa8AkdAQgEvuu5Fz8/Y70w9EeqAdwDtfU012BhEHHaDqvQNzg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.1" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.2.tgz", + "integrity": "sha512-YBqMMcjDi4QGYiSn4vNOYBhmlC4z5AXqkOUUqI2e0AFA4urNv4ESgOgwNl3K+4etQhha0twXlzeF20bbULm9Yg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.1" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.2.tgz", + "integrity": "sha512-Mrv4JQNYVQ94xH+jzZ9r+gowleN8mv2FTgKT+PI6bx5C0G8TdNYndu161pg2i7uoBwxy2ImPMHrJOM2LZef7Bw==", "dev": true, - "license": "MIT", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, "dependencies": { - "@so-ric/colorspace": "^1.1.6", - "enabled": "2.0.x", - "kuler": "^2.0.0" + "@emnapi/runtime": "^1.11.1" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" } }, - "node_modules/@emnapi/core": { - "version": "2.0.0-alpha.3", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-alpha.3.tgz", - "integrity": "sha512-AZypUeJ/yByuxyS7BlSNRDOMLMlROYtjYdIAuBmJssVz1UJDSeYxLrdizhXCFYhedC5bqd/ASy8EuNXbVVXp9g==", + "node_modules/@img/sharp-wasm32/node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@emnapi/wasi-threads": "2.0.1", "tslib": "^2.4.0" } }, - "node_modules/@emnapi/runtime": { - "version": "2.0.0-alpha.3", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-alpha.3.tgz", - "integrity": "sha512-hFPAhMUjJD9BSyCANEISPOogeXC9Zo9ZQl7L6vKnaVsMkCtzznaW/naYypeyl0Gv5rYfWYsZbpixTMpjDJzQeA==", + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.2.tgz", + "integrity": "sha512-QNV27pxs9wpApEiCfvHM1RDoP1w1+2KrUWWDPEhEwg+latvOrfuhWrHWZKwdSFwU6jh3myjw/yOCRsUIuOft3g==", + "cpu": [ + "wasm32" + ], "dev": true, - "license": "MIT", + "license": "Apache-2.0", "optional": true, "dependencies": { - "tslib": "^2.4.0" + "@img/sharp-wasm32": "0.35.2" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" } }, - "node_modules/@emnapi/wasi-threads": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.0.1.tgz", - "integrity": "sha512-9DsSk+o5NBX0CCJT8s0EROGSGxjR/tKu6aBTaVyq+SjAEQH4XcdcRxPBRzsBLizTTJ49MJjF+jgu3qnO9GLQcQ==", + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.2.tgz", + "integrity": "sha512-BiVRYc/t6/Vl3e1hBx0hugG4oN9Pydf4fgMSpxTQJmwGUg/YoXTWHiFeRymHfCZzifxu4F4rpk/I67D0LQ20wQ==", + "cpu": [ + "arm64" + ], "dev": true, - "license": "MIT", + "license": "Apache-2.0 AND LGPL-3.0-or-later", "optional": true, - "dependencies": { - "tslib": "^2.4.0" + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.2.tgz", + "integrity": "sha512-YYEhx9PImCC7T0tI8JDMi4DB9LwLCXCU5OWNYEXAxh5Q1ShKkyC6byxzoBJ3gEFDnH2lQckWuDe70G7mB2XJog==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.2.tgz", + "integrity": "sha512-imoOyBcoM/iiUr4J6VPpCNjPnjvP/Gks95898yB8YqoGGYmHYbOyCuNv9FMhFgtaiHFGbHW8bxKqRV6VjtXThQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { @@ -454,6 +1695,17 @@ "dev": true, "license": "MIT" }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@js-joda/core": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@js-joda/core/-/core-5.7.0.tgz", @@ -769,6 +2021,10 @@ "resolved": "packages/scheduler", "link": true }, + "node_modules/@pegma/scheduler-cloudflare": { + "resolved": "packages/scheduler-cloudflare", + "link": true + }, "node_modules/@pegma/spine": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@pegma/spine/-/spine-0.1.2.tgz", @@ -792,6 +2048,19 @@ "node": ">=22" } }, + "node_modules/@pegma/storage-cloudflare-d1": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@pegma/storage-cloudflare-d1/-/storage-cloudflare-d1-0.4.1.tgz", + "integrity": "sha512-nVH+ppAWi3QwyEX8QVkPOLXNjtblO0jDnnGqCHpbZZzPvFQAVyd/1Bhxg8JdsuOD/UWGktJ26asAKzpNjRol0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pegma/storage-core": "0.4.0" + }, + "engines": { + "node": ">=22" + } + }, "node_modules/@pegma/storage-core": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/@pegma/storage-core/-/storage-core-0.4.0.tgz", @@ -801,6 +2070,48 @@ "node": ">=22" } }, + "node_modules/@poppinss/colors": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^4.1.5" + } + }, + "node_modules/@poppinss/dumper": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + } + }, + "node_modules/@poppinss/dumper/node_modules/supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/@poppinss/exception": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", + "dev": true, + "license": "MIT" + }, "node_modules/@rolldown/binding-android-arm64": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.1.tgz", @@ -1080,6 +2391,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@sindresorhus/is": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, "node_modules/@so-ric/colorspace": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz", @@ -1091,6 +2415,13 @@ "text-hex": "1.0.x" } }, + "node_modules/@speed-highlight/core": { + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.17.tgz", + "integrity": "sha512-Z92FwKpCtfaW1V0jTU/fh3QzYEZN8wDwrzRIBoADCJfn4mJCNcJN/XegifX7BDrQ8/h9Xh/JnbyMchL0FqXrkg==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/@standard-schema/spec": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", @@ -2101,6 +3432,13 @@ "safe-buffer": "~5.2.0" } }, + "node_modules/blake3-wasm": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", + "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", + "dev": true, + "license": "MIT" + }, "node_modules/body-parser": { "version": "1.20.6", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.6.tgz", @@ -2649,6 +3987,16 @@ "node": ">= 0.8" } }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", @@ -2705,6 +4053,48 @@ "node": ">= 0.4" } }, + "node_modules/esbuild": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", + "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.1", + "@esbuild/android-arm": "0.28.1", + "@esbuild/android-arm64": "0.28.1", + "@esbuild/android-x64": "0.28.1", + "@esbuild/darwin-arm64": "0.28.1", + "@esbuild/darwin-x64": "0.28.1", + "@esbuild/freebsd-arm64": "0.28.1", + "@esbuild/freebsd-x64": "0.28.1", + "@esbuild/linux-arm": "0.28.1", + "@esbuild/linux-arm64": "0.28.1", + "@esbuild/linux-ia32": "0.28.1", + "@esbuild/linux-loong64": "0.28.1", + "@esbuild/linux-mips64el": "0.28.1", + "@esbuild/linux-ppc64": "0.28.1", + "@esbuild/linux-riscv64": "0.28.1", + "@esbuild/linux-s390x": "0.28.1", + "@esbuild/linux-x64": "0.28.1", + "@esbuild/netbsd-arm64": "0.28.1", + "@esbuild/netbsd-x64": "0.28.1", + "@esbuild/openbsd-arm64": "0.28.1", + "@esbuild/openbsd-x64": "0.28.1", + "@esbuild/openharmony-arm64": "0.28.1", + "@esbuild/sunos-x64": "0.28.1", + "@esbuild/win32-arm64": "0.28.1", + "@esbuild/win32-ia32": "0.28.1", + "@esbuild/win32-x64": "0.28.1" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -3529,6 +4919,16 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/kuler": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", @@ -4016,6 +5416,27 @@ "node": ">= 0.6" } }, + "node_modules/miniflare": { + "version": "4.20260722.0", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-4.20260722.0.tgz", + "integrity": "sha512-LW6ABMhCx/yIEFBLC/DO4yAhdm2T/G7jp7pr5T2kj895+CCIaHZqpMXdW9O6YE48LcYcCJChwWc8aEs1vpbTXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.35.2", + "undici": "7.28.0", + "workerd": "1.20260722.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "bin": { + "miniflare": "bootstrap.js" + }, + "engines": { + "node": ">=22.0.0" + } + }, "node_modules/minimatch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", @@ -4870,6 +6291,64 @@ "dev": true, "license": "ISC" }, + "node_modules/sharp": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.2.tgz", + "integrity": "sha512-FVtFjtBCMiJS6yb5CX7Sop45WFMpeGw6oRKuJnXYgf/f1ms/D7LE/ZUSNxnW7rZ/dbslQWYkoqFHGPaDBtaK4w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.4" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.2", + "@img/sharp-darwin-x64": "0.35.2", + "@img/sharp-freebsd-wasm32": "0.35.2", + "@img/sharp-libvips-darwin-arm64": "1.3.1", + "@img/sharp-libvips-darwin-x64": "1.3.1", + "@img/sharp-libvips-linux-arm": "1.3.1", + "@img/sharp-libvips-linux-arm64": "1.3.1", + "@img/sharp-libvips-linux-ppc64": "1.3.1", + "@img/sharp-libvips-linux-riscv64": "1.3.1", + "@img/sharp-libvips-linux-s390x": "1.3.1", + "@img/sharp-libvips-linux-x64": "1.3.1", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.1", + "@img/sharp-libvips-linuxmusl-x64": "1.3.1", + "@img/sharp-linux-arm": "0.35.2", + "@img/sharp-linux-arm64": "0.35.2", + "@img/sharp-linux-ppc64": "0.35.2", + "@img/sharp-linux-riscv64": "0.35.2", + "@img/sharp-linux-s390x": "0.35.2", + "@img/sharp-linux-x64": "0.35.2", + "@img/sharp-linuxmusl-arm64": "0.35.2", + "@img/sharp-linuxmusl-x64": "0.35.2", + "@img/sharp-webcontainers-wasm32": "0.35.2", + "@img/sharp-win32-arm64": "0.35.2", + "@img/sharp-win32-ia32": "0.35.2", + "@img/sharp-win32-x64": "0.35.2" + } + }, + "node_modules/sharp/node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/shimmer": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", @@ -5287,6 +6766,16 @@ "@typescript/typescript-win32-x64": "7.0.2" } }, + "node_modules/undici": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.28.0.tgz", + "integrity": "sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/undici-types": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz", @@ -5294,6 +6783,16 @@ "dev": true, "license": "MIT" }, + "node_modules/unenv": { + "version": "2.0.0-rc.24", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz", + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3" + } + }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", @@ -5650,6 +7149,27 @@ "@types/node": "*" } }, + "node_modules/workerd": { + "version": "1.20260722.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260722.1.tgz", + "integrity": "sha512-NycKuc1x2onvsRfGGpM093vRlLFU2zHDAM0+APpccfg4+gZxDGCH27RmdDvkeBuoZyYqgLo3oAfF6re4mvC3vQ==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20260722.1", + "@cloudflare/workerd-darwin-arm64": "1.20260722.1", + "@cloudflare/workerd-linux-64": "1.20260722.1", + "@cloudflare/workerd-linux-arm64": "1.20260722.1", + "@cloudflare/workerd-windows-64": "1.20260722.1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -5657,6 +7177,28 @@ "dev": true, "license": "ISC" }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/wsl-utils": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.1.0.tgz", @@ -5713,6 +7255,55 @@ "node": ">=4.0" } }, + "node_modules/youch": { + "version": "4.1.0-beta.10", + "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz", + "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "node_modules/youch-core": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz", + "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + }, + "node_modules/youch/node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/zod": { + "version": "3.25.76", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", + "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, "packages/scheduler": { "name": "@pegma/scheduler", "version": "0.0.0", @@ -5724,6 +7315,17 @@ "engines": { "node": ">=22" } + }, + "packages/scheduler-cloudflare": { + "name": "@pegma/scheduler-cloudflare", + "version": "0.0.0", + "license": "MIT", + "dependencies": { + "@pegma/scheduler": "0.0.0" + }, + "engines": { + "node": ">=22" + } } } } diff --git a/package.json b/package.json index 8d951f9..9854cb9 100644 --- a/package.json +++ b/package.json @@ -14,15 +14,20 @@ ], "scripts": { "build": "tsc -b", - "check": "tsc -b --pretty false && tsc -p tsconfig.test.json --pretty false", + "check": "tsc -b --pretty false && tsc -p tsconfig.test.json --pretty false && tsc -p tsconfig.d1-test.json --pretty false", "clean": "tsc -b --clean", "format": "prettier --write .", "format:check": "prettier --check .", - "test": "npm run build && vitest run" + "test": "npm run build && npm run test:node && npm run test:d1", + "test:node": "vitest run --config vitest.config.ts", + "test:d1": "vitest run --config vitest.d1.config.ts" }, "devDependencies": { "@azure/data-tables": "^13.3.2", + "@cloudflare/vitest-pool-workers": "^0.18.8", + "@cloudflare/workers-types": "^5.20260731.1", "@pegma/storage-azure-tables": "^0.4.0", + "@pegma/storage-cloudflare-d1": "0.4.1", "@types/node": "^26.1.1", "azurite": "^3.36.0", "prettier": "^3.9.6", diff --git a/packages/scheduler-cloudflare/LICENSE b/packages/scheduler-cloudflare/LICENSE new file mode 100644 index 0000000..897032a --- /dev/null +++ b/packages/scheduler-cloudflare/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 RetireGolden, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/scheduler-cloudflare/README.md b/packages/scheduler-cloudflare/README.md new file mode 100644 index 0000000..845f799 --- /dev/null +++ b/packages/scheduler-cloudflare/README.md @@ -0,0 +1,76 @@ +# @pegma/scheduler-cloudflare + +Explicit Cloudflare Cron Trigger dispatch for +[`@pegma/scheduler`](https://github.com/pegma-dev/scheduler). + +> [!IMPORTANT] +> This package is under active development and is not published or usable in +> production yet. Version `0.0.0` is a repository-development placeholder, +> not an advertised release. + +The adapter translates a Cloudflare `ScheduledController` into core +`runScheduled` calls through a **host-supplied cron route map**. It does not +own D1, Wrangler configuration, task discovery, or domain work. + +```ts +import { createScheduler, defineScheduledTasks } from "@pegma/scheduler"; +import { createCloudflareSchedulerDispatch } from "@pegma/scheduler-cloudflare"; +import { createCloudflareD1Store } from "@pegma/storage-cloudflare-d1"; + +const tasks = defineScheduledTasks({ + "health.probe-targets": async () => ({ more: false }), + "github.sync-orgs": async ({ checkpoint }) => { + // bounded domain page + return { nextCheckpoint: checkpoint ?? "page-1" }; + }, +}); + +const scheduler = createScheduler({ + store: createCloudflareD1Store({ database: env.DB }), + clock, + logger, + instanceId: "ops-hub", + workerId: env.WORKER_ID ?? "worker-1", + tasks, +}); + +const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { + "* * * * *": ["health.probe-targets"], + "*/10 * * * *": ["github.sync-orgs"], + }, +}); + +export default { + async scheduled( + controller: ScheduledController, + env: Env, + ctx: ExecutionContext, + ) { + await dispatch.scheduled(controller, ctx); + }, +}; +``` + +## Contracts + +- Route keys must match Wrangler cron expressions **exactly**. +- `controller.scheduledTime` becomes the trusted `scheduledFor` ISO timestamp. +- `ctx.waitUntil` keeps the isolate alive for the full dispatch promise. +- Unmapped cron expressions fail closed. +- Multiple tasks may share one expression; each keeps independent durable state. + +## Local development + +```sh +npx wrangler dev --test-scheduled --persist-to .wrangler/state +curl "http://127.0.0.1:8787/__scheduled?cron=*+*+*+*+*" +``` + +Persist `.wrangler/state` (for example as a Docker volume) so D1 and scheduler +task state survive restarts. A Docker-side timer that hits `/__scheduled` every +30 seconds is a development wakeup only; production still uses Cron Triggers. + +See the repository [Cloudflare guide](../../docs/CLOUDFLARE.md) and +[project plan](../../docs/PROJECT_PLAN.md). diff --git a/packages/scheduler-cloudflare/package.json b/packages/scheduler-cloudflare/package.json new file mode 100644 index 0000000..79ccd11 --- /dev/null +++ b/packages/scheduler-cloudflare/package.json @@ -0,0 +1,39 @@ +{ + "name": "@pegma/scheduler-cloudflare", + "version": "0.0.0", + "description": "Cloudflare Cron Trigger dispatch for @pegma/scheduler.", + "license": "MIT", + "type": "module", + "sideEffects": false, + "publishConfig": { + "access": "public" + }, + "files": [ + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "dist/**/*.js", + "dist/**/*.js.map" + ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "engines": { + "node": ">=22" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/pegma-dev/scheduler.git", + "directory": "packages/scheduler-cloudflare" + }, + "dependencies": { + "@pegma/scheduler": "0.0.0" + }, + "scripts": { + "build": "tsc -p tsconfig.json", + "check": "tsc -p tsconfig.json --noEmit", + "prepack": "npm run build" + } +} diff --git a/packages/scheduler-cloudflare/src/fixture.d1.test.ts b/packages/scheduler-cloudflare/src/fixture.d1.test.ts new file mode 100644 index 0000000..1e56e7e --- /dev/null +++ b/packages/scheduler-cloudflare/src/fixture.d1.test.ts @@ -0,0 +1,242 @@ +import { env } from "cloudflare:workers"; +import { + createScheduler, + defineScheduledTasks, + type Scheduler, +} from "@pegma/scheduler"; +import { fixedClock, noopLogger, type IsoTimestamp } from "@pegma/spine"; +import { createCloudflareD1Store } from "@pegma/storage-cloudflare-d1"; +import { schedulerTaskStates } from "@pegma/scheduler"; +import { beforeAll, beforeEach, describe, expect, it } from "vitest"; + +import { createCloudflareSchedulerDispatch } from "./index.js"; + +declare global { + namespace Cloudflare { + interface Env { + DB: D1Database; + } + } +} + +const T0 = "2026-07-31T12:00:00.000Z" as IsoTimestamp; +const T0_MS = Date.parse(T0); +const T1_MS = Date.parse("2026-07-31T12:01:00.000Z"); +const T2_MS = Date.parse("2026-07-31T12:02:00.000Z"); + +function compose(workerId: string): { + readonly scheduler: Scheduler<{ + "github.sync-orgs": ( + context: import("@pegma/scheduler").ScheduledTaskContext, + ) => Promise; + }>; + readonly dispatch: ReturnType< + typeof createCloudflareSchedulerDispatch<{ + "github.sync-orgs": ( + context: import("@pegma/scheduler").ScheduledTaskContext, + ) => Promise; + }> + >; +} { + const store = createCloudflareD1Store({ database: env.DB }); + const tasks = defineScheduledTasks({ + "github.sync-orgs": async ({ checkpoint }) => { + if (checkpoint === undefined) { + return { nextCheckpoint: "page-1", summary: { pages: 1 } }; + } + if (checkpoint === "page-1") { + return { nextCheckpoint: null, summary: { pages: 1 } }; + } + return {}; + }, + }); + const scheduler = createScheduler({ + store, + clock: fixedClock(T0), + logger: noopLogger, + instanceId: "ops-hub-d1", + workerId, + tasks, + leaseMilliseconds: 10_000, + handlerTimeoutMilliseconds: 8_000, + }); + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { + "*/10 * * * *": ["github.sync-orgs"], + }, + newInvocationId: () => `d1-${workerId}-${Date.now()}`, + }); + return { scheduler, dispatch }; +} + +beforeAll(async () => { + // Create schema via the adapter before clearing tables between tests. + const store = createCloudflareD1Store({ database: env.DB }); + await store + .collection(schedulerTaskStates) + .get({ partition: "ops-hub-d1", id: "github.sync-orgs" }); +}); + +beforeEach(async () => { + // Pool isolates storage per file, not per test. + await env.DB.prepare("DELETE FROM RECORDS").run(); + await env.DB.prepare("DELETE FROM PEGMA_STORAGE_D1_TX_GUARD").run(); +}); + +describe("scheduler-cloudflare against real local D1", () => { + it("completes a checkpoint cycle with occurrence suppression", async () => { + const { dispatch, scheduler } = compose("worker-a"); + + const first = await dispatch.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T0_MS, + }); + expect(first[0]?.outcome).toBe("succeeded"); + await expect(scheduler.getState("github.sync-orgs")).resolves.toMatchObject( + { + status: "succeeded", + checkpoint: "page-1", + }, + ); + + const second = await dispatch.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T1_MS, + }); + expect(second[0]?.outcome).toBe("succeeded"); + if (second[0]?.outcome === "succeeded") { + expect(second[0].state.checkpoint).toBeUndefined(); + expect(second[0].state.lastScheduledFor).toBe("2026-07-31T12:01:00.000Z"); + } + + const stale = await dispatch.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T0_MS, + }); + expect(stale[0]).toMatchObject({ + outcome: "skipped", + reason: "stale_occurrence", + }); + }); + + it("survives isolate restart with durable D1 state", async () => { + const firstIsolate = compose("worker-a"); + const first = await firstIsolate.dispatch.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T0_MS, + }); + expect(first[0]?.outcome).toBe("succeeded"); + + // A new composition over the same D1 binding models a Worker restart. + const restarted = compose("worker-b"); + await expect( + restarted.scheduler.getState("github.sync-orgs"), + ).resolves.toMatchObject({ + status: "succeeded", + checkpoint: "page-1", + }); + + const next = await restarted.dispatch.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T2_MS, + }); + expect(next[0]?.outcome).toBe("succeeded"); + if (next[0]?.outcome === "succeeded") { + expect(next[0].state.checkpoint).toBeUndefined(); + expect(next[0].state.lastScheduledFor).toBe("2026-07-31T12:02:00.000Z"); + } + }); + + it("fences overlapping scheduled deliveries on the same task", async () => { + const store = createCloudflareD1Store({ database: env.DB }); + let release: (() => void) | undefined; + const gate = new Promise((resolve) => { + release = resolve; + }); + let entered: (() => void) | undefined; + const enteredGate = new Promise((resolve) => { + entered = resolve; + }); + let starts = 0; + + const tasks = defineScheduledTasks({ + "github.sync-orgs": async () => { + starts += 1; + if (starts === 1) { + entered?.(); + await gate; + } + return { nextCheckpoint: "overlap" }; + }, + }); + + const a = createScheduler({ + store, + clock: fixedClock(T0), + logger: noopLogger, + instanceId: "ops-hub-d1", + workerId: "worker-a", + tasks, + leaseMilliseconds: 10_000, + handlerTimeoutMilliseconds: 8_000, + }); + const b = createScheduler({ + store, + clock: fixedClock(T0), + logger: noopLogger, + instanceId: "ops-hub-d1", + workerId: "worker-b", + tasks, + leaseMilliseconds: 10_000, + handlerTimeoutMilliseconds: 8_000, + }); + + const dispatchA = createCloudflareSchedulerDispatch({ + scheduler: a, + routes: { "*/10 * * * *": ["github.sync-orgs"] }, + newInvocationId: () => "a", + }); + const dispatchB = createCloudflareSchedulerDispatch({ + scheduler: b, + routes: { "*/10 * * * *": ["github.sync-orgs"] }, + newInvocationId: () => "b", + }); + + const running = dispatchA.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T1_MS, + }); + await enteredGate; + const overlap = await dispatchB.scheduled({ + cron: "*/10 * * * *", + scheduledTime: T1_MS, + }); + expect(overlap[0]).toMatchObject({ + outcome: "skipped", + reason: "live_lease", + }); + release?.(); + await expect(running).resolves.toMatchObject([{ outcome: "succeeded" }]); + expect(starts).toBe(1); + }); + + it("registers work with waitUntil on the execution context", async () => { + const { dispatch } = compose("worker-wait"); + const waited: Promise[] = []; + const results = await dispatch.scheduled( + { + cron: "*/10 * * * *", + scheduledTime: T0_MS, + }, + { + waitUntil(promise) { + waited.push(promise); + }, + }, + ); + expect(waited).toHaveLength(1); + await expect(waited[0]).resolves.toEqual(results); + expect(results[0]?.outcome).toBe("succeeded"); + }); +}); diff --git a/packages/scheduler-cloudflare/src/index.test.ts b/packages/scheduler-cloudflare/src/index.test.ts new file mode 100644 index 0000000..56268b3 --- /dev/null +++ b/packages/scheduler-cloudflare/src/index.test.ts @@ -0,0 +1,298 @@ +import { + createScheduler, + defineScheduledTasks, + type SchedulerRunResult, +} from "@pegma/scheduler"; +import { fixedClock, type IsoTimestamp, type Logger } from "@pegma/spine"; +import { createMemoryStore } from "@pegma/storage-core"; +import { describe, expect, it } from "vitest"; + +import { + createCloudflareSchedulerDispatch, + type CloudflareExecutionContext, + type CloudflareScheduledController, +} from "./index.js"; + +const T0_MS = Date.parse("2026-07-31T12:00:00.000Z"); +const T1_MS = Date.parse("2026-07-31T12:01:00.000Z"); +const T0 = "2026-07-31T12:00:00.000Z" as IsoTimestamp; + +function recordingLogger(): Logger & { + readonly entries: { readonly message: string }[]; +} { + const entries: { readonly message: string }[] = []; + return { + entries, + log(_level, message) { + entries.push({ message }); + }, + }; +} + +function controller( + overrides: Partial = {}, +): CloudflareScheduledController { + return { + scheduledTime: T1_MS, + cron: "* * * * *", + ...overrides, + }; +} + +function recordingContext(): CloudflareExecutionContext & { + readonly waited: Promise[]; +} { + const waited: Promise[] = []; + return { + waited, + waitUntil(promise) { + waited.push(promise); + }, + }; +} + +function makeScheduler( + handlers: Parameters[0], + options: { + readonly store?: ReturnType; + readonly workerId?: string; + } = {}, +) { + const store = options.store ?? createMemoryStore(); + const tasks = defineScheduledTasks(handlers); + const scheduler = createScheduler({ + store, + clock: fixedClock(T0), + logger: recordingLogger(), + instanceId: "ops-hub", + workerId: options.workerId ?? "worker-cf", + tasks, + leaseMilliseconds: 5_000, + handlerTimeoutMilliseconds: 4_000, + }); + return { store, scheduler, tasks }; +} + +describe("createCloudflareSchedulerDispatch", () => { + it("routes cron to registered tasks using scheduledTime and waitUntil", async () => { + const seen: { readonly scheduledFor: string; readonly id: string }[] = []; + const { scheduler } = makeScheduler({ + "health.probe-targets": async (context) => { + seen.push({ + scheduledFor: context.scheduledFor, + id: context.invocationId, + }); + return { more: false }; + }, + }); + let invocation = 0; + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { + "* * * * *": ["health.probe-targets"], + }, + newInvocationId: () => `inv-${++invocation}`, + }); + const ctx = recordingContext(); + const results = await dispatch.scheduled(controller(), ctx); + + expect(results).toHaveLength(1); + expect(results[0]?.outcome).toBe("succeeded"); + expect(seen).toEqual([ + { scheduledFor: "2026-07-31T12:01:00.000Z", id: "inv-1" }, + ]); + expect(ctx.waited).toHaveLength(1); + await expect(ctx.waited[0]).resolves.toEqual(results); + }); + + it("runs every task mapped to the same cron expression in order", async () => { + const order: string[] = []; + const { scheduler } = makeScheduler({ + "health.probe-targets": async () => { + order.push("health"); + return {}; + }, + "github.sync-orgs": async () => { + order.push("github"); + return { nextCheckpoint: "page-1" }; + }, + }); + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { + "*/5 * * * *": ["health.probe-targets", "github.sync-orgs"], + }, + newInvocationId: () => "shared", + }); + + const results = await dispatch.scheduled( + controller({ cron: "*/5 * * * *" }), + ); + expect(order).toEqual(["health", "github"]); + expect(results.map((result) => result.outcome)).toEqual([ + "succeeded", + "succeeded", + ]); + }); + + it("fails closed for an unmapped cron expression", async () => { + const { scheduler } = makeScheduler({ + "health.probe-targets": async () => ({}), + }); + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { "* * * * *": ["health.probe-targets"] }, + }); + + await expect( + dispatch.scheduled(controller({ cron: "0 * * * *" })), + ).rejects.toThrow(/no scheduled tasks are routed/); + }); + + it("rejects malformed routes and controllers without invoking tasks", async () => { + const { scheduler } = makeScheduler({ + "health.probe-targets": async () => { + throw new Error("should not run"); + }, + }); + + expect(() => + createCloudflareSchedulerDispatch({ + scheduler, + routes: {}, + }), + ).toThrow(/at least one cron route/); + + expect(() => + createCloudflareSchedulerDispatch({ + scheduler, + routes: { + "* * * * *": [], + }, + }), + ).toThrow(/non-empty array/); + + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { "* * * * *": ["health.probe-targets"] }, + }); + await expect( + dispatch.scheduled({ + cron: "* * * * *", + scheduledTime: Number.NaN, + }), + ).rejects.toThrow(/scheduledTime/); + }); + + it("suppresses overlap when the same task is already running", async () => { + const store = createMemoryStore(); + let release: (() => void) | undefined; + const gate = new Promise((resolve) => { + release = resolve; + }); + let entered: (() => void) | undefined; + const enteredGate = new Promise((resolve) => { + entered = resolve; + }); + + const first = makeScheduler( + { + "health.probe-targets": async () => { + entered?.(); + await gate; + return {}; + }, + }, + { store, workerId: "worker-a" }, + ); + const second = makeScheduler( + { + "health.probe-targets": async () => ({ nextCheckpoint: "nope" }), + }, + { store, workerId: "worker-b" }, + ); + + const dispatchA = createCloudflareSchedulerDispatch({ + scheduler: first.scheduler, + routes: { "* * * * *": ["health.probe-targets"] }, + newInvocationId: () => "a", + }); + const dispatchB = createCloudflareSchedulerDispatch({ + scheduler: second.scheduler, + routes: { "* * * * *": ["health.probe-targets"] }, + newInvocationId: () => "b", + }); + + const running = dispatchA.scheduled(controller({ scheduledTime: T1_MS })); + await enteredGate; + const overlap = await dispatchB.scheduled( + controller({ scheduledTime: T1_MS }), + ); + expect(overlap[0]).toMatchObject({ + outcome: "skipped", + reason: "live_lease", + }); + release?.(); + const completed = await running; + expect(completed[0]?.outcome).toBe("succeeded"); + }); + + it("advances checkpoints across successive scheduled occurrences", async () => { + const store = createMemoryStore(); + const { scheduler } = makeScheduler( + { + "github.sync-orgs": async ({ checkpoint }) => { + if (checkpoint === undefined) return { nextCheckpoint: "page-1" }; + if (checkpoint === "page-1") return { nextCheckpoint: null }; + return {}; + }, + }, + { store }, + ); + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { "*/10 * * * *": ["github.sync-orgs"] }, + newInvocationId: () => "cycle", + }); + + const first = await dispatch.scheduled( + controller({ cron: "*/10 * * * *", scheduledTime: T0_MS }), + ); + expect(first[0]).toMatchObject({ outcome: "succeeded" }); + if (first[0]?.outcome === "succeeded") { + expect(first[0].state.checkpoint).toBe("page-1"); + } + + const second = await dispatch.scheduled( + controller({ cron: "*/10 * * * *", scheduledTime: T1_MS }), + ); + expect(second[0]).toMatchObject({ outcome: "succeeded" }); + if (second[0]?.outcome === "succeeded") { + expect(second[0].state.checkpoint).toBeUndefined(); + expect(second[0].state.lastScheduledFor).toBe("2026-07-31T12:01:00.000Z"); + } + + const stale = await dispatch.scheduled( + controller({ cron: "*/10 * * * *", scheduledTime: T0_MS }), + ); + expect(stale[0]).toMatchObject({ + outcome: "skipped", + reason: "stale_occurrence", + }); + }); +}); + +describe("CloudflareSchedulerDispatch result typing", () => { + it("returns a frozen result list", async () => { + const { scheduler } = makeScheduler({ + "health.probe-targets": async () => ({}), + }); + const dispatch = createCloudflareSchedulerDispatch({ + scheduler, + routes: { "* * * * *": ["health.probe-targets"] }, + }); + const results: readonly SchedulerRunResult[] = + await dispatch.scheduled(controller()); + expect(Object.isFrozen(results)).toBe(true); + }); +}); diff --git a/packages/scheduler-cloudflare/src/index.ts b/packages/scheduler-cloudflare/src/index.ts new file mode 100644 index 0000000..255dd71 --- /dev/null +++ b/packages/scheduler-cloudflare/src/index.ts @@ -0,0 +1,204 @@ +import type { + Scheduler, + SchedulerRunResult, + ScheduledTaskDefinitions, +} from "@pegma/scheduler"; + +/** + * Minimal ScheduledController surface. Cloudflare's runtime type is assignable + * to this shape; the adapter does not import Workers types at runtime. + */ +export interface CloudflareScheduledController { + /** Unix milliseconds for the scheduled occurrence (host time). */ + readonly scheduledTime: number; + /** Cron expression that fired, as delivered by Cloudflare. */ + readonly cron: string; +} + +/** + * Minimal ExecutionContext surface used for waitUntil. Hosts pass the + * platform context; tests can supply a recorder. + */ +export interface CloudflareExecutionContext { + waitUntil(promise: Promise): void; +} + +/** Maps each Wrangler cron expression to one or more registered task ids. */ +export type CronRouteMap = Readonly< + Record +>; + +export interface CreateCloudflareSchedulerDispatchOptions< + TTasks extends ScheduledTaskDefinitions, +> { + readonly scheduler: Scheduler; + /** + * Explicit host-supplied routes. Keys must match Wrangler cron expressions + * exactly. The adapter never discovers tasks or reads wrangler config. + */ + readonly routes: CronRouteMap; + /** Host-issued correlation id factory. Defaults to crypto.randomUUID(). */ + readonly newInvocationId?: () => string; +} + +export interface CloudflareSchedulerDispatch< + TTasks extends ScheduledTaskDefinitions, +> { + /** + * Dispatch one Cloudflare scheduled event through the route map. + * + * When `ctx` is provided, the returned work is also registered with + * `waitUntil` so the isolate may outlive the handler return. The promise + * always settles with one result per routed task, in route order. + */ + scheduled( + controller: CloudflareScheduledController, + ctx?: CloudflareExecutionContext, + ): Promise; +} + +function requireRoutes( + routes: CronRouteMap, +): ReadonlyMap { + if (routes === null || typeof routes !== "object" || Array.isArray(routes)) { + throw new TypeError("routes must be an object"); + } + const keys = Object.keys(routes); + if (keys.length === 0) { + throw new TypeError("at least one cron route must be registered"); + } + const map = new Map(); + for (const cron of keys) { + if (typeof cron !== "string" || cron.length === 0) { + throw new TypeError("cron route keys must be non-empty strings"); + } + const descriptor = Object.getOwnPropertyDescriptor(routes, cron); + if (descriptor === undefined || !("value" in descriptor)) { + throw new TypeError(`route ${cron} must be an own data property`); + } + const tasks = descriptor.value; + if (!Array.isArray(tasks) || tasks.length === 0) { + throw new TypeError( + `route ${cron} must map to a non-empty array of task ids`, + ); + } + const copy: string[] = []; + for (const taskId of tasks) { + if (typeof taskId !== "string" || taskId.length === 0) { + throw new TypeError(`route ${cron} task ids must be non-empty strings`); + } + copy.push(taskId); + } + map.set(cron, Object.freeze(copy) as readonly (keyof TTasks & string)[]); + } + return map; +} + +function requireController(controller: CloudflareScheduledController): { + readonly cron: string; + readonly scheduledFor: string; +} { + if ( + controller === null || + typeof controller !== "object" || + Array.isArray(controller) + ) { + throw new TypeError("scheduled controller must be an object"); + } + const cron = controller.cron; + if (typeof cron !== "string" || cron.length === 0) { + throw new TypeError("controller.cron must be a non-empty string"); + } + const scheduledTime = controller.scheduledTime; + if (typeof scheduledTime !== "number" || !Number.isFinite(scheduledTime)) { + throw new TypeError("controller.scheduledTime must be a finite number"); + } + let scheduledFor: string; + try { + scheduledFor = new Date(scheduledTime).toISOString(); + } catch { + throw new TypeError("controller.scheduledTime is not a valid instant"); + } + return { cron, scheduledFor }; +} + +function defaultInvocationId(): string { + const webCrypto = ( + globalThis as { readonly crypto?: { readonly randomUUID?: () => string } } + ).crypto; + if (webCrypto === undefined || typeof webCrypto.randomUUID !== "function") { + throw new TypeError("crypto.randomUUID is required"); + } + return webCrypto.randomUUID(); +} + +/** + * Builds a thin Cloudflare Cron Trigger dispatcher over a core Scheduler. + * + * The host owns Wrangler cron configuration and the composition root. This + * adapter only translates `ScheduledController` into explicit `runScheduled` + * calls and keeps the isolate alive via `waitUntil` when an execution context + * is supplied. + */ +export function createCloudflareSchedulerDispatch< + TTasks extends ScheduledTaskDefinitions, +>( + options: CreateCloudflareSchedulerDispatchOptions, +): CloudflareSchedulerDispatch { + if ( + options === null || + typeof options !== "object" || + Array.isArray(options) + ) { + throw new TypeError("dispatch options must be an object"); + } + if ( + options.scheduler === null || + typeof options.scheduler !== "object" || + typeof options.scheduler.runScheduled !== "function" + ) { + throw new TypeError("scheduler must provide runScheduled"); + } + const routes = requireRoutes(options.routes); + const newInvocationId = options.newInvocationId ?? defaultInvocationId; + if (typeof newInvocationId !== "function") { + throw new TypeError("newInvocationId must be a function"); + } + + return { + async scheduled(controller, ctx) { + const { cron, scheduledFor } = requireController(controller); + const taskIds = routes.get(cron); + if (taskIds === undefined) { + throw new TypeError( + `no scheduled tasks are routed for cron ${JSON.stringify(cron)}`, + ); + } + + if (ctx !== undefined) { + if ( + ctx === null || + typeof ctx !== "object" || + typeof ctx.waitUntil !== "function" + ) { + throw new TypeError("execution context must provide waitUntil"); + } + } + + const work = (async (): Promise => { + const results: SchedulerRunResult[] = []; + for (const taskId of taskIds) { + const result = await options.scheduler.runScheduled(taskId, { + scheduledFor, + invocationId: newInvocationId(), + }); + results.push(result); + } + return Object.freeze(results); + })(); + + ctx?.waitUntil(work); + return work; + }, + }; +} diff --git a/packages/scheduler-cloudflare/tsconfig.json b/packages/scheduler-cloudflare/tsconfig.json new file mode 100644 index 0000000..1159c83 --- /dev/null +++ b/packages/scheduler-cloudflare/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "tsBuildInfoFile": "tsconfig.tsbuildinfo", + "types": [] + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.test.ts", "src/**/*.d1.test.ts"], + "references": [{ "path": "../scheduler" }] +} diff --git a/test/d1-worker.ts b/test/d1-worker.ts new file mode 100644 index 0000000..a9d332c --- /dev/null +++ b/test/d1-worker.ts @@ -0,0 +1,9 @@ +/** + * Minimal Worker entry for the Cloudflare Vitest pool. + * Tests import package modules directly; this file only satisfies Wrangler. + */ +export default { + async fetch(): Promise { + return new Response("scheduler-d1-tests"); + }, +}; diff --git a/test/wrangler.d1.toml b/test/wrangler.d1.toml new file mode 100644 index 0000000..35abcce --- /dev/null +++ b/test/wrangler.d1.toml @@ -0,0 +1,10 @@ +# Vitest Workers pool configuration for real local D1 tests. +# Not a production deployment; cron routes live in consumer Wrangler configs. +name = "scheduler-d1-tests" +compatibility_date = "2026-07-22" +main = "d1-worker.ts" + +[[d1_databases]] +binding = "DB" +database_name = "scheduler-test" +database_id = "00000000-0000-0000-0000-000000000001" diff --git a/tsconfig.d1-test.json b/tsconfig.d1-test.json new file mode 100644 index 0000000..dcd4f4f --- /dev/null +++ b/tsconfig.d1-test.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "composite": false, + "declaration": false, + "declarationMap": false, + "sourceMap": false, + "noEmit": true, + "types": ["@cloudflare/workers-types", "node"], + "lib": ["ES2022"] + }, + "include": [ + "packages/scheduler-cloudflare/src/**/*.d1.test.ts", + "vitest.d1.config.ts" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 322b231..f2177bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,7 @@ { "files": [], - "references": [{ "path": "./packages/scheduler" }] + "references": [ + { "path": "./packages/scheduler" }, + { "path": "./packages/scheduler-cloudflare" } + ] } diff --git a/tsconfig.test.json b/tsconfig.test.json index bbcbeaf..8da8ef3 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -8,5 +8,11 @@ "noEmit": true, "types": ["node"] }, - "include": ["packages/*/src/**/*.test.ts", "test/**/*.ts", "vitest.config.ts"] + "include": [ + "packages/*/src/**/*.test.ts", + "test/**/*.ts", + "vitest.config.ts", + "vitest.d1.config.ts" + ], + "exclude": ["packages/**/*.d1.test.ts"] } diff --git a/vitest.config.ts b/vitest.config.ts index d6e294a..991f2f0 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ test: { include: ["packages/**/*.test.ts"], - exclude: ["**/dist/**", "**/node_modules/**"], + exclude: ["**/dist/**", "**/node_modules/**", "**/*.d1.test.ts"], globalSetup: ["./test/azurite.ts"], testTimeout: 30_000, }, diff --git a/vitest.d1.config.ts b/vitest.d1.config.ts new file mode 100644 index 0000000..045e95c --- /dev/null +++ b/vitest.d1.config.ts @@ -0,0 +1,22 @@ +import { cloudflareTest } from "@cloudflare/vitest-pool-workers"; +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + plugins: [ + cloudflareTest({ + // Pin to a date supported by the bundled workerd binary. + wrangler: { + configPath: "./test/wrangler.d1.toml", + }, + miniflare: { + // Must not exceed the newest date supported by the locked workerd binary. + compatibilityDate: "2026-07-22", + d1Databases: ["DB"], + }, + }), + ], + test: { + include: ["packages/**/*.d1.test.ts"], + testTimeout: 30_000, + }, +});