@hypequery/cli 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/package.json +11 -11
- package/dist/bin/cli.d.ts +0 -3
- package/dist/bin/cli.d.ts.map +0 -1
- package/dist/bin/cli.js +0 -86
- package/dist/cli.d.ts +0 -4
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -162
- package/dist/commands/create-api-types.d.ts +0 -6
- package/dist/commands/create-api-types.d.ts.map +0 -1
- package/dist/commands/create-api-types.js +0 -149
- package/dist/commands/dev.d.ts +0 -12
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -249
- package/dist/commands/generate.d.ts +0 -8
- package/dist/commands/generate.d.ts.map +0 -1
- package/dist/commands/generate.js +0 -175
- package/dist/commands/init.d.ts +0 -9
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -362
- package/dist/commands/toolkit.d.ts +0 -6
- package/dist/commands/toolkit.d.ts.map +0 -1
- package/dist/commands/toolkit.js +0 -159
- package/dist/generators/clickhouse.d.ts +0 -7
- package/dist/generators/clickhouse.d.ts.map +0 -1
- package/dist/generators/clickhouse.js +0 -229
- package/dist/generators/index.d.ts +0 -7
- package/dist/generators/index.d.ts.map +0 -1
- package/dist/generators/index.js +0 -13
- package/dist/templates/client.d.ts +0 -5
- package/dist/templates/client.d.ts.map +0 -1
- package/dist/templates/client.js +0 -6
- package/dist/templates/env.d.ts +0 -14
- package/dist/templates/env.d.ts.map +0 -1
- package/dist/templates/env.js +0 -37
- package/dist/templates/gitignore.d.ts +0 -13
- package/dist/templates/gitignore.d.ts.map +0 -1
- package/dist/templates/gitignore.js +0 -22
- package/dist/templates/queries.d.ts +0 -8
- package/dist/templates/queries.d.ts.map +0 -1
- package/dist/templates/queries.js +0 -27
- package/dist/test-utils.d.ts +0 -86
- package/dist/test-utils.d.ts.map +0 -1
- package/dist/test-utils.js +0 -153
- package/dist/utils/clickhouse-client.d.ts +0 -11
- package/dist/utils/clickhouse-client.d.ts.map +0 -1
- package/dist/utils/clickhouse-client.js +0 -86
- package/dist/utils/detect-database.d.ts +0 -21
- package/dist/utils/detect-database.d.ts.map +0 -1
- package/dist/utils/detect-database.js +0 -224
- package/dist/utils/ensure-ts-runtime.d.ts +0 -4
- package/dist/utils/ensure-ts-runtime.d.ts.map +0 -1
- package/dist/utils/ensure-ts-runtime.js +0 -66
- 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/find-files.d.ts +0 -21
- package/dist/utils/find-files.d.ts.map +0 -1
- package/dist/utils/find-files.js +0 -183
- package/dist/utils/load-api.d.ts +0 -2
- package/dist/utils/load-api.d.ts.map +0 -1
- package/dist/utils/load-api.js +0 -308
- package/dist/utils/logger.d.ts +0 -54
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -122
- package/dist/utils/prompts.d.ts +0 -39
- package/dist/utils/prompts.d.ts.map +0 -1
- package/dist/utils/prompts.js +0 -282
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clickhouse-client.d.ts","sourceRoot":"","sources":["../../src/utils/clickhouse-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AASD,wBAAgB,0BAA0B,IAAI,mBAAmB,GAAG,IAAI,CAavE;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAmBtD;AAED,wBAAsB,+BAA+B,kBAKpD"}
|
|
@@ -1,86 +0,0 @@
|
|
|
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 { createClient } from '@clickhouse/client';
|
|
38
|
-
var client = null;
|
|
39
|
-
function readEnv(name, fallback) {
|
|
40
|
-
var value = process.env[name];
|
|
41
|
-
return value === undefined || value === '' ? fallback : value;
|
|
42
|
-
}
|
|
43
|
-
export function getClickHouseConfigFromEnv() {
|
|
44
|
-
var _a;
|
|
45
|
-
var url = (_a = readEnv('CLICKHOUSE_URL')) !== null && _a !== void 0 ? _a : readEnv('CLICKHOUSE_HOST');
|
|
46
|
-
if (!url) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
url: url,
|
|
51
|
-
username: readEnv('CLICKHOUSE_USERNAME', readEnv('CLICKHOUSE_USER', 'default')),
|
|
52
|
-
password: readEnv('CLICKHOUSE_PASSWORD', readEnv('CLICKHOUSE_PASS', '')),
|
|
53
|
-
database: readEnv('CLICKHOUSE_DATABASE', 'default'),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export function getClickHouseClient() {
|
|
57
|
-
if (!client) {
|
|
58
|
-
var config = getClickHouseConfigFromEnv();
|
|
59
|
-
if (!config) {
|
|
60
|
-
throw new Error('ClickHouse connection details are missing. Set CLICKHOUSE_HOST (or CLICKHOUSE_URL), CLICKHOUSE_DATABASE, CLICKHOUSE_USERNAME, and CLICKHOUSE_PASSWORD.');
|
|
61
|
-
}
|
|
62
|
-
client = createClient({
|
|
63
|
-
url: config.url,
|
|
64
|
-
username: config.username,
|
|
65
|
-
password: config.password,
|
|
66
|
-
database: config.database,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return client;
|
|
70
|
-
}
|
|
71
|
-
export function resetClickHouseClientForTesting() {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
switch (_a.label) {
|
|
75
|
-
case 0:
|
|
76
|
-
if (!client) return [3 /*break*/, 2];
|
|
77
|
-
return [4 /*yield*/, client.close()];
|
|
78
|
-
case 1:
|
|
79
|
-
_a.sent();
|
|
80
|
-
client = null;
|
|
81
|
-
_a.label = 2;
|
|
82
|
-
case 2: return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Database type detection result
|
|
3
|
-
*/
|
|
4
|
-
export type DatabaseType = 'clickhouse' | 'bigquery' | 'unknown';
|
|
5
|
-
/**
|
|
6
|
-
* Auto-detect database type from environment or config files
|
|
7
|
-
*/
|
|
8
|
-
export declare function detectDatabase(): Promise<DatabaseType>;
|
|
9
|
-
/**
|
|
10
|
-
* Validate database connection
|
|
11
|
-
*/
|
|
12
|
-
export declare function validateConnection(dbType: DatabaseType): Promise<boolean>;
|
|
13
|
-
/**
|
|
14
|
-
* Get table count from database
|
|
15
|
-
*/
|
|
16
|
-
export declare function getTableCount(dbType: DatabaseType): Promise<number>;
|
|
17
|
-
/**
|
|
18
|
-
* Get list of tables from database
|
|
19
|
-
*/
|
|
20
|
-
export declare function getTables(dbType: DatabaseType): Promise<string[]>;
|
|
21
|
-
//# sourceMappingURL=detect-database.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detect-database.d.ts","sourceRoot":"","sources":["../../src/utils/detect-database.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjE;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,CAyC5D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAS/E;AAuBD;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAOzE;AAyBD;;GAEG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOvE"}
|
|
@@ -1,224 +0,0 @@
|
|
|
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
|
-
import { getClickHouseClient } from './clickhouse-client.js';
|
|
40
|
-
/**
|
|
41
|
-
* Auto-detect database type from environment or config files
|
|
42
|
-
*/
|
|
43
|
-
export function detectDatabase() {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var envPath, readFile, envContent, _a;
|
|
46
|
-
return __generator(this, function (_b) {
|
|
47
|
-
switch (_b.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
// Check environment variables
|
|
50
|
-
if (process.env.CLICKHOUSE_HOST ||
|
|
51
|
-
process.env.CLICKHOUSE_URL ||
|
|
52
|
-
process.env.CLICKHOUSE_DATABASE) {
|
|
53
|
-
return [2 /*return*/, 'clickhouse'];
|
|
54
|
-
}
|
|
55
|
-
if (process.env.BIGQUERY_PROJECT_ID || process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
56
|
-
return [2 /*return*/, 'bigquery'];
|
|
57
|
-
}
|
|
58
|
-
_b.label = 1;
|
|
59
|
-
case 1:
|
|
60
|
-
_b.trys.push([1, 5, , 6]);
|
|
61
|
-
envPath = path.join(process.cwd(), '.env');
|
|
62
|
-
return [4 /*yield*/, access(envPath)];
|
|
63
|
-
case 2:
|
|
64
|
-
_b.sent();
|
|
65
|
-
return [4 /*yield*/, import('node:fs/promises')];
|
|
66
|
-
case 3:
|
|
67
|
-
readFile = (_b.sent()).readFile;
|
|
68
|
-
return [4 /*yield*/, readFile(envPath, 'utf-8')];
|
|
69
|
-
case 4:
|
|
70
|
-
envContent = _b.sent();
|
|
71
|
-
if (envContent.includes('CLICKHOUSE_') ||
|
|
72
|
-
envContent.includes('CLICKHOUSE_HOST')) {
|
|
73
|
-
return [2 /*return*/, 'clickhouse'];
|
|
74
|
-
}
|
|
75
|
-
if (envContent.includes('BIGQUERY_') ||
|
|
76
|
-
envContent.includes('GOOGLE_APPLICATION_CREDENTIALS')) {
|
|
77
|
-
return [2 /*return*/, 'bigquery'];
|
|
78
|
-
}
|
|
79
|
-
return [3 /*break*/, 6];
|
|
80
|
-
case 5:
|
|
81
|
-
_a = _b.sent();
|
|
82
|
-
return [3 /*break*/, 6];
|
|
83
|
-
case 6: return [2 /*return*/, 'unknown'];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Validate database connection
|
|
90
|
-
*/
|
|
91
|
-
export function validateConnection(dbType) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
return __generator(this, function (_a) {
|
|
94
|
-
switch (dbType) {
|
|
95
|
-
case 'clickhouse':
|
|
96
|
-
return [2 /*return*/, validateClickHouse()];
|
|
97
|
-
case 'bigquery':
|
|
98
|
-
return [2 /*return*/, validateBigQuery()];
|
|
99
|
-
default:
|
|
100
|
-
return [2 /*return*/, false];
|
|
101
|
-
}
|
|
102
|
-
return [2 /*return*/];
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function validateClickHouse() {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var client, result, _a;
|
|
109
|
-
return __generator(this, function (_b) {
|
|
110
|
-
switch (_b.label) {
|
|
111
|
-
case 0:
|
|
112
|
-
_b.trys.push([0, 3, , 4]);
|
|
113
|
-
client = getClickHouseClient();
|
|
114
|
-
return [4 /*yield*/, client.query({
|
|
115
|
-
query: 'SELECT 1',
|
|
116
|
-
format: 'JSONEachRow',
|
|
117
|
-
})];
|
|
118
|
-
case 1:
|
|
119
|
-
result = _b.sent();
|
|
120
|
-
return [4 /*yield*/, result.json()];
|
|
121
|
-
case 2:
|
|
122
|
-
_b.sent();
|
|
123
|
-
return [2 /*return*/, true];
|
|
124
|
-
case 3:
|
|
125
|
-
_a = _b.sent();
|
|
126
|
-
return [2 /*return*/, false];
|
|
127
|
-
case 4: return [2 /*return*/];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function validateBigQuery() {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
return __generator(this, function (_a) {
|
|
135
|
-
// TODO: Implement when BigQuery support is added
|
|
136
|
-
return [2 /*return*/, false];
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Get table count from database
|
|
142
|
-
*/
|
|
143
|
-
export function getTableCount(dbType) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
return __generator(this, function (_a) {
|
|
146
|
-
switch (dbType) {
|
|
147
|
-
case 'clickhouse':
|
|
148
|
-
return [2 /*return*/, getClickHouseTableCount()];
|
|
149
|
-
default:
|
|
150
|
-
return [2 /*return*/, 0];
|
|
151
|
-
}
|
|
152
|
-
return [2 /*return*/];
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Generic helper to execute ClickHouse queries with consistent error handling
|
|
158
|
-
*/
|
|
159
|
-
function executeClickHouseQuery(query, defaultValue) {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
161
|
-
var client, result, _a;
|
|
162
|
-
return __generator(this, function (_b) {
|
|
163
|
-
switch (_b.label) {
|
|
164
|
-
case 0:
|
|
165
|
-
_b.trys.push([0, 3, , 4]);
|
|
166
|
-
client = getClickHouseClient();
|
|
167
|
-
return [4 /*yield*/, client.query({
|
|
168
|
-
query: query,
|
|
169
|
-
format: 'JSONEachRow',
|
|
170
|
-
})];
|
|
171
|
-
case 1:
|
|
172
|
-
result = _b.sent();
|
|
173
|
-
return [4 /*yield*/, result.json()];
|
|
174
|
-
case 2: return [2 /*return*/, (_b.sent())];
|
|
175
|
-
case 3:
|
|
176
|
-
_a = _b.sent();
|
|
177
|
-
return [2 /*return*/, defaultValue];
|
|
178
|
-
case 4: return [2 /*return*/];
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
function getClickHouseTableCount() {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
-
var tables;
|
|
186
|
-
return __generator(this, function (_a) {
|
|
187
|
-
switch (_a.label) {
|
|
188
|
-
case 0: return [4 /*yield*/, executeClickHouseQuery('SHOW TABLES', [])];
|
|
189
|
-
case 1:
|
|
190
|
-
tables = _a.sent();
|
|
191
|
-
return [2 /*return*/, Array.isArray(tables) ? tables.length : 0];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get list of tables from database
|
|
198
|
-
*/
|
|
199
|
-
export function getTables(dbType) {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
return __generator(this, function (_a) {
|
|
202
|
-
switch (dbType) {
|
|
203
|
-
case 'clickhouse':
|
|
204
|
-
return [2 /*return*/, getClickHouseTables()];
|
|
205
|
-
default:
|
|
206
|
-
return [2 /*return*/, []];
|
|
207
|
-
}
|
|
208
|
-
return [2 /*return*/];
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
function getClickHouseTables() {
|
|
213
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
-
var tables;
|
|
215
|
-
return __generator(this, function (_a) {
|
|
216
|
-
switch (_a.label) {
|
|
217
|
-
case 0: return [4 /*yield*/, executeClickHouseQuery('SHOW TABLES', [])];
|
|
218
|
-
case 1:
|
|
219
|
-
tables = _a.sent();
|
|
220
|
-
return [2 /*return*/, tables.map(function (t) { return t.name; })];
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function ensureTypeScriptRuntime(): Promise<void>;
|
|
2
|
-
export declare function setTypeScriptRuntimeImporter(importer: () => Promise<unknown>): void;
|
|
3
|
-
export declare function resetTypeScriptRuntimeForTesting(): void;
|
|
4
|
-
//# sourceMappingURL=ensure-ts-runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-ts-runtime.d.ts","sourceRoot":"","sources":["../../src/utils/ensure-ts-runtime.ts"],"names":[],"mappings":"AAIA,wBAAsB,uBAAuB,kBAS5C;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,QAG5E;AAED,wBAAgB,gCAAgC,SAG/C"}
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
var tsxRuntimePromise = null;
|
|
38
|
-
var defaultImporter = function () { return import('tsx/esm'); };
|
|
39
|
-
var runtimeImporter = defaultImporter;
|
|
40
|
-
export function ensureTypeScriptRuntime() {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
switch (_a.label) {
|
|
44
|
-
case 0:
|
|
45
|
-
if (!tsxRuntimePromise) {
|
|
46
|
-
tsxRuntimePromise = runtimeImporter().catch(function (error) {
|
|
47
|
-
tsxRuntimePromise = null;
|
|
48
|
-
throw error;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return [4 /*yield*/, tsxRuntimePromise];
|
|
52
|
-
case 1:
|
|
53
|
-
_a.sent();
|
|
54
|
-
return [2 /*return*/];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
export function setTypeScriptRuntimeImporter(importer) {
|
|
60
|
-
runtimeImporter = importer;
|
|
61
|
-
tsxRuntimePromise = null;
|
|
62
|
-
}
|
|
63
|
-
export function resetTypeScriptRuntimeForTesting() {
|
|
64
|
-
runtimeImporter = defaultImporter;
|
|
65
|
-
tsxRuntimePromise = null;
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-messages.d.ts","sourceRoot":"","sources":["../../src/utils/error-messages.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAazE"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { logger } from './logger.js';
|
|
2
|
-
/**
|
|
3
|
-
* Display error when queries file cannot be found
|
|
4
|
-
* @param commandName - Name of the command for the usage example
|
|
5
|
-
*/
|
|
6
|
-
export function displayQueriesFileNotFoundError(commandName) {
|
|
7
|
-
logger.error('Could not find queries file');
|
|
8
|
-
logger.newline();
|
|
9
|
-
logger.info('Expected one of:');
|
|
10
|
-
logger.indent('• analytics/queries.ts');
|
|
11
|
-
logger.indent('• src/analytics/queries.ts');
|
|
12
|
-
logger.indent('• hypequery.ts');
|
|
13
|
-
logger.newline();
|
|
14
|
-
logger.info("Did you run 'hypequery init'?");
|
|
15
|
-
logger.newline();
|
|
16
|
-
logger.info('Or specify the file explicitly:');
|
|
17
|
-
logger.indent("hypequery ".concat(commandName, " ./path/to/queries.ts"));
|
|
18
|
-
logger.newline();
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the queries file in the project
|
|
3
|
-
*/
|
|
4
|
-
export declare function findQueriesFile(customPath?: string): Promise<string | null>;
|
|
5
|
-
/**
|
|
6
|
-
* Find the schema file (generated types)
|
|
7
|
-
*/
|
|
8
|
-
export declare function findSchemaFile(): Promise<string | null>;
|
|
9
|
-
/**
|
|
10
|
-
* Find the client file
|
|
11
|
-
*/
|
|
12
|
-
export declare function findClientFile(): Promise<string | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Check if .env file exists
|
|
15
|
-
*/
|
|
16
|
-
export declare function hasEnvFile(): Promise<boolean>;
|
|
17
|
-
/**
|
|
18
|
-
* Check if .gitignore exists
|
|
19
|
-
*/
|
|
20
|
-
export declare function hasGitignore(): Promise<boolean>;
|
|
21
|
-
//# sourceMappingURL=find-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-files.d.ts","sourceRoot":"","sources":["../../src/utils/find-files.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,wBAAsB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcjF;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO7D;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO7D;AAED;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAOnD;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAOrD"}
|
package/dist/utils/find-files.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/utils/load-api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-api.d.ts","sourceRoot":"","sources":["../../src/utils/load-api.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,gBAuErD"}
|