Skip to content

Commit 21e96f3

Browse files
committed
refactor(objectql): move the realtime publish bodies out of engine.ts
Cut 4 of the engine.ts split. The bodies of the private ObjectQL#publishDataEvent and #publishBulkDataEvent move unedited into packages/objectql/src/engine-realtime-publish.ts, reached through RealtimePublishHost (realtimeService, logger and _registry as getters). The module-level event helpers only those two call (generateEventUuid through eventMatchedCount, accessibleOrganizationsOf excepted) move with them byte for byte. Each method keeps its name, signature, docblock and position. The three path readers of the moved code follow it: the engine-data-events source pin, the federated injected-column readers ledger key, and the realtime-protocol docs page. Claude-Session: https://claude.ai/code/session_017kEHq65soeg6DRE9DDutT2 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f00e8d5 commit 21e96f3

5 files changed

Lines changed: 539 additions & 416 deletions

File tree

‎content/docs/protocol/kernel/realtime-protocol.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ They are camelCase, and the record body travels **inside `payload`**, never at t
432432
and `payload`, so a client written from the old fences reads `msg.subscription_id` and `msg.data`
433433
and gets `undefined` on both. `changes` is real but sits **one level down**, on the `DataEvent`
434434
inside `payload`, and it carries the write's own patch — a flat `{ field: newValue }` map
435-
(`publishDataEvent`, `packages/objectql/src/engine.ts`), not the `old` / `new` pairs this page
435+
(`publishDataEvent`, `packages/objectql/src/engine-realtime-publish.ts`), not the `old` / `new` pairs this page
436436
used to show; read the post-state from `payload.after`. `reason` is declared nowhere in the
437437
protocol at all — see **Subscribe to Query Results** below.
438438
</Callout>

‎packages/objectql/src/engine-data-events.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,11 +1009,12 @@ describe('#15225 / #15813 — a published BulkDataEvent names the organization t
10091009
// emitted INSIDE the `parse` call — a stamp added onto the envelope after
10101010
// validation would pass every pin above while bypassing the contract.
10111011
const testPath = expect.getState().testPath;
1012-
if (!testPath) throw new Error('vitest did not report a testPath — cannot locate engine.ts');
1013-
const src = readFileSync(join(dirname(testPath), 'engine.ts'), 'utf8');
1014-
const start = src.indexOf('private async publishBulkDataEvent(');
1012+
if (!testPath) throw new Error('vitest did not report a testPath — cannot locate engine-realtime-publish.ts');
1013+
// [#25522 cut 4] The body and the resolver moved out of `engine.ts`, whole.
1014+
const src = readFileSync(join(dirname(testPath), 'engine-realtime-publish.ts'), 'utf8');
1015+
const start = src.indexOf('export async function publishBulkDataEvent(');
10151016
expect(start).toBeGreaterThan(-1);
1016-
const body = src.slice(start, src.indexOf('\n }\n', start));
1017+
const body = src.slice(start, src.indexOf('\n}\n', start));
10171018
const parseCalls = body.match(/BulkDataEventSchema\.parse\(\{[\s\S]*?\n\s*\}\);/g) ?? [];
10181019
expect(parseCalls).toHaveLength(1);
10191020
expect(parseCalls[0]).toContain('organizationId');

0 commit comments

Comments
 (0)