@hypequery/cli 0.0.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.
Files changed (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +246 -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 +3 -0
  6. package/dist/cli.d.ts +4 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +189 -0
  9. package/dist/commands/create-api-types.d.ts +6 -0
  10. package/dist/commands/create-api-types.d.ts.map +1 -0
  11. package/dist/commands/create-api-types.js +149 -0
  12. package/dist/commands/dev.d.ts +12 -0
  13. package/dist/commands/dev.d.ts.map +1 -0
  14. package/dist/commands/dev.js +253 -0
  15. package/dist/commands/generate.d.ts +7 -0
  16. package/dist/commands/generate.d.ts.map +1 -0
  17. package/dist/commands/generate.js +193 -0
  18. package/dist/commands/init.d.ts +9 -0
  19. package/dist/commands/init.d.ts.map +1 -0
  20. package/dist/commands/init.js +363 -0
  21. package/dist/commands/toolkit.d.ts +6 -0
  22. package/dist/commands/toolkit.d.ts.map +1 -0
  23. package/dist/commands/toolkit.js +159 -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 +21 -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/detect-database.d.ts +21 -0
  40. package/dist/utils/detect-database.d.ts.map +1 -0
  41. package/dist/utils/detect-database.js +266 -0
  42. package/dist/utils/error-messages.d.ts +6 -0
  43. package/dist/utils/error-messages.d.ts.map +1 -0
  44. package/dist/utils/error-messages.js +19 -0
  45. package/dist/utils/find-files.d.ts +21 -0
  46. package/dist/utils/find-files.d.ts.map +1 -0
  47. package/dist/utils/find-files.js +183 -0
  48. package/dist/utils/load-api.d.ts +2 -0
  49. package/dist/utils/load-api.d.ts.map +1 -0
  50. package/dist/utils/load-api.js +163 -0
  51. package/dist/utils/logger.d.ts +54 -0
  52. package/dist/utils/logger.d.ts.map +1 -0
  53. package/dist/utils/logger.js +122 -0
  54. package/dist/utils/prompts.d.ts +39 -0
  55. package/dist/utils/prompts.d.ts.map +1 -0
  56. package/dist/utils/prompts.js +282 -0
  57. package/package.json +52 -0
@@ -0,0 +1,183 @@
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 { access } from 'node:fs/promises';
38
+ import path from 'node:path';
39
+ /**
40
+ * Generic helper to find a file from a list of candidate paths
41
+ */
42
+ function findFile(candidates) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var _i, candidates_1, candidate, resolved, _a;
45
+ return __generator(this, function (_b) {
46
+ switch (_b.label) {
47
+ case 0:
48
+ _i = 0, candidates_1 = candidates;
49
+ _b.label = 1;
50
+ case 1:
51
+ if (!(_i < candidates_1.length)) return [3 /*break*/, 6];
52
+ candidate = candidates_1[_i];
53
+ resolved = path.resolve(process.cwd(), candidate);
54
+ _b.label = 2;
55
+ case 2:
56
+ _b.trys.push([2, 4, , 5]);
57
+ return [4 /*yield*/, access(resolved)];
58
+ case 3:
59
+ _b.sent();
60
+ return [2 /*return*/, resolved];
61
+ case 4:
62
+ _a = _b.sent();
63
+ return [3 /*break*/, 5];
64
+ case 5:
65
+ _i++;
66
+ return [3 /*break*/, 1];
67
+ case 6: return [2 /*return*/, null];
68
+ }
69
+ });
70
+ });
71
+ }
72
+ /**
73
+ * Common query file locations to check
74
+ */
75
+ var DEFAULT_QUERY_PATHS = [
76
+ 'hypequery.ts',
77
+ 'analytics/queries.ts',
78
+ 'src/analytics/queries.ts',
79
+ 'queries.ts',
80
+ 'src/queries.ts',
81
+ ];
82
+ /**
83
+ * Find the queries file in the project
84
+ */
85
+ export function findQueriesFile(customPath) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var resolved, _a;
88
+ return __generator(this, function (_b) {
89
+ switch (_b.label) {
90
+ case 0:
91
+ if (!customPath) return [3 /*break*/, 4];
92
+ resolved = path.resolve(process.cwd(), customPath);
93
+ _b.label = 1;
94
+ case 1:
95
+ _b.trys.push([1, 3, , 4]);
96
+ return [4 /*yield*/, access(resolved)];
97
+ case 2:
98
+ _b.sent();
99
+ return [2 /*return*/, resolved];
100
+ case 3:
101
+ _a = _b.sent();
102
+ return [2 /*return*/, null];
103
+ case 4:
104
+ // Check default locations
105
+ return [2 /*return*/, findFile(DEFAULT_QUERY_PATHS)];
106
+ }
107
+ });
108
+ });
109
+ }
110
+ /**
111
+ * Find the schema file (generated types)
112
+ */
113
+ export function findSchemaFile() {
114
+ return __awaiter(this, void 0, void 0, function () {
115
+ return __generator(this, function (_a) {
116
+ return [2 /*return*/, findFile([
117
+ 'analytics/schema.ts',
118
+ 'src/analytics/schema.ts',
119
+ 'schema.ts',
120
+ 'src/schema.ts',
121
+ ])];
122
+ });
123
+ });
124
+ }
125
+ /**
126
+ * Find the client file
127
+ */
128
+ export function findClientFile() {
129
+ return __awaiter(this, void 0, void 0, function () {
130
+ return __generator(this, function (_a) {
131
+ return [2 /*return*/, findFile([
132
+ 'analytics/client.ts',
133
+ 'src/analytics/client.ts',
134
+ 'client.ts',
135
+ 'src/client.ts',
136
+ ])];
137
+ });
138
+ });
139
+ }
140
+ /**
141
+ * Check if .env file exists
142
+ */
143
+ export function hasEnvFile() {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var _a;
146
+ return __generator(this, function (_b) {
147
+ switch (_b.label) {
148
+ case 0:
149
+ _b.trys.push([0, 2, , 3]);
150
+ return [4 /*yield*/, access(path.join(process.cwd(), '.env'))];
151
+ case 1:
152
+ _b.sent();
153
+ return [2 /*return*/, true];
154
+ case 2:
155
+ _a = _b.sent();
156
+ return [2 /*return*/, false];
157
+ case 3: return [2 /*return*/];
158
+ }
159
+ });
160
+ });
161
+ }
162
+ /**
163
+ * Check if .gitignore exists
164
+ */
165
+ export function hasGitignore() {
166
+ return __awaiter(this, void 0, void 0, function () {
167
+ var _a;
168
+ return __generator(this, function (_b) {
169
+ switch (_b.label) {
170
+ case 0:
171
+ _b.trys.push([0, 2, , 3]);
172
+ return [4 /*yield*/, access(path.join(process.cwd(), '.gitignore'))];
173
+ case 1:
174
+ _b.sent();
175
+ return [2 /*return*/, true];
176
+ case 2:
177
+ _a = _b.sent();
178
+ return [2 /*return*/, false];
179
+ case 3: return [2 /*return*/];
180
+ }
181
+ });
182
+ });
183
+ }
@@ -0,0 +1,2 @@
1
+ export declare function loadApiModule(modulePath: string): Promise<any>;
2
+ //# sourceMappingURL=load-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-api.d.ts","sourceRoot":"","sources":["../../src/utils/load-api.ts"],"names":[],"mappings":"AAKA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,gBA6GrD"}
@@ -0,0 +1,163 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
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
+ };
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
57
+ import { pathToFileURL } from 'node:url';
58
+ import { spawn } from 'node:child_process';
59
+ import { access } from 'node:fs/promises';
60
+ import path from 'node:path';
61
+ export function loadApiModule(modulePath) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var resolved, _a, relativePath, isTypeScript, _b, child, moduleUrl, mod, error_1, relativePath, api, relativePath, availableExports;
64
+ var _c;
65
+ return __generator(this, function (_d) {
66
+ switch (_d.label) {
67
+ case 0:
68
+ resolved = path.resolve(process.cwd(), modulePath);
69
+ _d.label = 1;
70
+ case 1:
71
+ _d.trys.push([1, 3, , 4]);
72
+ return [4 /*yield*/, access(resolved)];
73
+ case 2:
74
+ _d.sent();
75
+ return [3 /*break*/, 4];
76
+ case 3:
77
+ _a = _d.sent();
78
+ relativePath = path.relative(process.cwd(), resolved);
79
+ throw new Error("File not found: ".concat(relativePath, "\n\n") +
80
+ "Make sure the file exists and the path is correct.\n" +
81
+ "You can specify a different file with:\n" +
82
+ " hypequery dev path/to/your/queries.ts");
83
+ case 4:
84
+ isTypeScript = resolved.endsWith('.ts') || resolved.endsWith('.mts') || resolved.endsWith('.cts');
85
+ if (!(isTypeScript && !process.env.TSX_LOADED)) return [3 /*break*/, 9];
86
+ _d.label = 5;
87
+ case 5:
88
+ _d.trys.push([5, 7, , 8]);
89
+ // @ts-ignore - tsx module might not have types
90
+ return [4 /*yield*/, import('tsx/esm')];
91
+ case 6:
92
+ // @ts-ignore - tsx module might not have types
93
+ _d.sent();
94
+ return [3 /*break*/, 8];
95
+ case 7:
96
+ _b = _d.sent();
97
+ throw new Error("To run TypeScript files directly, install tsx:\n npm install -D tsx\n\nOr compile your TypeScript first and use the .js file instead.");
98
+ case 8:
99
+ // Re-exec the current command with tsx
100
+ console.error('\n⚠️ TypeScript detected. Restarting with tsx...\n');
101
+ child = spawn('npx', __spreadArray(['tsx'], process.argv.slice(1), true), {
102
+ stdio: 'inherit',
103
+ env: __assign(__assign({}, process.env), { TSX_LOADED: 'true' }),
104
+ });
105
+ child.on('exit', function (code) {
106
+ process.exit(code || 0);
107
+ });
108
+ child.on('error', function (error) {
109
+ console.error('Failed to restart with tsx:', error);
110
+ process.exit(1);
111
+ });
112
+ // Return a never-resolving promise since we're exiting
113
+ return [2 /*return*/, new Promise(function () { })];
114
+ case 9:
115
+ moduleUrl = "".concat(pathToFileURL(resolved).href, "?t=").concat(Date.now());
116
+ _d.label = 10;
117
+ case 10:
118
+ _d.trys.push([10, 12, , 13]);
119
+ return [4 /*yield*/, import(moduleUrl)];
120
+ case 11:
121
+ mod = _d.sent();
122
+ return [3 /*break*/, 13];
123
+ case 12:
124
+ error_1 = _d.sent();
125
+ relativePath = path.relative(process.cwd(), resolved);
126
+ throw new Error("Failed to load module: ".concat(relativePath, "\n\n") +
127
+ "Error: ".concat(error_1.message, "\n\n") +
128
+ (error_1.code === 'ERR_MODULE_NOT_FOUND'
129
+ ? "This usually means:\n" +
130
+ " \u2022 A dependency is missing (run 'npm install')\n" +
131
+ " \u2022 An import path is incorrect\n"
132
+ : "") +
133
+ (error_1.stack ? "\nStack trace:\n".concat(error_1.stack, "\n") : ''));
134
+ case 13:
135
+ api = (_c = mod.api) !== null && _c !== void 0 ? _c : mod.default;
136
+ if (!api || typeof api.handler !== 'function') {
137
+ relativePath = path.relative(process.cwd(), resolved);
138
+ availableExports = Object.keys(mod).filter(function (key) { return key !== '__esModule'; });
139
+ throw new Error("Invalid API module: ".concat(relativePath, "\n\n") +
140
+ "The module must export a 'defineServe' result as 'api'.\n\n" +
141
+ (availableExports.length > 0
142
+ ? "Found exports: ".concat(availableExports.join(', '), "\n\n")
143
+ : "No exports found in the module.\n\n") +
144
+ "Expected format:\n\n" +
145
+ " import { initServe } from '@hypequery/serve';\n" +
146
+ " \n" +
147
+ " const { define, queries, query } = initServe({\n" +
148
+ " context: () => ({ db }),\n" +
149
+ " });\n" +
150
+ " \n" +
151
+ " export const api = define({\n" +
152
+ " queries: queries({\n" +
153
+ " myQuery: query.query(async ({ ctx }) => {\n" +
154
+ " // ...\n" +
155
+ " }),\n" +
156
+ " }),\n" +
157
+ " });\n");
158
+ }
159
+ return [2 /*return*/, api];
160
+ }
161
+ });
162
+ });
163
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Calm, professional CLI logger
3
+ * Follows Vercel-style output: informative, actionable, no noise
4
+ */
5
+ export declare class Logger {
6
+ private quiet;
7
+ constructor(quiet?: boolean);
8
+ /**
9
+ * Success message with checkmark
10
+ */
11
+ success(message: string): void;
12
+ /**
13
+ * Error message with X mark
14
+ */
15
+ error(message: string): void;
16
+ /**
17
+ * Warning message with warning symbol
18
+ */
19
+ warn(message: string): void;
20
+ /**
21
+ * Info message (no symbol)
22
+ */
23
+ info(message: string): void;
24
+ /**
25
+ * Reload/change message
26
+ */
27
+ reload(message: string): void;
28
+ /**
29
+ * Section header
30
+ */
31
+ header(message: string): void;
32
+ /**
33
+ * Empty line
34
+ */
35
+ newline(): void;
36
+ /**
37
+ * Indented message (for sub-items)
38
+ */
39
+ indent(message: string): void;
40
+ /**
41
+ * Boxed URL output
42
+ */
43
+ box(lines: string[]): void;
44
+ /**
45
+ * Table output (for dev server stats)
46
+ */
47
+ table(headers: string[], rows: string[][]): void;
48
+ /**
49
+ * Raw console.log (bypass quiet mode)
50
+ */
51
+ raw(message: string): void;
52
+ }
53
+ export declare const logger: Logger;
54
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAU;gBAEX,KAAK,UAAQ;IAIzB;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM;IAMvB;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM;IAMpB;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM;IAMpB;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM;IAMtB;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM;IAMtB;;OAEG;IACH,OAAO;IAMP;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM;IAMtB;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE;IAcnB;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAyBzC;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM;CAGpB;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
@@ -0,0 +1,122 @@
1
+ import chalk from 'chalk';
2
+ /**
3
+ * Calm, professional CLI logger
4
+ * Follows Vercel-style output: informative, actionable, no noise
5
+ */
6
+ var Logger = /** @class */ (function () {
7
+ function Logger(quiet) {
8
+ if (quiet === void 0) { quiet = false; }
9
+ this.quiet = quiet;
10
+ }
11
+ /**
12
+ * Success message with checkmark
13
+ */
14
+ Logger.prototype.success = function (message) {
15
+ if (!this.quiet) {
16
+ console.log(chalk.green('✓') + ' ' + message);
17
+ }
18
+ };
19
+ /**
20
+ * Error message with X mark
21
+ */
22
+ Logger.prototype.error = function (message) {
23
+ console.error(chalk.red('✗') + ' ' + message);
24
+ };
25
+ /**
26
+ * Warning message with warning symbol
27
+ */
28
+ Logger.prototype.warn = function (message) {
29
+ if (!this.quiet) {
30
+ console.warn(chalk.yellow('⚠') + ' ' + message);
31
+ }
32
+ };
33
+ /**
34
+ * Info message (no symbol)
35
+ */
36
+ Logger.prototype.info = function (message) {
37
+ if (!this.quiet) {
38
+ console.log(' ' + message);
39
+ }
40
+ };
41
+ /**
42
+ * Reload/change message
43
+ */
44
+ Logger.prototype.reload = function (message) {
45
+ if (!this.quiet) {
46
+ console.log(chalk.blue('↻') + ' ' + message);
47
+ }
48
+ };
49
+ /**
50
+ * Section header
51
+ */
52
+ Logger.prototype.header = function (message) {
53
+ if (!this.quiet) {
54
+ console.log('\n' + chalk.bold(message) + '\n');
55
+ }
56
+ };
57
+ /**
58
+ * Empty line
59
+ */
60
+ Logger.prototype.newline = function () {
61
+ if (!this.quiet) {
62
+ console.log();
63
+ }
64
+ };
65
+ /**
66
+ * Indented message (for sub-items)
67
+ */
68
+ Logger.prototype.indent = function (message) {
69
+ if (!this.quiet) {
70
+ console.log(' ' + message);
71
+ }
72
+ };
73
+ /**
74
+ * Boxed URL output
75
+ */
76
+ Logger.prototype.box = function (lines) {
77
+ if (!this.quiet) {
78
+ var maxLength = Math.max.apply(Math, lines.map(function (l) { return l.length; }));
79
+ var border = '─'.repeat(maxLength + 4);
80
+ console.log(' ┌' + border + '┐');
81
+ for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
82
+ var line = lines_1[_i];
83
+ var padding = ' '.repeat(maxLength - line.length);
84
+ console.log(' │ ' + line + padding + ' │');
85
+ }
86
+ console.log(' └' + border + '┘');
87
+ }
88
+ };
89
+ /**
90
+ * Table output (for dev server stats)
91
+ */
92
+ Logger.prototype.table = function (headers, rows) {
93
+ if (!this.quiet) {
94
+ var columnWidths_1 = headers.map(function (header, i) {
95
+ var maxContentWidth = Math.max.apply(Math, rows.map(function (row) { return (row[i] || '').length; }));
96
+ return Math.max(header.length, maxContentWidth);
97
+ });
98
+ // Header
99
+ var headerRow = headers
100
+ .map(function (h, i) { return h.padEnd(columnWidths_1[i]); })
101
+ .join(' ');
102
+ console.log(' ' + chalk.bold(headerRow));
103
+ // Rows
104
+ for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) {
105
+ var row = rows_1[_i];
106
+ var formattedRow = row
107
+ .map(function (cell, i) { return cell.padEnd(columnWidths_1[i]); })
108
+ .join(' ');
109
+ console.log(' ' + formattedRow);
110
+ }
111
+ }
112
+ };
113
+ /**
114
+ * Raw console.log (bypass quiet mode)
115
+ */
116
+ Logger.prototype.raw = function (message) {
117
+ console.log(message);
118
+ };
119
+ return Logger;
120
+ }());
121
+ export { Logger };
122
+ export var logger = new Logger();
@@ -0,0 +1,39 @@
1
+ import type { DatabaseType } from './detect-database.js';
2
+ /**
3
+ * Prompt for database type selection
4
+ */
5
+ export declare function promptDatabaseType(): Promise<DatabaseType | null>;
6
+ /**
7
+ * Prompt for ClickHouse connection details
8
+ */
9
+ export declare function promptClickHouseConnection(): Promise<{
10
+ host: string;
11
+ database: string;
12
+ username: string;
13
+ password: string;
14
+ } | null>;
15
+ /**
16
+ * Prompt for output directory
17
+ */
18
+ export declare function promptOutputDirectory(): Promise<string>;
19
+ /**
20
+ * Prompt for example query generation
21
+ */
22
+ export declare function promptGenerateExample(): Promise<boolean>;
23
+ /**
24
+ * Prompt for table selection (for example query)
25
+ */
26
+ export declare function promptTableSelection(tables: string[]): Promise<string | null>;
27
+ /**
28
+ * Confirm overwrite of existing files
29
+ */
30
+ export declare function confirmOverwrite(files: string[]): Promise<boolean>;
31
+ /**
32
+ * Retry prompt for failed operations
33
+ */
34
+ export declare function promptRetry(message: string): Promise<boolean>;
35
+ /**
36
+ * Ask if user wants to continue without DB connection
37
+ */
38
+ export declare function promptContinueWithoutDb(): Promise<boolean>;
39
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/utils/prompts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMzD;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAavE;AAED;;GAEG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAAC,CAkCR;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CA6B7D;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAS9D;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0BnF;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CASxE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASnE;AAED;;GAEG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAShE"}