Initial Commit
This commit is contained in:
57
openspec/changes/enterprise-api-plugin-campaigns/tasks.md
Normal file
57
openspec/changes/enterprise-api-plugin-campaigns/tasks.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Tasks: enterprise-api-plugin-campaigns
|
||||
|
||||
**Change ID**: enterprise-api-plugin-campaigns
|
||||
**Package**: `@suaveplan/api-plugin-campaigns`
|
||||
**Target path**: `api/comms/api-plugin-campaigns`
|
||||
**Prerequisite packages on Verdaccio**: `@suaveplan/api`, `@suaveplan/api-shared`, `@suaveplan/api-plugin-auth`, `@suaveplan/api-plugin-database`, `@suaveplan/api-plugin-contacts`, `@suaveplan/api-plugin-notifications`, `@suaveplan/templates`, `@suaveplan/suppression`, `@suaveplan/events`, `@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/comms/api-plugin-campaigns/`; `package.json` v0.0.0; standard tooling.
|
||||
- [ ] Types: `Campaign`, `CampaignRecipient`, `CampaignStats`, `Segment`, `SegmentFilter`, `CampaignsPluginConfig` (Zod).
|
||||
- [ ] Errors: 5-code union + metadata + registration. Test + doc.
|
||||
- [ ] Events: `CampaignEventMap` (campaign:started, campaign:completed, campaign:unsubscribed, campaign:bounced).
|
||||
|
||||
---
|
||||
|
||||
## 2. SurrealQL
|
||||
|
||||
- [ ] `campaign.surql`, `campaign_recipient.surql`, `campaign_stats.surql`. tenantId indexes.
|
||||
|
||||
---
|
||||
|
||||
## 3. Services (each `.test.ts` + `.md`)
|
||||
|
||||
- [ ] **CampaignService**: `createCampaign`, `updateCampaign`, `deleteCampaign`, `getCampaign`, `listCampaigns`, `scheduleCampaign`, `sendCampaign` (immediate or scheduled), `pauseCampaign`.
|
||||
- [ ] **SegmentService**: `buildSegment` — query contacts from `api-plugin-contacts` using filter rules; return contact list.
|
||||
- [ ] **DeliveryTrackingService**: track `sent/opened/clicked/bounced/unsubscribed` per recipient. `unsubscribe(token)` adds to suppression list + emits event.
|
||||
- [ ] **StatsService**: `getStats(campaignId)` — aggregate counts + rates.
|
||||
|
||||
---
|
||||
|
||||
## 4. Routes
|
||||
|
||||
- [ ] `GET/POST /campaigns`, `GET/PATCH/DELETE /campaigns/:id` — auth + `requireRole("MARKETER")`.
|
||||
- [ ] `POST /campaigns/:id/send` — auth + rate-limit + idempotency.
|
||||
- [ ] `GET /campaigns/:id/stats`, `GET /campaigns/:id/recipients` — auth.
|
||||
- [ ] `GET /campaigns/unsubscribe?token=...` — public (suppression + redirect).
|
||||
- [ ] Route `.test.ts` + `.md`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Plugin factory + integration tests + publish
|
||||
|
||||
- [ ] `createCampaignsPlugin`: `definePlugin`, `dependencies: ["database", "auth"]`, `migrationsPath: "./surql"`.
|
||||
- [ ] `onInit`: register services; start scheduler (interval for scheduled campaigns) with disposer captured for `onClose`.
|
||||
- [ ] Integration: create campaign → build segment → send → track open/click → unsubscribe (real SurrealDB).
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-campaigns` — green; 100% coverage.
|
||||
- [ ] `bun scripts/publish.ts --package @suaveplan/api-plugin-campaigns`.
|
||||
- [ ] Archive → `openspec/archive/2026-04-24-enterprise-api-plugin-campaigns/`.
|
||||
Reference in New Issue
Block a user