@agentforge/tools 0.16.69 → 0.16.71

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.cjs CHANGED
@@ -6794,16 +6794,24 @@ function findTable(schema, tableName) {
6794
6794
  function formatTableName(table) {
6795
6795
  return table.schema ? `${table.schema}.${table.name}` : table.name;
6796
6796
  }
6797
- var logger13 = core.createLogger("agentforge:tools:data:relational:type-mapper");
6797
+
6798
+ // src/data/relational/schema/type-mapper-normalization.ts
6799
+ function normaliseDbType(raw) {
6800
+ let type = raw.toLowerCase().trim();
6801
+ type = type.replace(/\[\]$/, "");
6802
+ type = type.replace(/\([\d,\s]+\)/, "");
6803
+ type = type.replace(/\s+unsigned$/, "");
6804
+ return type.trim();
6805
+ }
6806
+
6807
+ // src/data/relational/schema/type-mapper-vendor-maps.ts
6798
6808
  var POSTGRES_TYPE_MAP = {
6799
- // Numeric
6800
6809
  smallint: "number",
6801
6810
  integer: "number",
6802
6811
  int: "number",
6803
6812
  int2: "number",
6804
6813
  int4: "number",
6805
6814
  int8: "string",
6806
- // bigint → string to avoid JS precision loss
6807
6815
  bigint: "string",
6808
6816
  serial: "number",
6809
6817
  bigserial: "string",
@@ -6813,10 +6821,8 @@ var POSTGRES_TYPE_MAP = {
6813
6821
  "double precision": "number",
6814
6822
  float8: "number",
6815
6823
  numeric: "string",
6816
- // arbitrary precision → string
6817
6824
  decimal: "string",
6818
6825
  money: "string",
6819
- // Text
6820
6826
  text: "string",
6821
6827
  "character varying": "string",
6822
6828
  varchar: "string",
@@ -6824,10 +6830,8 @@ var POSTGRES_TYPE_MAP = {
6824
6830
  character: "string",
6825
6831
  name: "string",
6826
6832
  citext: "string",
6827
- // Boolean
6828
6833
  boolean: "boolean",
6829
6834
  bool: "boolean",
6830
- // Date / time
6831
6835
  date: "string",
6832
6836
  timestamp: "string",
6833
6837
  "timestamp with time zone": "string",
@@ -6838,19 +6842,14 @@ var POSTGRES_TYPE_MAP = {
6838
6842
  "time without time zone": "string",
6839
6843
  timetz: "string",
6840
6844
  interval: "string",
6841
- // JSON
6842
6845
  json: "unknown",
6843
6846
  jsonb: "unknown",
6844
- // Binary
6845
6847
  bytea: "Buffer",
6846
- // UUID
6847
6848
  uuid: "string",
6848
- // Network
6849
6849
  inet: "string",
6850
6850
  cidr: "string",
6851
6851
  macaddr: "string",
6852
6852
  macaddr8: "string",
6853
- // Geometric (represented as strings)
6854
6853
  point: "string",
6855
6854
  line: "string",
6856
6855
  lseg: "string",
@@ -6858,21 +6857,18 @@ var POSTGRES_TYPE_MAP = {
6858
6857
  path: "string",
6859
6858
  polygon: "string",
6860
6859
  circle: "string",
6861
- // Other
6862
6860
  xml: "string",
6863
6861
  tsvector: "string",
6864
6862
  tsquery: "string",
6865
6863
  oid: "number"
6866
6864
  };
6867
6865
  var MYSQL_TYPE_MAP = {
6868
- // Numeric
6869
6866
  tinyint: "number",
6870
6867
  smallint: "number",
6871
6868
  mediumint: "number",
6872
6869
  int: "number",
6873
6870
  integer: "number",
6874
6871
  bigint: "string",
6875
- // precision
6876
6872
  float: "number",
6877
6873
  double: "number",
6878
6874
  "double precision": "number",
@@ -6880,7 +6876,6 @@ var MYSQL_TYPE_MAP = {
6880
6876
  dec: "string",
6881
6877
  numeric: "string",
6882
6878
  bit: "number",
6883
- // Text
6884
6879
  char: "string",
6885
6880
  varchar: "string",
6886
6881
  tinytext: "string",
@@ -6889,40 +6884,32 @@ var MYSQL_TYPE_MAP = {
6889
6884
  longtext: "string",
6890
6885
  enum: "string",
6891
6886
  set: "string",
6892
- // Boolean (MySQL uses tinyint(1))
6893
6887
  boolean: "boolean",
6894
6888
  bool: "boolean",
6895
- // Binary
6896
6889
  binary: "Buffer",
6897
6890
  varbinary: "Buffer",
6898
6891
  tinyblob: "Buffer",
6899
6892
  blob: "Buffer",
6900
6893
  mediumblob: "Buffer",
6901
6894
  longblob: "Buffer",
6902
- // Date / time
6903
6895
  date: "string",
6904
6896
  datetime: "string",
6905
6897
  timestamp: "string",
6906
6898
  time: "string",
6907
6899
  year: "number",
6908
- // JSON
6909
6900
  json: "unknown",
6910
- // Spatial (represented as strings)
6911
6901
  geometry: "string",
6912
6902
  point: "string",
6913
6903
  linestring: "string",
6914
6904
  polygon: "string"
6915
6905
  };
6916
6906
  var SQLITE_TYPE_MAP = {
6917
- // SQLite has dynamic typing with 5 storage classes.
6918
- // The declared type is advisory; these are the common declared types.
6919
6907
  integer: "number",
6920
6908
  int: "number",
6921
6909
  tinyint: "number",
6922
6910
  smallint: "number",
6923
6911
  mediumint: "number",
6924
6912
  bigint: "number",
6925
- // SQLite stores as 64-bit int, JS number is safe up to 2^53
6926
6913
  real: "number",
6927
6914
  double: "number",
6928
6915
  "double precision": "number",
@@ -6930,7 +6917,6 @@ var SQLITE_TYPE_MAP = {
6930
6917
  numeric: "number",
6931
6918
  decimal: "number",
6932
6919
  boolean: "number",
6933
- // SQLite stores booleans as 0/1
6934
6920
  text: "string",
6935
6921
  varchar: "string",
6936
6922
  char: "string",
@@ -6945,13 +6931,16 @@ var SQLITE_TYPE_MAP = {
6945
6931
  timestamp: "string",
6946
6932
  json: "unknown"
6947
6933
  };
6948
- var VENDOR_MAPS = {
6934
+ var VENDOR_TYPE_MAPS = {
6949
6935
  postgresql: POSTGRES_TYPE_MAP,
6950
6936
  mysql: MYSQL_TYPE_MAP,
6951
6937
  sqlite: SQLITE_TYPE_MAP
6952
6938
  };
6939
+
6940
+ // src/data/relational/schema/type-mapper.ts
6941
+ var logger13 = core.createLogger("agentforge:tools:data:relational:type-mapper");
6953
6942
  function mapColumnType(vendor, dbType, nullable = false) {
6954
- const typeMap = VENDOR_MAPS[vendor];
6943
+ const typeMap = VENDOR_TYPE_MAPS[vendor];
6955
6944
  if (!typeMap) {
6956
6945
  return { tsType: "unknown", nullable, dbType, notes: `Unsupported vendor: ${vendor}` };
6957
6946
  }
@@ -6962,18 +6951,20 @@ function mapColumnType(vendor, dbType, nullable = false) {
6962
6951
  result.notes = `No explicit mapping for "${dbType}"; defaulting to unknown`;
6963
6952
  logger13.debug("Unmapped database type", { vendor, dbType, normalised });
6964
6953
  }
6965
- if ((normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql")) {
6954
+ if (usesStringPrecisionFallback(vendor, normalised)) {
6966
6955
  result.notes = "Mapped to string to avoid JavaScript number precision loss for 64-bit integers";
6967
6956
  }
6968
6957
  return result;
6969
6958
  }
6970
6959
  function mapSchemaTypes(vendor, columns) {
6971
6960
  const result = /* @__PURE__ */ new Map();
6972
- for (const col of columns) {
6973
- if (!result.has(col.table)) {
6974
- result.set(col.table, /* @__PURE__ */ new Map());
6961
+ for (const column of columns) {
6962
+ let tableColumns = result.get(column.table);
6963
+ if (!tableColumns) {
6964
+ tableColumns = /* @__PURE__ */ new Map();
6965
+ result.set(column.table, tableColumns);
6975
6966
  }
6976
- result.get(col.table).set(col.name, mapColumnType(vendor, col.type, col.nullable));
6967
+ tableColumns.set(column.name, mapColumnType(vendor, column.type, column.nullable));
6977
6968
  }
6978
6969
  logger13.debug("Schema type mapping complete", {
6979
6970
  vendor,
@@ -6983,14 +6974,10 @@ function mapSchemaTypes(vendor, columns) {
6983
6974
  return result;
6984
6975
  }
6985
6976
  function getVendorTypeMap(vendor) {
6986
- return { ...VENDOR_MAPS[vendor] };
6977
+ return { ...VENDOR_TYPE_MAPS[vendor] };
6987
6978
  }
6988
- function normaliseDbType(raw) {
6989
- let type = raw.toLowerCase().trim();
6990
- type = type.replace(/\[\]$/, "");
6991
- type = type.replace(/\([\d,\s]+\)/, "");
6992
- type = type.replace(/\s+unsigned$/, "");
6993
- return type.trim();
6979
+ function usesStringPrecisionFallback(vendor, normalised) {
6980
+ return (normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql");
6994
6981
  }
6995
6982
  var logger14 = core.createLogger("agentforge:tools:data:relational:schema-diff");
6996
6983
  function diffSchemas(before, after) {