Initial Commit
This commit is contained in:
77
openspec/changes/enterprise-api-plugin-site/proposal.md
Normal file
77
openspec/changes/enterprise-api-plugin-site/proposal.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# OpenSpec Change: enterprise-api-plugin-site
|
||||
|
||||
- **Change ID**: enterprise-api-plugin-site
|
||||
- **Package**: `@suaveplan/api-plugin-site`
|
||||
- **Category**: api/content
|
||||
- **Target path**: `api/content/api-plugin-site`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/api-plugin-site.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/api-plugin-site` on the genesis branch from scratch at enterprise quality. Site management plugin: multi-site configuration (custom domains, SSL status, theme/branding), page tree (parent/child hierarchy, SEO metadata, canonical URLs), navigation menus, redirect rules, sitemap generation via `@suaveplan/sitemap`, and robots.txt management. Routes under `/sites`. Per-table SurrealQL. Typed events: `site:published`, `site:domain:changed`, `site:page:created`.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps on genesis
|
||||
|
||||
| Package | Role |
|
||||
|---|---|
|
||||
| `@suaveplan/api` (`workspace:^`) | `definePlugin` |
|
||||
| `@suaveplan/api-shared` (`workspace:^`) | Helpers |
|
||||
| `@suaveplan/api-plugin-auth` (`workspace:^`) | `requireAuth`, `requireRole` |
|
||||
| `@suaveplan/api-plugin-database` (`workspace:^`) | SurrealDB |
|
||||
| `@suaveplan/sitemap` (`workspace:^`) | Sitemap XML generation |
|
||||
| `@suaveplan/domain-normalizer` (`workspace:^`) | Domain validation |
|
||||
| `@suaveplan/events` (`workspace:^`) | Event bus |
|
||||
| `@suaveplan/error` (`workspace:^`) | `SiteError` hierarchy |
|
||||
| `@suaveplan/audit-logging` (`workspace:^`) | Site change audit |
|
||||
| `hono` + `@hono/zod-openapi` + `zod` | Routes |
|
||||
| `@opentelemetry/api` | OTel |
|
||||
|
||||
---
|
||||
|
||||
## Public API surface
|
||||
|
||||
```ts
|
||||
function createSitePlugin(config?: SitePluginConfig): PluginDescriptor
|
||||
// Services: SiteService, PageService, NavigationService, RedirectService, SitemapService
|
||||
// Routes: /sites, /sites/:id, /sites/:id/pages, /sites/:id/navigation,
|
||||
// /sites/:id/redirects, /sites/:id/sitemap.xml, /sites/:id/robots.txt
|
||||
```
|
||||
|
||||
### Error codes
|
||||
|
||||
```ts
|
||||
type SiteErrorCode =
|
||||
| "SITE_NOT_FOUND"
|
||||
| "SITE_DOMAIN_TAKEN"
|
||||
| "SITE_PAGE_NOT_FOUND"
|
||||
| "SITE_REDIRECT_LOOP"
|
||||
| "SITE_SLUG_CONFLICT"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
api/content/api-plugin-site/
|
||||
package.json tsconfig.json vitest.config.ts
|
||||
surql/ (site, page, navigation_menu, redirect tables)
|
||||
src/
|
||||
index.ts events.ts types/ errors/
|
||||
services/site/ services/page/ services/navigation/
|
||||
services/redirect/ services/sitemap/
|
||||
routes/sites/
|
||||
tests/integration.test.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Impact
|
||||
|
||||
Prerequisites: `@suaveplan/api`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/sitemap`, `@suaveplan/domain-normalizer`.
|
||||
58
openspec/changes/enterprise-api-plugin-site/tasks.md
Normal file
58
openspec/changes/enterprise-api-plugin-site/tasks.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Tasks: enterprise-api-plugin-site
|
||||
|
||||
**Change ID**: enterprise-api-plugin-site
|
||||
**Package**: `@suaveplan/api-plugin-site`
|
||||
**Target path**: `api/content/api-plugin-site`
|
||||
**Prerequisite packages on Verdaccio**: `@suaveplan/api`, `@suaveplan/api-shared`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/sitemap`, `@suaveplan/domain-normalizer`, `@suaveplan/events`, `@suaveplan/audit-logging`, `@suaveplan/error`
|
||||
|
||||
---
|
||||
|
||||
## 0. Pre-flight (non-negotiable)
|
||||
|
||||
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
|
||||
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
|
||||
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
|
||||
|
||||
## 1. Scaffold + types + errors + events
|
||||
|
||||
- [ ] Create `api/content/api-plugin-site/`; `package.json` v0.0.0; standard tooling.
|
||||
- [ ] Types: `Site`, `Page`, `NavigationMenu`, `NavigationItem`, `Redirect`, `SitePluginConfig` (Zod).
|
||||
- [ ] Errors: 5-code union + metadata + registration. Test + doc.
|
||||
- [ ] Events: `SiteEventMap` (site:published, site:domain:changed, site:page:created, site:page:deleted).
|
||||
|
||||
---
|
||||
|
||||
## 2. SurrealQL
|
||||
|
||||
- [ ] `site.surql`, `page.surql`, `navigation_menu.surql`, `redirect.surql`. All with tenantId indexes.
|
||||
|
||||
---
|
||||
|
||||
## 3. Services (each `.test.ts` + `.md`)
|
||||
|
||||
- [ ] **SiteService**: `createSite`, `getSite`, `updateSite`, `deleteSite`, `listSites`. Domain uniqueness enforced via `@suaveplan/domain-normalizer`. Audit domain changes.
|
||||
- [ ] **PageService**: `createPage`, `updatePage`, `deletePage`, `listPages` (tree order), `getBySlug`. Slug conflict detection.
|
||||
- [ ] **NavigationService**: `getMenu`, `updateMenu` (ordered list of nav items linking to pages or external URLs).
|
||||
- [ ] **RedirectService**: `addRedirect`, `removeRedirect`, `listRedirects`. Cycle detection.
|
||||
- [ ] **SitemapService**: `generateSitemap()` → `@suaveplan/sitemap` builder; cache result.
|
||||
|
||||
---
|
||||
|
||||
## 4. Routes
|
||||
|
||||
- [ ] `GET/POST /sites`, `GET/PATCH/DELETE /sites/:id` — auth + `requireRole("ADMIN")`.
|
||||
- [ ] `GET/POST /sites/:id/pages`, `GET/PATCH/DELETE /sites/:id/pages/:pageId`.
|
||||
- [ ] `GET/PATCH /sites/:id/navigation`.
|
||||
- [ ] `GET/POST/DELETE /sites/:id/redirects`.
|
||||
- [ ] `GET /sites/:id/sitemap.xml`, `GET /sites/:id/robots.txt` — public.
|
||||
- [ ] Route `.test.ts` + `.md`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Plugin factory + integration tests + publish
|
||||
|
||||
- [ ] `createSitePlugin`: `definePlugin`, `dependencies: ["database", "auth"]`, `migrationsPath: "./surql"`.
|
||||
- [ ] Integration: create site → add pages → generate sitemap → update navigation (real SurrealDB).
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-site` — green; 100% coverage.
|
||||
- [ ] `bun scripts/publish.ts --package @suaveplan/api-plugin-site`.
|
||||
- [ ] Archive → `openspec/archive/2026-04-24-enterprise-api-plugin-site/`.
|
||||
Reference in New Issue
Block a user