@sequenceholdings/orm 2.8.4 → 2.9.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 (60) hide show
  1. package/dist/authoring.cjs +142 -56
  2. package/dist/authoring.cjs.map +1 -1
  3. package/dist/authoring.d.cts +7 -3
  4. package/dist/authoring.d.ts +7 -3
  5. package/dist/authoring.js +142 -56
  6. package/dist/authoring.js.map +1 -1
  7. package/dist/canonical.cjs +63 -13
  8. package/dist/canonical.cjs.map +1 -1
  9. package/dist/canonical.d.cts +77 -72
  10. package/dist/canonical.d.ts +77 -72
  11. package/dist/canonical.js +63 -13
  12. package/dist/canonical.js.map +1 -1
  13. package/dist/cli.cjs +170 -72
  14. package/dist/cli.cjs.map +1 -1
  15. package/dist/cli.d.cts +23 -1
  16. package/dist/cli.d.ts +23 -1
  17. package/dist/cli.js +167 -73
  18. package/dist/cli.js.map +1 -1
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.cts +1 -1
  21. package/dist/client.d.ts +1 -1
  22. package/dist/client.js.map +1 -1
  23. package/dist/compiler.cjs +77 -20
  24. package/dist/compiler.cjs.map +1 -1
  25. package/dist/compiler.d.cts +2 -2
  26. package/dist/compiler.d.ts +2 -2
  27. package/dist/compiler.js +77 -20
  28. package/dist/compiler.js.map +1 -1
  29. package/dist/{constants-Dou1RkTo.d.cts → constants-D2o0vK6U.d.cts} +8 -1
  30. package/dist/{constants-Dou1RkTo.d.ts → constants-D2o0vK6U.d.ts} +8 -1
  31. package/dist/dynamic-input.d.cts +1 -1
  32. package/dist/dynamic-input.d.ts +1 -1
  33. package/dist/index.cjs +193 -82
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +62 -59
  36. package/dist/index.d.ts +62 -59
  37. package/dist/index.js +192 -83
  38. package/dist/index.js.map +1 -1
  39. package/dist/ir.cjs +70 -15
  40. package/dist/ir.cjs.map +1 -1
  41. package/dist/ir.d.cts +76 -76
  42. package/dist/ir.d.ts +76 -76
  43. package/dist/ir.js +70 -15
  44. package/dist/ir.js.map +1 -1
  45. package/dist/predicate-v2.cjs +70 -15
  46. package/dist/predicate-v2.cjs.map +1 -1
  47. package/dist/predicate-v2.d.cts +1 -1
  48. package/dist/predicate-v2.d.ts +1 -1
  49. package/dist/predicate-v2.js +70 -15
  50. package/dist/predicate-v2.js.map +1 -1
  51. package/dist/sdl.cjs +70 -15
  52. package/dist/sdl.cjs.map +1 -1
  53. package/dist/sdl.d.cts +1 -1
  54. package/dist/sdl.d.ts +1 -1
  55. package/dist/sdl.js +70 -15
  56. package/dist/sdl.js.map +1 -1
  57. package/package.json +3 -3
  58. package/templates/orm-namespace/package.json +2 -1
  59. package/dist/{definition-DjfC7Lll.d.cts → definition-B99BsOAO.d.cts} +4 -4
  60. package/dist/{definition-DjfC7Lll.d.ts → definition-B99BsOAO.d.ts} +4 -4
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { b as CellPart } from './constants-Dou1RkTo.js';
2
+ import { b as CellPart } from './constants-D2o0vK6U.js';
3
3
  export { P as PolicyExpression, p as policyExpressionSchema, a as policyVariantSchema } from './policy-1iZbGnZZ.js';
4
4
 
5
5
  /** Authored intent only. Operation compilation validates reach; it never adds declarations. */
@@ -102,8 +102,8 @@ type CanonicalFetchShape = z.infer<typeof canonicalFetchShapeSchema>;
102
102
  declare const canonicalResolvedSourceSchema: z.ZodObject<{
103
103
  name: z.ZodString;
104
104
  kind: z.ZodEnum<{
105
- manual: "manual";
106
105
  prefetch: "prefetch";
106
+ manual: "manual";
107
107
  etl: "etl";
108
108
  }>;
109
109
  table: z.ZodString;
@@ -160,8 +160,8 @@ declare const canonicalResolvedSchema: z.ZodObject<{
160
160
  sources: z.ZodArray<z.ZodObject<{
161
161
  name: z.ZodString;
162
162
  kind: z.ZodEnum<{
163
- manual: "manual";
164
163
  prefetch: "prefetch";
164
+ manual: "manual";
165
165
  etl: "etl";
166
166
  }>;
167
167
  table: z.ZodString;
@@ -213,6 +213,7 @@ declare const canonicalResolvedSchema: z.ZodObject<{
213
213
  orderBy: z.ZodOptional<z.ZodString>;
214
214
  }, z.core.$strict>>;
215
215
  deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
216
+ existsIn: z.ZodOptional<z.ZodArray<z.ZodString>>;
216
217
  materialized: z.ZodOptional<z.ZodObject<{
217
218
  table: z.ZodString;
218
219
  compute: z.ZodString;
@@ -325,13 +326,13 @@ declare const canonicalColumnSchema: z.ZodObject<{
325
326
  bigint: "bigint";
326
327
  boolean: "boolean";
327
328
  date: "date";
328
- text: "text";
329
- timestamptz: "timestamptz";
330
- jsonb: "jsonb";
331
329
  uuid: "uuid";
330
+ text: "text";
332
331
  integer: "integer";
333
332
  numeric: "numeric";
334
333
  double: "double";
334
+ timestamptz: "timestamptz";
335
+ jsonb: "jsonb";
335
336
  }>, z.ZodObject<{
336
337
  enum: z.ZodString;
337
338
  }, z.core.$strip>]>;
@@ -353,10 +354,10 @@ declare const canonicalColumnSchema: z.ZodObject<{
353
354
  of: z.ZodString;
354
355
  part: z.ZodEnum<{
355
356
  at: "at";
356
- by: "by";
357
- rev: "rev";
358
357
  source: "source";
358
+ by: "by";
359
359
  conflicts: "conflicts";
360
+ rev: "rev";
360
361
  }>;
361
362
  }, z.core.$strict>>;
362
363
  }, z.core.$strip>;
@@ -460,21 +461,21 @@ declare const canonicalActionSchema: z.ZodObject<{
460
461
  bigint: "bigint";
461
462
  boolean: "boolean";
462
463
  date: "date";
463
- text: "text";
464
- timestamptz: "timestamptz";
465
- jsonb: "jsonb";
466
464
  uuid: "uuid";
465
+ text: "text";
467
466
  integer: "integer";
468
467
  numeric: "numeric";
469
468
  double: "double";
469
+ timestamptz: "timestamptz";
470
+ jsonb: "jsonb";
470
471
  }>;
471
472
  nullable: z.ZodDefault<z.ZodBoolean>;
472
473
  }, z.core.$strip>>>;
473
474
  executes: z.ZodString;
474
475
  returns: z.ZodDefault<z.ZodEnum<{
475
476
  rows: "rows";
476
- rowsAffected: "rowsAffected";
477
477
  scalar: "scalar";
478
+ rowsAffected: "rowsAffected";
478
479
  }>>;
479
480
  audit: z.ZodOptional<z.ZodObject<{
480
481
  action: z.ZodString;
@@ -540,13 +541,13 @@ declare const canonicalTableSchema: z.ZodObject<{
540
541
  bigint: "bigint";
541
542
  boolean: "boolean";
542
543
  date: "date";
543
- text: "text";
544
- timestamptz: "timestamptz";
545
- jsonb: "jsonb";
546
544
  uuid: "uuid";
545
+ text: "text";
547
546
  integer: "integer";
548
547
  numeric: "numeric";
549
548
  double: "double";
549
+ timestamptz: "timestamptz";
550
+ jsonb: "jsonb";
550
551
  }>, z.ZodObject<{
551
552
  enum: z.ZodString;
552
553
  }, z.core.$strip>]>;
@@ -568,10 +569,10 @@ declare const canonicalTableSchema: z.ZodObject<{
568
569
  of: z.ZodString;
569
570
  part: z.ZodEnum<{
570
571
  at: "at";
571
- by: "by";
572
- rev: "rev";
573
572
  source: "source";
573
+ by: "by";
574
574
  conflicts: "conflicts";
575
+ rev: "rev";
575
576
  }>;
576
577
  }, z.core.$strict>>;
577
578
  }, z.core.$strip>>>;
@@ -655,21 +656,21 @@ declare const canonicalTableSchema: z.ZodObject<{
655
656
  bigint: "bigint";
656
657
  boolean: "boolean";
657
658
  date: "date";
658
- text: "text";
659
- timestamptz: "timestamptz";
660
- jsonb: "jsonb";
661
659
  uuid: "uuid";
660
+ text: "text";
662
661
  integer: "integer";
663
662
  numeric: "numeric";
664
663
  double: "double";
664
+ timestamptz: "timestamptz";
665
+ jsonb: "jsonb";
665
666
  }>;
666
667
  nullable: z.ZodDefault<z.ZodBoolean>;
667
668
  }, z.core.$strip>>>;
668
669
  executes: z.ZodString;
669
670
  returns: z.ZodDefault<z.ZodEnum<{
670
671
  rows: "rows";
671
- rowsAffected: "rowsAffected";
672
672
  scalar: "scalar";
673
+ rowsAffected: "rowsAffected";
673
674
  }>>;
674
675
  audit: z.ZodOptional<z.ZodObject<{
675
676
  action: z.ZodString;
@@ -726,13 +727,13 @@ declare const canonicalViewSchema: z.ZodObject<{
726
727
  bigint: "bigint";
727
728
  boolean: "boolean";
728
729
  date: "date";
729
- text: "text";
730
- timestamptz: "timestamptz";
731
- jsonb: "jsonb";
732
730
  uuid: "uuid";
731
+ text: "text";
733
732
  integer: "integer";
734
733
  numeric: "numeric";
735
734
  double: "double";
735
+ timestamptz: "timestamptz";
736
+ jsonb: "jsonb";
736
737
  }>, z.ZodObject<{
737
738
  enum: z.ZodString;
738
739
  }, z.core.$strip>]>;
@@ -754,10 +755,10 @@ declare const canonicalViewSchema: z.ZodObject<{
754
755
  of: z.ZodString;
755
756
  part: z.ZodEnum<{
756
757
  at: "at";
757
- by: "by";
758
- rev: "rev";
759
758
  source: "source";
759
+ by: "by";
760
760
  conflicts: "conflicts";
761
+ rev: "rev";
761
762
  }>;
762
763
  }, z.core.$strict>>;
763
764
  }, z.core.$strip>>;
@@ -806,8 +807,8 @@ declare const canonicalViewSchema: z.ZodObject<{
806
807
  sources: z.ZodArray<z.ZodObject<{
807
808
  name: z.ZodString;
808
809
  kind: z.ZodEnum<{
809
- manual: "manual";
810
810
  prefetch: "prefetch";
811
+ manual: "manual";
811
812
  etl: "etl";
812
813
  }>;
813
814
  table: z.ZodString;
@@ -859,6 +860,7 @@ declare const canonicalViewSchema: z.ZodObject<{
859
860
  orderBy: z.ZodOptional<z.ZodString>;
860
861
  }, z.core.$strict>>;
861
862
  deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
863
+ existsIn: z.ZodOptional<z.ZodArray<z.ZodString>>;
862
864
  materialized: z.ZodOptional<z.ZodObject<{
863
865
  table: z.ZodString;
864
866
  compute: z.ZodString;
@@ -947,13 +949,13 @@ declare const localDefinitionSchema: z.ZodObject<{
947
949
  bigint: "bigint";
948
950
  boolean: "boolean";
949
951
  date: "date";
950
- text: "text";
951
- timestamptz: "timestamptz";
952
- jsonb: "jsonb";
953
952
  uuid: "uuid";
953
+ text: "text";
954
954
  integer: "integer";
955
955
  numeric: "numeric";
956
956
  double: "double";
957
+ timestamptz: "timestamptz";
958
+ jsonb: "jsonb";
957
959
  }>, z.ZodObject<{
958
960
  enum: z.ZodString;
959
961
  }, z.core.$strip>]>;
@@ -975,10 +977,10 @@ declare const localDefinitionSchema: z.ZodObject<{
975
977
  of: z.ZodString;
976
978
  part: z.ZodEnum<{
977
979
  at: "at";
978
- by: "by";
979
- rev: "rev";
980
980
  source: "source";
981
+ by: "by";
981
982
  conflicts: "conflicts";
983
+ rev: "rev";
982
984
  }>;
983
985
  }, z.core.$strict>>;
984
986
  }, z.core.$strip>>>;
@@ -1062,21 +1064,21 @@ declare const localDefinitionSchema: z.ZodObject<{
1062
1064
  bigint: "bigint";
1063
1065
  boolean: "boolean";
1064
1066
  date: "date";
1065
- text: "text";
1066
- timestamptz: "timestamptz";
1067
- jsonb: "jsonb";
1068
1067
  uuid: "uuid";
1068
+ text: "text";
1069
1069
  integer: "integer";
1070
1070
  numeric: "numeric";
1071
1071
  double: "double";
1072
+ timestamptz: "timestamptz";
1073
+ jsonb: "jsonb";
1072
1074
  }>;
1073
1075
  nullable: z.ZodDefault<z.ZodBoolean>;
1074
1076
  }, z.core.$strip>>>;
1075
1077
  executes: z.ZodString;
1076
1078
  returns: z.ZodDefault<z.ZodEnum<{
1077
1079
  rows: "rows";
1078
- rowsAffected: "rowsAffected";
1079
1080
  scalar: "scalar";
1081
+ rowsAffected: "rowsAffected";
1080
1082
  }>>;
1081
1083
  audit: z.ZodOptional<z.ZodObject<{
1082
1084
  action: z.ZodString;
@@ -1132,13 +1134,13 @@ declare const localDefinitionSchema: z.ZodObject<{
1132
1134
  bigint: "bigint";
1133
1135
  boolean: "boolean";
1134
1136
  date: "date";
1135
- text: "text";
1136
- timestamptz: "timestamptz";
1137
- jsonb: "jsonb";
1138
1137
  uuid: "uuid";
1138
+ text: "text";
1139
1139
  integer: "integer";
1140
1140
  numeric: "numeric";
1141
1141
  double: "double";
1142
+ timestamptz: "timestamptz";
1143
+ jsonb: "jsonb";
1142
1144
  }>, z.ZodObject<{
1143
1145
  enum: z.ZodString;
1144
1146
  }, z.core.$strip>]>;
@@ -1160,10 +1162,10 @@ declare const localDefinitionSchema: z.ZodObject<{
1160
1162
  of: z.ZodString;
1161
1163
  part: z.ZodEnum<{
1162
1164
  at: "at";
1163
- by: "by";
1164
- rev: "rev";
1165
1165
  source: "source";
1166
+ by: "by";
1166
1167
  conflicts: "conflicts";
1168
+ rev: "rev";
1167
1169
  }>;
1168
1170
  }, z.core.$strict>>;
1169
1171
  }, z.core.$strip>>;
@@ -1212,8 +1214,8 @@ declare const localDefinitionSchema: z.ZodObject<{
1212
1214
  sources: z.ZodArray<z.ZodObject<{
1213
1215
  name: z.ZodString;
1214
1216
  kind: z.ZodEnum<{
1215
- manual: "manual";
1216
1217
  prefetch: "prefetch";
1218
+ manual: "manual";
1217
1219
  etl: "etl";
1218
1220
  }>;
1219
1221
  table: z.ZodString;
@@ -1265,6 +1267,7 @@ declare const localDefinitionSchema: z.ZodObject<{
1265
1267
  orderBy: z.ZodOptional<z.ZodString>;
1266
1268
  }, z.core.$strict>>;
1267
1269
  deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1270
+ existsIn: z.ZodOptional<z.ZodArray<z.ZodString>>;
1268
1271
  materialized: z.ZodOptional<z.ZodObject<{
1269
1272
  table: z.ZodString;
1270
1273
  compute: z.ZodString;
@@ -1336,13 +1339,13 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1336
1339
  bigint: "bigint";
1337
1340
  boolean: "boolean";
1338
1341
  date: "date";
1339
- text: "text";
1340
- timestamptz: "timestamptz";
1341
- jsonb: "jsonb";
1342
1342
  uuid: "uuid";
1343
+ text: "text";
1343
1344
  integer: "integer";
1344
1345
  numeric: "numeric";
1345
1346
  double: "double";
1347
+ timestamptz: "timestamptz";
1348
+ jsonb: "jsonb";
1346
1349
  }>, z.ZodObject<{
1347
1350
  enum: z.ZodString;
1348
1351
  }, z.core.$strip>]>;
@@ -1364,10 +1367,10 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1364
1367
  of: z.ZodString;
1365
1368
  part: z.ZodEnum<{
1366
1369
  at: "at";
1367
- by: "by";
1368
- rev: "rev";
1369
1370
  source: "source";
1371
+ by: "by";
1370
1372
  conflicts: "conflicts";
1373
+ rev: "rev";
1371
1374
  }>;
1372
1375
  }, z.core.$strict>>;
1373
1376
  }, z.core.$strip>>>;
@@ -1451,21 +1454,21 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1451
1454
  bigint: "bigint";
1452
1455
  boolean: "boolean";
1453
1456
  date: "date";
1454
- text: "text";
1455
- timestamptz: "timestamptz";
1456
- jsonb: "jsonb";
1457
1457
  uuid: "uuid";
1458
+ text: "text";
1458
1459
  integer: "integer";
1459
1460
  numeric: "numeric";
1460
1461
  double: "double";
1462
+ timestamptz: "timestamptz";
1463
+ jsonb: "jsonb";
1461
1464
  }>;
1462
1465
  nullable: z.ZodDefault<z.ZodBoolean>;
1463
1466
  }, z.core.$strip>>>;
1464
1467
  executes: z.ZodString;
1465
1468
  returns: z.ZodDefault<z.ZodEnum<{
1466
1469
  rows: "rows";
1467
- rowsAffected: "rowsAffected";
1468
1470
  scalar: "scalar";
1471
+ rowsAffected: "rowsAffected";
1469
1472
  }>>;
1470
1473
  audit: z.ZodOptional<z.ZodObject<{
1471
1474
  action: z.ZodString;
@@ -1521,13 +1524,13 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1521
1524
  bigint: "bigint";
1522
1525
  boolean: "boolean";
1523
1526
  date: "date";
1524
- text: "text";
1525
- timestamptz: "timestamptz";
1526
- jsonb: "jsonb";
1527
1527
  uuid: "uuid";
1528
+ text: "text";
1528
1529
  integer: "integer";
1529
1530
  numeric: "numeric";
1530
1531
  double: "double";
1532
+ timestamptz: "timestamptz";
1533
+ jsonb: "jsonb";
1531
1534
  }>, z.ZodObject<{
1532
1535
  enum: z.ZodString;
1533
1536
  }, z.core.$strip>]>;
@@ -1549,10 +1552,10 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1549
1552
  of: z.ZodString;
1550
1553
  part: z.ZodEnum<{
1551
1554
  at: "at";
1552
- by: "by";
1553
- rev: "rev";
1554
1555
  source: "source";
1556
+ by: "by";
1555
1557
  conflicts: "conflicts";
1558
+ rev: "rev";
1556
1559
  }>;
1557
1560
  }, z.core.$strict>>;
1558
1561
  }, z.core.$strip>>;
@@ -1601,8 +1604,8 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1601
1604
  sources: z.ZodArray<z.ZodObject<{
1602
1605
  name: z.ZodString;
1603
1606
  kind: z.ZodEnum<{
1604
- manual: "manual";
1605
1607
  prefetch: "prefetch";
1608
+ manual: "manual";
1606
1609
  etl: "etl";
1607
1610
  }>;
1608
1611
  table: z.ZodString;
@@ -1654,6 +1657,7 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1654
1657
  orderBy: z.ZodOptional<z.ZodString>;
1655
1658
  }, z.core.$strict>>;
1656
1659
  deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1660
+ existsIn: z.ZodOptional<z.ZodArray<z.ZodString>>;
1657
1661
  materialized: z.ZodOptional<z.ZodObject<{
1658
1662
  table: z.ZodString;
1659
1663
  compute: z.ZodString;
@@ -1724,13 +1728,13 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1724
1728
  bigint: "bigint";
1725
1729
  boolean: "boolean";
1726
1730
  date: "date";
1727
- text: "text";
1728
- timestamptz: "timestamptz";
1729
- jsonb: "jsonb";
1730
1731
  uuid: "uuid";
1732
+ text: "text";
1731
1733
  integer: "integer";
1732
1734
  numeric: "numeric";
1733
1735
  double: "double";
1736
+ timestamptz: "timestamptz";
1737
+ jsonb: "jsonb";
1734
1738
  }>, z.ZodObject<{
1735
1739
  enum: z.ZodString;
1736
1740
  }, z.core.$strip>]>;
@@ -1752,10 +1756,10 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1752
1756
  of: z.ZodString;
1753
1757
  part: z.ZodEnum<{
1754
1758
  at: "at";
1755
- by: "by";
1756
- rev: "rev";
1757
1759
  source: "source";
1760
+ by: "by";
1758
1761
  conflicts: "conflicts";
1762
+ rev: "rev";
1759
1763
  }>;
1760
1764
  }, z.core.$strict>>;
1761
1765
  }, z.core.$strip>>>;
@@ -1839,21 +1843,21 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1839
1843
  bigint: "bigint";
1840
1844
  boolean: "boolean";
1841
1845
  date: "date";
1842
- text: "text";
1843
- timestamptz: "timestamptz";
1844
- jsonb: "jsonb";
1845
1846
  uuid: "uuid";
1847
+ text: "text";
1846
1848
  integer: "integer";
1847
1849
  numeric: "numeric";
1848
1850
  double: "double";
1851
+ timestamptz: "timestamptz";
1852
+ jsonb: "jsonb";
1849
1853
  }>;
1850
1854
  nullable: z.ZodDefault<z.ZodBoolean>;
1851
1855
  }, z.core.$strip>>>;
1852
1856
  executes: z.ZodString;
1853
1857
  returns: z.ZodDefault<z.ZodEnum<{
1854
1858
  rows: "rows";
1855
- rowsAffected: "rowsAffected";
1856
1859
  scalar: "scalar";
1860
+ rowsAffected: "rowsAffected";
1857
1861
  }>>;
1858
1862
  audit: z.ZodOptional<z.ZodObject<{
1859
1863
  action: z.ZodString;
@@ -1909,13 +1913,13 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1909
1913
  bigint: "bigint";
1910
1914
  boolean: "boolean";
1911
1915
  date: "date";
1912
- text: "text";
1913
- timestamptz: "timestamptz";
1914
- jsonb: "jsonb";
1915
1916
  uuid: "uuid";
1917
+ text: "text";
1916
1918
  integer: "integer";
1917
1919
  numeric: "numeric";
1918
1920
  double: "double";
1921
+ timestamptz: "timestamptz";
1922
+ jsonb: "jsonb";
1919
1923
  }>, z.ZodObject<{
1920
1924
  enum: z.ZodString;
1921
1925
  }, z.core.$strip>]>;
@@ -1937,10 +1941,10 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1937
1941
  of: z.ZodString;
1938
1942
  part: z.ZodEnum<{
1939
1943
  at: "at";
1940
- by: "by";
1941
- rev: "rev";
1942
1944
  source: "source";
1945
+ by: "by";
1943
1946
  conflicts: "conflicts";
1947
+ rev: "rev";
1944
1948
  }>;
1945
1949
  }, z.core.$strict>>;
1946
1950
  }, z.core.$strip>>;
@@ -1989,8 +1993,8 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
1989
1993
  sources: z.ZodArray<z.ZodObject<{
1990
1994
  name: z.ZodString;
1991
1995
  kind: z.ZodEnum<{
1992
- manual: "manual";
1993
1996
  prefetch: "prefetch";
1997
+ manual: "manual";
1994
1998
  etl: "etl";
1995
1999
  }>;
1996
2000
  table: z.ZodString;
@@ -2042,6 +2046,7 @@ declare const canonicalDefinitionSchema: z.ZodObject<{
2042
2046
  orderBy: z.ZodOptional<z.ZodString>;
2043
2047
  }, z.core.$strict>>;
2044
2048
  deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
2049
+ existsIn: z.ZodOptional<z.ZodArray<z.ZodString>>;
2045
2050
  materialized: z.ZodOptional<z.ZodObject<{
2046
2051
  table: z.ZodString;
2047
2052
  compute: z.ZodString;
package/dist/canonical.js CHANGED
@@ -252,6 +252,48 @@ var policyExpressionSchema = z.union([
252
252
  variants: z.array(policyVariantSchema).max(10).default([])
253
253
  })
254
254
  ]);
255
+
256
+ // src/canonical/resolved-rows.ts
257
+ function logicalKey(table) {
258
+ return (table.primaryKey ?? []).map((columnName) => table.columns.find((c) => c.columnName === columnName)?.name ?? columnName);
259
+ }
260
+ function sameKey(key, expected) {
261
+ return key.length === expected.length && key.every((name) => expected.includes(name));
262
+ }
263
+ function validateRowIdentity(input) {
264
+ validateExistsIn(input);
265
+ if (input.keys.length > 1) validateCompositeKey(input);
266
+ }
267
+ function validateExistsIn({ resolved, sourceByName, fail }) {
268
+ const name = resolved.existsIn?.[0];
269
+ if (name === void 0) return;
270
+ if (sourceByName.get(name)?.kind !== "etl") fail(`existsIn '${name}' must be an etl source`);
271
+ if (resolved.policies.insert !== void 0 || resolved.policies.write !== void 0) {
272
+ fail("existsIn allows only an update policy: rows come from the etl source");
273
+ }
274
+ }
275
+ function validateCompositeKey({ resolved, keys, tableByName, fail }) {
276
+ const keyList = `(${keys.join(", ")})`;
277
+ if (resolved.existsIn === void 0) {
278
+ fail(`requires exactly one primary-key column: composite key ${keyList} requires existsIn`);
279
+ return;
280
+ }
281
+ const writes = ["insert", "update", "write"].filter((kind) => resolved.policies[kind] !== void 0);
282
+ if (writes.length > 0) fail(`composite key ${keyList} requires a read-only table: remove the ${writes.join("/")} policy`);
283
+ if (resolved.materialized) fail(`composite key ${keyList} cannot be materialized`);
284
+ for (const source of resolved.sources) {
285
+ if (source.kind === "prefetch") {
286
+ fail(`composite key ${keyList} cannot have prefetch source '${source.name}'`);
287
+ continue;
288
+ }
289
+ const table = tableByName.get(source.table);
290
+ if (table && !sameKey(logicalKey(table), keys)) {
291
+ fail(`composite key ${keyList} requires ${source.kind} source '${source.name}' to be keyed by it; table '${source.table}' is keyed by (${logicalKey(table).join(", ")})`);
292
+ }
293
+ }
294
+ }
295
+
296
+ // src/canonical/resolved.ts
255
297
  function parseDurationMs(input) {
256
298
  if (typeof input === "number") return Number.isInteger(input) && input > 0 ? input : void 0;
257
299
  const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(input);
@@ -329,6 +371,13 @@ var canonicalResolvedSchema = z.object({
329
371
  resolve: z.array(canonicalResolveRuleSchema).max(500),
330
372
  /** Sources whose tombstone hides the resolved row (v1: the manual source only). */
331
373
  deletedBy: z.array(identifier).max(1).default([]),
374
+ /**
375
+ * `rows.existsIn`: the one etl source whose rows are the table's rows (read
376
+ * directly as the row source). Only an update policy may write. It is also
377
+ * what admits a composite primary key: a read-only table keyed exactly like
378
+ * that source.
379
+ */
380
+ existsIn: z.array(identifier).length(1).optional(),
332
381
  /**
333
382
  * Materialized: the view reads an indexed internal table (`table`) that the
334
383
  * data plane keeps in step with `compute`, the internal view holding the
@@ -347,8 +396,8 @@ function validateResolvedView({ view, tables, views = [] }) {
347
396
  if (!resolved) return [];
348
397
  const errors = [];
349
398
  const fail = (message) => errors.push(`resolved table '${view.view}': ${message}`);
350
- const pkColumn = view.primaryKey?.length === 1 ? view.columns.find((c) => c.columnName === view.primaryKey?.[0]) : void 0;
351
- if (!pkColumn) {
399
+ const keyColumns = (view.primaryKey ?? []).map((columnName) => view.columns.find((c) => c.columnName === columnName)).filter((column) => column !== void 0);
400
+ if (keyColumns.length === 0 || keyColumns.length !== view.primaryKey?.length) {
352
401
  fail("requires exactly one primary-key column");
353
402
  return errors;
354
403
  }
@@ -356,7 +405,7 @@ function validateResolvedView({ view, tables, views = [] }) {
356
405
  const scope = {
357
406
  view,
358
407
  resolved,
359
- pkColumn,
408
+ keys: new Map(keyColumns.map((column) => [column.name, column])),
360
409
  dataColumns: new Map(view.columns.filter((c) => !systemNames.has(c.name) && c.cell === void 0).map((c) => [c.name, c])),
361
410
  sourceByName: /* @__PURE__ */ new Map(),
362
411
  fail
@@ -370,6 +419,7 @@ function validateResolvedView({ view, tables, views = [] }) {
370
419
  if (!table) fail(`source '${source.name}' references unknown table '${source.table}'`);
371
420
  else validateSource({ scope, source, table });
372
421
  }
422
+ validateRowIdentity({ resolved, keys: [...scope.keys.keys()], sourceByName: scope.sourceByName, tableByName, fail });
373
423
  validateRules(scope);
374
424
  validateViewCells(scope);
375
425
  if (resolved.materialized) validateMaterialized({ scope, tableByName, views });
@@ -399,7 +449,7 @@ function validateSource({ scope, source, table }) {
399
449
  validatePrefetchFields({ scope, source });
400
450
  }
401
451
  function validatePrefetchFields({ scope, source }) {
402
- const { fail, pkColumn } = scope;
452
+ const { fail, keys } = scope;
403
453
  if (source.kind !== "prefetch") {
404
454
  if (source.key || source.fetch || source.function || source.prefetchDefaults || source.writeback) {
405
455
  fail(`only prefetch sources may declare key/fetch/function/prefetchDefaults/writeback ('${source.name}')`);
@@ -408,7 +458,7 @@ function validatePrefetchFields({ scope, source }) {
408
458
  }
409
459
  if (!source.key || !source.fetch || !source.function || !source.prefetchDefaults) {
410
460
  fail(`prefetch source '${source.name}' requires key, fetch, function and prefetchDefaults`);
411
- } else if (source.key !== pkColumn.name && !source.columns.includes(source.key)) {
461
+ } else if (!keys.has(source.key) && !source.columns.includes(source.key)) {
412
462
  fail(`prefetch source '${source.name}' key '${source.key}' must be the primary key or one of its columns`);
413
463
  }
414
464
  for (const column of source.writeback?.columns ?? []) {
@@ -416,19 +466,19 @@ function validatePrefetchFields({ scope, source }) {
416
466
  }
417
467
  }
418
468
  function validateSourceColumns({ scope, source, byName }) {
419
- const { fail, pkColumn, dataColumns } = scope;
420
- for (const column of [pkColumn.name, ...source.columns]) {
421
- const own = column === pkColumn.name ? pkColumn : dataColumns.get(column);
469
+ const { fail, keys, dataColumns } = scope;
470
+ for (const column of [...keys.keys(), ...source.columns]) {
471
+ const own = keys.get(column) ?? dataColumns.get(column);
422
472
  const theirs = byName.get(column);
423
473
  if (!own) fail(`source '${source.name}' supplies unknown column '${column}'`);
424
474
  else if (!theirs) fail(`source '${source.name}' table '${source.table}' has no column '${column}'`);
425
475
  else if (JSON.stringify(theirs.type) !== JSON.stringify(own.type)) fail(`column '${column}' has a different type on source '${source.name}'`);
426
476
  }
427
477
  }
428
- function validateRules({ resolved, pkColumn, dataColumns, sourceByName, fail }) {
478
+ function validateRules({ resolved, keys, dataColumns, sourceByName, fail }) {
429
479
  const ruled = /* @__PURE__ */ new Set();
430
480
  for (const rule of resolved.resolve) {
431
- if (!dataColumns.has(rule.column) || rule.column === pkColumn.name) {
481
+ if (!dataColumns.has(rule.column) || keys.has(rule.column)) {
432
482
  fail(`resolve rule targets unknown column '${rule.column}'`);
433
483
  continue;
434
484
  }
@@ -445,7 +495,7 @@ function validateRules({ resolved, pkColumn, dataColumns, sourceByName, fail })
445
495
  }
446
496
  }
447
497
  for (const column of dataColumns.keys()) {
448
- if (column !== pkColumn.name && !ruled.has(column)) fail(`column '${column}' has no resolve rule`);
498
+ if (!keys.has(column) && !ruled.has(column)) fail(`column '${column}' has no resolve rule`);
449
499
  }
450
500
  }
451
501
  var VIEW_CELL_TYPES = {
@@ -454,10 +504,10 @@ var VIEW_CELL_TYPES = {
454
504
  by: "text",
455
505
  conflicts: "jsonb"
456
506
  };
457
- function validateViewCells({ view, dataColumns, pkColumn, fail }) {
507
+ function validateViewCells({ view, dataColumns, keys, fail }) {
458
508
  const expected = /* @__PURE__ */ new Map();
459
509
  for (const column of dataColumns.values()) {
460
- if (column.name === pkColumn.name) continue;
510
+ if (keys.has(column.name)) continue;
461
511
  for (const part of RESOLVED_VIEW_CELL_PARTS) {
462
512
  expected.set(cellColumnName(column.name, part), { part, columnName: cellColumnName(column.columnName, part) });
463
513
  }