@hypequery/cli 0.0.8 → 0.0.9

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.
Files changed (61) hide show
  1. package/dist/bin/cli.d.ts +3 -0
  2. package/dist/bin/cli.d.ts.map +1 -0
  3. package/dist/bin/cli.js +86 -0
  4. package/dist/cli.d.ts +4 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +163 -0
  7. package/dist/commands/dev.d.ts +12 -0
  8. package/dist/commands/dev.d.ts.map +1 -0
  9. package/dist/commands/dev.js +265 -0
  10. package/dist/commands/generate.d.ts +8 -0
  11. package/dist/commands/generate.d.ts.map +1 -0
  12. package/dist/commands/generate.js +175 -0
  13. package/dist/commands/init.d.ts +10 -0
  14. package/dist/commands/init.d.ts.map +1 -0
  15. package/dist/commands/init.js +408 -0
  16. package/dist/generators/clickhouse.d.ts +7 -0
  17. package/dist/generators/clickhouse.d.ts.map +1 -0
  18. package/dist/generators/clickhouse.js +229 -0
  19. package/dist/generators/index.d.ts +7 -0
  20. package/dist/generators/index.d.ts.map +1 -0
  21. package/dist/generators/index.js +13 -0
  22. package/dist/templates/client.d.ts +5 -0
  23. package/dist/templates/client.d.ts.map +1 -0
  24. package/dist/templates/client.js +6 -0
  25. package/dist/templates/env.d.ts +14 -0
  26. package/dist/templates/env.d.ts.map +1 -0
  27. package/dist/templates/env.js +37 -0
  28. package/dist/templates/gitignore.d.ts +13 -0
  29. package/dist/templates/gitignore.d.ts.map +1 -0
  30. package/dist/templates/gitignore.js +22 -0
  31. package/dist/templates/queries.d.ts +8 -0
  32. package/dist/templates/queries.d.ts.map +1 -0
  33. package/dist/templates/queries.js +27 -0
  34. package/dist/test-utils.d.ts +86 -0
  35. package/dist/test-utils.d.ts.map +1 -0
  36. package/dist/test-utils.js +153 -0
  37. package/dist/utils/clickhouse-client.d.ts +11 -0
  38. package/dist/utils/clickhouse-client.d.ts.map +1 -0
  39. package/dist/utils/clickhouse-client.js +86 -0
  40. package/dist/utils/dependency-installer.d.ts +2 -0
  41. package/dist/utils/dependency-installer.d.ts.map +1 -0
  42. package/dist/utils/dependency-installer.js +180 -0
  43. package/dist/utils/detect-database.d.ts +21 -0
  44. package/dist/utils/detect-database.d.ts.map +1 -0
  45. package/dist/utils/detect-database.js +224 -0
  46. package/dist/utils/error-messages.d.ts +6 -0
  47. package/dist/utils/error-messages.d.ts.map +1 -0
  48. package/dist/utils/error-messages.js +19 -0
  49. package/dist/utils/find-files.d.ts +21 -0
  50. package/dist/utils/find-files.d.ts.map +1 -0
  51. package/dist/utils/find-files.js +183 -0
  52. package/dist/utils/load-api.d.ts +2 -0
  53. package/dist/utils/load-api.d.ts.map +1 -0
  54. package/dist/utils/load-api.js +400 -0
  55. package/dist/utils/logger.d.ts +54 -0
  56. package/dist/utils/logger.d.ts.map +1 -0
  57. package/dist/utils/logger.js +122 -0
  58. package/dist/utils/prompts.d.ts +39 -0
  59. package/dist/utils/prompts.d.ts.map +1 -0
  60. package/dist/utils/prompts.js +282 -0
  61. package/package.json +2 -2
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
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
+ import { program } from '../cli.js';
39
+ function loadEnv() {
40
+ return __awaiter(this, void 0, void 0, function () {
41
+ var dotenvx, _a, config, _b;
42
+ return __generator(this, function (_c) {
43
+ switch (_c.label) {
44
+ case 0:
45
+ _c.trys.push([0, 4, , 5]);
46
+ return [4 /*yield*/, import('@dotenvx/dotenvx')];
47
+ case 1:
48
+ dotenvx = _c.sent();
49
+ if (!((dotenvx === null || dotenvx === void 0 ? void 0 : dotenvx.config) && typeof dotenvx.config.load === 'function')) return [3 /*break*/, 3];
50
+ return [4 /*yield*/, dotenvx.config.load()];
51
+ case 2:
52
+ _c.sent();
53
+ return [2 /*return*/];
54
+ case 3: return [3 /*break*/, 5];
55
+ case 4:
56
+ _a = _c.sent();
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
+ });
72
+ }
73
+ function main() {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ return __generator(this, function (_a) {
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
+ });
85
+ }
86
+ main();
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const program: Command;
3
+ export { program };
4
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AA8F9B,OAAO,EAAE,OAAO,EAAE,CAAC"}
package/dist/cli.js ADDED
@@ -0,0 +1,163 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ 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);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { Command } from 'commander';
38
+ import { initCommand } from './commands/init.js';
39
+ import { devCommand } from './commands/dev.js';
40
+ import { generateCommand } from './commands/generate.js';
41
+ var program = new Command();
42
+ program
43
+ .name('hypequery')
44
+ .description('Type-safe analytics layer for ClickHouse')
45
+ .version('0.0.1');
46
+ // Init command
47
+ program
48
+ .command('init')
49
+ .description('Initialize a new hypequery project')
50
+ .option('--database <type>', 'Database type (clickhouse|bigquery)')
51
+ .option('--path <path>', 'Output directory (default: analytics/)')
52
+ .option('--no-example', 'Skip example query generation')
53
+ .option('--no-interactive', 'Non-interactive mode (use env vars)')
54
+ .option('--force', 'Overwrite existing files')
55
+ .option('--skip-connection', 'Skip database connectivity test')
56
+ .action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
57
+ var error_1;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0:
61
+ _a.trys.push([0, 2, , 3]);
62
+ return [4 /*yield*/, initCommand(options)];
63
+ case 1:
64
+ _a.sent();
65
+ return [3 /*break*/, 3];
66
+ case 2:
67
+ error_1 = _a.sent();
68
+ console.error(error_1 instanceof Error ? error_1.message : error_1);
69
+ process.exit(1);
70
+ return [3 /*break*/, 3];
71
+ case 3: return [2 /*return*/];
72
+ }
73
+ });
74
+ }); });
75
+ // Dev command
76
+ program
77
+ .command('dev [file]')
78
+ .description('Start development server')
79
+ .option('-p, --port <port>', 'Port number', function (val) { return parseInt(val, 10); })
80
+ .option('-h, --hostname <host>', 'Host to bind (default: localhost)')
81
+ .option('--no-watch', 'Disable file watching')
82
+ .option('--no-cache', 'Disable caching')
83
+ .option('--cache <provider>', 'Cache provider (memory|redis)')
84
+ .option('--redis-url <url>', 'Redis connection URL')
85
+ .option('--open', 'Open browser automatically')
86
+ .option('--cors', 'Enable CORS')
87
+ .option('-q, --quiet', 'Suppress startup messages')
88
+ .action(function (file, options) { return __awaiter(void 0, void 0, void 0, function () {
89
+ var error_2;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ _a.trys.push([0, 2, , 3]);
94
+ return [4 /*yield*/, devCommand(file, options)];
95
+ case 1:
96
+ _a.sent();
97
+ return [3 /*break*/, 3];
98
+ case 2:
99
+ error_2 = _a.sent();
100
+ console.error(error_2 instanceof Error ? error_2.message : error_2);
101
+ process.exit(1);
102
+ return [3 /*break*/, 3];
103
+ case 3: return [2 /*return*/];
104
+ }
105
+ });
106
+ }); });
107
+ // Generate command
108
+ program
109
+ .command('generate')
110
+ .description('Regenerate types from ClickHouse')
111
+ .option('-o, --output <path>', 'Output file (default: analytics/schema.ts)')
112
+ .option('--tables <names>', 'Only generate for specific tables (comma-separated)')
113
+ .option('--database <type>', 'Database driver to use (default: auto-detect)')
114
+ .action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
115
+ var error_3;
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0:
119
+ _a.trys.push([0, 2, , 3]);
120
+ return [4 /*yield*/, generateCommand(options)];
121
+ case 1:
122
+ _a.sent();
123
+ return [3 /*break*/, 3];
124
+ case 2:
125
+ error_3 = _a.sent();
126
+ console.error(error_3 instanceof Error ? error_3.message : error_3);
127
+ process.exit(1);
128
+ return [3 /*break*/, 3];
129
+ case 3: return [2 /*return*/];
130
+ }
131
+ });
132
+ }); });
133
+ // Help command
134
+ program
135
+ .command('help [command]')
136
+ .description('Show help for command')
137
+ .action(function (command) {
138
+ if (command) {
139
+ var cmd = program.commands.find(function (c) { return c.name() === command; });
140
+ if (cmd) {
141
+ cmd.help();
142
+ }
143
+ else {
144
+ console.error("Unknown command: ".concat(command));
145
+ process.exit(1);
146
+ }
147
+ }
148
+ else {
149
+ program.help();
150
+ }
151
+ });
152
+ // Custom help
153
+ program.on('--help', function () {
154
+ console.log('');
155
+ console.log('Examples:');
156
+ console.log(' hypequery init');
157
+ console.log(' hypequery dev');
158
+ console.log(' hypequery dev --port 3000');
159
+ console.log(' hypequery generate --output analytics/schema.ts');
160
+ console.log('');
161
+ console.log('Docs: https://hypequery.com/docs');
162
+ });
163
+ export { program };
@@ -0,0 +1,12 @@
1
+ export interface DevOptions {
2
+ port?: number;
3
+ hostname?: string;
4
+ watch?: boolean;
5
+ quiet?: boolean;
6
+ cache?: string;
7
+ redisUrl?: string;
8
+ open?: boolean;
9
+ cors?: boolean;
10
+ }
11
+ export declare function devCommand(file?: string, options?: DevOptions): Promise<void>;
12
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AASA,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;CAChB;AAED,wBAAsB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,iBAqLvE"}
@@ -0,0 +1,265 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ 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);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { watch } from 'node:fs';
38
+ import path from 'node:path';
39
+ import ora from 'ora';
40
+ import { logger } from '../utils/logger.js';
41
+ import { findQueriesFile } from '../utils/find-files.js';
42
+ import { getTableCount } from '../utils/detect-database.js';
43
+ import { loadApiModule } from '../utils/load-api.js';
44
+ import { displayQueriesFileNotFoundError } from '../utils/error-messages.js';
45
+ export function devCommand(file_1) {
46
+ return __awaiter(this, arguments, void 0, function (file, options) {
47
+ var queriesFile, currentServer, shouldWatch, startServer, restartServer, shutdown, watchDir, debounceTimer_1, watcher_1;
48
+ var _this = this;
49
+ if (options === void 0) { options = {}; }
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0: return [4 /*yield*/, findQueriesFile(file)];
53
+ case 1:
54
+ queriesFile = _a.sent();
55
+ if (!queriesFile) {
56
+ displayQueriesFileNotFoundError('dev');
57
+ process.exit(1);
58
+ }
59
+ logger.info("Found: ".concat(path.relative(process.cwd(), queriesFile)));
60
+ logger.newline();
61
+ currentServer = null;
62
+ shouldWatch = options.watch !== false;
63
+ startServer = function () { return __awaiter(_this, void 0, void 0, function () {
64
+ var compileSpinner, dbSpinner, api, tableCount, error_1, queryCount, serveDev, address, port, hostname, baseUrl, docsPath, openapiPath, open_1, _a, error_2;
65
+ var _b, _c, _d, _e, _f, _g;
66
+ return __generator(this, function (_h) {
67
+ switch (_h.label) {
68
+ case 0:
69
+ compileSpinner = ora('Compiling queries...').start();
70
+ dbSpinner = ora('Connecting to ClickHouse...').start();
71
+ _h.label = 1;
72
+ case 1:
73
+ _h.trys.push([1, 14, , 15]);
74
+ return [4 /*yield*/, loadApiModule(queriesFile)];
75
+ case 2:
76
+ api = _h.sent();
77
+ compileSpinner.succeed('Compiled queries');
78
+ tableCount = 0;
79
+ _h.label = 3;
80
+ case 3:
81
+ _h.trys.push([3, 5, , 6]);
82
+ return [4 /*yield*/, getTableCount('clickhouse')];
83
+ case 4:
84
+ tableCount = _h.sent();
85
+ dbSpinner.succeed("Connected to ClickHouse (".concat(tableCount, " tables)"));
86
+ return [3 /*break*/, 6];
87
+ case 5:
88
+ error_1 = _h.sent();
89
+ // Log but don't fail - table count is optional
90
+ dbSpinner.warn('Could not connect to ClickHouse');
91
+ if (error_1 instanceof Error) {
92
+ logger.indent("Reason: ".concat(error_1.message));
93
+ }
94
+ return [3 /*break*/, 6];
95
+ case 6:
96
+ queryCount = Object.keys(api.queries || {}).length;
97
+ logger.header('hypequery dev');
98
+ logger.success("Registered ".concat(queryCount, " ").concat(queryCount === 1 ? 'query' : 'queries'));
99
+ logger.newline();
100
+ return [4 /*yield*/, import('@hypequery/serve')];
101
+ case 7:
102
+ serveDev = (_h.sent()).serveDev;
103
+ return [4 /*yield*/, serveDev(api, {
104
+ port: options.port,
105
+ hostname: options.hostname,
106
+ quiet: true,
107
+ })];
108
+ case 8:
109
+ currentServer = _h.sent();
110
+ address = currentServer.server.address();
111
+ port = typeof address === 'object' && address ? address.port : options.port || 4000;
112
+ hostname = options.hostname || 'localhost';
113
+ baseUrl = "http://".concat(hostname, ":").concat(port);
114
+ docsPath = (_c = (_b = api.docs) === null || _b === void 0 ? void 0 : _b.path) !== null && _c !== void 0 ? _c : '/docs';
115
+ openapiPath = (_e = (_d = api.openapi) === null || _d === void 0 ? void 0 : _d.path) !== null && _e !== void 0 ? _e : '/openapi.json';
116
+ logger.box([
117
+ "Docs: ".concat(baseUrl).concat((_f = api.basePath) !== null && _f !== void 0 ? _f : '').concat(docsPath),
118
+ "OpenAPI: ".concat(baseUrl).concat((_g = api.basePath) !== null && _g !== void 0 ? _g : '').concat(openapiPath),
119
+ ]);
120
+ logger.newline();
121
+ logger.success("Ready in ".concat(process.uptime().toFixed(0), "ms"));
122
+ logger.newline();
123
+ // Query execution stats are logged automatically
124
+ if (!options.quiet) {
125
+ logger.info('Query execution stats will appear below as requests are made');
126
+ logger.newline();
127
+ }
128
+ if (shouldWatch) {
129
+ logger.info('Watching for changes...');
130
+ }
131
+ if (!options.open) return [3 /*break*/, 13];
132
+ _h.label = 9;
133
+ case 9:
134
+ _h.trys.push([9, 12, , 13]);
135
+ return [4 /*yield*/, import('open')];
136
+ case 10:
137
+ open_1 = (_h.sent()).default;
138
+ return [4 /*yield*/, open_1(baseUrl)];
139
+ case 11:
140
+ _h.sent();
141
+ logger.success("Opened ".concat(baseUrl, " in browser"));
142
+ return [3 /*break*/, 13];
143
+ case 12:
144
+ _a = _h.sent();
145
+ // Log but don't fail - browser open is optional
146
+ logger.warn('Could not open browser automatically');
147
+ logger.indent("Visit: ".concat(baseUrl));
148
+ return [3 /*break*/, 13];
149
+ case 13: return [3 /*break*/, 15];
150
+ case 14:
151
+ error_2 = _h.sent();
152
+ // Stop spinners if they're still running
153
+ if (compileSpinner.isSpinning) {
154
+ compileSpinner.fail('Failed to compile queries');
155
+ }
156
+ if (dbSpinner.isSpinning) {
157
+ dbSpinner.stop();
158
+ }
159
+ logger.error('Failed to start server');
160
+ logger.newline();
161
+ if (error_2 instanceof Error) {
162
+ logger.info(error_2.message);
163
+ if (error_2.stack) {
164
+ logger.newline();
165
+ logger.info('Stack trace:');
166
+ logger.info(error_2.stack);
167
+ }
168
+ }
169
+ else {
170
+ logger.info(String(error_2));
171
+ }
172
+ logger.newline();
173
+ if (!shouldWatch) {
174
+ process.exit(1);
175
+ }
176
+ return [3 /*break*/, 15];
177
+ case 15: return [2 /*return*/];
178
+ }
179
+ });
180
+ }); };
181
+ restartServer = function () { return __awaiter(_this, void 0, void 0, function () {
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0:
185
+ if (!currentServer) return [3 /*break*/, 2];
186
+ logger.newline();
187
+ logger.reload('File changed, restarting...');
188
+ logger.newline();
189
+ return [4 /*yield*/, currentServer.stop()];
190
+ case 1:
191
+ _a.sent();
192
+ _a.label = 2;
193
+ case 2: return [4 /*yield*/, startServer()];
194
+ case 3:
195
+ _a.sent();
196
+ return [2 /*return*/];
197
+ }
198
+ });
199
+ }); };
200
+ shutdown = function () { return __awaiter(_this, void 0, void 0, function () {
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0:
204
+ logger.newline();
205
+ logger.info('Shutting down dev server...');
206
+ if (!currentServer) return [3 /*break*/, 2];
207
+ return [4 /*yield*/, currentServer.stop()];
208
+ case 1:
209
+ _a.sent();
210
+ _a.label = 2;
211
+ case 2:
212
+ process.exit(0);
213
+ return [2 /*return*/];
214
+ }
215
+ });
216
+ }); };
217
+ // Start initial server
218
+ return [4 /*yield*/, startServer()];
219
+ case 2:
220
+ // Start initial server
221
+ _a.sent();
222
+ // Watch for changes
223
+ if (shouldWatch) {
224
+ watchDir = path.dirname(queriesFile);
225
+ debounceTimer_1 = null;
226
+ watcher_1 = watch(watchDir, { recursive: true }, function (_eventType, filename) {
227
+ if (!filename)
228
+ return;
229
+ // Only watch .ts and .js files
230
+ if (!filename.endsWith('.ts') && !filename.endsWith('.js')) {
231
+ return;
232
+ }
233
+ // Debounce file changes
234
+ if (debounceTimer_1) {
235
+ clearTimeout(debounceTimer_1);
236
+ }
237
+ debounceTimer_1 = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0: return [4 /*yield*/, restartServer()];
241
+ case 1:
242
+ _a.sent();
243
+ return [2 /*return*/];
244
+ }
245
+ });
246
+ }); }, 100);
247
+ });
248
+ process.once('SIGINT', function () {
249
+ watcher_1.close();
250
+ shutdown();
251
+ });
252
+ process.once('SIGTERM', function () {
253
+ watcher_1.close();
254
+ shutdown();
255
+ });
256
+ }
257
+ else {
258
+ process.once('SIGINT', shutdown);
259
+ process.once('SIGTERM', shutdown);
260
+ }
261
+ return [2 /*return*/];
262
+ }
263
+ });
264
+ });
265
+ }
@@ -0,0 +1,8 @@
1
+ import { type DatabaseType } from '../utils/detect-database.js';
2
+ export interface GenerateOptions {
3
+ output?: string;
4
+ tables?: string;
5
+ database?: DatabaseType;
6
+ }
7
+ export declare function generateCommand(options?: GenerateOptions): Promise<void>;
8
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiC,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG/F,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,wBAAsB,eAAe,CAAC,OAAO,GAAE,eAAoB,iBAwHlE"}