@memberjunction/cli 2.121.0 → 2.122.1
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 +41 -0
- package/bin/dev.cmd +2 -2
- package/bin/run.cmd +3 -3
- package/dist/commands/dbdoc/export-sample-queries.d.ts +18 -0
- package/dist/commands/dbdoc/export-sample-queries.js +120 -0
- package/dist/commands/sync/push.js +1 -0
- package/oclif.manifest.json +109 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -494,6 +494,7 @@ Available dbdoc commands:
|
|
|
494
494
|
- `analyze` - Analyze database and generate documentation
|
|
495
495
|
- `generate-queries` - Generate sample SQL queries from existing analysis state
|
|
496
496
|
- `export` - Export documentation in multiple formats (SQL, Markdown, HTML, CSV, Mermaid)
|
|
497
|
+
- `export-sample-queries` - Export sample queries to MemberJunction metadata format
|
|
497
498
|
- `status` - Show analysis status and progress
|
|
498
499
|
- `reset` - Reset analysis state
|
|
499
500
|
|
|
@@ -522,6 +523,19 @@ mj dbdoc generate-queries --from-state ./output/run-1/state.json \
|
|
|
522
523
|
--queries-per-table 10 \
|
|
523
524
|
--output-dir ./queries
|
|
524
525
|
|
|
526
|
+
# Export sample queries to MemberJunction metadata format
|
|
527
|
+
mj dbdoc export-sample-queries \
|
|
528
|
+
--input ./output/sample-queries.json \
|
|
529
|
+
--output ./metadata/queries/.queries.json
|
|
530
|
+
|
|
531
|
+
# Export with separate SQL files and category
|
|
532
|
+
mj dbdoc export-sample-queries \
|
|
533
|
+
--input ./output/sample-queries.json \
|
|
534
|
+
--output ./metadata/queries/.queries.json \
|
|
535
|
+
--separate-sql-files \
|
|
536
|
+
--category "Database Documentation" \
|
|
537
|
+
--min-confidence 0.8
|
|
538
|
+
|
|
525
539
|
# Export all formats
|
|
526
540
|
mj dbdoc export --sql --markdown --html --csv --mermaid
|
|
527
541
|
|
|
@@ -561,6 +575,18 @@ mj dbdoc reset --force
|
|
|
561
575
|
- `--queries-per-table <number>`: Number of queries to generate per table (optional, overrides config)
|
|
562
576
|
- `--max-execution-time <ms>`: Maximum execution time for query validation in milliseconds (optional, overrides config)
|
|
563
577
|
|
|
578
|
+
**Export Sample Queries Command:**
|
|
579
|
+
- `-i, --input <path>`: Path to sample-queries.json file from generate-queries (required)
|
|
580
|
+
- `-o, --output <path>`: Output path for the .queries.json metadata file (required)
|
|
581
|
+
- `--separate-sql-files`: Write SQL to separate files and use @file: references
|
|
582
|
+
- `--sql-dir <name>`: Directory for SQL files when using --separate-sql-files (default: SQL)
|
|
583
|
+
- `--category <name>`: Category name for @lookup reference (e.g., "Database Documentation")
|
|
584
|
+
- `--status <value>`: Status to assign (Approved/Pending/Rejected/Expired, default: Pending)
|
|
585
|
+
- `--min-confidence <value>`: Minimum confidence threshold to export (0-1, default: 0)
|
|
586
|
+
- `--validated-only`: Only export queries that were successfully validated
|
|
587
|
+
- `--append`: Append to existing metadata file instead of overwriting
|
|
588
|
+
- `--include-primary-key`: Include primaryKey and sync fields (for updating existing records)
|
|
589
|
+
|
|
564
590
|
**Export Command:**
|
|
565
591
|
- `-s, --state-file <path>`: Path to state JSON file
|
|
566
592
|
- `-o, --output-dir <path>`: Output directory for generated files
|
|
@@ -640,11 +666,26 @@ Or generate separately from existing state:
|
|
|
640
666
|
mj dbdoc generate-queries --from-state ./output/run-1/state.json
|
|
641
667
|
```
|
|
642
668
|
|
|
669
|
+
**Export to MemberJunction Metadata:**
|
|
670
|
+
|
|
671
|
+
Transform generated queries into MemberJunction's Query entity format for use with AI agents like Skip:
|
|
672
|
+
```bash
|
|
673
|
+
mj dbdoc export-sample-queries \
|
|
674
|
+
--input ./output/sample-queries.json \
|
|
675
|
+
--output ./metadata/queries/.queries.json \
|
|
676
|
+
--category "Database Documentation" \
|
|
677
|
+
--separate-sql-files
|
|
678
|
+
|
|
679
|
+
# Then sync to database
|
|
680
|
+
mj sync push ./metadata/queries/
|
|
681
|
+
```
|
|
682
|
+
|
|
643
683
|
**Use Cases:**
|
|
644
684
|
- Training AI agents to generate consistent multi-query patterns
|
|
645
685
|
- Creating reference examples for few-shot prompting
|
|
646
686
|
- Documenting common query patterns for your database
|
|
647
687
|
- Validating that related queries use consistent filtering logic
|
|
688
|
+
- Syncing generated queries to MemberJunction's Query entity for use by Skip
|
|
648
689
|
|
|
649
690
|
---
|
|
650
691
|
|
package/bin/dev.cmd
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
3
|
node "%~dp0\dev" %*
|
package/bin/run.cmd
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
|
|
3
|
-
node "%~dp0\run" %*
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
node "%~dp0\run" %*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class DbDocExportSampleQueries extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
input: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
'separate-sql-files': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'sql-dir': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
category: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
status: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
'min-confidence': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
'validated-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
append: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
'include-primary-key': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const core_1 = require("@oclif/core");
|
|
27
|
+
class DbDocExportSampleQueries extends core_1.Command {
|
|
28
|
+
static description = 'Export sample queries to MemberJunction metadata format (delegates to db-auto-doc export-sample-queries)';
|
|
29
|
+
static examples = [
|
|
30
|
+
'<%= config.bin %> <%= command.id %> --input ./output/sample-queries.json --output ./metadata/queries/.queries.json',
|
|
31
|
+
'<%= config.bin %> <%= command.id %> --input ./sample-queries.json --output ./metadata/queries/.queries.json --separate-sql-files',
|
|
32
|
+
'<%= config.bin %> <%= command.id %> --input ./sample-queries.json --output ./queries/.queries.json --category "Database Documentation"',
|
|
33
|
+
'<%= config.bin %> <%= command.id %> --input ./sample-queries.json --output ./queries/.queries.json --status Pending --min-confidence 0.8',
|
|
34
|
+
];
|
|
35
|
+
static flags = {
|
|
36
|
+
input: core_1.Flags.string({
|
|
37
|
+
char: 'i',
|
|
38
|
+
description: 'Path to sample-queries.json file generated by generate-queries command',
|
|
39
|
+
required: true
|
|
40
|
+
}),
|
|
41
|
+
output: core_1.Flags.string({
|
|
42
|
+
char: 'o',
|
|
43
|
+
description: 'Output path for the .queries.json metadata file',
|
|
44
|
+
required: true
|
|
45
|
+
}),
|
|
46
|
+
'separate-sql-files': core_1.Flags.boolean({
|
|
47
|
+
description: 'Write SQL to separate files and use @file: references',
|
|
48
|
+
default: false
|
|
49
|
+
}),
|
|
50
|
+
'sql-dir': core_1.Flags.string({
|
|
51
|
+
description: 'Directory for SQL files when using --separate-sql-files (relative to output file)',
|
|
52
|
+
default: 'SQL'
|
|
53
|
+
}),
|
|
54
|
+
category: core_1.Flags.string({
|
|
55
|
+
description: 'Category name for @lookup reference (e.g., "Database Documentation")',
|
|
56
|
+
required: false
|
|
57
|
+
}),
|
|
58
|
+
status: core_1.Flags.string({
|
|
59
|
+
description: 'Status to assign to exported queries',
|
|
60
|
+
options: ['Approved', 'Pending', 'Rejected', 'Expired'],
|
|
61
|
+
default: 'Pending'
|
|
62
|
+
}),
|
|
63
|
+
'min-confidence': core_1.Flags.string({
|
|
64
|
+
description: 'Minimum confidence threshold to export (0-1)',
|
|
65
|
+
default: '0'
|
|
66
|
+
}),
|
|
67
|
+
'validated-only': core_1.Flags.boolean({
|
|
68
|
+
description: 'Only export queries that were successfully validated',
|
|
69
|
+
default: false
|
|
70
|
+
}),
|
|
71
|
+
append: core_1.Flags.boolean({
|
|
72
|
+
description: 'Append to existing metadata file instead of overwriting',
|
|
73
|
+
default: false
|
|
74
|
+
}),
|
|
75
|
+
'include-primary-key': core_1.Flags.boolean({
|
|
76
|
+
description: 'Include primaryKey and sync fields (for updating existing records)',
|
|
77
|
+
default: false
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
async run() {
|
|
81
|
+
const { flags } = await this.parse(DbDocExportSampleQueries);
|
|
82
|
+
// Load DBAutoDoc command dynamically
|
|
83
|
+
const { default: ExportSampleQueriesCommand } = await Promise.resolve().then(() => __importStar(require('@memberjunction/db-auto-doc/dist/commands/export-sample-queries')));
|
|
84
|
+
// Build args array for DBAutoDoc command
|
|
85
|
+
const args = [];
|
|
86
|
+
if (flags.input) {
|
|
87
|
+
args.push('--input', flags.input);
|
|
88
|
+
}
|
|
89
|
+
if (flags.output) {
|
|
90
|
+
args.push('--output', flags.output);
|
|
91
|
+
}
|
|
92
|
+
if (flags['separate-sql-files']) {
|
|
93
|
+
args.push('--separate-sql-files');
|
|
94
|
+
}
|
|
95
|
+
if (flags['sql-dir'] && flags['sql-dir'] !== 'SQL') {
|
|
96
|
+
args.push('--sql-dir', flags['sql-dir']);
|
|
97
|
+
}
|
|
98
|
+
if (flags.category) {
|
|
99
|
+
args.push('--category', flags.category);
|
|
100
|
+
}
|
|
101
|
+
if (flags.status && flags.status !== 'Pending') {
|
|
102
|
+
args.push('--status', flags.status);
|
|
103
|
+
}
|
|
104
|
+
if (flags['min-confidence'] && flags['min-confidence'] !== '0') {
|
|
105
|
+
args.push('--min-confidence', flags['min-confidence']);
|
|
106
|
+
}
|
|
107
|
+
if (flags['validated-only']) {
|
|
108
|
+
args.push('--validated-only');
|
|
109
|
+
}
|
|
110
|
+
if (flags.append) {
|
|
111
|
+
args.push('--append');
|
|
112
|
+
}
|
|
113
|
+
if (flags['include-primary-key']) {
|
|
114
|
+
args.push('--include-primary-key');
|
|
115
|
+
}
|
|
116
|
+
// Execute the DBAutoDoc export-sample-queries command
|
|
117
|
+
await ExportSampleQueriesCommand.run(args);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.default = DbDocExportSampleQueries;
|
package/oclif.manifest.json
CHANGED
|
@@ -202,6 +202,114 @@
|
|
|
202
202
|
"analyze.js"
|
|
203
203
|
]
|
|
204
204
|
},
|
|
205
|
+
"dbdoc:export-sample-queries": {
|
|
206
|
+
"aliases": [],
|
|
207
|
+
"args": {},
|
|
208
|
+
"description": "Export sample queries to MemberJunction metadata format (delegates to db-auto-doc export-sample-queries)",
|
|
209
|
+
"examples": [
|
|
210
|
+
"<%= config.bin %> <%= command.id %> --input ./output/sample-queries.json --output ./metadata/queries/.queries.json",
|
|
211
|
+
"<%= config.bin %> <%= command.id %> --input ./sample-queries.json --output ./metadata/queries/.queries.json --separate-sql-files",
|
|
212
|
+
"<%= config.bin %> <%= command.id %> --input ./sample-queries.json --output ./queries/.queries.json --category \"Database Documentation\"",
|
|
213
|
+
"<%= config.bin %> <%= command.id %> --input ./sample-queries.json --output ./queries/.queries.json --status Pending --min-confidence 0.8"
|
|
214
|
+
],
|
|
215
|
+
"flags": {
|
|
216
|
+
"input": {
|
|
217
|
+
"char": "i",
|
|
218
|
+
"description": "Path to sample-queries.json file generated by generate-queries command",
|
|
219
|
+
"name": "input",
|
|
220
|
+
"required": true,
|
|
221
|
+
"hasDynamicHelp": false,
|
|
222
|
+
"multiple": false,
|
|
223
|
+
"type": "option"
|
|
224
|
+
},
|
|
225
|
+
"output": {
|
|
226
|
+
"char": "o",
|
|
227
|
+
"description": "Output path for the .queries.json metadata file",
|
|
228
|
+
"name": "output",
|
|
229
|
+
"required": true,
|
|
230
|
+
"hasDynamicHelp": false,
|
|
231
|
+
"multiple": false,
|
|
232
|
+
"type": "option"
|
|
233
|
+
},
|
|
234
|
+
"separate-sql-files": {
|
|
235
|
+
"description": "Write SQL to separate files and use @file: references",
|
|
236
|
+
"name": "separate-sql-files",
|
|
237
|
+
"allowNo": false,
|
|
238
|
+
"type": "boolean"
|
|
239
|
+
},
|
|
240
|
+
"sql-dir": {
|
|
241
|
+
"description": "Directory for SQL files when using --separate-sql-files (relative to output file)",
|
|
242
|
+
"name": "sql-dir",
|
|
243
|
+
"default": "SQL",
|
|
244
|
+
"hasDynamicHelp": false,
|
|
245
|
+
"multiple": false,
|
|
246
|
+
"type": "option"
|
|
247
|
+
},
|
|
248
|
+
"category": {
|
|
249
|
+
"description": "Category name for @lookup reference (e.g., \"Database Documentation\")",
|
|
250
|
+
"name": "category",
|
|
251
|
+
"required": false,
|
|
252
|
+
"hasDynamicHelp": false,
|
|
253
|
+
"multiple": false,
|
|
254
|
+
"type": "option"
|
|
255
|
+
},
|
|
256
|
+
"status": {
|
|
257
|
+
"description": "Status to assign to exported queries",
|
|
258
|
+
"name": "status",
|
|
259
|
+
"default": "Pending",
|
|
260
|
+
"hasDynamicHelp": false,
|
|
261
|
+
"multiple": false,
|
|
262
|
+
"options": [
|
|
263
|
+
"Approved",
|
|
264
|
+
"Pending",
|
|
265
|
+
"Rejected",
|
|
266
|
+
"Expired"
|
|
267
|
+
],
|
|
268
|
+
"type": "option"
|
|
269
|
+
},
|
|
270
|
+
"min-confidence": {
|
|
271
|
+
"description": "Minimum confidence threshold to export (0-1)",
|
|
272
|
+
"name": "min-confidence",
|
|
273
|
+
"default": "0",
|
|
274
|
+
"hasDynamicHelp": false,
|
|
275
|
+
"multiple": false,
|
|
276
|
+
"type": "option"
|
|
277
|
+
},
|
|
278
|
+
"validated-only": {
|
|
279
|
+
"description": "Only export queries that were successfully validated",
|
|
280
|
+
"name": "validated-only",
|
|
281
|
+
"allowNo": false,
|
|
282
|
+
"type": "boolean"
|
|
283
|
+
},
|
|
284
|
+
"append": {
|
|
285
|
+
"description": "Append to existing metadata file instead of overwriting",
|
|
286
|
+
"name": "append",
|
|
287
|
+
"allowNo": false,
|
|
288
|
+
"type": "boolean"
|
|
289
|
+
},
|
|
290
|
+
"include-primary-key": {
|
|
291
|
+
"description": "Include primaryKey and sync fields (for updating existing records)",
|
|
292
|
+
"name": "include-primary-key",
|
|
293
|
+
"allowNo": false,
|
|
294
|
+
"type": "boolean"
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
"hasDynamicHelp": false,
|
|
298
|
+
"hiddenAliases": [],
|
|
299
|
+
"id": "dbdoc:export-sample-queries",
|
|
300
|
+
"pluginAlias": "@memberjunction/cli",
|
|
301
|
+
"pluginName": "@memberjunction/cli",
|
|
302
|
+
"pluginType": "core",
|
|
303
|
+
"strict": true,
|
|
304
|
+
"enableJsonFlag": false,
|
|
305
|
+
"isESM": false,
|
|
306
|
+
"relativePath": [
|
|
307
|
+
"dist",
|
|
308
|
+
"commands",
|
|
309
|
+
"dbdoc",
|
|
310
|
+
"export-sample-queries.js"
|
|
311
|
+
]
|
|
312
|
+
},
|
|
205
313
|
"dbdoc:export": {
|
|
206
314
|
"aliases": [],
|
|
207
315
|
"args": {},
|
|
@@ -2177,5 +2285,5 @@
|
|
|
2177
2285
|
]
|
|
2178
2286
|
}
|
|
2179
2287
|
},
|
|
2180
|
-
"version": "2.
|
|
2288
|
+
"version": "2.122.1"
|
|
2181
2289
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.122.1",
|
|
4
4
|
"description": "MemberJunction command line tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oclif"
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@inquirer/prompts": "^5.0.1",
|
|
54
|
-
"@memberjunction/ai-cli": "2.
|
|
55
|
-
"@memberjunction/codegen-lib": "2.
|
|
56
|
-
"@memberjunction/core": "2.
|
|
57
|
-
"@memberjunction/db-auto-doc": "2.
|
|
58
|
-
"@memberjunction/metadata-sync": "2.
|
|
59
|
-
"@memberjunction/sqlserver-dataprovider": "2.
|
|
60
|
-
"@memberjunction/testing-cli": "2.
|
|
54
|
+
"@memberjunction/ai-cli": "2.122.1",
|
|
55
|
+
"@memberjunction/codegen-lib": "2.122.1",
|
|
56
|
+
"@memberjunction/core": "2.122.1",
|
|
57
|
+
"@memberjunction/db-auto-doc": "2.122.1",
|
|
58
|
+
"@memberjunction/metadata-sync": "2.122.1",
|
|
59
|
+
"@memberjunction/sqlserver-dataprovider": "2.122.1",
|
|
60
|
+
"@memberjunction/testing-cli": "2.122.1",
|
|
61
61
|
"@oclif/core": "^3",
|
|
62
62
|
"@oclif/plugin-help": "^6",
|
|
63
63
|
"@oclif/plugin-version": "^2.0.17",
|