mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Embedding CTAs as a 16384-byte JSON blob on `insights` was the wrong shape — they're real documents with their own lifecycle. Move them out. Schema: - New platform `ctas` collection. Each row carries `projectInternalId`, `projectId`, `insightInternalId`, `insightId` (backref), plus the CTA fields: `key`, `label`, `service`, `method`, `params`. - Indexes: `(projectInternalId, insightInternalId)` for the subquery lookup and a UNIQUE `(insightInternalId, key)` so the per-insight uniqueness invariant lives at the DB layer (not just in PHP). - The `ctas` field on `insights` becomes a virtual attribute backed by a new `subQueryInsightCTAs` filter that joins child docs at read time. Consumers still get CTAs embedded on the insight response — one round-trip from their perspective. - The CTA descriptor's within-insight identifier renamed `id` → `key` (clashed with the document `$id`). Validator updated. Endpoints: - Manager Create now persists CTAs as separate `ctas` documents after the parent insight, then re-fetches the insight so the response carries the freshly-joined CTA list. - User Update trimmed to user-controlled state only (`severity`, `status`). `title`, `summary`, `payload`, `ctas`, and `analyzedAt` are analyzer-controlled — analyzers re-ingest by deleting and POSTing again to the manager endpoint. - Insight Delete cascades to CTAs. - Report Delete cascades through Insights → CTAs. Response model: - InsightCTA gains the standard document headers (`$id`, `$createdAt`, `$updatedAt`) and an `insightId` backref. The caller-supplied identifier is now `key`. Tests: - E2E sampleCTA factory uses `key` everywhere; testCreate asserts the freshly-created CTA carries `$id`, `$createdAt`, `insightId`, and the right shape. - Dropped the testUpdate*CTA* tests — user Update no longer accepts CTAs. testDismissViaUpdate now depends on testUpdate directly. - Unit tests rewritten to validate `key` instead of `id`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| filters.php | ||
| formats.php | ||