@duckcodeailabs/dql-cli 0.1.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/LICENSE +123 -0
- package/dist/args.d.ts +14 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +39 -0
- package/dist/args.js.map +1 -0
- package/dist/commands/certify.d.ts +3 -0
- package/dist/commands/certify.d.ts.map +1 -0
- package/dist/commands/certify.js +62 -0
- package/dist/commands/certify.js.map +1 -0
- package/dist/commands/fmt.d.ts +3 -0
- package/dist/commands/fmt.d.ts.map +1 -0
- package/dist/commands/fmt.js +34 -0
- package/dist/commands/fmt.js.map +1 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +56 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/migrate.d.ts +11 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +106 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/parse.d.ts +3 -0
- package/dist/commands/parse.d.ts.map +1 -0
- package/dist/commands/parse.js +63 -0
- package/dist/commands/parse.js.map +1 -0
- package/dist/commands/test.d.ts +3 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +55 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship.
|
|
41
|
+
|
|
42
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
43
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
44
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
45
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
46
|
+
on behalf of the copyright owner.
|
|
47
|
+
|
|
48
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
49
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
50
|
+
incorporated within the Work.
|
|
51
|
+
|
|
52
|
+
2. Grant of Copyright License.
|
|
53
|
+
|
|
54
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
55
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
56
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
57
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
58
|
+
Derivative Works in Source or Object form.
|
|
59
|
+
|
|
60
|
+
3. Grant of Patent License.
|
|
61
|
+
|
|
62
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
63
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
64
|
+
irrevocable patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution.
|
|
68
|
+
|
|
69
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
70
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
71
|
+
provided that You meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
74
|
+
this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
77
|
+
You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
80
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
81
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
82
|
+
of the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
85
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
86
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
87
|
+
that do not pertain to any part of the Derivative Works.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
92
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
93
|
+
conditions of this License, without any additional terms or conditions.
|
|
94
|
+
|
|
95
|
+
6. Trademarks.
|
|
96
|
+
|
|
97
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
98
|
+
service marks, or product names of the Licensor, except as required for
|
|
99
|
+
reasonable and customary use in describing the origin of the Work.
|
|
100
|
+
|
|
101
|
+
7. Disclaimer of Warranty.
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
104
|
+
Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
105
|
+
express or implied, including, without limitation, any warranties or conditions
|
|
106
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
107
|
+
PURPOSE.
|
|
108
|
+
|
|
109
|
+
8. Limitation of Liability.
|
|
110
|
+
|
|
111
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
112
|
+
contract, or otherwise, unless required by applicable law, shall any Contributor
|
|
113
|
+
be liable to You for damages, including any direct, indirect, special,
|
|
114
|
+
incidental, or consequential damages of any character arising as a result of this
|
|
115
|
+
License or out of the use or inability to use the Work.
|
|
116
|
+
|
|
117
|
+
9. Accepting Warranty or Additional Liability.
|
|
118
|
+
|
|
119
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
120
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
121
|
+
other liability obligations and/or rights consistent with this License.
|
|
122
|
+
|
|
123
|
+
END OF TERMS AND CONDITIONS
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CLIFlags {
|
|
2
|
+
format: 'text' | 'json';
|
|
3
|
+
verbose: boolean;
|
|
4
|
+
help: boolean;
|
|
5
|
+
check: boolean;
|
|
6
|
+
input: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ParsedArgs {
|
|
9
|
+
command: string | null;
|
|
10
|
+
file: string | null;
|
|
11
|
+
flags: CLIFlags;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
14
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAiCpD"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function parseArgs(argv) {
|
|
2
|
+
const flags = {
|
|
3
|
+
format: 'text',
|
|
4
|
+
verbose: false,
|
|
5
|
+
help: false,
|
|
6
|
+
check: false,
|
|
7
|
+
input: '',
|
|
8
|
+
};
|
|
9
|
+
let command = null;
|
|
10
|
+
let file = null;
|
|
11
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12
|
+
const arg = argv[i];
|
|
13
|
+
if (arg === '--help' || arg === '-h') {
|
|
14
|
+
flags.help = true;
|
|
15
|
+
}
|
|
16
|
+
else if (arg === '--verbose' || arg === '-v') {
|
|
17
|
+
flags.verbose = true;
|
|
18
|
+
}
|
|
19
|
+
else if (arg === '--check') {
|
|
20
|
+
flags.check = true;
|
|
21
|
+
}
|
|
22
|
+
else if (arg === '--format' && i + 1 < argv.length) {
|
|
23
|
+
const fmt = argv[++i];
|
|
24
|
+
if (fmt === 'json' || fmt === 'text')
|
|
25
|
+
flags.format = fmt;
|
|
26
|
+
}
|
|
27
|
+
else if (arg === '--input' && i + 1 < argv.length) {
|
|
28
|
+
flags.input = argv[++i];
|
|
29
|
+
}
|
|
30
|
+
else if (!command) {
|
|
31
|
+
command = arg;
|
|
32
|
+
}
|
|
33
|
+
else if (!file) {
|
|
34
|
+
file = arg;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { command, file, flags };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,KAAK,GAAa;QACtB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,IAAI,OAAO,GAAkB,IAAI,CAAC;IAClC,IAAI,IAAI,GAAkB,IAAI,CAAC;IAE/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QACpB,CAAC;aAAM,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC/C,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;aAAM,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAC7B,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,IAAI,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACrD,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACtB,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,MAAM;gBAAE,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3D,CAAC;aAAM,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACpD,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1B,CAAC;aAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,GAAG,GAAG,CAAC;QAChB,CAAC;aAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,IAAI,GAAG,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certify.d.ts","sourceRoot":"","sources":["../../src/commands/certify.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAgEjF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { Parser } from '@duckcodeailabs/dql-core';
|
|
3
|
+
import { Certifier } from '@duckcodeailabs/dql-governance';
|
|
4
|
+
export async function runCertify(filePath, flags) {
|
|
5
|
+
const source = readFileSync(filePath, 'utf-8');
|
|
6
|
+
const parser = new Parser(source, filePath);
|
|
7
|
+
const ast = parser.parse();
|
|
8
|
+
const blocks = ast.statements.filter((s) => s.kind === 'BlockDecl');
|
|
9
|
+
if (blocks.length === 0) {
|
|
10
|
+
console.log('\n ⚠ No block declarations found in file.');
|
|
11
|
+
console.log('');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const certifier = new Certifier();
|
|
15
|
+
for (const block of blocks) {
|
|
16
|
+
const b = block;
|
|
17
|
+
const record = {
|
|
18
|
+
id: 'local',
|
|
19
|
+
name: b.name ?? 'unnamed',
|
|
20
|
+
domain: b.domain ?? '',
|
|
21
|
+
type: b.type ?? '',
|
|
22
|
+
version: '0.0.0',
|
|
23
|
+
status: 'draft',
|
|
24
|
+
gitRepo: '',
|
|
25
|
+
gitPath: filePath,
|
|
26
|
+
gitCommitSha: '',
|
|
27
|
+
description: b.description ?? '',
|
|
28
|
+
owner: b.owner ?? '',
|
|
29
|
+
tags: b.tags ?? [],
|
|
30
|
+
dependencies: [],
|
|
31
|
+
usedInCount: 0,
|
|
32
|
+
createdAt: new Date(),
|
|
33
|
+
updatedAt: new Date(),
|
|
34
|
+
};
|
|
35
|
+
const result = certifier.evaluate(record);
|
|
36
|
+
if (flags.format === 'json') {
|
|
37
|
+
console.log(JSON.stringify(result, null, 2));
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
console.log(`\n Block: "${record.name}"`);
|
|
41
|
+
if (result.certified) {
|
|
42
|
+
console.log(' Status: ✓ CERTIFIABLE');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(' Status: ✗ NOT CERTIFIABLE');
|
|
46
|
+
}
|
|
47
|
+
if (result.errors.length > 0) {
|
|
48
|
+
console.log(`\n Errors (${result.errors.length}):`);
|
|
49
|
+
for (const e of result.errors) {
|
|
50
|
+
console.log(` ✗ ${e.rule}: ${e.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (result.warnings.length > 0) {
|
|
54
|
+
console.log(`\n Warnings (${result.warnings.length}):`);
|
|
55
|
+
for (const w of result.warnings) {
|
|
56
|
+
console.log(` ⚠ ${w.rule}: ${w.message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
console.log('');
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=certify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certify.js","sourceRoot":"","sources":["../../src/commands/certify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAI3D,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB,EAAE,KAAe;IAChE,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IAE3B,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;IAEzE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAElC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,KAAY,CAAC;QACvB,MAAM,MAAM,GAAgB;YAC1B,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,SAAS;YACzB,MAAM,EAAE,CAAC,CAAC,MA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,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC;YACzD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fmt.d.ts","sourceRoot":"","sources":["../../src/commands/fmt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B7E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { formatDQL } from '@duckcodeailabs/dql-core';
|
|
3
|
+
export async function runFmt(filePath, flags) {
|
|
4
|
+
const source = readFileSync(filePath, 'utf-8');
|
|
5
|
+
const formatted = formatDQL(source);
|
|
6
|
+
const changed = source !== formatted;
|
|
7
|
+
if (flags.check) {
|
|
8
|
+
if (flags.format === 'json') {
|
|
9
|
+
console.log(JSON.stringify({ file: filePath, changed, mode: 'check' }, null, 2));
|
|
10
|
+
}
|
|
11
|
+
else if (changed) {
|
|
12
|
+
console.log(`\n ✗ Needs formatting: ${filePath}\n`);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.log(`\n ✓ Already formatted: ${filePath}\n`);
|
|
16
|
+
}
|
|
17
|
+
if (changed)
|
|
18
|
+
process.exit(1);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (changed) {
|
|
22
|
+
writeFileSync(filePath, formatted, 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
if (flags.format === 'json') {
|
|
25
|
+
console.log(JSON.stringify({ file: filePath, changed, mode: 'write' }, null, 2));
|
|
26
|
+
}
|
|
27
|
+
else if (changed) {
|
|
28
|
+
console.log(`\n ✓ Formatted: ${filePath}\n`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.log(`\n ✓ No changes: ${filePath}\n`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=fmt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fmt.js","sourceRoot":"","sources":["../../src/commands/fmt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAgB,EAAE,KAAe;IAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,MAAM,KAAK,SAAS,CAAC;IAErC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACnF,CAAC;aAAM,IAAI,OAAO,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,2BAA2B,QAAQ,IAAI,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC;SAAM,IAAI,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,oBAAoB,QAAQ,IAAI,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,qBAAqB,QAAQ,IAAI,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA0D9E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { Parser } from '@duckcodeailabs/dql-core';
|
|
3
|
+
import { CostEstimator } from '@duckcodeailabs/dql-governance';
|
|
4
|
+
export async function runInfo(filePath, flags) {
|
|
5
|
+
const source = readFileSync(filePath, 'utf-8');
|
|
6
|
+
const parser = new Parser(source, filePath);
|
|
7
|
+
const ast = parser.parse();
|
|
8
|
+
const blocks = ast.statements.filter((s) => s.kind === 'BlockDecl');
|
|
9
|
+
if (blocks.length === 0) {
|
|
10
|
+
console.log('\n ⚠ No block declarations found in file.');
|
|
11
|
+
console.log('');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const estimator = new CostEstimator();
|
|
15
|
+
for (const block of blocks) {
|
|
16
|
+
const b = block;
|
|
17
|
+
if (flags.format === 'json') {
|
|
18
|
+
const cost = b.query ? estimator.estimate(b.query) : null;
|
|
19
|
+
console.log(JSON.stringify({
|
|
20
|
+
name: b.name,
|
|
21
|
+
domain: b.domain,
|
|
22
|
+
type: b.type,
|
|
23
|
+
description: b.description,
|
|
24
|
+
owner: b.owner,
|
|
25
|
+
tags: b.tags,
|
|
26
|
+
query: b.query,
|
|
27
|
+
params: b.params,
|
|
28
|
+
tests: b.tests?.length ?? 0,
|
|
29
|
+
costEstimate: cost,
|
|
30
|
+
}, null, 2));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
console.log(`\n Block: "${b.name ?? 'unnamed'}"`);
|
|
34
|
+
console.log(` Domain: ${b.domain ?? '(none)'}`);
|
|
35
|
+
console.log(` Type: ${b.type ?? '(none)'}`);
|
|
36
|
+
console.log(` Owner: ${b.owner ?? '(none)'}`);
|
|
37
|
+
console.log(` Description: ${b.description ?? '(none)'}`);
|
|
38
|
+
console.log(` Tags: ${b.tags?.length ? b.tags.join(', ') : '(none)'}`);
|
|
39
|
+
console.log(` Params: ${b.params?.length ?? 0}`);
|
|
40
|
+
console.log(` Tests: ${b.tests?.length ?? 0} assertion(s)`);
|
|
41
|
+
if (b.query) {
|
|
42
|
+
const cost = estimator.estimate(b.query);
|
|
43
|
+
console.log(`\n Cost Estimate: ${cost.score}/100`);
|
|
44
|
+
if (cost.recommendation) {
|
|
45
|
+
console.log(` → ${cost.recommendation}`);
|
|
46
|
+
}
|
|
47
|
+
if (cost.factors.length > 0 && flags.verbose) {
|
|
48
|
+
for (const f of cost.factors) {
|
|
49
|
+
console.log(` • ${f.name} (+${f.impact}): ${f.description}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
console.log('');
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,QAAgB,EAAE,KAAe;IAC7D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IAE3B,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;IAEzE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;IAEtC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,KAAY,CAAC;QAEvB,I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IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjF,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,eAAe,CAAC,CAAC;QAErE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACzC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC;YACtD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC7C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CLIFlags } from '../args.js';
|
|
2
|
+
export type MigrationSource = 'looker' | 'tableau' | 'dbt' | 'metabase' | 'raw-sql';
|
|
3
|
+
export interface MigrationResult {
|
|
4
|
+
source: MigrationSource;
|
|
5
|
+
blocksGenerated: number;
|
|
6
|
+
metricsGenerated: number;
|
|
7
|
+
dimensionsGenerated: number;
|
|
8
|
+
needsReview: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function runMigrate(file: string, flags: CLIFlags): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;AAEpF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB;AAuCD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAkF7E"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a DQL block skeleton from a source tool definition.
|
|
3
|
+
*/
|
|
4
|
+
function generateBlockDQL(opts) {
|
|
5
|
+
const tagStr = opts.tags.map((t) => `"${t}"`).join(', ');
|
|
6
|
+
return `block "${opts.name}" {
|
|
7
|
+
domain = "${opts.domain}"
|
|
8
|
+
type = "${opts.type}"
|
|
9
|
+
description = "${opts.description}"
|
|
10
|
+
tags = [${tagStr}]
|
|
11
|
+
owner = "${opts.owner}"
|
|
12
|
+
|
|
13
|
+
query = """
|
|
14
|
+
${opts.sql.split('\n').join('\n ')}
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
visualization {
|
|
18
|
+
chart = "bar"
|
|
19
|
+
x = dimension
|
|
20
|
+
y = measure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
tests {
|
|
24
|
+
assert row_count > 0
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
export async function runMigrate(file, flags) {
|
|
30
|
+
// file is used as the source type for migration
|
|
31
|
+
const source = file;
|
|
32
|
+
const validSources = ['looker', 'tableau', 'dbt', 'metabase', 'raw-sql'];
|
|
33
|
+
if (!validSources.includes(source)) {
|
|
34
|
+
console.error(`\n ✗ Unknown migration source: "${source}"`);
|
|
35
|
+
console.error(` Valid sources: ${validSources.join(', ')}`);
|
|
36
|
+
console.error('');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
if (flags.format === 'json') {
|
|
40
|
+
console.log(JSON.stringify({
|
|
41
|
+
source,
|
|
42
|
+
status: 'scaffold',
|
|
43
|
+
message: `Migration from ${source} is scaffold-only in the OSS CLI. Use the generated block as a starting point.`,
|
|
44
|
+
exampleBlock: generateBlockDQL({
|
|
45
|
+
name: `migrated-from-${source}`,
|
|
46
|
+
domain: 'migrated',
|
|
47
|
+
type: 'chart.bar',
|
|
48
|
+
description: `Auto-migrated from ${source}`,
|
|
49
|
+
sql: 'SELECT dimension, SUM(measure) AS measure\nFROM source_table\nGROUP BY dimension',
|
|
50
|
+
owner: 'migration-bot',
|
|
51
|
+
tags: ['migrated', source],
|
|
52
|
+
}),
|
|
53
|
+
}, null, 2));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.log(`\n DQL Migration: ${source}`);
|
|
57
|
+
console.log(' ─────────────────────────────');
|
|
58
|
+
switch (source) {
|
|
59
|
+
case 'looker':
|
|
60
|
+
console.log(' Source: LookML explores + measures + dimensions');
|
|
61
|
+
console.log(' Method: Parse LookML → generate DQL blocks + semantic layer YAML');
|
|
62
|
+
console.log(' Coverage: ~80% automated');
|
|
63
|
+
break;
|
|
64
|
+
case 'tableau':
|
|
65
|
+
console.log(' Source: Workbook calculations + dashboard structure');
|
|
66
|
+
console.log(' Method: Extract via REST API → generate DQL blocks per sheet');
|
|
67
|
+
console.log(' Coverage: Semi-automated');
|
|
68
|
+
break;
|
|
69
|
+
case 'dbt': {
|
|
70
|
+
const dbtDir = flags.input || '.';
|
|
71
|
+
console.log(` Source: dbt project at "${dbtDir}"`);
|
|
72
|
+
console.log(' Method: Inspect models and metrics, then scaffold DQL blocks and semantic layer files manually.');
|
|
73
|
+
console.log(' Coverage: Planning-only in OSS V1');
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case 'metabase':
|
|
77
|
+
console.log(' Source: Saved questions + dashboard cards');
|
|
78
|
+
console.log(' Method: Export via API → generate DQL blocks per question');
|
|
79
|
+
console.log(' Coverage: ~85% automated');
|
|
80
|
+
break;
|
|
81
|
+
case 'raw-sql':
|
|
82
|
+
console.log(' Source: Ad-hoc SQL scripts');
|
|
83
|
+
console.log(' Method: AI wraps in DQL block structure + adds metadata');
|
|
84
|
+
console.log(' Coverage: AI-assisted');
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
console.log('\n Example generated block:');
|
|
88
|
+
console.log(' ───');
|
|
89
|
+
const example = generateBlockDQL({
|
|
90
|
+
name: `migrated-from-${source}`,
|
|
91
|
+
domain: 'migrated',
|
|
92
|
+
type: 'chart.bar',
|
|
93
|
+
description: `Auto-migrated from ${source}`,
|
|
94
|
+
sql: 'SELECT dimension, SUM(measure) AS measure\nFROM source_table\nGROUP BY dimension',
|
|
95
|
+
owner: 'migration-bot',
|
|
96
|
+
tags: ['migrated', source],
|
|
97
|
+
});
|
|
98
|
+
console.log(example.split('\n').map((l) => ` ${l}`).join('\n'));
|
|
99
|
+
console.log(' Next steps:');
|
|
100
|
+
console.log(` 1. Provide source files: dql migrate ${source} --input <path>`);
|
|
101
|
+
console.log(' 2. Review generated blocks in blocks/migrated/');
|
|
102
|
+
console.log(' 3. Run: dql test blocks/migrated/example.dql');
|
|
103
|
+
console.log(' 4. Commit and push for certification');
|
|
104
|
+
console.log('');
|
|
105
|
+
}
|
|
106
|
+
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E,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/commands/parse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D/E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { Parser, SemanticAnalyzer, printAST } from '@duckcodeailabs/dql-core';
|
|
3
|
+
export async function runParse(filePath, flags) {
|
|
4
|
+
const source = readFileSync(filePath, 'utf-8');
|
|
5
|
+
let ast;
|
|
6
|
+
try {
|
|
7
|
+
const parser = new Parser(source, filePath);
|
|
8
|
+
ast = parser.parse();
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
if (flags.format === 'json') {
|
|
12
|
+
console.log(JSON.stringify({ file: filePath, error: err.message }, null, 2));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.error(`\n ✗ Parse error: ${err.message}\n`);
|
|
16
|
+
}
|
|
17
|
+
process.exit(1);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const analyzer = new SemanticAnalyzer();
|
|
21
|
+
const diagnostics = analyzer.analyze(ast);
|
|
22
|
+
if (flags.format === 'json') {
|
|
23
|
+
console.log(JSON.stringify({
|
|
24
|
+
file: filePath,
|
|
25
|
+
statements: ast.statements.length,
|
|
26
|
+
diagnostics,
|
|
27
|
+
ast: flags.verbose ? ast : undefined,
|
|
28
|
+
}, null, 2));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.log(`\n ✓ Parsed: ${filePath}`);
|
|
32
|
+
console.log(` Statements: ${ast.statements.length}`);
|
|
33
|
+
if (false) {
|
|
34
|
+
const parseErrors = [];
|
|
35
|
+
console.log(`\n ✗ Parse errors (${parseErrors.length}):`);
|
|
36
|
+
for (const e of parseErrors) {
|
|
37
|
+
console.log(` → ${e.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (diagnostics.length > 0) {
|
|
41
|
+
const errors = diagnostics.filter((d) => d.severity === 'error');
|
|
42
|
+
const warnings = diagnostics.filter((d) => d.severity === 'warning');
|
|
43
|
+
if (errors.length > 0) {
|
|
44
|
+
console.log(`\n ✗ Errors (${errors.length}):`);
|
|
45
|
+
for (const e of errors)
|
|
46
|
+
console.log(` → ${e.message}`);
|
|
47
|
+
}
|
|
48
|
+
if (warnings.length > 0) {
|
|
49
|
+
console.log(`\n ⚠ Warnings (${warnings.length}):`);
|
|
50
|
+
for (const w of warnings)
|
|
51
|
+
console.log(` → ${w.message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
console.log(' Diagnostics: ✓ No errors, no warnings');
|
|
56
|
+
}
|
|
57
|
+
if (flags.verbose) {
|
|
58
|
+
console.log('\n AST:');
|
|
59
|
+
console.log(printAST(ast).split('\n').map((l) => ` ${l}`).join('\n'));
|
|
60
|
+
}
|
|
61
|
+
console.log('');
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/commands/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAG9E,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,QAAgB,EAAE,KAAe;IAC9D,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/C,IAAI,GAAG,CAAC;IACR,IAAI,CAAC;QACH,MAAM,MAAM,GAA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AC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa3C,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAyC9E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { Parser } from '@duckcodeailabs/dql-core';
|
|
3
|
+
function formatExpected(expr) {
|
|
4
|
+
if (expr === null || expr === undefined)
|
|
5
|
+
return 'null';
|
|
6
|
+
if (typeof expr !== 'object')
|
|
7
|
+
return String(expr);
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(expr, 'value'))
|
|
9
|
+
return String(expr.value);
|
|
10
|
+
if (Object.prototype.hasOwnProperty.call(expr, 'name'))
|
|
11
|
+
return String(expr.name);
|
|
12
|
+
if (expr.kind === 'ArrayLiteral' && Array.isArray(expr.elements)) {
|
|
13
|
+
return `[${expr.elements.map((e) => formatExpected(e)).join(', ')}]`;
|
|
14
|
+
}
|
|
15
|
+
return JSON.stringify(expr);
|
|
16
|
+
}
|
|
17
|
+
export async function runTest(filePath, flags) {
|
|
18
|
+
const source = readFileSync(filePath, 'utf-8');
|
|
19
|
+
const parser = new Parser(source, filePath);
|
|
20
|
+
const ast = parser.parse();
|
|
21
|
+
// Find block declarations with tests
|
|
22
|
+
const blocks = ast.statements.filter((s) => s.kind === 'BlockDecl');
|
|
23
|
+
if (blocks.length === 0) {
|
|
24
|
+
console.log('\n ⚠ No block declarations found in file.');
|
|
25
|
+
console.log('');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (flags.format === 'json') {
|
|
29
|
+
console.log(JSON.stringify({
|
|
30
|
+
file: filePath,
|
|
31
|
+
blocks: blocks.map((b) => ({
|
|
32
|
+
name: b.name,
|
|
33
|
+
tests: b.tests?.length ?? 0,
|
|
34
|
+
})),
|
|
35
|
+
note: 'Test execution requires a database connection. Use --connection to specify.',
|
|
36
|
+
}, null, 2));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
console.log(`\n ✓ Found ${blocks.length} block(s) in ${filePath}`);
|
|
40
|
+
for (const block of blocks) {
|
|
41
|
+
const b = block;
|
|
42
|
+
const testCount = b.tests?.length ?? 0;
|
|
43
|
+
console.log(`\n Block: "${b.name}"`);
|
|
44
|
+
console.log(` Tests: ${testCount} assertion(s)`);
|
|
45
|
+
if (testCount > 0) {
|
|
46
|
+
for (const test of b.tests) {
|
|
47
|
+
console.log(` → assert ${test.field} ${test.operator} ${formatExpected(test.expected)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log(' Status: ⚠ Dry run (no database connection)');
|
|
51
|
+
console.log(' Hint: Connect a database to execute assertions');
|
|
52
|
+
}
|
|
53
|
+
console.log('');
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,SAAS,cAAc,CAAC,IAAS;IAC/B,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACvD,IAAI,OAAO,IAAI,KA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GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from './args.js';
|
|
3
|
+
import { runParse } from './commands/parse.js';
|
|
4
|
+
import { runTest } from './commands/test.js';
|
|
5
|
+
import { runCertify } from './commands/certify.js';
|
|
6
|
+
import { runInfo } from './commands/info.js';
|
|
7
|
+
import { runMigrate } from './commands/migrate.js';
|
|
8
|
+
import { runFmt } from './commands/fmt.js';
|
|
9
|
+
const HELP = `
|
|
10
|
+
dql — DQL CLI
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
dql parse <file.dql> Parse and analyze a DQL file
|
|
14
|
+
dql test <file.dql> Inspect block tests
|
|
15
|
+
dql certify <file.dql> Evaluate certification rules
|
|
16
|
+
dql info <file.dql> Show block metadata
|
|
17
|
+
dql migrate <source> Scaffold migration from looker/tableau/dbt/metabase/raw-sql
|
|
18
|
+
dql fmt <file.dql> Format DQL file in place
|
|
19
|
+
dql --help Show this help
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
--format json|text Output format (default: text)
|
|
23
|
+
--verbose Show detailed output
|
|
24
|
+
--check For "fmt": check-only and exit 1 if changes needed
|
|
25
|
+
--input <path> Source path for scaffold-style migration commands
|
|
26
|
+
`;
|
|
27
|
+
async function main() {
|
|
28
|
+
const { command, file, flags } = parseArgs(process.argv.slice(2));
|
|
29
|
+
if (flags.help || !command) {
|
|
30
|
+
console.log(HELP.trim());
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
if (!file) {
|
|
34
|
+
console.error('Error: No file/argument specified. Run "dql --help" for usage.');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
switch (command) {
|
|
39
|
+
case 'parse':
|
|
40
|
+
await runParse(file, flags);
|
|
41
|
+
break;
|
|
42
|
+
case 'test':
|
|
43
|
+
await runTest(file, flags);
|
|
44
|
+
break;
|
|
45
|
+
case 'certify':
|
|
46
|
+
await runCertify(file, flags);
|
|
47
|
+
break;
|
|
48
|
+
case 'info':
|
|
49
|
+
await runInfo(file, flags);
|
|
50
|
+
break;
|
|
51
|
+
case 'migrate':
|
|
52
|
+
await runMigrate(file, flags);
|
|
53
|
+
break;
|
|
54
|
+
case 'fmt':
|
|
55
|
+
await runFmt(file, flags);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
console.error(`Unknown command: ${command}. Run "dql --help" for usage.`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
main();
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;CAiBZ,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,E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AY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@duckcodeailabs/dql-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"dql": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/duckcode-ai/dql.git",
|
|
19
|
+
"directory": "apps/cli"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@duckcodeailabs/dql-core": "0.1.0",
|
|
23
|
+
"@duckcodeailabs/dql-project": "0.1.0",
|
|
24
|
+
"@duckcodeailabs/dql-governance": "0.1.0",
|
|
25
|
+
"@duckcodeailabs/dql-compiler": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.7.0",
|
|
29
|
+
"tsx": "^4.19.0",
|
|
30
|
+
"vitest": "^3.0.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -b",
|
|
37
|
+
"dev": "tsx src/index.ts",
|
|
38
|
+
"test": "vitest run --passWithNoTests",
|
|
39
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
40
|
+
}
|
|
41
|
+
}
|