Skip to content

asReadonly

asReadonly<TTable, TLocalTable>(entry): SyncTableEntry<TTable, TLocalTable>

Defined in: packages/contracts/src/projection.ts:36

Per-client mode projection (ADR-0025). The authoritative (server) registry defines a table once with its full write contract; a client that must only read that table consumes the same entry through asReadonly. The read/identity contract — table, columns, primary key, synced-table name, column omission, the shape/row filter, the row classification (rowClass), AND the column-builder factory (makeColumns) — is preserved verbatim; the write-capability metadata is dropped:

  • mode flips to readonly;
  • the overlay-merged read-model view and the overlay/journal client projection (the local write machinery @pgxsinkit/client provisions for a writable table) are removed — a readonly client reads the synced base table directly;
  • conflictPolicy, governance (managed fields), and writeMode are removed — a readonly table has no write path, and defineSyncRegistry would otherwise still treat them as a writable declaration.

The result is the same entry defineSyncTable would have produced for this table with mode: "readonly", so defineSyncRegistry accepts it without the writable-table requirements (server-version field + conflictPolicy).

Lifecycle axes (consistencyGroup, subscription, retention) are preserved — a projection may keep the authoritative grouping/timing/durability; change them on the projected entry if a client needs to.

makeColumns (the column-builder factory defineSyncTable stashes) is carried too: since ADR-0029 P1 the client derives EVERY synced-table object from it (getSyncedLocalTableprojectedColumnBuilders), so a readonly projection that dropped it could not build its own local synced read cache — the member-boot failure this keep-list’s NOTE below predicted. It is read-derivation machinery, not a write handle.

NOTE: if a new read-relevant field is added to SyncTableEntry, carry it here too (this builds the readonly entry by listing what to keep, so a new field is otherwise silently dropped).

TTable extends AnyPgTable

TLocalTable extends AnyPgTable

SyncTableEntry<TTable, TLocalTable>

SyncTableEntry<TTable, TLocalTable>