Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
# Tasks — Add @suaveplan/api-plugin-site
> Every checkbox MUST reflect work actually done in this change.
## 1. Spec authoring
- [x] 1.1 Read `/mnt/s/web/suaveplan/enterprise/api-plugin-site.md` end-to-end.
- [x] 1.2 Confirm no prior `openspec/specs/api-plugin-site/spec.md` exists.
- [x] 1.3 Read `openspec/AGENTS.md` §§ 0a, 2a, 6a, 7, 12, 13, 14.
- [x] 1.4 Draft `proposal.md` with `### Source mapping` table + `### Excluded` section.
- [x] 1.5 Draft `specs/api-plugin-site/spec.md` with `## ADDED Requirements`, every requirement carrying a `**Verified by:**` line.
## 2. Implementation
- [x] 2.1 `src/error-codes/error-codes.ts` — `defineCodes("SITE", [...])` (14 codes) + `SiteError extends SuaveplanError`.
- [x] 2.2 `src/types/types.ts` — runtime-free types: `Site`, `SiteSettings`, `SiteTheme`, push types, `SiteEventMap`, state constants.
- [x] 2.3 `src/schemas/site.ts` — Zod schemas for the site entity.
- [x] 2.4 `src/schemas/domain.ts` — Zod schemas for domain values + requests/responses.
- [x] 2.5 `src/schemas/push.ts` — Push-config schemas + `validatePushConfig` pure validator.
- [x] 2.6 `src/schemas/options.ts` — `SitePluginOptionsSchema`, `mergeConfig`, frozen `DEFAULT_CONFIG`.
- [x] 2.7 `src/otel/instruments.ts` — `getSiteInstruments` / `resetSiteInstruments` / `SiteInstruments`.
- [x] 2.8 `src/service/db-port.ts` — structural `SiteDb` interface.
- [x] 2.9 `src/service/normalize-domain.ts` — pure normaliser.
- [x] 2.10 `src/service/domain-resolver.ts` — `DomainResolverService` with OTel + envelope result.
- [x] 2.11 `src/service/site.ts` — `SiteService` (CRUD + emit `site:settings:updated`).
- [x] 2.12 `src/middleware/domain-resolver.ts` — middleware factory.
- [x] 2.13 `src/routes/public-routes.ts` — public OpenAPI router.
- [x] 2.14 `src/routes/private-routes.ts` — private OpenAPI router.
- [x] 2.15 `src/plugin/plugin.ts` — `createSitePlugin` via `definePlugin<SitePluginConfig>`.
- [x] 2.16 `src/services/registry-augmentation.ts` — `ServiceRegistry` slots.
- [x] 2.17 `src/index.ts` — explicit named re-exports.
- [x] 2.18 `surql/tables/site.surql` — table + `fn::domain::search`.
## 3. Tests
- [x] 3.1 `src/error-codes/error-codes.test.ts` — registry shape + `SiteError` preserves cause.
- [x] 3.2 `src/otel/instruments.test.ts` — cache + rebind against real `MeterProvider`.
- [x] 3.3 `src/schemas/options.test.ts`, `site.test.ts`, `domain.test.ts`, `push.test.ts`.
- [x] 3.4 `src/service/normalize-domain.test.ts`.
- [x] 3.5 `src/service/domain-resolver.test.ts` — hit/miss/error envelopes, normalisation, `resolveOrThrow`.
- [x] 3.6 `src/service/site.test.ts` — every method, every error path.
- [x] 3.7 `src/middleware/domain-resolver.test.ts` — Hono integration.
- [x] 3.8 `src/routes/public-routes.test.ts`, `private-routes.test.ts`.
- [x] 3.9 `src/plugin/plugin.test.ts` — lifecycle, event wiring, route mount, collision detection.
- [x] 3.10 `src/api-plugin-site.spec-conformance.test.ts` — public-surface re-export check.
- [x] 3.11 Every `it(...)` carries `{ timeout: 5000 }`.
- [x] 3.12 Every test imports from `@suaveplan/testing/runner`.
## 4. Documentation
- [x] 4.1 Sibling `.md` for every non-barrel, non-test, non-types, non-augmentation `.ts`.
- [x] 4.2 Root `README.md` lists every module link.
## 5. Pre-archive gates
- [ ] 5.1 `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-site` green.
- [ ] 5.2 `bunx turbo test:coverage --filter=@suaveplan/api-plugin-site` ≥ 100% on every metric.
- [ ] 5.3 `bunx turbo build --filter=@suaveplan/api-plugin-site` green.
- [ ] 5.4 Banned-pattern scan returns no hits.
- [ ] 5.5 Barrel `export *` scan returns no hits in `<feature>/index.ts`.
- [ ] 5.6 Test-runner import scan returns no hits.
- [ ] 5.7 Sibling `.md` scan returns no missing-doc hits.
- [ ] 5.8 No bare versions in `package.json`.
- [ ] 5.9 Subpath export count matches feature-module count.
## 6. Archive
- [ ] 6.1 Fold `specs/api-plugin-site/spec.md` into `openspec/specs/api-plugin-site/spec.md`.
- [ ] 6.2 `mv openspec/changes/add-api-plugin-site openspec/archive/2026-05-19-add-api-plugin-site`.