qubu 0.6.1 → 0.6.2

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 (84) hide show
  1. package/dist/{complete-DP7pliuY.mjs → canonical-B5_ouh-c.mjs} +466 -241
  2. package/dist/codegen.d.mts +2 -2
  3. package/dist/codegen.mjs +180 -90
  4. package/dist/column-Cyc2CMnG.mjs +116 -0
  5. package/dist/column-DDRvD7SF.mjs +721 -0
  6. package/dist/{constraints-DM_tarXc.mjs → constraints-CAmi18Uk.mjs} +8 -3
  7. package/dist/core.d.mts +3 -3
  8. package/dist/core.mjs +4 -4
  9. package/dist/diff.d.mts +9 -9
  10. package/dist/diff.mjs +152 -102
  11. package/dist/{explain-CkIK13L_.mjs → explain-BIqEmZha.mjs} +1 -1
  12. package/dist/{expressions-BCjc08zw.mjs → expressions-_6JF_J77.mjs} +2 -1
  13. package/dist/index-CaxrMD1A.d.mts +1 -0
  14. package/dist/index.d.mts +2 -2
  15. package/dist/index.mjs +368 -74
  16. package/dist/introspection/mysql.d.mts +1 -1
  17. package/dist/introspection/mysql.mjs +156 -23
  18. package/dist/introspection/postgres.d.mts +6 -3
  19. package/dist/introspection/postgres.mjs +388 -53
  20. package/dist/introspection/sqlite.d.mts +1 -1
  21. package/dist/introspection/sqlite.mjs +198 -12
  22. package/dist/introspection.d.mts +26 -12
  23. package/dist/introspection.mjs +2 -672
  24. package/dist/mysql.d.mts +3 -3
  25. package/dist/mysql.mjs +6 -5
  26. package/dist/{errors-Dxv73YJu.mjs → omit-VEr9Ydux.mjs} +5 -1
  27. package/dist/{on-conflict-CnaY5qso.mjs → on-conflict-B2rFyHGF.mjs} +6 -8
  28. package/dist/on-duplicate-key-update-Czsw1Yq-.mjs +95 -0
  29. package/dist/{postgres-Dey7QXPL.mjs → postgres-hFhd0I9n.mjs} +4 -5
  30. package/dist/postgres.d.mts +2 -2
  31. package/dist/postgres.mjs +2 -2
  32. package/dist/{registry-oWDiqD7i.mjs → registry-BXE_4M9P.mjs} +1 -1
  33. package/dist/{relational-DSAJ-l58.mjs → relational-CoPBETjI.mjs} +3 -2
  34. package/dist/schema.d.mts +2 -2
  35. package/dist/schema.mjs +8 -8
  36. package/dist/{serialize-CE-gw5_s.mjs → serialize-CyobNEx-.mjs} +174 -30
  37. package/dist/serialize-Du2UPZMt.d.mts +92 -0
  38. package/dist/snapshot/mysql.d.mts +5 -5
  39. package/dist/snapshot/mysql.mjs +8 -8
  40. package/dist/snapshot/postgres.d.mts +3 -3
  41. package/dist/snapshot/postgres.mjs +9 -9
  42. package/dist/snapshot/sqlite.d.mts +3 -3
  43. package/dist/snapshot/sqlite.mjs +7 -7
  44. package/dist/snapshot-mIb-Zzb5.mjs +1489 -0
  45. package/dist/snapshot.d.mts +4 -5
  46. package/dist/snapshot.mjs +3 -4
  47. package/dist/{source-BDuUXmAk.mjs → source-DYSUqzvb.mjs} +2 -2
  48. package/dist/sqlite.d.mts +2 -2
  49. package/dist/sqlite.mjs +6 -6
  50. package/dist/{table-C1QGNe4P.mjs → table-B8zEq0az.mjs} +4 -4
  51. package/dist/{types-BLNRatG_.mjs → types-CYHpSPwj.mjs} +10 -5
  52. package/dist/{types-BEn0N_al.d.mts → types-CiMvKi5V.d.mts} +14 -4
  53. package/dist/{types-DUe6eeI0.d.mts → types-Dqr4o2I1.d.mts} +590 -168
  54. package/dist/value-CpaUFtjw.mjs +45 -0
  55. package/dist/vite/ambient.d.ts +2 -0
  56. package/dist/vite.d.mts +1 -1
  57. package/dist/vite.mjs +2 -0
  58. package/docs/dialects-and-execution.md +61 -11
  59. package/docs/getting-started.md +1 -1
  60. package/docs/guides/extensions/typed-expressions.md +5 -3
  61. package/docs/guides/json.md +95 -2
  62. package/docs/guides/mutations.md +36 -0
  63. package/docs/index.md +1 -1
  64. package/docs/migrations/adapters.md +58 -21
  65. package/docs/migrations/recovery.md +7 -1
  66. package/docs/query-model/fragments.md +21 -1
  67. package/docs/reference/introspection-support.md +16 -18
  68. package/docs/reference/supported-surface.md +8 -7
  69. package/docs/schema/catalog-model.md +20 -7
  70. package/docs/schema/code-generation.md +1 -1
  71. package/docs/schema/diff.md +2 -2
  72. package/docs/schema/introspection.md +21 -14
  73. package/docs/schema/snapshots.md +18 -8
  74. package/docs/schema/storage-and-schema-sql.md +7 -2
  75. package/package.json +2 -1
  76. package/dist/canonical-DMvR9yBe.mjs +0 -972
  77. package/dist/column-BzN8KFJa.mjs +0 -364
  78. package/dist/column-CFvSbil0.mjs +0 -309
  79. package/dist/complete-types-CNMWBWap.d.mts +0 -371
  80. package/dist/index-CGui70hi.d.mts +0 -32
  81. package/dist/json-Db7XRD91.mjs +0 -169
  82. package/dist/omit-OxV58AwX.mjs +0 -5
  83. package/dist/serialize-OvXCLzjm.d.mts +0 -66
  84. package/dist/snapshot-DgsOhf_8.mjs +0 -354
@@ -1,4 +1,4 @@
1
- import { kt as CatalogConnection, st as IntrospectionCatalog, ut as IntrospectionOptions } from "../types-BEn0N_al.mjs";
1
+ import { ft as IntrospectionOptions, jt as CatalogConnection, lt as IntrospectionCatalog } from "../types-CiMvKi5V.mjs";
2
2
  //#region src/introspection/sqlite.d.ts
3
3
  declare const sqliteServerQuery = "SELECT sqlite_version() AS version, sqlite_source_id() AS source_id";
4
4
  declare const sqliteDatabaseListQuery = "\n SELECT seq, name, file\n FROM pragma_database_list()\n ORDER BY seq\n";
@@ -83,6 +83,7 @@ async function readCatalog(connection, options) {
83
83
  const tableRows = await query(connection, sqliteTableListQuery, [options.namespace], options, diagnostics, "table-list");
84
84
  const tableSql = new Map(schemaRows.map((row) => [text(row.name), text(row.sql)]).filter((entry) => entry[0] !== void 0));
85
85
  const tables = tableRows.filter((row) => normalizeType(row.type) === "table").map((row) => table(row, tableSql.get(text(row.name) ?? "") ?? void 0, options.namespace));
86
+ const tableByName = new Map(tables.map((currentTable) => [currentTable.physicalName, currentTable]));
86
87
  const deferredObjects = [];
87
88
  const opaqueObjects = [];
88
89
  for (const row of tableRows) {
@@ -141,7 +142,11 @@ async function readCatalog(connection, options) {
141
142
  const rowidPrimaryKey = rows.filter((row) => (number(row.pk) ?? 0) > 0).length === 1;
142
143
  const columns = rows.filter((row) => number(row.hidden) !== 1).map((row) => column(row, currentTable, options.namespace, sqlText, rowidPrimaryKey, diagnostics));
143
144
  currentTable.columns = columns;
144
- currentTable.constraints = tableConstraints(currentTable, rows, columns, sqlText, options.namespace);
145
+ currentTable.constraints = tableConstraints(currentTable, rows, columns, sqlText, options.namespace, diagnostics, opaqueObjects);
146
+ }
147
+ for (const currentTable of tables) {
148
+ const tableName = currentTable.physicalName;
149
+ const sqlText = tableSql.get(tableName);
145
150
  const indexRows = await query(connection, sqliteIndexListQuery, [tableName, options.namespace], options, diagnostics, `index-list:${tableName}`);
146
151
  const mappedIndexes = [];
147
152
  const mappedConstraints = [...currentTable.constraints];
@@ -154,7 +159,8 @@ async function readCatalog(connection, options) {
154
159
  else mappedConstraints.push(index);
155
160
  }
156
161
  const foreignRows = await query(connection, sqliteForeignKeyQuery, [tableName, options.namespace], options, diagnostics, `foreign-key:${tableName}`);
157
- mappedConstraints.push(...foreignKeys(currentTable, foreignRows, options.namespace));
162
+ for (const value of foreignKeys(currentTable, foreignRows, tableByName, options.namespace, diagnostics)) if (value.kind === "opaque-object") opaqueObjects.push(value);
163
+ else mappedConstraints.push(value);
158
164
  currentTable.indexes = mappedIndexes;
159
165
  currentTable.constraints = mappedConstraints;
160
166
  }
@@ -691,7 +697,7 @@ function column(row, table, namespace, sqlText, rowidPrimaryKey, diagnostics) {
691
697
  id: stableId(physicalName),
692
698
  identitySource: "physical-name",
693
699
  physicalName,
694
- ordinalPosition: number(row.cid) ?? 0,
700
+ ordinalPosition: (number(row.cid) ?? 0) + 1,
695
701
  nullable: !boolean(row.not_null) && !(rowid || (number(row.pk) ?? 0) > 0 && (/WITHOUT\s+ROWID/i.test(sqlText ?? "") || /\bSTRICT\b/i.test(sqlText ?? ""))),
696
702
  storage: { nativeType: type || "BLOB" },
697
703
  default: defaultValue !== void 0 && !generatedExpression ? {
@@ -712,7 +718,7 @@ function column(row, table, namespace, sqlText, rowidPrimaryKey, diagnostics) {
712
718
  })
713
719
  };
714
720
  }
715
- function tableConstraints(table, rows, columns, sqlText, namespace) {
721
+ function tableConstraints(table, rows, columns, sqlText, namespace, diagnostics, opaqueObjects) {
716
722
  const primaryNames = new Map(rows.filter((row) => (number(row.pk) ?? 0) > 0).map((row) => [text(row.name), number(row.pk) ?? 0]));
717
723
  const primaryColumns = columns.filter((column) => primaryNames.has(column.physicalName)).sort((left, right) => primaryNames.get(left.physicalName) - primaryNames.get(right.physicalName));
718
724
  const constraints = [];
@@ -730,20 +736,142 @@ function tableConstraints(table, rows, columns, sqlText, namespace) {
730
736
  };
731
737
  constraints.push(primary);
732
738
  }
733
- [...sqlText?.matchAll(/(?:CONSTRAINT\s+("(?:[^"]|"")*"|`[^`]*`|\[[^\]]*\]|[A-Za-z_][A-Za-z0-9_$]*)\s+)?CHECK\s*\(([^()]*(?:\([^()]*\)[^()]*)*)\)/gi) ?? []].forEach((match, index) => {
734
- const name = unquoteIdentifier(match[1]) ?? `check_${index}_${table.physicalName}`;
739
+ const checkResult = checkExpressions(sqlText);
740
+ checkResult.values.forEach((checkValue, index) => {
741
+ const name = checkValue.name ?? `check_${index}_${table.physicalName}`;
735
742
  const check = {
736
743
  kind: "check",
737
744
  id: stableId(name),
738
745
  identitySource: "deterministic-fallback",
739
746
  physicalName: name,
740
- expression: sql(match[2] ?? "true", namespace, table, name),
747
+ expression: sql(checkValue.expression, namespace, table, name),
741
748
  dialect: extension({ source: "create-sql" })
742
749
  };
743
750
  constraints.push(check);
744
751
  });
752
+ if (checkResult.unrecoverable) {
753
+ const name = checkResult.unrecoverableName ?? `check_${checkResult.values.length}_${table.physicalName}`;
754
+ diagnostics.push(createIntrospectionDiagnostic({
755
+ severity: "error",
756
+ code: "expression-parse-failed",
757
+ message: `SQLite CHECK constraint ${name} could not be recovered from CREATE TABLE SQL`,
758
+ path: [
759
+ table.id,
760
+ "constraints",
761
+ name
762
+ ],
763
+ physicalReference: reference("opaque-object", name, namespace, "sqlite_schema", "name"),
764
+ remediation: "Preserve the complete CREATE TABLE SQL or use lossy mode."
765
+ }));
766
+ opaqueObjects.push(opaqueCheckConstraint(table, name, sqlText, namespace));
767
+ }
745
768
  return constraints;
746
769
  }
770
+ function checkExpressions(sqlText) {
771
+ if (!sqlText) return {
772
+ values: [],
773
+ unrecoverable: false
774
+ };
775
+ const values = [];
776
+ let offset = 0;
777
+ while (offset < sqlText.length) {
778
+ const checkIndex = findSqlKeyword(sqlText, "CHECK", offset);
779
+ if (checkIndex < 0) return {
780
+ values,
781
+ unrecoverable: false
782
+ };
783
+ let open = checkIndex + 5;
784
+ while (/\s/.test(sqlText[open] ?? "")) open++;
785
+ if (sqlText[open] !== "(") {
786
+ offset = checkIndex + 5;
787
+ continue;
788
+ }
789
+ const close = matchingParen(sqlText, open);
790
+ if (close < 0) return {
791
+ values,
792
+ unrecoverable: true,
793
+ unrecoverableName: checkConstraintName(sqlText, checkIndex)
794
+ };
795
+ values.push({
796
+ name: checkConstraintName(sqlText, checkIndex),
797
+ expression: sqlText.slice(open + 1, close).trim()
798
+ });
799
+ offset = close + 1;
800
+ }
801
+ return {
802
+ values,
803
+ unrecoverable: false
804
+ };
805
+ }
806
+ function findSqlKeyword(source, keyword, start) {
807
+ let quote;
808
+ for (let index = start; index < source.length; index++) {
809
+ const character = source[index];
810
+ if (quote === "single") {
811
+ if (character === "'" && source[index + 1] === "'") index++;
812
+ else if (character === "'") quote = void 0;
813
+ continue;
814
+ }
815
+ if (quote === "double") {
816
+ if (character === "\"" && source[index + 1] === "\"") index++;
817
+ else if (character === "\"") quote = void 0;
818
+ continue;
819
+ }
820
+ if (quote === "backtick") {
821
+ if (character === "`") quote = void 0;
822
+ continue;
823
+ }
824
+ if (quote === "bracket") {
825
+ if (character === "]") quote = void 0;
826
+ continue;
827
+ }
828
+ if (character === "'") {
829
+ quote = "single";
830
+ continue;
831
+ }
832
+ if (character === "\"") {
833
+ quote = "double";
834
+ continue;
835
+ }
836
+ if (character === "`") {
837
+ quote = "backtick";
838
+ continue;
839
+ }
840
+ if (character === "[") {
841
+ quote = "bracket";
842
+ continue;
843
+ }
844
+ if (source.slice(index, index + keyword.length).toUpperCase() === keyword.toUpperCase() && !isSqlIdentifierCharacter(source[index - 1]) && !isSqlIdentifierCharacter(source[index + keyword.length])) return index;
845
+ }
846
+ return -1;
847
+ }
848
+ function isSqlIdentifierCharacter(value) {
849
+ return value !== void 0 && /[A-Za-z0-9_$]/.test(value);
850
+ }
851
+ function checkConstraintName(source, checkIndex) {
852
+ return unquoteIdentifier(source.slice(0, checkIndex).match(/CONSTRAINT\s+("(?:[^"]|"")*"|`[^`]*`|\[[^\]]*\]|[A-Za-z_][A-Za-z0-9_$]*)\s*$/i)?.[1]);
853
+ }
854
+ function opaqueCheckConstraint(table, constraintName, sqlText, namespace) {
855
+ const physicalReference = reference("opaque-object", constraintName, namespace, "sqlite_schema", "name", table.physicalName);
856
+ return {
857
+ kind: "opaque-object",
858
+ id: stableId(`check:${table.physicalName}:${constraintName}`),
859
+ identitySource: "deterministic-fallback",
860
+ objectKind: "check-constraint",
861
+ physicalName: constraintName,
862
+ data: {
863
+ table: table.physicalName,
864
+ reason: "definition-unavailable"
865
+ },
866
+ ...sqlText === void 0 ? {} : { sql: sql(sqlText, namespace, table, constraintName) },
867
+ reference: physicalReference,
868
+ provenance: {
869
+ kind: "catalog",
870
+ dialect: "sqlite",
871
+ reference: physicalReference
872
+ }
873
+ };
874
+ }
747
875
  function mapIndex(table, row, infoRows, sqlText, namespace, diagnostics, opaqueObjects) {
748
876
  const physicalName = text(row.name);
749
877
  if (!physicalName) return;
@@ -848,7 +976,7 @@ function declaredConstraintName(sqlText, keyword, columns) {
848
976
  if (found.length === columns.length && found.every((value, index) => value === columns[index])) return unquoteIdentifier(match[1]);
849
977
  }
850
978
  }
851
- function foreignKeys(table, rows, namespace) {
979
+ function foreignKeys(table, rows, tables, namespace, diagnostics) {
852
980
  const grouped = /* @__PURE__ */ new Map();
853
981
  for (const row of rows) {
854
982
  const id = text(row.id) ?? "0";
@@ -857,17 +985,53 @@ function foreignKeys(table, rows, namespace) {
857
985
  grouped.set(id, group);
858
986
  }
859
987
  return [...grouped.entries()].map(([key, group]) => {
860
- const first = group[0];
988
+ const ordered = [...group].sort((left, right) => (number(left.seq) ?? 0) - (number(right.seq) ?? 0));
989
+ const first = ordered[0];
861
990
  const physicalName = `foreign_key_${table.physicalName}_${key}`;
991
+ const targetTableName = text(first.target_table);
992
+ const targetTable = targetTableName === void 0 ? void 0 : tables.get(targetTableName);
993
+ const targetColumns = ordered.map((row) => text(row.target_column));
994
+ const sourceColumns = ordered.map((row) => text(row.source_column));
995
+ const explicitTargetColumns = targetColumns.every((column) => column !== void 0);
996
+ const implicitTargetColumns = targetColumns.every((column) => column === void 0);
997
+ let normalizedTargetColumns;
998
+ let problem;
999
+ if (targetTableName === void 0) problem = "has no referenced table";
1000
+ else if (targetTable === void 0) problem = `references table ${targetTableName}, which is not visible`;
1001
+ else if (implicitTargetColumns) {
1002
+ const primaryKey = targetTable.constraints.find((constraint) => constraint.kind === "primary-key");
1003
+ if (primaryKey === void 0) problem = `references ${targetTableName} without target columns, but that table has no declared primary key`;
1004
+ else if (primaryKey.columns.length !== ordered.length) problem = `references ${targetTableName} without target columns with an incompatible primary-key width`;
1005
+ else normalizedTargetColumns = primaryKey.columns;
1006
+ } else if (explicitTargetColumns) normalizedTargetColumns = targetColumns;
1007
+ else problem = "has a mixture of explicit and implicit target columns";
1008
+ if (sourceColumns.some((column) => column === void 0)) problem = problem ?? "has an unresolved source column";
1009
+ const physicalReference = reference("opaque-object", physicalName, namespace, "pragma_foreign_key_list", "id", key);
1010
+ if (problem !== void 0 || targetTableName === void 0 || normalizedTargetColumns === void 0) {
1011
+ diagnostics.push(createIntrospectionDiagnostic({
1012
+ severity: "error",
1013
+ code: "unresolved-reference",
1014
+ message: `SQLite foreign key ${physicalName} ${problem ?? "has no recoverable target columns"}`,
1015
+ path: [
1016
+ table.id,
1017
+ "constraints",
1018
+ physicalName,
1019
+ "target"
1020
+ ],
1021
+ physicalReference,
1022
+ remediation: "Declare explicit target columns or expose the referenced table primary key."
1023
+ }));
1024
+ return opaqueForeignKey(table, physicalName, key, targetTableName, sourceColumns, targetColumns, physicalReference);
1025
+ }
862
1026
  return {
863
1027
  kind: "foreign-key",
864
1028
  id: stableId(physicalName),
865
1029
  identitySource: "deterministic-fallback",
866
1030
  physicalName,
867
- columns: group.sort((left, right) => (number(left.seq) ?? 0) - (number(right.seq) ?? 0)).map((row) => text(row.source_column) ?? "unknown"),
1031
+ columns: sourceColumns,
868
1032
  target: {
869
- table: text(first.target_table) ?? "unknown",
870
- columns: group.map((row) => text(row.target_column) ?? "unknown")
1033
+ table: targetTableName,
1034
+ columns: normalizedTargetColumns
871
1035
  },
872
1036
  onUpdate: action(first.on_update),
873
1037
  onDelete: action(first.on_delete),
@@ -877,6 +1041,28 @@ function foreignKeys(table, rows, namespace) {
877
1041
  };
878
1042
  });
879
1043
  }
1044
+ function opaqueForeignKey(table, physicalName, key, targetTable, sourceColumns, targetColumns, physicalReference) {
1045
+ return {
1046
+ kind: "opaque-object",
1047
+ id: stableId(`foreign-key:${table.physicalName}:${key}`),
1048
+ identitySource: "deterministic-fallback",
1049
+ objectKind: "foreign-key",
1050
+ physicalName,
1051
+ data: {
1052
+ table: table.physicalName,
1053
+ foreignKeyId: key,
1054
+ ...targetTable === void 0 ? {} : { targetTable },
1055
+ sourceColumns: sourceColumns.map((column) => column ?? null),
1056
+ targetColumns: targetColumns.map((column) => column ?? null)
1057
+ },
1058
+ reference: physicalReference,
1059
+ provenance: {
1060
+ kind: "catalog",
1061
+ dialect: "sqlite",
1062
+ reference: physicalReference
1063
+ }
1064
+ };
1065
+ }
880
1066
  function partialPredicate(sqlText, indexName, namespace, table) {
881
1067
  const predicate = (sqlText?.match(/\bWHERE\s+([\s\S]+)$/i))?.[1]?.trim().replace(/;\s*$/, "");
882
1068
  return predicate ? sql(predicate, namespace, table, indexName) : void 0;
@@ -1,5 +1,5 @@
1
- import { $ as CatalogTrigger, A as CatalogNamespace, At as CatalogQuery, B as CatalogPrimaryKeyConstraint, C as CatalogForeignKeyTarget, Ct as IntrospectionDiagnosticCode, D as CatalogIndexTerm, Dt as createIntrospectionDiagnostic, E as CatalogIndex, Et as IntrospectionError, F as CatalogOpaqueObject, G as CatalogRoutine, H as CatalogProvenanceKind, I as CatalogOwnership, J as CatalogSequence, K as CatalogRoutineParameter, L as CatalogPartition, M as CatalogObjectBase, N as CatalogObjectMetadata, O as CatalogIntrospector, Ot as hasIntrospectionErrors, P as CatalogObjectReference, Q as CatalogTable, R as CatalogPolicy, S as CatalogForeignKeyConstraint, St as IntrospectionDiagnostic, T as CatalogIdentity, Tt as IntrospectionDiagnosticSeverity, U as CatalogQueryRow, V as CatalogProvenance, W as CatalogReference, X as CatalogSqlExpression, Y as CatalogServerInfo, Z as CatalogStorageType, _ as CatalogEntityReference, _t as CatalogIdentityPolicy, a as CatalogCollation, at as CatalogView, b as CatalogExpressionFact, bt as CatalogResolvedIdentity, c as CatalogCompleteObject, ct as IntrospectionFailure, d as CatalogDeferredObject, dt as IntrospectionResult, et as CatalogUniqueConstraint, f as CatalogDeferredObjectKind, ft as IntrospectionSuccess, g as CatalogEntityKind, gt as CatalogIdentityHints, h as CatalogDomain, ht as CatalogIdentityHint, i as CatalogClassificationConfidence, it as CatalogVersion, j as CatalogObject, jt as CatalogQueryOptions, k as CatalogLiteralFact, kt as CatalogConnection, l as CatalogConstraint, lt as IntrospectionMode, m as CatalogDialectExtension, mt as CatalogIdentityFallback, n as CatalogCatalogReference, nt as CatalogUnknownObject, o as CatalogColumn, ot as CompleteIntrospectionCatalog, p as CatalogDialect, pt as CatalogIdentityEntityKind, q as CatalogScalar, r as CatalogCheckConstraint, rt as CatalogValueFact, s as CatalogComment, st as IntrospectionCatalog, t as CatalogCapabilities, tt as CatalogUnknownField, u as CatalogData, ut as IntrospectionOptions, v as CatalogEnum, vt as CatalogIdentitySource, w as CatalogGeneratedColumn, wt as IntrospectionDiagnosticInput, x as CatalogExtensionObject, xt as introspectedPhysicalIdentityPolicy, y as CatalogEnumValue, yt as CatalogPreviousSnapshotIdentitySource, z as CatalogPortableStorageType } from "./types-BEn0N_al.mjs";
2
- import { t as CompleteSchemaSnapshot } from "./complete-types-CNMWBWap.mjs";
1
+ import { $ as CatalogStorageType, A as CatalogNamespace, At as hasIntrospectionErrors, B as CatalogPolicy, C as CatalogForeignKeyTarget, Ct as introspectedPhysicalIdentityPolicy, D as CatalogIndexTerm, Dt as IntrospectionDiagnosticSeverity, E as CatalogIndex, Et as IntrospectionDiagnosticInput, F as CatalogObjectOwnerKind, G as CatalogQueryRow, H as CatalogPrimaryKeyConstraint, I as CatalogObjectReference, J as CatalogRoutineParameter, K as CatalogReference, L as CatalogOpaqueObject, M as CatalogObjectBase, Mt as CatalogQuery, N as CatalogObjectMetadata, Nt as CatalogQueryOptions, O as CatalogIntrospector, Ot as IntrospectionError, P as CatalogObjectOwner, Q as CatalogSqlExpression, R as CatalogOwnership, S as CatalogForeignKeyConstraint, St as CatalogResolvedIdentity, T as CatalogIdentity, Tt as IntrospectionDiagnosticCode, U as CatalogProvenance, V as CatalogPortableStorageType, W as CatalogProvenanceKind, X as CatalogSequence, Y as CatalogScalar, Z as CatalogServerInfo, _ as CatalogEntityReference, _t as CatalogIdentityHint, a as CatalogCollation, at as CatalogValueFact, b as CatalogExpressionFact, bt as CatalogIdentitySource, c as CatalogCompleteObject, ct as CompleteIntrospectionCatalog, d as CatalogDeferredObject, dt as IntrospectionMode, et as CatalogTable, f as CatalogDeferredObjectKind, ft as IntrospectionOptions, g as CatalogEntityKind, gt as CatalogIdentityFallback, h as CatalogDomain, ht as CatalogIdentityEntityKind, i as CatalogClassificationConfidence, it as CatalogUnknownObject, j as CatalogObject, jt as CatalogConnection, k as CatalogLiteralFact, kt as createIntrospectionDiagnostic, l as CatalogConstraint, lt as IntrospectionCatalog, m as CatalogDialectExtension, mt as IntrospectionSuccess, n as CatalogCatalogReference, nt as CatalogUniqueConstraint, o as CatalogColumn, ot as CatalogVersion, p as CatalogDialect, pt as IntrospectionResult, q as CatalogRoutine, r as CatalogCheckConstraint, rt as CatalogUnknownField, s as CatalogComment, st as CatalogView, t as CatalogCapabilities, tt as CatalogTrigger, u as CatalogData, ut as IntrospectionFailure, v as CatalogEnum, vt as CatalogIdentityHints, w as CatalogGeneratedColumn, wt as IntrospectionDiagnostic, x as CatalogExtensionObject, xt as CatalogPreviousSnapshotIdentitySource, y as CatalogEnumValue, yt as CatalogIdentityPolicy, z as CatalogPartition } from "./types-CiMvKi5V.mjs";
2
+ import { B as CompleteSchemaSnapshot } from "./types-Dqr4o2I1.mjs";
3
3
  //#region src/introspection/catalog.d.ts
4
4
  /**
5
5
  * Materialize every optional object-family collection and deeply freeze the normalized catalog.
@@ -13,13 +13,19 @@ declare const freezeIntrospectionCatalog: typeof createCompleteIntrospectionCata
13
13
  declare function toIntrospectionCatalog(catalog: CompleteIntrospectionCatalog): IntrospectionCatalog;
14
14
  //#endregion
15
15
  //#region src/introspection/complete-snapshot.d.ts
16
- /** Result returned by the strict normalized-catalog to Snapshot v2 mapper. */
16
+ /** Result returned by the normalized-catalog-to-Snapshot v1 mapper, including lossiness status. */
17
17
  type CompleteSnapshotMappingResult = {
18
18
  readonly ok: true;
19
19
  readonly catalog: CompleteIntrospectionCatalog;
20
20
  readonly snapshot: CompleteSchemaSnapshot;
21
21
  readonly diagnostics: readonly IntrospectionDiagnostic[];
22
22
  readonly lossy: false;
23
+ } | {
24
+ readonly ok: true;
25
+ readonly catalog: CompleteIntrospectionCatalog;
26
+ readonly snapshot: CompleteSchemaSnapshot;
27
+ readonly diagnostics: readonly IntrospectionDiagnostic[];
28
+ readonly lossy: true;
23
29
  } | {
24
30
  readonly ok: false;
25
31
  readonly catalog: CompleteIntrospectionCatalog;
@@ -27,16 +33,24 @@ type CompleteSnapshotMappingResult = {
27
33
  readonly lossy: false;
28
34
  };
29
35
  /**
30
- * Map a normalized catalog to strict Snapshot v2 data. This is intentionally separate from the
31
- * Snapshot v1 mapper: complete objects are never fabricated as tables, and catalog references
32
- * remain evidence rather than logical IDs.
36
+ * Map a normalized catalog to validated Snapshot v1 data.
37
+ *
38
+ * Strict mode reports mapping errors as failure. Explicit lossy mode may omit only recoverable
39
+ * unsafe facts and marks a successful result as lossy. Complete objects are never fabricated as
40
+ * tables, and catalog references remain evidence rather than logical IDs.
33
41
  */
34
- declare function mapCatalogToCompleteSnapshot(input: IntrospectionCatalog): CompleteSnapshotMappingResult;
35
- /** Numbered alias for callers that keep both snapshot mappers available. */
36
- declare const mapCatalogToSnapshotV2: typeof mapCatalogToCompleteSnapshot;
42
+ declare function mapCatalogToCompleteSnapshot(input: IntrospectionCatalog, options?: IntrospectionOptions): CompleteSnapshotMappingResult;
43
+ /** Numbered alias for callers that prefer the explicit Snapshot v1 mapper name. */
44
+ declare const mapCatalogToSnapshotV1: typeof mapCatalogToCompleteSnapshot;
37
45
  //#endregion
38
46
  //#region src/introspection/snapshot.d.ts
39
- /** Construct and validate a canonical Snapshot v1 from a normalized catalog. */
40
- declare function mapCatalogToSnapshot(catalog: IntrospectionCatalog, options: IntrospectionOptions): IntrospectionResult;
47
+ /**
48
+ * Map a normalized catalog to the canonical Snapshot v1 object model.
49
+ *
50
+ * Snapshot identity and namespace facts come from the normalized catalog, with explicit identity
51
+ * continuity options applied during the mapping step. Strict mode fails on mapping errors; lossy
52
+ * mode may omit recoverable facts and marks successful output accordingly.
53
+ */
54
+ declare function mapCatalogToSnapshot(catalog: IntrospectionCatalog, options?: IntrospectionOptions): IntrospectionResult;
41
55
  //#endregion
42
- export { CatalogCapabilities, CatalogCatalogReference, CatalogCheckConstraint, CatalogClassificationConfidence, CatalogCollation, CatalogColumn, CatalogComment, CatalogCompleteObject, CatalogConnection, CatalogConstraint, CatalogData, CatalogDeferredObject, CatalogDeferredObjectKind, CatalogDialect, CatalogDialectExtension, CatalogDomain, CatalogEntityKind, CatalogEntityReference, CatalogEnum, CatalogEnumValue, CatalogExpressionFact, CatalogExtensionObject, CatalogForeignKeyConstraint, CatalogForeignKeyTarget, CatalogGeneratedColumn, CatalogIdentity, CatalogIdentityEntityKind, CatalogIdentityFallback, CatalogIdentityHint, CatalogIdentityHints, CatalogIdentityPolicy, CatalogIdentitySource, CatalogIndex, CatalogIndexTerm, CatalogIntrospector, CatalogLiteralFact, CatalogNamespace, CatalogObject, CatalogObjectBase, CatalogObjectMetadata, CatalogObjectReference, CatalogOpaqueObject, CatalogOwnership, CatalogPartition, CatalogPolicy, CatalogPortableStorageType, CatalogPreviousSnapshotIdentitySource, CatalogPrimaryKeyConstraint, CatalogProvenance, CatalogProvenanceKind, CatalogQuery, CatalogQueryOptions, CatalogQueryRow, CatalogReference, CatalogResolvedIdentity, CatalogRoutine, CatalogRoutineParameter, CatalogScalar, CatalogSequence, CatalogServerInfo, CatalogSqlExpression, CatalogStorageType, CatalogTable, CatalogTrigger, CatalogUniqueConstraint, CatalogUnknownField, CatalogUnknownObject, CatalogValueFact, CatalogVersion, CatalogView, CompleteIntrospectionCatalog, CompleteSnapshotMappingResult, IntrospectionCatalog, IntrospectionDiagnostic, IntrospectionDiagnosticCode, IntrospectionDiagnosticInput, IntrospectionDiagnosticSeverity, IntrospectionError, IntrospectionFailure, IntrospectionMode, IntrospectionOptions, IntrospectionResult, IntrospectionSuccess, createCompleteIntrospectionCatalog, createIntrospectionDiagnostic, freezeIntrospectionCatalog, hasIntrospectionErrors, introspectedPhysicalIdentityPolicy, mapCatalogToCompleteSnapshot, mapCatalogToSnapshot, mapCatalogToSnapshotV2, toIntrospectionCatalog };
56
+ export { CatalogCapabilities, CatalogCatalogReference, CatalogCheckConstraint, CatalogClassificationConfidence, CatalogCollation, CatalogColumn, CatalogComment, CatalogCompleteObject, CatalogConnection, CatalogConstraint, CatalogData, CatalogDeferredObject, CatalogDeferredObjectKind, CatalogDialect, CatalogDialectExtension, CatalogDomain, CatalogEntityKind, CatalogEntityReference, CatalogEnum, CatalogEnumValue, CatalogExpressionFact, CatalogExtensionObject, CatalogForeignKeyConstraint, CatalogForeignKeyTarget, CatalogGeneratedColumn, CatalogIdentity, CatalogIdentityEntityKind, CatalogIdentityFallback, CatalogIdentityHint, CatalogIdentityHints, CatalogIdentityPolicy, CatalogIdentitySource, CatalogIndex, CatalogIndexTerm, CatalogIntrospector, CatalogLiteralFact, CatalogNamespace, CatalogObject, CatalogObjectBase, CatalogObjectMetadata, CatalogObjectOwner, CatalogObjectOwnerKind, CatalogObjectReference, CatalogOpaqueObject, CatalogOwnership, CatalogPartition, CatalogPolicy, CatalogPortableStorageType, CatalogPreviousSnapshotIdentitySource, CatalogPrimaryKeyConstraint, CatalogProvenance, CatalogProvenanceKind, CatalogQuery, CatalogQueryOptions, CatalogQueryRow, CatalogReference, CatalogResolvedIdentity, CatalogRoutine, CatalogRoutineParameter, CatalogScalar, CatalogSequence, CatalogServerInfo, CatalogSqlExpression, CatalogStorageType, CatalogTable, CatalogTrigger, CatalogUniqueConstraint, CatalogUnknownField, CatalogUnknownObject, CatalogValueFact, CatalogVersion, CatalogView, CompleteIntrospectionCatalog, CompleteSnapshotMappingResult, IntrospectionCatalog, IntrospectionDiagnostic, IntrospectionDiagnosticCode, IntrospectionDiagnosticInput, IntrospectionDiagnosticSeverity, IntrospectionError, IntrospectionFailure, IntrospectionMode, IntrospectionOptions, IntrospectionResult, IntrospectionSuccess, createCompleteIntrospectionCatalog, createIntrospectionDiagnostic, freezeIntrospectionCatalog, hasIntrospectionErrors, introspectedPhysicalIdentityPolicy, mapCatalogToCompleteSnapshot, mapCatalogToSnapshot, mapCatalogToSnapshotV1, toIntrospectionCatalog };