@hypequery/cli 0.0.0-canary-20260306132943

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 (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +199 -0
  3. package/dist/bin/cli.d.ts +3 -0
  4. package/dist/bin/cli.d.ts.map +1 -0
  5. package/dist/bin/cli.js +86 -0
  6. package/dist/cli.d.ts +4 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +163 -0
  9. package/dist/commands/dev.d.ts +12 -0
  10. package/dist/commands/dev.d.ts.map +1 -0
  11. package/dist/commands/dev.js +265 -0
  12. package/dist/commands/generate.d.ts +8 -0
  13. package/dist/commands/generate.d.ts.map +1 -0
  14. package/dist/commands/generate.js +175 -0
  15. package/dist/commands/init.d.ts +10 -0
  16. package/dist/commands/init.d.ts.map +1 -0
  17. package/dist/commands/init.js +408 -0
  18. package/dist/generators/clickhouse.d.ts +7 -0
  19. package/dist/generators/clickhouse.d.ts.map +1 -0
  20. package/dist/generators/clickhouse.js +229 -0
  21. package/dist/generators/index.d.ts +7 -0
  22. package/dist/generators/index.d.ts.map +1 -0
  23. package/dist/generators/index.js +13 -0
  24. package/dist/templates/client.d.ts +5 -0
  25. package/dist/templates/client.d.ts.map +1 -0
  26. package/dist/templates/client.js +6 -0
  27. package/dist/templates/env.d.ts +14 -0
  28. package/dist/templates/env.d.ts.map +1 -0
  29. package/dist/templates/env.js +37 -0
  30. package/dist/templates/gitignore.d.ts +13 -0
  31. package/dist/templates/gitignore.d.ts.map +1 -0
  32. package/dist/templates/gitignore.js +22 -0
  33. package/dist/templates/queries.d.ts +8 -0
  34. package/dist/templates/queries.d.ts.map +1 -0
  35. package/dist/templates/queries.js +27 -0
  36. package/dist/test-utils.d.ts +86 -0
  37. package/dist/test-utils.d.ts.map +1 -0
  38. package/dist/test-utils.js +153 -0
  39. package/dist/utils/clickhouse-client.d.ts +11 -0
  40. package/dist/utils/clickhouse-client.d.ts.map +1 -0
  41. package/dist/utils/clickhouse-client.js +86 -0
  42. package/dist/utils/dependency-installer.d.ts +2 -0
  43. package/dist/utils/dependency-installer.d.ts.map +1 -0
  44. package/dist/utils/dependency-installer.js +180 -0
  45. package/dist/utils/detect-database.d.ts +21 -0
  46. package/dist/utils/detect-database.d.ts.map +1 -0
  47. package/dist/utils/detect-database.js +224 -0
  48. package/dist/utils/error-messages.d.ts +6 -0
  49. package/dist/utils/error-messages.d.ts.map +1 -0
  50. package/dist/utils/error-messages.js +19 -0
  51. package/dist/utils/find-files.d.ts +21 -0
  52. package/dist/utils/find-files.d.ts.map +1 -0
  53. package/dist/utils/find-files.js +183 -0
  54. package/dist/utils/load-api.d.ts +2 -0
  55. package/dist/utils/load-api.d.ts.map +1 -0
  56. package/dist/utils/load-api.js +400 -0
  57. package/dist/utils/logger.d.ts +54 -0
  58. package/dist/utils/logger.d.ts.map +1 -0
  59. package/dist/utils/logger.js +122 -0
  60. package/dist/utils/prompts.d.ts +39 -0
  61. package/dist/utils/prompts.d.ts.map +1 -0
  62. package/dist/utils/prompts.js +282 -0
  63. package/package.json +50 -0
@@ -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"}
@@ -0,0 +1,175 @@
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 path from 'node:path';
38
+ import ora from 'ora';
39
+ import { logger } from '../utils/logger.js';
40
+ import { findSchemaFile } from '../utils/find-files.js';
41
+ import { detectDatabase, getTableCount } from '../utils/detect-database.js';
42
+ import { getTypeGenerator } from '../generators/index.js';
43
+ export function generateCommand() {
44
+ return __awaiter(this, arguments, void 0, function (options) {
45
+ var outputPath, existingSchema, parsedTables, requestedDbType, dbType, _a, spinner, generator, tableCount, typeSpinner, error_1;
46
+ if (options === void 0) { options = {}; }
47
+ return __generator(this, function (_b) {
48
+ switch (_b.label) {
49
+ case 0:
50
+ if (!options.output) return [3 /*break*/, 1];
51
+ outputPath = path.resolve(process.cwd(), options.output);
52
+ return [3 /*break*/, 3];
53
+ case 1: return [4 /*yield*/, findSchemaFile()];
54
+ case 2:
55
+ existingSchema = _b.sent();
56
+ if (existingSchema) {
57
+ outputPath = existingSchema;
58
+ }
59
+ else {
60
+ // Default to analytics/schema.ts
61
+ outputPath = path.join(process.cwd(), 'analytics', 'schema.ts');
62
+ }
63
+ _b.label = 3;
64
+ case 3:
65
+ parsedTables = options.tables
66
+ ? options.tables
67
+ .split(',')
68
+ .map(function (table) { return table.trim(); })
69
+ .filter(Boolean)
70
+ : undefined;
71
+ requestedDbType = options.database;
72
+ if (!(requestedDbType !== null && requestedDbType !== void 0)) return [3 /*break*/, 4];
73
+ _a = requestedDbType;
74
+ return [3 /*break*/, 6];
75
+ case 4: return [4 /*yield*/, detectDatabase()];
76
+ case 5:
77
+ _a = (_b.sent());
78
+ _b.label = 6;
79
+ case 6:
80
+ dbType = _a;
81
+ logger.newline();
82
+ logger.header('hypequery generate');
83
+ spinner = ora("Connecting to ".concat(dbType, "...")).start();
84
+ _b.label = 7;
85
+ case 7:
86
+ _b.trys.push([7, 10, , 11]);
87
+ generator = getTypeGenerator(dbType);
88
+ return [4 /*yield*/, getTableCount(dbType)];
89
+ case 8:
90
+ tableCount = _b.sent();
91
+ spinner.succeed("Connected to ".concat(dbType === 'clickhouse' ? 'ClickHouse' : dbType));
92
+ logger.success("Found ".concat(tableCount, " tables"));
93
+ typeSpinner = ora('Generating types...').start();
94
+ return [4 /*yield*/, generator({
95
+ outputPath: outputPath,
96
+ includeTables: parsedTables,
97
+ })];
98
+ case 9:
99
+ _b.sent();
100
+ typeSpinner.succeed("Generated types for ".concat(tableCount, " tables"));
101
+ logger.success("Updated ".concat(path.relative(process.cwd(), outputPath)));
102
+ logger.newline();
103
+ logger.header('Types regenerated successfully!');
104
+ logger.newline();
105
+ return [3 /*break*/, 11];
106
+ case 10:
107
+ error_1 = _b.sent();
108
+ spinner.fail('Failed to generate types');
109
+ logger.newline();
110
+ if (error_1 instanceof Error) {
111
+ logger.error(error_1.message);
112
+ // Provide specific guidance based on error type
113
+ if (error_1.message.includes('ECONNREFUSED')) {
114
+ logger.newline();
115
+ logger.info('This usually means:');
116
+ logger.indent('• ClickHouse is not running');
117
+ logger.indent('• Wrong host/port in configuration');
118
+ logger.indent('• Firewall blocking connection');
119
+ logger.newline();
120
+ logger.info('Check your configuration:');
121
+ logger.indent('CLICKHOUSE_HOST=' + (process.env.CLICKHOUSE_HOST || 'not set'));
122
+ logger.newline();
123
+ logger.info('Docs: https://hypequery.com/docs/troubleshooting#connection-errors');
124
+ }
125
+ else if (error_1.message.includes('ETIMEDOUT') || error_1.message.includes('timeout')) {
126
+ logger.newline();
127
+ logger.info('Database connection timed out');
128
+ logger.newline();
129
+ logger.info('This usually means:');
130
+ logger.indent('• Database is running but not responding');
131
+ logger.indent('• Network latency is too high');
132
+ logger.indent('• Firewall is dropping packets');
133
+ logger.newline();
134
+ logger.info('Try:');
135
+ logger.indent('• Check if database is under heavy load');
136
+ logger.indent('• Verify network connectivity');
137
+ logger.indent('• Check firewall rules');
138
+ }
139
+ else if (error_1.message.toLowerCase().includes('ssl') || error_1.message.toLowerCase().includes('tls')) {
140
+ logger.newline();
141
+ logger.info('SSL/TLS connection error');
142
+ logger.newline();
143
+ logger.info('This usually means:');
144
+ logger.indent('• SSL certificate validation failed');
145
+ logger.indent('• Incorrect SSL configuration');
146
+ logger.newline();
147
+ logger.info('Try:');
148
+ logger.indent('• Check if your connection string requires SSL');
149
+ logger.indent('• Verify SSL certificate is valid');
150
+ logger.indent('• Check SSL-related environment variables');
151
+ }
152
+ else if (error_1.message.toLowerCase().includes('authentication') || error_1.message.toLowerCase().includes('auth')) {
153
+ logger.newline();
154
+ logger.info('Authentication failed');
155
+ logger.newline();
156
+ logger.info('This usually means:');
157
+ logger.indent('• Invalid username or password');
158
+ logger.indent('• User does not have required permissions');
159
+ logger.newline();
160
+ logger.info('Check your configuration:');
161
+ logger.indent('CLICKHOUSE_USERNAME=' + (process.env.CLICKHOUSE_USERNAME || 'not set'));
162
+ logger.indent('CLICKHOUSE_PASSWORD=' + (process.env.CLICKHOUSE_PASSWORD ? '***' : 'not set'));
163
+ }
164
+ }
165
+ else {
166
+ logger.error(String(error_1));
167
+ }
168
+ logger.newline();
169
+ process.exit(1);
170
+ return [3 /*break*/, 11];
171
+ case 11: return [2 /*return*/];
172
+ }
173
+ });
174
+ });
175
+ }
@@ -0,0 +1,10 @@
1
+ export interface InitOptions {
2
+ database?: string;
3
+ path?: string;
4
+ noExample?: boolean;
5
+ noInteractive?: boolean;
6
+ force?: boolean;
7
+ skipConnection?: boolean;
8
+ }
9
+ export declare function initCommand(options?: InitOptions): Promise<void>;
10
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAgFD,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAAgB,iBAoO1D"}