@sequenceholdings/orm 0.1.3 → 2.1.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 (59) hide show
  1. package/README.md +108 -38
  2. package/dist/authoring.cjs +128 -16
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +21 -4
  5. package/dist/authoring.d.ts +21 -4
  6. package/dist/authoring.js +128 -16
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +83 -9
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +47 -1
  11. package/dist/canonical.d.ts +47 -1
  12. package/dist/canonical.js +83 -10
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +816 -134
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +818 -136
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.js.map +1 -1
  20. package/dist/compiler.cjs +488 -96
  21. package/dist/compiler.cjs.map +1 -1
  22. package/dist/compiler.d.cts +34 -2
  23. package/dist/compiler.d.ts +34 -2
  24. package/dist/compiler.js +489 -97
  25. package/dist/compiler.js.map +1 -1
  26. package/dist/index.cjs +420 -71
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +266 -9
  29. package/dist/index.d.ts +266 -9
  30. package/dist/index.js +410 -73
  31. package/dist/index.js.map +1 -1
  32. package/dist/ir.cjs +146 -12
  33. package/dist/ir.cjs.map +1 -1
  34. package/dist/ir.d.cts +161 -5
  35. package/dist/ir.d.ts +161 -5
  36. package/dist/ir.js +144 -13
  37. package/dist/ir.js.map +1 -1
  38. package/dist/{naming-CTvWSRTf.d.ts → naming-DCn94LJ4.d.ts} +15 -1
  39. package/dist/{naming-DRyinU4u.d.cts → naming-DPglwzkB.d.cts} +15 -1
  40. package/dist/predicate-v2.cjs +136 -11
  41. package/dist/predicate-v2.cjs.map +1 -1
  42. package/dist/predicate-v2.d.cts +3 -0
  43. package/dist/predicate-v2.d.ts +3 -0
  44. package/dist/predicate-v2.js +136 -11
  45. package/dist/predicate-v2.js.map +1 -1
  46. package/dist/sdl.cjs +460 -13
  47. package/dist/sdl.cjs.map +1 -1
  48. package/dist/sdl.d.cts +1 -1
  49. package/dist/sdl.d.ts +1 -1
  50. package/dist/sdl.js +459 -14
  51. package/dist/sdl.js.map +1 -1
  52. package/package.json +6 -4
  53. package/src/codegen-gql/preset.cjs +64 -0
  54. package/src/codegen-gql/server-fns.cjs +11 -6
  55. package/templates/orm-namespace/codegen.preset.cjs +17 -0
  56. package/templates/orm-namespace/codegen.ts +1 -1
  57. package/templates/orm-namespace/package.json +3 -0
  58. package/templates/orm-namespace/schema/tables.ts +1 -1
  59. package/templates/orm-namespace/sequence.config.ts +1 -1
package/dist/ir.d.cts CHANGED
@@ -22,7 +22,12 @@ import { z } from 'zod';
22
22
  * pattern): executor upgrades decouple from artifact re-pushes.
23
23
  */
24
24
 
25
- declare const IR_VERSION: 1;
25
+ /** Maximum supported version. Emit v1 until an operation needs v2 semantics. */
26
+ declare const IR_VERSION: 2;
27
+ declare const LEGACY_IR_VERSION: 1;
28
+ declare const irVersionSchema: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
29
+ /** Keep v1 artifact identity when assembling only legacy operations from registry rows. */
30
+ declare function requiredArtifactIrVersion(operations: readonly unknown[]): z.infer<typeof irVersionSchema>;
26
31
  /** The exact claim keys the platform stamps — mirrors claims.ts. */
27
32
  declare const CLAIMS_CONTRACT: {
28
33
  readonly sub: "string";
@@ -156,6 +161,32 @@ interface SelectionIr {
156
161
  }
157
162
  declare const selectionIrSchema: z.ZodType<SelectionIr>;
158
163
 
164
+ /**
165
+ * The date-bucket units a grouped aggregate may apply to a `date` /
166
+ * `timestamptz` group key. A CLOSED enum on purpose: the executor maps each
167
+ * member to a `date_trunc` literal, so no caller-supplied string ever reaches
168
+ * SQL text. Adding a unit means adding it here AND to the executor's map —
169
+ * the executor's exhaustive switch makes the omission a type error.
170
+ */
171
+ declare const DATE_BUCKETS: readonly ["year", "quarter", "month", "week", "day", "hour"];
172
+ type DateBucket = (typeof DATE_BUCKETS)[number];
173
+ /**
174
+ * One group key: a column, optionally bucketed. `bucket` is only ever set on a
175
+ * `date` / `timestamptz` column — the compiler rejects it on anything else, so
176
+ * the executor can apply `date_trunc` without re-checking the column type.
177
+ */
178
+ declare const groupByKeyIrSchema: z.ZodObject<{
179
+ column: z.ZodString;
180
+ bucket: z.ZodOptional<z.ZodEnum<{
181
+ year: "year";
182
+ quarter: "quarter";
183
+ month: "month";
184
+ week: "week";
185
+ day: "day";
186
+ hour: "hour";
187
+ }>>;
188
+ }, z.core.$strip>;
189
+ type GroupByKeyIr = z.infer<typeof groupByKeyIrSchema>;
159
190
  declare const rootIrSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
160
191
  kind: z.ZodLiteral<"select">;
161
192
  alias: z.ZodString;
@@ -237,6 +268,46 @@ declare const rootIrSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
237
268
  variable: z.ZodString;
238
269
  negated: z.ZodBoolean;
239
270
  }, z.core.$strip>>;
271
+ }, z.core.$strip>, z.ZodObject<{
272
+ kind: z.ZodLiteral<"aggregateGroups">;
273
+ alias: z.ZodString;
274
+ table: z.ZodString;
275
+ where: z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>;
276
+ groupBy: z.ZodArray<z.ZodObject<{
277
+ column: z.ZodString;
278
+ bucket: z.ZodOptional<z.ZodEnum<{
279
+ year: "year";
280
+ quarter: "quarter";
281
+ month: "month";
282
+ week: "week";
283
+ day: "day";
284
+ hour: "hour";
285
+ }>>;
286
+ }, z.core.$strip>>;
287
+ key: z.ZodDefault<z.ZodArray<z.ZodObject<{
288
+ alias: z.ZodString;
289
+ column: z.ZodString;
290
+ }, z.core.$strip>>>;
291
+ count: z.ZodOptional<z.ZodObject<{
292
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
293
+ distinct: z.ZodOptional<z.ZodBoolean>;
294
+ }, z.core.$strip>>;
295
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
296
+ avg: z.ZodOptional<z.ZodArray<z.ZodString>>;
297
+ limit: z.ZodObject<{
298
+ variable: z.ZodOptional<z.ZodString>;
299
+ value: z.ZodOptional<z.ZodNumber>;
300
+ default: z.ZodNumber;
301
+ max: z.ZodNumber;
302
+ }, z.core.$strip>;
303
+ offset: z.ZodOptional<z.ZodObject<{
304
+ variable: z.ZodOptional<z.ZodString>;
305
+ value: z.ZodOptional<z.ZodNumber>;
306
+ }, z.core.$strip>>;
307
+ includeIf: z.ZodOptional<z.ZodObject<{
308
+ variable: z.ZodString;
309
+ negated: z.ZodBoolean;
310
+ }, z.core.$strip>>;
240
311
  }, z.core.$strip>, z.ZodObject<{
241
312
  kind: z.ZodLiteral<"mutation">;
242
313
  op: z.ZodEnum<{
@@ -376,6 +447,7 @@ declare const rootIrSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
376
447
  insertCheck: z.ZodOptional<z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>>;
377
448
  returning: z.ZodNullable<z.ZodType<SelectionIr, unknown, z.core.$ZodTypeInternals<SelectionIr, unknown>>>;
378
449
  affectedRows: z.ZodDefault<z.ZodBoolean>;
450
+ assertAffectedRows: z.ZodOptional<z.ZodNumber>;
379
451
  includeIf: z.ZodOptional<z.ZodObject<{
380
452
  variable: z.ZodString;
381
453
  negated: z.ZodBoolean;
@@ -436,7 +508,7 @@ declare const variableIrSchema: z.ZodObject<{
436
508
  }, z.core.$strip>;
437
509
  type VariableIr = z.infer<typeof variableIrSchema>;
438
510
  declare const compiledOperationSchema: z.ZodObject<{
439
- irVersion: z.ZodLiteral<1>;
511
+ irVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
440
512
  name: z.ZodString;
441
513
  opHash: z.ZodString;
442
514
  kind: z.ZodEnum<{
@@ -568,6 +640,46 @@ declare const compiledOperationSchema: z.ZodObject<{
568
640
  variable: z.ZodString;
569
641
  negated: z.ZodBoolean;
570
642
  }, z.core.$strip>>;
643
+ }, z.core.$strip>, z.ZodObject<{
644
+ kind: z.ZodLiteral<"aggregateGroups">;
645
+ alias: z.ZodString;
646
+ table: z.ZodString;
647
+ where: z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>;
648
+ groupBy: z.ZodArray<z.ZodObject<{
649
+ column: z.ZodString;
650
+ bucket: z.ZodOptional<z.ZodEnum<{
651
+ year: "year";
652
+ quarter: "quarter";
653
+ month: "month";
654
+ week: "week";
655
+ day: "day";
656
+ hour: "hour";
657
+ }>>;
658
+ }, z.core.$strip>>;
659
+ key: z.ZodDefault<z.ZodArray<z.ZodObject<{
660
+ alias: z.ZodString;
661
+ column: z.ZodString;
662
+ }, z.core.$strip>>>;
663
+ count: z.ZodOptional<z.ZodObject<{
664
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
665
+ distinct: z.ZodOptional<z.ZodBoolean>;
666
+ }, z.core.$strip>>;
667
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
668
+ avg: z.ZodOptional<z.ZodArray<z.ZodString>>;
669
+ limit: z.ZodObject<{
670
+ variable: z.ZodOptional<z.ZodString>;
671
+ value: z.ZodOptional<z.ZodNumber>;
672
+ default: z.ZodNumber;
673
+ max: z.ZodNumber;
674
+ }, z.core.$strip>;
675
+ offset: z.ZodOptional<z.ZodObject<{
676
+ variable: z.ZodOptional<z.ZodString>;
677
+ value: z.ZodOptional<z.ZodNumber>;
678
+ }, z.core.$strip>>;
679
+ includeIf: z.ZodOptional<z.ZodObject<{
680
+ variable: z.ZodString;
681
+ negated: z.ZodBoolean;
682
+ }, z.core.$strip>>;
571
683
  }, z.core.$strip>, z.ZodObject<{
572
684
  kind: z.ZodLiteral<"mutation">;
573
685
  op: z.ZodEnum<{
@@ -707,6 +819,7 @@ declare const compiledOperationSchema: z.ZodObject<{
707
819
  insertCheck: z.ZodOptional<z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>>;
708
820
  returning: z.ZodNullable<z.ZodType<SelectionIr, unknown, z.core.$ZodTypeInternals<SelectionIr, unknown>>>;
709
821
  affectedRows: z.ZodDefault<z.ZodBoolean>;
822
+ assertAffectedRows: z.ZodOptional<z.ZodNumber>;
710
823
  includeIf: z.ZodOptional<z.ZodObject<{
711
824
  variable: z.ZodString;
712
825
  negated: z.ZodBoolean;
@@ -761,6 +874,7 @@ declare const tableMetaIrSchema: z.ZodObject<{
761
874
  insertable: z.ZodArray<z.ZodString>;
762
875
  settable: z.ZodArray<z.ZodString>;
763
876
  appendable: z.ZodArray<z.ZodString>;
877
+ touchOnUpdate: z.ZodOptional<z.ZodArray<z.ZodString>>;
764
878
  constraints: z.ZodArray<z.ZodObject<{
765
879
  name: z.ZodString;
766
880
  columns: z.ZodArray<z.ZodString>;
@@ -770,7 +884,7 @@ declare const tableMetaIrSchema: z.ZodObject<{
770
884
  }, z.core.$strip>;
771
885
  type TableMetaIr = z.infer<typeof tableMetaIrSchema>;
772
886
  declare const compiledArtifactSchema: z.ZodObject<{
773
- irVersion: z.ZodLiteral<1>;
887
+ irVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
774
888
  namespace: z.ZodString;
775
889
  schemaHash: z.ZodString;
776
890
  opsHash: z.ZodString;
@@ -816,6 +930,7 @@ declare const compiledArtifactSchema: z.ZodObject<{
816
930
  insertable: z.ZodArray<z.ZodString>;
817
931
  settable: z.ZodArray<z.ZodString>;
818
932
  appendable: z.ZodArray<z.ZodString>;
933
+ touchOnUpdate: z.ZodOptional<z.ZodArray<z.ZodString>>;
819
934
  constraints: z.ZodArray<z.ZodObject<{
820
935
  name: z.ZodString;
821
936
  columns: z.ZodArray<z.ZodString>;
@@ -824,7 +939,7 @@ declare const compiledArtifactSchema: z.ZodObject<{
824
939
  dynamicFilterMaxNodes: z.ZodDefault<z.ZodNumber>;
825
940
  }, z.core.$strip>>;
826
941
  operations: z.ZodRecord<z.ZodString, z.ZodObject<{
827
- irVersion: z.ZodLiteral<1>;
942
+ irVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
828
943
  name: z.ZodString;
829
944
  opHash: z.ZodString;
830
945
  kind: z.ZodEnum<{
@@ -956,6 +1071,46 @@ declare const compiledArtifactSchema: z.ZodObject<{
956
1071
  variable: z.ZodString;
957
1072
  negated: z.ZodBoolean;
958
1073
  }, z.core.$strip>>;
1074
+ }, z.core.$strip>, z.ZodObject<{
1075
+ kind: z.ZodLiteral<"aggregateGroups">;
1076
+ alias: z.ZodString;
1077
+ table: z.ZodString;
1078
+ where: z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>;
1079
+ groupBy: z.ZodArray<z.ZodObject<{
1080
+ column: z.ZodString;
1081
+ bucket: z.ZodOptional<z.ZodEnum<{
1082
+ year: "year";
1083
+ quarter: "quarter";
1084
+ month: "month";
1085
+ week: "week";
1086
+ day: "day";
1087
+ hour: "hour";
1088
+ }>>;
1089
+ }, z.core.$strip>>;
1090
+ key: z.ZodDefault<z.ZodArray<z.ZodObject<{
1091
+ alias: z.ZodString;
1092
+ column: z.ZodString;
1093
+ }, z.core.$strip>>>;
1094
+ count: z.ZodOptional<z.ZodObject<{
1095
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
1096
+ distinct: z.ZodOptional<z.ZodBoolean>;
1097
+ }, z.core.$strip>>;
1098
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
1099
+ avg: z.ZodOptional<z.ZodArray<z.ZodString>>;
1100
+ limit: z.ZodObject<{
1101
+ variable: z.ZodOptional<z.ZodString>;
1102
+ value: z.ZodOptional<z.ZodNumber>;
1103
+ default: z.ZodNumber;
1104
+ max: z.ZodNumber;
1105
+ }, z.core.$strip>;
1106
+ offset: z.ZodOptional<z.ZodObject<{
1107
+ variable: z.ZodOptional<z.ZodString>;
1108
+ value: z.ZodOptional<z.ZodNumber>;
1109
+ }, z.core.$strip>>;
1110
+ includeIf: z.ZodOptional<z.ZodObject<{
1111
+ variable: z.ZodString;
1112
+ negated: z.ZodBoolean;
1113
+ }, z.core.$strip>>;
959
1114
  }, z.core.$strip>, z.ZodObject<{
960
1115
  kind: z.ZodLiteral<"mutation">;
961
1116
  op: z.ZodEnum<{
@@ -1095,6 +1250,7 @@ declare const compiledArtifactSchema: z.ZodObject<{
1095
1250
  insertCheck: z.ZodOptional<z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>>;
1096
1251
  returning: z.ZodNullable<z.ZodType<SelectionIr, unknown, z.core.$ZodTypeInternals<SelectionIr, unknown>>>;
1097
1252
  affectedRows: z.ZodDefault<z.ZodBoolean>;
1253
+ assertAffectedRows: z.ZodOptional<z.ZodNumber>;
1098
1254
  includeIf: z.ZodOptional<z.ZodObject<{
1099
1255
  variable: z.ZodString;
1100
1256
  negated: z.ZodBoolean;
@@ -1116,4 +1272,4 @@ declare function normalizeIr(raw: unknown): CompiledArtifact;
1116
1272
  /** Index an artifact's operations by opHash (the wire selector). */
1117
1273
  declare function indexByHash(artifact: CompiledArtifact): Map<string, CompiledOperation>;
1118
1274
 
1119
- export { CLAIMS_CONTRACT, CMP_OPS, type ClaimKey, type CmpOp, type CompiledArtifact, type CompiledOperation, INPUT_REF_KINDS, IR_VERSION, type InputRefKind, IrVersionError, type LimitIr, type OrderIr, type PredIr, type RootIr, type SelectionIr, type TableMetaIr, type ValueIr, type VariableDefaultIr, type VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema };
1275
+ export { CLAIMS_CONTRACT, CMP_OPS, type ClaimKey, type CmpOp, type CompiledArtifact, type CompiledOperation, DATE_BUCKETS, type DateBucket, type GroupByKeyIr, INPUT_REF_KINDS, IR_VERSION, type InputRefKind, IrVersionError, LEGACY_IR_VERSION, type LimitIr, type OrderIr, type PredIr, type RootIr, type SelectionIr, type TableMetaIr, type ValueIr, type VariableDefaultIr, type VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, requiredArtifactIrVersion, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema };
package/dist/ir.d.ts CHANGED
@@ -22,7 +22,12 @@ import { z } from 'zod';
22
22
  * pattern): executor upgrades decouple from artifact re-pushes.
23
23
  */
24
24
 
25
- declare const IR_VERSION: 1;
25
+ /** Maximum supported version. Emit v1 until an operation needs v2 semantics. */
26
+ declare const IR_VERSION: 2;
27
+ declare const LEGACY_IR_VERSION: 1;
28
+ declare const irVersionSchema: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
29
+ /** Keep v1 artifact identity when assembling only legacy operations from registry rows. */
30
+ declare function requiredArtifactIrVersion(operations: readonly unknown[]): z.infer<typeof irVersionSchema>;
26
31
  /** The exact claim keys the platform stamps — mirrors claims.ts. */
27
32
  declare const CLAIMS_CONTRACT: {
28
33
  readonly sub: "string";
@@ -156,6 +161,32 @@ interface SelectionIr {
156
161
  }
157
162
  declare const selectionIrSchema: z.ZodType<SelectionIr>;
158
163
 
164
+ /**
165
+ * The date-bucket units a grouped aggregate may apply to a `date` /
166
+ * `timestamptz` group key. A CLOSED enum on purpose: the executor maps each
167
+ * member to a `date_trunc` literal, so no caller-supplied string ever reaches
168
+ * SQL text. Adding a unit means adding it here AND to the executor's map —
169
+ * the executor's exhaustive switch makes the omission a type error.
170
+ */
171
+ declare const DATE_BUCKETS: readonly ["year", "quarter", "month", "week", "day", "hour"];
172
+ type DateBucket = (typeof DATE_BUCKETS)[number];
173
+ /**
174
+ * One group key: a column, optionally bucketed. `bucket` is only ever set on a
175
+ * `date` / `timestamptz` column — the compiler rejects it on anything else, so
176
+ * the executor can apply `date_trunc` without re-checking the column type.
177
+ */
178
+ declare const groupByKeyIrSchema: z.ZodObject<{
179
+ column: z.ZodString;
180
+ bucket: z.ZodOptional<z.ZodEnum<{
181
+ year: "year";
182
+ quarter: "quarter";
183
+ month: "month";
184
+ week: "week";
185
+ day: "day";
186
+ hour: "hour";
187
+ }>>;
188
+ }, z.core.$strip>;
189
+ type GroupByKeyIr = z.infer<typeof groupByKeyIrSchema>;
159
190
  declare const rootIrSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
160
191
  kind: z.ZodLiteral<"select">;
161
192
  alias: z.ZodString;
@@ -237,6 +268,46 @@ declare const rootIrSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
237
268
  variable: z.ZodString;
238
269
  negated: z.ZodBoolean;
239
270
  }, z.core.$strip>>;
271
+ }, z.core.$strip>, z.ZodObject<{
272
+ kind: z.ZodLiteral<"aggregateGroups">;
273
+ alias: z.ZodString;
274
+ table: z.ZodString;
275
+ where: z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>;
276
+ groupBy: z.ZodArray<z.ZodObject<{
277
+ column: z.ZodString;
278
+ bucket: z.ZodOptional<z.ZodEnum<{
279
+ year: "year";
280
+ quarter: "quarter";
281
+ month: "month";
282
+ week: "week";
283
+ day: "day";
284
+ hour: "hour";
285
+ }>>;
286
+ }, z.core.$strip>>;
287
+ key: z.ZodDefault<z.ZodArray<z.ZodObject<{
288
+ alias: z.ZodString;
289
+ column: z.ZodString;
290
+ }, z.core.$strip>>>;
291
+ count: z.ZodOptional<z.ZodObject<{
292
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
293
+ distinct: z.ZodOptional<z.ZodBoolean>;
294
+ }, z.core.$strip>>;
295
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
296
+ avg: z.ZodOptional<z.ZodArray<z.ZodString>>;
297
+ limit: z.ZodObject<{
298
+ variable: z.ZodOptional<z.ZodString>;
299
+ value: z.ZodOptional<z.ZodNumber>;
300
+ default: z.ZodNumber;
301
+ max: z.ZodNumber;
302
+ }, z.core.$strip>;
303
+ offset: z.ZodOptional<z.ZodObject<{
304
+ variable: z.ZodOptional<z.ZodString>;
305
+ value: z.ZodOptional<z.ZodNumber>;
306
+ }, z.core.$strip>>;
307
+ includeIf: z.ZodOptional<z.ZodObject<{
308
+ variable: z.ZodString;
309
+ negated: z.ZodBoolean;
310
+ }, z.core.$strip>>;
240
311
  }, z.core.$strip>, z.ZodObject<{
241
312
  kind: z.ZodLiteral<"mutation">;
242
313
  op: z.ZodEnum<{
@@ -376,6 +447,7 @@ declare const rootIrSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
376
447
  insertCheck: z.ZodOptional<z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>>;
377
448
  returning: z.ZodNullable<z.ZodType<SelectionIr, unknown, z.core.$ZodTypeInternals<SelectionIr, unknown>>>;
378
449
  affectedRows: z.ZodDefault<z.ZodBoolean>;
450
+ assertAffectedRows: z.ZodOptional<z.ZodNumber>;
379
451
  includeIf: z.ZodOptional<z.ZodObject<{
380
452
  variable: z.ZodString;
381
453
  negated: z.ZodBoolean;
@@ -436,7 +508,7 @@ declare const variableIrSchema: z.ZodObject<{
436
508
  }, z.core.$strip>;
437
509
  type VariableIr = z.infer<typeof variableIrSchema>;
438
510
  declare const compiledOperationSchema: z.ZodObject<{
439
- irVersion: z.ZodLiteral<1>;
511
+ irVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
440
512
  name: z.ZodString;
441
513
  opHash: z.ZodString;
442
514
  kind: z.ZodEnum<{
@@ -568,6 +640,46 @@ declare const compiledOperationSchema: z.ZodObject<{
568
640
  variable: z.ZodString;
569
641
  negated: z.ZodBoolean;
570
642
  }, z.core.$strip>>;
643
+ }, z.core.$strip>, z.ZodObject<{
644
+ kind: z.ZodLiteral<"aggregateGroups">;
645
+ alias: z.ZodString;
646
+ table: z.ZodString;
647
+ where: z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>;
648
+ groupBy: z.ZodArray<z.ZodObject<{
649
+ column: z.ZodString;
650
+ bucket: z.ZodOptional<z.ZodEnum<{
651
+ year: "year";
652
+ quarter: "quarter";
653
+ month: "month";
654
+ week: "week";
655
+ day: "day";
656
+ hour: "hour";
657
+ }>>;
658
+ }, z.core.$strip>>;
659
+ key: z.ZodDefault<z.ZodArray<z.ZodObject<{
660
+ alias: z.ZodString;
661
+ column: z.ZodString;
662
+ }, z.core.$strip>>>;
663
+ count: z.ZodOptional<z.ZodObject<{
664
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
665
+ distinct: z.ZodOptional<z.ZodBoolean>;
666
+ }, z.core.$strip>>;
667
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
668
+ avg: z.ZodOptional<z.ZodArray<z.ZodString>>;
669
+ limit: z.ZodObject<{
670
+ variable: z.ZodOptional<z.ZodString>;
671
+ value: z.ZodOptional<z.ZodNumber>;
672
+ default: z.ZodNumber;
673
+ max: z.ZodNumber;
674
+ }, z.core.$strip>;
675
+ offset: z.ZodOptional<z.ZodObject<{
676
+ variable: z.ZodOptional<z.ZodString>;
677
+ value: z.ZodOptional<z.ZodNumber>;
678
+ }, z.core.$strip>>;
679
+ includeIf: z.ZodOptional<z.ZodObject<{
680
+ variable: z.ZodString;
681
+ negated: z.ZodBoolean;
682
+ }, z.core.$strip>>;
571
683
  }, z.core.$strip>, z.ZodObject<{
572
684
  kind: z.ZodLiteral<"mutation">;
573
685
  op: z.ZodEnum<{
@@ -707,6 +819,7 @@ declare const compiledOperationSchema: z.ZodObject<{
707
819
  insertCheck: z.ZodOptional<z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>>;
708
820
  returning: z.ZodNullable<z.ZodType<SelectionIr, unknown, z.core.$ZodTypeInternals<SelectionIr, unknown>>>;
709
821
  affectedRows: z.ZodDefault<z.ZodBoolean>;
822
+ assertAffectedRows: z.ZodOptional<z.ZodNumber>;
710
823
  includeIf: z.ZodOptional<z.ZodObject<{
711
824
  variable: z.ZodString;
712
825
  negated: z.ZodBoolean;
@@ -761,6 +874,7 @@ declare const tableMetaIrSchema: z.ZodObject<{
761
874
  insertable: z.ZodArray<z.ZodString>;
762
875
  settable: z.ZodArray<z.ZodString>;
763
876
  appendable: z.ZodArray<z.ZodString>;
877
+ touchOnUpdate: z.ZodOptional<z.ZodArray<z.ZodString>>;
764
878
  constraints: z.ZodArray<z.ZodObject<{
765
879
  name: z.ZodString;
766
880
  columns: z.ZodArray<z.ZodString>;
@@ -770,7 +884,7 @@ declare const tableMetaIrSchema: z.ZodObject<{
770
884
  }, z.core.$strip>;
771
885
  type TableMetaIr = z.infer<typeof tableMetaIrSchema>;
772
886
  declare const compiledArtifactSchema: z.ZodObject<{
773
- irVersion: z.ZodLiteral<1>;
887
+ irVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
774
888
  namespace: z.ZodString;
775
889
  schemaHash: z.ZodString;
776
890
  opsHash: z.ZodString;
@@ -816,6 +930,7 @@ declare const compiledArtifactSchema: z.ZodObject<{
816
930
  insertable: z.ZodArray<z.ZodString>;
817
931
  settable: z.ZodArray<z.ZodString>;
818
932
  appendable: z.ZodArray<z.ZodString>;
933
+ touchOnUpdate: z.ZodOptional<z.ZodArray<z.ZodString>>;
819
934
  constraints: z.ZodArray<z.ZodObject<{
820
935
  name: z.ZodString;
821
936
  columns: z.ZodArray<z.ZodString>;
@@ -824,7 +939,7 @@ declare const compiledArtifactSchema: z.ZodObject<{
824
939
  dynamicFilterMaxNodes: z.ZodDefault<z.ZodNumber>;
825
940
  }, z.core.$strip>>;
826
941
  operations: z.ZodRecord<z.ZodString, z.ZodObject<{
827
- irVersion: z.ZodLiteral<1>;
942
+ irVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
828
943
  name: z.ZodString;
829
944
  opHash: z.ZodString;
830
945
  kind: z.ZodEnum<{
@@ -956,6 +1071,46 @@ declare const compiledArtifactSchema: z.ZodObject<{
956
1071
  variable: z.ZodString;
957
1072
  negated: z.ZodBoolean;
958
1073
  }, z.core.$strip>>;
1074
+ }, z.core.$strip>, z.ZodObject<{
1075
+ kind: z.ZodLiteral<"aggregateGroups">;
1076
+ alias: z.ZodString;
1077
+ table: z.ZodString;
1078
+ where: z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>;
1079
+ groupBy: z.ZodArray<z.ZodObject<{
1080
+ column: z.ZodString;
1081
+ bucket: z.ZodOptional<z.ZodEnum<{
1082
+ year: "year";
1083
+ quarter: "quarter";
1084
+ month: "month";
1085
+ week: "week";
1086
+ day: "day";
1087
+ hour: "hour";
1088
+ }>>;
1089
+ }, z.core.$strip>>;
1090
+ key: z.ZodDefault<z.ZodArray<z.ZodObject<{
1091
+ alias: z.ZodString;
1092
+ column: z.ZodString;
1093
+ }, z.core.$strip>>>;
1094
+ count: z.ZodOptional<z.ZodObject<{
1095
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
1096
+ distinct: z.ZodOptional<z.ZodBoolean>;
1097
+ }, z.core.$strip>>;
1098
+ sum: z.ZodOptional<z.ZodArray<z.ZodString>>;
1099
+ avg: z.ZodOptional<z.ZodArray<z.ZodString>>;
1100
+ limit: z.ZodObject<{
1101
+ variable: z.ZodOptional<z.ZodString>;
1102
+ value: z.ZodOptional<z.ZodNumber>;
1103
+ default: z.ZodNumber;
1104
+ max: z.ZodNumber;
1105
+ }, z.core.$strip>;
1106
+ offset: z.ZodOptional<z.ZodObject<{
1107
+ variable: z.ZodOptional<z.ZodString>;
1108
+ value: z.ZodOptional<z.ZodNumber>;
1109
+ }, z.core.$strip>>;
1110
+ includeIf: z.ZodOptional<z.ZodObject<{
1111
+ variable: z.ZodString;
1112
+ negated: z.ZodBoolean;
1113
+ }, z.core.$strip>>;
959
1114
  }, z.core.$strip>, z.ZodObject<{
960
1115
  kind: z.ZodLiteral<"mutation">;
961
1116
  op: z.ZodEnum<{
@@ -1095,6 +1250,7 @@ declare const compiledArtifactSchema: z.ZodObject<{
1095
1250
  insertCheck: z.ZodOptional<z.ZodType<PredIr, unknown, z.core.$ZodTypeInternals<PredIr, unknown>>>;
1096
1251
  returning: z.ZodNullable<z.ZodType<SelectionIr, unknown, z.core.$ZodTypeInternals<SelectionIr, unknown>>>;
1097
1252
  affectedRows: z.ZodDefault<z.ZodBoolean>;
1253
+ assertAffectedRows: z.ZodOptional<z.ZodNumber>;
1098
1254
  includeIf: z.ZodOptional<z.ZodObject<{
1099
1255
  variable: z.ZodString;
1100
1256
  negated: z.ZodBoolean;
@@ -1116,4 +1272,4 @@ declare function normalizeIr(raw: unknown): CompiledArtifact;
1116
1272
  /** Index an artifact's operations by opHash (the wire selector). */
1117
1273
  declare function indexByHash(artifact: CompiledArtifact): Map<string, CompiledOperation>;
1118
1274
 
1119
- export { CLAIMS_CONTRACT, CMP_OPS, type ClaimKey, type CmpOp, type CompiledArtifact, type CompiledOperation, INPUT_REF_KINDS, IR_VERSION, type InputRefKind, IrVersionError, type LimitIr, type OrderIr, type PredIr, type RootIr, type SelectionIr, type TableMetaIr, type ValueIr, type VariableDefaultIr, type VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema };
1275
+ export { CLAIMS_CONTRACT, CMP_OPS, type ClaimKey, type CmpOp, type CompiledArtifact, type CompiledOperation, DATE_BUCKETS, type DateBucket, type GroupByKeyIr, INPUT_REF_KINDS, IR_VERSION, type InputRefKind, IrVersionError, LEGACY_IR_VERSION, type LimitIr, type OrderIr, type PredIr, type RootIr, type SelectionIr, type TableMetaIr, type ValueIr, type VariableDefaultIr, type VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, requiredArtifactIrVersion, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema };