@deepagents/text2sql 0.38.1 → 0.39.0
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/README.md +81 -44
- package/dist/index.js +40 -16
- package/dist/index.js.map +2 -2
- package/dist/lib/adapters/adapter.d.ts +1 -0
- package/dist/lib/adapters/adapter.d.ts.map +1 -1
- package/dist/lib/adapters/bigquery/index.js +24 -13
- package/dist/lib/adapters/bigquery/index.js.map +2 -2
- package/dist/lib/adapters/groundings/context.d.ts +2 -2
- package/dist/lib/adapters/groundings/context.d.ts.map +1 -1
- package/dist/lib/adapters/groundings/index.js +20 -9
- package/dist/lib/adapters/groundings/index.js.map +2 -2
- package/dist/lib/adapters/mysql/index.js +23 -12
- package/dist/lib/adapters/mysql/index.js.map +2 -2
- package/dist/lib/adapters/postgres/index.js +31 -18
- package/dist/lib/adapters/postgres/index.js.map +3 -3
- package/dist/lib/adapters/postgres/postgres.d.ts.map +1 -1
- package/dist/lib/adapters/spreadsheet/index.js +20 -9
- package/dist/lib/adapters/spreadsheet/index.js.map +2 -2
- package/dist/lib/adapters/sqlite/index.js +23 -12
- package/dist/lib/adapters/sqlite/index.js.map +2 -2
- package/dist/lib/adapters/sqlserver/index.js +31 -18
- package/dist/lib/adapters/sqlserver/index.js.map +3 -3
- package/dist/lib/adapters/sqlserver/sqlserver.d.ts.map +1 -1
- package/dist/lib/sql.d.ts +1 -0
- package/dist/lib/sql.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -148,6 +148,17 @@ function relationship(input) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// packages/text2sql/src/lib/adapters/groundings/context.ts
|
|
151
|
+
var noopProgress = () => {
|
|
152
|
+
};
|
|
153
|
+
function timestampProgress(onProgress) {
|
|
154
|
+
if (!onProgress) return noopProgress;
|
|
155
|
+
return (progress) => {
|
|
156
|
+
onProgress({
|
|
157
|
+
...progress,
|
|
158
|
+
timestampMs: progress.timestampMs ?? Date.now()
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
}
|
|
151
162
|
function createGroundingContext(options = {}) {
|
|
152
163
|
return {
|
|
153
164
|
tables: [],
|
|
@@ -155,7 +166,7 @@ function createGroundingContext(options = {}) {
|
|
|
155
166
|
relationships: [],
|
|
156
167
|
info: void 0,
|
|
157
168
|
cache: /* @__PURE__ */ new Map(),
|
|
158
|
-
onProgress: options.onProgress
|
|
169
|
+
onProgress: timestampProgress(options.onProgress)
|
|
159
170
|
};
|
|
160
171
|
}
|
|
161
172
|
|
|
@@ -302,7 +313,7 @@ var Adapter = class {
|
|
|
302
313
|
for (const fn of this.grounding) {
|
|
303
314
|
const grounding = fn(this);
|
|
304
315
|
if (grounding.phase) {
|
|
305
|
-
ctx.onProgress
|
|
316
|
+
ctx.onProgress({
|
|
306
317
|
type: "phase:start",
|
|
307
318
|
phase: grounding.phase,
|
|
308
319
|
message: `Starting ${grounding.name} introspection...`
|
|
@@ -312,7 +323,7 @@ var Adapter = class {
|
|
|
312
323
|
await grounding.execute(ctx);
|
|
313
324
|
} finally {
|
|
314
325
|
if (grounding.phase) {
|
|
315
|
-
ctx.onProgress
|
|
326
|
+
ctx.onProgress({
|
|
316
327
|
type: "phase:end",
|
|
317
328
|
phase: grounding.phase,
|
|
318
329
|
message: `Finished ${grounding.name} introspection.`
|
|
@@ -694,7 +705,7 @@ var ColumnStatsGrounding = class extends AbstractGrounding {
|
|
|
694
705
|
const total = allContainers.length;
|
|
695
706
|
for (let i = 0; i < allContainers.length; i++) {
|
|
696
707
|
const container = allContainers[i];
|
|
697
|
-
ctx.onProgress
|
|
708
|
+
ctx.onProgress({
|
|
698
709
|
type: "phase:progress",
|
|
699
710
|
phase: "column_stats",
|
|
700
711
|
table: container.name,
|
|
@@ -812,7 +823,7 @@ var ColumnValuesGrounding = class extends AbstractGrounding {
|
|
|
812
823
|
const total = allContainers.length;
|
|
813
824
|
for (let i = 0; i < allContainers.length; i++) {
|
|
814
825
|
const container = allContainers[i];
|
|
815
|
-
ctx.onProgress
|
|
826
|
+
ctx.onProgress({
|
|
816
827
|
type: "phase:progress",
|
|
817
828
|
phase: "column_values",
|
|
818
829
|
table: container.name,
|
|
@@ -883,7 +894,7 @@ var ConstraintGrounding = class extends AbstractGrounding {
|
|
|
883
894
|
const total = ctx.tables.length;
|
|
884
895
|
for (let i = 0; i < ctx.tables.length; i++) {
|
|
885
896
|
const table2 = ctx.tables[i];
|
|
886
|
-
ctx.onProgress
|
|
897
|
+
ctx.onProgress({
|
|
887
898
|
type: "phase:progress",
|
|
888
899
|
phase: "constraints",
|
|
889
900
|
table: table2.name,
|
|
@@ -913,7 +924,7 @@ var IndexesGrounding = class extends AbstractGrounding {
|
|
|
913
924
|
const total = ctx.tables.length;
|
|
914
925
|
for (let i = 0; i < ctx.tables.length; i++) {
|
|
915
926
|
const table2 = ctx.tables[i];
|
|
916
|
-
ctx.onProgress
|
|
927
|
+
ctx.onProgress({
|
|
917
928
|
type: "phase:progress",
|
|
918
929
|
phase: "indexes",
|
|
919
930
|
table: table2.name,
|
|
@@ -961,7 +972,7 @@ var RowCountGrounding = class extends AbstractGrounding {
|
|
|
961
972
|
const total = ctx.tables.length;
|
|
962
973
|
for (let i = 0; i < ctx.tables.length; i++) {
|
|
963
974
|
const table2 = ctx.tables[i];
|
|
964
|
-
ctx.onProgress
|
|
975
|
+
ctx.onProgress({
|
|
965
976
|
type: "phase:progress",
|
|
966
977
|
phase: "row_counts",
|
|
967
978
|
table: table2.name,
|
|
@@ -1012,7 +1023,7 @@ var TableGrounding = class extends AbstractGrounding {
|
|
|
1012
1023
|
if (!forward && !backward) {
|
|
1013
1024
|
const tables3 = await Promise.all(
|
|
1014
1025
|
seedTables.map(async (name, index2) => {
|
|
1015
|
-
ctx.onProgress
|
|
1026
|
+
ctx.onProgress({
|
|
1016
1027
|
type: "phase:progress",
|
|
1017
1028
|
phase: "tables",
|
|
1018
1029
|
table: name,
|
|
@@ -1047,7 +1058,7 @@ var TableGrounding = class extends AbstractGrounding {
|
|
|
1047
1058
|
forwardVisited.add(name);
|
|
1048
1059
|
if (!tables2[name]) {
|
|
1049
1060
|
loadedCount++;
|
|
1050
|
-
ctx.onProgress
|
|
1061
|
+
ctx.onProgress({
|
|
1051
1062
|
type: "phase:progress",
|
|
1052
1063
|
phase: "tables",
|
|
1053
1064
|
table: name,
|
|
@@ -1079,7 +1090,7 @@ var TableGrounding = class extends AbstractGrounding {
|
|
|
1079
1090
|
backwardVisited.add(name);
|
|
1080
1091
|
if (!tables2[name]) {
|
|
1081
1092
|
loadedCount++;
|
|
1082
|
-
ctx.onProgress
|
|
1093
|
+
ctx.onProgress({
|
|
1083
1094
|
type: "phase:progress",
|
|
1084
1095
|
phase: "tables",
|
|
1085
1096
|
table: name,
|
|
@@ -1571,6 +1582,8 @@ var SQL_SERVER_ERROR_MAP = {
|
|
|
1571
1582
|
}
|
|
1572
1583
|
};
|
|
1573
1584
|
var LOW_CARDINALITY_LIMIT = 20;
|
|
1585
|
+
var noopProgress2 = () => {
|
|
1586
|
+
};
|
|
1574
1587
|
function getErrorCode(error) {
|
|
1575
1588
|
if (typeof error === "object" && error !== null && "number" in error && typeof error.number === "number") {
|
|
1576
1589
|
return String(error.number);
|
|
@@ -1725,12 +1738,12 @@ var SqlServer = class extends Adapter {
|
|
|
1725
1738
|
}
|
|
1726
1739
|
return Array.from(relationships.values());
|
|
1727
1740
|
}
|
|
1728
|
-
async #annotateRowCounts(tables2, onProgress) {
|
|
1741
|
+
async #annotateRowCounts(tables2, onProgress = noopProgress2) {
|
|
1729
1742
|
const total = tables2.length;
|
|
1730
1743
|
for (let i = 0; i < tables2.length; i++) {
|
|
1731
1744
|
const table2 = tables2[i];
|
|
1732
1745
|
const tableIdentifier = this.#formatQualifiedTableName(table2);
|
|
1733
|
-
onProgress
|
|
1746
|
+
onProgress({
|
|
1734
1747
|
type: "phase:progress",
|
|
1735
1748
|
phase: "row_counts",
|
|
1736
1749
|
table: table2.name,
|
|
@@ -1819,7 +1832,7 @@ var SqlServer = class extends Adapter {
|
|
|
1819
1832
|
}
|
|
1820
1833
|
}
|
|
1821
1834
|
}
|
|
1822
|
-
async #annotateColumnStats(tables2, onProgress) {
|
|
1835
|
+
async #annotateColumnStats(tables2, onProgress = noopProgress2) {
|
|
1823
1836
|
if (!tables2.length) {
|
|
1824
1837
|
return;
|
|
1825
1838
|
}
|
|
@@ -1827,7 +1840,7 @@ var SqlServer = class extends Adapter {
|
|
|
1827
1840
|
for (let i = 0; i < tables2.length; i++) {
|
|
1828
1841
|
const table2 = tables2[i];
|
|
1829
1842
|
const tableIdentifier = this.#formatQualifiedTableName(table2);
|
|
1830
|
-
onProgress
|
|
1843
|
+
onProgress({
|
|
1831
1844
|
type: "phase:progress",
|
|
1832
1845
|
phase: "column_stats",
|
|
1833
1846
|
table: table2.name,
|
|
@@ -1866,12 +1879,12 @@ var SqlServer = class extends Adapter {
|
|
|
1866
1879
|
}
|
|
1867
1880
|
}
|
|
1868
1881
|
}
|
|
1869
|
-
async #annotateLowCardinalityColumns(tables2, onProgress) {
|
|
1882
|
+
async #annotateLowCardinalityColumns(tables2, onProgress = noopProgress2) {
|
|
1870
1883
|
const total = tables2.length;
|
|
1871
1884
|
for (let i = 0; i < tables2.length; i++) {
|
|
1872
1885
|
const table2 = tables2[i];
|
|
1873
1886
|
const tableIdentifier = this.#formatQualifiedTableName(table2);
|
|
1874
|
-
onProgress
|
|
1887
|
+
onProgress({
|
|
1875
1888
|
type: "phase:progress",
|
|
1876
1889
|
phase: "low_cardinality",
|
|
1877
1890
|
table: table2.name,
|
|
@@ -2174,7 +2187,7 @@ var ViewGrounding = class extends AbstractGrounding {
|
|
|
2174
2187
|
const viewNames = await this.applyFilter();
|
|
2175
2188
|
const views2 = await Promise.all(
|
|
2176
2189
|
viewNames.map(async (name, index2) => {
|
|
2177
|
-
ctx.onProgress
|
|
2190
|
+
ctx.onProgress({
|
|
2178
2191
|
type: "phase:progress",
|
|
2179
2192
|
phase: "views",
|
|
2180
2193
|
table: name,
|