|
| 1 | +--- |
| 2 | +'@objectstack/spec': minor |
| 3 | +--- |
| 4 | + |
| 5 | +feat(spec)!: `RealtimeEventType` names the realtime events the runtime emits — `data.record.*` and `data.records.*`; `record.created` / `record.updated` / `record.deleted` / `field.changed` retired (#20288) |
| 6 | + |
| 7 | +Clause-②: yes (narrowing) |
| 8 | + |
| 9 | +**BREAKING** — shipped as `minor` under the launch-window convention |
| 10 | +(`check-changeset-no-major` refuses `major` until GA; breaking-ness is carried by |
| 11 | +this banner, the `(narrowing)` arm above and the ADR-0087 disposition below, |
| 12 | +never by the level). The enum both gains and loses values: it gains the five |
| 13 | +names the runtime emits and loses the four it never emitted. |
| 14 | + |
| 15 | +`RealtimeEventType` (`@objectstack/spec/api`) types `SubscriptionEvent.type`, so |
| 16 | +it is the event vocabulary of `Subscription.events[]` and |
| 17 | +`RealtimeConfig.subscriptions[].events[]`, and the generated API reference |
| 18 | +published it as such. None of its four values was ever emitted by anything. The |
| 19 | +ObjectQL engine publishes `data.record.created` / `data.record.updated` / |
| 20 | +`data.record.deleted` for each written record and `data.records.updated` / |
| 21 | +`data.records.deleted` for a predicate write (`multi: true`), and it parses every |
| 22 | +event through `DataEventSchema` / `BulkDataEventSchema` before publishing. A |
| 23 | +subscription written with the names the reference showed could never fire. |
| 24 | +The runtime's published event names do not change; the enum moves to them. |
| 25 | + |
| 26 | +- **Accepted now:** exactly `DataEventType` + `BulkDataEventType` — |
| 27 | + `data.record.created`, `data.record.updated`, `data.record.deleted`, |
| 28 | + `data.records.updated`, `data.records.deleted`. Metadata change events |
| 29 | + (`metadata.{type}.{action}`) are not members: a subscription event is |
| 30 | + record-shaped, and metadata events keep their own `MetadataEventType` contract |
| 31 | + and `subscribeMetadata` client primitive. |
| 32 | +- **Refused now:** `record.created`, `record.updated`, `record.deleted` and |
| 33 | + `field.changed`, each with its own prescription. Any other unknown value keeps |
| 34 | + zod's own message, which lists the legal names. |
| 35 | + |
| 36 | +``` |
| 37 | +FROM SubscriptionSchema.parse({ id, transport: 'websocket', events: [{ type: 'record.created', object: 'account' }] }) |
| 38 | + -> parsed; nothing ever published 'record.created', so the subscription never fired |
| 39 | +TO -> ZodError at events[0].type (invalid_value): `record.created` was removed from |
| 40 | + `RealtimeEventType` in @objectstack/spec 17.5.0 (ADR-0049 enforce-or-remove) — … Write |
| 41 | + `data.record.created` — the same event, spelled the way the engine publishes it. |
| 42 | +
|
| 43 | +FROM { type: 'record.updated' } -> TO { type: 'data.record.updated' } |
| 44 | + (add { type: 'data.records.updated' } to also hear predicate writes, which carry a count, not records) |
| 45 | +FROM { type: 'record.deleted' } -> TO { type: 'data.record.deleted' } |
| 46 | + (add { type: 'data.records.deleted' } to also hear predicate writes) |
| 47 | +FROM { type: 'field.changed' } -> TO { type: 'data.record.updated' } |
| 48 | + (read the field from the DataEvent payload's `changes`; no event is published per field) |
| 49 | +``` |
| 50 | + |
| 51 | +**Fix.** Rename each value as mapped above. `tsc` refuses the old values at a |
| 52 | +`RealtimeEventType` / `SubscriptionEvent` position (the type no longer contains |
| 53 | +them), and a `SubscriptionSchema`, `SubscriptionEventSchema` or |
| 54 | +`RealtimeConfigSchema` parse refuses them with the prescription. A handler keyed |
| 55 | +on an old name never ran, so the rename changes behaviour only by making it fire. |
| 56 | +Nothing in the open framework parses a subscription today — it mounts no realtime |
| 57 | +transport — so no running deployment changes behaviour. |
| 58 | + |
| 59 | +### The kit |
| 60 | + |
| 61 | +- **Schema.** `RealtimeEventType` lists the five emitted names; its error map |
| 62 | + gives each retired value its own prescription (the `HookBodyCapability` |
| 63 | + precedent for a removed enum value). `realtime.test.ts` pins the enum equal to |
| 64 | + `DataEventType` + `BulkDataEventType`, and pins each refusal's code, path and |
| 65 | + first sentence through `SubscriptionSchema`. |
| 66 | +- **ADR-0087.** The D3 entry `realtime-event-type-unemitted-values-retired` |
| 67 | + carries the prescription to `os migrate meta` and the upgrade guide. No D2 |
| 68 | + conversion and no `RETIRED_KEYS_BY_MAJOR` row: an enum value is not a key, and |
| 69 | + a subscription is neither a stack collection member nor a stored row, so no |
| 70 | + conversion seam would ever see one. |
| 71 | +- **Docs.** The `realtime` reference page is regenerated; the |
| 72 | + `RealtimeEventPayload.type` and `RealtimeEvent.type` examples name emitted |
| 73 | + events. |
| 74 | + |
| 75 | +<!-- adr-0087: registered realtime-event-type-unemitted-values-retired --> |
0 commit comments