# 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/`.