@sequenceholdings/orm 2.5.0 → 2.6.1

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.
package/dist/index.js CHANGED
@@ -1258,10 +1258,10 @@ function validateResolvedView({ view, tables, views = [] }) {
1258
1258
  const resolved = view.resolved;
1259
1259
  if (!resolved) return [];
1260
1260
  const errors = [];
1261
- const fail2 = (message) => errors.push(`resolved table '${view.view}': ${message}`);
1261
+ const fail3 = (message) => errors.push(`resolved table '${view.view}': ${message}`);
1262
1262
  const pkColumn = view.primaryKey?.length === 1 ? view.columns.find((c) => c.columnName === view.primaryKey?.[0]) : void 0;
1263
1263
  if (!pkColumn) {
1264
- fail2("requires exactly one primary-key column");
1264
+ fail3("requires exactly one primary-key column");
1265
1265
  return errors;
1266
1266
  }
1267
1267
  const systemNames = new Set(Object.values(RESOLVED_VIEW_SYSTEM_COLUMNS).map((c) => c.name));
@@ -1271,93 +1271,93 @@ function validateResolvedView({ view, tables, views = [] }) {
1271
1271
  pkColumn,
1272
1272
  dataColumns: new Map(view.columns.filter((c) => !systemNames.has(c.name) && c.cell === void 0).map((c) => [c.name, c])),
1273
1273
  sourceByName: /* @__PURE__ */ new Map(),
1274
- fail: fail2
1274
+ fail: fail3
1275
1275
  };
1276
- if (resolved.sources.filter((source) => source.kind === "manual").length !== 1) fail2("requires exactly one manual source");
1276
+ if (resolved.sources.filter((source) => source.kind === "manual").length !== 1) fail3("requires exactly one manual source");
1277
1277
  const tableByName = new Map(tables.map((table) => [table.table, table]));
1278
1278
  for (const source of resolved.sources) {
1279
- if (scope.sourceByName.has(source.name)) fail2(`duplicate source '${source.name}'`);
1279
+ if (scope.sourceByName.has(source.name)) fail3(`duplicate source '${source.name}'`);
1280
1280
  scope.sourceByName.set(source.name, source);
1281
1281
  const table = tableByName.get(source.table);
1282
- if (!table) fail2(`source '${source.name}' references unknown table '${source.table}'`);
1282
+ if (!table) fail3(`source '${source.name}' references unknown table '${source.table}'`);
1283
1283
  else validateSource({ scope, source, table });
1284
1284
  }
1285
1285
  validateRules(scope);
1286
1286
  validateViewCells(scope);
1287
1287
  if (resolved.materialized) validateMaterialized({ scope, tableByName, views });
1288
1288
  for (const name2 of resolved.deletedBy) {
1289
- if (scope.sourceByName.get(name2)?.kind !== "manual") fail2(`deletedBy '${name2}' must be the manual source`);
1289
+ if (scope.sourceByName.get(name2)?.kind !== "manual") fail3(`deletedBy '${name2}' must be the manual source`);
1290
1290
  }
1291
1291
  return errors;
1292
1292
  }
1293
1293
  function validateSource({ scope, source, table }) {
1294
- const { fail: fail2 } = scope;
1295
- if (source.kind === "etl" && table.source === void 0) fail2(`etl source '${source.name}' must reference a synced table`);
1296
- if (source.kind === "etl" && table.primaryKey?.length === 0) fail2(`etl source '${source.name}' cannot use an unkeyed synced table for resolved row identity`);
1294
+ const { fail: fail3 } = scope;
1295
+ if (source.kind === "etl" && table.source === void 0) fail3(`etl source '${source.name}' must reference a synced table`);
1296
+ if (source.kind === "etl" && table.primaryKey?.length === 0) fail3(`etl source '${source.name}' cannot use an unkeyed synced table for resolved row identity`);
1297
1297
  if (source.kind !== "etl" && (table.internal !== true || table.cellMetadata !== true)) {
1298
- fail2(`${source.kind} source '${source.name}' must reference an internal table with cell metadata`);
1298
+ fail3(`${source.kind} source '${source.name}' must reference an internal table with cell metadata`);
1299
1299
  }
1300
1300
  const hasRev = table.columns.some((column) => column.cell?.part === "rev");
1301
- if (source.kind === "manual" && !hasRev) fail2(`manual source '${source.name}' must carry '__rev' cell columns`);
1302
- if (source.kind === "prefetch" && hasRev) fail2(`prefetch source '${source.name}' must not carry '__rev' cell columns`);
1301
+ if (source.kind === "manual" && !hasRev) fail3(`manual source '${source.name}' must carry '__rev' cell columns`);
1302
+ if (source.kind === "prefetch" && hasRev) fail3(`prefetch source '${source.name}' must not carry '__rev' cell columns`);
1303
1303
  const byName = new Map(table.columns.map((c) => [c.name, c]));
1304
1304
  validateSourceColumns({ scope, source, byName });
1305
1305
  if (source.kind === "etl") {
1306
1306
  const updatedAt = source.updatedAt === void 0 ? void 0 : byName.get(source.updatedAt);
1307
1307
  if (source.updatedAt !== void 0 && updatedAt?.type !== "timestamptz" && updatedAt?.type !== "date") {
1308
- fail2(`etl source '${source.name}' updatedAt must name a timestamptz/date column on '${source.table}'`);
1308
+ fail3(`etl source '${source.name}' updatedAt must name a timestamptz/date column on '${source.table}'`);
1309
1309
  }
1310
1310
  }
1311
1311
  validatePrefetchFields({ scope, source });
1312
1312
  }
1313
1313
  function validatePrefetchFields({ scope, source }) {
1314
- const { fail: fail2, pkColumn } = scope;
1314
+ const { fail: fail3, pkColumn } = scope;
1315
1315
  if (source.kind !== "prefetch") {
1316
1316
  if (source.key || source.fetch || source.function || source.prefetchDefaults || source.writeback) {
1317
- fail2(`only prefetch sources may declare key/fetch/function/prefetchDefaults/writeback ('${source.name}')`);
1317
+ fail3(`only prefetch sources may declare key/fetch/function/prefetchDefaults/writeback ('${source.name}')`);
1318
1318
  }
1319
1319
  return;
1320
1320
  }
1321
1321
  if (!source.key || !source.fetch || !source.function || !source.prefetchDefaults) {
1322
- fail2(`prefetch source '${source.name}' requires key, fetch, function and prefetchDefaults`);
1322
+ fail3(`prefetch source '${source.name}' requires key, fetch, function and prefetchDefaults`);
1323
1323
  } else if (source.key !== pkColumn.name && !source.columns.includes(source.key)) {
1324
- fail2(`prefetch source '${source.name}' key '${source.key}' must be the primary key or one of its columns`);
1324
+ fail3(`prefetch source '${source.name}' key '${source.key}' must be the primary key or one of its columns`);
1325
1325
  }
1326
1326
  for (const column of source.writeback?.columns ?? []) {
1327
- if (!source.columns.includes(column)) fail2(`prefetch source '${source.name}' writes back '${column}', which it does not supply`);
1327
+ if (!source.columns.includes(column)) fail3(`prefetch source '${source.name}' writes back '${column}', which it does not supply`);
1328
1328
  }
1329
1329
  }
1330
1330
  function validateSourceColumns({ scope, source, byName }) {
1331
- const { fail: fail2, pkColumn, dataColumns } = scope;
1331
+ const { fail: fail3, pkColumn, dataColumns } = scope;
1332
1332
  for (const column of [pkColumn.name, ...source.columns]) {
1333
1333
  const own = column === pkColumn.name ? pkColumn : dataColumns.get(column);
1334
1334
  const theirs = byName.get(column);
1335
- if (!own) fail2(`source '${source.name}' supplies unknown column '${column}'`);
1336
- else if (!theirs) fail2(`source '${source.name}' table '${source.table}' has no column '${column}'`);
1337
- else if (JSON.stringify(theirs.type) !== JSON.stringify(own.type)) fail2(`column '${column}' has a different type on source '${source.name}'`);
1335
+ if (!own) fail3(`source '${source.name}' supplies unknown column '${column}'`);
1336
+ else if (!theirs) fail3(`source '${source.name}' table '${source.table}' has no column '${column}'`);
1337
+ else if (JSON.stringify(theirs.type) !== JSON.stringify(own.type)) fail3(`column '${column}' has a different type on source '${source.name}'`);
1338
1338
  }
1339
1339
  }
1340
- function validateRules({ resolved, pkColumn, dataColumns, sourceByName, fail: fail2 }) {
1340
+ function validateRules({ resolved, pkColumn, dataColumns, sourceByName, fail: fail3 }) {
1341
1341
  const ruled = /* @__PURE__ */ new Set();
1342
1342
  for (const rule of resolved.resolve) {
1343
1343
  if (!dataColumns.has(rule.column) || rule.column === pkColumn.name) {
1344
- fail2(`resolve rule targets unknown column '${rule.column}'`);
1344
+ fail3(`resolve rule targets unknown column '${rule.column}'`);
1345
1345
  continue;
1346
1346
  }
1347
- if (ruled.has(rule.column)) fail2(`column '${rule.column}' has more than one resolve rule`);
1347
+ if (ruled.has(rule.column)) fail3(`column '${rule.column}' has more than one resolve rule`);
1348
1348
  ruled.add(rule.column);
1349
1349
  if (rule.comparator === "custom" !== (rule.orderBy !== void 0)) {
1350
- fail2(`column '${rule.column}': orderBy is required for custom comparators and only allowed there`);
1350
+ fail3(`column '${rule.column}': orderBy is required for custom comparators and only allowed there`);
1351
1351
  }
1352
- if (new Set(rule.candidates).size !== rule.candidates.length) fail2(`column '${rule.column}' repeats a candidate`);
1352
+ if (new Set(rule.candidates).size !== rule.candidates.length) fail3(`column '${rule.column}' repeats a candidate`);
1353
1353
  for (const candidate of rule.candidates) {
1354
1354
  const source = sourceByName.get(candidate);
1355
- if (!source) fail2(`column '${rule.column}' names unknown candidate source '${candidate}'`);
1356
- else if (!source.columns.includes(rule.column)) fail2(`column '${rule.column}' candidate '${candidate}' does not supply it`);
1355
+ if (!source) fail3(`column '${rule.column}' names unknown candidate source '${candidate}'`);
1356
+ else if (!source.columns.includes(rule.column)) fail3(`column '${rule.column}' candidate '${candidate}' does not supply it`);
1357
1357
  }
1358
1358
  }
1359
1359
  for (const column of dataColumns.keys()) {
1360
- if (column !== pkColumn.name && !ruled.has(column)) fail2(`column '${column}' has no resolve rule`);
1360
+ if (column !== pkColumn.name && !ruled.has(column)) fail3(`column '${column}' has no resolve rule`);
1361
1361
  }
1362
1362
  }
1363
1363
  var VIEW_CELL_TYPES = {
@@ -1366,7 +1366,7 @@ var VIEW_CELL_TYPES = {
1366
1366
  by: "text",
1367
1367
  conflicts: "jsonb"
1368
1368
  };
1369
- function validateViewCells({ view, dataColumns, pkColumn, fail: fail2 }) {
1369
+ function validateViewCells({ view, dataColumns, pkColumn, fail: fail3 }) {
1370
1370
  const expected = /* @__PURE__ */ new Map();
1371
1371
  for (const column of dataColumns.values()) {
1372
1372
  if (column.name === pkColumn.name) continue;
@@ -1378,34 +1378,34 @@ function validateViewCells({ view, dataColumns, pkColumn, fail: fail2 }) {
1378
1378
  if (!column.cell) continue;
1379
1379
  const want = expected.get(column.name);
1380
1380
  if (!want || want.part !== column.cell.part || want.columnName !== column.columnName || cellColumnName(column.cell.of, column.cell.part) !== column.name) {
1381
- fail2(`unexpected cell column '${column.name}'`);
1381
+ fail3(`unexpected cell column '${column.name}'`);
1382
1382
  continue;
1383
1383
  }
1384
- if (column.type !== VIEW_CELL_TYPES[column.cell.part]) fail2(`cell column '${column.name}' must be ${VIEW_CELL_TYPES[column.cell.part]}`);
1384
+ if (column.type !== VIEW_CELL_TYPES[column.cell.part]) fail3(`cell column '${column.name}' must be ${VIEW_CELL_TYPES[column.cell.part]}`);
1385
1385
  expected.delete(column.name);
1386
1386
  }
1387
- for (const name2 of expected.keys()) fail2(`missing cell column '${name2}'`);
1387
+ for (const name2 of expected.keys()) fail3(`missing cell column '${name2}'`);
1388
1388
  }
1389
1389
  var columnSignature = (columns) => JSON.stringify(columns.map((column) => [column.name, column.columnName, column.type]));
1390
1390
  function validateMaterialized({ scope, tableByName, views }) {
1391
- const { view, resolved, fail: fail2 } = scope;
1391
+ const { view, resolved, fail: fail3 } = scope;
1392
1392
  const { table: tableName, compute: computeName } = resolved.materialized;
1393
1393
  const table = tableByName.get(tableName);
1394
1394
  if (!table || table.internal !== true || table.materializes !== view.view) {
1395
- fail2(`materialized table '${tableName}' must be an internal table that materializes '${view.view}'`);
1395
+ fail3(`materialized table '${tableName}' must be an internal table that materializes '${view.view}'`);
1396
1396
  } else {
1397
- if (columnSignature(table.columns) !== columnSignature(view.columns)) fail2(`materialized table '${tableName}' must have exactly the view's columns`);
1398
- if (JSON.stringify(table.primaryKey ?? []) !== JSON.stringify(view.primaryKey ?? [])) fail2(`materialized table '${tableName}' must share the view's primary key`);
1397
+ if (columnSignature(table.columns) !== columnSignature(view.columns)) fail3(`materialized table '${tableName}' must have exactly the view's columns`);
1398
+ if (JSON.stringify(table.primaryKey ?? []) !== JSON.stringify(view.primaryKey ?? [])) fail3(`materialized table '${tableName}' must share the view's primary key`);
1399
1399
  }
1400
1400
  const compute = views.find((candidate) => candidate.view === computeName);
1401
- if (!compute || compute.internal !== true) fail2(`compute view '${computeName}' must be an internal view`);
1402
- else if (columnSignature(compute.columns) !== columnSignature(view.columns)) fail2(`compute view '${computeName}' must have exactly the view's columns`);
1401
+ if (!compute || compute.internal !== true) fail3(`compute view '${computeName}' must be an internal view`);
1402
+ else if (columnSignature(compute.columns) !== columnSignature(view.columns)) fail3(`compute view '${computeName}' must have exactly the view's columns`);
1403
1403
  for (const source of resolved.sources) {
1404
1404
  if (source.kind !== "etl") continue;
1405
1405
  const read = tableByName.get(source.table)?.policies?.read;
1406
1406
  const unconditional = typeof read === "string" ? read.trim() === "true" : read !== void 0 && read.default.trim() === "true" && read.variants.length === 0;
1407
1407
  if (!unconditional) {
1408
- fail2(`etl source '${source.name}' must have read policy 'true' to be materialized (the copy is shared by every caller)`);
1408
+ fail3(`etl source '${source.name}' must have read policy 'true' to be materialized (the copy is shared by every caller)`);
1409
1409
  }
1410
1410
  }
1411
1411
  }
@@ -1780,26 +1780,26 @@ var canonicalTableSchema = z.object({
1780
1780
  materializes: identifier2.optional()
1781
1781
  }).superRefine((table, ctx) => {
1782
1782
  if (table.primaryKey?.length !== 0) return;
1783
- const fail2 = (message, path = ["primaryKey"]) => ctx.addIssue({ code: "custom", path, message: `unkeyed table '${table.table}' ${message}` });
1783
+ const fail3 = (message, path = ["primaryKey"]) => ctx.addIssue({ code: "custom", path, message: `unkeyed table '${table.table}' ${message}` });
1784
1784
  if (table.source === void 0 || table.columns.length === 0) {
1785
- fail2("requires a typed synced source");
1785
+ fail3("requires a typed synced source");
1786
1786
  }
1787
1787
  if ([table.policies.write, table.policies.insert, table.policies.update].some((policy) => policy !== void 0)) {
1788
- fail2("is read-only and cannot declare write policies", ["policies"]);
1788
+ fail3("is read-only and cannot declare write policies", ["policies"]);
1789
1789
  }
1790
1790
  const ownedCollections = [table.indexes, table.actions, table.checks, table.foreignKeys, table.cowMutations];
1791
1791
  const ownedMetadata = [table.cellMetadata, table.internal, table.materializes, table.renamedFrom];
1792
1792
  if (ownedCollections.some((items) => items !== void 0 && items.length > 0) || ownedMetadata.some((value) => value !== void 0)) {
1793
- fail2("cannot declare owned storage, constraints or identity operations");
1793
+ fail3("cannot declare owned storage, constraints or identity operations");
1794
1794
  }
1795
1795
  for (const [index3, column] of table.columns.entries()) {
1796
1796
  const ownedColumnMetadata = [column.default, column.defaultFn, column.onUpdateFn, column.renamedFrom, column.cast, column.cell];
1797
1797
  if (column.unique || ownedColumnMetadata.some((value) => value !== void 0)) {
1798
- fail2("cannot declare column uniqueness, mutation defaults or migration metadata", ["columns", index3]);
1798
+ fail3("cannot declare column uniqueness, mutation defaults or migration metadata", ["columns", index3]);
1799
1799
  }
1800
1800
  }
1801
1801
  for (const [index3, link] of table.links.entries()) {
1802
- if (link.enforce || link.kind === "toMany") fail2("cannot provide an identity for this link", ["links", index3]);
1802
+ if (link.enforce || link.kind === "toMany") fail3("cannot provide an identity for this link", ["links", index3]);
1803
1803
  }
1804
1804
  });
1805
1805
  var MAX_VIEW_QUERY = 1e5;
@@ -1890,49 +1890,49 @@ function trackedCellColumns(table) {
1890
1890
  }
1891
1891
  var SUFFIXES = Object.values(CELL_PART_SUFFIX);
1892
1892
  function validateCellMetadata(table, index3, ctx) {
1893
- const fail2 = (message, path = ["tables", index3]) => ctx.addIssue({ code: "custom", path, message });
1893
+ const fail3 = (message, path = ["tables", index3]) => ctx.addIssue({ code: "custom", path, message });
1894
1894
  const cells = table.columns.flatMap((column, position) => column.cell ? [{ column, position, cell: column.cell }] : []);
1895
1895
  if (table.materializes !== void 0) return;
1896
1896
  if (table.cellMetadata !== true) {
1897
- for (const { position } of cells) fail2(`cell-metadata columns require cellMetadata on table '${table.table}'`, ["tables", index3, "columns", position]);
1897
+ for (const { position } of cells) fail3(`cell-metadata columns require cellMetadata on table '${table.table}'`, ["tables", index3, "columns", position]);
1898
1898
  return;
1899
1899
  }
1900
1900
  if (table.source !== void 0) {
1901
- fail2(`synced table '${table.table}' cannot track cell metadata`);
1901
+ fail3(`synced table '${table.table}' cannot track cell metadata`);
1902
1902
  return;
1903
1903
  }
1904
1904
  const tracked = trackedCellColumns(table);
1905
1905
  const byName = new Map(tracked.map((column) => [column.name, column]));
1906
1906
  const withRev = cells.some(({ cell }) => cell.part === "rev");
1907
- if (withRev && table.internal !== true) fail2(`only a resolved table's internal sources carry '__rev' cell columns ('${table.table}')`);
1907
+ if (withRev && table.internal !== true) fail3(`only a resolved table's internal sources carry '__rev' cell columns ('${table.table}')`);
1908
1908
  const seen = /* @__PURE__ */ new Set();
1909
1909
  for (const { column, position, cell } of cells) {
1910
1910
  const path = ["tables", index3, "columns", position];
1911
1911
  const owner = byName.get(cell.of);
1912
1912
  if (!owner) {
1913
- fail2(`cell column '${column.name}' belongs to '${cell.of}', which is not a tracked column`, path);
1913
+ fail3(`cell column '${column.name}' belongs to '${cell.of}', which is not a tracked column`, path);
1914
1914
  continue;
1915
1915
  }
1916
- if (cell.part !== "at" && cell.part !== "by" && cell.part !== "rev") fail2(`a table cell column must be part at/by/rev, not '${cell.part}'`, path);
1916
+ if (cell.part !== "at" && cell.part !== "by" && cell.part !== "rev") fail3(`a table cell column must be part at/by/rev, not '${cell.part}'`, path);
1917
1917
  if (column.name !== cellColumnName(owner.name, cell.part) || column.columnName !== cellColumnName(owner.columnName, cell.part)) {
1918
- fail2(`cell column for '${owner.name}' ${cell.part} must be named '${cellColumnName(owner.name, cell.part)}' / '${cellColumnName(owner.columnName, cell.part)}'`, path);
1918
+ fail3(`cell column for '${owner.name}' ${cell.part} must be named '${cellColumnName(owner.name, cell.part)}' / '${cellColumnName(owner.columnName, cell.part)}'`, path);
1919
1919
  }
1920
1920
  if (column.type !== CELL_PART_TYPES[cell.part] || !column.nullable || column.unique || column.default !== void 0 || column.defaultFn !== void 0) {
1921
- fail2(`cell column '${column.name}' must be a nullable, default-less ${CELL_PART_TYPES[cell.part]}`, path);
1921
+ fail3(`cell column '${column.name}' must be a nullable, default-less ${CELL_PART_TYPES[cell.part]}`, path);
1922
1922
  }
1923
1923
  const key = `${cell.of}:${cell.part}`;
1924
- if (seen.has(key)) fail2(`duplicate cell column '${column.name}'`, path);
1924
+ if (seen.has(key)) fail3(`duplicate cell column '${column.name}'`, path);
1925
1925
  seen.add(key);
1926
1926
  }
1927
1927
  for (const column of tracked) {
1928
1928
  if (column.columnName.length > MAX_TRACKED_COLUMN_NAME) {
1929
- fail2(`column '${column.columnName}' is too long to track cell metadata (max ${MAX_TRACKED_COLUMN_NAME} characters)`);
1929
+ fail3(`column '${column.columnName}' is too long to track cell metadata (max ${MAX_TRACKED_COLUMN_NAME} characters)`);
1930
1930
  }
1931
1931
  if (SUFFIXES.some((suffix) => column.columnName.endsWith(suffix))) {
1932
- fail2(`column '${column.columnName}' ends in a reserved cell-metadata suffix (${SUFFIXES.join(", ")})`);
1932
+ fail3(`column '${column.columnName}' ends in a reserved cell-metadata suffix (${SUFFIXES.join(", ")})`);
1933
1933
  }
1934
1934
  for (const part of withRev ? ["at", "by", "rev"] : ["at", "by"]) {
1935
- if (!seen.has(`${column.name}:${part}`)) fail2(`tracked column '${column.name}' is missing its '${cellColumnName(column.columnName, part)}' cell column`);
1935
+ if (!seen.has(`${column.name}:${part}`)) fail3(`tracked column '${column.name}' is missing its '${cellColumnName(column.columnName, part)}' cell column`);
1936
1936
  }
1937
1937
  }
1938
1938
  }
@@ -2000,38 +2000,38 @@ var localDefinitionSchema = z.object({
2000
2000
  }
2001
2001
  }
2002
2002
  for (const [index3, check] of (table.checks ?? []).entries()) {
2003
- const fail2 = (message) => ctx.addIssue({ code: "custom", path: ["tables", tableIndex, "checks", index3], message });
2004
- if (table.source) fail2("synced tables cannot declare checks");
2005
- if (names.has(check.name)) fail2(`duplicate constraint '${check.name}'`);
2003
+ const fail3 = (message) => ctx.addIssue({ code: "custom", path: ["tables", tableIndex, "checks", index3], message });
2004
+ if (table.source) fail3("synced tables cannot declare checks");
2005
+ if (names.has(check.name)) fail3(`duplicate constraint '${check.name}'`);
2006
2006
  names.add(check.name);
2007
2007
  try {
2008
2008
  compileCheckExpression(check.expression, table.columns);
2009
2009
  } catch (error) {
2010
- fail2(error instanceof Error ? error.message : String(error));
2010
+ fail3(error instanceof Error ? error.message : String(error));
2011
2011
  }
2012
2012
  }
2013
2013
  for (const [index3, fk] of (table.foreignKeys ?? []).entries()) {
2014
- const fail2 = (message) => ctx.addIssue({ code: "custom", path: ["tables", tableIndex, "foreignKeys", index3], message });
2015
- if (names.has(fk.name)) fail2(`duplicate foreign key '${fk.name}'`);
2014
+ const fail3 = (message) => ctx.addIssue({ code: "custom", path: ["tables", tableIndex, "foreignKeys", index3], message });
2015
+ if (names.has(fk.name)) fail3(`duplicate foreign key '${fk.name}'`);
2016
2016
  names.add(fk.name);
2017
2017
  const target = fkTables.get(fk.target);
2018
2018
  if (table.source || !target || target.source) {
2019
- fail2("foreign keys must connect owned tables in the same namespace");
2019
+ fail3("foreign keys must connect owned tables in the same namespace");
2020
2020
  continue;
2021
2021
  }
2022
- if (fk.columns.length !== fk.references.length) fail2("foreign key columns and references must have the same number of columns");
2023
- if (new Set(fk.columns).size !== fk.columns.length || new Set(fk.references).size !== fk.references.length) fail2("foreign key columns must not repeat");
2022
+ if (fk.columns.length !== fk.references.length) fail3("foreign key columns and references must have the same number of columns");
2023
+ if (new Set(fk.columns).size !== fk.columns.length || new Set(fk.references).size !== fk.references.length) fail3("foreign key columns must not repeat");
2024
2024
  for (const [position, name2] of fk.columns.entries()) {
2025
2025
  const sourceColumn = table.columns.find((column) => column.columnName === name2);
2026
2026
  const targetColumn = target.columns.find((column) => column.columnName === fk.references[position]);
2027
- if (!sourceColumn || !targetColumn) fail2("foreign key references an unknown column");
2028
- else if (JSON.stringify(sourceColumn.type) !== JSON.stringify(targetColumn.type)) fail2("foreign key column types must match");
2027
+ if (!sourceColumn || !targetColumn) fail3("foreign key references an unknown column");
2028
+ else if (JSON.stringify(sourceColumn.type) !== JSON.stringify(targetColumn.type)) fail3("foreign key column types must match");
2029
2029
  }
2030
2030
  if (fk.onDelete === "set null" || fk.onUpdate === "set null") {
2031
- if (fk.columns.some((name2) => table.columns.find((column) => column.columnName === name2)?.nullable === false || table.primaryKey?.includes(name2))) fail2("SET NULL requires nullable source columns");
2031
+ if (fk.columns.some((name2) => table.columns.find((column) => column.columnName === name2)?.nullable === false || table.primaryKey?.includes(name2))) fail3("SET NULL requires nullable source columns");
2032
2032
  }
2033
2033
  const uniqueKeys = [target.primaryKey ?? [], ...target.indexes.filter((index4) => index4.unique).map((index4) => index4.columns), ...target.columns.filter((column) => column.unique).map((column) => [column.columnName])];
2034
- if (!uniqueKeys.some((key) => key.length === fk.references.length && key.every((column) => fk.references.includes(column)))) fail2("foreign key target columns must form a unique key");
2034
+ if (!uniqueKeys.some((key) => key.length === fk.references.length && key.every((column) => fk.references.includes(column)))) fail3("foreign key target columns must form a unique key");
2035
2035
  }
2036
2036
  }
2037
2037
  for (const [viewIndex, view] of (definition.views ?? []).entries()) {
@@ -2219,8 +2219,8 @@ function cloneColumn({ builder, property, notNull, primaryKey: primaryKey2 }) {
2219
2219
  return clone;
2220
2220
  }
2221
2221
  function planSource(input) {
2222
- const { sourceName, input: source, fail: fail2 } = input;
2223
- if (!IDENTIFIER_PATTERN.test(sourceName)) fail2(`source name "${sourceName}" must match ${IDENTIFIER_PATTERN}`);
2222
+ const { sourceName, input: source, fail: fail3 } = input;
2223
+ if (!IDENTIFIER_PATTERN.test(sourceName)) fail3(`source name "${sourceName}" must match ${IDENTIFIER_PATTERN}`);
2224
2224
  switch (source.kind) {
2225
2225
  case "manual":
2226
2226
  return {
@@ -2260,27 +2260,27 @@ function assertColumns(input, list2, what) {
2260
2260
  for (const column of list2) if (!input.dataColumns.includes(column)) input.fail(`${what} names unknown column "${column}"`);
2261
2261
  }
2262
2262
  function planEtl(input, source) {
2263
- const { sourceName, pk, dataColumns, fail: fail2 } = input;
2263
+ const { sourceName, pk, dataColumns, fail: fail3 } = input;
2264
2264
  const table = typeof source.table === "function" ? source.table() : source.table;
2265
- if (!isSeqTable(table) || table.source === void 0) fail2(`etl source "${sourceName}" must reference a defineSyncedTable`);
2265
+ if (!isSeqTable(table) || table.source === void 0) fail3(`etl source "${sourceName}" must reference a defineSyncedTable`);
2266
2266
  const synced = table;
2267
- if (synced.config.primaryKey?.length === 0) fail2(`etl source "${sourceName}" cannot use an unkeyed synced table for resolved row identity`);
2268
- if (!(pk in synced.columns)) fail2(`etl source "${sourceName}" table "${synced.tableName}" has no "${pk}" column`);
2267
+ if (synced.config.primaryKey?.length === 0) fail3(`etl source "${sourceName}" cannot use an unkeyed synced table for resolved row identity`);
2268
+ if (!(pk in synced.columns)) fail3(`etl source "${sourceName}" table "${synced.tableName}" has no "${pk}" column`);
2269
2269
  const supplied = source.columns ? [...source.columns] : dataColumns.filter((column) => column in synced.columns);
2270
2270
  assertColumns(input, supplied, `etl source "${sourceName}"`);
2271
2271
  if (source.updatedAt !== void 0 && !(source.updatedAt in synced.columns)) {
2272
- fail2(`etl source "${sourceName}" updatedAt "${source.updatedAt}" is not a column of "${synced.tableName}"`);
2272
+ fail3(`etl source "${sourceName}" updatedAt "${source.updatedAt}" is not a column of "${synced.tableName}"`);
2273
2273
  }
2274
2274
  return { name: sourceName, kind: "etl", table: synced, columns: supplied, ...source.updatedAt ? { updatedAt: source.updatedAt } : {} };
2275
2275
  }
2276
2276
  function planPrefetch(input, source) {
2277
- const { sourceName, pk, fail: fail2 } = input;
2277
+ const { sourceName, pk, fail: fail3 } = input;
2278
2278
  assertColumns(input, source.columns, `prefetch source "${sourceName}"`);
2279
2279
  if (source.key !== pk && !source.columns.includes(source.key)) {
2280
- fail2(`prefetch source "${sourceName}" key "${source.key}" must be the primary key or one of its columns`);
2280
+ fail3(`prefetch source "${sourceName}" key "${source.key}" must be the primary key or one of its columns`);
2281
2281
  }
2282
2282
  for (const column of source.writeback?.columns ?? []) {
2283
- if (!source.columns.includes(column)) fail2(`prefetch source "${sourceName}" writes back "${column}", which it does not supply`);
2283
+ if (!source.columns.includes(column)) fail3(`prefetch source "${sourceName}" writes back "${column}", which it does not supply`);
2284
2284
  }
2285
2285
  const writeback = source.writeback;
2286
2286
  return {
@@ -2486,34 +2486,34 @@ var SYSTEM_VIEW_COLUMNS = {
2486
2486
  };
2487
2487
  function defineResolvedTable(name2, columns, config) {
2488
2488
  const file = activeAuthoringContext()?.currentFile;
2489
- const fail2 = (message) => {
2489
+ const fail3 = (message) => {
2490
2490
  throw new OrmDefinitionError(`resolved table "${name2}": ${message}`, file);
2491
2491
  };
2492
- if (!IDENTIFIER_PATTERN.test(name2)) fail2(`name must match ${IDENTIFIER_PATTERN}`);
2492
+ if (!IDENTIFIER_PATTERN.test(name2)) fail3(`name must match ${IDENTIFIER_PATTERN}`);
2493
2493
  for (const property of Object.keys(columns)) {
2494
2494
  if (RESERVED_RESOLVED_COLUMN_NAMES.has(property) || RESERVED_RESOLVED_COLUMN_NAMES.has(columns[property].columnNameFor(property))) {
2495
- fail2(`column "${property}" collides with a reserved system column`);
2495
+ fail3(`column "${property}" collides with a reserved system column`);
2496
2496
  }
2497
2497
  }
2498
2498
  for (const property of Object.keys(columns)) {
2499
2499
  if (columns[property].columnNameFor(property).length > MAX_TRACKED_COLUMN_NAME) {
2500
- fail2(`column "${property}" is too long for a resolved table (max ${MAX_TRACKED_COLUMN_NAME} characters, room for cell parts)`);
2500
+ fail3(`column "${property}" is too long for a resolved table (max ${MAX_TRACKED_COLUMN_NAME} characters, room for cell parts)`);
2501
2501
  }
2502
2502
  }
2503
2503
  const pkEntries = Object.entries(columns).filter(([, builder]) => builder.isPrimaryKey);
2504
- if (pkEntries.length !== 1) fail2("declare exactly one .primaryKey() column");
2504
+ if (pkEntries.length !== 1) fail3("declare exactly one .primaryKey() column");
2505
2505
  const [pk, pkBuilder] = pkEntries[0];
2506
2506
  const dataColumns = Object.keys(columns).filter((property) => property !== pk);
2507
- if (dataColumns.length === 0) fail2("declare at least one non-key column");
2507
+ if (dataColumns.length === 0) fail3("declare at least one non-key column");
2508
2508
  const sourceEntries = Object.entries(config.sources);
2509
- if (sourceEntries.filter(([, source]) => source.kind === "manual").length !== 1) fail2("declare exactly one manualSource()");
2509
+ if (sourceEntries.filter(([, source]) => source.kind === "manual").length !== 1) fail3("declare exactly one manualSource()");
2510
2510
  const plans = sourceEntries.map(
2511
- ([sourceName, input]) => planSource({ viewName: name2, sourceName, input, columns, pk, pkBuilder, dataColumns, fail: fail2 })
2511
+ ([sourceName, input]) => planSource({ viewName: name2, sourceName, input, columns, pk, pkBuilder, dataColumns, fail: fail3 })
2512
2512
  );
2513
- const rules = planRules({ config, plans, dataColumns, fail: fail2 });
2513
+ const rules = planRules({ config, plans, dataColumns, fail: fail3 });
2514
2514
  const deletedBy = [...config.rows?.deletedBy ?? []];
2515
2515
  for (const source of deletedBy) {
2516
- if (plans.find((plan) => plan.name === source)?.kind !== "manual") fail2(`rows.deletedBy "${source}" must be the manual source`);
2516
+ if (plans.find((plan) => plan.name === source)?.kind !== "manual") fail3(`rows.deletedBy "${source}" must be the manual source`);
2517
2517
  }
2518
2518
  const partType = { source: t.text, at: t.timestamptz, by: t.text, conflicts: t.jsonb };
2519
2519
  const viewColumns = {};
@@ -2576,11 +2576,11 @@ function defineResolvedTable(name2, columns, config) {
2576
2576
  }
2577
2577
  });
2578
2578
  }
2579
- function planRules({ config, plans, dataColumns, fail: fail2 }) {
2579
+ function planRules({ config, plans, dataColumns, fail: fail3 }) {
2580
2580
  const kindOrder = { manual: 0, prefetch: 1, etl: 2 };
2581
2581
  const fallback = config.default ?? priority([...plans].sort((a, b) => kindOrder[a.kind] - kindOrder[b.kind]).map((plan) => plan.name));
2582
2582
  for (const column of Object.keys(config.resolve ?? {})) {
2583
- if (!dataColumns.includes(column)) fail2(`resolve names unknown column "${column}"`);
2583
+ if (!dataColumns.includes(column)) fail3(`resolve names unknown column "${column}"`);
2584
2584
  }
2585
2585
  return dataColumns.map((column) => {
2586
2586
  const explicit = config.resolve?.[column];
@@ -2588,11 +2588,11 @@ function planRules({ config, plans, dataColumns, fail: fail2 }) {
2588
2588
  const candidates = explicit ? [...explicit.candidates] : comparator.candidates.filter((name2) => plans.find((plan) => plan.name === name2)?.columns.includes(column));
2589
2589
  for (const candidate of candidates) {
2590
2590
  const plan = plans.find((entry) => entry.name === candidate);
2591
- if (!plan) fail2(`column "${column}" names unknown source "${candidate}"`);
2592
- else if (!plan.columns.includes(column)) fail2(`column "${column}" candidate "${candidate}" does not supply it`);
2591
+ if (!plan) fail3(`column "${column}" names unknown source "${candidate}"`);
2592
+ else if (!plan.columns.includes(column)) fail3(`column "${column}" candidate "${candidate}" does not supply it`);
2593
2593
  }
2594
- if (candidates.length === 0) fail2(`column "${column}" has no candidate source`);
2595
- if (comparator.kind === "custom") assertSafeOrderBy({ orderBy: comparator.orderBy ?? "", column, fail: fail2 });
2594
+ if (candidates.length === 0) fail3(`column "${column}" has no candidate source`);
2595
+ if (comparator.kind === "custom") assertSafeOrderBy({ orderBy: comparator.orderBy ?? "", column, fail: fail3 });
2596
2596
  return {
2597
2597
  column,
2598
2598
  comparator: comparator.kind,
@@ -2643,18 +2643,18 @@ var ORDER_BY_KEYWORDS = /* @__PURE__ */ new Set([
2643
2643
  ]);
2644
2644
  var ALLOWED_FUNCTIONS = new Set(VIEW_QUERY_FUNCTION_ALLOWLIST);
2645
2645
  var ORDER_BY_TOKEN = /\s+|'(?:[^']|'')*'|\d+(?:\.\d+)?|[a-z_][a-z0-9_]*|::|<=|>=|<>|!=|[-+*/%<>=(),|]/giy;
2646
- function assertSafeOrderBy({ orderBy, column, fail: fail2 }) {
2646
+ function assertSafeOrderBy({ orderBy, column, fail: fail3 }) {
2647
2647
  ORDER_BY_TOKEN.lastIndex = 0;
2648
2648
  let consumed = 0;
2649
2649
  for (let match = ORDER_BY_TOKEN.exec(orderBy); match; match = ORDER_BY_TOKEN.exec(orderBy)) {
2650
2650
  consumed = ORDER_BY_TOKEN.lastIndex;
2651
2651
  const token = match[0].toLowerCase();
2652
2652
  if (/^[a-z_]/.test(token) && !ORDER_BY_KEYWORDS.has(token) && !ALLOWED_FUNCTIONS.has(token)) {
2653
- fail2(`column "${column}" custom orderBy uses "${match[0]}" \u2014 only value, updated_at, source, actor, ord, SQL keywords and allowlisted functions`);
2653
+ fail3(`column "${column}" custom orderBy uses "${match[0]}" \u2014 only value, updated_at, source, actor, ord, SQL keywords and allowlisted functions`);
2654
2654
  }
2655
2655
  }
2656
2656
  if (consumed !== orderBy.length || orderBy.trim() === "") {
2657
- fail2(`column "${column}" custom orderBy contains an unsupported character near "${orderBy.slice(consumed, consumed + 10)}"`);
2657
+ fail3(`column "${column}" custom orderBy contains an unsupported character near "${orderBy.slice(consumed, consumed + 10)}"`);
2658
2658
  }
2659
2659
  }
2660
2660
  function stableJson(value) {
@@ -3182,17 +3182,17 @@ function buildCanonicalLink({
3182
3182
  }) {
3183
3183
  const ownerKind = relationKind(relation);
3184
3184
  const ownerName = relationName(relation);
3185
- const fail2 = (message) => {
3185
+ const fail3 = (message) => {
3186
3186
  throw new OrmDefinitionError(`${ownerKind} "${ownerName}": link "${linkName}" ${message}`, relation.file);
3187
3187
  };
3188
3188
  if (link.enforce && link.linkKind !== "toOne") {
3189
- return fail2("sets enforce: true, which is only supported on toOne links");
3189
+ return fail3("sets enforce: true, which is only supported on toOne links");
3190
3190
  }
3191
3191
  if ((link.onDelete !== void 0 || link.onUpdate !== void 0) && !link.enforce) {
3192
- return fail2("sets a referential action without enforce: true");
3192
+ return fail3("sets a referential action without enforce: true");
3193
3193
  }
3194
3194
  if (link.linkKind === "toPlatformUser") {
3195
- if (link.target !== void 0) return fail2("is toPlatformUser and must not declare a target table");
3195
+ if (link.target !== void 0) return fail3("is toPlatformUser and must not declare a target table");
3196
3196
  return {
3197
3197
  name: linkName,
3198
3198
  kind: "toPlatformUser",
@@ -3203,7 +3203,7 @@ function buildCanonicalLink({
3203
3203
  };
3204
3204
  }
3205
3205
  if (typeof link.target === "object" && link.target?.kind === "seq-external-object") {
3206
- if (link.enforce) return fail2("cannot enforce a cross-namespace physical foreign key; use an ORM link without enforce");
3206
+ if (link.enforce) return fail3("cannot enforce a cross-namespace physical foreign key; use an ORM link without enforce");
3207
3207
  return {
3208
3208
  name: linkName,
3209
3209
  kind: link.linkKind,
@@ -3215,13 +3215,13 @@ function buildCanonicalLink({
3215
3215
  ...link.description !== void 0 ? { description: link.description } : {}
3216
3216
  };
3217
3217
  }
3218
- const target = resolveRelationRef({ ref: link.target, fail: fail2 });
3218
+ const target = resolveRelationRef({ ref: link.target, fail: fail3 });
3219
3219
  const targetName = relationName(target);
3220
3220
  if (!relationsByName.has(targetName)) {
3221
- return fail2(`targets ${relationKind(target)} "${targetName}" which is not part of this namespace`);
3221
+ return fail3(`targets ${relationKind(target)} "${targetName}" which is not part of this namespace`);
3222
3222
  }
3223
3223
  if (link.enforce && (!isSeqTable(relation) || !isSeqTable(target))) {
3224
- return fail2("cannot enforce a PostgreSQL foreign key involving a view");
3224
+ return fail3("cannot enforce a PostgreSQL foreign key involving a view");
3225
3225
  }
3226
3226
  const owningSide = link.linkKind === "toOne" ? relation : target;
3227
3227
  const referencedSide = link.linkKind === "toOne" ? target : relation;
@@ -3237,19 +3237,19 @@ function buildCanonicalLink({
3237
3237
  ...link.description !== void 0 ? { description: link.description } : {}
3238
3238
  };
3239
3239
  }
3240
- function resolveRelationRef({ ref, fail: fail2 }) {
3241
- if (ref === void 0) return fail2("declares no target relation");
3240
+ function resolveRelationRef({ ref, fail: fail3 }) {
3241
+ if (ref === void 0) return fail3("declares no target relation");
3242
3242
  if (typeof ref !== "function") return ref;
3243
3243
  let resolved;
3244
3244
  try {
3245
3245
  resolved = ref();
3246
3246
  } catch (error) {
3247
- return fail2(
3247
+ return fail3(
3248
3248
  `target thunk threw (${error instanceof Error ? error.message : String(error)}) \u2014 lazy refs resolve at serialize time; make sure the target module ran`
3249
3249
  );
3250
3250
  }
3251
3251
  if (!isSeqTable(resolved) && !isSeqView(resolved)) {
3252
- return fail2("target thunk did not return a relation defined with defineTable/defineView");
3252
+ return fail3("target thunk did not return a relation defined with defineTable/defineView");
3253
3253
  }
3254
3254
  return resolved;
3255
3255
  }
@@ -4121,19 +4121,19 @@ function compileComparison(op, left, right, columnTypes) {
4121
4121
  }
4122
4122
  return `${compileOperand(left, right, columnTypes)} ${SQL_COMPARE_OPS[op]} ${compileOperand(right, left, columnTypes)}`;
4123
4123
  }
4124
- function compilePredicate(predicate, columnTypes) {
4124
+ function compilePredicate(predicate, columnTypes, options = {}) {
4125
4125
  switch (predicate.kind) {
4126
4126
  case "and":
4127
4127
  case "or": {
4128
- const joined = predicate.operands.map((operand) => compilePredicate(operand, columnTypes)).join(` ${predicate.kind.toUpperCase()} `);
4128
+ const joined = predicate.operands.map((operand) => compilePredicate(operand, columnTypes, options)).join(` ${predicate.kind.toUpperCase()} `);
4129
4129
  return `(${joined})`;
4130
4130
  }
4131
4131
  case "not":
4132
- return `(NOT ${compilePredicate(predicate.operand, columnTypes)})`;
4132
+ return `(NOT ${compilePredicate(predicate.operand, columnTypes, options)})`;
4133
4133
  case "compare":
4134
4134
  return `(${compileComparison(predicate.op, predicate.left, predicate.right, columnTypes)})`;
4135
4135
  case "capability":
4136
- return `(${capabilityExpression(predicate.key)})`;
4136
+ return `(${options.statementClaimChecks ? "SELECT " : ""}${capabilityExpression(predicate.key)})`;
4137
4137
  }
4138
4138
  }
4139
4139
 
@@ -4219,9 +4219,9 @@ function compilePredIrToSql(pred, options = {}) {
4219
4219
  case "cmp":
4220
4220
  return compileCmp(pred.op, pred.column, pred.value, options);
4221
4221
  case "capability":
4222
- return `(${capabilityExpression(pred.key, pred.namespace ?? options.namespace)})`;
4222
+ return `(${options.statementClaimChecks ? "SELECT " : ""}${capabilityExpression(pred.key, pred.namespace ?? options.namespace)})`;
4223
4223
  case "role":
4224
- return `(${roleExpression(pred.key, pred.namespace ?? options.namespace)})`;
4224
+ return `(${options.statementClaimChecks ? "SELECT " : ""}${roleExpression(pred.key, pred.namespace ?? options.namespace)})`;
4225
4225
  case "exists":
4226
4226
  if (options.exists) return options.exists(pred);
4227
4227
  throw new OrmDefinitionError("synced view read policy cannot use 'exists' without a relationship resolver");
@@ -4797,7 +4797,9 @@ function syncedViewStatements({
4797
4797
  columnNamesByTable,
4798
4798
  columnTypesByTable,
4799
4799
  executionOwnerRole = SYNCED_VIEW_EXECUTION_OWNER_ROLE,
4800
- backingPrivileges = "grant"
4800
+ backingPrivileges = "grant",
4801
+ viewPrivileges = "grant",
4802
+ statementClaimChecks = true
4801
4803
  }) {
4802
4804
  const schema = quoteIdentifier(ormSchemaName(definition.namespace));
4803
4805
  const role = quoteIdentifier(consumerRoleName(definition.namespace));
@@ -4840,9 +4842,10 @@ function syncedViewStatements({
4840
4842
  const readPolicy = table.policies?.read;
4841
4843
  const policyClause = readPolicyIr ? ` WHERE ${compilePredIrToSql(readPolicyIr, {
4842
4844
  namespace: definition.namespace,
4845
+ statementClaimChecks,
4843
4846
  columnTypes,
4844
4847
  columnNames: columnNamesByTable?.get(table.table)
4845
- })}` : readPolicy ? ` WHERE ${compilePredicate(readPolicy.ast, narrowToV1ColumnTypes(columnTypes))}` : " WHERE false";
4848
+ })}` : readPolicy ? ` WHERE ${compilePredicate(readPolicy.ast, narrowToV1ColumnTypes(columnTypes), { statementClaimChecks })}` : " WHERE false";
4846
4849
  if (backingPrivileges === "grant") {
4847
4850
  const selectPrivilege = backing.selectColumns ? `SELECT (${backing.selectColumns.map(quoteIdentifier).join(", ")})` : "SELECT";
4848
4851
  const hasSelectPrivilege = backing.selectColumns ? backing.selectColumns.map((column) => `pg_catalog.has_column_privilege(${quoteLiteral(executionOwnerRole)}, ${quoteLiteral(physicalTarget)}, ${quoteLiteral(column)}, 'SELECT')`).join("\n AND ") : `pg_catalog.has_table_privilege(${quoteLiteral(executionOwnerRole)}, ${quoteLiteral(physicalTarget)}, 'SELECT')`;
@@ -4859,7 +4862,7 @@ END`)}`);
4859
4862
  statements.push(
4860
4863
  `CREATE OR REPLACE VIEW ${viewName} AS SELECT ${projection} FROM ${physicalTarget}${whereClause}`
4861
4864
  );
4862
- statements.push(`GRANT SELECT ON ${viewName} TO ${role}`);
4865
+ if (viewPrivileges === "grant") statements.push(`GRANT SELECT ON ${viewName} TO ${role}`);
4863
4866
  }
4864
4867
  return statements;
4865
4868
  }
@@ -5197,15 +5200,15 @@ var sqlValues = /* @__PURE__ */ new Set([
5197
5200
  async function validateManagedViewQueries({ canonical }) {
5198
5201
  for (const definition of [canonical, ...canonical.imports ?? []]) {
5199
5202
  for (const view of definition.views ?? []) {
5200
- const fail2 = (message) => {
5203
+ const fail3 = (message) => {
5201
5204
  throw new OrmDefinitionError(`managed view '${definition.namespace}/${view.view}': ${message}`);
5202
5205
  };
5203
5206
  parser ??= new PgParser({ version: 17 });
5204
5207
  const parsed = await parser.parse(view.query);
5205
- if (parsed.error || !parsed.tree) fail2("invalid SELECT query");
5208
+ if (parsed.error || !parsed.tree) fail3("invalid SELECT query");
5206
5209
  const statements = list(obj(parsed.tree).stmts);
5207
- if (statements.length !== 1 || !obj(obj(statements[0]).stmt).SelectStmt) fail2("one SELECT query is required");
5208
- validateTree({ tree: parsed.tree, schema: ormSchemaName(definition.namespace), enums: definition.enums.map((entry) => entry.name), fail: fail2 });
5210
+ if (statements.length !== 1 || !obj(obj(statements[0]).stmt).SelectStmt) fail3("one SELECT query is required");
5211
+ validateTree({ tree: parsed.tree, schema: ormSchemaName(definition.namespace), enums: definition.enums.map((entry) => entry.name), fail: fail3 });
5209
5212
  }
5210
5213
  }
5211
5214
  }
@@ -5234,29 +5237,29 @@ function validateTree({ tree, ...scope }) {
5234
5237
  }
5235
5238
  }
5236
5239
  function validateNode({ kind, child, scope }) {
5237
- const { fail: fail2 } = scope;
5238
- if (kind.endsWith("Stmt") && kind !== "SelectStmt") fail2("only SELECT statements are permitted");
5240
+ const { fail: fail3 } = scope;
5241
+ if (kind.endsWith("Stmt") && kind !== "SelectStmt") fail3("only SELECT statements are permitted");
5239
5242
  if (kind === "FuncCall") {
5240
5243
  const call = obj(child);
5241
5244
  const parts = strings(call.funcname);
5242
5245
  const name2 = reviewedFunctionName({ parts, format: call.funcformat });
5243
- if (!name2 || !functions.has(name2)) fail2(`only explicitly allowlisted pg_catalog functions are permitted (found '${parts.join(".")}')`);
5246
+ if (!name2 || !functions.has(name2)) fail3(`only explicitly allowlisted pg_catalog functions are permitted (found '${parts.join(".")}')`);
5244
5247
  }
5245
5248
  if (kind === "typeName" || kind === "TypeName") validateType({ node: obj(child), ...scope });
5246
- if (kind === "A_Expr" && pgCatalogName(strings(obj(child).name)) === void 0) fail2("only pg_catalog operators are permitted");
5247
- if (kind === "SortBy" && list(obj(child).useOp).length && pgCatalogName(strings(obj(child).useOp)) === void 0) fail2("only pg_catalog sort operators are permitted");
5248
- if (kind === "SQLValueFunction" && !sqlValues.has(String(obj(child).op))) fail2("unsupported SQL value expression");
5249
- if (kind === "ParamRef") fail2("view queries cannot contain parameters");
5249
+ if (kind === "A_Expr" && pgCatalogName(strings(obj(child).name)) === void 0) fail3("only pg_catalog operators are permitted");
5250
+ if (kind === "SortBy" && list(obj(child).useOp).length && pgCatalogName(strings(obj(child).useOp)) === void 0) fail3("only pg_catalog sort operators are permitted");
5251
+ if (kind === "SQLValueFunction" && !sqlValues.has(String(obj(child).op))) fail3("unsupported SQL value expression");
5252
+ if (kind === "ParamRef") fail3("view queries cannot contain parameters");
5250
5253
  if (kind === "A_Indirection" && list(obj(child).indirection).some((entry) => !obj(entry).A_Indices)) {
5251
- fail2("composite field notation is not permitted in managed views");
5254
+ fail3("composite field notation is not permitted in managed views");
5252
5255
  }
5253
5256
  }
5254
- function validateType({ node, schema, enums, fail: fail2 }) {
5257
+ function validateType({ node, schema, enums, fail: fail3 }) {
5255
5258
  const parts = strings(node.names);
5256
5259
  const builtin = pgCatalogName(parts);
5257
5260
  const managedEnum = parts.length === 1 && enums.includes(parts[0]) || parts.length === 2 && parts[0] === schema && enums.includes(parts[1]);
5258
5261
  if (node.setof || node.pct_type || !managedEnum && (!builtin || !scalarTypes.has(builtin))) {
5259
- fail2(`casts may only use supported pg_catalog scalar types or declared enums (found '${parts.join(".")}')`);
5262
+ fail3(`casts may only use supported pg_catalog scalar types or declared enums (found '${parts.join(".")}')`);
5260
5263
  }
5261
5264
  }
5262
5265
 
@@ -6468,6 +6471,118 @@ async function guardedRun(run) {
6468
6471
  process.exit = originalExit;
6469
6472
  }
6470
6473
  }
6474
+ var parser2;
6475
+ var locations = /* @__PURE__ */ new Set(["location", "stmt_location", "stmt_len"]);
6476
+ async function assertSyncedViewDefinitionMatches({
6477
+ viewDefinition,
6478
+ expectedCreateStatements
6479
+ }) {
6480
+ if (!expectedCreateStatements.length) fail2();
6481
+ const expected = [];
6482
+ for (const statement of expectedCreateStatements) {
6483
+ const node = await parseStatement(statement);
6484
+ const view = obj(node.ViewStmt);
6485
+ requireKeys(view, ["view", "query", "replace", "withCheckOption"]);
6486
+ if (view.replace !== true || view.withCheckOption !== "NO_CHECK_OPTION") fail2();
6487
+ backingOf(obj(view.view));
6488
+ expected.push(canonicalSelect(obj(obj(view.query).SelectStmt)));
6489
+ }
6490
+ const actual = await parseStatement(viewDefinition);
6491
+ if (!expected.includes(canonicalSelect(obj(actual.SelectStmt)))) fail2();
6492
+ }
6493
+ function fail2() {
6494
+ throw new OrmDefinitionError("synced view definition does not match the compiler");
6495
+ }
6496
+ async function parseStatement(sql7) {
6497
+ if (!sql7.length || sql7.length > 262144) fail2();
6498
+ parser2 ??= new PgParser({ version: 17 });
6499
+ const parsed = await parser2.parse(sql7);
6500
+ if (parsed.error || !parsed.tree) fail2();
6501
+ const statements = list(obj(parsed.tree).stmts);
6502
+ if (statements.length !== 1) fail2();
6503
+ return obj(obj(statements[0]).stmt);
6504
+ }
6505
+ function requireKeys(node, allowed) {
6506
+ for (const key of Object.keys(node)) if (!locations.has(key) && !allowed.includes(key)) fail2();
6507
+ }
6508
+ function backingOf(node) {
6509
+ requireKeys(node, ["catalogname", "schemaname", "relname", "inh", "relpersistence"]);
6510
+ if (node.catalogname !== "" || node.inh !== true || node.relpersistence !== "p") fail2();
6511
+ const schema = str(node.schemaname);
6512
+ const relation = str(node.relname);
6513
+ if (!schema || !relation) fail2();
6514
+ return { schema, relation };
6515
+ }
6516
+ function validateSelect(select, scalar2) {
6517
+ requireKeys(select, ["targetList", "fromClause", "whereClause", "groupDistinct", "limitOption", "op", "all"]);
6518
+ if (select.groupDistinct !== false || select.limitOption !== "LIMIT_OPTION_DEFAULT" || select.op !== "SETOP_NONE" || select.all !== false) fail2();
6519
+ if (scalar2 && (list(select.fromClause).length || select.whereClause !== void 0 || list(select.targetList).length !== 1)) fail2();
6520
+ }
6521
+ function canonicalSelect(select) {
6522
+ validateSelect(select, false);
6523
+ const from = list(select.fromClause);
6524
+ if (from.length !== 1) fail2();
6525
+ const backing = backingOf(obj(obj(from[0]).RangeVar));
6526
+ const targets = list(select.targetList);
6527
+ if (!targets.length) fail2();
6528
+ for (const target of targets) {
6529
+ const node = obj(obj(target).ResTarget);
6530
+ requireKeys(node, ["name", "val"]);
6531
+ if (node.name !== "" || !obj(node.val).ColumnRef) fail2();
6532
+ }
6533
+ return JSON.stringify(normalize({ value: select, backing, scalar: false }));
6534
+ }
6535
+ function normalize({ value, backing, scalar: scalar2 }) {
6536
+ if (Array.isArray(value)) return value.map((entry) => normalize({ value: entry, backing, scalar: scalar2 }));
6537
+ if (!value || typeof value !== "object") return value;
6538
+ const node = obj(value);
6539
+ if (node.ColumnRef) return normalizeColumnRef({ ref: obj(node.ColumnRef), backing, scalar: scalar2 });
6540
+ if (node.TypeCast && isLiteralTextCast(obj(node.TypeCast))) {
6541
+ return normalize({ value: obj(node.TypeCast).arg, backing, scalar: scalar2 });
6542
+ }
6543
+ if (node.SubLink) return normalizeScalarSubLink({ sublink: obj(node.SubLink), backing });
6544
+ const result = {};
6545
+ for (const key of Object.keys(node).sort()) {
6546
+ if (locations.has(key)) continue;
6547
+ if (key === "ParamRef" || key === "RangeSubselect" || key === "JoinExpr" || key.endsWith("Stmt") && key !== "SelectStmt" || scalar2 && key === "RangeVar") fail2();
6548
+ result[key] = normalize({ value: node[key], backing, scalar: scalar2 });
6549
+ }
6550
+ return result;
6551
+ }
6552
+ function normalizeColumnRef({ ref, backing, scalar: scalar2 }) {
6553
+ if (scalar2) fail2();
6554
+ requireKeys(ref, ["fields"]);
6555
+ const fields = strings(ref.fields);
6556
+ const qualified = fields.length === 2 && fields[0] === backing.relation || fields.length === 3 && fields[0] === backing.schema && fields[1] === backing.relation;
6557
+ if (fields.length !== 1 && !qualified) fail2();
6558
+ const column = fields.at(-1);
6559
+ if (!column) fail2();
6560
+ return { ColumnRef: { fields: [{ String: { sval: column } }] } };
6561
+ }
6562
+ function normalizeScalarSubLink({ sublink, backing }) {
6563
+ requireKeys(sublink, ["subLinkType", "subLinkId", "subselect"]);
6564
+ if (sublink.subLinkType !== "EXPR_SUBLINK" || sublink.subLinkId !== 0) fail2();
6565
+ const select = obj(obj(sublink.subselect).SelectStmt);
6566
+ validateSelect(select, true);
6567
+ const target = obj(obj(list(select.targetList)[0]).ResTarget);
6568
+ requireKeys(target, ["name", "val"]);
6569
+ const normalizedSelect = { ...select, targetList: [{ ResTarget: { ...target, name: "" } }] };
6570
+ return { SubLink: normalize({ value: { ...sublink, subselect: { SelectStmt: normalizedSelect } }, backing, scalar: true }) };
6571
+ }
6572
+ function isLiteralTextCast(cast) {
6573
+ requireKeys(cast, ["arg", "typeName"]);
6574
+ const arg = obj(cast.arg);
6575
+ if (!arg.A_Const) return false;
6576
+ const constant = obj(arg.A_Const);
6577
+ if (constant.isnull !== false || !constant.sval || typeof obj(constant.sval).sval !== "string") return false;
6578
+ const type = obj(cast.typeName);
6579
+ const names = strings(type.names);
6580
+ if (!(names.length === 1 && names[0] === "text" || names.length === 2 && names[0] === "pg_catalog" && names[1] === "text")) return false;
6581
+ if (list(type.arrayBounds).length || list(type.typmods).length) return false;
6582
+ requireKeys(type, ["names", "typeOid", "setof", "pct_type", "typemod"]);
6583
+ if (type.typeOid !== 0 || type.setof !== false || type.pct_type !== false || type.typemod !== -1) return false;
6584
+ return true;
6585
+ }
6471
6586
 
6472
6587
  // src/engine/index.ts
6473
6588
  var STATEMENT_KINDS = ["hint", "ddl", "security", "function", "synced_view"];
@@ -6537,6 +6652,11 @@ function renderOrmMigrationExport(exported) {
6537
6652
  if (Buffer.byteLength(text4, "utf8") > ORM_MIGRATION_EXPORT_MAX_BYTES) throw new Error("ORM migration export exceeds the size limit");
6538
6653
  return text4;
6539
6654
  }
6655
+
6656
+ // src/client/sql.ts
6657
+ var BUILTIN_SQL_READ_HASH = "sha256:a50c477c952a5e0fe68ed158a4530e4aab573c09bcbb1a8ac454dc88a39a6258";
6658
+
6659
+ // src/ir/index.ts
6540
6660
  var IR_VERSION = 5;
6541
6661
  var LEGACY_IR_VERSION = 1;
6542
6662
  var GUARDED_IR_VERSION = 2;
@@ -6869,7 +6989,8 @@ var compiledOperationSchema = z.object({
6869
6989
  }).superRefine((operation, ctx) => {
6870
6990
  if (operation.language === "sql") {
6871
6991
  const validPlan = operation.sqlQuery ? !operation.sql && operation.irVersion === RUNTIME_SQL_IR_VERSION : !!operation.sql && operation.irVersion === SQL_IR_VERSION;
6872
- if (!validPlan || operation.kind !== "query" || operation.roots.length !== 0 || !operation.requires?.capability) {
6992
+ const builtin = operation.name === "BuiltinSqlRead" && operation.opHash === BUILTIN_SQL_READ_HASH && operation.requires === null;
6993
+ if (!validPlan || operation.kind !== "query" || operation.roots.length !== 0 || !builtin && !operation.requires?.capability) {
6873
6994
  ctx.addIssue({ code: "custom", message: "SQL operations require a query-only v4 plan or v5 runtime contract, capability, and no GraphQL roots" });
6874
6995
  }
6875
6996
  } else if (operation.sql || operation.sqlQuery || operation.roots.length === 0) {
@@ -8240,6 +8361,6 @@ function resumeArguments({
8240
8361
  return [literal2.sql];
8241
8362
  }
8242
8363
 
8243
- 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, 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, 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, validateNamespaceCatalog, validateViewCatalogStatement, valueIrSchema, variableDefaultIrSchema, variableIrSchema, verifyRebaseIsNoop, walkPredicate, writeMigration };
8364
+ 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, 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, validateNamespaceCatalog, validateViewCatalogStatement, valueIrSchema, variableDefaultIrSchema, variableIrSchema, verifyRebaseIsNoop, walkPredicate, writeMigration };
8244
8365
  //# sourceMappingURL=index.js.map
8245
8366
  //# sourceMappingURL=index.js.map