@sequenceholdings/orm 0.1.1 → 0.1.3

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 (81) hide show
  1. package/README.md +12 -2
  2. package/dist/authoring.cjs +1801 -0
  3. package/dist/authoring.cjs.map +1 -0
  4. package/dist/authoring.d.cts +539 -0
  5. package/dist/authoring.d.ts +539 -0
  6. package/dist/authoring.js +1759 -0
  7. package/dist/authoring.js.map +1 -0
  8. package/dist/canonical.cjs +552 -0
  9. package/dist/canonical.cjs.map +1 -0
  10. package/dist/canonical.d.cts +603 -0
  11. package/dist/canonical.d.ts +603 -0
  12. package/dist/canonical.js +532 -0
  13. package/dist/canonical.js.map +1 -0
  14. package/dist/cli.cjs +7843 -1815
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.d.cts +8 -1
  17. package/dist/cli.d.ts +8 -1
  18. package/dist/cli.js +7854 -1828
  19. package/dist/cli.js.map +1 -1
  20. package/dist/client.cjs +120 -0
  21. package/dist/client.cjs.map +1 -1
  22. package/dist/client.d.cts +74 -2
  23. package/dist/client.d.ts +74 -2
  24. package/dist/client.js +116 -1
  25. package/dist/client.js.map +1 -1
  26. package/dist/compiler.cjs +3453 -0
  27. package/dist/compiler.cjs.map +1 -0
  28. package/dist/compiler.d.cts +389 -0
  29. package/dist/compiler.d.ts +389 -0
  30. package/dist/compiler.js +3396 -0
  31. package/dist/compiler.js.map +1 -0
  32. package/dist/drizzle.cjs +14 -0
  33. package/dist/drizzle.cjs.map +1 -0
  34. package/dist/drizzle.d.cts +1 -0
  35. package/dist/drizzle.d.ts +1 -0
  36. package/dist/drizzle.js +3 -0
  37. package/dist/drizzle.js.map +1 -0
  38. package/dist/dynamic-input.cjs +391 -0
  39. package/dist/dynamic-input.cjs.map +1 -0
  40. package/dist/dynamic-input.d.cts +111 -0
  41. package/dist/dynamic-input.d.ts +111 -0
  42. package/dist/dynamic-input.js +380 -0
  43. package/dist/dynamic-input.js.map +1 -0
  44. package/dist/index.cjs +3727 -344
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.cts +236 -59
  47. package/dist/index.d.ts +236 -59
  48. package/dist/index.js +3757 -482
  49. package/dist/index.js.map +1 -1
  50. package/dist/ir.cjs +642 -0
  51. package/dist/ir.cjs.map +1 -0
  52. package/dist/ir.d.cts +1119 -0
  53. package/dist/ir.d.ts +1119 -0
  54. package/dist/ir.js +623 -0
  55. package/dist/ir.js.map +1 -0
  56. package/dist/naming-CTvWSRTf.d.ts +79 -0
  57. package/dist/naming-DRyinU4u.d.cts +79 -0
  58. package/dist/predicate-v2.cjs +1093 -0
  59. package/dist/predicate-v2.cjs.map +1 -0
  60. package/dist/predicate-v2.d.cts +139 -0
  61. package/dist/predicate-v2.d.ts +139 -0
  62. package/dist/predicate-v2.js +1083 -0
  63. package/dist/predicate-v2.js.map +1 -0
  64. package/dist/sdl.cjs +1122 -0
  65. package/dist/sdl.cjs.map +1 -0
  66. package/dist/sdl.d.cts +94 -0
  67. package/dist/sdl.d.ts +94 -0
  68. package/dist/sdl.js +1098 -0
  69. package/dist/sdl.js.map +1 -0
  70. package/package.json +51 -3
  71. package/src/codegen-gql/apollo-hooks.cjs +98 -0
  72. package/src/codegen-gql/server-fns.cjs +101 -0
  73. package/templates/README.md +13 -0
  74. package/templates/orm-namespace/CLAUDE.md +82 -0
  75. package/templates/orm-namespace/codegen.ts +22 -0
  76. package/templates/orm-namespace/gitignore +5 -0
  77. package/templates/orm-namespace/graphql/example/queries.ts +56 -0
  78. package/templates/orm-namespace/package.json +24 -0
  79. package/templates/orm-namespace/schema/tables.ts +71 -0
  80. package/templates/orm-namespace/sequence.config.ts +32 -0
  81. package/templates/orm-namespace/tsconfig.json +15 -0
@@ -0,0 +1,603 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Canonical namespace definition v2 — the data-only JSON a consumer's
5
+ * TypeScript schema serializes to. This is v2's equivalent of the v1 YAML
6
+ * `NamespaceDefinition`: the CLI's jiti loader produces it, the content hash
7
+ * is computed over it, the server re-validates it (consumer TS never runs
8
+ * server-side), and the SDL generator / GraphQL compiler / migration engine
9
+ * all consume it.
10
+ *
11
+ * FROZEN CONTRACT (week 1): downstream tracks build against these shapes.
12
+ * Additive evolution only; `definition_format` discriminates on the wire.
13
+ */
14
+
15
+ declare const CANONICAL_FORMAT: 2;
16
+ /** Identifier grammar shared with v1 (`^[a-z][a-z0-9_]*$`, ≤63 bytes). */
17
+ declare const IDENTIFIER_RE: RegExp;
18
+ /** The 10 v1 column types, unchanged in v2. */
19
+ declare const COLUMN_TYPES: readonly ["uuid", "text", "integer", "bigint", "numeric", "double", "boolean", "timestamptz", "date", "jsonb"];
20
+ type ColumnType = (typeof COLUMN_TYPES)[number];
21
+ /** Enum columns reference a namespace-level `defineEnum` by name. */
22
+ declare const canonicalEnumSchema: z.ZodObject<{
23
+ name: z.ZodString;
24
+ values: z.ZodArray<z.ZodString>;
25
+ }, z.core.$strip>;
26
+ type CanonicalEnum = z.infer<typeof canonicalEnumSchema>;
27
+ declare const canonicalColumnSchema: z.ZodObject<{
28
+ name: z.ZodString;
29
+ columnName: z.ZodString;
30
+ type: z.ZodUnion<readonly [z.ZodEnum<{
31
+ bigint: "bigint";
32
+ boolean: "boolean";
33
+ uuid: "uuid";
34
+ text: "text";
35
+ integer: "integer";
36
+ numeric: "numeric";
37
+ double: "double";
38
+ timestamptz: "timestamptz";
39
+ date: "date";
40
+ jsonb: "jsonb";
41
+ }>, z.ZodObject<{
42
+ enum: z.ZodString;
43
+ }, z.core.$strip>]>;
44
+ nullable: z.ZodDefault<z.ZodBoolean>;
45
+ unique: z.ZodDefault<z.ZodBoolean>;
46
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
47
+ defaultFn: z.ZodOptional<z.ZodEnum<{
48
+ "gen_random_uuid()": "gen_random_uuid()";
49
+ "now()": "now()";
50
+ }>>;
51
+ description: z.ZodOptional<z.ZodString>;
52
+ renamedFrom: z.ZodOptional<z.ZodString>;
53
+ cast: z.ZodOptional<z.ZodString>;
54
+ deprecated: z.ZodDefault<z.ZodBoolean>;
55
+ }, z.core.$strip>;
56
+ type CanonicalColumn = z.infer<typeof canonicalColumnSchema>;
57
+ declare const canonicalLinkSchema: z.ZodObject<{
58
+ name: z.ZodString;
59
+ kind: z.ZodEnum<{
60
+ toOne: "toOne";
61
+ toMany: "toMany";
62
+ toPlatformUser: "toPlatformUser";
63
+ }>;
64
+ target: z.ZodOptional<z.ZodString>;
65
+ on: z.ZodString;
66
+ references: z.ZodOptional<z.ZodString>;
67
+ enforce: z.ZodDefault<z.ZodBoolean>;
68
+ description: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ type CanonicalLink = z.infer<typeof canonicalLinkSchema>;
71
+ declare const canonicalIndexSchema: z.ZodObject<{
72
+ columns: z.ZodArray<z.ZodString>;
73
+ unique: z.ZodDefault<z.ZodBoolean>;
74
+ name: z.ZodOptional<z.ZodString>;
75
+ }, 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>;
95
+ declare const canonicalPoliciesSchema: z.ZodObject<{
96
+ read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
97
+ default: z.ZodString;
98
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
99
+ when: z.ZodString;
100
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
101
+ policy: z.ZodOptional<z.ZodString>;
102
+ }, z.core.$strip>>>;
103
+ }, z.core.$strip>]>>;
104
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
105
+ default: z.ZodString;
106
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
107
+ when: z.ZodString;
108
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
109
+ policy: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strip>>>;
111
+ }, z.core.$strip>]>>;
112
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
113
+ default: z.ZodString;
114
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
115
+ when: z.ZodString;
116
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
117
+ policy: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>>>;
119
+ }, z.core.$strip>]>>;
120
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
121
+ default: z.ZodString;
122
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
123
+ when: z.ZodString;
124
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
125
+ policy: z.ZodOptional<z.ZodString>;
126
+ }, z.core.$strip>>>;
127
+ }, z.core.$strip>]>>;
128
+ }, z.core.$strip>;
129
+ /**
130
+ * View SQL is generated by Drizzle in the authoring process, then crosses the
131
+ * CLI → Atlas JSON boundary. Keep the canonical form to one SELECT statement:
132
+ * PostgreSQL validates the complete grammar when the view is created, while
133
+ * this scanner prevents statement stacking before the text reaches DDL.
134
+ */
135
+ declare function isSingleViewQuerySql(value: string): boolean;
136
+ /**
137
+ * Managed views execute as the shared ORM relation owner. Treat function use
138
+ * as a capability boundary: a new function is unavailable until it is
139
+ * deliberately reviewed here as side-effect-free. The migration engine checks
140
+ * the functions PostgreSQL actually resolved against this list and pg_catalog,
141
+ * so qualification and same-named functions in a consumer schema cannot evade
142
+ * the boundary.
143
+ */
144
+ declare const VIEW_QUERY_FUNCTION_ALLOWLIST: readonly ["abs", "age", "array_agg", "array_append", "array_cat", "array_dims", "array_length", "array_lower", "array_ndims", "array_position", "array_positions", "array_prepend", "array_remove", "array_replace", "array_to_string", "array_trim", "array_upper", "ascii", "avg", "bit_and", "bit_or", "bit_xor", "bool_and", "bool_or", "btrim", "cardinality", "cbrt", "ceil", "ceiling", "char_length", "character_length", "chr", "concat", "concat_ws", "count", "cume_dist", "date_bin", "date_part", "date_trunc", "decode", "degrees", "dense_rank", "encode", "enum_first", "enum_last", "enum_range", "every", "exp", "first_value", "floor", "format", "grouping", "initcap", "json_agg", "json_array_length", "json_build_array", "json_build_object", "json_extract_path", "json_extract_path_text", "json_object_agg", "json_object_keys", "json_strip_nulls", "json_typeof", "jsonb_agg", "jsonb_array_length", "jsonb_build_array", "jsonb_build_object", "jsonb_extract_path", "jsonb_extract_path_text", "jsonb_insert", "jsonb_object_agg", "jsonb_object_keys", "jsonb_path_exists", "jsonb_path_match", "jsonb_path_query", "jsonb_path_query_array", "jsonb_path_query_first", "jsonb_pretty", "jsonb_set", "jsonb_set_lax", "jsonb_strip_nulls", "jsonb_typeof", "justify_days", "justify_hours", "justify_interval", "lag", "last_value", "lead", "left", "length", "ln", "log", "lower", "lpad", "ltrim", "make_date", "make_interval", "make_time", "make_timestamp", "make_timestamptz", "max", "md5", "min", "mod", "nth_value", "ntile", "octet_length", "percent_rank", "pi", "power", "quote_ident", "quote_literal", "quote_nullable", "radians", "rank", "regexp_count", "regexp_instr", "regexp_like", "regexp_match", "regexp_matches", "regexp_replace", "regexp_split_to_array", "regexp_split_to_table", "repeat", "replace", "reverse", "right", "round", "row_number", "rpad", "rtrim", "sign", "split_part", "sqrt", "starts_with", "string_agg", "string_to_array", "strpos", "substr", "substring", "sum", "timezone", "to_ascii", "to_char", "to_date", "to_hex", "to_json", "to_jsonb", "to_number", "to_timestamp", "translate", "trunc", "unnest", "upper", "width_bucket"];
145
+ /** Actions carry over from v1 as compiled named-SQL ops (plan: resolved OQ-1). */
146
+ declare const canonicalActionSchema: z.ZodObject<{
147
+ name: z.ZodString;
148
+ requires: z.ZodOptional<z.ZodString>;
149
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
150
+ type: z.ZodEnum<{
151
+ bigint: "bigint";
152
+ boolean: "boolean";
153
+ uuid: "uuid";
154
+ text: "text";
155
+ integer: "integer";
156
+ numeric: "numeric";
157
+ double: "double";
158
+ timestamptz: "timestamptz";
159
+ date: "date";
160
+ jsonb: "jsonb";
161
+ }>;
162
+ nullable: z.ZodDefault<z.ZodBoolean>;
163
+ }, z.core.$strip>>>;
164
+ executes: z.ZodString;
165
+ returns: z.ZodDefault<z.ZodEnum<{
166
+ rows: "rows";
167
+ rowsAffected: "rowsAffected";
168
+ scalar: "scalar";
169
+ }>>;
170
+ audit: z.ZodOptional<z.ZodObject<{
171
+ action: z.ZodString;
172
+ resource: z.ZodString;
173
+ }, z.core.$strip>>;
174
+ }, z.core.$strip>;
175
+ /**
176
+ * Copy-on-write mutations for overlay tables backed by a synced twin
177
+ * (v2-only). Structured metadata, never authored SQL: the compiler and data
178
+ * plane generate the INSERT…SELECT / UPDATE / DELETE statements from it, so
179
+ * there is no SQL surface to validate and write policies inject like any
180
+ * other mutation. `override` copies the synced row into the overlay
181
+ * (ON CONFLICT DO NOTHING) then updates the `set` columns; `revert` deletes
182
+ * the overlay row so the coalesce view falls back to synced.
183
+ */
184
+ declare const canonicalCowMutationSchema: z.ZodObject<{
185
+ kind: z.ZodEnum<{
186
+ override: "override";
187
+ revert: "revert";
188
+ }>;
189
+ name: z.ZodString;
190
+ synced: z.ZodString;
191
+ pk: z.ZodString;
192
+ copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
193
+ set: z.ZodDefault<z.ZodArray<z.ZodString>>;
194
+ }, z.core.$strip>;
195
+ type CanonicalCowMutation = z.infer<typeof canonicalCowMutationSchema>;
196
+ declare const canonicalTableSchema: z.ZodObject<{
197
+ table: z.ZodString;
198
+ description: z.ZodOptional<z.ZodString>;
199
+ renamedFrom: z.ZodOptional<z.ZodString>;
200
+ source: z.ZodOptional<z.ZodString>;
201
+ columns: z.ZodDefault<z.ZodArray<z.ZodObject<{
202
+ name: z.ZodString;
203
+ columnName: z.ZodString;
204
+ type: z.ZodUnion<readonly [z.ZodEnum<{
205
+ bigint: "bigint";
206
+ boolean: "boolean";
207
+ uuid: "uuid";
208
+ text: "text";
209
+ integer: "integer";
210
+ numeric: "numeric";
211
+ double: "double";
212
+ timestamptz: "timestamptz";
213
+ date: "date";
214
+ jsonb: "jsonb";
215
+ }>, z.ZodObject<{
216
+ enum: z.ZodString;
217
+ }, z.core.$strip>]>;
218
+ nullable: z.ZodDefault<z.ZodBoolean>;
219
+ unique: z.ZodDefault<z.ZodBoolean>;
220
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
221
+ defaultFn: z.ZodOptional<z.ZodEnum<{
222
+ "gen_random_uuid()": "gen_random_uuid()";
223
+ "now()": "now()";
224
+ }>>;
225
+ description: z.ZodOptional<z.ZodString>;
226
+ renamedFrom: z.ZodOptional<z.ZodString>;
227
+ cast: z.ZodOptional<z.ZodString>;
228
+ deprecated: z.ZodDefault<z.ZodBoolean>;
229
+ }, z.core.$strip>>>;
230
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
231
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
232
+ name: z.ZodString;
233
+ kind: z.ZodEnum<{
234
+ toOne: "toOne";
235
+ toMany: "toMany";
236
+ toPlatformUser: "toPlatformUser";
237
+ }>;
238
+ target: z.ZodOptional<z.ZodString>;
239
+ on: z.ZodString;
240
+ references: z.ZodOptional<z.ZodString>;
241
+ enforce: z.ZodDefault<z.ZodBoolean>;
242
+ description: z.ZodOptional<z.ZodString>;
243
+ }, z.core.$strip>>>;
244
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
245
+ columns: z.ZodArray<z.ZodString>;
246
+ unique: z.ZodDefault<z.ZodBoolean>;
247
+ name: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strip>>>;
249
+ policies: z.ZodDefault<z.ZodObject<{
250
+ read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
251
+ default: z.ZodString;
252
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
253
+ when: z.ZodString;
254
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
255
+ policy: z.ZodOptional<z.ZodString>;
256
+ }, z.core.$strip>>>;
257
+ }, z.core.$strip>]>>;
258
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
259
+ default: z.ZodString;
260
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
261
+ when: z.ZodString;
262
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
263
+ policy: z.ZodOptional<z.ZodString>;
264
+ }, z.core.$strip>>>;
265
+ }, z.core.$strip>]>>;
266
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
267
+ default: z.ZodString;
268
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
269
+ when: z.ZodString;
270
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
271
+ policy: z.ZodOptional<z.ZodString>;
272
+ }, z.core.$strip>>>;
273
+ }, z.core.$strip>]>>;
274
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
275
+ default: z.ZodString;
276
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
277
+ when: z.ZodString;
278
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
279
+ policy: z.ZodOptional<z.ZodString>;
280
+ }, z.core.$strip>>>;
281
+ }, z.core.$strip>]>>;
282
+ }, z.core.$strip>>;
283
+ actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
284
+ name: z.ZodString;
285
+ requires: z.ZodOptional<z.ZodString>;
286
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
287
+ type: z.ZodEnum<{
288
+ bigint: "bigint";
289
+ boolean: "boolean";
290
+ uuid: "uuid";
291
+ text: "text";
292
+ integer: "integer";
293
+ numeric: "numeric";
294
+ double: "double";
295
+ timestamptz: "timestamptz";
296
+ date: "date";
297
+ jsonb: "jsonb";
298
+ }>;
299
+ nullable: z.ZodDefault<z.ZodBoolean>;
300
+ }, z.core.$strip>>>;
301
+ executes: z.ZodString;
302
+ returns: z.ZodDefault<z.ZodEnum<{
303
+ rows: "rows";
304
+ rowsAffected: "rowsAffected";
305
+ scalar: "scalar";
306
+ }>>;
307
+ audit: z.ZodOptional<z.ZodObject<{
308
+ action: z.ZodString;
309
+ resource: z.ZodString;
310
+ }, z.core.$strip>>;
311
+ }, z.core.$strip>>>;
312
+ cowMutations: z.ZodOptional<z.ZodArray<z.ZodObject<{
313
+ kind: z.ZodEnum<{
314
+ override: "override";
315
+ revert: "revert";
316
+ }>;
317
+ name: z.ZodString;
318
+ synced: z.ZodString;
319
+ pk: z.ZodString;
320
+ copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
321
+ set: z.ZodDefault<z.ZodArray<z.ZodString>>;
322
+ }, z.core.$strip>>>;
323
+ }, z.core.$strip>;
324
+ type CanonicalTable = z.infer<typeof canonicalTableSchema>;
325
+ declare const canonicalViewSchema: z.ZodObject<{
326
+ view: z.ZodString;
327
+ description: z.ZodOptional<z.ZodString>;
328
+ columns: z.ZodArray<z.ZodObject<{
329
+ name: z.ZodString;
330
+ columnName: z.ZodString;
331
+ type: z.ZodUnion<readonly [z.ZodEnum<{
332
+ bigint: "bigint";
333
+ boolean: "boolean";
334
+ uuid: "uuid";
335
+ text: "text";
336
+ integer: "integer";
337
+ numeric: "numeric";
338
+ double: "double";
339
+ timestamptz: "timestamptz";
340
+ date: "date";
341
+ jsonb: "jsonb";
342
+ }>, z.ZodObject<{
343
+ enum: z.ZodString;
344
+ }, z.core.$strip>]>;
345
+ nullable: z.ZodDefault<z.ZodBoolean>;
346
+ unique: z.ZodDefault<z.ZodBoolean>;
347
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
348
+ defaultFn: z.ZodOptional<z.ZodEnum<{
349
+ "gen_random_uuid()": "gen_random_uuid()";
350
+ "now()": "now()";
351
+ }>>;
352
+ description: z.ZodOptional<z.ZodString>;
353
+ renamedFrom: z.ZodOptional<z.ZodString>;
354
+ cast: z.ZodOptional<z.ZodString>;
355
+ deprecated: z.ZodDefault<z.ZodBoolean>;
356
+ }, z.core.$strip>>;
357
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
359
+ name: z.ZodString;
360
+ kind: z.ZodEnum<{
361
+ toOne: "toOne";
362
+ toMany: "toMany";
363
+ toPlatformUser: "toPlatformUser";
364
+ }>;
365
+ target: z.ZodOptional<z.ZodString>;
366
+ on: z.ZodString;
367
+ references: z.ZodOptional<z.ZodString>;
368
+ enforce: z.ZodDefault<z.ZodBoolean>;
369
+ description: z.ZodOptional<z.ZodString>;
370
+ }, z.core.$strip>>>;
371
+ policies: z.ZodObject<{
372
+ read: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
373
+ default: z.ZodString;
374
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
375
+ when: z.ZodString;
376
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
377
+ policy: z.ZodOptional<z.ZodString>;
378
+ }, z.core.$strip>>>;
379
+ }, z.core.$strip>]>;
380
+ }, z.core.$strict>;
381
+ query: z.ZodString;
382
+ dependencies: z.ZodArray<z.ZodString>;
383
+ }, z.core.$strip>;
384
+ type CanonicalView = z.infer<typeof canonicalViewSchema>;
385
+ declare const canonicalDefinitionSchema: z.ZodObject<{
386
+ definition_format: z.ZodLiteral<2>;
387
+ namespace: z.ZodString;
388
+ description: z.ZodOptional<z.ZodString>;
389
+ enums: z.ZodDefault<z.ZodArray<z.ZodObject<{
390
+ name: z.ZodString;
391
+ values: z.ZodArray<z.ZodString>;
392
+ }, z.core.$strip>>>;
393
+ tables: z.ZodArray<z.ZodObject<{
394
+ table: z.ZodString;
395
+ description: z.ZodOptional<z.ZodString>;
396
+ renamedFrom: z.ZodOptional<z.ZodString>;
397
+ source: z.ZodOptional<z.ZodString>;
398
+ columns: z.ZodDefault<z.ZodArray<z.ZodObject<{
399
+ name: z.ZodString;
400
+ columnName: z.ZodString;
401
+ type: z.ZodUnion<readonly [z.ZodEnum<{
402
+ bigint: "bigint";
403
+ boolean: "boolean";
404
+ uuid: "uuid";
405
+ text: "text";
406
+ integer: "integer";
407
+ numeric: "numeric";
408
+ double: "double";
409
+ timestamptz: "timestamptz";
410
+ date: "date";
411
+ jsonb: "jsonb";
412
+ }>, z.ZodObject<{
413
+ enum: z.ZodString;
414
+ }, z.core.$strip>]>;
415
+ nullable: z.ZodDefault<z.ZodBoolean>;
416
+ unique: z.ZodDefault<z.ZodBoolean>;
417
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
418
+ defaultFn: z.ZodOptional<z.ZodEnum<{
419
+ "gen_random_uuid()": "gen_random_uuid()";
420
+ "now()": "now()";
421
+ }>>;
422
+ description: z.ZodOptional<z.ZodString>;
423
+ renamedFrom: z.ZodOptional<z.ZodString>;
424
+ cast: z.ZodOptional<z.ZodString>;
425
+ deprecated: z.ZodDefault<z.ZodBoolean>;
426
+ }, z.core.$strip>>>;
427
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
428
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
429
+ name: z.ZodString;
430
+ kind: z.ZodEnum<{
431
+ toOne: "toOne";
432
+ toMany: "toMany";
433
+ toPlatformUser: "toPlatformUser";
434
+ }>;
435
+ target: z.ZodOptional<z.ZodString>;
436
+ on: z.ZodString;
437
+ references: z.ZodOptional<z.ZodString>;
438
+ enforce: z.ZodDefault<z.ZodBoolean>;
439
+ description: z.ZodOptional<z.ZodString>;
440
+ }, z.core.$strip>>>;
441
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
442
+ columns: z.ZodArray<z.ZodString>;
443
+ unique: z.ZodDefault<z.ZodBoolean>;
444
+ name: z.ZodOptional<z.ZodString>;
445
+ }, z.core.$strip>>>;
446
+ policies: z.ZodDefault<z.ZodObject<{
447
+ read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
448
+ default: z.ZodString;
449
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
450
+ when: z.ZodString;
451
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
452
+ policy: z.ZodOptional<z.ZodString>;
453
+ }, z.core.$strip>>>;
454
+ }, z.core.$strip>]>>;
455
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
456
+ default: z.ZodString;
457
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
458
+ when: z.ZodString;
459
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
460
+ policy: z.ZodOptional<z.ZodString>;
461
+ }, z.core.$strip>>>;
462
+ }, z.core.$strip>]>>;
463
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
464
+ default: z.ZodString;
465
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
466
+ when: z.ZodString;
467
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
468
+ policy: z.ZodOptional<z.ZodString>;
469
+ }, z.core.$strip>>>;
470
+ }, z.core.$strip>]>>;
471
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
472
+ default: z.ZodString;
473
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
474
+ when: z.ZodString;
475
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
476
+ policy: z.ZodOptional<z.ZodString>;
477
+ }, z.core.$strip>>>;
478
+ }, z.core.$strip>]>>;
479
+ }, z.core.$strip>>;
480
+ actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
481
+ name: z.ZodString;
482
+ requires: z.ZodOptional<z.ZodString>;
483
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
484
+ type: z.ZodEnum<{
485
+ bigint: "bigint";
486
+ boolean: "boolean";
487
+ uuid: "uuid";
488
+ text: "text";
489
+ integer: "integer";
490
+ numeric: "numeric";
491
+ double: "double";
492
+ timestamptz: "timestamptz";
493
+ date: "date";
494
+ jsonb: "jsonb";
495
+ }>;
496
+ nullable: z.ZodDefault<z.ZodBoolean>;
497
+ }, z.core.$strip>>>;
498
+ executes: z.ZodString;
499
+ returns: z.ZodDefault<z.ZodEnum<{
500
+ rows: "rows";
501
+ rowsAffected: "rowsAffected";
502
+ scalar: "scalar";
503
+ }>>;
504
+ audit: z.ZodOptional<z.ZodObject<{
505
+ action: z.ZodString;
506
+ resource: z.ZodString;
507
+ }, z.core.$strip>>;
508
+ }, z.core.$strip>>>;
509
+ cowMutations: z.ZodOptional<z.ZodArray<z.ZodObject<{
510
+ kind: z.ZodEnum<{
511
+ override: "override";
512
+ revert: "revert";
513
+ }>;
514
+ name: z.ZodString;
515
+ synced: z.ZodString;
516
+ pk: z.ZodString;
517
+ copy: z.ZodDefault<z.ZodArray<z.ZodString>>;
518
+ set: z.ZodDefault<z.ZodArray<z.ZodString>>;
519
+ }, z.core.$strip>>>;
520
+ }, z.core.$strip>>;
521
+ views: z.ZodOptional<z.ZodArray<z.ZodObject<{
522
+ view: z.ZodString;
523
+ description: z.ZodOptional<z.ZodString>;
524
+ columns: z.ZodArray<z.ZodObject<{
525
+ name: z.ZodString;
526
+ columnName: z.ZodString;
527
+ type: z.ZodUnion<readonly [z.ZodEnum<{
528
+ bigint: "bigint";
529
+ boolean: "boolean";
530
+ uuid: "uuid";
531
+ text: "text";
532
+ integer: "integer";
533
+ numeric: "numeric";
534
+ double: "double";
535
+ timestamptz: "timestamptz";
536
+ date: "date";
537
+ jsonb: "jsonb";
538
+ }>, z.ZodObject<{
539
+ enum: z.ZodString;
540
+ }, z.core.$strip>]>;
541
+ nullable: z.ZodDefault<z.ZodBoolean>;
542
+ unique: z.ZodDefault<z.ZodBoolean>;
543
+ default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
544
+ defaultFn: z.ZodOptional<z.ZodEnum<{
545
+ "gen_random_uuid()": "gen_random_uuid()";
546
+ "now()": "now()";
547
+ }>>;
548
+ description: z.ZodOptional<z.ZodString>;
549
+ renamedFrom: z.ZodOptional<z.ZodString>;
550
+ cast: z.ZodOptional<z.ZodString>;
551
+ deprecated: z.ZodDefault<z.ZodBoolean>;
552
+ }, z.core.$strip>>;
553
+ primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
554
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
555
+ name: z.ZodString;
556
+ kind: z.ZodEnum<{
557
+ toOne: "toOne";
558
+ toMany: "toMany";
559
+ toPlatformUser: "toPlatformUser";
560
+ }>;
561
+ target: z.ZodOptional<z.ZodString>;
562
+ on: z.ZodString;
563
+ references: z.ZodOptional<z.ZodString>;
564
+ enforce: z.ZodDefault<z.ZodBoolean>;
565
+ description: z.ZodOptional<z.ZodString>;
566
+ }, z.core.$strip>>>;
567
+ policies: z.ZodObject<{
568
+ read: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
569
+ default: z.ZodString;
570
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
571
+ when: z.ZodString;
572
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
573
+ policy: z.ZodOptional<z.ZodString>;
574
+ }, z.core.$strip>>>;
575
+ }, z.core.$strip>]>;
576
+ }, z.core.$strict>;
577
+ query: z.ZodString;
578
+ dependencies: z.ZodArray<z.ZodString>;
579
+ }, z.core.$strip>>>;
580
+ capabilities: z.ZodDefault<z.ZodObject<{
581
+ roles: z.ZodOptional<z.ZodUnknown>;
582
+ uses: z.ZodDefault<z.ZodArray<z.ZodString>>;
583
+ }, z.core.$strip>>;
584
+ }, z.core.$strip>;
585
+ type CanonicalDefinition = z.infer<typeof canonicalDefinitionSchema>;
586
+ /**
587
+ * Project namespace-local tables and views onto the shared read/query surface.
588
+ * A view deliberately becomes a CanonicalTable-shaped relation with no write
589
+ * policy, indexes, actions, defaults, or constraints. Keeping this adapter at
590
+ * the canonical boundary makes SDL and compiler behavior identical without
591
+ * pretending views are writable tables in the wire contract.
592
+ */
593
+ declare function canonicalRelations(definition: CanonicalDefinition): CanonicalTable[];
594
+ /**
595
+ * Deterministic serialization discipline: tables sorted by name, columns in
596
+ * declaration order (order is meaningful for DDL), links/indexes/actions
597
+ * sorted by name, object keys emitted in schema order. `serializeNamespace`
598
+ * (authoring layer) and the server-side re-validation both normalize through
599
+ * this function before hashing so CLI and server hash identical bytes.
600
+ */
601
+ declare function normalizeCanonical(definition: CanonicalDefinition): CanonicalDefinition;
602
+
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 };