Files
2026-05-27 23:29:53 +01:00

70 lines
4.5 KiB
Markdown

# Tasks — storage-cdn-bunnycdn
> Every checkbox MUST reflect work actually done in this change.
> Hard dependency: `@suaveplan/storage-cdn` (change `add-storage-cdn`) MUST be archived first.
## 1. Spec authoring
- [ ] 1.1 Read `openspec/changes/add-storage-cdn/specs/storage-cdn/spec.md` for the contract
- [ ] 1.2 Read `openspec/changes/add-storage-cdn-rackspace/` for the sibling provider pattern
- [ ] 1.3 Read BunnyCDN Storage HTTP API, Pull Zone purge API, and Token Authentication docs
- [ ] 1.4 Draft `proposal.md`, `design.md`, `specs/storage-cdn-bunnycdn/spec.md`, `tasks.md`
- [ ] 1.5 Numbered Requirement/Scenario checklist per §0c step 6
## 2. Scaffolding
- [ ] 2.1 Create `packages/storage/storage-cdn-bunnycdn/`
- [ ] 2.2 `package.json` v0.0.0, `"sideEffects": false`, subpath exports
- [ ] 2.3 Deps: `@suaveplan/error`, `@suaveplan/storage`, `@suaveplan/storage-cdn`, `@suaveplan/retry`, `@suaveplan/types`, `@opentelemetry/api`, `zod`, `tslib`
- [ ] 2.4 DevDeps: `@suaveplan/testing`, `@vitest/coverage-istanbul`, `fast-check`, `mitata`, `typescript`, `vite`, `vite-plugin-dts`, `vitest`
- [ ] 2.5 `tsconfig`, `vite.config.ts`, `vitest.config.ts` via `createTestConfig`
## 3. Implementation
- [ ] 3.1 `src/error-codes.ts` — `defineCodes("STORAGE_CDN_BUNNYCDN", [...])` with 8 codes, `StorageCdnBunnycdnError`
- [ ] 3.2 `src/types/*.ts` + `.schemas.ts` — `BunnyCdnAdapterOptions` + Zod schema (region whitelist)
- [ ] 3.3 `src/storage-client/storage-client.ts` — PUT/GET/DELETE/HEAD/LIST against regional Storage Zone with `AccessKey` header
- [ ] 3.4 `src/pull-zone-client/pull-zone-client.ts` — single-URL purge + prefix purge via `api.bunny.net/purge`
- [ ] 3.5 `src/token-auth/token-auth.ts` — HMAC-SHA256 Token Authentication via WebCrypto, URL-safe base64
- [ ] 3.6 `src/key-sanitizer/key-sanitizer.ts` — strict boundary + per-segment encoder
- [ ] 3.7 `src/retry-helper/retry-helper.ts` — transient classifier + Retry-After honour
- [ ] 3.8 `src/otel/otel.ts` — meter/tracer with `provider="bunnycdn"` + `storage_region` attrs
- [ ] 3.9 `src/bunny-cdn-adapter/bunny-cdn-adapter.ts` — `BunnyCdnAdapter extends CdnAdapter` + `purgePrefix` extra method
- [ ] 3.10 `src/registry/registry.ts` — `registerBunnyCdnProvider()` idempotent
- [ ] 3.11 `src/index.ts` — explicit named re-exports
## 4. Tests
- [ ] 4.1 `src/storage-client/storage-client.test.ts` — `de` unprefixed host, `ny` prefixed host, PUT/GET/DELETE/HEAD/LIST round-trips, 401 → STORAGE_AUTH_FAILED, 404 → undefined
- [ ] 4.2 `src/pull-zone-client/pull-zone-client.test.ts` — single purge 200, prefix purge wildcard, 401 → PURGE_AUTH_FAILED, missing API key → PURGE_API_KEY_MISSING
- [ ] 4.3 `src/token-auth/token-auth.test.ts` — reference-vector byte equality, path-scoped token, missing key error
- [ ] 4.4 `src/key-sanitizer/key-sanitizer.test.ts` — traversal, absolute, overlong, per-segment encoding
- [ ] 4.5 `src/retry-helper/retry-helper.test.ts` — transient classifier, `Retry-After` honour, non-retry on 401
- [ ] 4.6 `src/otel/otel.test.ts` — measurement attrs include `provider` and `storage_region`
- [ ] 4.7 `src/bunny-cdn-adapter/bunny-cdn-adapter.test.ts` — full CRUD, range, edgeUrl, purge, prefix purge, signUrl, AbortSignal, retry, list mapping
- [ ] 4.8 `src/bunny-cdn-adapter/bunny-cdn-adapter.spec-conformance.test.ts` — type conformance, capabilities, every code reachable, tier-purity grep
- [ ] 4.9 `src/registry/registry.test.ts` — factory dispatch, idempotency
- [ ] 4.10 Every `it(...)` carries `{ timeout: 5000 }` (or 30000 for genuinely async)
- [ ] 4.11 All test imports via `@suaveplan/testing/runner` (§7)
## 5. Documentation
- [ ] 5.1 Sibling `.md` for every implementation `.ts`
- [ ] 5.2 `README.md` documents region selection (`de|ny|la|sg|syd|uk`), two-key model (storage vs purge), Token Authentication setup
## 6. Gates
- [ ] 6.1 `bun run check`
- [ ] 6.2 `bunx turbo lint typecheck test --filter=@suaveplan/storage-cdn-bunnycdn`
- [ ] 6.3 `bunx turbo test:coverage --filter=@suaveplan/storage-cdn-bunnycdn` (100/100/100/100)
- [ ] 6.4 `bun scripts/lint/check-test-runner-imports.ts`
- [ ] 6.5 Tier-purity grep returns empty
- [ ] 6.6 `bun scripts/openspec-conformance.ts @suaveplan/storage-cdn-bunnycdn`
## 7. Manifest & archival
- [ ] 7.1 `bun scripts/folder-reorg/generate-manifest.ts`
- [ ] 7.2 Update `STATUS.md`
- [ ] 7.3 Fold `specs/storage-cdn-bunnycdn/spec.md` → `openspec/specs/storage-cdn-bunnycdn/spec.md`
- [ ] 7.4 Move change folder → `openspec/archive/<yyyy-mm-dd>-add-storage-cdn-bunnycdn/`