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,77 @@
# OpenSpec Change: enterprise-api-plugin-events
- **Change ID**: enterprise-api-plugin-events
- **Package**: `@suaveplan/api-plugin-events`
- **Category**: api/content
- **Target path**: `api/content/api-plugin-events`
- **Status**: PROPOSED
- **Date**: 2026-04-24
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/api-plugin-events.md`
---
## Summary
Deliver `@suaveplan/api-plugin-events` on the genesis branch from scratch at enterprise quality. Calendar/events plugin: event management (create/update/cancel), recurring event rules (RRule subset via `@suaveplan/datetime`), RSVP/attendance tracking, venue management, capacity limits, ticketing hooks, and an iCal feed export. Routes under `/events`. Per-table SurrealQL. Typed bus events: `calendar:event:created`, `calendar:event:cancelled`, `calendar:rsvp:confirmed`. Distinct from `@suaveplan/events` (the typed event bus package).
---
## Available workspace deps on genesis
| Package | Role |
|---|---|
| `@suaveplan/api` (`workspace:^`) | `definePlugin` |
| `@suaveplan/api-shared` (`workspace:^`) | Helpers |
| `@suaveplan/api-plugin-auth` (`workspace:^`) | `requireAuth` |
| `@suaveplan/api-plugin-database` (`workspace:^`) | SurrealDB |
| `@suaveplan/datetime` (`workspace:^`) | Timezone-aware dates, RRule recurrence |
| `@suaveplan/events` (`workspace:^`) | Event bus (the pub/sub package) |
| `@suaveplan/error` (`workspace:^`) | `CalendarError` hierarchy |
| `@suaveplan/audit-logging` (`workspace:^`) | Audit |
| `@suaveplan/rate-limiter` (`workspace:^`) | Rate limits |
| `hono` + `@hono/zod-openapi` + `zod` | Routes |
| `@opentelemetry/api` | OTel |
---
## Public API surface
```ts
function createEventsPlugin(config?: EventsPluginConfig): PluginDescriptor
// Services: CalendarEventService, VenueService, RsvpService, RecurrenceService
// Routes: /events, /events/:id, /events/:id/rsvp, /events/:id/attendance,
// /venues, /events/feed.ics
```
### Error codes
```ts
type CalendarErrorCode =
| "CALENDAR_EVENT_NOT_FOUND"
| "CALENDAR_VENUE_NOT_FOUND"
| "CALENDAR_EVENT_FULL"
| "CALENDAR_RSVP_DUPLICATE"
| "CALENDAR_EVENT_CANCELLED"
| "CALENDAR_INVALID_RECURRENCE"
```
---
## File layout
```text
api/content/api-plugin-events/
package.json tsconfig.json vitest.config.ts
surql/ (calendar_event, venue, rsvp, attendance tables)
src/
index.ts events.ts types/ errors/
services/calendar-event/ services/venue/ services/rsvp/ services/recurrence/
routes/events/ routes/venues/
tests/integration.test.ts
```
---
## Impact
Prerequisites: `@suaveplan/api`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/datetime`.

View File

@@ -0,0 +1,57 @@
# Tasks: enterprise-api-plugin-events
**Change ID**: enterprise-api-plugin-events
**Package**: `@suaveplan/api-plugin-events`
**Target path**: `api/content/api-plugin-events`
**Prerequisite packages on Verdaccio**: `@suaveplan/api`, `@suaveplan/api-shared`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/datetime`, `@suaveplan/events`, `@suaveplan/audit-logging`, `@suaveplan/rate-limiter`, `@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-events/`; `package.json` v0.0.0; standard tooling.
- [ ] Types: `CalendarEvent`, `Venue`, `Rsvp`, `Attendance`, `RecurrenceRule`, `EventsPluginConfig` (Zod).
- [ ] Errors: 6-code union + metadata + registration. Test + doc.
- [ ] Events: `CalendarEventMap` (calendar:event:created, calendar:event:cancelled, calendar:rsvp:confirmed, calendar:event:started).
---
## 2. SurrealQL
- [ ] `calendar_event.surql`, `venue.surql`, `rsvp.surql`, `attendance.surql`. All with tenantId indexes + datetime indexes.
---
## 3. Services (each `.test.ts` + `.md`)
- [ ] **CalendarEventService**: `createEvent`, `updateEvent`, `cancelEvent`, `deleteEvent`, `listEvents` (date range filter), `getEvent`. Timezone handling via `@suaveplan/datetime`.
- [ ] **RecurrenceService**: expand recurring event rules into occurrence instances using `@suaveplan/datetime` RRule subset; store expansion on create.
- [ ] **VenueService**: CRUD + capacity tracking.
- [ ] **RsvpService**: `rsvp`, `cancelRsvp`, `listRsvps`. Capacity enforcement: `CalendarError(CALENDAR_EVENT_FULL)`.
---
## 4. Routes
- [ ] `GET/POST /events`, `GET/PATCH/DELETE /events/:id` — auth-gated write.
- [ ] `POST /events/:id/rsvp`, `DELETE /events/:id/rsvp` — `requireAuth` + rate-limit.
- [ ] `GET /events/:id/attendance` — auth.
- [ ] `GET/POST /venues`, `PATCH/DELETE /venues/:id` — auth.
- [ ] `GET /events/feed.ics` — public; iCal format.
- [ ] Route `.test.ts` + `.md`.
---
## 5. Plugin factory + integration tests + publish
- [ ] `createEventsPlugin`: `definePlugin`, `dependencies: ["database", "auth"]`, `migrationsPath: "./surql"`.
- [ ] Integration: create event (recurring) → RSVP → capacity hit → iCal feed (real SurrealDB).
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-events` — green; 100% coverage.
- [ ] `bun scripts/publish.ts --package @suaveplan/api-plugin-events`.
- [ ] Archive → `openspec/archive/2026-04-24-enterprise-api-plugin-events/`.