@dbx-app/node-core 0.4.5 → 0.4.7

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.
@@ -1,4 +1,4 @@
1
- import { evaluateMongoAggregateSafety, evaluateMongoWriteSafety, inferMongoColumns, mongoDocumentsToQueryResult, parseMongoAggregateCommand, parseMongoCountDocumentsCommand, parseMongoFindCommand, parseMongoWriteCommand, } from "./database.js";
1
+ import { evaluateMongoAggregateSafety, evaluateMongoWriteSafety, inferMongoColumns, mongoDocumentsToQueryResult, parseMongoAggregateCommand, parseMongoCountDocumentsCommand, parseMongoFindCommand, parseMongoGetIndexesCommand, parseMongoWriteCommand, } from "./database.js";
2
2
  import { sqlSafetyFromEnv } from "./sql-safety.js";
3
3
  const baseUrl = process.env.DBX_WEB_URL.replace(/\/+$/, "");
4
4
  const password = process.env.DBX_WEB_PASSWORD || "";
@@ -164,6 +164,21 @@ export async function executeQuery(config, sql, options) {
164
164
  const result = (await res.json());
165
165
  return mongoDocumentsToQueryResult(result.documents.slice(0, options?.maxRows ?? result.documents.length), result.total);
166
166
  }
167
+ const getIndexes = parseMongoGetIndexesCommand(sql);
168
+ if (getIndexes) {
169
+ const res = await apiFetch("/api/mongo/aggregate-documents", {
170
+ method: "POST",
171
+ body: JSON.stringify({
172
+ connectionId: config.id,
173
+ database: config.database || "",
174
+ collection: getIndexes.collection,
175
+ pipelineJson: '[{"$indexStats":{}}]',
176
+ maxRows: options?.maxRows ?? 100,
177
+ }),
178
+ });
179
+ const result = (await res.json());
180
+ return mongoDocumentsToQueryResult(result.documents.slice(0, options?.maxRows ?? result.documents.length), result.total);
181
+ }
167
182
  const write = parseMongoWriteCommand(sql);
168
183
  if (write) {
169
184
  const safety = evaluateMongoWriteSafety(write, sqlSafetyFromEnv());
@@ -172,7 +187,7 @@ export async function executeQuery(config, sql, options) {
172
187
  const affected = await executeMongoWrite(config, write);
173
188
  return { columns: [], rows: [], row_count: affected };
174
189
  }
175
- throw new Error("Use MongoDB shell-style commands, for example: db.projects.find({}).limit(100), db.projects.countDocuments({}), db.projects.insertOne({...}), db.projects.updateOne({...}, {$set: {...}}), or db.projects.deleteOne({...})");
190
+ throw new Error("Use MongoDB shell-style commands, for example: db.projects.find({}).limit(100), db.projects.countDocuments({}), db.projects.getIndexes(), db.projects.insertOne({...}), db.projects.updateOne({...}, {$set: {...}}), or db.projects.deleteOne({...})");
176
191
  }
177
192
  const res = await apiFetch("/api/query/execute", {
178
193
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbx-app/node-core",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Shared Node.js database and DBX connection utilities for DBX CLI and MCP server",
5
5
  "type": "module",
6
6
  "engines": {
@@ -22,7 +22,7 @@
22
22
  "./schema-context": "./dist/schema-context.js",
23
23
  "./sql-safety": "./dist/sql-safety.js"
24
24
  },
25
- "license": "MIT",
25
+ "license": "Apache-2.0",
26
26
  "dependencies": {
27
27
  "better-sqlite3": "^12.9.0",
28
28
  "keytar": "^7.9.0",
@@ -37,7 +37,7 @@
37
37
  "typescript": "^5.8.3"
38
38
  },
39
39
  "scripts": {
40
- "test": "tsx --test tests/*.test.ts",
40
+ "test": "vitest run --config vitest.config.ts",
41
41
  "build": "tsc"
42
42
  }
43
43
  }