@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
package/dist/index.js CHANGED
@@ -203,6 +203,8 @@ function materializedRefreshFunctionName(table) {
203
203
  function materializeLockKey(schema, table) {
204
204
  return `orm:materialize:${schema}.${table}`;
205
205
  }
206
+ var OPERATION_DOCUMENTS_FILE = "operations.documents.json";
207
+ var OPERATION_DOCUMENTS_VERSION = 1;
206
208
 
207
209
  // src/errors.ts
208
210
  var OrmDefinitionError = class extends Error {
@@ -1187,6 +1189,48 @@ var policyExpressionSchema = z.union([
1187
1189
  variants: z.array(policyVariantSchema).max(10).default([])
1188
1190
  })
1189
1191
  ]);
1192
+
1193
+ // src/canonical/resolved-rows.ts
1194
+ function logicalKey(table) {
1195
+ return (table.primaryKey ?? []).map((columnName) => table.columns.find((c) => c.columnName === columnName)?.name ?? columnName);
1196
+ }
1197
+ function sameKey(key, expected) {
1198
+ return key.length === expected.length && key.every((name2) => expected.includes(name2));
1199
+ }
1200
+ function validateRowIdentity(input) {
1201
+ validateExistsIn(input);
1202
+ if (input.keys.length > 1) validateCompositeKey(input);
1203
+ }
1204
+ function validateExistsIn({ resolved, sourceByName, fail: fail3 }) {
1205
+ const name2 = resolved.existsIn?.[0];
1206
+ if (name2 === void 0) return;
1207
+ if (sourceByName.get(name2)?.kind !== "etl") fail3(`existsIn '${name2}' must be an etl source`);
1208
+ if (resolved.policies.insert !== void 0 || resolved.policies.write !== void 0) {
1209
+ fail3("existsIn allows only an update policy: rows come from the etl source");
1210
+ }
1211
+ }
1212
+ function validateCompositeKey({ resolved, keys, tableByName, fail: fail3 }) {
1213
+ const keyList = `(${keys.join(", ")})`;
1214
+ if (resolved.existsIn === void 0) {
1215
+ fail3(`requires exactly one primary-key column: composite key ${keyList} requires existsIn`);
1216
+ return;
1217
+ }
1218
+ const writes = ["insert", "update", "write"].filter((kind) => resolved.policies[kind] !== void 0);
1219
+ if (writes.length > 0) fail3(`composite key ${keyList} requires a read-only table: remove the ${writes.join("/")} policy`);
1220
+ if (resolved.materialized) fail3(`composite key ${keyList} cannot be materialized`);
1221
+ for (const source of resolved.sources) {
1222
+ if (source.kind === "prefetch") {
1223
+ fail3(`composite key ${keyList} cannot have prefetch source '${source.name}'`);
1224
+ continue;
1225
+ }
1226
+ const table = tableByName.get(source.table);
1227
+ if (table && !sameKey(logicalKey(table), keys)) {
1228
+ fail3(`composite key ${keyList} requires ${source.kind} source '${source.name}' to be keyed by it; table '${source.table}' is keyed by (${logicalKey(table).join(", ")})`);
1229
+ }
1230
+ }
1231
+ }
1232
+
1233
+ // src/canonical/resolved.ts
1190
1234
  function parseDurationMs(input) {
1191
1235
  if (typeof input === "number") return Number.isInteger(input) && input > 0 ? input : void 0;
1192
1236
  const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(input);
@@ -1263,6 +1307,13 @@ var canonicalResolvedSchema = z.object({
1263
1307
  resolve: z.array(canonicalResolveRuleSchema).max(500),
1264
1308
  /** Sources whose tombstone hides the resolved row (v1: the manual source only). */
1265
1309
  deletedBy: z.array(identifier).max(1).default([]),
1310
+ /**
1311
+ * `rows.existsIn`: the one etl source whose rows are the table's rows (read
1312
+ * directly as the row source). Only an update policy may write. It is also
1313
+ * what admits a composite primary key: a read-only table keyed exactly like
1314
+ * that source.
1315
+ */
1316
+ existsIn: z.array(identifier).length(1).optional(),
1266
1317
  /**
1267
1318
  * Materialized: the view reads an indexed internal table (`table`) that the
1268
1319
  * data plane keeps in step with `compute`, the internal view holding the
@@ -1281,8 +1332,8 @@ function validateResolvedView({ view, tables, views = [] }) {
1281
1332
  if (!resolved) return [];
1282
1333
  const errors = [];
1283
1334
  const fail3 = (message) => errors.push(`resolved table '${view.view}': ${message}`);
1284
- const pkColumn = view.primaryKey?.length === 1 ? view.columns.find((c) => c.columnName === view.primaryKey?.[0]) : void 0;
1285
- if (!pkColumn) {
1335
+ const keyColumns = (view.primaryKey ?? []).map((columnName) => view.columns.find((c) => c.columnName === columnName)).filter((column) => column !== void 0);
1336
+ if (keyColumns.length === 0 || keyColumns.length !== view.primaryKey?.length) {
1286
1337
  fail3("requires exactly one primary-key column");
1287
1338
  return errors;
1288
1339
  }
@@ -1290,7 +1341,7 @@ function validateResolvedView({ view, tables, views = [] }) {
1290
1341
  const scope = {
1291
1342
  view,
1292
1343
  resolved,
1293
- pkColumn,
1344
+ keys: new Map(keyColumns.map((column) => [column.name, column])),
1294
1345
  dataColumns: new Map(view.columns.filter((c) => !systemNames.has(c.name) && c.cell === void 0).map((c) => [c.name, c])),
1295
1346
  sourceByName: /* @__PURE__ */ new Map(),
1296
1347
  fail: fail3
@@ -1304,6 +1355,7 @@ function validateResolvedView({ view, tables, views = [] }) {
1304
1355
  if (!table) fail3(`source '${source.name}' references unknown table '${source.table}'`);
1305
1356
  else validateSource({ scope, source, table });
1306
1357
  }
1358
+ validateRowIdentity({ resolved, keys: [...scope.keys.keys()], sourceByName: scope.sourceByName, tableByName, fail: fail3 });
1307
1359
  validateRules(scope);
1308
1360
  validateViewCells(scope);
1309
1361
  if (resolved.materialized) validateMaterialized({ scope, tableByName, views });
@@ -1333,7 +1385,7 @@ function validateSource({ scope, source, table }) {
1333
1385
  validatePrefetchFields({ scope, source });
1334
1386
  }
1335
1387
  function validatePrefetchFields({ scope, source }) {
1336
- const { fail: fail3, pkColumn } = scope;
1388
+ const { fail: fail3, keys } = scope;
1337
1389
  if (source.kind !== "prefetch") {
1338
1390
  if (source.key || source.fetch || source.function || source.prefetchDefaults || source.writeback) {
1339
1391
  fail3(`only prefetch sources may declare key/fetch/function/prefetchDefaults/writeback ('${source.name}')`);
@@ -1342,7 +1394,7 @@ function validatePrefetchFields({ scope, source }) {
1342
1394
  }
1343
1395
  if (!source.key || !source.fetch || !source.function || !source.prefetchDefaults) {
1344
1396
  fail3(`prefetch source '${source.name}' requires key, fetch, function and prefetchDefaults`);
1345
- } else if (source.key !== pkColumn.name && !source.columns.includes(source.key)) {
1397
+ } else if (!keys.has(source.key) && !source.columns.includes(source.key)) {
1346
1398
  fail3(`prefetch source '${source.name}' key '${source.key}' must be the primary key or one of its columns`);
1347
1399
  }
1348
1400
  for (const column of source.writeback?.columns ?? []) {
@@ -1350,19 +1402,19 @@ function validatePrefetchFields({ scope, source }) {
1350
1402
  }
1351
1403
  }
1352
1404
  function validateSourceColumns({ scope, source, byName }) {
1353
- const { fail: fail3, pkColumn, dataColumns } = scope;
1354
- for (const column of [pkColumn.name, ...source.columns]) {
1355
- const own = column === pkColumn.name ? pkColumn : dataColumns.get(column);
1405
+ const { fail: fail3, keys, dataColumns } = scope;
1406
+ for (const column of [...keys.keys(), ...source.columns]) {
1407
+ const own = keys.get(column) ?? dataColumns.get(column);
1356
1408
  const theirs = byName.get(column);
1357
1409
  if (!own) fail3(`source '${source.name}' supplies unknown column '${column}'`);
1358
1410
  else if (!theirs) fail3(`source '${source.name}' table '${source.table}' has no column '${column}'`);
1359
1411
  else if (JSON.stringify(theirs.type) !== JSON.stringify(own.type)) fail3(`column '${column}' has a different type on source '${source.name}'`);
1360
1412
  }
1361
1413
  }
1362
- function validateRules({ resolved, pkColumn, dataColumns, sourceByName, fail: fail3 }) {
1414
+ function validateRules({ resolved, keys, dataColumns, sourceByName, fail: fail3 }) {
1363
1415
  const ruled = /* @__PURE__ */ new Set();
1364
1416
  for (const rule of resolved.resolve) {
1365
- if (!dataColumns.has(rule.column) || rule.column === pkColumn.name) {
1417
+ if (!dataColumns.has(rule.column) || keys.has(rule.column)) {
1366
1418
  fail3(`resolve rule targets unknown column '${rule.column}'`);
1367
1419
  continue;
1368
1420
  }
@@ -1379,7 +1431,7 @@ function validateRules({ resolved, pkColumn, dataColumns, sourceByName, fail: fa
1379
1431
  }
1380
1432
  }
1381
1433
  for (const column of dataColumns.keys()) {
1382
- if (column !== pkColumn.name && !ruled.has(column)) fail3(`column '${column}' has no resolve rule`);
1434
+ if (!keys.has(column) && !ruled.has(column)) fail3(`column '${column}' has no resolve rule`);
1383
1435
  }
1384
1436
  }
1385
1437
  var VIEW_CELL_TYPES = {
@@ -1388,10 +1440,10 @@ var VIEW_CELL_TYPES = {
1388
1440
  by: "text",
1389
1441
  conflicts: "jsonb"
1390
1442
  };
1391
- function validateViewCells({ view, dataColumns, pkColumn, fail: fail3 }) {
1443
+ function validateViewCells({ view, dataColumns, keys, fail: fail3 }) {
1392
1444
  const expected = /* @__PURE__ */ new Map();
1393
1445
  for (const column of dataColumns.values()) {
1394
- if (column.name === pkColumn.name) continue;
1446
+ if (keys.has(column.name)) continue;
1395
1447
  for (const part of RESOLVED_VIEW_CELL_PARTS) {
1396
1448
  expected.set(cellColumnName(column.name, part), { part, columnName: cellColumnName(column.columnName, part) });
1397
1449
  }
@@ -2264,8 +2316,9 @@ function planSource(input) {
2264
2316
  }
2265
2317
  var tombstoned = () => t.boolean(RESOLVED_SOURCE_SYSTEM_COLUMNS.tombstoned.columnName).notNull().default(false);
2266
2318
  function internalTable(input, supplied, system, options = {}) {
2267
- const { viewName, sourceName, columns, pk, pkBuilder } = input;
2268
- const tableColumns = { [pk]: cloneColumn({ builder: pkBuilder, property: pk, notNull: true, primaryKey: true }) };
2319
+ const { viewName, sourceName, columns, keys } = input;
2320
+ const tableColumns = {};
2321
+ for (const key of keys) tableColumns[key] = cloneColumn({ builder: columns[key], property: key, notNull: true, primaryKey: true });
2269
2322
  for (const property of supplied) {
2270
2323
  tableColumns[property] = cloneColumn({ builder: columns[property], property, notNull: false, primaryKey: false });
2271
2324
  }
@@ -2282,12 +2335,14 @@ function assertColumns(input, list2, what) {
2282
2335
  for (const column of list2) if (!input.dataColumns.includes(column)) input.fail(`${what} names unknown column "${column}"`);
2283
2336
  }
2284
2337
  function planEtl(input, source) {
2285
- const { sourceName, pk, dataColumns, fail: fail3 } = input;
2338
+ const { sourceName, keys, dataColumns, fail: fail3 } = input;
2286
2339
  const table = typeof source.table === "function" ? source.table() : source.table;
2287
2340
  if (!isSeqTable(table) || table.source === void 0) fail3(`etl source "${sourceName}" must reference a defineSyncedTable`);
2288
2341
  const synced = table;
2289
2342
  if (synced.config.primaryKey?.length === 0) fail3(`etl source "${sourceName}" cannot use an unkeyed synced table for resolved row identity`);
2290
- if (!(pk in synced.columns)) fail3(`etl source "${sourceName}" table "${synced.tableName}" has no "${pk}" column`);
2343
+ for (const key of keys) {
2344
+ if (!(key in synced.columns)) fail3(`etl source "${sourceName}" table "${synced.tableName}" has no "${key}" column`);
2345
+ }
2291
2346
  const supplied = source.columns ? [...source.columns] : dataColumns.filter((column) => column in synced.columns);
2292
2347
  assertColumns(input, supplied, `etl source "${sourceName}"`);
2293
2348
  if (source.updatedAt !== void 0 && !(source.updatedAt in synced.columns)) {
@@ -2296,9 +2351,9 @@ function planEtl(input, source) {
2296
2351
  return { name: sourceName, kind: "etl", table: synced, columns: supplied, ...source.updatedAt ? { updatedAt: source.updatedAt } : {} };
2297
2352
  }
2298
2353
  function planPrefetch(input, source) {
2299
- const { sourceName, pk, fail: fail3 } = input;
2354
+ const { sourceName, keys, fail: fail3 } = input;
2300
2355
  assertColumns(input, source.columns, `prefetch source "${sourceName}"`);
2301
- if (source.key !== pk && !source.columns.includes(source.key)) {
2356
+ if (!keys.includes(source.key) && !source.columns.includes(source.key)) {
2302
2357
  fail3(`prefetch source "${sourceName}" key "${source.key}" must be the primary key or one of its columns`);
2303
2358
  }
2304
2359
  for (const column of source.writeback?.columns ?? []) {
@@ -2351,7 +2406,7 @@ var PG_TYPE = {
2351
2406
  var ident = (value) => `"${value.replace(/"/g, '""')}"`;
2352
2407
  var literal = (value) => `'${value.replace(/'/g, "''")}'`;
2353
2408
  var physical = ({ source, property }) => source.table.columns[property].columnNameFor(property);
2354
- function candidateSql({ source, column, pk, pgType }) {
2409
+ function candidateSql({ source, column, key, pgType }) {
2355
2410
  const a = ident(`s_${source.name}`);
2356
2411
  const name2 = physical({ source, property: column });
2357
2412
  const value = `CAST(${a}.${ident(name2)} AS ${pgType})`;
@@ -2359,7 +2414,7 @@ function candidateSql({ source, column, pk, pgType }) {
2359
2414
  return {
2360
2415
  source: source.name,
2361
2416
  value,
2362
- has: `(${a}.${ident(physical({ source, property: pk }))} IS NOT NULL)`,
2417
+ has: `(${a}.${ident(physical({ source, property: key }))} IS NOT NULL)`,
2363
2418
  at: source.updatedAt ? `CAST(${a}.${ident(physical({ source, property: source.updatedAt }))} AS timestamptz)` : "CAST(NULL AS timestamptz)",
2364
2419
  by: "CAST(NULL AS text)"
2365
2420
  };
@@ -2447,39 +2502,44 @@ function customCell({ candidates, orderBy, index: index3 }) {
2447
2502
  }
2448
2503
  function buildResolvedQuery({ context, plan }) {
2449
2504
  const { qb, relation } = context;
2450
- const pkColumn = plan.columns[plan.pk].columnNameFor(plan.pk);
2505
+ const keyColumns = plan.keys.map((key) => plan.columns[key].columnNameFor(key));
2451
2506
  const alias = (source) => ident(`s_${source}`);
2452
2507
  const tombstoned2 = RESOLVED_SOURCE_SYSTEM_COLUMNS.tombstoned.columnName;
2453
2508
  const sourceByName = new Map(plan.plans.map((source) => [source.name, source]));
2454
2509
  const schema = getTableConfig(relation(plan.plans[0].table)).schema;
2455
2510
  const keySource = plan.existsIn === void 0 ? void 0 : sourceByName.get(plan.existsIn);
2456
- const keyRef = keySource ? `${alias(keySource.name)}.${ident(physical({ source: keySource, property: plan.pk }))}` : `"k".${ident(pkColumn)}`;
2511
+ const keyRefs = plan.keys.map((key, index3) => keySource ? `${alias(keySource.name)}.${ident(physical({ source: keySource, property: key }))}` : `"k".${ident(keyColumns[index3])}`);
2457
2512
  const keyBranches = plan.plans.map((source) => {
2458
2513
  const where = source.kind === "prefetch" ? sql.raw(` WHERE NOT ${ident(tombstoned2)}`) : sql.raw("");
2459
- const sourcePk = ident(physical({ source, property: plan.pk }));
2460
- const selectedPk = sourcePk === ident(pkColumn) ? sourcePk : `${sourcePk} AS ${ident(pkColumn)}`;
2461
- return sql`SELECT ${sql.raw(selectedPk)} FROM ${relation(source.table)}${where}`;
2514
+ const selectedKey = plan.keys.map((key, index3) => {
2515
+ const sourceKey = ident(physical({ source, property: key }));
2516
+ return sourceKey === ident(keyColumns[index3]) ? sourceKey : `${sourceKey} AS ${ident(keyColumns[index3])}`;
2517
+ });
2518
+ return sql`SELECT ${sql.raw(selectedKey.join(", "))} FROM ${relation(source.table)}${where}`;
2462
2519
  });
2463
2520
  const base2 = keySource ? sql`${relation(keySource.table)} AS ${sql.raw(alias(keySource.name))}` : sql`(${sql.join(keyBranches, sql.raw(" UNION "))}) AS "k"`;
2464
- const joins = plan.plans.filter((source) => source !== keySource).map(
2465
- (source) => sql` LEFT JOIN ${relation(source.table)} AS ${sql.raw(alias(source.name))} ON ${sql.raw(`${alias(source.name)}.${ident(physical({ source, property: plan.pk }))} = ${keyRef}`)}`
2466
- );
2521
+ const joins = plan.plans.filter((source) => source !== keySource).map((source) => {
2522
+ const on = plan.keys.map((key, index3) => `${alias(source.name)}.${ident(physical({ source, property: key }))} = ${keyRefs[index3]}`);
2523
+ return sql` LEFT JOIN ${relation(source.table)} AS ${sql.raw(alias(source.name))} ON ${sql.raw(on.join(" AND "))}`;
2524
+ });
2467
2525
  const cells = /* @__PURE__ */ new Map();
2468
2526
  plan.rules.forEach((rule, index3) => {
2469
2527
  const canonical = plan.columns[rule.column].toCanonicalColumn(rule.column);
2470
2528
  const pgType = typeof canonical.type === "string" ? PG_TYPE[canonical.type] : `${schema === void 0 ? "" : `${ident(schema)}.`}${ident(canonical.type.enum)}`;
2471
- const candidates = rule.candidates.map((name2) => candidateSql({ source: sourceByName.get(name2), column: rule.column, pk: plan.pk, pgType }));
2529
+ const candidates = rule.candidates.map((name2) => candidateSql({ source: sourceByName.get(name2), column: rule.column, key: plan.keys[0], pgType }));
2472
2530
  cells.set(rule.column, keySource && rule.candidates.length === 1 && rule.candidates[0] === keySource.name ? existsInCell(candidates[0]) : rule.comparator === "custom" ? customCell({ candidates, orderBy: rule.orderBy, index: index3 }) : builtinCell({ comparator: rule.comparator, candidates }));
2473
2531
  });
2474
2532
  const laterals = [...cells.values()].flatMap((cell) => cell.lateral ? [sql.raw(cell.lateral)] : []);
2475
2533
  const from = sql.join([base2, ...joins, ...laterals], sql.raw(""));
2476
- const selected = {
2477
- [plan.pk]: sql.raw(keyRef).as(pkColumn)
2478
- };
2534
+ const selected = {};
2479
2535
  for (const [property, builder] of Object.entries(plan.columns)) {
2480
- if (property === plan.pk) continue;
2481
- const cell = cells.get(property);
2482
2536
  const columnName = builder.columnNameFor(property);
2537
+ const keyIndex = plan.keys.indexOf(property);
2538
+ if (keyIndex !== -1) {
2539
+ selected[property] = sql.raw(keyRefs[keyIndex]).as(columnName);
2540
+ continue;
2541
+ }
2542
+ const cell = cells.get(property);
2483
2543
  selected[property] = sql.raw(cell.value).as(columnName);
2484
2544
  for (const [part, expression] of Object.entries(cell.parts)) {
2485
2545
  selected[cellColumnName(property, part)] = sql.raw(expression).as(cellColumnName(columnName, part));
@@ -2493,6 +2553,44 @@ function buildResolvedQuery({ context, plan }) {
2493
2553
  const query = qb.select(selected).from(from);
2494
2554
  return hidden.length > 0 ? query.where(sql.raw(hidden.join(" AND "))) : query;
2495
2555
  }
2556
+
2557
+ // src/authoring/resolved-rows.ts
2558
+ function planKeys({ columns, config, fail: fail3 }) {
2559
+ const keys = Object.entries(columns).filter(([, builder]) => builder.isPrimaryKey).map(([property]) => property);
2560
+ if (keys.length === 0) fail3("declare exactly one .primaryKey() column");
2561
+ if (keys.length === 1) return keys;
2562
+ const key = `(${keys.join(", ")})`;
2563
+ if (config.rows?.existsIn === void 0) fail3(`declare exactly one .primaryKey() column: composite key ${key} requires rows.existsIn`);
2564
+ const writes = ["insert", "update", "write"].filter((kind) => config.policies[kind] !== void 0);
2565
+ if (writes.length > 0) fail3(`composite key ${key} requires a read-only table: remove the ${writes.join("/")} policy`);
2566
+ if (config.materialize) fail3(`composite key ${key} cannot be materialized`);
2567
+ const prefetch = Object.entries(config.sources).find(([, source]) => source.kind === "prefetch");
2568
+ if (prefetch) fail3(`composite key ${key} cannot have prefetch source "${prefetch[0]}"`);
2569
+ return keys;
2570
+ }
2571
+ function assertCompositeSourceKeys({ keys, plans, fail: fail3 }) {
2572
+ if (keys.length === 1) return;
2573
+ for (const plan of plans) {
2574
+ if (plan.kind !== "etl") continue;
2575
+ const sourceKey = declaredPrimaryKeyProperties(plan.table);
2576
+ if (sourceKey.length !== keys.length || !keys.every((key) => sourceKey.includes(key))) {
2577
+ fail3(`composite key (${keys.join(", ")}) requires etl source "${plan.name}" to be keyed by it; table "${plan.table.tableName}" is keyed by (${sourceKey.join(", ")})`);
2578
+ }
2579
+ }
2580
+ }
2581
+ function planExistsIn({ config, plans, fail: fail3 }) {
2582
+ const names = config.rows?.existsIn;
2583
+ if (names === void 0) return void 0;
2584
+ if (names.length !== 1) fail3("rows.existsIn names exactly one etl source");
2585
+ const source = plans.find((plan) => plan.name === names[0]);
2586
+ if (source?.kind !== "etl") return fail3(`rows.existsIn "${names[0]}" must be an etl source`);
2587
+ if (config.policies.insert !== void 0 || config.policies.write !== void 0) fail3("rows.existsIn allows only an update policy: rows come from the etl source");
2588
+ return source;
2589
+ }
2590
+ function inheritedNotNullColumns({ existsIn, rules }) {
2591
+ if (!existsIn) return /* @__PURE__ */ new Set();
2592
+ return new Set(rules.filter((rule) => rule.candidates.length === 1 && rule.candidates[0] === existsIn.name).map((rule) => rule.column).filter((column) => existsIn.table.columns[column]?.toCanonicalColumn(column).nullable === false));
2593
+ }
2496
2594
  function managedFn(id) {
2497
2595
  return { kind: "managed", id };
2498
2596
  }
@@ -2531,28 +2629,28 @@ function defineResolvedTable(name2, columns, config) {
2531
2629
  fail3(`column "${property}" is too long for a resolved table (max ${MAX_TRACKED_COLUMN_NAME} characters, room for cell parts)`);
2532
2630
  }
2533
2631
  }
2534
- const pkEntries = Object.entries(columns).filter(([, builder]) => builder.isPrimaryKey);
2535
- if (pkEntries.length !== 1) fail3("declare exactly one .primaryKey() column");
2536
- const [pk, pkBuilder] = pkEntries[0];
2537
- const dataColumns = Object.keys(columns).filter((property) => property !== pk);
2632
+ const keys = planKeys({ columns, config, fail: fail3 });
2633
+ const dataColumns = Object.keys(columns).filter((property) => !keys.includes(property));
2538
2634
  if (dataColumns.length === 0) fail3("declare at least one non-key column");
2539
2635
  const sourceEntries = Object.entries(config.sources);
2540
2636
  if (sourceEntries.filter(([, source]) => source.kind === "manual").length !== 1) fail3("declare exactly one manualSource()");
2541
2637
  const plans = sourceEntries.map(
2542
- ([sourceName, input]) => planSource({ viewName: name2, sourceName, input, columns, pk, pkBuilder, dataColumns, fail: fail3 })
2638
+ ([sourceName, input]) => planSource({ viewName: name2, sourceName, input, columns, keys, dataColumns, fail: fail3 })
2543
2639
  );
2544
2640
  const rules = planRules({ config, plans, dataColumns, fail: fail3 });
2545
2641
  const deletedBy = [...config.rows?.deletedBy ?? []];
2546
2642
  for (const source of deletedBy) {
2547
2643
  if (plans.find((plan) => plan.name === source)?.kind !== "manual") fail3(`rows.deletedBy "${source}" must be the manual source`);
2548
2644
  }
2645
+ assertCompositeSourceKeys({ keys, plans, fail: fail3 });
2549
2646
  const existsIn = planExistsIn({ config, plans, fail: fail3 });
2550
- const notNullColumns = existsIn ? inheritedNotNullColumns({ existsIn, rules }) : /* @__PURE__ */ new Set();
2647
+ const notNullColumns = inheritedNotNullColumns({ existsIn, rules });
2551
2648
  const partType = { source: t.text, at: t.timestamptz, by: t.text, conflicts: t.jsonb };
2552
2649
  const viewColumns = {};
2553
2650
  for (const [property, builder] of Object.entries(columns)) {
2554
- viewColumns[property] = cloneColumn({ builder, property, notNull: property === pk || notNullColumns.has(property), primaryKey: property === pk });
2555
- if (property === pk) continue;
2651
+ const isKey = keys.includes(property);
2652
+ viewColumns[property] = cloneColumn({ builder, property, notNull: isKey || notNullColumns.has(property), primaryKey: isKey });
2653
+ if (isKey) continue;
2556
2654
  const columnName = builder.columnNameFor(property);
2557
2655
  for (const part of RESOLVED_VIEW_CELL_PARTS) {
2558
2656
  viewColumns[cellColumnName(property, part)] = partType[part](cellColumnName(columnName, part)).cellPart(property, part);
@@ -2565,9 +2663,10 @@ function defineResolvedTable(name2, columns, config) {
2565
2663
  sources: plans,
2566
2664
  rules,
2567
2665
  deletedBy,
2666
+ ...existsIn ? { existsIn: [existsIn.name] } : {},
2568
2667
  policies: writePolicies
2569
2668
  };
2570
- const queryPlan = { columns, pk, plans, rules, deletedBy, ...existsIn ? { existsIn: existsIn.name } : {} };
2669
+ const queryPlan = { columns, keys, plans, rules, deletedBy, ...existsIn ? { existsIn: existsIn.name } : {} };
2571
2670
  const typedColumns = viewColumns;
2572
2671
  const surface = {
2573
2672
  ...config.description !== void 0 ? { description: config.description } : {},
@@ -2609,18 +2708,6 @@ function defineResolvedTable(name2, columns, config) {
2609
2708
  }
2610
2709
  });
2611
2710
  }
2612
- function planExistsIn({ config, plans, fail: fail3 }) {
2613
- const names = config.rows?.existsIn;
2614
- if (names === void 0) return void 0;
2615
- if (names.length !== 1) fail3("rows.existsIn names exactly one etl source");
2616
- const source = plans.find((plan) => plan.name === names[0]);
2617
- if (source?.kind !== "etl") fail3(`rows.existsIn "${names[0]}" must be an etl source`);
2618
- if (config.policies.insert !== void 0 || config.policies.write !== void 0) fail3("rows.existsIn allows only an update policy: rows come from the etl source");
2619
- return source;
2620
- }
2621
- function inheritedNotNullColumns({ existsIn, rules }) {
2622
- return new Set(rules.filter((rule) => rule.candidates.length === 1 && rule.candidates[0] === existsIn.name).map((rule) => rule.column).filter((column) => existsIn.table.columns[column]?.toCanonicalColumn(column).nullable === false));
2623
- }
2624
2711
  function planRules({ config, plans, dataColumns, fail: fail3 }) {
2625
2712
  const kindOrder = { manual: 0, prefetch: 1, etl: 2 };
2626
2713
  const fallback = config.default ?? priority([...plans].sort((a, b) => kindOrder[a.kind] - kindOrder[b.kind]).map((plan) => plan.name));
@@ -3220,6 +3307,7 @@ function buildCanonicalResolved(resolved) {
3220
3307
  })),
3221
3308
  resolve: resolved.rules.map((rule) => ({ ...rule, candidates: [...rule.candidates] })),
3222
3309
  deletedBy: [...resolved.deletedBy],
3310
+ ...resolved.existsIn !== void 0 ? { existsIn: [...resolved.existsIn] } : {},
3223
3311
  ...resolved.materialized ? { materialized: { ...resolved.materialized } } : {},
3224
3312
  policies
3225
3313
  };
@@ -7145,8 +7233,13 @@ var resolvedSourceIrSchema = z.object({
7145
7233
  }).optional()
7146
7234
  });
7147
7235
  var resolvedMetaIrSchema = z.object({
7148
- /** Logical pk column of the resolved view (single-column). */
7149
- pk: z.string(),
7236
+ /**
7237
+ * Logical pk column of the resolved view. Absent for a composite key, which
7238
+ * only a read-only `existsIn` table may declare: it has no writes, prefetch
7239
+ * or materialization (the paths that address one key column), and its reads
7240
+ * use the view's `primaryKey` like any keyed view.
7241
+ */
7242
+ pk: z.string().optional(),
7150
7243
  /** Source name of the manual source. */
7151
7244
  manual: z.string(),
7152
7245
  sources: z.array(resolvedSourceIrSchema),
@@ -7541,6 +7634,42 @@ async function readSnapshot(dir, ordinal) {
7541
7634
  const path = join(dir, MIGRATIONS_DIRNAME, META_DIRNAME, `${pad(ordinal)}.snapshot.json`);
7542
7635
  return parseJson(path, await readSnapshotText(dir, ordinal));
7543
7636
  }
7637
+ async function verifyCommittedLedger(dir, entries) {
7638
+ const firstRequiredSnapshot = entries.length - 2;
7639
+ let previousId3;
7640
+ let previousSnapshotPresent = false;
7641
+ let previousHash = null;
7642
+ for (const [index3, entry] of entries.entries()) {
7643
+ const sql7 = await readMigrationSql(dir, entry);
7644
+ if (checksumOf(sql7) !== entry.checksum) {
7645
+ return `${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`;
7646
+ }
7647
+ const snapshotText = index3 >= firstRequiredSnapshot ? await readSnapshotText(dir, entry.ordinal) : await readPrunableSnapshotText(dir, entry.ordinal);
7648
+ if (snapshotText !== void 0) {
7649
+ if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
7650
+ return `the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`;
7651
+ }
7652
+ const snapshot = JSON.parse(snapshotText);
7653
+ if (previousSnapshotPresent && snapshot.prevId !== previousId3) {
7654
+ return `snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``;
7655
+ }
7656
+ previousId3 = snapshot.id;
7657
+ }
7658
+ previousSnapshotPresent = snapshotText !== void 0;
7659
+ if (entry.previous_content_hash !== previousHash) {
7660
+ return `content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``;
7661
+ }
7662
+ previousHash = entry.content_hash;
7663
+ }
7664
+ return void 0;
7665
+ }
7666
+ async function readPrunableSnapshotText(dir, ordinal) {
7667
+ const path = join(dir, MIGRATIONS_DIRNAME, META_DIRNAME, `${pad(ordinal)}.snapshot.json`);
7668
+ return readFile(path, "utf8").catch((error) => {
7669
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
7670
+ throw error;
7671
+ });
7672
+ }
7544
7673
  async function readMigrationSql(dir, entry) {
7545
7674
  const path = join(dir, MIGRATIONS_DIRNAME, `${entry.name}.sql`);
7546
7675
  return readFile(path, "utf8").catch(() => {
@@ -7701,30 +7830,10 @@ async function checkWorkspace({
7701
7830
  log(`no committed migrations for '${loaded.definition.namespace}' \u2014 run \`seq-studio orm diff\` and commit the result`);
7702
7831
  return 1;
7703
7832
  }
7704
- let previousId3;
7705
- let previousHash = null;
7706
- for (const entry of workspace.journal.entries) {
7707
- const sql7 = await readMigrationSql(dir, entry);
7708
- if (checksumOf(sql7) !== entry.checksum) {
7709
- log(`${MIGRATIONS_DIRNAME}/${entry.name}.sql does not match its journal checksum \u2014 committed migrations must not be edited`);
7710
- return 1;
7711
- }
7712
- const snapshotText = await readSnapshotText(dir, entry.ordinal);
7713
- if (checksumOf(snapshotText) !== entry.snapshot_checksum) {
7714
- log(`the snapshot for ${entry.name} does not match its journal checksum \u2014 committed snapshots must not be edited (the next diff builds on it)`);
7715
- return 1;
7716
- }
7717
- const snapshot = JSON.parse(snapshotText);
7718
- if (entry.ordinal > 1 && snapshot.prevId !== previousId3) {
7719
- log(`snapshot chain broken at ${entry.name} \u2014 regenerate the workspace with \`seq-studio orm diff\``);
7720
- return 1;
7721
- }
7722
- if (entry.previous_content_hash !== previousHash) {
7723
- log(`content-hash chain broken at ${entry.name} \u2014 migrations must be appended in order by \`seq-studio orm diff\``);
7724
- return 1;
7725
- }
7726
- previousId3 = snapshot.id;
7727
- previousHash = entry.content_hash;
7833
+ const broken = await verifyCommittedLedger(dir, workspace.journal.entries);
7834
+ if (broken) {
7835
+ log(broken);
7836
+ return 1;
7728
7837
  }
7729
7838
  if (tip.content_hash !== loaded.contentHash) {
7730
7839
  log(`definitions changed since ${tip.name} \u2014 run \`seq-studio orm diff\` and commit the new migration`);
@@ -8481,6 +8590,6 @@ function resumeArguments({
8481
8590
  return [literal2.sql];
8482
8591
  }
8483
8592
 
8484
- export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, CANONICAL_FORMAT, CAPABILITIES_CLAIM_KEY, CAPABILITY_KEY_PATTERN, CELLS_FIELD, CELL_PARTS, CELL_PART_SUFFIX, CLAIMS_CONTRACT, CLAIMS_SETTING, CLAIM_KEY_PATTERN, CMP_OPS, COLUMN_BRAND, COLUMN_DEFAULT_FNS, COLUMN_IDENTIFIER_PATTERN, COLUMN_TYPES2 as COLUMN_TYPES, COMPARE_OPS, COMPOSED_IR_VERSION, CONSUMER_ROLE_SUFFIX, ColumnBuilder, DATE_BUCKETS, DEFINITION_FILE_EXTENSIONS, ENUM_BRAND, EXTERNAL_POLICY_CLAIM_KEYS, GUARDED_IR_VERSION, HASH_DOMAIN, IDENTIFIER_PATTERN, IDENTIFIER_RE, IMPORT_CONFLICT_MODES, INPUT_REF_KINDS, IR_VERSION, IrVersionError, LEGACY_IR_VERSION, LINK_BRAND, MATERIALIZE_ACTOR, MATERIALIZE_CLAIMS_JSON, MAX_DEFINITION_FILE_BYTES, MAX_GENERATED_SDL_BYTES, MAX_IDENTIFIER_LENGTH, MAX_PERSISTED_READ_ROWS, MAX_TRACKED_COLUMN_NAME, MIGRATIONS_DIRNAME, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NAMESPACE_CONFIG_FILENAMES, NAMESPACE_PATTERN, ORM_DATA_TOKEN_HEADER, ORM_MIGRATION_EXPORT_FILE, ORM_MIGRATION_EXPORT_MAX_BYTES, ORM_REGISTRATION_MAX_BYTES, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, ORM_TO_PIPELINE_TYPE, OrmDefinitionError, PredicateParseError, QUALIFIED_TABLE_PATTERN, RESERVED_COLUMN_NAMES, RESERVED_TABLE_NAMES, ROLES_CLAIM_KEY, RUNTIME_SQL_IR_VERSION, SCHEMA_DIR, SERVICE_PRINCIPAL_IR_VERSION, SQL_IR_VERSION, STATEMENT_KINDS, SYNCED_CONTRACT_HASH_DOMAIN, SYNCED_SOURCE_PATTERN, SYNCED_VIEW_EXECUTION_OWNER_ROLE, TABLE_BRAND, VIEW_BRAND, actionFunctionName, actionFunctionStatements, actionParamArg, actionParamOrder, actionParamSchema, actionPrepareChecks, actionSchema, actionWriteTargets, actionsInterfaceName, activeAuthoringContext, applyMigrationHints, applyMigrationHintsV2, assertSyncedViewDefinitionMatches, beginAuthoringContext, buildActionParamsSchema, buildDrizzleEntities, buildDrizzleEntitiesV2, buildNamespaceDefinition, buildRebaseJournalEntry, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, canonicalizeDefinition, capabilityExpression, castParts, cellColumnName, checksumOf, claimExpression, classifyDestructive, columnSchema, columnTypeSchema2 as columnTypeSchema, compileActionRequires, compileActionStatements, compileNamespace, compilePredIrToSql, compilePredicate, compiledArtifactSchema, compiledOperationSchema, computeCanonicalHash, computeDefinitionHash, computeSyncedContractHash, consumerRoleName, convertV1DefinitionToCanonical, createOrmMigrationExport, custom, declaredCapabilityKeys, defineEnum, defineNamespace, defineOperation, defineResolvedTable, defineSyncedTable, defineTable, defineView, deriveColumnName, diffCommand, diffStatements, emptyJournal, emptySnapshot, endAuthoringContext, etlSource, extractNamedParams, extractOrmSyncedTableContract, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, highest, identifierSchema, importSpecSchema, indexByHash, isColumnBuilder, isEnumRef, isExternalPolicyClaimKey, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, latest, limitIrSchema, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, loadNamespaceFromDir, lowest, managedFn, manualSource, materializeLockKey, materializedRefreshFunctionName, migrationName, namespaceConfigSchema, namespaceSchema, nonNullFirst, normalizeCanonical, normalizeIr, normalizeSnapshot, objectRef, ontologyContractSchema, orderIrSchema, ormMigrationExportSchema, ormSchemaName, overlayWinsUnion, overrideRowMutation, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, planTableImport, policyExpressionSchema, policyVariantSchema, predIrSchema, predicateOperands, prefetchPlanIrSchema, prefetchSource, priority, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readOntologyContract, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, renderOrmMigrationExport, requiredArtifactIrVersion, resolvedMetaIrSchema, resolvedSourceIrSchema, revertOverlayMutation, rewriteSyncedSourceRelationsInViewQuery, roleExpression, rootIrSchema, securityStatements, selectionIrSchema, serializeNamespace, sqlTypeName, stableJson, syncedBackingRevokeStatements, syncedContractSurface, syncedTables, syncedViewDropStatements, syncedViewStatements, t, tableFileSchema, tableMetaIrSchema, tableReferenceSchema, toMany, toOne, toPlatformUser, typesInterfaceName, usesServicePrincipal, validateNamespaceCatalog, validateViewCatalogStatement, valueIrSchema, variableDefaultIrSchema, variableIrSchema, verifyRebaseIsNoop, walkPredicate, writeMigration };
8593
+ export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, CANONICAL_FORMAT, CAPABILITIES_CLAIM_KEY, CAPABILITY_KEY_PATTERN, CELLS_FIELD, CELL_PARTS, CELL_PART_SUFFIX, CLAIMS_CONTRACT, CLAIMS_SETTING, CLAIM_KEY_PATTERN, CMP_OPS, COLUMN_BRAND, COLUMN_DEFAULT_FNS, COLUMN_IDENTIFIER_PATTERN, COLUMN_TYPES2 as COLUMN_TYPES, COMPARE_OPS, COMPOSED_IR_VERSION, CONSUMER_ROLE_SUFFIX, ColumnBuilder, DATE_BUCKETS, DEFINITION_FILE_EXTENSIONS, ENUM_BRAND, EXTERNAL_POLICY_CLAIM_KEYS, GUARDED_IR_VERSION, HASH_DOMAIN, IDENTIFIER_PATTERN, IDENTIFIER_RE, IMPORT_CONFLICT_MODES, INPUT_REF_KINDS, IR_VERSION, IrVersionError, LEGACY_IR_VERSION, LINK_BRAND, MATERIALIZE_ACTOR, MATERIALIZE_CLAIMS_JSON, MAX_DEFINITION_FILE_BYTES, MAX_GENERATED_SDL_BYTES, MAX_IDENTIFIER_LENGTH, MAX_PERSISTED_READ_ROWS, MAX_TRACKED_COLUMN_NAME, MIGRATIONS_DIRNAME, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NAMESPACE_CONFIG_FILENAMES, NAMESPACE_PATTERN, OPERATION_DOCUMENTS_FILE, OPERATION_DOCUMENTS_VERSION, ORM_DATA_TOKEN_HEADER, ORM_MIGRATION_EXPORT_FILE, ORM_MIGRATION_EXPORT_MAX_BYTES, ORM_REGISTRATION_MAX_BYTES, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, ORM_TO_PIPELINE_TYPE, OrmDefinitionError, PredicateParseError, QUALIFIED_TABLE_PATTERN, RESERVED_COLUMN_NAMES, RESERVED_TABLE_NAMES, ROLES_CLAIM_KEY, RUNTIME_SQL_IR_VERSION, SCHEMA_DIR, SERVICE_PRINCIPAL_IR_VERSION, SQL_IR_VERSION, STATEMENT_KINDS, SYNCED_CONTRACT_HASH_DOMAIN, SYNCED_SOURCE_PATTERN, SYNCED_VIEW_EXECUTION_OWNER_ROLE, TABLE_BRAND, VIEW_BRAND, actionFunctionName, actionFunctionStatements, actionParamArg, actionParamOrder, actionParamSchema, actionPrepareChecks, actionSchema, actionWriteTargets, actionsInterfaceName, activeAuthoringContext, applyMigrationHints, applyMigrationHintsV2, assertSyncedViewDefinitionMatches, beginAuthoringContext, buildActionParamsSchema, buildDrizzleEntities, buildDrizzleEntitiesV2, buildNamespaceDefinition, buildRebaseJournalEntry, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, canonicalizeDefinition, capabilityExpression, castParts, cellColumnName, checksumOf, claimExpression, classifyDestructive, columnSchema, columnTypeSchema2 as columnTypeSchema, compileActionRequires, compileActionStatements, compileNamespace, compilePredIrToSql, compilePredicate, compiledArtifactSchema, compiledOperationSchema, computeCanonicalHash, computeDefinitionHash, computeSyncedContractHash, consumerRoleName, convertV1DefinitionToCanonical, createOrmMigrationExport, custom, declaredCapabilityKeys, defineEnum, defineNamespace, defineOperation, defineResolvedTable, defineSyncedTable, defineTable, defineView, deriveColumnName, diffCommand, diffStatements, emptyJournal, emptySnapshot, endAuthoringContext, etlSource, extractNamedParams, extractOrmSyncedTableContract, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, highest, identifierSchema, importSpecSchema, indexByHash, isColumnBuilder, isEnumRef, isExternalPolicyClaimKey, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, latest, limitIrSchema, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, loadNamespaceFromDir, lowest, managedFn, manualSource, materializeLockKey, materializedRefreshFunctionName, migrationName, namespaceConfigSchema, namespaceSchema, nonNullFirst, normalizeCanonical, normalizeIr, normalizeSnapshot, objectRef, ontologyContractSchema, orderIrSchema, ormMigrationExportSchema, ormSchemaName, overlayWinsUnion, overrideRowMutation, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, planTableImport, policyExpressionSchema, policyVariantSchema, predIrSchema, predicateOperands, prefetchPlanIrSchema, prefetchSource, priority, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readOntologyContract, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, renderOrmMigrationExport, requiredArtifactIrVersion, resolvedMetaIrSchema, resolvedSourceIrSchema, revertOverlayMutation, rewriteSyncedSourceRelationsInViewQuery, roleExpression, rootIrSchema, securityStatements, selectionIrSchema, serializeNamespace, sqlTypeName, stableJson, syncedBackingRevokeStatements, syncedContractSurface, syncedTables, syncedViewDropStatements, syncedViewStatements, t, tableFileSchema, tableMetaIrSchema, tableReferenceSchema, toMany, toOne, toPlatformUser, typesInterfaceName, usesServicePrincipal, validateNamespaceCatalog, validateViewCatalogStatement, valueIrSchema, variableDefaultIrSchema, variableIrSchema, verifyRebaseIsNoop, walkPredicate, writeMigration };
8485
8594
  //# sourceMappingURL=index.js.map
8486
8595
  //# sourceMappingURL=index.js.map