# @suaveplan/api-plugin-campaigns - Campaigns + suppression + delivery-webhooks HTTP plugin for @suaveplan/api. Mounts /campaigns, /suppression, and /webhooks on a Hono OpenAPI registry, backed by SurrealDB implementations of @suaveplan/campaigns CampaignStore and a local CampaignSuppressionStore, plus the @suaveplan/delivery-tracking SurrealDeliveryEventStore. Chunked migration (A: foundation, B: repositories, C: routes). Campaigns + suppression + delivery-webhooks HTTP plugin for `@suaveplan/api`. Mounts the `/campaigns`, `/suppression`, and `/webhooks` route trees on a Hono `OpenAPIHono` registry, backed by SurrealDB implementations of the universal `@suaveplan/campaigns` `CampaignStore`, a local `CampaignSuppressionStore`, and the already-shipped `@suaveplan/delivery-tracking` `SurrealDeliveryEventStore`. ## Documentation tree - [context](./src/context/context.md) — The `context` module owns the Hono `ContextVariableMap` declaration-merge augmentation applied by `@suaveplan/api-plugi… - [context](./src/context/context.md) — The `context` module owns the Hono `ContextVariableMap` declaration-merge augmentation applied by `@suaveplan/api-plugi… - [error-codes](./src/error-codes/error-codes.md) — The error-codes module owns the stable `CAMPAIGNS_API.*` namespace used by every failure path inside `@suaveplan/api-pl… - [error-codes](./src/error-codes/error-codes.md) — The error-codes module owns the stable `CAMPAIGNS_API.*` namespace used by every failure path inside `@suaveplan/api-pl… - [otel](./src/otel/instruments.md) — The `otel/instruments` module owns the OpenTelemetry instrument bundle emitted by `@suaveplan/api-plugin-campaigns`. It… - [instruments](./src/otel/instruments.md) — The `otel/instruments` module owns the OpenTelemetry instrument bundle emitted by `@suaveplan/api-plugin-campaigns`. It… - [plugin](./src/plugin/plugin.md) — The `plugin` module exports `createCampaignsPlugin` — the `PluginDescriptor` factory consumed by `@suaveplan/api` hosts… - [plugin](./src/plugin/plugin.md) — The `plugin` module exports `createCampaignsPlugin` — the `PluginDescriptor` factory consumed by `@suaveplan/api` hosts… - [campaign](./src/repositories/campaign/campaign.md) — This module owns the SurrealDB-backed implementation of the campaign persistence contract for `@suaveplan/api-plugin-ca… - [campaign](./src/repositories/campaign/campaign.md) — This module owns the SurrealDB-backed implementation of the campaign persistence contract for `@suaveplan/api-plugin-ca… - [suppression](./src/repositories/suppression/suppression.md) — This module owns the SurrealDB-backed implementation of the tenant + channel-scoped `CampaignSuppressionStore` interfac… - [suppression-internals](./src/repositories/suppression/suppression-internals.md) — This module owns the validation and mapping primitives shared by the two `CampaignSuppressionStore` implementations — `… - [suppression-memory](./src/repositories/suppression/suppression-memory.md) — In-memory reference implementation of the tenant + channel-scoped `CampaignSuppressionStore` interface. Intended for un… - [suppression](./src/repositories/suppression/suppression.md) — This module owns the SurrealDB-backed implementation of the tenant + channel-scoped `CampaignSuppressionStore` interfac… - [action-routes](./src/routes/campaigns/action-routes.md) — This module owns the campaign action routes — state-machine transitions (`/send`, `/pause`, `/cancel`), the `/duplicate… - [build-routes](./src/routes/campaigns/build-routes.md) — `buildCampaignRoutes` is the single aggregator that materialises every `/campaigns/*` `PluginRouteEntry` in a canonical… - [crud-routes](./src/routes/campaigns/crud-routes.md) — This module owns the five canonical CRUD entries for the `/campaigns` route tree: list, create, get, update, and delete… - [schemas](./src/routes/campaigns/schemas.md) — This module is the OpenAPI-facing contract for the `/campaigns` route tree. Every incoming request body, query string,… - [require-tenant](./src/routes/shared/require-tenant.md) — `requireTenant` extracts the request principal from the Hono context slot `c.get("user")` (populated by `@suaveplan/api… - [strip-undefined](./src/routes/shared/strip-undefined.md) — `stripUndefined` is a route-layer adapter that bridges Zod's `optional()` output (`T | undefined`) with the `exactOptio… - [build-routes](./src/routes/suppression/build-routes.md) — `buildSuppressionRoutes` aggregates the four `/suppression/*` plugin route entries in canonical order (list, check, cre… - [routes](./src/routes/suppression/routes.md) — The suppression-route module owns the four endpoints that manage the `(tenantId, channel, channelValue)`-keyed suppress… - [schemas](./src/routes/suppression/schemas.md) — The suppression-route schemas describe the OpenAPI contract for the `/suppression` route tree. The package's local `Cam… - [build-routes](./src/routes/webhooks/build-routes.md) — `buildWebhookRoutes` aggregates the two `/webhooks/*` route entries in canonical order — delivery ingest first, then on… - [routes](./src/routes/webhooks/routes.md) — The webhook-route module owns the two webhook endpoints: a delivery event ingestion endpoint that normalises and persis… - [schemas](./src/routes/webhooks/schemas.md) — The webhook-route schemas describe the OpenAPI contract for the `/webhooks` route tree, plus a `decodeUnsubscribeToken`… - [schemas](./src/schemas/options.md) — The `schemas/options` module owns the Zod validator that `createCampaignsPlugin` runs against its caller-supplied optio… - [options](./src/schemas/options.md) — The `schemas/options` module owns the Zod validator that `createCampaignsPlugin` runs against its caller-supplied optio… - [services](./src/services/registry-augmentation.md) — The `services/registry-augmentation` module owns the `ServiceRegistry` declaration-merge augmentation applied by `@suav… - [registry-augmentation](./src/services/registry-augmentation.md) — The `services/registry-augmentation` module owns the `ServiceRegistry` declaration-merge augmentation applied by `@suav… - [types](./src/types/types.md) — The `types` module exports the public type bundle for `@suaveplan/api-plugin-campaigns` — the option-input shape consum… - [types](./src/types/types.md) — The `types` module exports the public type bundle for `@suaveplan/api-plugin-campaigns` — the option-input shape consum… ## Chunked migration status This package is being being migrated in three sequential chunks so each ships green on its own: - **Chunk A — foundation (this version)** — package shell, error codes, OTel instruments, Zod options schema, shared types, plugin scaffold with a no-op `onInit` placeholder. - **Chunk B — repositories** (follow-up) — `SurrealCampaignRepository`, `CampaignSuppressionStore` + Surreal implementation, delivery-event store wiring, schema DDL bundle, repository registration on the host `ServiceRegistry`. - **Chunk C — routes** (follow-up) — `/campaigns`, `/suppression`, and `/webhooks` route trees registered via `definePluginRoutes`, integration tests against a SurrealDB testcontainer. ## Quality gates `bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-campaigns` plus `bunx turbo test:coverage --filter=@suaveplan/api-plugin-campaigns` at 100/100/100/100 are required for every chunk to land.