@hypequery/cli 1.1.2 → 1.2.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 +26 -2
- package/dist/bin/cli.js +21 -81
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +72 -116
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +180 -255
- package/dist/commands/generate-datasets.d.ts +14 -0
- package/dist/commands/generate-datasets.d.ts.map +1 -0
- package/dist/commands/generate-datasets.js +96 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +112 -167
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +337 -370
- package/dist/generators/clickhouse.d.ts +1 -1
- package/dist/generators/clickhouse.d.ts.map +1 -1
- package/dist/generators/clickhouse.js +10 -269
- package/dist/generators/dataset-generator.d.ts +16 -0
- package/dist/generators/dataset-generator.d.ts.map +1 -0
- package/dist/generators/dataset-generator.js +246 -0
- package/dist/generators/index.js +3 -3
- package/dist/templates/api.d.ts +9 -0
- package/dist/templates/api.d.ts.map +1 -0
- package/dist/templates/api.js +26 -0
- package/dist/templates/auth-scaffold.d.ts +17 -0
- package/dist/templates/auth-scaffold.d.ts.map +1 -0
- package/dist/templates/auth-scaffold.js +41 -0
- package/dist/templates/client.js +10 -1
- package/dist/templates/datasets.d.ts +5 -0
- package/dist/templates/datasets.d.ts.map +1 -0
- package/dist/templates/datasets.js +23 -0
- package/dist/templates/env.js +19 -8
- package/dist/templates/gitignore.js +4 -1
- package/dist/templates/queries.d.ts +3 -0
- package/dist/templates/queries.d.ts.map +1 -1
- package/dist/templates/queries.js +66 -10
- package/dist/test-utils.d.ts +0 -71
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +12 -137
- package/dist/utils/clickhouse-client.js +10 -57
- package/dist/utils/clickhouse-sql.d.ts +6 -0
- package/dist/utils/clickhouse-sql.d.ts.map +1 -0
- package/dist/utils/clickhouse-sql.js +18 -0
- package/dist/utils/clickhouse-type-utils.d.ts +6 -0
- package/dist/utils/clickhouse-type-utils.d.ts.map +1 -0
- package/dist/utils/clickhouse-type-utils.js +59 -0
- package/dist/utils/dependency-installer.d.ts +4 -2
- package/dist/utils/dependency-installer.d.ts.map +1 -1
- package/dist/utils/dependency-installer.js +93 -170
- package/dist/utils/detect-database.js +84 -195
- package/dist/utils/find-files.d.ts +3 -1
- package/dist/utils/find-files.d.ts.map +1 -1
- package/dist/utils/find-files.js +82 -148
- package/dist/utils/load-api.d.ts.map +1 -1
- package/dist/utils/load-api.js +207 -396
- package/dist/utils/logger.js +38 -42
- package/dist/utils/prompts.d.ts +14 -0
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/prompts.js +170 -219
- package/dist/utils/runtime-guards.d.ts +4 -0
- package/dist/utils/runtime-guards.d.ts.map +1 -0
- package/dist/utils/runtime-guards.js +9 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/dist/utils/sha256.d.ts.map +1 -0
- package/dist/utils/sha256.js +4 -0
- package/package.json +3 -8
- package/dist/utils/error-messages.d.ts +0 -6
- package/dist/utils/error-messages.d.ts.map +0 -1
- package/dist/utils/error-messages.js +0 -19
- package/dist/utils/load-hypequery-config.d.ts +0 -7
- package/dist/utils/load-hypequery-config.d.ts.map +0 -1
- package/dist/utils/load-hypequery-config.js +0 -89
package/README.md
CHANGED
|
@@ -45,11 +45,18 @@ It will:
|
|
|
45
45
|
Options:
|
|
46
46
|
|
|
47
47
|
- `--path <path>`: output directory, default `analytics/`
|
|
48
|
+
- `--style <style>`: `queries` (default) or `datasets`
|
|
49
|
+
- `--auth <mode>`: `none` (default) or `context`
|
|
50
|
+
- `--all-tables`: with `--style datasets`, scaffold every table
|
|
51
|
+
- `--tables <names>`: with `--style datasets`, scaffold these comma-separated tables
|
|
52
|
+
- `--exclude-tables <names>`: with `--style datasets`, exclude these comma-separated tables
|
|
48
53
|
- `--no-example`: skip the example query
|
|
49
54
|
- `--no-interactive`: read connection details from env vars
|
|
50
55
|
- `--force`: overwrite existing scaffold files
|
|
51
56
|
- `--skip-connection`: skip testing the ClickHouse connection before scaffolding
|
|
52
57
|
|
|
58
|
+
Set `HYPEQUERY_SKIP_INSTALL=1` to skip the automatic dependency install.
|
|
59
|
+
|
|
53
60
|
### `hypequery dev`
|
|
54
61
|
|
|
55
62
|
Runs the local serve runtime with docs and hot reload.
|
|
@@ -62,10 +69,9 @@ Options:
|
|
|
62
69
|
|
|
63
70
|
- `--port <port>`: default `4000`
|
|
64
71
|
- `--hostname <host>`: default `localhost`
|
|
72
|
+
- `--path <path>`: analytics directory to load (`<path>/api.ts` or `<path>/queries.ts`)
|
|
65
73
|
- `--no-watch`: disable file watching
|
|
66
|
-
- `--cache <provider>`: `memory`, `redis`, or `none`
|
|
67
74
|
- `--open`: open the browser automatically
|
|
68
|
-
- `--cors`: enable CORS
|
|
69
75
|
- `--quiet`: reduce startup output
|
|
70
76
|
|
|
71
77
|
The CLI understands TypeScript entry files directly, so `analytics/queries.ts` works without an extra runner.
|
|
@@ -81,9 +87,27 @@ npx hypequery generate
|
|
|
81
87
|
Options:
|
|
82
88
|
|
|
83
89
|
- `--output <path>`: default `analytics/schema.ts`
|
|
90
|
+
- `--path <path>`: analytics directory (derives `<path>/schema.ts`)
|
|
84
91
|
- `--tables <names>`: comma-separated table list
|
|
85
92
|
- `--database <type>`: currently `clickhouse`
|
|
86
93
|
|
|
94
|
+
`hypequery generate:types` is an alias for `hypequery generate`.
|
|
95
|
+
|
|
96
|
+
### `hypequery generate:datasets`
|
|
97
|
+
|
|
98
|
+
Generates dataset (semantic layer) definitions from ClickHouse.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx hypequery generate:datasets
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Options:
|
|
105
|
+
|
|
106
|
+
- `--output <path>`: default `src/datasets/generated.ts`
|
|
107
|
+
- `--path <path>`: analytics directory (derives `<path>/datasets.ts`)
|
|
108
|
+
- `--tables <names>`: comma-separated table list
|
|
109
|
+
- `--exclude-tables <names>`: comma-separated tables to exclude
|
|
110
|
+
|
|
87
111
|
## Non-interactive Setup
|
|
88
112
|
|
|
89
113
|
`hypequery init --no-interactive` reads:
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,86 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
import { program } from '../cli.js';
|
|
39
|
-
function loadEnv() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return [3 /*break*/, 5];
|
|
58
|
-
case 5:
|
|
59
|
-
_c.trys.push([5, 7, , 8]);
|
|
60
|
-
return [4 /*yield*/, import('dotenv')];
|
|
61
|
-
case 6:
|
|
62
|
-
config = (_c.sent()).config;
|
|
63
|
-
config();
|
|
64
|
-
return [3 /*break*/, 8];
|
|
65
|
-
case 7:
|
|
66
|
-
_b = _c.sent();
|
|
67
|
-
return [3 /*break*/, 8];
|
|
68
|
-
case 8: return [2 /*return*/];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
3
|
+
async function loadEnv() {
|
|
4
|
+
try {
|
|
5
|
+
const dotenvx = await import('@dotenvx/dotenvx');
|
|
6
|
+
if (dotenvx?.config && typeof dotenvx.config.load === 'function') {
|
|
7
|
+
await dotenvx.config.load();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// Optional dependency, ignore if missing
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const { config } = await import('dotenv');
|
|
16
|
+
config();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// dotenv is optional; continue if not available
|
|
20
|
+
}
|
|
72
21
|
}
|
|
73
|
-
function main() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
switch (_a.label) {
|
|
77
|
-
case 0: return [4 /*yield*/, loadEnv()];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.sent();
|
|
80
|
-
program.parse(process.argv);
|
|
81
|
-
return [2 /*return*/];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
22
|
+
async function main() {
|
|
23
|
+
await loadEnv();
|
|
24
|
+
program.parse(process.argv);
|
|
85
25
|
}
|
|
86
26
|
main();
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AAa9B,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;EAKpE;AAuHD,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,95 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
48
3
|
import { Command } from 'commander';
|
|
49
4
|
import { initCommand } from './commands/init.js';
|
|
50
5
|
import { devCommand } from './commands/dev.js';
|
|
51
6
|
import { generateCommand } from './commands/generate.js';
|
|
52
|
-
|
|
7
|
+
import { generateDatasetsCommand } from './commands/generate-datasets.js';
|
|
8
|
+
const program = new Command();
|
|
9
|
+
function getCliVersion() {
|
|
10
|
+
try {
|
|
11
|
+
const pkg = JSON.parse(readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'));
|
|
12
|
+
return pkg.version ?? '0.0.0';
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return '0.0.0';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
53
18
|
export function normalizeInitOptions(options) {
|
|
54
|
-
return
|
|
19
|
+
return {
|
|
20
|
+
...options,
|
|
21
|
+
noInteractive: options.noInteractive === true || options.interactive === false,
|
|
22
|
+
};
|
|
55
23
|
}
|
|
56
24
|
program
|
|
57
25
|
.name('hypequery')
|
|
58
26
|
.description('Type-safe analytics layer for ClickHouse')
|
|
59
|
-
.version(
|
|
27
|
+
.version(getCliVersion());
|
|
28
|
+
function runCommand(action) {
|
|
29
|
+
return async (...args) => {
|
|
30
|
+
try {
|
|
31
|
+
await action(...args);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error(error instanceof Error ? error.message : error);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function addTypeGenerationOptions(command) {
|
|
40
|
+
return command
|
|
41
|
+
.description('Regenerate types from ClickHouse')
|
|
42
|
+
.option('-o, --output <path>', 'Output file (default: analytics/schema.ts)')
|
|
43
|
+
.option('--path <path>', 'Analytics directory (derives <path>/schema.ts)')
|
|
44
|
+
.option('--tables <names>', 'Only generate for specific tables (comma-separated)')
|
|
45
|
+
.option('--database <type>', 'Database driver to use (default: auto-detect)');
|
|
46
|
+
}
|
|
60
47
|
// Init command
|
|
61
48
|
program
|
|
62
49
|
.command('init')
|
|
63
50
|
.description('Initialize a new hypequery project')
|
|
64
51
|
.option('--path <path>', 'Output directory (default: analytics/)')
|
|
52
|
+
.option('--style <style>', 'Scaffold style: queries or datasets')
|
|
53
|
+
.option('--auth <mode>', 'Auth scaffold mode: none or context')
|
|
54
|
+
.option('--all-tables', 'Generate datasets for all discovered tables when using --style datasets')
|
|
55
|
+
.option('--tables <names>', 'Generate datasets for specific tables when using --style datasets (comma-separated)')
|
|
56
|
+
.option('--exclude-tables <names>', 'Exclude tables from dataset generation when using --style datasets (comma-separated)')
|
|
65
57
|
.option('--no-example', 'Skip example query generation')
|
|
66
58
|
.option('--no-interactive', 'Non-interactive mode (use env vars)')
|
|
67
59
|
.option('--force', 'Overwrite existing files')
|
|
68
60
|
.option('--skip-connection', 'Skip database connectivity test')
|
|
69
|
-
.action(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
_a.trys.push([0, 2, , 3]);
|
|
75
|
-
return [4 /*yield*/, initCommand(normalizeInitOptions(options))];
|
|
76
|
-
case 1:
|
|
77
|
-
_a.sent();
|
|
78
|
-
return [3 /*break*/, 3];
|
|
79
|
-
case 2:
|
|
80
|
-
error_1 = _a.sent();
|
|
81
|
-
console.error(error_1 instanceof Error ? error_1.message : error_1);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
return [3 /*break*/, 3];
|
|
84
|
-
case 3: return [2 /*return*/];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}); });
|
|
61
|
+
.action(runCommand(async (options) => {
|
|
62
|
+
await initCommand(normalizeInitOptions(options));
|
|
63
|
+
}));
|
|
88
64
|
// Dev command
|
|
89
65
|
program
|
|
90
66
|
.command('dev [file]')
|
|
91
67
|
.description('Start development server')
|
|
92
|
-
.option('-p, --port <port>', 'Port number',
|
|
68
|
+
.option('-p, --port <port>', 'Port number', (val) => parseInt(val, 10))
|
|
93
69
|
.option('-h, --hostname <host>', 'Host to bind (default: localhost)')
|
|
94
70
|
.option('--no-watch', 'Disable file watching')
|
|
95
71
|
.option('--no-cache', 'Disable caching')
|
|
@@ -97,64 +73,42 @@ program
|
|
|
97
73
|
.option('--redis-url <url>', 'Redis connection URL')
|
|
98
74
|
.option('--open', 'Open browser automatically')
|
|
99
75
|
.option('--cors', 'Enable CORS')
|
|
76
|
+
.option('--path <path>', 'Analytics directory (loads <path>/api.ts or <path>/queries.ts)')
|
|
100
77
|
.option('-q, --quiet', 'Suppress startup messages')
|
|
101
|
-
.action(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
switch (_a.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
_a.trys.push([0, 2, , 3]);
|
|
107
|
-
return [4 /*yield*/, devCommand(file, options)];
|
|
108
|
-
case 1:
|
|
109
|
-
_a.sent();
|
|
110
|
-
return [3 /*break*/, 3];
|
|
111
|
-
case 2:
|
|
112
|
-
error_2 = _a.sent();
|
|
113
|
-
console.error(error_2 instanceof Error ? error_2.message : error_2);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
return [3 /*break*/, 3];
|
|
116
|
-
case 3: return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); });
|
|
78
|
+
.action(runCommand(async (file, options) => {
|
|
79
|
+
await devCommand(file, options);
|
|
80
|
+
}));
|
|
120
81
|
// Generate command
|
|
82
|
+
addTypeGenerationOptions(program.command('generate'))
|
|
83
|
+
.action(runCommand(async (options) => {
|
|
84
|
+
await generateCommand(options);
|
|
85
|
+
}));
|
|
86
|
+
addTypeGenerationOptions(program.command('generate:types'))
|
|
87
|
+
.action(runCommand(async (options) => {
|
|
88
|
+
await generateCommand({ ...options, commandName: 'hypequery generate:types' });
|
|
89
|
+
}));
|
|
121
90
|
program
|
|
122
|
-
.command('generate')
|
|
123
|
-
.description('
|
|
124
|
-
.option('-o, --output <path>', 'Output file (default:
|
|
91
|
+
.command('generate:datasets')
|
|
92
|
+
.description('Generate dataset definitions from ClickHouse schema')
|
|
93
|
+
.option('-o, --output <path>', 'Output file (default: src/datasets/generated.ts)')
|
|
94
|
+
.option('--path <path>', 'Analytics directory (derives <path>/datasets.ts)')
|
|
125
95
|
.option('--tables <names>', 'Only generate for specific tables (comma-separated)')
|
|
126
|
-
.option('--
|
|
127
|
-
.action(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
switch (_a.label) {
|
|
131
|
-
case 0:
|
|
132
|
-
_a.trys.push([0, 2, , 3]);
|
|
133
|
-
return [4 /*yield*/, generateCommand(options)];
|
|
134
|
-
case 1:
|
|
135
|
-
_a.sent();
|
|
136
|
-
return [3 /*break*/, 3];
|
|
137
|
-
case 2:
|
|
138
|
-
error_3 = _a.sent();
|
|
139
|
-
console.error(error_3 instanceof Error ? error_3.message : error_3);
|
|
140
|
-
process.exit(1);
|
|
141
|
-
return [3 /*break*/, 3];
|
|
142
|
-
case 3: return [2 /*return*/];
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}); });
|
|
96
|
+
.option('--exclude-tables <names>', 'Exclude specific tables (comma-separated)')
|
|
97
|
+
.action(runCommand(async (options) => {
|
|
98
|
+
await generateDatasetsCommand(options);
|
|
99
|
+
}));
|
|
146
100
|
// Help command
|
|
147
101
|
program
|
|
148
102
|
.command('help [command]')
|
|
149
103
|
.description('Show help for command')
|
|
150
|
-
.action(
|
|
104
|
+
.action((command) => {
|
|
151
105
|
if (command) {
|
|
152
|
-
|
|
106
|
+
const cmd = program.commands.find((c) => c.name() === command);
|
|
153
107
|
if (cmd) {
|
|
154
108
|
cmd.help();
|
|
155
109
|
}
|
|
156
110
|
else {
|
|
157
|
-
console.error(
|
|
111
|
+
console.error(`Unknown command: ${command}`);
|
|
158
112
|
process.exit(1);
|
|
159
113
|
}
|
|
160
114
|
}
|
|
@@ -163,13 +117,15 @@ program
|
|
|
163
117
|
}
|
|
164
118
|
});
|
|
165
119
|
// Custom help
|
|
166
|
-
program.on('--help',
|
|
120
|
+
program.on('--help', () => {
|
|
167
121
|
console.log('');
|
|
168
122
|
console.log('Examples:');
|
|
169
123
|
console.log(' hypequery init');
|
|
170
124
|
console.log(' hypequery dev');
|
|
171
125
|
console.log(' hypequery dev --port 3000');
|
|
172
126
|
console.log(' hypequery generate --output analytics/schema.ts');
|
|
127
|
+
console.log(' hypequery generate:types --output analytics/schema.ts');
|
|
128
|
+
console.log(' hypequery generate:datasets');
|
|
173
129
|
console.log('');
|
|
174
130
|
console.log('Docs: https://hypequery.com/docs');
|
|
175
131
|
});
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,iBAyLvE"}
|