Skip to content

SyncTableEntry

Defined in: packages/contracts/src/registry.ts:122

TTable extends AnyPgTable = AnyPgTable

TLocalTable extends AnyPgTable = TTable

applyMode: "insert" | "upsert"

Defined in: packages/contracts/src/registry.ts:143

CDC insert-apply policy (ADR-0045). Default "insert": a server CDC insert is applied as a plain INSERT, so a genuine primary-key collision surfaces (the ADR-0014 collision-surfacing invariant). "upsert": this table legitimately receives locally-derived provisional rows (e.g. written by a local trigger from another synced table), so server CDC inserts are applied idempotently as INSERT … ON CONFLICT (pk) DO UPDATE — the authoritative server row overwrites the provisional local row instead of failing the commit. Resolved to "insert" when omitted.


optional clientProjection?: ClientProjectionSpecForTable<TTable>

Defined in: packages/contracts/src/registry.ts:164


optional conflictPolicy?: ConflictPolicy

Defined in: packages/contracts/src/registry.ts:172

Conflict policy (ADR-0015): what happens to a stale write on this table. Required for writable tables (registry validation rejects an undeclared one — the third hard-require); ignored for readonly tables (they have no write path). See ConflictPolicy.


optional consistencyGroup?: string

Defined in: packages/contracts/src/registry.ts:181

Consistency group (ADR-0009 decision 2). Tables sharing a consistencyGroup are synced on one MultiShapeStream and committed atomically at a shared LSN frontier, so a local reader never sees one grouped table advanced past another for the same server transaction. Omitted → the table is its own singleton group (independent frontier, no cross-table atomicity — the resolution for a table that declares no group). The latency cost (a group advances only as fast as its slowest shape) is contained to the tables that opt in.


optional governance?: TableGovernanceSpecForTable<TTable>

Defined in: packages/contracts/src/registry.ts:166


localTable: TLocalTable

Defined in: packages/contracts/src/registry.ts:129

Projected client-side table for PGlite use. Columns listed in clientProjection.omitColumns (e.g. created_by_id) are absent from both the runtime table definition and the TypeScript shape of this table.


optional makeColumns?: () => Record<string, ColumnBuilderBase>

Defined in: packages/contracts/src/registry.ts:222

The column-builder factory that produced this entry’s table (set by defineSyncTable). Retained so defineReadProjection can reuse the owner’s column definitions to build a typed column subset without restating them, AND — since ADR-0029 P1 — so the client can derive every synced-table object (the local synced read cache, overlay, journal) via getSyncedLocalTableprojectedColumnBuilders. It is therefore read-derivation machinery, not a write handle: it is carried through every projection (asReadonly, withRetention, defineReadProjection), NOT fingerprinted (functions are invisible to the read-contract hash), and required on every registered entry — defineSyncRegistry/validateSyncTableEntry reject a hand-assembled entry that lacks it, since the client hard-requires it at boot.

Record<string, ColumnBuilderBase>


mode: TableMode

Defined in: packages/contracts/src/registry.ts:133


primaryKey: PrimaryKeySpec

Defined in: packages/contracts/src/registry.ts:134


optional readProjection?: boolean

Defined in: packages/contracts/src/registry.ts:210

True when this entry is a read PROJECTION over a table OWNED by another entry (built by defineReadProjection). Such an entry owns no physical table — its table is the owner’s, and only its localTable + shape are its own — so migration/apply/RLS generation skips it and a consumer’s schema barrel must never export a fresh table for it. Absent → the entry owns its table.


optional retention?: Retention

Defined in: packages/contracts/src/registry.ts:195

Retention (ADR-0021): persistent (default) | ephemeral. An ephemeral table’s whole local cluster is emitted as TEMP — no durable trace, no durable offline write queue. A property of the consistency group — every table sharing a consistencyGroup must agree (validated). See Retention.


optional rowClass?: string

Defined in: packages/contracts/src/registry.ts:162

Consumer-defined ROW CLASSIFICATION (ADR-0052) — documentation-as-code for what KIND of rows this entry carries. The vocabulary is entirely the CONSUMER’s: pgxsinkit defines no values and attaches no behaviour to any of them. Its two jobs:

  • Fail-closed enumeration. When the registry declares its vocabulary (SyncRegistryDefinition.rowClasses), EVERY entry must carry a rowClass drawn from that set — validated at defineSyncRegistry, i.e. at module eval. A new entry therefore cannot join the registry without its author classifying it, which is what stops a privacy/visibility obligation from being silently inherited by tables nobody remembered to enumerate.
  • The binding key for assertRegistryInvariant. An invariant binds to rowClass values rather than to a hand-maintained table list, so coverage grows with the registry instead of drifting behind it.

When the registry declares no rowClasses, this field is unconstrained (any string, or none). It is authoring metadata only: it is deliberately absent from the registry fingerprint and the read-contract fingerprint, so classifying a table never shifts a persisted cache key (ADR-0052).


optional serverProjection?: ServerProjectionSpec

Defined in: packages/contracts/src/registry.ts:165


optional shape?: ShapeSpec

Defined in: packages/contracts/src/registry.ts:163


optional subscription?: SubscriptionTiming

Defined in: packages/contracts/src/registry.ts:188

Subscription timing (ADR-0021): eager (default) | lazy. A lazy table is excluded from the boot subscription set and subscribed on first query-reference. A property of the consistency group — every table sharing a consistencyGroup must agree (validated). See SubscriptionTiming.


table: TTable

Defined in: packages/contracts/src/registry.ts:123


optional view?: AnyPgView

Defined in: packages/contracts/src/registry.ts:132


optional writeMode?: WriteMode

Defined in: packages/contracts/src/registry.ts:203

Write-mode (ADR-0022): optimistic (default) | pessimistic. A pessimistic consistency group is a standing server-authoritative write-unit — its writes flush-route to the authoritative endpoint and the UI shows success only after the server confirms. Write-mode is a property of the write-unit; the static write-unit is the consistency group, so every table sharing a consistencyGroup must agree (validated). See WriteMode.