querydig 0.1.1 → 0.2.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/scan.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type QuerydigConfig } from './config.js';
2
2
  import { type Finding, type ScanSummary } from './types.js';
3
+ import type { LiveOptions } from './live/types.js';
3
4
  export interface ScanOptions extends QuerydigConfig {
4
5
  root: string;
5
6
  files?: string[];
@@ -7,6 +8,9 @@ export interface ScanOptions extends QuerydigConfig {
7
8
  baseline?: Set<string> | Map<string, number>;
8
9
  threads?: number;
9
10
  onProgress?: (done: number, total: number) => void;
11
+ /** connect to a live database for evidence (--uri) */
12
+ live?: LiveOptions;
13
+ onLiveStart?: () => void;
10
14
  }
11
15
  export declare function listFiles(opts: ScanOptions): Promise<string[]>;
12
16
  export declare function gradeFor(findings: Finding[], files: number): {
package/dist/types.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface Finding {
9
9
  title: string;
10
10
  severity: Severity;
11
11
  db: Db;
12
- lang: LangId;
12
+ lang: LangId | 'db';
13
13
  file: string;
14
14
  line: number;
15
15
  column: number;
@@ -18,10 +18,58 @@ export interface Finding {
18
18
  fix: string;
19
19
  confidence: Confidence;
20
20
  fingerprint: string;
21
+ /** id of the static query shape this finding belongs to (for live correlation) */
22
+ shapeId?: string;
23
+ /** evidence gathered from a live database (--uri) */
24
+ evidence?: Evidence;
25
+ }
26
+ export interface SortKey {
27
+ key: string;
28
+ dir: 1 | -1;
29
+ }
30
+ /** A database call found in the code, described well enough to explain it against a live DB. */
31
+ export interface QueryShape {
32
+ id: string;
33
+ db: Db;
34
+ orm?: string;
35
+ collection?: string;
36
+ method: string;
37
+ kind: string;
38
+ filterKeys: string[];
39
+ sortKeys: SortKey[];
40
+ hasLimit: boolean;
41
+ inLoop: boolean;
42
+ sql?: string;
43
+ file: string;
44
+ line: number;
45
+ }
46
+ export interface Evidence {
47
+ source: 'explain' | 'profiler' | 'stats' | 'indexes';
48
+ collection?: string;
49
+ rows?: number;
50
+ plan?: string;
51
+ index?: string;
52
+ ms?: number;
53
+ docsExamined?: number;
54
+ note: string;
55
+ severityChange?: {
56
+ from: Severity;
57
+ to: Severity;
58
+ };
21
59
  }
22
60
  export interface FileResult {
23
61
  file: string;
24
62
  findings: Finding[];
63
+ shapes?: QueryShape[];
64
+ error?: string;
65
+ }
66
+ export interface LiveSummary {
67
+ adapter: 'mongodb' | 'postgres';
68
+ database: string;
69
+ tables: number;
70
+ explained: number;
71
+ slowQueries: number;
72
+ warnings: string[];
25
73
  error?: string;
26
74
  }
27
75
  export interface ScanSummary {
@@ -39,4 +87,5 @@ export interface ScanSummary {
39
87
  error: string;
40
88
  }[];
41
89
  version: string;
90
+ live?: LiveSummary;
42
91
  }
package/dist/worker.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  analyzeFile
3
- } from "./chunk-VAYEO4RI.js";
3
+ } from "./chunk-DZLU5MLV.js";
4
+ import "./chunk-YKUITQ6N.js";
4
5
 
5
6
  // src/worker.ts
6
7
  import { parentPort } from "worker_threads";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "querydig",
3
- "version": "0.1.1",
4
- "description": "Find slow, N+1 and unoptimized database queries (MongoDB, Postgres, MySQL) in JS/TS, Python and Go code. Zero-config CLI for local runs and CI.",
3
+ "version": "0.2.0",
4
+ "description": "Find slow, N+1 and unoptimized database queries (MongoDB, Postgres, MySQL) in JS/TS, Python and Go code, with optional read-only live evidence from your database. Zero-config CLI for local runs and CI.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsup && tsc -p tsconfig.build.json && node -e \"require('fs').chmodSync('dist/cli.js',0o755)\"",
@@ -37,6 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^26.6.6",
40
+ "@types/pg": "^8.23.1",
40
41
  "tree-sitter-wasms": "^0.1.13",
41
42
  "tsup": "^9.0.0",
42
43
  "tsx": "^4.23.15",
@@ -66,8 +67,12 @@
66
67
  "type": "git",
67
68
  "url": "git+https://github.com/milankatira/querydig.git"
68
69
  },
69
- "homepage": "https://github.com/milankatira/querydig#readme",
70
+ "homepage": "https://milankatira.github.io/querydig/",
70
71
  "bugs": {
71
72
  "url": "https://github.com/milankatira/querydig/issues"
73
+ },
74
+ "optionalDependencies": {
75
+ "mongodb": "^7.8.0",
76
+ "pg": "^8.23.1"
72
77
  }
73
78
  }