@pgxsinkit/contracts 0.1.51 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAgC,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAS,UAAU,EAAE,WAAW,SAAS,UAAU,EAClF,KAAK,EAAE,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,GACzC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CA2BrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,MAAM,SAAS,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAExG;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,iBAAiB,EAChC,UAAU,EAAE,iBAAiB,EAC7B,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B,IAAI,CAsBN"}
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAgC,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAS,UAAU,EAAE,WAAW,SAAS,UAAU,EAClF,KAAK,EAAE,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,GACzC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CA8BrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,MAAM,SAAS,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAExG;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,iBAAiB,EAChC,UAAU,EAAE,iBAAiB,EAC7B,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B,IAAI,CAsBN"}
@@ -51,6 +51,15 @@ export interface SyncTableEntry<TTable extends AnyPgTable = AnyPgTable, TLocalTa
51
51
  view?: AnyPgView | undefined;
52
52
  mode: TableMode;
53
53
  primaryKey: PrimaryKeySpec;
54
+ /**
55
+ * CDC insert-apply policy (ADR-0045). Default `"insert"`: a server CDC `insert` is applied as a plain
56
+ * INSERT, so a genuine primary-key collision surfaces (the ADR-0014 collision-surfacing invariant).
57
+ * `"upsert"`: this table legitimately receives locally-derived provisional rows (e.g. written by a
58
+ * local trigger from another synced table), so server CDC inserts are applied idempotently as
59
+ * `INSERT … ON CONFLICT (pk) DO UPDATE` — the authoritative server row overwrites the provisional
60
+ * local row instead of failing the commit. Resolved to `"insert"` when omitted.
61
+ */
62
+ applyMode: "insert" | "upsert";
54
63
  shape?: ShapeSpec;
55
64
  clientProjection?: ClientProjectionSpecForTable<TTable>;
56
65
  serverProjection?: ServerProjectionSpec;
@@ -192,10 +201,34 @@ export type SyncTableInput<TName extends string, TColumns extends Record<string,
192
201
  /** @default "readonly" */
193
202
  mode?: TableMode;
194
203
  /**
195
- * Primary key column names. Defaults to `["id"]`.
196
- * Use an array with multiple entries for composite keys.
204
+ * THE primary key of the server table — the single source of truth for its physical
205
+ * `PRIMARY KEY` constraint. `defineSyncTable` emits it as the constraint, named
206
+ * `` `${tableName}_pkey` `` (matching Postgres's inline-PK default, so existing consumer
207
+ * databases see no rename churn) unless the object form overrides `name`.
208
+ *
209
+ * Defaults to `["id"]`. Use an array with multiple entries for composite keys, or the object
210
+ * form `{ name, columns }` to name the constraint.
211
+ *
212
+ * A single-column key MAY equivalently be declared via the column's own `.primaryKey()`
213
+ * (idiomatic drizzle); it must match this spec, and emission is then skipped because the
214
+ * column already carries the constraint. A table-level `primaryKey(...)` in `extras`/`policies`
215
+ * is REJECTED — declare the key here instead.
216
+ */
217
+ primaryKey?: string[] | {
218
+ name: string;
219
+ columns: string[];
220
+ };
221
+ /**
222
+ * CDC insert-apply policy (ADR-0045). **Default `"insert"`** — a CDC insert is a plain INSERT, so a
223
+ * genuine PK collision must surface (the ADR-0014 collision-surfacing invariant; a synced cache table
224
+ * is server-authoritative and a duplicate insert is a real bug). Set `"upsert"` **only** when this
225
+ * table legitimately receives locally-DERIVED provisional rows — e.g. a local trigger on another
226
+ * synced table inserts a provisional row here, and the server independently creates the same row so
227
+ * its CDC insert would collide (23505). With `"upsert"`, server CDC inserts are applied idempotently
228
+ * as `INSERT … ON CONFLICT (pk) DO UPDATE`; the authoritative server row overwrites the provisional
229
+ * local row. Declare the exception here, where it lives — do not weaken the invariant repo-wide.
197
230
  */
198
- primaryKey?: string[];
231
+ applyMode?: "insert" | "upsert";
199
232
  shape?: ShapeSpecInputFor<TColumns>;
200
233
  clientProjection?: SyncTableInputProjection<TColumns, TOmittedColumns>;
201
234
  /** Server-side response-path projection (e.g. `rowTransform`). Server authority, not client shape. */
@@ -273,6 +306,7 @@ export declare function defineSyncTable<const TName extends string, const TColum
273
306
  writeMode?: WriteMode;
274
307
  mode: TableMode;
275
308
  primaryKey: PrimaryKeySpec;
309
+ applyMode: "insert" | "upsert";
276
310
  shape?: ShapeSpec;
277
311
  governance?: TableGovernanceSpecForTable<PgTableWithColumns<{
278
312
  name: TName;
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,KAAK,aAAa,EAAyB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EASL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,IAAI,uBAAuB,EACnD,KAAK,SAAS,EACd,KAAK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AAU,EAAE,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CAiBhH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAWjE;AAED,2FAA2F;AAC3F,wBAAgB,0BAA0B,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,aAAa,CAElH;AAED,wBAAgB,8BAA8B,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,YAEtG;AAED,wBAAgB,oCAAoC,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,YAE5G;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,SAAS,UAAU,EACtE,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAC5B,MAAM,GAAG,SAAS,CAkBpB;AAED,wBAAgB,wBAAwB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,aAwCjH;AAED,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,UAG7F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgxsinkit/contracts",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "keywords": [
5
5
  "tanstack-intent"
6
6
  ],
@@ -15,7 +15,7 @@ description: >-
15
15
  metadata:
16
16
  type: core
17
17
  library: "@pgxsinkit/contracts"
18
- library_version: "0.1.51"
18
+ library_version: "0.1.53"
19
19
  source: https://pgxsinkit.github.io/start/getting-started/
20
20
  ---
21
21
 
@@ -56,6 +56,48 @@ widgets: defineSyncTable({
56
56
  }),
57
57
  ```
58
58
 
59
+ **Column types don't constrain sync.** The read-path backfill picks a bulk-insert tier (COPY / JSON /
60
+ per-row `INSERT`) statically from a table's Drizzle column types; enum columns and `GENERATED ALWAYS AS
61
+ IDENTITY` primary keys are fully supported (enum labels round-trip through COPY/JSON, and a synced
62
+ identity PK keeps the server's value via `OVERRIDING SYSTEM VALUE`), so you never need to avoid them for
63
+ sync's sake.
64
+
65
+ ## The `primaryKey` spec emits the physical PRIMARY KEY — it is the single source of truth
66
+
67
+ `defineSyncTable` **emits** the `primaryKey` spec as the server table's physical `PRIMARY KEY` constraint,
68
+ named `` `${tableName}_pkey` `` (Postgres's inline-PK default, so an existing consumer DB sees no rename
69
+ churn). The spec was runtime-only metadata until a consumer had drizzle-kit DROP a live composite key —
70
+ seeing no PK in the generated DDL — so the spec now drives DDL directly.
71
+
72
+ - **Composite / non-`id` key:** `primaryKey: ["org_id", "person_id"]` (default `["id"]`). Constraint
73
+ columns follow spec order.
74
+ - **Custom constraint name:** the object form `primaryKey: { name: "org_person_pk", columns: [...] }`.
75
+ - **Single-column key, idiomatic drizzle:** declaring `id: uuid("id").primaryKey()` on the column is
76
+ allowed and equivalent — it must match the spec, and emission is skipped (the column already carries
77
+ the constraint), so existing single-`id` tables keep byte-identical DDL. A custom constraint name
78
+ cannot be combined with a column-level `.primaryKey()` (a named constraint needs `defineSyncTable` to
79
+ emit it).
80
+ - **Rejected:** a table-level `primaryKey(...)` passed through `extras`/`policies`, and more than one
81
+ column-level `.primaryKey()` — declare composite keys via the `primaryKey` option instead.
82
+
83
+ ## `applyMode` — CDC insert-apply policy (default stays strict)
84
+
85
+ `applyMode` chooses how a **server CDC insert** for this table is applied on the client (ADR-0045).
86
+
87
+ - **`"insert"` (default):** a CDC insert is a plain INSERT with no conflict clause, so a genuine
88
+ primary-key collision **surfaces** (the ADR-0014 invariant — a synced cache table is
89
+ server-authoritative, and a duplicate insert is a real bug). Do not change this without a reason below.
90
+ - **`"upsert"`:** server CDC inserts are applied idempotently as `INSERT … ON CONFLICT (pk) DO UPDATE`
91
+ (or a pk-targeted `DO NOTHING` for a pk-only table); the authoritative server row overwrites the
92
+ provisional local row.
93
+
94
+ **When to use `"upsert"`:** only when this table legitimately receives locally-**derived** provisional
95
+ rows — e.g. a local trigger on another synced table writes a provisional row here, and the server
96
+ independently creates the same row, so its CDC insert would otherwise collide (23505) and degrade the
97
+ engine. It routes all three CDC-insert paths (initial bulk snapshot, steady-state fold, per-message)
98
+ through the idempotent applier. Declare the exception on the table where it lives; never weaken the
99
+ strict default repo-wide.
100
+
59
101
  ## Managed fields are server-assigned — never send them
60
102
 
61
103
  A managed field is stamped by the apply function under the verified request claims. Two strategies:
@@ -24,14 +24,25 @@ export interface SyncColumnType {
24
24
  sqlType: string;
25
25
  /** True when the column is an array of any dimension. */
26
26
  isArray: boolean;
27
+ /**
28
+ * True when the column is a Drizzle `pgEnum` column. An enum's {@link sqlType} is its custom type NAME
29
+ * (not a base type), so it is not in {@link COPY_SAFE_BASE_TYPES} — but enum labels round-trip
30
+ * losslessly through both the COPY text format and a `json_to_recordset` cast (whose cast type is the
31
+ * enum type name), so an enum column is COPY-safe / JSON-safe. This flag carries that positively rather
32
+ * than trying to whitelist every enum type name. When true, {@link sqlType} is the enum type name,
33
+ * usable as a cast type once the applier identifier-quotes (and schema-qualifies) it.
34
+ */
35
+ isEnum: boolean;
27
36
  }
28
37
 
29
38
  /**
30
39
  * Postgres scalar types whose JS→CSV-text rendering is unambiguous, so PGlite `COPY ... FROM`
31
40
  * round-trips them losslessly. Deliberately **conservative** (ADR-0009 decision 3): never add a
32
41
  * type here unless `COPY` truly handles it. Notably EXCLUDES timestamps/dates (format nuances),
33
- * `numeric` (precision/format), `bytea`, `interval`, enums, `json`/`jsonb`, and arrays — those
34
- * route to the `json` tier (if json-representable) or the always-correct `insert` floor.
42
+ * `numeric` (precision/format), `bytea`, `interval`, `json`/`jsonb`, and arrays — those route to the
43
+ * `json` tier (if json-representable) or the always-correct `insert` floor. Enums are NOT listed by
44
+ * type name (each is a distinct custom type) but ARE COPY-safe — carried via {@link SyncColumnType.isEnum}
45
+ * rather than this base-type set, since their labels round-trip through COPY text losslessly.
35
46
  */
36
47
  const COPY_SAFE_BASE_TYPES = new Set<string>([
37
48
  "text",
@@ -71,7 +82,15 @@ function normalizeBaseType(sqlType: string): string {
71
82
  }
72
83
 
73
84
  function isCopySafe(column: SyncColumnType): boolean {
74
- return !column.isArray && COPY_SAFE_BASE_TYPES.has(normalizeBaseType(column.sqlType));
85
+ if (column.isArray) {
86
+ return false;
87
+ }
88
+ // Enum labels are plain text on the COPY wire; PGlite's COPY input casts them into the enum type
89
+ // losslessly, so an enum column is COPY-safe even though its `sqlType` (the enum name) is not a base type.
90
+ if (column.isEnum) {
91
+ return true;
92
+ }
93
+ return COPY_SAFE_BASE_TYPES.has(normalizeBaseType(column.sqlType));
75
94
  }
76
95
 
77
96
  /**
package/src/projection.ts CHANGED
@@ -51,6 +51,9 @@ export function asReadonly<TTable extends AnyPgTable, TLocalTable extends AnyPgT
51
51
  localTable: entry.localTable,
52
52
  mode: "readonly",
53
53
  primaryKey: entry.primaryKey,
54
+ // Read-relevant (ADR-0045): a readonly projection over a table that receives locally-derived rows must
55
+ // apply CDC inserts with the same idempotent policy, so carry the resolved applyMode verbatim.
56
+ applyMode: entry.applyMode,
54
57
  ...(entry.shape != null ? { shape: entry.shape } : {}),
55
58
  ...(readonlyProjection != null ? { clientProjection: readonlyProjection } : {}),
56
59
  ...(entry.serverProjection != null ? { serverProjection: entry.serverProjection } : {}),
package/src/registry.ts CHANGED
@@ -4,6 +4,9 @@ import {
4
4
  getTableConfig,
5
5
  pgTable,
6
6
  pgView,
7
+ primaryKey as pgPrimaryKey,
8
+ PrimaryKeyBuilder,
9
+ type AnyPgColumn,
7
10
  type AnyPgTable,
8
11
  type PgBigInt64Builder,
9
12
  type PgBuildColumns,
@@ -116,6 +119,15 @@ export interface SyncTableEntry<TTable extends AnyPgTable = AnyPgTable, TLocalTa
116
119
  view?: AnyPgView | undefined;
117
120
  mode: TableMode;
118
121
  primaryKey: PrimaryKeySpec;
122
+ /**
123
+ * CDC insert-apply policy (ADR-0045). Default `"insert"`: a server CDC `insert` is applied as a plain
124
+ * INSERT, so a genuine primary-key collision surfaces (the ADR-0014 collision-surfacing invariant).
125
+ * `"upsert"`: this table legitimately receives locally-derived provisional rows (e.g. written by a
126
+ * local trigger from another synced table), so server CDC inserts are applied idempotently as
127
+ * `INSERT … ON CONFLICT (pk) DO UPDATE` — the authoritative server row overwrites the provisional
128
+ * local row instead of failing the commit. Resolved to `"insert"` when omitted.
129
+ */
130
+ applyMode: "insert" | "upsert";
119
131
  shape?: ShapeSpec;
120
132
  clientProjection?: ClientProjectionSpecForTable<TTable>;
121
133
  serverProjection?: ServerProjectionSpec;
@@ -305,10 +317,31 @@ export type SyncTableInput<
305
317
  /** @default "readonly" */
306
318
  mode?: TableMode;
307
319
  /**
308
- * Primary key column names. Defaults to `["id"]`.
309
- * Use an array with multiple entries for composite keys.
320
+ * THE primary key of the server table — the single source of truth for its physical
321
+ * `PRIMARY KEY` constraint. `defineSyncTable` emits it as the constraint, named
322
+ * `` `${tableName}_pkey` `` (matching Postgres's inline-PK default, so existing consumer
323
+ * databases see no rename churn) unless the object form overrides `name`.
324
+ *
325
+ * Defaults to `["id"]`. Use an array with multiple entries for composite keys, or the object
326
+ * form `{ name, columns }` to name the constraint.
327
+ *
328
+ * A single-column key MAY equivalently be declared via the column's own `.primaryKey()`
329
+ * (idiomatic drizzle); it must match this spec, and emission is then skipped because the
330
+ * column already carries the constraint. A table-level `primaryKey(...)` in `extras`/`policies`
331
+ * is REJECTED — declare the key here instead.
310
332
  */
311
- primaryKey?: string[];
333
+ primaryKey?: string[] | { name: string; columns: string[] };
334
+ /**
335
+ * CDC insert-apply policy (ADR-0045). **Default `"insert"`** — a CDC insert is a plain INSERT, so a
336
+ * genuine PK collision must surface (the ADR-0014 collision-surfacing invariant; a synced cache table
337
+ * is server-authoritative and a duplicate insert is a real bug). Set `"upsert"` **only** when this
338
+ * table legitimately receives locally-DERIVED provisional rows — e.g. a local trigger on another
339
+ * synced table inserts a provisional row here, and the server independently creates the same row so
340
+ * its CDC insert would collide (23505). With `"upsert"`, server CDC inserts are applied idempotently
341
+ * as `INSERT … ON CONFLICT (pk) DO UPDATE`; the authoritative server row overwrites the provisional
342
+ * local row. Declare the exception here, where it lives — do not weaken the invariant repo-wide.
343
+ */
344
+ applyMode?: "insert" | "upsert";
312
345
  shape?: ShapeSpecInputFor<TColumns>;
313
346
  clientProjection?: SyncTableInputProjection<TColumns, TOmittedColumns>;
314
347
  /** Server-side response-path projection (e.g. `rowTransform`). Server authority, not client shape. */
@@ -452,6 +485,7 @@ export function defineSyncTable<
452
485
  schema,
453
486
  mode,
454
487
  primaryKey,
488
+ applyMode,
455
489
  governance,
456
490
  clientProjection,
457
491
  serverProjection,
@@ -460,7 +494,55 @@ export function defineSyncTable<
460
494
  } = input;
461
495
 
462
496
  const resolvedMode: TableMode = mode ?? "readonly";
463
- const resolvedPrimaryKey: PrimaryKeySpec = { columns: primaryKey ?? ["id"] };
497
+
498
+ // The `primaryKey` spec is the SINGLE SOURCE OF TRUTH for the server table's physical PRIMARY KEY.
499
+ // It was runtime-only metadata until a consumer (transcrobes) had drizzle-kit DROP a composite PK
500
+ // from a live DB because nothing re-declared it in DDL — so `defineSyncTable` now emits the
501
+ // constraint itself. The default constraint name `${tableName}_pkey` matches Postgres's inline-PK
502
+ // naming, so existing consumer databases see no rename churn; the object form overrides it.
503
+ const primaryKeyColumns = Array.isArray(primaryKey) ? primaryKey : (primaryKey?.columns ?? ["id"]);
504
+ const resolvedPrimaryKey: PrimaryKeySpec = { columns: primaryKeyColumns };
505
+
506
+ // ADR-0045: default to the strict `"insert"` policy (a CDC insert is a plain INSERT — a genuine PK
507
+ // collision must surface). Only tables that legitimately receive locally-derived provisional rows opt
508
+ // into idempotent `"upsert"` apply of server CDC inserts.
509
+ const resolvedApplyMode: "insert" | "upsert" = applyMode ?? "insert";
510
+ const customPrimaryKeyName = !Array.isArray(primaryKey) ? primaryKey?.name : undefined;
511
+ const primaryKeyConstraintName = customPrimaryKeyName ?? `${tableName}_pkey`;
512
+
513
+ // Probe the columns (no extras — cheap) to detect idiomatic column-level `.primaryKey()` flags and
514
+ // to resolve each spec column to its PROPERTY KEY (spec entries may be given as the SQL column name
515
+ // or the property key, matching the omitColumns precedent below).
516
+ const probeColumns = getColumns(pgTable(tableName, makeColumns())) as Record<string, AnyPgColumn>;
517
+ const columnLevelPkKeys = Object.entries(probeColumns)
518
+ .filter(([, col]) => col.primary === true)
519
+ .map(([key]) => key);
520
+ const specPropertyKeys = primaryKeyColumns.map((key) => {
521
+ if (probeColumns[key]) return key;
522
+ const byColumnName = Object.entries(probeColumns).find(([, col]) => col.name === key);
523
+ if (byColumnName) return byColumnName[0];
524
+ throw new Error(`[pgxsinkit] ${tableName}: primaryKey column "${key}" not found among the table's columns`);
525
+ });
526
+
527
+ if (columnLevelPkKeys.length > 1) {
528
+ throw new Error(
529
+ `[pgxsinkit] ${tableName}: multiple columns declare .primaryKey() (${columnLevelPkKeys.join(", ")}) — declare a composite key via the primaryKey option ({ name?, columns }) and remove the column-level .primaryKey() flags; the spec is the single source of truth`,
530
+ );
531
+ }
532
+ if (columnLevelPkKeys.length === 1) {
533
+ const columnLevelPkKey = columnLevelPkKeys[0]!;
534
+ if (specPropertyKeys.length !== 1 || specPropertyKeys[0] !== columnLevelPkKey) {
535
+ throw new Error(
536
+ `[pgxsinkit] ${tableName}: column "${columnLevelPkKey}" declares .primaryKey() but the primaryKey spec is [${resolvedPrimaryKey.columns.join(", ")}] — they must match; the spec is the single source of truth`,
537
+ );
538
+ }
539
+ if (customPrimaryKeyName != null && customPrimaryKeyName !== `${tableName}_pkey`) {
540
+ throw new Error(
541
+ `[pgxsinkit] ${tableName}: a custom primary-key name ("${customPrimaryKeyName}") requires defineSyncTable to emit the constraint — remove .primaryKey() from column "${columnLevelPkKey}" so the named constraint can be emitted`,
542
+ );
543
+ }
544
+ }
545
+ const emitPrimaryKey = columnLevelPkKeys.length === 0;
464
546
 
465
547
  const resolvedClientProjection =
466
548
  resolvedMode !== "writeonly" || clientProjection != null
@@ -477,11 +559,21 @@ export function defineSyncTable<
477
559
  : undefined;
478
560
 
479
561
  const extrasFn =
480
- policies || extras
481
- ? (self: PgBuildExtraConfigColumns<ReturnType<typeof makeColumns>>) => [
482
- ...(policies ?? []),
483
- ...(extras ? extras(self) : []),
484
- ]
562
+ policies || extras || emitPrimaryKey
563
+ ? (self: PgBuildExtraConfigColumns<ReturnType<typeof makeColumns>>) => {
564
+ const consumerExtras = [...(policies ?? []), ...(extras ? extras(self) : [])];
565
+ for (const extra of consumerExtras) {
566
+ if (extra instanceof PrimaryKeyBuilder) {
567
+ throw new Error(
568
+ `[pgxsinkit] ${tableName}: declare the primary key via the primaryKey option (string[] or { name, columns }), not a primaryKey(...) extra — the spec is the single source of truth and defineSyncTable emits the constraint`,
569
+ );
570
+ }
571
+ }
572
+ if (!emitPrimaryKey) return consumerExtras;
573
+ const selfCols = self as unknown as Record<string, AnyPgColumn>;
574
+ const pkColumns = specPropertyKeys.map((k) => selfCols[k]!) as [AnyPgColumn, ...AnyPgColumn[]];
575
+ return [...consumerExtras, pgPrimaryKey({ name: primaryKeyConstraintName, columns: pkColumns })];
576
+ }
485
577
  : undefined;
486
578
  const table = schema ? schema.table(tableName, makeColumns(), extrasFn) : pgTable(tableName, makeColumns(), extrasFn);
487
579
 
@@ -525,6 +617,7 @@ export function defineSyncTable<
525
617
  ...otherRest,
526
618
  mode: resolvedMode,
527
619
  primaryKey: resolvedPrimaryKey,
620
+ applyMode: resolvedApplyMode,
528
621
  ...(resolvedShape != null ? { shape: resolvedShape } : {}),
529
622
  // The input specs are typed over the builder columns map (keys of
530
623
  // TColumns); the entry fields demand specs typed over the built table.
@@ -1008,12 +1101,19 @@ export function getProjectedColumnNames<TTable extends AnyPgTable>(entry: SyncTa
1008
1101
  */
1009
1102
  export function deriveSyncColumnTypes<TTable extends AnyPgTable>(entry: SyncTableEntry<TTable>): SyncColumnType[] {
1010
1103
  return getProjectedColumns(entry).map(({ column, columnName }) => {
1011
- const typedColumn = column as { getSQLType?: () => string; dimensions?: number };
1104
+ const typedColumn = column as { getSQLType?: () => string; dimensions?: number; columnType?: string };
1012
1105
  const sqlType = normalizeCastPositionType(typedColumn.getSQLType?.() ?? "");
1013
1106
  return {
1014
1107
  name: columnName,
1015
1108
  sqlType,
1016
1109
  isArray: (typedColumn.dimensions ?? 0) > 0,
1110
+ // A real Postgres enum column brands as `PgEnumColumn`. `enumValues` is NOT the discriminator:
1111
+ // `text("c", { enum: […] })` / varchar variants expose `enumValues` too but their `getSQLType()` is
1112
+ // a BASE type (`text`, `varchar(255)`) — identifier-quoting that as a cast type would be wrong (and
1113
+ // broken for parameterised types). For a true enum, `getSQLType()` returns the enum TYPE NAME
1114
+ // (usable as a cast type once quoted) — the flag lets the ladder classify it as COPY/JSON-safe
1115
+ // instead of falling to the `insert` floor on the unrecognised type name.
1116
+ isEnum: typedColumn.columnType?.startsWith("PgEnum") === true,
1017
1117
  } satisfies SyncColumnType;
1018
1118
  });
1019
1119
  }