dbnexus 0.5.4 → 0.6.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/dist/api.js +1208 -867
- package/dist/cli.js +45 -7
- package/dist/web/assets/{index-DCJ7drPm.js → index-6pOQ4v1N.js} +100 -100
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -34357,7 +34357,7 @@ var ServerRepository = class {
|
|
|
34357
34357
|
};
|
|
34358
34358
|
|
|
34359
34359
|
// apps/cli/dist/version.js
|
|
34360
|
-
var VERSION = true ? "0.
|
|
34360
|
+
var VERSION = true ? "0.6.0" : "0.1.10";
|
|
34361
34361
|
|
|
34362
34362
|
// apps/cli/dist/commands/init.js
|
|
34363
34363
|
function loadEnvFile(cwd) {
|
|
@@ -34814,7 +34814,7 @@ var esm_default = import_lib.default;
|
|
|
34814
34814
|
|
|
34815
34815
|
// packages/connectors/dist/postgres/postgres.connector.js
|
|
34816
34816
|
var { Pool: Pool2 } = esm_default;
|
|
34817
|
-
var PostgresConnector = class {
|
|
34817
|
+
var PostgresConnector = class _PostgresConnector {
|
|
34818
34818
|
pool = null;
|
|
34819
34819
|
config;
|
|
34820
34820
|
constructor(config2) {
|
|
@@ -34880,20 +34880,56 @@ var PostgresConnector = class {
|
|
|
34880
34880
|
isConnected() {
|
|
34881
34881
|
return this.pool !== null;
|
|
34882
34882
|
}
|
|
34883
|
+
/**
|
|
34884
|
+
* node-pg returns an array of Result objects when the SQL string contains multiple
|
|
34885
|
+
* statements (simple query protocol). Callers expect a single Result shape.
|
|
34886
|
+
*/
|
|
34887
|
+
static normalizePoolQueryResults(raw) {
|
|
34888
|
+
if (Array.isArray(raw)) {
|
|
34889
|
+
return raw;
|
|
34890
|
+
}
|
|
34891
|
+
if (raw != null && typeof raw === "object") {
|
|
34892
|
+
return [raw];
|
|
34893
|
+
}
|
|
34894
|
+
return [];
|
|
34895
|
+
}
|
|
34896
|
+
static emptyPgQueryResult() {
|
|
34897
|
+
return {
|
|
34898
|
+
rows: [],
|
|
34899
|
+
fields: [],
|
|
34900
|
+
rowCount: 0,
|
|
34901
|
+
command: "",
|
|
34902
|
+
oid: 0
|
|
34903
|
+
};
|
|
34904
|
+
}
|
|
34905
|
+
/** Last statement wins (matches common SQL client behavior). */
|
|
34906
|
+
static pickLastPgQueryResult(results) {
|
|
34907
|
+
if (results.length === 0) {
|
|
34908
|
+
return _PostgresConnector.emptyPgQueryResult();
|
|
34909
|
+
}
|
|
34910
|
+
return results[results.length - 1];
|
|
34911
|
+
}
|
|
34912
|
+
static fieldPackets(result) {
|
|
34913
|
+
const f = result.fields;
|
|
34914
|
+
return Array.isArray(f) ? f : [];
|
|
34915
|
+
}
|
|
34883
34916
|
async query(sql, params) {
|
|
34884
34917
|
if (!this.pool) {
|
|
34885
34918
|
throw new Error("Not connected to database");
|
|
34886
34919
|
}
|
|
34887
34920
|
const startTime = Date.now();
|
|
34888
|
-
const
|
|
34921
|
+
const raw = await this.pool.query(sql, params);
|
|
34889
34922
|
const executionTimeMs = Date.now() - startTime;
|
|
34890
|
-
const
|
|
34923
|
+
const results = _PostgresConnector.normalizePoolQueryResults(raw);
|
|
34924
|
+
const result = _PostgresConnector.pickLastPgQueryResult(results);
|
|
34925
|
+
const fields = _PostgresConnector.fieldPackets(result);
|
|
34926
|
+
const columns = fields.map((field) => ({
|
|
34891
34927
|
name: field.name,
|
|
34892
34928
|
dataType: this.pgTypeToString(field.dataTypeID)
|
|
34893
34929
|
}));
|
|
34894
34930
|
return {
|
|
34895
34931
|
columns,
|
|
34896
|
-
rows: result.rows,
|
|
34932
|
+
rows: result.rows ?? [],
|
|
34897
34933
|
rowCount: result.rowCount ?? 0,
|
|
34898
34934
|
executionTimeMs,
|
|
34899
34935
|
truncated: false
|
|
@@ -34903,8 +34939,10 @@ var PostgresConnector = class {
|
|
|
34903
34939
|
if (!this.pool) {
|
|
34904
34940
|
throw new Error("Not connected to database");
|
|
34905
34941
|
}
|
|
34906
|
-
const
|
|
34907
|
-
|
|
34942
|
+
const raw = await this.pool.query(sql, params);
|
|
34943
|
+
const results = _PostgresConnector.normalizePoolQueryResults(raw);
|
|
34944
|
+
const rowsAffected = results.reduce((acc, r) => acc + (r.rowCount ?? 0), 0);
|
|
34945
|
+
return { rowsAffected };
|
|
34908
34946
|
}
|
|
34909
34947
|
async getTables(schema3 = "public") {
|
|
34910
34948
|
if (!this.pool) {
|