@agentforge/tools 0.16.70 → 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.d.cts CHANGED
@@ -5553,7 +5553,7 @@ declare function validateColumnTypes(schema: DatabaseSchema, tableName: string,
5553
5553
  * Database type → TypeScript type mapper.
5554
5554
  *
5555
5555
  * Maps vendor-specific SQL column types to their closest TypeScript
5556
- * equivalents. Used for code generation hints, documentation, and
5556
+ * equivalents. Used for code generation hints, documentation, and
5557
5557
  * schema-aware validation utilities.
5558
5558
  *
5559
5559
  * @module schema/type-mapper
@@ -5575,8 +5575,9 @@ interface MappedType {
5575
5575
  /**
5576
5576
  * Map a single database column type to its TypeScript equivalent.
5577
5577
  *
5578
- * Normalises the input type to lower-case and strips size suffixes
5579
- * (e.g. `varchar(255)` → `varchar`) before looking up the mapping.
5578
+ * Normalises the input type to lower-case and strips PostgreSQL array
5579
+ * suffixes, MySQL `unsigned`, and size/precision suffixes such as
5580
+ * `varchar(255)` or `numeric(10,2)` before map lookup.
5580
5581
  *
5581
5582
  * @param vendor - Database vendor
5582
5583
  * @param dbType - The raw column type string from the database
@@ -5587,7 +5588,7 @@ declare function mapColumnType(vendor: DatabaseVendor, dbType: string, nullable?
5587
5588
  /**
5588
5589
  * Map all columns in a database schema to TypeScript types.
5589
5590
  *
5590
- * Returns a nested map: `tableName → columnName → MappedType`.
5591
+ * Returns a nested map: `tableName → columnName → MappedType`.
5591
5592
  *
5592
5593
  * @param vendor - Database vendor
5593
5594
  * @param columns - Array of columns with their metadata
package/dist/index.d.ts CHANGED
@@ -5553,7 +5553,7 @@ declare function validateColumnTypes(schema: DatabaseSchema, tableName: string,
5553
5553
  * Database type → TypeScript type mapper.
5554
5554
  *
5555
5555
  * Maps vendor-specific SQL column types to their closest TypeScript
5556
- * equivalents. Used for code generation hints, documentation, and
5556
+ * equivalents. Used for code generation hints, documentation, and
5557
5557
  * schema-aware validation utilities.
5558
5558
  *
5559
5559
  * @module schema/type-mapper
@@ -5575,8 +5575,9 @@ interface MappedType {
5575
5575
  /**
5576
5576
  * Map a single database column type to its TypeScript equivalent.
5577
5577
  *
5578
- * Normalises the input type to lower-case and strips size suffixes
5579
- * (e.g. `varchar(255)` → `varchar`) before looking up the mapping.
5578
+ * Normalises the input type to lower-case and strips PostgreSQL array
5579
+ * suffixes, MySQL `unsigned`, and size/precision suffixes such as
5580
+ * `varchar(255)` or `numeric(10,2)` before map lookup.
5580
5581
  *
5581
5582
  * @param vendor - Database vendor
5582
5583
  * @param dbType - The raw column type string from the database
@@ -5587,7 +5588,7 @@ declare function mapColumnType(vendor: DatabaseVendor, dbType: string, nullable?
5587
5588
  /**
5588
5589
  * Map all columns in a database schema to TypeScript types.
5589
5590
  *
5590
- * Returns a nested map: `tableName → columnName → MappedType`.
5591
+ * Returns a nested map: `tableName → columnName → MappedType`.
5591
5592
  *
5592
5593
  * @param vendor - Database vendor
5593
5594
  * @param columns - Array of columns with their metadata
package/dist/index.js CHANGED
@@ -6767,16 +6767,24 @@ function findTable(schema, tableName) {
6767
6767
  function formatTableName(table) {
6768
6768
  return table.schema ? `${table.schema}.${table.name}` : table.name;
6769
6769
  }
6770
- var logger13 = createLogger("agentforge:tools:data:relational:type-mapper");
6770
+
6771
+ // src/data/relational/schema/type-mapper-normalization.ts
6772
+ function normaliseDbType(raw) {
6773
+ let type = raw.toLowerCase().trim();
6774
+ type = type.replace(/\[\]$/, "");
6775
+ type = type.replace(/\([\d,\s]+\)/, "");
6776
+ type = type.replace(/\s+unsigned$/, "");
6777
+ return type.trim();
6778
+ }
6779
+
6780
+ // src/data/relational/schema/type-mapper-vendor-maps.ts
6771
6781
  var POSTGRES_TYPE_MAP = {
6772
- // Numeric
6773
6782
  smallint: "number",
6774
6783
  integer: "number",
6775
6784
  int: "number",
6776
6785
  int2: "number",
6777
6786
  int4: "number",
6778
6787
  int8: "string",
6779
- // bigint → string to avoid JS precision loss
6780
6788
  bigint: "string",
6781
6789
  serial: "number",
6782
6790
  bigserial: "string",
@@ -6786,10 +6794,8 @@ var POSTGRES_TYPE_MAP = {
6786
6794
  "double precision": "number",
6787
6795
  float8: "number",
6788
6796
  numeric: "string",
6789
- // arbitrary precision → string
6790
6797
  decimal: "string",
6791
6798
  money: "string",
6792
- // Text
6793
6799
  text: "string",
6794
6800
  "character varying": "string",
6795
6801
  varchar: "string",
@@ -6797,10 +6803,8 @@ var POSTGRES_TYPE_MAP = {
6797
6803
  character: "string",
6798
6804
  name: "string",
6799
6805
  citext: "string",
6800
- // Boolean
6801
6806
  boolean: "boolean",
6802
6807
  bool: "boolean",
6803
- // Date / time
6804
6808
  date: "string",
6805
6809
  timestamp: "string",
6806
6810
  "timestamp with time zone": "string",
@@ -6811,19 +6815,14 @@ var POSTGRES_TYPE_MAP = {
6811
6815
  "time without time zone": "string",
6812
6816
  timetz: "string",
6813
6817
  interval: "string",
6814
- // JSON
6815
6818
  json: "unknown",
6816
6819
  jsonb: "unknown",
6817
- // Binary
6818
6820
  bytea: "Buffer",
6819
- // UUID
6820
6821
  uuid: "string",
6821
- // Network
6822
6822
  inet: "string",
6823
6823
  cidr: "string",
6824
6824
  macaddr: "string",
6825
6825
  macaddr8: "string",
6826
- // Geometric (represented as strings)
6827
6826
  point: "string",
6828
6827
  line: "string",
6829
6828
  lseg: "string",
@@ -6831,21 +6830,18 @@ var POSTGRES_TYPE_MAP = {
6831
6830
  path: "string",
6832
6831
  polygon: "string",
6833
6832
  circle: "string",
6834
- // Other
6835
6833
  xml: "string",
6836
6834
  tsvector: "string",
6837
6835
  tsquery: "string",
6838
6836
  oid: "number"
6839
6837
  };
6840
6838
  var MYSQL_TYPE_MAP = {
6841
- // Numeric
6842
6839
  tinyint: "number",
6843
6840
  smallint: "number",
6844
6841
  mediumint: "number",
6845
6842
  int: "number",
6846
6843
  integer: "number",
6847
6844
  bigint: "string",
6848
- // precision
6849
6845
  float: "number",
6850
6846
  double: "number",
6851
6847
  "double precision": "number",
@@ -6853,7 +6849,6 @@ var MYSQL_TYPE_MAP = {
6853
6849
  dec: "string",
6854
6850
  numeric: "string",
6855
6851
  bit: "number",
6856
- // Text
6857
6852
  char: "string",
6858
6853
  varchar: "string",
6859
6854
  tinytext: "string",
@@ -6862,40 +6857,32 @@ var MYSQL_TYPE_MAP = {
6862
6857
  longtext: "string",
6863
6858
  enum: "string",
6864
6859
  set: "string",
6865
- // Boolean (MySQL uses tinyint(1))
6866
6860
  boolean: "boolean",
6867
6861
  bool: "boolean",
6868
- // Binary
6869
6862
  binary: "Buffer",
6870
6863
  varbinary: "Buffer",
6871
6864
  tinyblob: "Buffer",
6872
6865
  blob: "Buffer",
6873
6866
  mediumblob: "Buffer",
6874
6867
  longblob: "Buffer",
6875
- // Date / time
6876
6868
  date: "string",
6877
6869
  datetime: "string",
6878
6870
  timestamp: "string",
6879
6871
  time: "string",
6880
6872
  year: "number",
6881
- // JSON
6882
6873
  json: "unknown",
6883
- // Spatial (represented as strings)
6884
6874
  geometry: "string",
6885
6875
  point: "string",
6886
6876
  linestring: "string",
6887
6877
  polygon: "string"
6888
6878
  };
6889
6879
  var SQLITE_TYPE_MAP = {
6890
- // SQLite has dynamic typing with 5 storage classes.
6891
- // The declared type is advisory; these are the common declared types.
6892
6880
  integer: "number",
6893
6881
  int: "number",
6894
6882
  tinyint: "number",
6895
6883
  smallint: "number",
6896
6884
  mediumint: "number",
6897
6885
  bigint: "number",
6898
- // SQLite stores as 64-bit int, JS number is safe up to 2^53
6899
6886
  real: "number",
6900
6887
  double: "number",
6901
6888
  "double precision": "number",
@@ -6903,7 +6890,6 @@ var SQLITE_TYPE_MAP = {
6903
6890
  numeric: "number",
6904
6891
  decimal: "number",
6905
6892
  boolean: "number",
6906
- // SQLite stores booleans as 0/1
6907
6893
  text: "string",
6908
6894
  varchar: "string",
6909
6895
  char: "string",
@@ -6918,13 +6904,16 @@ var SQLITE_TYPE_MAP = {
6918
6904
  timestamp: "string",
6919
6905
  json: "unknown"
6920
6906
  };
6921
- var VENDOR_MAPS = {
6907
+ var VENDOR_TYPE_MAPS = {
6922
6908
  postgresql: POSTGRES_TYPE_MAP,
6923
6909
  mysql: MYSQL_TYPE_MAP,
6924
6910
  sqlite: SQLITE_TYPE_MAP
6925
6911
  };
6912
+
6913
+ // src/data/relational/schema/type-mapper.ts
6914
+ var logger13 = createLogger("agentforge:tools:data:relational:type-mapper");
6926
6915
  function mapColumnType(vendor, dbType, nullable = false) {
6927
- const typeMap = VENDOR_MAPS[vendor];
6916
+ const typeMap = VENDOR_TYPE_MAPS[vendor];
6928
6917
  if (!typeMap) {
6929
6918
  return { tsType: "unknown", nullable, dbType, notes: `Unsupported vendor: ${vendor}` };
6930
6919
  }
@@ -6935,18 +6924,20 @@ function mapColumnType(vendor, dbType, nullable = false) {
6935
6924
  result.notes = `No explicit mapping for "${dbType}"; defaulting to unknown`;
6936
6925
  logger13.debug("Unmapped database type", { vendor, dbType, normalised });
6937
6926
  }
6938
- if ((normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql")) {
6927
+ if (usesStringPrecisionFallback(vendor, normalised)) {
6939
6928
  result.notes = "Mapped to string to avoid JavaScript number precision loss for 64-bit integers";
6940
6929
  }
6941
6930
  return result;
6942
6931
  }
6943
6932
  function mapSchemaTypes(vendor, columns) {
6944
6933
  const result = /* @__PURE__ */ new Map();
6945
- for (const col of columns) {
6946
- if (!result.has(col.table)) {
6947
- result.set(col.table, /* @__PURE__ */ new Map());
6934
+ for (const column of columns) {
6935
+ let tableColumns = result.get(column.table);
6936
+ if (!tableColumns) {
6937
+ tableColumns = /* @__PURE__ */ new Map();
6938
+ result.set(column.table, tableColumns);
6948
6939
  }
6949
- result.get(col.table).set(col.name, mapColumnType(vendor, col.type, col.nullable));
6940
+ tableColumns.set(column.name, mapColumnType(vendor, column.type, column.nullable));
6950
6941
  }
6951
6942
  logger13.debug("Schema type mapping complete", {
6952
6943
  vendor,
@@ -6956,14 +6947,10 @@ function mapSchemaTypes(vendor, columns) {
6956
6947
  return result;
6957
6948
  }
6958
6949
  function getVendorTypeMap(vendor) {
6959
- return { ...VENDOR_MAPS[vendor] };
6950
+ return { ...VENDOR_TYPE_MAPS[vendor] };
6960
6951
  }
6961
- function normaliseDbType(raw) {
6962
- let type = raw.toLowerCase().trim();
6963
- type = type.replace(/\[\]$/, "");
6964
- type = type.replace(/\([\d,\s]+\)/, "");
6965
- type = type.replace(/\s+unsigned$/, "");
6966
- return type.trim();
6952
+ function usesStringPrecisionFallback(vendor, normalised) {
6953
+ return (normalised === "bigint" || normalised === "int8" || normalised === "bigserial") && (vendor === "postgresql" || vendor === "mysql");
6967
6954
  }
6968
6955
  var logger14 = createLogger("agentforge:tools:data:relational:schema-diff");
6969
6956
  function diffSchemas(before, after) {