Commit Graph

73 Commits

Author SHA1 Message Date
Jake Barnby 68c354e09b refactor(insights): nest insights API under reports
Insights are children of reports — make the URL hierarchy reflect that.

Endpoints:
- POST   /v1/manager/reports/:reportId/insights        (manager Create)
- GET    /v1/reports/:reportId/insights                (List)
- GET    /v1/reports/:reportId/insights/:insightId     (Get)
- PATCH  /v1/reports/:reportId/insights/:insightId     (Update)
- DELETE /v1/reports/:reportId/insights/:insightId     (Delete)

`reportId` moves from optional body field to required path param. All
endpoints fetch the report first (404 REPORT_NOT_FOUND if missing or
in another project), then verify the insight's `reportInternalId`
matches before doing anything else.

Side effects:
- Event names nested: `reports.[reportId].insights.[insightId].create`
  etc. Top-level `insights.*` event tree removed from events.php.
- Realtime channel parser handles the nested form: a `reports.{rid}`
  event lights up `reports`, `reports.{rid}` channels; a nested
  `reports.{rid}.insights.{iid}` event also lights up
  `reports.{rid}.insights` and `reports.{rid}.insights.{iid}`.
- Audit resource paths nested similarly:
  `report/{request.reportId}/insight/{response.$id}`.
- listInsights query validator drops `reportId` from
  ALLOWED_ATTRIBUTES — it's path-scoped now, not a query filter.

Tests:
- E2E helpers `createInsight`/`getInsight`/`listInsights`/
  `updateInsight`/`deleteInsight` all take `reportId` as the first
  argument.
- New `createFixtureReport()` helper for standalone validation tests
  that need a parent.
- Dropped `testCreateWithoutReport` — reportId is mandatory now.
- `testCreateRejectsUnknownReport` now exercises the path-level 404
  rather than a body-level check.
- `testGet` and `testUpdateMissing` exercise the
  wrong-reportId-but-valid-insightId case (returns
  `report_not_found`).
- `testList` asserts every result carries the path's reportId, plus a
  404 case for a nonexistent parent.
- `testCreateForEachEngine` and the standalone create-rejection tests
  inline-create their own fixture report and clean up after.
- `testListSurvivesEmptyDatabase` renamed to
  `testListSurvivesEmptyReport` and uses a fresh fixture report.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 18:53:54 +12:00
Jake Barnby 00565ea471 refactor(insights): metadata-only CTAs, platform DB, reports parent
Address review feedback on PR #12194:

- Pivot CTAs to pure descriptors (id/label/action/params). Drop the
  server-side execution layer: Action interface, registry, the
  databases.indexes.create CTA action, the params validator, the
  /v1/insights/:id/ctas/:id/executions endpoint, the InsightCTAExecution
  model, the INSIGHT_CTA_* errors, and the corresponding events. The
  console invokes the existing public API directly with the descriptor's
  action + params.

- Restore Databases\Indexes\Action.php to its pre-CTA shape and inline
  the index-create body back into Create.php (the createIndex helper
  was added solely for CTA reuse).

- Move insights collection from project DB to platform DB and add a
  parent reports collection alongside it. Insights carry projectId /
  projectInternalId for tenant scoping and an optional reportId for
  grouping. List endpoints filter by projectInternalId; Get/Update/
  Delete also enforce project ownership before touching the document.

- New Reports module with full CRUD (Create/Get/XList/Update/Delete),
  Report response model, Reports query validator, REPORT_NOT_FOUND /
  REPORT_ALREADY_EXISTS errors, reports.read / reports.write scopes,
  and reports.* event tree. Delete cascades to child insights.

- Update.php now mutates the loaded document via setAttribute (instead
  of passing a partial new Document), reuses CTAsValidator (instead of
  the looser ArrayList<JSON> + isset check), and rejects duplicate CTA
  ids.

- Create.php enforces unique CTA ids during normalization.

- CTAsValidator gained a configurable maxCount (default 16) so the
  Create path matches the Update path and the DB column size, and
  oversized payloads return a clean 400.

- Validator\Queries\Insights adds status and reportId to
  ALLOWED_ATTRIBUTES so dismissal / report workflows are filterable.

- Realtime channel parser guards $parts[1] for both insights and
  reports event names.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 13:46:07 +12:00
Jake Barnby f779c7aa3b refactor(insights): collapse dismissal into a status field on update
Dismissal was a sub-resource (POST /v1/insights/:id/dismissals) but a
dismissal is just a state transition, not a thing the client creates.
Drop the dedicated endpoint and add a `status` enum (`active` |
`dismissed`) to the insights schema, settable via the existing PATCH
update route. The server still derives `dismissedAt` and `dismissedBy`
on transition for audit/sorting, but the client-facing API is just a
single status toggle.

- Schema: add `status` attribute (default `active`)
- Constants: add `INSIGHT_STATUSES`
- Update endpoint: accept `status` param, derive dismissedAt/By on
  active <-> dismissed transitions
- Response model: add `status` rule
- Drop Insights/Dismissal/Create.php, the createInsightDismissal SDK
  method, the `insights.[id].dismissals.create` event, and the
  `insight.dismissal.create` audit
- E2E: replace testCreateDismissal with testDismissViaUpdate covering
  both directions of the toggle

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 14:36:31 +12:00
Jake Barnby da5a137b98 refactor(insights): nest CTA execution and dismissal as sub-resources
Move POST /v1/insights/:id/dismiss to /v1/insights/:id/dismissals
and POST /v1/insights/:id/ctas/:ctaId/trigger to
/v1/insights/:id/ctas/:ctaId/executions, with the corresponding
class moves into Http/Insights/Dismissal/Create.php and
Http/CTA/Execution/Create.php. Rename the response model to
InsightCtaExecution and update events.php to surface dismissal
and execution as resource events with create verbs. The reshape
matches the rest of the API where verbs hang off plural sub-resources.
2026-05-01 14:04:31 +12:00
Jake Barnby e1ddcd051c feat(insights): add schema, scopes, events, errors, constants
Wires the platform glue for insights: the `insights` collection on the
project database, the `insights.read` / `insights.write` scopes, the
`insights.[insightId]` event tree (including the nested `ctas.[ctaId].trigger`
event), the typed exceptions, and the runtime CTA registry resource.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:40:28 +12:00
Prem Palanisamy e1c35c743c Add data field to Schedule response model and remove unused events 2026-02-18 06:23:19 +00:00
Prem Palanisamy 3fde05e024 Add resource validation, admin scopes, and events for schedules 2026-02-18 06:23:19 +00:00
Jake Barnby dace50d9b7 Add missing attribute/index update events 2025-08-15 20:03:38 +12:00
Jake Barnby a5e9fbf362 Add grids upsert event 2025-08-15 19:54:01 +12:00
Jake Barnby b38ac866b8 Merge remote-tracking branch 'origin/1.7.x' into 1.8.x
# Conflicts:
#	app/controllers/api/databases.php
#	composer.lock
2025-08-15 19:28:49 +12:00
Jake Barnby 6043cc2fc9 Add upsert event 2025-08-14 17:34:56 +12:00
Darshan fcdddf7bf0 address comments. 2025-06-11 12:21:48 +05:30
Darshan f2f23be648 update: events, errors, realtime. 2025-05-07 14:11:28 +05:30
Darshan 8610687b87 update: events schema, response models for database usages. 2025-05-07 13:23:27 +05:30
Darshan 46ccf6f537 update: re-add legacy models; remove: filters. 2025-05-07 11:13:15 +05:30
Darshan 7a53680786 update: document response model to row; refactor: old collection to table models on response types. 2025-05-05 09:42:33 +05:30
Darshan 675d404b9b update: attribute* response model to column*. 2025-05-05 09:30:27 +05:30
Darshan 949f58522d change: events system. 2025-04-27 10:33:44 +05:30
Khushboo Verma 5b0a05b4b3 Create site endpoint working 2024-10-22 17:01:38 +02:00
loks0n 77b1762514 chore: fix token event 2024-01-16 10:40:49 +00:00
prateek banga c2cd544948 review changes 2023-10-26 13:46:45 +05:30
prateek banga fd4a81c4fc made review changes 2023-10-25 23:03:23 +05:30
Prateek Banga a92390dda2 review changes 2023-10-06 19:23:46 +05:30
Prateek Banga 25fc64c4ab moves provider to top level in events config 2023-09-15 02:28:32 +05:30
prateek banga 0534b11b32 Merge branch 'feat-add-messaging-response-models' into feat-messages-event-config 2023-08-31 18:26:32 +05:30
prateek banga 296a54d0ce adds messages event config and target attribute in user model 2023-08-14 21:11:24 +05:30
Matej Bačo 906f86fbb8 Merge branch 'cloud-1.4.x' into feat-git-integration 2023-08-06 09:31:32 +02:00
Torsten Dittmann 818d111068 fix: wrong team event descriptions 2023-03-23 10:52:43 +01:00
Torsten Dittmann 348c2d4ffe Update app/config/events.php
Co-authored-by: Christy Jacob <christyjacob4@gmail.com>
2023-03-15 12:11:46 +01:00
Matej Baco 4b0d6d9826 Bug fixes after proxy QA 2023-03-10 12:20:24 +00:00
Torsten Dittmann 4f08d8e82a Apply suggestions from code review
Co-authored-by: Vincent (Wen Yu) Ge <vincent@appwrite.io>
2023-03-09 02:09:03 +05:30
Torsten Dittmann 496da61cd9 feat: team preferences 2023-03-06 19:54:02 +05:30
Toir Tuychiev fd9d300654 Fixed typo in events.php
accessiable -> accessible
2022-09-17 21:27:32 +05:00
Damodar Lohani 8f14f5aa21 Database layer (#3338)
* database response model

* database collection config

* new database scopes

* database service update

* database execption codes

* remove read write permission from database model

* updating tests and fixing some bugs

* server side tests are now passing

* databases api

* tests for database endpoint

* composer update

* fix error

* formatting

* formatting fixes

* get database test

* more updates to events and usage

* more usage updates

* fix delete type

* fix test

* delete database

* more fixes

* databaseId in attributes and indexes

* more fixes

* fix issues

* fix index subquery

* fix console scope and index query

* updating tests as required

* fix phpcs errors and warnings

* updates to review suggestions

* UI progress

* ui updates and cleaning up

* fix type

* rework database events

* update tests

* update types

* event generation fixed

* events config updated

* updating context to support multiple

* realtime updates

* fix ids

* update context

* validator updates

* fix naming conflict

* fix tests

* fix lint errors

* fix wprler and realtime tests

* fix webhooks test

* fix event validator and other tests

* formatting fixes

* removing leftover var_dumps

* remove leftover comment

* update usage params

* usage metrics updates

* update database usage

* fix usage

* specs update

* updates to usage

* fix UI and usage

* fix lints

* internal id fixes

* fixes for internal Id

* renaming services and related files

* rename tests

* rename doc link

* rename readme

* fix test name

* tests: fixes for 0.15.x sync

Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
2022-06-22 12:51:49 +02:00
Torsten Dittmann ec22aa3dfe style: remove whitespace 2022-04-20 15:38:43 +02:00
Torsten Dittmann d85c341875 fix: events config 2022-04-20 15:34:55 +02:00
Torsten Dittmann 7790d72c0c fix: realtime, tests and webhooks 2022-04-18 18:21:45 +02:00
Torsten Dittmann 2f9b9445dd sync with devices 2022-04-04 08:30:07 +02:00
Christy Jacob 3c65d40234 Merge branch '0.13.x' of github.com:appwrite/appwrite into feat-functions-refactor-merge 2022-02-18 15:16:10 +04:00
Christy Jacob 4ad47061dd Merge branch 'master' of github.com:appwrite/appwrite into feat-functions-refactor 2022-02-18 13:38:54 +04:00
Damodar Lohani d73d3015eb Merge branch 'master' into feat-storage-buckets 2022-02-10 01:20:16 +00:00
Matej Baco 4299ffa27e Tests fix 2022-02-04 10:19:14 +01:00
Matej Baco 3aa62b439b Implemented refresh token endpoint 2022-02-01 16:54:20 +01:00
Christy Jacob 8307c8d432 feat: rename tags response model to deployment 2022-01-25 02:54:13 +04:00
Christy Jacob 939a11d701 feat: rename tags to deployments in events.php 2022-01-25 02:40:49 +04:00
Damodar Lohani 3e78abfc85 Merge branch 'feat-database-indexing' into feat-storage-buckets 2021-10-17 11:38:33 +05:45
Torsten Dittmann 1ed41f52d3 Merge branch 'master' of https://github.com/appwrite/appwrite into sync-realtime-with-db-refactor 2021-09-30 12:32:10 +02:00
Damodar Lohani 91e13572a8 Merge branch 'feat-database-indexing' into feat-storage-buckets 2021-09-02 13:37:40 +05:45
Damodar Lohani 040dbcc9d5 Apply suggestions from code review
Co-authored-by: Eldad A. Fux <eldad.fux@gmail.com>
2021-08-30 16:31:40 +05:45
Damodar Lohani 27b00b3619 update events 2021-08-30 11:56:07 +05:45