@deepagents/text2sql 0.38.0 → 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 +90 -44
- package/dist/index.js +51 -25
- 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 +9 -3
- package/dist/lib/sql.d.ts.map +1 -1
- package/package.json +11 -10
|
@@ -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,
|
|
@@ -1659,7 +1670,7 @@ var ViewGrounding = class extends AbstractGrounding {
|
|
|
1659
1670
|
const viewNames = await this.applyFilter();
|
|
1660
1671
|
const views2 = await Promise.all(
|
|
1661
1672
|
viewNames.map(async (name, index2) => {
|
|
1662
|
-
ctx.onProgress
|
|
1673
|
+
ctx.onProgress({
|
|
1663
1674
|
type: "phase:progress",
|
|
1664
1675
|
phase: "views",
|
|
1665
1676
|
table: name,
|