@deepagents/text2sql 7.31.0 → 7.32.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 +16 -2
- package/dist/index.js.map +2 -2
- package/dist/lib/adapters/spreadsheet/index.js +16 -24
- package/dist/lib/adapters/spreadsheet/index.js.map +2 -2
- package/dist/lib/adapters/spreadsheet/parser.d.ts.map +1 -1
- package/dist/lib/fs/mssql/mssql-fs.d.ts.map +1 -1
- package/dist/lib/fs/postgres/postgres-fs.d.ts.map +1 -1
- package/dist/lib/fs/sqlite/sqlite-fs.d.ts.map +1 -1
- package/dist/lib/synthesis/decorators/deduplicated-producer.d.ts +4 -2
- package/dist/lib/synthesis/decorators/deduplicated-producer.d.ts.map +1 -1
- package/dist/lib/synthesis/index.js.map +2 -2
- package/package.json +4 -4
|
@@ -1766,19 +1766,19 @@ function parseFile(filePath) {
|
|
|
1766
1766
|
});
|
|
1767
1767
|
}
|
|
1768
1768
|
const sheets = [];
|
|
1769
|
+
const tableIdentifier = uniqueIdentifiers();
|
|
1769
1770
|
for (const sheetName of workbook.SheetNames) {
|
|
1770
1771
|
const sheet = workbook.Sheets[sheetName];
|
|
1771
1772
|
const rows = XLSX.utils.sheet_to_json(sheet);
|
|
1772
1773
|
if (rows.length === 0) {
|
|
1773
1774
|
continue;
|
|
1774
1775
|
}
|
|
1775
|
-
const tableName = ext === ".csv" || ext === ".tsv" ? getTableNameFromFile(filePath) : sanitizeTableName(sheetName);
|
|
1776
1776
|
const columns = inferColumns(rows);
|
|
1777
1777
|
if (columns.length === 0) {
|
|
1778
1778
|
continue;
|
|
1779
1779
|
}
|
|
1780
1780
|
sheets.push({
|
|
1781
|
-
name:
|
|
1781
|
+
name: ext === ".csv" || ext === ".tsv" ? getTableNameFromFile(filePath) : tableIdentifier(sheetName),
|
|
1782
1782
|
columns,
|
|
1783
1783
|
rows
|
|
1784
1784
|
});
|
|
@@ -1821,32 +1821,24 @@ function inferColumns(rows) {
|
|
|
1821
1821
|
if (keySet.size === 0) {
|
|
1822
1822
|
return [];
|
|
1823
1823
|
}
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1826
|
-
return dedupedNames.map((name, idx) => {
|
|
1827
|
-
const originalKey = rawNames[idx];
|
|
1824
|
+
const columnIdentifier = uniqueIdentifiers();
|
|
1825
|
+
return Array.from(keySet, (originalKey) => {
|
|
1828
1826
|
const values = rows.map((row) => row[originalKey]);
|
|
1829
1827
|
const type = inferColumnType(values);
|
|
1830
|
-
return { name, originalKey, type };
|
|
1828
|
+
return { name: columnIdentifier(originalKey), originalKey, type };
|
|
1831
1829
|
});
|
|
1832
1830
|
}
|
|
1833
|
-
function
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
let name =
|
|
1838
|
-
|
|
1839
|
-
name =
|
|
1840
|
-
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
} else {
|
|
1845
|
-
result.push(name);
|
|
1846
|
-
}
|
|
1847
|
-
seen.set(name, count + 1);
|
|
1848
|
-
}
|
|
1849
|
-
return result;
|
|
1831
|
+
function uniqueIdentifiers() {
|
|
1832
|
+
const used = /* @__PURE__ */ new Set();
|
|
1833
|
+
return (rawName) => {
|
|
1834
|
+
const base = sanitizeIdentifier(rawName);
|
|
1835
|
+
let name = base;
|
|
1836
|
+
for (let suffix = 2; used.has(name); suffix++) {
|
|
1837
|
+
name = `${base}_${suffix}`;
|
|
1838
|
+
}
|
|
1839
|
+
used.add(name);
|
|
1840
|
+
return name;
|
|
1841
|
+
};
|
|
1850
1842
|
}
|
|
1851
1843
|
function inferColumnType(values) {
|
|
1852
1844
|
let hasInteger = false;
|