@sequenceholdings/orm 2.1.0 → 2.2.0

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 (77) hide show
  1. package/README.md +40 -1
  2. package/dist/authoring.cjs +1619 -121
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +252 -8
  5. package/dist/authoring.d.ts +252 -8
  6. package/dist/authoring.js +1607 -123
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +713 -41
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +1520 -51
  11. package/dist/canonical.d.ts +1520 -51
  12. package/dist/canonical.js +693 -42
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +7103 -3901
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +7104 -3902
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs +122 -40
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.cts +85 -25
  21. package/dist/client.d.ts +85 -25
  22. package/dist/client.js +119 -41
  23. package/dist/client.js.map +1 -1
  24. package/dist/compiler.cjs +2464 -450
  25. package/dist/compiler.cjs.map +1 -1
  26. package/dist/compiler.d.cts +79 -4
  27. package/dist/compiler.d.ts +79 -4
  28. package/dist/compiler.js +2457 -451
  29. package/dist/compiler.js.map +1 -1
  30. package/dist/constants-C6EG6Wq7.d.cts +99 -0
  31. package/dist/constants-C6EG6Wq7.d.ts +99 -0
  32. package/dist/definition-DjfC7Lll.d.cts +91 -0
  33. package/dist/definition-DjfC7Lll.d.ts +91 -0
  34. package/dist/dynamic-input.cjs +2 -1
  35. package/dist/dynamic-input.cjs.map +1 -1
  36. package/dist/dynamic-input.d.cts +9 -1
  37. package/dist/dynamic-input.d.ts +9 -1
  38. package/dist/dynamic-input.js +2 -1
  39. package/dist/dynamic-input.js.map +1 -1
  40. package/dist/index.cjs +2656 -418
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +693 -116
  43. package/dist/index.d.ts +693 -116
  44. package/dist/index.js +2622 -420
  45. package/dist/index.js.map +1 -1
  46. package/dist/ir.cjs +811 -48
  47. package/dist/ir.cjs.map +1 -1
  48. package/dist/ir.d.cts +670 -27
  49. package/dist/ir.d.ts +670 -27
  50. package/dist/ir.js +802 -49
  51. package/dist/ir.js.map +1 -1
  52. package/dist/{naming-DCn94LJ4.d.ts → naming-CPfx7EfF.d.ts} +14 -1
  53. package/dist/{naming-DPglwzkB.d.cts → naming-CU9ThP_E.d.cts} +14 -1
  54. package/dist/policy-1iZbGnZZ.d.cts +24 -0
  55. package/dist/policy-1iZbGnZZ.d.ts +24 -0
  56. package/dist/predicate-v2.cjs +804 -51
  57. package/dist/predicate-v2.cjs.map +1 -1
  58. package/dist/predicate-v2.d.cts +2 -1
  59. package/dist/predicate-v2.d.ts +2 -1
  60. package/dist/predicate-v2.js +804 -51
  61. package/dist/predicate-v2.js.map +1 -1
  62. package/dist/sdl.cjs +1014 -75
  63. package/dist/sdl.cjs.map +1 -1
  64. package/dist/sdl.d.cts +14 -3
  65. package/dist/sdl.d.ts +14 -3
  66. package/dist/sdl.js +1012 -76
  67. package/dist/sdl.js.map +1 -1
  68. package/package.json +13 -7
  69. package/src/codegen-gql/server-fns.cjs +2 -2
  70. package/templates/orm-namespace/AGENTS.md +10 -0
  71. package/templates/orm-namespace/CLAUDE.md +1 -82
  72. package/templates/orm-namespace/codegen.preset.d.cts +7 -0
  73. package/templates/orm-namespace/codegen.ts +2 -1
  74. package/templates/orm-namespace/graphql/example/queries.ts +4 -3
  75. package/templates/orm-namespace/package.json +2 -1
  76. package/templates/orm-namespace/schema/tables.ts +3 -2
  77. package/templates/orm-namespace/sequence.config.ts +7 -11
@@ -1,4 +1,298 @@
1
1
  import { z } from 'zod';
2
+ import { b as CellPart } from './constants-C6EG6Wq7.cjs';
3
+ export { P as PolicyExpression, p as policyExpressionSchema, a as policyVariantSchema } from './policy-1iZbGnZZ.cjs';
4
+
5
+ /** Authored intent only. Operation compilation validates reach; it never adds declarations. */
6
+ declare const ontologyContractSchema: z.ZodObject<{
7
+ version: z.ZodLiteral<1>;
8
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
9
+ write: z.ZodDefault<z.ZodArray<z.ZodString>>;
10
+ produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
11
+ invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
12
+ }, z.core.$strict>;
13
+ type OntologyContract = z.infer<typeof ontologyContractSchema>;
14
+ /** Missing is legacy; present-but-invalid fails closed, including null. */
15
+ declare function readOntologyContract(manifest: unknown): OntologyContract | undefined;
16
+
17
+ /**
18
+ * Canonical contract for resolved tables: one logical table (a generated
19
+ * managed view) backed by N source tables of three kinds —
20
+ *
21
+ * - `manual` an internal ORM table holding sparse user edits (the only
22
+ * GraphQL mutation target),
23
+ * - `etl` a synced (`source: schema.table`) table fed by a pipeline,
24
+ * - `prefetch` an internal ORM "live" table filled by a function that reads
25
+ * the source system on demand (and confirms writebacks).
26
+ *
27
+ * Each column picks its value across candidate sources with a SQL comparator
28
+ * compiled into the view, so policies, filters, sorting and nested relations
29
+ * all see resolved values. This module owns the metadata the compiler (write
30
+ * roots, directives) and data plane (prefetch, writeback) need; the view SQL
31
+ * itself is generated at authoring time and validated like any managed view.
32
+ */
33
+
34
+ /** `'1500ms'` / `'30s'` / `'5m'` (or a millisecond number) → milliseconds; undefined when malformed. */
35
+ declare function parseDurationMs(input: number | string): number | undefined;
36
+ /**
37
+ * Row-level system columns the generated view adds after the authored columns
38
+ * (GraphQL fields). Per-cell provenance lives in typed cell parts instead —
39
+ * see RESOLVED_VIEW_CELL_PARTS.
40
+ */
41
+ declare const RESOLVED_VIEW_SYSTEM_COLUMNS: {
42
+ readonly writebackStatus: {
43
+ readonly name: "writebackStatus";
44
+ readonly columnName: "_writeback_status";
45
+ readonly type: "text";
46
+ };
47
+ readonly writebackError: {
48
+ readonly name: "writebackError";
49
+ readonly columnName: "_writeback_error";
50
+ readonly type: "text";
51
+ };
52
+ };
53
+ /** System columns on the internal manual / live tables (never exposed in GraphQL). */
54
+ declare const RESOLVED_SOURCE_SYSTEM_COLUMNS: {
55
+ readonly tombstoned: {
56
+ readonly name: "sysTombstoned";
57
+ readonly columnName: "_tombstoned";
58
+ };
59
+ readonly fetchedAt: {
60
+ readonly name: "sysFetchedAt";
61
+ readonly columnName: "_fetched_at";
62
+ };
63
+ readonly writebackStatus: {
64
+ readonly name: "sysWritebackStatus";
65
+ readonly columnName: "_writeback_status";
66
+ };
67
+ readonly writebackError: {
68
+ readonly name: "sysWritebackError";
69
+ readonly columnName: "_writeback_error";
70
+ };
71
+ readonly writebackAt: {
72
+ readonly name: "sysWritebackAt";
73
+ readonly columnName: "_writeback_at";
74
+ };
75
+ };
76
+ /** Cell parts the resolved view exposes per resolved column: the winner's source, time, actor, and newer losers. */
77
+ declare const RESOLVED_VIEW_CELL_PARTS: readonly ["source", "at", "by", "conflicts"];
78
+ /** Cell parts on a resolved table's internal sources; only the manual source carries `rev`. */
79
+ declare const RESOLVED_SOURCE_CELL_PARTS: {
80
+ readonly manual: readonly ["at", "by", "rev"];
81
+ readonly prefetch: readonly ["at", "by"];
82
+ };
83
+ declare const RESERVED_RESOLVED_COLUMN_NAMES: ReadonlySet<string>;
84
+ declare const COMPARATORS: readonly ["latest", "highest", "lowest", "priority", "nonNullFirst", "custom"];
85
+ type ComparatorKind = (typeof COMPARATORS)[number];
86
+ declare const canonicalFunctionRefSchema: z.ZodObject<{
87
+ kind: z.ZodEnum<{
88
+ managed: "managed";
89
+ native: "native";
90
+ }>;
91
+ id: z.ZodString;
92
+ }, z.core.$strict>;
93
+ type CanonicalFunctionRef = z.infer<typeof canonicalFunctionRefSchema>;
94
+ /** What the source API can fetch: one key per call, or a batch of up to maxKeys. */
95
+ declare const canonicalFetchShapeSchema: z.ZodUnion<readonly [z.ZodObject<{
96
+ shape: z.ZodLiteral<"single">;
97
+ }, z.core.$strict>, z.ZodObject<{
98
+ shape: z.ZodLiteral<"batch">;
99
+ maxKeys: z.ZodNumber;
100
+ }, z.core.$strict>]>;
101
+ type CanonicalFetchShape = z.infer<typeof canonicalFetchShapeSchema>;
102
+ declare const canonicalResolvedSourceSchema: z.ZodObject<{
103
+ name: z.ZodString;
104
+ kind: z.ZodEnum<{
105
+ manual: "manual";
106
+ prefetch: "prefetch";
107
+ etl: "etl";
108
+ }>;
109
+ table: z.ZodString;
110
+ columns: z.ZodArray<z.ZodString>;
111
+ updatedAt: z.ZodOptional<z.ZodString>;
112
+ key: z.ZodOptional<z.ZodString>;
113
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
114
+ shape: z.ZodLiteral<"single">;
115
+ }, z.core.$strict>, z.ZodObject<{
116
+ shape: z.ZodLiteral<"batch">;
117
+ maxKeys: z.ZodNumber;
118
+ }, z.core.$strict>]>>;
119
+ function: z.ZodOptional<z.ZodObject<{
120
+ kind: z.ZodEnum<{
121
+ managed: "managed";
122
+ native: "native";
123
+ }>;
124
+ id: z.ZodString;
125
+ }, z.core.$strict>>;
126
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
127
+ maxStalenessMs: z.ZodNumber;
128
+ timeoutMs: z.ZodNumber;
129
+ onError: z.ZodEnum<{
130
+ fallback: "fallback";
131
+ fail: "fail";
132
+ }>;
133
+ }, z.core.$strict>>;
134
+ writeback: z.ZodOptional<z.ZodObject<{
135
+ columns: z.ZodArray<z.ZodString>;
136
+ defaultMode: z.ZodEnum<{
137
+ sync: "sync";
138
+ async: "async";
139
+ }>;
140
+ timeoutMs: z.ZodNumber;
141
+ clearManualOnConfirm: z.ZodBoolean;
142
+ }, z.core.$strict>>;
143
+ }, z.core.$strict>;
144
+ type CanonicalResolvedSource = z.infer<typeof canonicalResolvedSourceSchema>;
145
+ declare const canonicalResolveRuleSchema: z.ZodObject<{
146
+ column: z.ZodString;
147
+ comparator: z.ZodEnum<{
148
+ custom: "custom";
149
+ latest: "latest";
150
+ highest: "highest";
151
+ lowest: "lowest";
152
+ priority: "priority";
153
+ nonNullFirst: "nonNullFirst";
154
+ }>;
155
+ candidates: z.ZodArray<z.ZodString>;
156
+ orderBy: z.ZodOptional<z.ZodString>;
157
+ }, z.core.$strict>;
158
+ type CanonicalResolveRule = z.infer<typeof canonicalResolveRuleSchema>;
159
+ declare const canonicalResolvedSchema: z.ZodObject<{
160
+ sources: z.ZodArray<z.ZodObject<{
161
+ name: z.ZodString;
162
+ kind: z.ZodEnum<{
163
+ manual: "manual";
164
+ prefetch: "prefetch";
165
+ etl: "etl";
166
+ }>;
167
+ table: z.ZodString;
168
+ columns: z.ZodArray<z.ZodString>;
169
+ updatedAt: z.ZodOptional<z.ZodString>;
170
+ key: z.ZodOptional<z.ZodString>;
171
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
172
+ shape: z.ZodLiteral<"single">;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ shape: z.ZodLiteral<"batch">;
175
+ maxKeys: z.ZodNumber;
176
+ }, z.core.$strict>]>>;
177
+ function: z.ZodOptional<z.ZodObject<{
178
+ kind: z.ZodEnum<{
179
+ managed: "managed";
180
+ native: "native";
181
+ }>;
182
+ id: z.ZodString;
183
+ }, z.core.$strict>>;
184
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
185
+ maxStalenessMs: z.ZodNumber;
186
+ timeoutMs: z.ZodNumber;
187
+ onError: z.ZodEnum<{
188
+ fallback: "fallback";
189
+ fail: "fail";
190
+ }>;
191
+ }, z.core.$strict>>;
192
+ writeback: z.ZodOptional<z.ZodObject<{
193
+ columns: z.ZodArray<z.ZodString>;
194
+ defaultMode: z.ZodEnum<{
195
+ sync: "sync";
196
+ async: "async";
197
+ }>;
198
+ timeoutMs: z.ZodNumber;
199
+ clearManualOnConfirm: z.ZodBoolean;
200
+ }, z.core.$strict>>;
201
+ }, z.core.$strict>>;
202
+ resolve: z.ZodArray<z.ZodObject<{
203
+ column: z.ZodString;
204
+ comparator: z.ZodEnum<{
205
+ custom: "custom";
206
+ latest: "latest";
207
+ highest: "highest";
208
+ lowest: "lowest";
209
+ priority: "priority";
210
+ nonNullFirst: "nonNullFirst";
211
+ }>;
212
+ candidates: z.ZodArray<z.ZodString>;
213
+ orderBy: z.ZodOptional<z.ZodString>;
214
+ }, z.core.$strict>>;
215
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
216
+ materialized: z.ZodOptional<z.ZodObject<{
217
+ table: z.ZodString;
218
+ compute: z.ZodString;
219
+ }, z.core.$strict>>;
220
+ policies: z.ZodDefault<z.ZodObject<{
221
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
222
+ default: z.ZodString;
223
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
224
+ when: z.ZodString;
225
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
226
+ policy: z.ZodOptional<z.ZodString>;
227
+ }, z.core.$strip>>>;
228
+ }, z.core.$strip>]>>;
229
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
230
+ default: z.ZodString;
231
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
232
+ when: z.ZodString;
233
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
234
+ policy: z.ZodOptional<z.ZodString>;
235
+ }, z.core.$strip>>>;
236
+ }, z.core.$strip>]>>;
237
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
238
+ default: z.ZodString;
239
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
240
+ when: z.ZodString;
241
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
242
+ policy: z.ZodOptional<z.ZodString>;
243
+ }, z.core.$strip>>>;
244
+ }, z.core.$strip>]>>;
245
+ }, z.core.$strict>>;
246
+ }, z.core.$strict>;
247
+ type CanonicalResolved = z.infer<typeof canonicalResolvedSchema>;
248
+ interface RelationShape {
249
+ table: string;
250
+ source?: string;
251
+ internal?: true;
252
+ cellMetadata?: true;
253
+ materializes?: string;
254
+ policies?: {
255
+ read?: string | {
256
+ default: string;
257
+ variants: unknown[];
258
+ };
259
+ };
260
+ primaryKey?: string[];
261
+ columns: Array<{
262
+ name: string;
263
+ columnName: string;
264
+ type: unknown;
265
+ cell?: {
266
+ of: string;
267
+ part: CellPart;
268
+ };
269
+ }>;
270
+ }
271
+ interface ViewShape {
272
+ view: string;
273
+ internal?: true;
274
+ primaryKey?: string[];
275
+ columns: Array<{
276
+ name: string;
277
+ columnName: string;
278
+ type: unknown;
279
+ nullable?: boolean;
280
+ cell?: {
281
+ of: string;
282
+ part: CellPart;
283
+ };
284
+ }>;
285
+ resolved?: CanonicalResolved;
286
+ }
287
+ /**
288
+ * Cross-relation validation for one resolved view. Returns messages rather
289
+ * than throwing so the definition-level superRefine can attach paths.
290
+ */
291
+ declare function validateResolvedView({ view, tables, views }: {
292
+ view: ViewShape;
293
+ tables: readonly RelationShape[];
294
+ views?: readonly ViewShape[];
295
+ }): string[];
2
296
 
3
297
  /**
4
298
  * Canonical namespace definition v2 — the data-only JSON a consumer's
@@ -30,14 +324,14 @@ declare const canonicalColumnSchema: z.ZodObject<{
30
324
  type: z.ZodUnion<readonly [z.ZodEnum<{
31
325
  bigint: "bigint";
32
326
  boolean: "boolean";
33
- uuid: "uuid";
327
+ date: "date";
34
328
  text: "text";
329
+ timestamptz: "timestamptz";
330
+ jsonb: "jsonb";
331
+ uuid: "uuid";
35
332
  integer: "integer";
36
333
  numeric: "numeric";
37
334
  double: "double";
38
- timestamptz: "timestamptz";
39
- date: "date";
40
- jsonb: "jsonb";
41
335
  }>, z.ZodObject<{
42
336
  enum: z.ZodString;
43
337
  }, z.core.$strip>]>;
@@ -55,6 +349,16 @@ declare const canonicalColumnSchema: z.ZodObject<{
55
349
  renamedFrom: z.ZodOptional<z.ZodString>;
56
350
  cast: z.ZodOptional<z.ZodString>;
57
351
  deprecated: z.ZodDefault<z.ZodBoolean>;
352
+ cell: z.ZodOptional<z.ZodObject<{
353
+ of: z.ZodString;
354
+ part: z.ZodEnum<{
355
+ at: "at";
356
+ by: "by";
357
+ rev: "rev";
358
+ source: "source";
359
+ conflicts: "conflicts";
360
+ }>;
361
+ }, z.core.$strict>>;
58
362
  }, z.core.$strip>;
59
363
  type CanonicalColumn = z.infer<typeof canonicalColumnSchema>;
60
364
  declare const canonicalLinkSchema: z.ZodObject<{
@@ -65,9 +369,24 @@ declare const canonicalLinkSchema: z.ZodObject<{
65
369
  toPlatformUser: "toPlatformUser";
66
370
  }>;
67
371
  target: z.ZodOptional<z.ZodString>;
372
+ namespace: z.ZodOptional<z.ZodString>;
68
373
  on: z.ZodString;
69
374
  references: z.ZodOptional<z.ZodString>;
70
375
  enforce: z.ZodDefault<z.ZodBoolean>;
376
+ onDelete: z.ZodOptional<z.ZodEnum<{
377
+ cascade: "cascade";
378
+ restrict: "restrict";
379
+ "no action": "no action";
380
+ "set null": "set null";
381
+ "set default": "set default";
382
+ }>>;
383
+ onUpdate: z.ZodOptional<z.ZodEnum<{
384
+ cascade: "cascade";
385
+ restrict: "restrict";
386
+ "no action": "no action";
387
+ "set null": "set null";
388
+ "set default": "set default";
389
+ }>>;
71
390
  description: z.ZodOptional<z.ZodString>;
72
391
  }, z.core.$strip>;
73
392
  type CanonicalLink = z.infer<typeof canonicalLinkSchema>;
@@ -76,25 +395,12 @@ declare const canonicalIndexSchema: z.ZodObject<{
76
395
  unique: z.ZodDefault<z.ZodBoolean>;
77
396
  name: z.ZodOptional<z.ZodString>;
78
397
  }, z.core.$strip>;
79
- /**
80
- * Policy expressions stay DSL SOURCE STRINGS in the canonical form — parsing
81
- * and claim-key validation happen in both CLI and server via the shared
82
- * predicate parser. Variants follow §4c permissive-union semantics.
83
- */
84
- declare const policyVariantSchema: z.ZodObject<{
85
- when: z.ZodString;
86
- allow: z.ZodOptional<z.ZodLiteral<true>>;
87
- policy: z.ZodOptional<z.ZodString>;
88
- }, z.core.$strip>;
89
- declare const policyExpressionSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
90
- default: z.ZodString;
91
- variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
92
- when: z.ZodString;
93
- allow: z.ZodOptional<z.ZodLiteral<true>>;
94
- policy: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strip>>>;
96
- }, z.core.$strip>]>;
97
- type PolicyExpression = z.infer<typeof policyExpressionSchema>;
398
+ declare const canonicalCheckSchema: z.ZodObject<{
399
+ name: z.ZodString;
400
+ expression: z.ZodString;
401
+ }, z.core.$strict>;
402
+ type CanonicalCheck = z.infer<typeof canonicalCheckSchema>;
403
+
98
404
  declare const canonicalPoliciesSchema: z.ZodObject<{
99
405
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
100
406
  default: z.ZodString;
@@ -153,14 +459,14 @@ declare const canonicalActionSchema: z.ZodObject<{
153
459
  type: z.ZodEnum<{
154
460
  bigint: "bigint";
155
461
  boolean: "boolean";
156
- uuid: "uuid";
462
+ date: "date";
157
463
  text: "text";
464
+ timestamptz: "timestamptz";
465
+ jsonb: "jsonb";
466
+ uuid: "uuid";
158
467
  integer: "integer";
159
468
  numeric: "numeric";
160
469
  double: "double";
161
- timestamptz: "timestamptz";
162
- date: "date";
163
- jsonb: "jsonb";
164
470
  }>;
165
471
  nullable: z.ZodDefault<z.ZodBoolean>;
166
472
  }, z.core.$strip>>>;
@@ -205,10 +511,25 @@ declare const canonicalForeignKeySchema: z.ZodObject<{
205
511
  "initially-immediate": "initially-immediate";
206
512
  "initially-deferred": "initially-deferred";
207
513
  }>>;
514
+ onDelete: z.ZodOptional<z.ZodEnum<{
515
+ cascade: "cascade";
516
+ restrict: "restrict";
517
+ "no action": "no action";
518
+ "set null": "set null";
519
+ "set default": "set default";
520
+ }>>;
521
+ onUpdate: z.ZodOptional<z.ZodEnum<{
522
+ cascade: "cascade";
523
+ restrict: "restrict";
524
+ "no action": "no action";
525
+ "set null": "set null";
526
+ "set default": "set default";
527
+ }>>;
208
528
  }, z.core.$strict>;
209
529
  type CanonicalForeignKey = z.infer<typeof canonicalForeignKeySchema>;
210
530
  declare const canonicalTableSchema: z.ZodObject<{
211
531
  table: z.ZodString;
532
+ displayName: z.ZodOptional<z.ZodString>;
212
533
  description: z.ZodOptional<z.ZodString>;
213
534
  renamedFrom: z.ZodOptional<z.ZodString>;
214
535
  source: z.ZodOptional<z.ZodString>;
@@ -218,14 +539,14 @@ declare const canonicalTableSchema: z.ZodObject<{
218
539
  type: z.ZodUnion<readonly [z.ZodEnum<{
219
540
  bigint: "bigint";
220
541
  boolean: "boolean";
221
- uuid: "uuid";
542
+ date: "date";
222
543
  text: "text";
544
+ timestamptz: "timestamptz";
545
+ jsonb: "jsonb";
546
+ uuid: "uuid";
223
547
  integer: "integer";
224
548
  numeric: "numeric";
225
549
  double: "double";
226
- timestamptz: "timestamptz";
227
- date: "date";
228
- jsonb: "jsonb";
229
550
  }>, z.ZodObject<{
230
551
  enum: z.ZodString;
231
552
  }, z.core.$strip>]>;
@@ -243,6 +564,16 @@ declare const canonicalTableSchema: z.ZodObject<{
243
564
  renamedFrom: z.ZodOptional<z.ZodString>;
244
565
  cast: z.ZodOptional<z.ZodString>;
245
566
  deprecated: z.ZodDefault<z.ZodBoolean>;
567
+ cell: z.ZodOptional<z.ZodObject<{
568
+ of: z.ZodString;
569
+ part: z.ZodEnum<{
570
+ at: "at";
571
+ by: "by";
572
+ rev: "rev";
573
+ source: "source";
574
+ conflicts: "conflicts";
575
+ }>;
576
+ }, z.core.$strict>>;
246
577
  }, z.core.$strip>>>;
247
578
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
248
579
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -253,9 +584,24 @@ declare const canonicalTableSchema: z.ZodObject<{
253
584
  toPlatformUser: "toPlatformUser";
254
585
  }>;
255
586
  target: z.ZodOptional<z.ZodString>;
587
+ namespace: z.ZodOptional<z.ZodString>;
256
588
  on: z.ZodString;
257
589
  references: z.ZodOptional<z.ZodString>;
258
590
  enforce: z.ZodDefault<z.ZodBoolean>;
591
+ onDelete: z.ZodOptional<z.ZodEnum<{
592
+ cascade: "cascade";
593
+ restrict: "restrict";
594
+ "no action": "no action";
595
+ "set null": "set null";
596
+ "set default": "set default";
597
+ }>>;
598
+ onUpdate: z.ZodOptional<z.ZodEnum<{
599
+ cascade: "cascade";
600
+ restrict: "restrict";
601
+ "no action": "no action";
602
+ "set null": "set null";
603
+ "set default": "set default";
604
+ }>>;
259
605
  description: z.ZodOptional<z.ZodString>;
260
606
  }, z.core.$strip>>>;
261
607
  indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -263,6 +609,10 @@ declare const canonicalTableSchema: z.ZodObject<{
263
609
  unique: z.ZodDefault<z.ZodBoolean>;
264
610
  name: z.ZodOptional<z.ZodString>;
265
611
  }, z.core.$strip>>>;
612
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
613
+ name: z.ZodString;
614
+ expression: z.ZodString;
615
+ }, z.core.$strict>>>;
266
616
  policies: z.ZodDefault<z.ZodObject<{
267
617
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
268
618
  default: z.ZodString;
@@ -304,14 +654,14 @@ declare const canonicalTableSchema: z.ZodObject<{
304
654
  type: z.ZodEnum<{
305
655
  bigint: "bigint";
306
656
  boolean: "boolean";
307
- uuid: "uuid";
657
+ date: "date";
308
658
  text: "text";
659
+ timestamptz: "timestamptz";
660
+ jsonb: "jsonb";
661
+ uuid: "uuid";
309
662
  integer: "integer";
310
663
  numeric: "numeric";
311
664
  double: "double";
312
- timestamptz: "timestamptz";
313
- date: "date";
314
- jsonb: "jsonb";
315
665
  }>;
316
666
  nullable: z.ZodDefault<z.ZodBoolean>;
317
667
  }, z.core.$strip>>>;
@@ -346,7 +696,24 @@ declare const canonicalTableSchema: z.ZodObject<{
346
696
  "initially-immediate": "initially-immediate";
347
697
  "initially-deferred": "initially-deferred";
348
698
  }>>;
699
+ onDelete: z.ZodOptional<z.ZodEnum<{
700
+ cascade: "cascade";
701
+ restrict: "restrict";
702
+ "no action": "no action";
703
+ "set null": "set null";
704
+ "set default": "set default";
705
+ }>>;
706
+ onUpdate: z.ZodOptional<z.ZodEnum<{
707
+ cascade: "cascade";
708
+ restrict: "restrict";
709
+ "no action": "no action";
710
+ "set null": "set null";
711
+ "set default": "set default";
712
+ }>>;
349
713
  }, z.core.$strict>>>;
714
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
715
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
716
+ materializes: z.ZodOptional<z.ZodString>;
350
717
  }, z.core.$strip>;
351
718
  type CanonicalTable = z.infer<typeof canonicalTableSchema>;
352
719
  declare const canonicalViewSchema: z.ZodObject<{
@@ -358,14 +725,14 @@ declare const canonicalViewSchema: z.ZodObject<{
358
725
  type: z.ZodUnion<readonly [z.ZodEnum<{
359
726
  bigint: "bigint";
360
727
  boolean: "boolean";
361
- uuid: "uuid";
728
+ date: "date";
362
729
  text: "text";
730
+ timestamptz: "timestamptz";
731
+ jsonb: "jsonb";
732
+ uuid: "uuid";
363
733
  integer: "integer";
364
734
  numeric: "numeric";
365
735
  double: "double";
366
- timestamptz: "timestamptz";
367
- date: "date";
368
- jsonb: "jsonb";
369
736
  }>, z.ZodObject<{
370
737
  enum: z.ZodString;
371
738
  }, z.core.$strip>]>;
@@ -383,6 +750,16 @@ declare const canonicalViewSchema: z.ZodObject<{
383
750
  renamedFrom: z.ZodOptional<z.ZodString>;
384
751
  cast: z.ZodOptional<z.ZodString>;
385
752
  deprecated: z.ZodDefault<z.ZodBoolean>;
753
+ cell: z.ZodOptional<z.ZodObject<{
754
+ of: z.ZodString;
755
+ part: z.ZodEnum<{
756
+ at: "at";
757
+ by: "by";
758
+ rev: "rev";
759
+ source: "source";
760
+ conflicts: "conflicts";
761
+ }>;
762
+ }, z.core.$strict>>;
386
763
  }, z.core.$strip>>;
387
764
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
388
765
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -393,9 +770,24 @@ declare const canonicalViewSchema: z.ZodObject<{
393
770
  toPlatformUser: "toPlatformUser";
394
771
  }>;
395
772
  target: z.ZodOptional<z.ZodString>;
773
+ namespace: z.ZodOptional<z.ZodString>;
396
774
  on: z.ZodString;
397
775
  references: z.ZodOptional<z.ZodString>;
398
776
  enforce: z.ZodDefault<z.ZodBoolean>;
777
+ onDelete: z.ZodOptional<z.ZodEnum<{
778
+ cascade: "cascade";
779
+ restrict: "restrict";
780
+ "no action": "no action";
781
+ "set null": "set null";
782
+ "set default": "set default";
783
+ }>>;
784
+ onUpdate: z.ZodOptional<z.ZodEnum<{
785
+ cascade: "cascade";
786
+ restrict: "restrict";
787
+ "no action": "no action";
788
+ "set null": "set null";
789
+ "set default": "set default";
790
+ }>>;
399
791
  description: z.ZodOptional<z.ZodString>;
400
792
  }, z.core.$strip>>>;
401
793
  policies: z.ZodObject<{
@@ -410,9 +802,131 @@ declare const canonicalViewSchema: z.ZodObject<{
410
802
  }, z.core.$strict>;
411
803
  query: z.ZodString;
412
804
  dependencies: z.ZodArray<z.ZodString>;
805
+ resolved: z.ZodOptional<z.ZodObject<{
806
+ sources: z.ZodArray<z.ZodObject<{
807
+ name: z.ZodString;
808
+ kind: z.ZodEnum<{
809
+ manual: "manual";
810
+ prefetch: "prefetch";
811
+ etl: "etl";
812
+ }>;
813
+ table: z.ZodString;
814
+ columns: z.ZodArray<z.ZodString>;
815
+ updatedAt: z.ZodOptional<z.ZodString>;
816
+ key: z.ZodOptional<z.ZodString>;
817
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
818
+ shape: z.ZodLiteral<"single">;
819
+ }, z.core.$strict>, z.ZodObject<{
820
+ shape: z.ZodLiteral<"batch">;
821
+ maxKeys: z.ZodNumber;
822
+ }, z.core.$strict>]>>;
823
+ function: z.ZodOptional<z.ZodObject<{
824
+ kind: z.ZodEnum<{
825
+ managed: "managed";
826
+ native: "native";
827
+ }>;
828
+ id: z.ZodString;
829
+ }, z.core.$strict>>;
830
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
831
+ maxStalenessMs: z.ZodNumber;
832
+ timeoutMs: z.ZodNumber;
833
+ onError: z.ZodEnum<{
834
+ fallback: "fallback";
835
+ fail: "fail";
836
+ }>;
837
+ }, z.core.$strict>>;
838
+ writeback: z.ZodOptional<z.ZodObject<{
839
+ columns: z.ZodArray<z.ZodString>;
840
+ defaultMode: z.ZodEnum<{
841
+ sync: "sync";
842
+ async: "async";
843
+ }>;
844
+ timeoutMs: z.ZodNumber;
845
+ clearManualOnConfirm: z.ZodBoolean;
846
+ }, z.core.$strict>>;
847
+ }, z.core.$strict>>;
848
+ resolve: z.ZodArray<z.ZodObject<{
849
+ column: z.ZodString;
850
+ comparator: z.ZodEnum<{
851
+ custom: "custom";
852
+ latest: "latest";
853
+ highest: "highest";
854
+ lowest: "lowest";
855
+ priority: "priority";
856
+ nonNullFirst: "nonNullFirst";
857
+ }>;
858
+ candidates: z.ZodArray<z.ZodString>;
859
+ orderBy: z.ZodOptional<z.ZodString>;
860
+ }, z.core.$strict>>;
861
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
862
+ materialized: z.ZodOptional<z.ZodObject<{
863
+ table: z.ZodString;
864
+ compute: z.ZodString;
865
+ }, z.core.$strict>>;
866
+ policies: z.ZodDefault<z.ZodObject<{
867
+ write: 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
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
876
+ default: z.ZodString;
877
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
878
+ when: z.ZodString;
879
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
880
+ policy: z.ZodOptional<z.ZodString>;
881
+ }, z.core.$strip>>>;
882
+ }, z.core.$strip>]>>;
883
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
884
+ default: z.ZodString;
885
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
886
+ when: z.ZodString;
887
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
888
+ policy: z.ZodOptional<z.ZodString>;
889
+ }, z.core.$strip>>>;
890
+ }, z.core.$strip>]>>;
891
+ }, z.core.$strict>>;
892
+ }, z.core.$strict>>;
893
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
413
894
  }, z.core.$strip>;
414
895
  type CanonicalView = z.infer<typeof canonicalViewSchema>;
415
- declare const canonicalDefinitionSchema: z.ZodObject<{
896
+ /** The type each cell part is stored as. */
897
+ declare const CELL_PART_TYPES: Readonly<Record<CellPart, ColumnType>>;
898
+ interface TrackedShape {
899
+ columns: ReadonlyArray<{
900
+ name: string;
901
+ columnName: string;
902
+ onUpdateFn?: string;
903
+ cell?: {
904
+ of: string;
905
+ part: CellPart;
906
+ };
907
+ }>;
908
+ primaryKey?: readonly string[];
909
+ }
910
+ /** Columns a cell-tracking table stamps: everything except the primary key, clock columns and cell parts. */
911
+ declare function trackedCellColumns<T extends TrackedShape>(table: T): Array<T['columns'][number]>;
912
+ declare const exportGateSchema: z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
913
+ capability: z.ZodString;
914
+ }, z.core.$strict>, z.ZodObject<{
915
+ role: z.ZodString;
916
+ }, z.core.$strict>]>;
917
+ declare const relationExportSchema: z.ZodObject<{
918
+ read: z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
919
+ capability: z.ZodString;
920
+ }, z.core.$strict>, z.ZodObject<{
921
+ role: z.ZodString;
922
+ }, z.core.$strict>]>;
923
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
924
+ capability: z.ZodString;
925
+ }, z.core.$strict>, z.ZodObject<{
926
+ role: z.ZodString;
927
+ }, z.core.$strict>]>>;
928
+ }, z.core.$strict>;
929
+ declare const localDefinitionSchema: z.ZodObject<{
416
930
  definition_format: z.ZodLiteral<2>;
417
931
  namespace: z.ZodString;
418
932
  description: z.ZodOptional<z.ZodString>;
@@ -422,6 +936,7 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
422
936
  }, z.core.$strip>>>;
423
937
  tables: z.ZodArray<z.ZodObject<{
424
938
  table: z.ZodString;
939
+ displayName: z.ZodOptional<z.ZodString>;
425
940
  description: z.ZodOptional<z.ZodString>;
426
941
  renamedFrom: z.ZodOptional<z.ZodString>;
427
942
  source: z.ZodOptional<z.ZodString>;
@@ -431,14 +946,14 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
431
946
  type: z.ZodUnion<readonly [z.ZodEnum<{
432
947
  bigint: "bigint";
433
948
  boolean: "boolean";
434
- uuid: "uuid";
949
+ date: "date";
435
950
  text: "text";
951
+ timestamptz: "timestamptz";
952
+ jsonb: "jsonb";
953
+ uuid: "uuid";
436
954
  integer: "integer";
437
955
  numeric: "numeric";
438
956
  double: "double";
439
- timestamptz: "timestamptz";
440
- date: "date";
441
- jsonb: "jsonb";
442
957
  }>, z.ZodObject<{
443
958
  enum: z.ZodString;
444
959
  }, z.core.$strip>]>;
@@ -456,6 +971,16 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
456
971
  renamedFrom: z.ZodOptional<z.ZodString>;
457
972
  cast: z.ZodOptional<z.ZodString>;
458
973
  deprecated: z.ZodDefault<z.ZodBoolean>;
974
+ cell: z.ZodOptional<z.ZodObject<{
975
+ of: z.ZodString;
976
+ part: z.ZodEnum<{
977
+ at: "at";
978
+ by: "by";
979
+ rev: "rev";
980
+ source: "source";
981
+ conflicts: "conflicts";
982
+ }>;
983
+ }, z.core.$strict>>;
459
984
  }, z.core.$strip>>>;
460
985
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
461
986
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -466,9 +991,24 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
466
991
  toPlatformUser: "toPlatformUser";
467
992
  }>;
468
993
  target: z.ZodOptional<z.ZodString>;
994
+ namespace: z.ZodOptional<z.ZodString>;
469
995
  on: z.ZodString;
470
996
  references: z.ZodOptional<z.ZodString>;
471
997
  enforce: z.ZodDefault<z.ZodBoolean>;
998
+ onDelete: z.ZodOptional<z.ZodEnum<{
999
+ cascade: "cascade";
1000
+ restrict: "restrict";
1001
+ "no action": "no action";
1002
+ "set null": "set null";
1003
+ "set default": "set default";
1004
+ }>>;
1005
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1006
+ cascade: "cascade";
1007
+ restrict: "restrict";
1008
+ "no action": "no action";
1009
+ "set null": "set null";
1010
+ "set default": "set default";
1011
+ }>>;
472
1012
  description: z.ZodOptional<z.ZodString>;
473
1013
  }, z.core.$strip>>>;
474
1014
  indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -476,6 +1016,10 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
476
1016
  unique: z.ZodDefault<z.ZodBoolean>;
477
1017
  name: z.ZodOptional<z.ZodString>;
478
1018
  }, z.core.$strip>>>;
1019
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
1020
+ name: z.ZodString;
1021
+ expression: z.ZodString;
1022
+ }, z.core.$strict>>>;
479
1023
  policies: z.ZodDefault<z.ZodObject<{
480
1024
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
481
1025
  default: z.ZodString;
@@ -517,14 +1061,14 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
517
1061
  type: z.ZodEnum<{
518
1062
  bigint: "bigint";
519
1063
  boolean: "boolean";
520
- uuid: "uuid";
1064
+ date: "date";
521
1065
  text: "text";
1066
+ timestamptz: "timestamptz";
1067
+ jsonb: "jsonb";
1068
+ uuid: "uuid";
522
1069
  integer: "integer";
523
1070
  numeric: "numeric";
524
1071
  double: "double";
525
- timestamptz: "timestamptz";
526
- date: "date";
527
- jsonb: "jsonb";
528
1072
  }>;
529
1073
  nullable: z.ZodDefault<z.ZodBoolean>;
530
1074
  }, z.core.$strip>>>;
@@ -559,7 +1103,24 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
559
1103
  "initially-immediate": "initially-immediate";
560
1104
  "initially-deferred": "initially-deferred";
561
1105
  }>>;
1106
+ onDelete: z.ZodOptional<z.ZodEnum<{
1107
+ cascade: "cascade";
1108
+ restrict: "restrict";
1109
+ "no action": "no action";
1110
+ "set null": "set null";
1111
+ "set default": "set default";
1112
+ }>>;
1113
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1114
+ cascade: "cascade";
1115
+ restrict: "restrict";
1116
+ "no action": "no action";
1117
+ "set null": "set null";
1118
+ "set default": "set default";
1119
+ }>>;
562
1120
  }, z.core.$strict>>>;
1121
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
1122
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
1123
+ materializes: z.ZodOptional<z.ZodString>;
563
1124
  }, z.core.$strip>>;
564
1125
  views: z.ZodOptional<z.ZodArray<z.ZodObject<{
565
1126
  view: z.ZodString;
@@ -570,14 +1131,403 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
570
1131
  type: z.ZodUnion<readonly [z.ZodEnum<{
571
1132
  bigint: "bigint";
572
1133
  boolean: "boolean";
573
- uuid: "uuid";
1134
+ date: "date";
574
1135
  text: "text";
1136
+ timestamptz: "timestamptz";
1137
+ jsonb: "jsonb";
1138
+ uuid: "uuid";
575
1139
  integer: "integer";
576
1140
  numeric: "numeric";
577
1141
  double: "double";
1142
+ }>, z.ZodObject<{
1143
+ enum: z.ZodString;
1144
+ }, z.core.$strip>]>;
1145
+ nullable: z.ZodDefault<z.ZodBoolean>;
1146
+ unique: z.ZodDefault<z.ZodBoolean>;
1147
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
1148
+ defaultFn: z.ZodOptional<z.ZodEnum<{
1149
+ "gen_random_uuid()": "gen_random_uuid()";
1150
+ "now()": "now()";
1151
+ }>>;
1152
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
1153
+ "now()": "now()";
1154
+ }>>;
1155
+ description: z.ZodOptional<z.ZodString>;
1156
+ renamedFrom: z.ZodOptional<z.ZodString>;
1157
+ cast: z.ZodOptional<z.ZodString>;
1158
+ deprecated: z.ZodDefault<z.ZodBoolean>;
1159
+ cell: z.ZodOptional<z.ZodObject<{
1160
+ of: z.ZodString;
1161
+ part: z.ZodEnum<{
1162
+ at: "at";
1163
+ by: "by";
1164
+ rev: "rev";
1165
+ source: "source";
1166
+ conflicts: "conflicts";
1167
+ }>;
1168
+ }, z.core.$strict>>;
1169
+ }, z.core.$strip>>;
1170
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
1171
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
1172
+ name: z.ZodString;
1173
+ kind: z.ZodEnum<{
1174
+ toOne: "toOne";
1175
+ toMany: "toMany";
1176
+ toPlatformUser: "toPlatformUser";
1177
+ }>;
1178
+ target: z.ZodOptional<z.ZodString>;
1179
+ namespace: z.ZodOptional<z.ZodString>;
1180
+ on: z.ZodString;
1181
+ references: z.ZodOptional<z.ZodString>;
1182
+ enforce: z.ZodDefault<z.ZodBoolean>;
1183
+ onDelete: z.ZodOptional<z.ZodEnum<{
1184
+ cascade: "cascade";
1185
+ restrict: "restrict";
1186
+ "no action": "no action";
1187
+ "set null": "set null";
1188
+ "set default": "set default";
1189
+ }>>;
1190
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1191
+ cascade: "cascade";
1192
+ restrict: "restrict";
1193
+ "no action": "no action";
1194
+ "set null": "set null";
1195
+ "set default": "set default";
1196
+ }>>;
1197
+ description: z.ZodOptional<z.ZodString>;
1198
+ }, z.core.$strip>>>;
1199
+ policies: z.ZodObject<{
1200
+ read: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1201
+ default: z.ZodString;
1202
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1203
+ when: z.ZodString;
1204
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1205
+ policy: z.ZodOptional<z.ZodString>;
1206
+ }, z.core.$strip>>>;
1207
+ }, z.core.$strip>]>;
1208
+ }, z.core.$strict>;
1209
+ query: z.ZodString;
1210
+ dependencies: z.ZodArray<z.ZodString>;
1211
+ resolved: z.ZodOptional<z.ZodObject<{
1212
+ sources: z.ZodArray<z.ZodObject<{
1213
+ name: z.ZodString;
1214
+ kind: z.ZodEnum<{
1215
+ manual: "manual";
1216
+ prefetch: "prefetch";
1217
+ etl: "etl";
1218
+ }>;
1219
+ table: z.ZodString;
1220
+ columns: z.ZodArray<z.ZodString>;
1221
+ updatedAt: z.ZodOptional<z.ZodString>;
1222
+ key: z.ZodOptional<z.ZodString>;
1223
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
1224
+ shape: z.ZodLiteral<"single">;
1225
+ }, z.core.$strict>, z.ZodObject<{
1226
+ shape: z.ZodLiteral<"batch">;
1227
+ maxKeys: z.ZodNumber;
1228
+ }, z.core.$strict>]>>;
1229
+ function: z.ZodOptional<z.ZodObject<{
1230
+ kind: z.ZodEnum<{
1231
+ managed: "managed";
1232
+ native: "native";
1233
+ }>;
1234
+ id: z.ZodString;
1235
+ }, z.core.$strict>>;
1236
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
1237
+ maxStalenessMs: z.ZodNumber;
1238
+ timeoutMs: z.ZodNumber;
1239
+ onError: z.ZodEnum<{
1240
+ fallback: "fallback";
1241
+ fail: "fail";
1242
+ }>;
1243
+ }, z.core.$strict>>;
1244
+ writeback: z.ZodOptional<z.ZodObject<{
1245
+ columns: z.ZodArray<z.ZodString>;
1246
+ defaultMode: z.ZodEnum<{
1247
+ sync: "sync";
1248
+ async: "async";
1249
+ }>;
1250
+ timeoutMs: z.ZodNumber;
1251
+ clearManualOnConfirm: z.ZodBoolean;
1252
+ }, z.core.$strict>>;
1253
+ }, z.core.$strict>>;
1254
+ resolve: z.ZodArray<z.ZodObject<{
1255
+ column: z.ZodString;
1256
+ comparator: z.ZodEnum<{
1257
+ custom: "custom";
1258
+ latest: "latest";
1259
+ highest: "highest";
1260
+ lowest: "lowest";
1261
+ priority: "priority";
1262
+ nonNullFirst: "nonNullFirst";
1263
+ }>;
1264
+ candidates: z.ZodArray<z.ZodString>;
1265
+ orderBy: z.ZodOptional<z.ZodString>;
1266
+ }, z.core.$strict>>;
1267
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1268
+ materialized: z.ZodOptional<z.ZodObject<{
1269
+ table: z.ZodString;
1270
+ compute: z.ZodString;
1271
+ }, z.core.$strict>>;
1272
+ policies: z.ZodDefault<z.ZodObject<{
1273
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1274
+ default: z.ZodString;
1275
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1276
+ when: z.ZodString;
1277
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1278
+ policy: z.ZodOptional<z.ZodString>;
1279
+ }, z.core.$strip>>>;
1280
+ }, z.core.$strip>]>>;
1281
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1282
+ default: z.ZodString;
1283
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1284
+ when: z.ZodString;
1285
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1286
+ policy: z.ZodOptional<z.ZodString>;
1287
+ }, z.core.$strip>>>;
1288
+ }, z.core.$strip>]>>;
1289
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1290
+ default: z.ZodString;
1291
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1292
+ when: z.ZodString;
1293
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1294
+ policy: z.ZodOptional<z.ZodString>;
1295
+ }, z.core.$strip>>>;
1296
+ }, z.core.$strip>]>>;
1297
+ }, z.core.$strict>>;
1298
+ }, z.core.$strict>>;
1299
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
1300
+ }, z.core.$strip>>>;
1301
+ exports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1302
+ read: z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
1303
+ capability: z.ZodString;
1304
+ }, z.core.$strict>, z.ZodObject<{
1305
+ role: z.ZodString;
1306
+ }, z.core.$strict>]>;
1307
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
1308
+ capability: z.ZodString;
1309
+ }, z.core.$strict>, z.ZodObject<{
1310
+ role: z.ZodString;
1311
+ }, z.core.$strict>]>>;
1312
+ }, z.core.$strict>>>;
1313
+ capabilities: z.ZodDefault<z.ZodObject<{
1314
+ roles: z.ZodOptional<z.ZodUnknown>;
1315
+ uses: z.ZodDefault<z.ZodArray<z.ZodString>>;
1316
+ }, z.core.$strip>>;
1317
+ }, z.core.$strip>;
1318
+ declare const canonicalDefinitionSchema: z.ZodObject<{
1319
+ definition_format: z.ZodLiteral<2>;
1320
+ namespace: z.ZodString;
1321
+ description: z.ZodOptional<z.ZodString>;
1322
+ enums: z.ZodDefault<z.ZodArray<z.ZodObject<{
1323
+ name: z.ZodString;
1324
+ values: z.ZodArray<z.ZodString>;
1325
+ }, z.core.$strip>>>;
1326
+ tables: z.ZodArray<z.ZodObject<{
1327
+ table: z.ZodString;
1328
+ displayName: z.ZodOptional<z.ZodString>;
1329
+ description: z.ZodOptional<z.ZodString>;
1330
+ renamedFrom: z.ZodOptional<z.ZodString>;
1331
+ source: z.ZodOptional<z.ZodString>;
1332
+ columns: z.ZodDefault<z.ZodArray<z.ZodObject<{
1333
+ name: z.ZodString;
1334
+ columnName: z.ZodString;
1335
+ type: z.ZodUnion<readonly [z.ZodEnum<{
1336
+ bigint: "bigint";
1337
+ boolean: "boolean";
1338
+ date: "date";
1339
+ text: "text";
578
1340
  timestamptz: "timestamptz";
1341
+ jsonb: "jsonb";
1342
+ uuid: "uuid";
1343
+ integer: "integer";
1344
+ numeric: "numeric";
1345
+ double: "double";
1346
+ }>, z.ZodObject<{
1347
+ enum: z.ZodString;
1348
+ }, z.core.$strip>]>;
1349
+ nullable: z.ZodDefault<z.ZodBoolean>;
1350
+ unique: z.ZodDefault<z.ZodBoolean>;
1351
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
1352
+ defaultFn: z.ZodOptional<z.ZodEnum<{
1353
+ "gen_random_uuid()": "gen_random_uuid()";
1354
+ "now()": "now()";
1355
+ }>>;
1356
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
1357
+ "now()": "now()";
1358
+ }>>;
1359
+ description: z.ZodOptional<z.ZodString>;
1360
+ renamedFrom: z.ZodOptional<z.ZodString>;
1361
+ cast: z.ZodOptional<z.ZodString>;
1362
+ deprecated: z.ZodDefault<z.ZodBoolean>;
1363
+ cell: z.ZodOptional<z.ZodObject<{
1364
+ of: z.ZodString;
1365
+ part: z.ZodEnum<{
1366
+ at: "at";
1367
+ by: "by";
1368
+ rev: "rev";
1369
+ source: "source";
1370
+ conflicts: "conflicts";
1371
+ }>;
1372
+ }, z.core.$strict>>;
1373
+ }, z.core.$strip>>>;
1374
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
1375
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
1376
+ name: z.ZodString;
1377
+ kind: z.ZodEnum<{
1378
+ toOne: "toOne";
1379
+ toMany: "toMany";
1380
+ toPlatformUser: "toPlatformUser";
1381
+ }>;
1382
+ target: z.ZodOptional<z.ZodString>;
1383
+ namespace: z.ZodOptional<z.ZodString>;
1384
+ on: z.ZodString;
1385
+ references: z.ZodOptional<z.ZodString>;
1386
+ enforce: z.ZodDefault<z.ZodBoolean>;
1387
+ onDelete: z.ZodOptional<z.ZodEnum<{
1388
+ cascade: "cascade";
1389
+ restrict: "restrict";
1390
+ "no action": "no action";
1391
+ "set null": "set null";
1392
+ "set default": "set default";
1393
+ }>>;
1394
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1395
+ cascade: "cascade";
1396
+ restrict: "restrict";
1397
+ "no action": "no action";
1398
+ "set null": "set null";
1399
+ "set default": "set default";
1400
+ }>>;
1401
+ description: z.ZodOptional<z.ZodString>;
1402
+ }, z.core.$strip>>>;
1403
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
1404
+ columns: z.ZodArray<z.ZodString>;
1405
+ unique: z.ZodDefault<z.ZodBoolean>;
1406
+ name: z.ZodOptional<z.ZodString>;
1407
+ }, z.core.$strip>>>;
1408
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
1409
+ name: z.ZodString;
1410
+ expression: z.ZodString;
1411
+ }, z.core.$strict>>>;
1412
+ policies: z.ZodDefault<z.ZodObject<{
1413
+ read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1414
+ default: z.ZodString;
1415
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1416
+ when: z.ZodString;
1417
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1418
+ policy: z.ZodOptional<z.ZodString>;
1419
+ }, z.core.$strip>>>;
1420
+ }, z.core.$strip>]>>;
1421
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1422
+ default: z.ZodString;
1423
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1424
+ when: z.ZodString;
1425
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1426
+ policy: z.ZodOptional<z.ZodString>;
1427
+ }, z.core.$strip>>>;
1428
+ }, z.core.$strip>]>>;
1429
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1430
+ default: z.ZodString;
1431
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1432
+ when: z.ZodString;
1433
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1434
+ policy: z.ZodOptional<z.ZodString>;
1435
+ }, z.core.$strip>>>;
1436
+ }, z.core.$strip>]>>;
1437
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1438
+ default: z.ZodString;
1439
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1440
+ when: z.ZodString;
1441
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1442
+ policy: z.ZodOptional<z.ZodString>;
1443
+ }, z.core.$strip>>>;
1444
+ }, z.core.$strip>]>>;
1445
+ }, z.core.$strip>>;
1446
+ actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
1447
+ name: z.ZodString;
1448
+ requires: z.ZodOptional<z.ZodString>;
1449
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1450
+ type: z.ZodEnum<{
1451
+ bigint: "bigint";
1452
+ boolean: "boolean";
1453
+ date: "date";
1454
+ text: "text";
1455
+ timestamptz: "timestamptz";
1456
+ jsonb: "jsonb";
1457
+ uuid: "uuid";
1458
+ integer: "integer";
1459
+ numeric: "numeric";
1460
+ double: "double";
1461
+ }>;
1462
+ nullable: z.ZodDefault<z.ZodBoolean>;
1463
+ }, z.core.$strip>>>;
1464
+ executes: z.ZodString;
1465
+ returns: z.ZodDefault<z.ZodEnum<{
1466
+ rows: "rows";
1467
+ rowsAffected: "rowsAffected";
1468
+ scalar: "scalar";
1469
+ }>>;
1470
+ audit: z.ZodOptional<z.ZodObject<{
1471
+ action: z.ZodString;
1472
+ resource: z.ZodString;
1473
+ }, z.core.$strip>>;
1474
+ }, z.core.$strip>>>;
1475
+ cowMutations: z.ZodOptional<z.ZodArray<z.ZodObject<{
1476
+ kind: z.ZodEnum<{
1477
+ override: "override";
1478
+ revert: "revert";
1479
+ }>;
1480
+ name: z.ZodString;
1481
+ synced: z.ZodString;
1482
+ pk: z.ZodString;
1483
+ copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1484
+ set: z.ZodDefault<z.ZodArray<z.ZodString>>;
1485
+ }, z.core.$strip>>>;
1486
+ foreignKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
1487
+ name: z.ZodString;
1488
+ columns: z.ZodArray<z.ZodString>;
1489
+ target: z.ZodString;
1490
+ references: z.ZodArray<z.ZodString>;
1491
+ deferrable: z.ZodOptional<z.ZodEnum<{
1492
+ "initially-immediate": "initially-immediate";
1493
+ "initially-deferred": "initially-deferred";
1494
+ }>>;
1495
+ onDelete: z.ZodOptional<z.ZodEnum<{
1496
+ cascade: "cascade";
1497
+ restrict: "restrict";
1498
+ "no action": "no action";
1499
+ "set null": "set null";
1500
+ "set default": "set default";
1501
+ }>>;
1502
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1503
+ cascade: "cascade";
1504
+ restrict: "restrict";
1505
+ "no action": "no action";
1506
+ "set null": "set null";
1507
+ "set default": "set default";
1508
+ }>>;
1509
+ }, z.core.$strict>>>;
1510
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
1511
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
1512
+ materializes: z.ZodOptional<z.ZodString>;
1513
+ }, z.core.$strip>>;
1514
+ views: z.ZodOptional<z.ZodArray<z.ZodObject<{
1515
+ view: z.ZodString;
1516
+ description: z.ZodOptional<z.ZodString>;
1517
+ columns: z.ZodArray<z.ZodObject<{
1518
+ name: z.ZodString;
1519
+ columnName: z.ZodString;
1520
+ type: z.ZodUnion<readonly [z.ZodEnum<{
1521
+ bigint: "bigint";
1522
+ boolean: "boolean";
579
1523
  date: "date";
1524
+ text: "text";
1525
+ timestamptz: "timestamptz";
580
1526
  jsonb: "jsonb";
1527
+ uuid: "uuid";
1528
+ integer: "integer";
1529
+ numeric: "numeric";
1530
+ double: "double";
581
1531
  }>, z.ZodObject<{
582
1532
  enum: z.ZodString;
583
1533
  }, z.core.$strip>]>;
@@ -595,6 +1545,16 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
595
1545
  renamedFrom: z.ZodOptional<z.ZodString>;
596
1546
  cast: z.ZodOptional<z.ZodString>;
597
1547
  deprecated: z.ZodDefault<z.ZodBoolean>;
1548
+ cell: z.ZodOptional<z.ZodObject<{
1549
+ of: z.ZodString;
1550
+ part: z.ZodEnum<{
1551
+ at: "at";
1552
+ by: "by";
1553
+ rev: "rev";
1554
+ source: "source";
1555
+ conflicts: "conflicts";
1556
+ }>;
1557
+ }, z.core.$strict>>;
598
1558
  }, z.core.$strip>>;
599
1559
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
600
1560
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -605,9 +1565,24 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
605
1565
  toPlatformUser: "toPlatformUser";
606
1566
  }>;
607
1567
  target: z.ZodOptional<z.ZodString>;
1568
+ namespace: z.ZodOptional<z.ZodString>;
608
1569
  on: z.ZodString;
609
1570
  references: z.ZodOptional<z.ZodString>;
610
1571
  enforce: z.ZodDefault<z.ZodBoolean>;
1572
+ onDelete: z.ZodOptional<z.ZodEnum<{
1573
+ cascade: "cascade";
1574
+ restrict: "restrict";
1575
+ "no action": "no action";
1576
+ "set null": "set null";
1577
+ "set default": "set default";
1578
+ }>>;
1579
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1580
+ cascade: "cascade";
1581
+ restrict: "restrict";
1582
+ "no action": "no action";
1583
+ "set null": "set null";
1584
+ "set default": "set default";
1585
+ }>>;
611
1586
  description: z.ZodOptional<z.ZodString>;
612
1587
  }, z.core.$strip>>>;
613
1588
  policies: z.ZodObject<{
@@ -622,11 +1597,501 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
622
1597
  }, z.core.$strict>;
623
1598
  query: z.ZodString;
624
1599
  dependencies: z.ZodArray<z.ZodString>;
1600
+ resolved: z.ZodOptional<z.ZodObject<{
1601
+ sources: z.ZodArray<z.ZodObject<{
1602
+ name: z.ZodString;
1603
+ kind: z.ZodEnum<{
1604
+ manual: "manual";
1605
+ prefetch: "prefetch";
1606
+ etl: "etl";
1607
+ }>;
1608
+ table: z.ZodString;
1609
+ columns: z.ZodArray<z.ZodString>;
1610
+ updatedAt: z.ZodOptional<z.ZodString>;
1611
+ key: z.ZodOptional<z.ZodString>;
1612
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
1613
+ shape: z.ZodLiteral<"single">;
1614
+ }, z.core.$strict>, z.ZodObject<{
1615
+ shape: z.ZodLiteral<"batch">;
1616
+ maxKeys: z.ZodNumber;
1617
+ }, z.core.$strict>]>>;
1618
+ function: z.ZodOptional<z.ZodObject<{
1619
+ kind: z.ZodEnum<{
1620
+ managed: "managed";
1621
+ native: "native";
1622
+ }>;
1623
+ id: z.ZodString;
1624
+ }, z.core.$strict>>;
1625
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
1626
+ maxStalenessMs: z.ZodNumber;
1627
+ timeoutMs: z.ZodNumber;
1628
+ onError: z.ZodEnum<{
1629
+ fallback: "fallback";
1630
+ fail: "fail";
1631
+ }>;
1632
+ }, z.core.$strict>>;
1633
+ writeback: z.ZodOptional<z.ZodObject<{
1634
+ columns: z.ZodArray<z.ZodString>;
1635
+ defaultMode: z.ZodEnum<{
1636
+ sync: "sync";
1637
+ async: "async";
1638
+ }>;
1639
+ timeoutMs: z.ZodNumber;
1640
+ clearManualOnConfirm: z.ZodBoolean;
1641
+ }, z.core.$strict>>;
1642
+ }, z.core.$strict>>;
1643
+ resolve: z.ZodArray<z.ZodObject<{
1644
+ column: z.ZodString;
1645
+ comparator: z.ZodEnum<{
1646
+ custom: "custom";
1647
+ latest: "latest";
1648
+ highest: "highest";
1649
+ lowest: "lowest";
1650
+ priority: "priority";
1651
+ nonNullFirst: "nonNullFirst";
1652
+ }>;
1653
+ candidates: z.ZodArray<z.ZodString>;
1654
+ orderBy: z.ZodOptional<z.ZodString>;
1655
+ }, z.core.$strict>>;
1656
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1657
+ materialized: z.ZodOptional<z.ZodObject<{
1658
+ table: z.ZodString;
1659
+ compute: z.ZodString;
1660
+ }, z.core.$strict>>;
1661
+ policies: z.ZodDefault<z.ZodObject<{
1662
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1663
+ default: z.ZodString;
1664
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1665
+ when: z.ZodString;
1666
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1667
+ policy: z.ZodOptional<z.ZodString>;
1668
+ }, z.core.$strip>>>;
1669
+ }, z.core.$strip>]>>;
1670
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1671
+ default: z.ZodString;
1672
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1673
+ when: z.ZodString;
1674
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1675
+ policy: z.ZodOptional<z.ZodString>;
1676
+ }, z.core.$strip>>>;
1677
+ }, z.core.$strip>]>>;
1678
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1679
+ default: z.ZodString;
1680
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1681
+ when: z.ZodString;
1682
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1683
+ policy: z.ZodOptional<z.ZodString>;
1684
+ }, z.core.$strip>>>;
1685
+ }, z.core.$strip>]>>;
1686
+ }, z.core.$strict>>;
1687
+ }, z.core.$strict>>;
1688
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
625
1689
  }, z.core.$strip>>>;
1690
+ exports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1691
+ read: z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
1692
+ capability: z.ZodString;
1693
+ }, z.core.$strict>, z.ZodObject<{
1694
+ role: z.ZodString;
1695
+ }, z.core.$strict>]>;
1696
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
1697
+ capability: z.ZodString;
1698
+ }, z.core.$strict>, z.ZodObject<{
1699
+ role: z.ZodString;
1700
+ }, z.core.$strict>]>>;
1701
+ }, z.core.$strict>>>;
626
1702
  capabilities: z.ZodDefault<z.ZodObject<{
627
1703
  roles: z.ZodOptional<z.ZodUnknown>;
628
1704
  uses: z.ZodDefault<z.ZodArray<z.ZodString>>;
629
1705
  }, z.core.$strip>>;
1706
+ imports: z.ZodOptional<z.ZodArray<z.ZodObject<{
1707
+ definition_format: z.ZodLiteral<2>;
1708
+ namespace: z.ZodString;
1709
+ description: z.ZodOptional<z.ZodString>;
1710
+ enums: z.ZodDefault<z.ZodArray<z.ZodObject<{
1711
+ name: z.ZodString;
1712
+ values: z.ZodArray<z.ZodString>;
1713
+ }, z.core.$strip>>>;
1714
+ tables: z.ZodArray<z.ZodObject<{
1715
+ table: z.ZodString;
1716
+ displayName: z.ZodOptional<z.ZodString>;
1717
+ description: z.ZodOptional<z.ZodString>;
1718
+ renamedFrom: z.ZodOptional<z.ZodString>;
1719
+ source: z.ZodOptional<z.ZodString>;
1720
+ columns: z.ZodDefault<z.ZodArray<z.ZodObject<{
1721
+ name: z.ZodString;
1722
+ columnName: z.ZodString;
1723
+ type: z.ZodUnion<readonly [z.ZodEnum<{
1724
+ bigint: "bigint";
1725
+ boolean: "boolean";
1726
+ date: "date";
1727
+ text: "text";
1728
+ timestamptz: "timestamptz";
1729
+ jsonb: "jsonb";
1730
+ uuid: "uuid";
1731
+ integer: "integer";
1732
+ numeric: "numeric";
1733
+ double: "double";
1734
+ }>, z.ZodObject<{
1735
+ enum: z.ZodString;
1736
+ }, z.core.$strip>]>;
1737
+ nullable: z.ZodDefault<z.ZodBoolean>;
1738
+ unique: z.ZodDefault<z.ZodBoolean>;
1739
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
1740
+ defaultFn: z.ZodOptional<z.ZodEnum<{
1741
+ "gen_random_uuid()": "gen_random_uuid()";
1742
+ "now()": "now()";
1743
+ }>>;
1744
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
1745
+ "now()": "now()";
1746
+ }>>;
1747
+ description: z.ZodOptional<z.ZodString>;
1748
+ renamedFrom: z.ZodOptional<z.ZodString>;
1749
+ cast: z.ZodOptional<z.ZodString>;
1750
+ deprecated: z.ZodDefault<z.ZodBoolean>;
1751
+ cell: z.ZodOptional<z.ZodObject<{
1752
+ of: z.ZodString;
1753
+ part: z.ZodEnum<{
1754
+ at: "at";
1755
+ by: "by";
1756
+ rev: "rev";
1757
+ source: "source";
1758
+ conflicts: "conflicts";
1759
+ }>;
1760
+ }, z.core.$strict>>;
1761
+ }, z.core.$strip>>>;
1762
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
1763
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
1764
+ name: z.ZodString;
1765
+ kind: z.ZodEnum<{
1766
+ toOne: "toOne";
1767
+ toMany: "toMany";
1768
+ toPlatformUser: "toPlatformUser";
1769
+ }>;
1770
+ target: z.ZodOptional<z.ZodString>;
1771
+ namespace: z.ZodOptional<z.ZodString>;
1772
+ on: z.ZodString;
1773
+ references: z.ZodOptional<z.ZodString>;
1774
+ enforce: z.ZodDefault<z.ZodBoolean>;
1775
+ onDelete: z.ZodOptional<z.ZodEnum<{
1776
+ cascade: "cascade";
1777
+ restrict: "restrict";
1778
+ "no action": "no action";
1779
+ "set null": "set null";
1780
+ "set default": "set default";
1781
+ }>>;
1782
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1783
+ cascade: "cascade";
1784
+ restrict: "restrict";
1785
+ "no action": "no action";
1786
+ "set null": "set null";
1787
+ "set default": "set default";
1788
+ }>>;
1789
+ description: z.ZodOptional<z.ZodString>;
1790
+ }, z.core.$strip>>>;
1791
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
1792
+ columns: z.ZodArray<z.ZodString>;
1793
+ unique: z.ZodDefault<z.ZodBoolean>;
1794
+ name: z.ZodOptional<z.ZodString>;
1795
+ }, z.core.$strip>>>;
1796
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
1797
+ name: z.ZodString;
1798
+ expression: z.ZodString;
1799
+ }, z.core.$strict>>>;
1800
+ policies: z.ZodDefault<z.ZodObject<{
1801
+ read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1802
+ default: z.ZodString;
1803
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1804
+ when: z.ZodString;
1805
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1806
+ policy: z.ZodOptional<z.ZodString>;
1807
+ }, z.core.$strip>>>;
1808
+ }, z.core.$strip>]>>;
1809
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1810
+ default: z.ZodString;
1811
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1812
+ when: z.ZodString;
1813
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1814
+ policy: z.ZodOptional<z.ZodString>;
1815
+ }, z.core.$strip>>>;
1816
+ }, z.core.$strip>]>>;
1817
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1818
+ default: z.ZodString;
1819
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1820
+ when: z.ZodString;
1821
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1822
+ policy: z.ZodOptional<z.ZodString>;
1823
+ }, z.core.$strip>>>;
1824
+ }, z.core.$strip>]>>;
1825
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1826
+ default: z.ZodString;
1827
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1828
+ when: z.ZodString;
1829
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1830
+ policy: z.ZodOptional<z.ZodString>;
1831
+ }, z.core.$strip>>>;
1832
+ }, z.core.$strip>]>>;
1833
+ }, z.core.$strip>>;
1834
+ actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
1835
+ name: z.ZodString;
1836
+ requires: z.ZodOptional<z.ZodString>;
1837
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1838
+ type: z.ZodEnum<{
1839
+ bigint: "bigint";
1840
+ boolean: "boolean";
1841
+ date: "date";
1842
+ text: "text";
1843
+ timestamptz: "timestamptz";
1844
+ jsonb: "jsonb";
1845
+ uuid: "uuid";
1846
+ integer: "integer";
1847
+ numeric: "numeric";
1848
+ double: "double";
1849
+ }>;
1850
+ nullable: z.ZodDefault<z.ZodBoolean>;
1851
+ }, z.core.$strip>>>;
1852
+ executes: z.ZodString;
1853
+ returns: z.ZodDefault<z.ZodEnum<{
1854
+ rows: "rows";
1855
+ rowsAffected: "rowsAffected";
1856
+ scalar: "scalar";
1857
+ }>>;
1858
+ audit: z.ZodOptional<z.ZodObject<{
1859
+ action: z.ZodString;
1860
+ resource: z.ZodString;
1861
+ }, z.core.$strip>>;
1862
+ }, z.core.$strip>>>;
1863
+ cowMutations: z.ZodOptional<z.ZodArray<z.ZodObject<{
1864
+ kind: z.ZodEnum<{
1865
+ override: "override";
1866
+ revert: "revert";
1867
+ }>;
1868
+ name: z.ZodString;
1869
+ synced: z.ZodString;
1870
+ pk: z.ZodString;
1871
+ copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1872
+ set: z.ZodDefault<z.ZodArray<z.ZodString>>;
1873
+ }, z.core.$strip>>>;
1874
+ foreignKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{
1875
+ name: z.ZodString;
1876
+ columns: z.ZodArray<z.ZodString>;
1877
+ target: z.ZodString;
1878
+ references: z.ZodArray<z.ZodString>;
1879
+ deferrable: z.ZodOptional<z.ZodEnum<{
1880
+ "initially-immediate": "initially-immediate";
1881
+ "initially-deferred": "initially-deferred";
1882
+ }>>;
1883
+ onDelete: z.ZodOptional<z.ZodEnum<{
1884
+ cascade: "cascade";
1885
+ restrict: "restrict";
1886
+ "no action": "no action";
1887
+ "set null": "set null";
1888
+ "set default": "set default";
1889
+ }>>;
1890
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1891
+ cascade: "cascade";
1892
+ restrict: "restrict";
1893
+ "no action": "no action";
1894
+ "set null": "set null";
1895
+ "set default": "set default";
1896
+ }>>;
1897
+ }, z.core.$strict>>>;
1898
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
1899
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
1900
+ materializes: z.ZodOptional<z.ZodString>;
1901
+ }, z.core.$strip>>;
1902
+ views: z.ZodOptional<z.ZodArray<z.ZodObject<{
1903
+ view: z.ZodString;
1904
+ description: z.ZodOptional<z.ZodString>;
1905
+ columns: z.ZodArray<z.ZodObject<{
1906
+ name: z.ZodString;
1907
+ columnName: z.ZodString;
1908
+ type: z.ZodUnion<readonly [z.ZodEnum<{
1909
+ bigint: "bigint";
1910
+ boolean: "boolean";
1911
+ date: "date";
1912
+ text: "text";
1913
+ timestamptz: "timestamptz";
1914
+ jsonb: "jsonb";
1915
+ uuid: "uuid";
1916
+ integer: "integer";
1917
+ numeric: "numeric";
1918
+ double: "double";
1919
+ }>, z.ZodObject<{
1920
+ enum: z.ZodString;
1921
+ }, z.core.$strip>]>;
1922
+ nullable: z.ZodDefault<z.ZodBoolean>;
1923
+ unique: z.ZodDefault<z.ZodBoolean>;
1924
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
1925
+ defaultFn: z.ZodOptional<z.ZodEnum<{
1926
+ "gen_random_uuid()": "gen_random_uuid()";
1927
+ "now()": "now()";
1928
+ }>>;
1929
+ onUpdateFn: z.ZodOptional<z.ZodEnum<{
1930
+ "now()": "now()";
1931
+ }>>;
1932
+ description: z.ZodOptional<z.ZodString>;
1933
+ renamedFrom: z.ZodOptional<z.ZodString>;
1934
+ cast: z.ZodOptional<z.ZodString>;
1935
+ deprecated: z.ZodDefault<z.ZodBoolean>;
1936
+ cell: z.ZodOptional<z.ZodObject<{
1937
+ of: z.ZodString;
1938
+ part: z.ZodEnum<{
1939
+ at: "at";
1940
+ by: "by";
1941
+ rev: "rev";
1942
+ source: "source";
1943
+ conflicts: "conflicts";
1944
+ }>;
1945
+ }, z.core.$strict>>;
1946
+ }, z.core.$strip>>;
1947
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
1948
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
1949
+ name: z.ZodString;
1950
+ kind: z.ZodEnum<{
1951
+ toOne: "toOne";
1952
+ toMany: "toMany";
1953
+ toPlatformUser: "toPlatformUser";
1954
+ }>;
1955
+ target: z.ZodOptional<z.ZodString>;
1956
+ namespace: z.ZodOptional<z.ZodString>;
1957
+ on: z.ZodString;
1958
+ references: z.ZodOptional<z.ZodString>;
1959
+ enforce: z.ZodDefault<z.ZodBoolean>;
1960
+ onDelete: z.ZodOptional<z.ZodEnum<{
1961
+ cascade: "cascade";
1962
+ restrict: "restrict";
1963
+ "no action": "no action";
1964
+ "set null": "set null";
1965
+ "set default": "set default";
1966
+ }>>;
1967
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1968
+ cascade: "cascade";
1969
+ restrict: "restrict";
1970
+ "no action": "no action";
1971
+ "set null": "set null";
1972
+ "set default": "set default";
1973
+ }>>;
1974
+ description: z.ZodOptional<z.ZodString>;
1975
+ }, z.core.$strip>>>;
1976
+ policies: z.ZodObject<{
1977
+ read: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1978
+ default: z.ZodString;
1979
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1980
+ when: z.ZodString;
1981
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1982
+ policy: z.ZodOptional<z.ZodString>;
1983
+ }, z.core.$strip>>>;
1984
+ }, z.core.$strip>]>;
1985
+ }, z.core.$strict>;
1986
+ query: z.ZodString;
1987
+ dependencies: z.ZodArray<z.ZodString>;
1988
+ resolved: z.ZodOptional<z.ZodObject<{
1989
+ sources: z.ZodArray<z.ZodObject<{
1990
+ name: z.ZodString;
1991
+ kind: z.ZodEnum<{
1992
+ manual: "manual";
1993
+ prefetch: "prefetch";
1994
+ etl: "etl";
1995
+ }>;
1996
+ table: z.ZodString;
1997
+ columns: z.ZodArray<z.ZodString>;
1998
+ updatedAt: z.ZodOptional<z.ZodString>;
1999
+ key: z.ZodOptional<z.ZodString>;
2000
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
2001
+ shape: z.ZodLiteral<"single">;
2002
+ }, z.core.$strict>, z.ZodObject<{
2003
+ shape: z.ZodLiteral<"batch">;
2004
+ maxKeys: z.ZodNumber;
2005
+ }, z.core.$strict>]>>;
2006
+ function: z.ZodOptional<z.ZodObject<{
2007
+ kind: z.ZodEnum<{
2008
+ managed: "managed";
2009
+ native: "native";
2010
+ }>;
2011
+ id: z.ZodString;
2012
+ }, z.core.$strict>>;
2013
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
2014
+ maxStalenessMs: z.ZodNumber;
2015
+ timeoutMs: z.ZodNumber;
2016
+ onError: z.ZodEnum<{
2017
+ fallback: "fallback";
2018
+ fail: "fail";
2019
+ }>;
2020
+ }, z.core.$strict>>;
2021
+ writeback: z.ZodOptional<z.ZodObject<{
2022
+ columns: z.ZodArray<z.ZodString>;
2023
+ defaultMode: z.ZodEnum<{
2024
+ sync: "sync";
2025
+ async: "async";
2026
+ }>;
2027
+ timeoutMs: z.ZodNumber;
2028
+ clearManualOnConfirm: z.ZodBoolean;
2029
+ }, z.core.$strict>>;
2030
+ }, z.core.$strict>>;
2031
+ resolve: z.ZodArray<z.ZodObject<{
2032
+ column: z.ZodString;
2033
+ comparator: z.ZodEnum<{
2034
+ custom: "custom";
2035
+ latest: "latest";
2036
+ highest: "highest";
2037
+ lowest: "lowest";
2038
+ priority: "priority";
2039
+ nonNullFirst: "nonNullFirst";
2040
+ }>;
2041
+ candidates: z.ZodArray<z.ZodString>;
2042
+ orderBy: z.ZodOptional<z.ZodString>;
2043
+ }, z.core.$strict>>;
2044
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
2045
+ materialized: z.ZodOptional<z.ZodObject<{
2046
+ table: z.ZodString;
2047
+ compute: z.ZodString;
2048
+ }, z.core.$strict>>;
2049
+ policies: z.ZodDefault<z.ZodObject<{
2050
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
2051
+ default: z.ZodString;
2052
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
2053
+ when: z.ZodString;
2054
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
2055
+ policy: z.ZodOptional<z.ZodString>;
2056
+ }, z.core.$strip>>>;
2057
+ }, z.core.$strip>]>>;
2058
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
2059
+ default: z.ZodString;
2060
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
2061
+ when: z.ZodString;
2062
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
2063
+ policy: z.ZodOptional<z.ZodString>;
2064
+ }, z.core.$strip>>>;
2065
+ }, z.core.$strip>]>>;
2066
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
2067
+ default: z.ZodString;
2068
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
2069
+ when: z.ZodString;
2070
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
2071
+ policy: z.ZodOptional<z.ZodString>;
2072
+ }, z.core.$strip>>>;
2073
+ }, z.core.$strip>]>>;
2074
+ }, z.core.$strict>>;
2075
+ }, z.core.$strict>>;
2076
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
2077
+ }, z.core.$strip>>>;
2078
+ exports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2079
+ read: z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
2080
+ capability: z.ZodString;
2081
+ }, z.core.$strict>, z.ZodObject<{
2082
+ role: z.ZodString;
2083
+ }, z.core.$strict>]>;
2084
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
2085
+ capability: z.ZodString;
2086
+ }, z.core.$strict>, z.ZodObject<{
2087
+ role: z.ZodString;
2088
+ }, z.core.$strict>]>>;
2089
+ }, z.core.$strict>>>;
2090
+ capabilities: z.ZodDefault<z.ZodObject<{
2091
+ roles: z.ZodOptional<z.ZodUnknown>;
2092
+ uses: z.ZodDefault<z.ZodArray<z.ZodString>>;
2093
+ }, z.core.$strip>>;
2094
+ }, z.core.$strip>>>;
630
2095
  }, z.core.$strip>;
631
2096
  type CanonicalDefinition = z.infer<typeof canonicalDefinitionSchema>;
632
2097
  /**
@@ -636,7 +2101,11 @@ type CanonicalDefinition = z.infer<typeof canonicalDefinitionSchema>;
636
2101
  * the canonical boundary makes SDL and compiler behavior identical without
637
2102
  * pretending views are writable tables in the wire contract.
638
2103
  */
639
- declare function canonicalRelations(definition: CanonicalDefinition): CanonicalTable[];
2104
+ /** A table or view as the compiler/SDL see it; resolved views also carry their multi-source metadata. */
2105
+ type CanonicalRelation = CanonicalTable & {
2106
+ resolved?: CanonicalResolved;
2107
+ };
2108
+ declare function canonicalRelations(definition: CanonicalDefinition): CanonicalRelation[];
640
2109
  /**
641
2110
  * Deterministic serialization discipline: tables sorted by name, columns in
642
2111
  * declaration order (order is meaningful for DDL), links/indexes/actions
@@ -646,4 +2115,4 @@ declare function canonicalRelations(definition: CanonicalDefinition): CanonicalT
646
2115
  */
647
2116
  declare function normalizeCanonical(definition: CanonicalDefinition): CanonicalDefinition;
648
2117
 
649
- export { CANONICAL_FORMAT, COLUMN_TYPES, type CanonicalColumn, type CanonicalCowMutation, type CanonicalDefinition, type CanonicalEnum, type CanonicalForeignKey, type CanonicalLink, type CanonicalTable, type CanonicalView, type ColumnType, IDENTIFIER_RE, type PolicyExpression, VIEW_QUERY_FUNCTION_ALLOWLIST, canonicalActionSchema, canonicalColumnSchema, canonicalCowMutationSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalForeignKeySchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, isSingleViewQuerySql, normalizeCanonical, policyExpressionSchema, policyVariantSchema };
2118
+ 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, type OntologyContract, 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, exportGateSchema, isSingleViewQuerySql, localDefinitionSchema, normalizeCanonical, ontologyContractSchema, parseDurationMs, readOntologyContract, relationExportSchema, trackedCellColumns, validateResolvedView };