@sequenceholdings/orm 2.0.0 → 2.1.1

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.
Files changed (69) hide show
  1. package/README.md +94 -2
  2. package/dist/authoring.cjs +1474 -54
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +242 -4
  5. package/dist/authoring.d.ts +242 -4
  6. package/dist/authoring.js +1465 -56
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +740 -42
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +742 -53
  11. package/dist/canonical.d.ts +742 -53
  12. package/dist/canonical.js +724 -43
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +2478 -328
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +2480 -330
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs +90 -25
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.cts +39 -22
  21. package/dist/client.d.ts +39 -22
  22. package/dist/client.js +87 -26
  23. package/dist/client.js.map +1 -1
  24. package/dist/compiler.cjs +1755 -329
  25. package/dist/compiler.cjs.map +1 -1
  26. package/dist/compiler.d.cts +56 -3
  27. package/dist/compiler.d.ts +56 -3
  28. package/dist/compiler.js +1756 -330
  29. package/dist/compiler.js.map +1 -1
  30. package/dist/constants-YoFGjIBM.d.cts +99 -0
  31. package/dist/constants-YoFGjIBM.d.ts +99 -0
  32. package/dist/dynamic-input.d.cts +1 -0
  33. package/dist/dynamic-input.d.ts +1 -0
  34. package/dist/index.cjs +1973 -164
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +474 -100
  37. package/dist/index.d.ts +474 -100
  38. package/dist/index.js +1940 -167
  39. package/dist/index.js.map +1 -1
  40. package/dist/ir.cjs +869 -46
  41. package/dist/ir.cjs.map +1 -1
  42. package/dist/ir.d.cts +699 -25
  43. package/dist/ir.d.ts +699 -25
  44. package/dist/ir.js +861 -47
  45. package/dist/ir.js.map +1 -1
  46. package/dist/{naming-CTvWSRTf.d.ts → naming-CPfx7EfF.d.ts} +28 -1
  47. package/dist/{naming-DRyinU4u.d.cts → naming-CU9ThP_E.d.cts} +28 -1
  48. package/dist/policy-1iZbGnZZ.d.cts +24 -0
  49. package/dist/policy-1iZbGnZZ.d.ts +24 -0
  50. package/dist/predicate-v2.cjs +852 -49
  51. package/dist/predicate-v2.cjs.map +1 -1
  52. package/dist/predicate-v2.d.cts +2 -1
  53. package/dist/predicate-v2.d.ts +2 -1
  54. package/dist/predicate-v2.js +852 -49
  55. package/dist/predicate-v2.js.map +1 -1
  56. package/dist/sdl.cjs +1309 -58
  57. package/dist/sdl.cjs.map +1 -1
  58. package/dist/sdl.d.cts +7 -3
  59. package/dist/sdl.d.ts +7 -3
  60. package/dist/sdl.js +1305 -59
  61. package/dist/sdl.js.map +1 -1
  62. package/package.json +11 -6
  63. package/templates/orm-namespace/CLAUDE.md +6 -4
  64. package/templates/orm-namespace/codegen.preset.d.cts +7 -0
  65. package/templates/orm-namespace/codegen.ts +2 -1
  66. package/templates/orm-namespace/graphql/example/queries.ts +4 -3
  67. package/templates/orm-namespace/package.json +2 -1
  68. package/templates/orm-namespace/schema/tables.ts +3 -2
  69. package/templates/orm-namespace/sequence.config.ts +7 -11
@@ -1,4 +1,286 @@
1
1
  import { z } from 'zod';
2
+ import { b as CellPart } from './constants-YoFGjIBM.js';
3
+ export { P as PolicyExpression, p as policyExpressionSchema, a as policyVariantSchema } from './policy-1iZbGnZZ.js';
4
+
5
+ /**
6
+ * Canonical contract for resolved tables: one logical table (a generated
7
+ * managed view) backed by N source tables of three kinds —
8
+ *
9
+ * - `manual` an internal ORM table holding sparse user edits (the only
10
+ * GraphQL mutation target),
11
+ * - `etl` a synced (`source: gold.*`) table fed by a pipeline,
12
+ * - `prefetch` an internal ORM "live" table filled by a function that reads
13
+ * the source system on demand (and confirms writebacks).
14
+ *
15
+ * Each column picks its value across candidate sources with a SQL comparator
16
+ * compiled into the view, so policies, filters, sorting and nested relations
17
+ * all see resolved values. This module owns the metadata the compiler (write
18
+ * roots, directives) and data plane (prefetch, writeback) need; the view SQL
19
+ * itself is generated at authoring time and validated like any managed view.
20
+ */
21
+
22
+ /** `'1500ms'` / `'30s'` / `'5m'` (or a millisecond number) → milliseconds; undefined when malformed. */
23
+ declare function parseDurationMs(input: number | string): number | undefined;
24
+ /**
25
+ * Row-level system columns the generated view adds after the authored columns
26
+ * (GraphQL fields). Per-cell provenance lives in typed cell parts instead —
27
+ * see RESOLVED_VIEW_CELL_PARTS.
28
+ */
29
+ declare const RESOLVED_VIEW_SYSTEM_COLUMNS: {
30
+ readonly writebackStatus: {
31
+ readonly name: "writebackStatus";
32
+ readonly columnName: "_writeback_status";
33
+ readonly type: "text";
34
+ };
35
+ readonly writebackError: {
36
+ readonly name: "writebackError";
37
+ readonly columnName: "_writeback_error";
38
+ readonly type: "text";
39
+ };
40
+ };
41
+ /** System columns on the internal manual / live tables (never exposed in GraphQL). */
42
+ declare const RESOLVED_SOURCE_SYSTEM_COLUMNS: {
43
+ readonly tombstoned: {
44
+ readonly name: "sysTombstoned";
45
+ readonly columnName: "_tombstoned";
46
+ };
47
+ readonly fetchedAt: {
48
+ readonly name: "sysFetchedAt";
49
+ readonly columnName: "_fetched_at";
50
+ };
51
+ readonly writebackStatus: {
52
+ readonly name: "sysWritebackStatus";
53
+ readonly columnName: "_writeback_status";
54
+ };
55
+ readonly writebackError: {
56
+ readonly name: "sysWritebackError";
57
+ readonly columnName: "_writeback_error";
58
+ };
59
+ readonly writebackAt: {
60
+ readonly name: "sysWritebackAt";
61
+ readonly columnName: "_writeback_at";
62
+ };
63
+ };
64
+ /** Cell parts the resolved view exposes per resolved column: the winner's source, time, actor, and newer losers. */
65
+ declare const RESOLVED_VIEW_CELL_PARTS: readonly ["source", "at", "by", "conflicts"];
66
+ /** Cell parts on a resolved table's internal sources; only the manual source carries `rev`. */
67
+ declare const RESOLVED_SOURCE_CELL_PARTS: {
68
+ readonly manual: readonly ["at", "by", "rev"];
69
+ readonly prefetch: readonly ["at", "by"];
70
+ };
71
+ declare const RESERVED_RESOLVED_COLUMN_NAMES: ReadonlySet<string>;
72
+ declare const COMPARATORS: readonly ["latest", "highest", "lowest", "priority", "nonNullFirst", "custom"];
73
+ type ComparatorKind = (typeof COMPARATORS)[number];
74
+ declare const canonicalFunctionRefSchema: z.ZodObject<{
75
+ kind: z.ZodEnum<{
76
+ managed: "managed";
77
+ native: "native";
78
+ }>;
79
+ id: z.ZodString;
80
+ }, z.core.$strict>;
81
+ type CanonicalFunctionRef = z.infer<typeof canonicalFunctionRefSchema>;
82
+ /** What the source API can fetch: one key per call, or a batch of up to maxKeys. */
83
+ declare const canonicalFetchShapeSchema: z.ZodUnion<readonly [z.ZodObject<{
84
+ shape: z.ZodLiteral<"single">;
85
+ }, z.core.$strict>, z.ZodObject<{
86
+ shape: z.ZodLiteral<"batch">;
87
+ maxKeys: z.ZodNumber;
88
+ }, z.core.$strict>]>;
89
+ type CanonicalFetchShape = z.infer<typeof canonicalFetchShapeSchema>;
90
+ declare const canonicalResolvedSourceSchema: z.ZodObject<{
91
+ name: z.ZodString;
92
+ kind: z.ZodEnum<{
93
+ manual: "manual";
94
+ prefetch: "prefetch";
95
+ etl: "etl";
96
+ }>;
97
+ table: z.ZodString;
98
+ columns: z.ZodArray<z.ZodString>;
99
+ updatedAt: z.ZodOptional<z.ZodString>;
100
+ key: z.ZodOptional<z.ZodString>;
101
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
102
+ shape: z.ZodLiteral<"single">;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ shape: z.ZodLiteral<"batch">;
105
+ maxKeys: z.ZodNumber;
106
+ }, z.core.$strict>]>>;
107
+ function: z.ZodOptional<z.ZodObject<{
108
+ kind: z.ZodEnum<{
109
+ managed: "managed";
110
+ native: "native";
111
+ }>;
112
+ id: z.ZodString;
113
+ }, z.core.$strict>>;
114
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
115
+ maxStalenessMs: z.ZodNumber;
116
+ timeoutMs: z.ZodNumber;
117
+ onError: z.ZodEnum<{
118
+ fallback: "fallback";
119
+ fail: "fail";
120
+ }>;
121
+ }, z.core.$strict>>;
122
+ writeback: z.ZodOptional<z.ZodObject<{
123
+ columns: z.ZodArray<z.ZodString>;
124
+ defaultMode: z.ZodEnum<{
125
+ sync: "sync";
126
+ async: "async";
127
+ }>;
128
+ timeoutMs: z.ZodNumber;
129
+ clearManualOnConfirm: z.ZodBoolean;
130
+ }, z.core.$strict>>;
131
+ }, z.core.$strict>;
132
+ type CanonicalResolvedSource = z.infer<typeof canonicalResolvedSourceSchema>;
133
+ declare const canonicalResolveRuleSchema: z.ZodObject<{
134
+ column: z.ZodString;
135
+ comparator: z.ZodEnum<{
136
+ custom: "custom";
137
+ latest: "latest";
138
+ highest: "highest";
139
+ lowest: "lowest";
140
+ priority: "priority";
141
+ nonNullFirst: "nonNullFirst";
142
+ }>;
143
+ candidates: z.ZodArray<z.ZodString>;
144
+ orderBy: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strict>;
146
+ type CanonicalResolveRule = z.infer<typeof canonicalResolveRuleSchema>;
147
+ declare const canonicalResolvedSchema: z.ZodObject<{
148
+ sources: z.ZodArray<z.ZodObject<{
149
+ name: z.ZodString;
150
+ kind: z.ZodEnum<{
151
+ manual: "manual";
152
+ prefetch: "prefetch";
153
+ etl: "etl";
154
+ }>;
155
+ table: z.ZodString;
156
+ columns: z.ZodArray<z.ZodString>;
157
+ updatedAt: z.ZodOptional<z.ZodString>;
158
+ key: z.ZodOptional<z.ZodString>;
159
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
160
+ shape: z.ZodLiteral<"single">;
161
+ }, z.core.$strict>, z.ZodObject<{
162
+ shape: z.ZodLiteral<"batch">;
163
+ maxKeys: z.ZodNumber;
164
+ }, z.core.$strict>]>>;
165
+ function: z.ZodOptional<z.ZodObject<{
166
+ kind: z.ZodEnum<{
167
+ managed: "managed";
168
+ native: "native";
169
+ }>;
170
+ id: z.ZodString;
171
+ }, z.core.$strict>>;
172
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
173
+ maxStalenessMs: z.ZodNumber;
174
+ timeoutMs: z.ZodNumber;
175
+ onError: z.ZodEnum<{
176
+ fallback: "fallback";
177
+ fail: "fail";
178
+ }>;
179
+ }, z.core.$strict>>;
180
+ writeback: z.ZodOptional<z.ZodObject<{
181
+ columns: z.ZodArray<z.ZodString>;
182
+ defaultMode: z.ZodEnum<{
183
+ sync: "sync";
184
+ async: "async";
185
+ }>;
186
+ timeoutMs: z.ZodNumber;
187
+ clearManualOnConfirm: z.ZodBoolean;
188
+ }, z.core.$strict>>;
189
+ }, z.core.$strict>>;
190
+ resolve: z.ZodArray<z.ZodObject<{
191
+ column: z.ZodString;
192
+ comparator: z.ZodEnum<{
193
+ custom: "custom";
194
+ latest: "latest";
195
+ highest: "highest";
196
+ lowest: "lowest";
197
+ priority: "priority";
198
+ nonNullFirst: "nonNullFirst";
199
+ }>;
200
+ candidates: z.ZodArray<z.ZodString>;
201
+ orderBy: z.ZodOptional<z.ZodString>;
202
+ }, z.core.$strict>>;
203
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
204
+ materialized: z.ZodOptional<z.ZodObject<{
205
+ table: z.ZodString;
206
+ compute: z.ZodString;
207
+ }, z.core.$strict>>;
208
+ policies: z.ZodDefault<z.ZodObject<{
209
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
210
+ default: z.ZodString;
211
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
212
+ when: z.ZodString;
213
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
214
+ policy: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$strip>>>;
216
+ }, z.core.$strip>]>>;
217
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
218
+ default: z.ZodString;
219
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
220
+ when: z.ZodString;
221
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
222
+ policy: z.ZodOptional<z.ZodString>;
223
+ }, z.core.$strip>>>;
224
+ }, z.core.$strip>]>>;
225
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
226
+ default: z.ZodString;
227
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
228
+ when: z.ZodString;
229
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
230
+ policy: z.ZodOptional<z.ZodString>;
231
+ }, z.core.$strip>>>;
232
+ }, z.core.$strip>]>>;
233
+ }, z.core.$strict>>;
234
+ }, z.core.$strict>;
235
+ type CanonicalResolved = z.infer<typeof canonicalResolvedSchema>;
236
+ interface RelationShape {
237
+ table: string;
238
+ source?: string;
239
+ internal?: true;
240
+ cellMetadata?: true;
241
+ materializes?: string;
242
+ policies?: {
243
+ read?: string | {
244
+ default: string;
245
+ variants: unknown[];
246
+ };
247
+ };
248
+ primaryKey?: string[];
249
+ columns: Array<{
250
+ name: string;
251
+ columnName: string;
252
+ type: unknown;
253
+ cell?: {
254
+ of: string;
255
+ part: CellPart;
256
+ };
257
+ }>;
258
+ }
259
+ interface ViewShape {
260
+ view: string;
261
+ internal?: true;
262
+ primaryKey?: string[];
263
+ columns: Array<{
264
+ name: string;
265
+ columnName: string;
266
+ type: unknown;
267
+ nullable?: boolean;
268
+ cell?: {
269
+ of: string;
270
+ part: CellPart;
271
+ };
272
+ }>;
273
+ resolved?: CanonicalResolved;
274
+ }
275
+ /**
276
+ * Cross-relation validation for one resolved view. Returns messages rather
277
+ * than throwing so the definition-level superRefine can attach paths.
278
+ */
279
+ declare function validateResolvedView({ view, tables, views }: {
280
+ view: ViewShape;
281
+ tables: readonly RelationShape[];
282
+ views?: readonly ViewShape[];
283
+ }): string[];
2
284
 
3
285
  /**
4
286
  * Canonical namespace definition v2 — the data-only JSON a consumer's
@@ -30,14 +312,14 @@ declare const canonicalColumnSchema: z.ZodObject<{
30
312
  type: z.ZodUnion<readonly [z.ZodEnum<{
31
313
  bigint: "bigint";
32
314
  boolean: "boolean";
33
- uuid: "uuid";
34
315
  text: "text";
316
+ date: "date";
317
+ timestamptz: "timestamptz";
318
+ jsonb: "jsonb";
319
+ uuid: "uuid";
35
320
  integer: "integer";
36
321
  numeric: "numeric";
37
322
  double: "double";
38
- timestamptz: "timestamptz";
39
- date: "date";
40
- jsonb: "jsonb";
41
323
  }>, z.ZodObject<{
42
324
  enum: z.ZodString;
43
325
  }, z.core.$strip>]>;
@@ -48,10 +330,23 @@ declare const canonicalColumnSchema: z.ZodObject<{
48
330
  "gen_random_uuid()": "gen_random_uuid()";
49
331
  "now()": "now()";
50
332
  }>>;
333
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
334
+ "now()": "now()";
335
+ }>>;
51
336
  description: z.ZodOptional<z.ZodString>;
52
337
  renamedFrom: z.ZodOptional<z.ZodString>;
53
338
  cast: z.ZodOptional<z.ZodString>;
54
339
  deprecated: z.ZodDefault<z.ZodBoolean>;
340
+ cell: z.ZodOptional<z.ZodObject<{
341
+ of: z.ZodString;
342
+ part: z.ZodEnum<{
343
+ at: "at";
344
+ by: "by";
345
+ rev: "rev";
346
+ source: "source";
347
+ conflicts: "conflicts";
348
+ }>;
349
+ }, z.core.$strict>>;
55
350
  }, z.core.$strip>;
56
351
  type CanonicalColumn = z.infer<typeof canonicalColumnSchema>;
57
352
  declare const canonicalLinkSchema: z.ZodObject<{
@@ -65,6 +360,20 @@ declare const canonicalLinkSchema: z.ZodObject<{
65
360
  on: z.ZodString;
66
361
  references: z.ZodOptional<z.ZodString>;
67
362
  enforce: z.ZodDefault<z.ZodBoolean>;
363
+ onDelete: z.ZodOptional<z.ZodEnum<{
364
+ cascade: "cascade";
365
+ restrict: "restrict";
366
+ "no action": "no action";
367
+ "set null": "set null";
368
+ "set default": "set default";
369
+ }>>;
370
+ onUpdate: z.ZodOptional<z.ZodEnum<{
371
+ cascade: "cascade";
372
+ restrict: "restrict";
373
+ "no action": "no action";
374
+ "set null": "set null";
375
+ "set default": "set default";
376
+ }>>;
68
377
  description: z.ZodOptional<z.ZodString>;
69
378
  }, z.core.$strip>;
70
379
  type CanonicalLink = z.infer<typeof canonicalLinkSchema>;
@@ -73,25 +382,12 @@ declare const canonicalIndexSchema: z.ZodObject<{
73
382
  unique: z.ZodDefault<z.ZodBoolean>;
74
383
  name: z.ZodOptional<z.ZodString>;
75
384
  }, z.core.$strip>;
76
- /**
77
- * Policy expressions stay DSL SOURCE STRINGS in the canonical form — parsing
78
- * and claim-key validation happen in both CLI and server via the shared
79
- * predicate parser. Variants follow §4c permissive-union semantics.
80
- */
81
- declare const policyVariantSchema: z.ZodObject<{
82
- when: z.ZodString;
83
- allow: z.ZodOptional<z.ZodLiteral<true>>;
84
- policy: z.ZodOptional<z.ZodString>;
85
- }, z.core.$strip>;
86
- declare const policyExpressionSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
87
- default: z.ZodString;
88
- variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
89
- when: z.ZodString;
90
- allow: z.ZodOptional<z.ZodLiteral<true>>;
91
- policy: z.ZodOptional<z.ZodString>;
92
- }, z.core.$strip>>>;
93
- }, z.core.$strip>]>;
94
- type PolicyExpression = z.infer<typeof policyExpressionSchema>;
385
+ declare const canonicalCheckSchema: z.ZodObject<{
386
+ name: z.ZodString;
387
+ expression: z.ZodString;
388
+ }, z.core.$strict>;
389
+ type CanonicalCheck = z.infer<typeof canonicalCheckSchema>;
390
+
95
391
  declare const canonicalPoliciesSchema: z.ZodObject<{
96
392
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
97
393
  default: z.ZodString;
@@ -150,14 +446,14 @@ declare const canonicalActionSchema: z.ZodObject<{
150
446
  type: z.ZodEnum<{
151
447
  bigint: "bigint";
152
448
  boolean: "boolean";
153
- uuid: "uuid";
154
449
  text: "text";
450
+ date: "date";
451
+ timestamptz: "timestamptz";
452
+ jsonb: "jsonb";
453
+ uuid: "uuid";
155
454
  integer: "integer";
156
455
  numeric: "numeric";
157
456
  double: "double";
158
- timestamptz: "timestamptz";
159
- date: "date";
160
- jsonb: "jsonb";
161
457
  }>;
162
458
  nullable: z.ZodDefault<z.ZodBoolean>;
163
459
  }, z.core.$strip>>>;
@@ -193,6 +489,31 @@ declare const canonicalCowMutationSchema: z.ZodObject<{
193
489
  set: z.ZodDefault<z.ZodArray<z.ZodString>>;
194
490
  }, z.core.$strip>;
195
491
  type CanonicalCowMutation = z.infer<typeof canonicalCowMutationSchema>;
492
+ declare const canonicalForeignKeySchema: z.ZodObject<{
493
+ name: z.ZodString;
494
+ columns: z.ZodArray<z.ZodString>;
495
+ target: z.ZodString;
496
+ references: z.ZodArray<z.ZodString>;
497
+ deferrable: z.ZodOptional<z.ZodEnum<{
498
+ "initially-immediate": "initially-immediate";
499
+ "initially-deferred": "initially-deferred";
500
+ }>>;
501
+ onDelete: z.ZodOptional<z.ZodEnum<{
502
+ cascade: "cascade";
503
+ restrict: "restrict";
504
+ "no action": "no action";
505
+ "set null": "set null";
506
+ "set default": "set default";
507
+ }>>;
508
+ onUpdate: z.ZodOptional<z.ZodEnum<{
509
+ cascade: "cascade";
510
+ restrict: "restrict";
511
+ "no action": "no action";
512
+ "set null": "set null";
513
+ "set default": "set default";
514
+ }>>;
515
+ }, z.core.$strict>;
516
+ type CanonicalForeignKey = z.infer<typeof canonicalForeignKeySchema>;
196
517
  declare const canonicalTableSchema: z.ZodObject<{
197
518
  table: z.ZodString;
198
519
  description: z.ZodOptional<z.ZodString>;
@@ -204,14 +525,14 @@ declare const canonicalTableSchema: z.ZodObject<{
204
525
  type: z.ZodUnion<readonly [z.ZodEnum<{
205
526
  bigint: "bigint";
206
527
  boolean: "boolean";
207
- uuid: "uuid";
208
528
  text: "text";
529
+ date: "date";
530
+ timestamptz: "timestamptz";
531
+ jsonb: "jsonb";
532
+ uuid: "uuid";
209
533
  integer: "integer";
210
534
  numeric: "numeric";
211
535
  double: "double";
212
- timestamptz: "timestamptz";
213
- date: "date";
214
- jsonb: "jsonb";
215
536
  }>, z.ZodObject<{
216
537
  enum: z.ZodString;
217
538
  }, z.core.$strip>]>;
@@ -222,10 +543,23 @@ declare const canonicalTableSchema: z.ZodObject<{
222
543
  "gen_random_uuid()": "gen_random_uuid()";
223
544
  "now()": "now()";
224
545
  }>>;
546
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
547
+ "now()": "now()";
548
+ }>>;
225
549
  description: z.ZodOptional<z.ZodString>;
226
550
  renamedFrom: z.ZodOptional<z.ZodString>;
227
551
  cast: z.ZodOptional<z.ZodString>;
228
552
  deprecated: z.ZodDefault<z.ZodBoolean>;
553
+ cell: z.ZodOptional<z.ZodObject<{
554
+ of: z.ZodString;
555
+ part: z.ZodEnum<{
556
+ at: "at";
557
+ by: "by";
558
+ rev: "rev";
559
+ source: "source";
560
+ conflicts: "conflicts";
561
+ }>;
562
+ }, z.core.$strict>>;
229
563
  }, z.core.$strip>>>;
230
564
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
231
565
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -239,6 +573,20 @@ declare const canonicalTableSchema: z.ZodObject<{
239
573
  on: z.ZodString;
240
574
  references: z.ZodOptional<z.ZodString>;
241
575
  enforce: z.ZodDefault<z.ZodBoolean>;
576
+ onDelete: z.ZodOptional<z.ZodEnum<{
577
+ cascade: "cascade";
578
+ restrict: "restrict";
579
+ "no action": "no action";
580
+ "set null": "set null";
581
+ "set default": "set default";
582
+ }>>;
583
+ onUpdate: z.ZodOptional<z.ZodEnum<{
584
+ cascade: "cascade";
585
+ restrict: "restrict";
586
+ "no action": "no action";
587
+ "set null": "set null";
588
+ "set default": "set default";
589
+ }>>;
242
590
  description: z.ZodOptional<z.ZodString>;
243
591
  }, z.core.$strip>>>;
244
592
  indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -246,6 +594,10 @@ declare const canonicalTableSchema: z.ZodObject<{
246
594
  unique: z.ZodDefault<z.ZodBoolean>;
247
595
  name: z.ZodOptional<z.ZodString>;
248
596
  }, z.core.$strip>>>;
597
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
598
+ name: z.ZodString;
599
+ expression: z.ZodString;
600
+ }, z.core.$strict>>>;
249
601
  policies: z.ZodDefault<z.ZodObject<{
250
602
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
251
603
  default: z.ZodString;
@@ -287,14 +639,14 @@ declare const canonicalTableSchema: z.ZodObject<{
287
639
  type: z.ZodEnum<{
288
640
  bigint: "bigint";
289
641
  boolean: "boolean";
290
- uuid: "uuid";
291
642
  text: "text";
643
+ date: "date";
644
+ timestamptz: "timestamptz";
645
+ jsonb: "jsonb";
646
+ uuid: "uuid";
292
647
  integer: "integer";
293
648
  numeric: "numeric";
294
649
  double: "double";
295
- timestamptz: "timestamptz";
296
- date: "date";
297
- jsonb: "jsonb";
298
650
  }>;
299
651
  nullable: z.ZodDefault<z.ZodBoolean>;
300
652
  }, z.core.$strip>>>;
@@ -320,6 +672,33 @@ declare const canonicalTableSchema: z.ZodObject<{
320
672
  copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
321
673
  set: z.ZodDefault<z.ZodArray<z.ZodString>>;
322
674
  }, z.core.$strip>>>;
675
+ foreignKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
676
+ name: z.ZodString;
677
+ columns: z.ZodArray<z.ZodString>;
678
+ target: z.ZodString;
679
+ references: z.ZodArray<z.ZodString>;
680
+ deferrable: z.ZodOptional<z.ZodEnum<{
681
+ "initially-immediate": "initially-immediate";
682
+ "initially-deferred": "initially-deferred";
683
+ }>>;
684
+ onDelete: z.ZodOptional<z.ZodEnum<{
685
+ cascade: "cascade";
686
+ restrict: "restrict";
687
+ "no action": "no action";
688
+ "set null": "set null";
689
+ "set default": "set default";
690
+ }>>;
691
+ onUpdate: z.ZodOptional<z.ZodEnum<{
692
+ cascade: "cascade";
693
+ restrict: "restrict";
694
+ "no action": "no action";
695
+ "set null": "set null";
696
+ "set default": "set default";
697
+ }>>;
698
+ }, z.core.$strict>>>;
699
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
700
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
701
+ materializes: z.ZodOptional<z.ZodString>;
323
702
  }, z.core.$strip>;
324
703
  type CanonicalTable = z.infer<typeof canonicalTableSchema>;
325
704
  declare const canonicalViewSchema: z.ZodObject<{
@@ -331,14 +710,14 @@ declare const canonicalViewSchema: z.ZodObject<{
331
710
  type: z.ZodUnion<readonly [z.ZodEnum<{
332
711
  bigint: "bigint";
333
712
  boolean: "boolean";
334
- uuid: "uuid";
335
713
  text: "text";
714
+ date: "date";
715
+ timestamptz: "timestamptz";
716
+ jsonb: "jsonb";
717
+ uuid: "uuid";
336
718
  integer: "integer";
337
719
  numeric: "numeric";
338
720
  double: "double";
339
- timestamptz: "timestamptz";
340
- date: "date";
341
- jsonb: "jsonb";
342
721
  }>, z.ZodObject<{
343
722
  enum: z.ZodString;
344
723
  }, z.core.$strip>]>;
@@ -349,10 +728,23 @@ declare const canonicalViewSchema: z.ZodObject<{
349
728
  "gen_random_uuid()": "gen_random_uuid()";
350
729
  "now()": "now()";
351
730
  }>>;
731
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
732
+ "now()": "now()";
733
+ }>>;
352
734
  description: z.ZodOptional<z.ZodString>;
353
735
  renamedFrom: z.ZodOptional<z.ZodString>;
354
736
  cast: z.ZodOptional<z.ZodString>;
355
737
  deprecated: z.ZodDefault<z.ZodBoolean>;
738
+ cell: z.ZodOptional<z.ZodObject<{
739
+ of: z.ZodString;
740
+ part: z.ZodEnum<{
741
+ at: "at";
742
+ by: "by";
743
+ rev: "rev";
744
+ source: "source";
745
+ conflicts: "conflicts";
746
+ }>;
747
+ }, z.core.$strict>>;
356
748
  }, z.core.$strip>>;
357
749
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
750
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -366,6 +758,20 @@ declare const canonicalViewSchema: z.ZodObject<{
366
758
  on: z.ZodString;
367
759
  references: z.ZodOptional<z.ZodString>;
368
760
  enforce: z.ZodDefault<z.ZodBoolean>;
761
+ onDelete: z.ZodOptional<z.ZodEnum<{
762
+ cascade: "cascade";
763
+ restrict: "restrict";
764
+ "no action": "no action";
765
+ "set null": "set null";
766
+ "set default": "set default";
767
+ }>>;
768
+ onUpdate: z.ZodOptional<z.ZodEnum<{
769
+ cascade: "cascade";
770
+ restrict: "restrict";
771
+ "no action": "no action";
772
+ "set null": "set null";
773
+ "set default": "set default";
774
+ }>>;
369
775
  description: z.ZodOptional<z.ZodString>;
370
776
  }, z.core.$strip>>>;
371
777
  policies: z.ZodObject<{
@@ -380,8 +786,113 @@ declare const canonicalViewSchema: z.ZodObject<{
380
786
  }, z.core.$strict>;
381
787
  query: z.ZodString;
382
788
  dependencies: z.ZodArray<z.ZodString>;
789
+ resolved: z.ZodOptional<z.ZodObject<{
790
+ sources: z.ZodArray<z.ZodObject<{
791
+ name: z.ZodString;
792
+ kind: z.ZodEnum<{
793
+ manual: "manual";
794
+ prefetch: "prefetch";
795
+ etl: "etl";
796
+ }>;
797
+ table: z.ZodString;
798
+ columns: z.ZodArray<z.ZodString>;
799
+ updatedAt: z.ZodOptional<z.ZodString>;
800
+ key: z.ZodOptional<z.ZodString>;
801
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
802
+ shape: z.ZodLiteral<"single">;
803
+ }, z.core.$strict>, z.ZodObject<{
804
+ shape: z.ZodLiteral<"batch">;
805
+ maxKeys: z.ZodNumber;
806
+ }, z.core.$strict>]>>;
807
+ function: z.ZodOptional<z.ZodObject<{
808
+ kind: z.ZodEnum<{
809
+ managed: "managed";
810
+ native: "native";
811
+ }>;
812
+ id: z.ZodString;
813
+ }, z.core.$strict>>;
814
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
815
+ maxStalenessMs: z.ZodNumber;
816
+ timeoutMs: z.ZodNumber;
817
+ onError: z.ZodEnum<{
818
+ fallback: "fallback";
819
+ fail: "fail";
820
+ }>;
821
+ }, z.core.$strict>>;
822
+ writeback: z.ZodOptional<z.ZodObject<{
823
+ columns: z.ZodArray<z.ZodString>;
824
+ defaultMode: z.ZodEnum<{
825
+ sync: "sync";
826
+ async: "async";
827
+ }>;
828
+ timeoutMs: z.ZodNumber;
829
+ clearManualOnConfirm: z.ZodBoolean;
830
+ }, z.core.$strict>>;
831
+ }, z.core.$strict>>;
832
+ resolve: z.ZodArray<z.ZodObject<{
833
+ column: z.ZodString;
834
+ comparator: z.ZodEnum<{
835
+ custom: "custom";
836
+ latest: "latest";
837
+ highest: "highest";
838
+ lowest: "lowest";
839
+ priority: "priority";
840
+ nonNullFirst: "nonNullFirst";
841
+ }>;
842
+ candidates: z.ZodArray<z.ZodString>;
843
+ orderBy: z.ZodOptional<z.ZodString>;
844
+ }, z.core.$strict>>;
845
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
846
+ materialized: z.ZodOptional<z.ZodObject<{
847
+ table: z.ZodString;
848
+ compute: z.ZodString;
849
+ }, z.core.$strict>>;
850
+ policies: z.ZodDefault<z.ZodObject<{
851
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
852
+ default: z.ZodString;
853
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
854
+ when: z.ZodString;
855
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
856
+ policy: z.ZodOptional<z.ZodString>;
857
+ }, z.core.$strip>>>;
858
+ }, z.core.$strip>]>>;
859
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
860
+ default: z.ZodString;
861
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
862
+ when: z.ZodString;
863
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
864
+ policy: z.ZodOptional<z.ZodString>;
865
+ }, z.core.$strip>>>;
866
+ }, z.core.$strip>]>>;
867
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
868
+ default: z.ZodString;
869
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
870
+ when: z.ZodString;
871
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
872
+ policy: z.ZodOptional<z.ZodString>;
873
+ }, z.core.$strip>>>;
874
+ }, z.core.$strip>]>>;
875
+ }, z.core.$strict>>;
876
+ }, z.core.$strict>>;
877
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
383
878
  }, z.core.$strip>;
384
879
  type CanonicalView = z.infer<typeof canonicalViewSchema>;
880
+ /** The type each cell part is stored as. */
881
+ declare const CELL_PART_TYPES: Readonly<Record<CellPart, ColumnType>>;
882
+ interface TrackedShape {
883
+ columns: ReadonlyArray<{
884
+ name: string;
885
+ columnName: string;
886
+ onUpdateFn?: string;
887
+ cell?: {
888
+ of: string;
889
+ part: CellPart;
890
+ };
891
+ }>;
892
+ primaryKey?: readonly string[];
893
+ }
894
+ /** Columns a cell-tracking table stamps: everything except the primary key, clock columns and cell parts. */
895
+ declare function trackedCellColumns<T extends TrackedShape>(table: T): Array<T['columns'][number]>;
385
896
  declare const canonicalDefinitionSchema: z.ZodObject<{
386
897
  definition_format: z.ZodLiteral<2>;
387
898
  namespace: z.ZodString;
@@ -401,14 +912,14 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
401
912
  type: z.ZodUnion<readonly [z.ZodEnum<{
402
913
  bigint: "bigint";
403
914
  boolean: "boolean";
404
- uuid: "uuid";
405
915
  text: "text";
916
+ date: "date";
917
+ timestamptz: "timestamptz";
918
+ jsonb: "jsonb";
919
+ uuid: "uuid";
406
920
  integer: "integer";
407
921
  numeric: "numeric";
408
922
  double: "double";
409
- timestamptz: "timestamptz";
410
- date: "date";
411
- jsonb: "jsonb";
412
923
  }>, z.ZodObject<{
413
924
  enum: z.ZodString;
414
925
  }, z.core.$strip>]>;
@@ -419,10 +930,23 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
419
930
  "gen_random_uuid()": "gen_random_uuid()";
420
931
  "now()": "now()";
421
932
  }>>;
933
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
934
+ "now()": "now()";
935
+ }>>;
422
936
  description: z.ZodOptional<z.ZodString>;
423
937
  renamedFrom: z.ZodOptional<z.ZodString>;
424
938
  cast: z.ZodOptional<z.ZodString>;
425
939
  deprecated: z.ZodDefault<z.ZodBoolean>;
940
+ cell: z.ZodOptional<z.ZodObject<{
941
+ of: z.ZodString;
942
+ part: z.ZodEnum<{
943
+ at: "at";
944
+ by: "by";
945
+ rev: "rev";
946
+ source: "source";
947
+ conflicts: "conflicts";
948
+ }>;
949
+ }, z.core.$strict>>;
426
950
  }, z.core.$strip>>>;
427
951
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
428
952
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -436,6 +960,20 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
436
960
  on: z.ZodString;
437
961
  references: z.ZodOptional<z.ZodString>;
438
962
  enforce: z.ZodDefault<z.ZodBoolean>;
963
+ onDelete: z.ZodOptional<z.ZodEnum<{
964
+ cascade: "cascade";
965
+ restrict: "restrict";
966
+ "no action": "no action";
967
+ "set null": "set null";
968
+ "set default": "set default";
969
+ }>>;
970
+ onUpdate: z.ZodOptional<z.ZodEnum<{
971
+ cascade: "cascade";
972
+ restrict: "restrict";
973
+ "no action": "no action";
974
+ "set null": "set null";
975
+ "set default": "set default";
976
+ }>>;
439
977
  description: z.ZodOptional<z.ZodString>;
440
978
  }, z.core.$strip>>>;
441
979
  indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -443,6 +981,10 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
443
981
  unique: z.ZodDefault<z.ZodBoolean>;
444
982
  name: z.ZodOptional<z.ZodString>;
445
983
  }, z.core.$strip>>>;
984
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
985
+ name: z.ZodString;
986
+ expression: z.ZodString;
987
+ }, z.core.$strict>>>;
446
988
  policies: z.ZodDefault<z.ZodObject<{
447
989
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
448
990
  default: z.ZodString;
@@ -484,14 +1026,14 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
484
1026
  type: z.ZodEnum<{
485
1027
  bigint: "bigint";
486
1028
  boolean: "boolean";
487
- uuid: "uuid";
488
1029
  text: "text";
1030
+ date: "date";
1031
+ timestamptz: "timestamptz";
1032
+ jsonb: "jsonb";
1033
+ uuid: "uuid";
489
1034
  integer: "integer";
490
1035
  numeric: "numeric";
491
1036
  double: "double";
492
- timestamptz: "timestamptz";
493
- date: "date";
494
- jsonb: "jsonb";
495
1037
  }>;
496
1038
  nullable: z.ZodDefault<z.ZodBoolean>;
497
1039
  }, z.core.$strip>>>;
@@ -517,6 +1059,33 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
517
1059
  copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
518
1060
  set: z.ZodDefault<z.ZodArray<z.ZodString>>;
519
1061
  }, z.core.$strip>>>;
1062
+ foreignKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
1063
+ name: z.ZodString;
1064
+ columns: z.ZodArray<z.ZodString>;
1065
+ target: z.ZodString;
1066
+ references: z.ZodArray<z.ZodString>;
1067
+ deferrable: z.ZodOptional<z.ZodEnum<{
1068
+ "initially-immediate": "initially-immediate";
1069
+ "initially-deferred": "initially-deferred";
1070
+ }>>;
1071
+ onDelete: z.ZodOptional<z.ZodEnum<{
1072
+ cascade: "cascade";
1073
+ restrict: "restrict";
1074
+ "no action": "no action";
1075
+ "set null": "set null";
1076
+ "set default": "set default";
1077
+ }>>;
1078
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1079
+ cascade: "cascade";
1080
+ restrict: "restrict";
1081
+ "no action": "no action";
1082
+ "set null": "set null";
1083
+ "set default": "set default";
1084
+ }>>;
1085
+ }, z.core.$strict>>>;
1086
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
1087
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
1088
+ materializes: z.ZodOptional<z.ZodString>;
520
1089
  }, z.core.$strip>>;
521
1090
  views: z.ZodOptional<z.ZodArray<z.ZodObject<{
522
1091
  view: z.ZodString;
@@ -527,14 +1096,14 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
527
1096
  type: z.ZodUnion<readonly [z.ZodEnum<{
528
1097
  bigint: "bigint";
529
1098
  boolean: "boolean";
530
- uuid: "uuid";
531
1099
  text: "text";
1100
+ date: "date";
1101
+ timestamptz: "timestamptz";
1102
+ jsonb: "jsonb";
1103
+ uuid: "uuid";
532
1104
  integer: "integer";
533
1105
  numeric: "numeric";
534
1106
  double: "double";
535
- timestamptz: "timestamptz";
536
- date: "date";
537
- jsonb: "jsonb";
538
1107
  }>, z.ZodObject<{
539
1108
  enum: z.ZodString;
540
1109
  }, z.core.$strip>]>;
@@ -545,10 +1114,23 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
545
1114
  "gen_random_uuid()": "gen_random_uuid()";
546
1115
  "now()": "now()";
547
1116
  }>>;
1117
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
1118
+ "now()": "now()";
1119
+ }>>;
548
1120
  description: z.ZodOptional<z.ZodString>;
549
1121
  renamedFrom: z.ZodOptional<z.ZodString>;
550
1122
  cast: z.ZodOptional<z.ZodString>;
551
1123
  deprecated: z.ZodDefault<z.ZodBoolean>;
1124
+ cell: z.ZodOptional<z.ZodObject<{
1125
+ of: z.ZodString;
1126
+ part: z.ZodEnum<{
1127
+ at: "at";
1128
+ by: "by";
1129
+ rev: "rev";
1130
+ source: "source";
1131
+ conflicts: "conflicts";
1132
+ }>;
1133
+ }, z.core.$strict>>;
552
1134
  }, z.core.$strip>>;
553
1135
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
554
1136
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -562,6 +1144,20 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
562
1144
  on: z.ZodString;
563
1145
  references: z.ZodOptional<z.ZodString>;
564
1146
  enforce: z.ZodDefault<z.ZodBoolean>;
1147
+ onDelete: z.ZodOptional<z.ZodEnum<{
1148
+ cascade: "cascade";
1149
+ restrict: "restrict";
1150
+ "no action": "no action";
1151
+ "set null": "set null";
1152
+ "set default": "set default";
1153
+ }>>;
1154
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1155
+ cascade: "cascade";
1156
+ restrict: "restrict";
1157
+ "no action": "no action";
1158
+ "set null": "set null";
1159
+ "set default": "set default";
1160
+ }>>;
565
1161
  description: z.ZodOptional<z.ZodString>;
566
1162
  }, z.core.$strip>>>;
567
1163
  policies: z.ZodObject<{
@@ -576,6 +1172,95 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
576
1172
  }, z.core.$strict>;
577
1173
  query: z.ZodString;
578
1174
  dependencies: z.ZodArray<z.ZodString>;
1175
+ resolved: z.ZodOptional<z.ZodObject<{
1176
+ sources: z.ZodArray<z.ZodObject<{
1177
+ name: z.ZodString;
1178
+ kind: z.ZodEnum<{
1179
+ manual: "manual";
1180
+ prefetch: "prefetch";
1181
+ etl: "etl";
1182
+ }>;
1183
+ table: z.ZodString;
1184
+ columns: z.ZodArray<z.ZodString>;
1185
+ updatedAt: z.ZodOptional<z.ZodString>;
1186
+ key: z.ZodOptional<z.ZodString>;
1187
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
1188
+ shape: z.ZodLiteral<"single">;
1189
+ }, z.core.$strict>, z.ZodObject<{
1190
+ shape: z.ZodLiteral<"batch">;
1191
+ maxKeys: z.ZodNumber;
1192
+ }, z.core.$strict>]>>;
1193
+ function: z.ZodOptional<z.ZodObject<{
1194
+ kind: z.ZodEnum<{
1195
+ managed: "managed";
1196
+ native: "native";
1197
+ }>;
1198
+ id: z.ZodString;
1199
+ }, z.core.$strict>>;
1200
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
1201
+ maxStalenessMs: z.ZodNumber;
1202
+ timeoutMs: z.ZodNumber;
1203
+ onError: z.ZodEnum<{
1204
+ fallback: "fallback";
1205
+ fail: "fail";
1206
+ }>;
1207
+ }, z.core.$strict>>;
1208
+ writeback: z.ZodOptional<z.ZodObject<{
1209
+ columns: z.ZodArray<z.ZodString>;
1210
+ defaultMode: z.ZodEnum<{
1211
+ sync: "sync";
1212
+ async: "async";
1213
+ }>;
1214
+ timeoutMs: z.ZodNumber;
1215
+ clearManualOnConfirm: z.ZodBoolean;
1216
+ }, z.core.$strict>>;
1217
+ }, z.core.$strict>>;
1218
+ resolve: z.ZodArray<z.ZodObject<{
1219
+ column: z.ZodString;
1220
+ comparator: z.ZodEnum<{
1221
+ custom: "custom";
1222
+ latest: "latest";
1223
+ highest: "highest";
1224
+ lowest: "lowest";
1225
+ priority: "priority";
1226
+ nonNullFirst: "nonNullFirst";
1227
+ }>;
1228
+ candidates: z.ZodArray<z.ZodString>;
1229
+ orderBy: z.ZodOptional<z.ZodString>;
1230
+ }, z.core.$strict>>;
1231
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1232
+ materialized: z.ZodOptional<z.ZodObject<{
1233
+ table: z.ZodString;
1234
+ compute: z.ZodString;
1235
+ }, z.core.$strict>>;
1236
+ policies: z.ZodDefault<z.ZodObject<{
1237
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1238
+ default: z.ZodString;
1239
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1240
+ when: z.ZodString;
1241
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1242
+ policy: z.ZodOptional<z.ZodString>;
1243
+ }, z.core.$strip>>>;
1244
+ }, z.core.$strip>]>>;
1245
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1246
+ default: z.ZodString;
1247
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1248
+ when: z.ZodString;
1249
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1250
+ policy: z.ZodOptional<z.ZodString>;
1251
+ }, z.core.$strip>>>;
1252
+ }, z.core.$strip>]>>;
1253
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1254
+ default: z.ZodString;
1255
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1256
+ when: z.ZodString;
1257
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1258
+ policy: z.ZodOptional<z.ZodString>;
1259
+ }, z.core.$strip>>>;
1260
+ }, z.core.$strip>]>>;
1261
+ }, z.core.$strict>>;
1262
+ }, z.core.$strict>>;
1263
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
579
1264
  }, z.core.$strip>>>;
580
1265
  capabilities: z.ZodDefault<z.ZodObject<{
581
1266
  roles: z.ZodOptional<z.ZodUnknown>;
@@ -590,7 +1275,11 @@ type CanonicalDefinition = z.infer<typeof canonicalDefinitionSchema>;
590
1275
  * the canonical boundary makes SDL and compiler behavior identical without
591
1276
  * pretending views are writable tables in the wire contract.
592
1277
  */
593
- declare function canonicalRelations(definition: CanonicalDefinition): CanonicalTable[];
1278
+ /** A table or view as the compiler/SDL see it; resolved views also carry their multi-source metadata. */
1279
+ type CanonicalRelation = CanonicalTable & {
1280
+ resolved?: CanonicalResolved;
1281
+ };
1282
+ declare function canonicalRelations(definition: CanonicalDefinition): CanonicalRelation[];
594
1283
  /**
595
1284
  * Deterministic serialization discipline: tables sorted by name, columns in
596
1285
  * declaration order (order is meaningful for DDL), links/indexes/actions
@@ -600,4 +1289,4 @@ declare function canonicalRelations(definition: CanonicalDefinition): CanonicalT
600
1289
  */
601
1290
  declare function normalizeCanonical(definition: CanonicalDefinition): CanonicalDefinition;
602
1291
 
603
- export { CANONICAL_FORMAT, COLUMN_TYPES, type CanonicalColumn, type CanonicalCowMutation, type CanonicalDefinition, type CanonicalEnum, type CanonicalLink, type CanonicalTable, type CanonicalView, type ColumnType, IDENTIFIER_RE, type PolicyExpression, VIEW_QUERY_FUNCTION_ALLOWLIST, canonicalActionSchema, canonicalColumnSchema, canonicalCowMutationSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, isSingleViewQuerySql, normalizeCanonical, policyExpressionSchema, policyVariantSchema };
1292
+ export { CANONICAL_FORMAT, CELL_PART_TYPES, COLUMN_TYPES, COMPARATORS, type CanonicalCheck, type CanonicalColumn, type CanonicalCowMutation, type CanonicalDefinition, type CanonicalEnum, type CanonicalFetchShape, type CanonicalForeignKey, type CanonicalFunctionRef, type CanonicalLink, type CanonicalRelation, type CanonicalResolveRule, type CanonicalResolved, type CanonicalResolvedSource, type CanonicalTable, type CanonicalView, type ColumnType, type ComparatorKind, IDENTIFIER_RE, RESERVED_RESOLVED_COLUMN_NAMES, RESOLVED_SOURCE_CELL_PARTS, RESOLVED_SOURCE_SYSTEM_COLUMNS, RESOLVED_VIEW_CELL_PARTS, RESOLVED_VIEW_SYSTEM_COLUMNS, VIEW_QUERY_FUNCTION_ALLOWLIST, canonicalActionSchema, canonicalCheckSchema, canonicalColumnSchema, canonicalCowMutationSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalFetchShapeSchema, canonicalForeignKeySchema, canonicalFunctionRefSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalResolveRuleSchema, canonicalResolvedSchema, canonicalResolvedSourceSchema, canonicalTableSchema, canonicalViewSchema, isSingleViewQuerySql, normalizeCanonical, parseDurationMs, trackedCellColumns, validateResolvedView };