@hypequery/cli 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/dist/bin/cli.js +21 -81
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +72 -116
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +180 -255
- package/dist/commands/generate-datasets.d.ts +14 -0
- package/dist/commands/generate-datasets.d.ts.map +1 -0
- package/dist/commands/generate-datasets.js +96 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +112 -167
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +337 -370
- package/dist/generators/clickhouse.d.ts +1 -1
- package/dist/generators/clickhouse.d.ts.map +1 -1
- package/dist/generators/clickhouse.js +10 -269
- package/dist/generators/dataset-generator.d.ts +16 -0
- package/dist/generators/dataset-generator.d.ts.map +1 -0
- package/dist/generators/dataset-generator.js +246 -0
- package/dist/generators/index.js +3 -3
- package/dist/templates/api.d.ts +9 -0
- package/dist/templates/api.d.ts.map +1 -0
- package/dist/templates/api.js +26 -0
- package/dist/templates/auth-scaffold.d.ts +17 -0
- package/dist/templates/auth-scaffold.d.ts.map +1 -0
- package/dist/templates/auth-scaffold.js +41 -0
- package/dist/templates/client.js +10 -1
- package/dist/templates/datasets.d.ts +5 -0
- package/dist/templates/datasets.d.ts.map +1 -0
- package/dist/templates/datasets.js +23 -0
- package/dist/templates/env.js +19 -8
- package/dist/templates/gitignore.js +4 -1
- package/dist/templates/queries.d.ts +3 -0
- package/dist/templates/queries.d.ts.map +1 -1
- package/dist/templates/queries.js +66 -10
- package/dist/test-utils.d.ts +0 -71
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +12 -137
- package/dist/utils/clickhouse-client.js +10 -57
- package/dist/utils/clickhouse-sql.d.ts +6 -0
- package/dist/utils/clickhouse-sql.d.ts.map +1 -0
- package/dist/utils/clickhouse-sql.js +18 -0
- package/dist/utils/clickhouse-type-utils.d.ts +6 -0
- package/dist/utils/clickhouse-type-utils.d.ts.map +1 -0
- package/dist/utils/clickhouse-type-utils.js +59 -0
- package/dist/utils/dependency-installer.d.ts +4 -2
- package/dist/utils/dependency-installer.d.ts.map +1 -1
- package/dist/utils/dependency-installer.js +93 -170
- package/dist/utils/detect-database.js +84 -195
- package/dist/utils/find-files.d.ts +3 -1
- package/dist/utils/find-files.d.ts.map +1 -1
- package/dist/utils/find-files.js +82 -148
- package/dist/utils/load-api.d.ts.map +1 -1
- package/dist/utils/load-api.js +207 -396
- package/dist/utils/logger.js +38 -42
- package/dist/utils/prompts.d.ts +14 -0
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/prompts.js +170 -219
- package/dist/utils/runtime-guards.d.ts +4 -0
- package/dist/utils/runtime-guards.d.ts.map +1 -0
- package/dist/utils/runtime-guards.js +9 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/dist/utils/sha256.d.ts.map +1 -0
- package/dist/utils/sha256.js +4 -0
- package/package.json +3 -8
- package/dist/utils/error-messages.d.ts +0 -6
- package/dist/utils/error-messages.d.ts.map +0 -1
- package/dist/utils/error-messages.js +0 -19
- package/dist/utils/load-hypequery-config.d.ts +0 -7
- package/dist/utils/load-hypequery-config.d.ts.map +0 -1
- package/dist/utils/load-hypequery-config.js +0 -89
|
@@ -1,224 +1,113 @@
|
|
|
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
1
|
import { access } from 'node:fs/promises';
|
|
38
2
|
import path from 'node:path';
|
|
39
3
|
import { getClickHouseClient } from './clickhouse-client.js';
|
|
40
4
|
/**
|
|
41
5
|
* Auto-detect database type from environment or config files
|
|
42
6
|
*/
|
|
43
|
-
export function detectDatabase() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
});
|
|
7
|
+
export async function detectDatabase() {
|
|
8
|
+
// Check environment variables
|
|
9
|
+
if (process.env.CLICKHOUSE_HOST ||
|
|
10
|
+
process.env.CLICKHOUSE_URL ||
|
|
11
|
+
process.env.CLICKHOUSE_DATABASE) {
|
|
12
|
+
return 'clickhouse';
|
|
13
|
+
}
|
|
14
|
+
if (process.env.BIGQUERY_PROJECT_ID || process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
15
|
+
return 'bigquery';
|
|
16
|
+
}
|
|
17
|
+
// Check for .env file and parse it
|
|
18
|
+
try {
|
|
19
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
20
|
+
await access(envPath);
|
|
21
|
+
const { readFile } = await import('node:fs/promises');
|
|
22
|
+
const envContent = await readFile(envPath, 'utf-8');
|
|
23
|
+
if (envContent.includes('CLICKHOUSE_') ||
|
|
24
|
+
envContent.includes('CLICKHOUSE_HOST')) {
|
|
25
|
+
return 'clickhouse';
|
|
26
|
+
}
|
|
27
|
+
if (envContent.includes('BIGQUERY_') ||
|
|
28
|
+
envContent.includes('GOOGLE_APPLICATION_CREDENTIALS')) {
|
|
29
|
+
return 'bigquery';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// .env doesn't exist, continue
|
|
34
|
+
}
|
|
35
|
+
return 'unknown';
|
|
87
36
|
}
|
|
88
37
|
/**
|
|
89
38
|
* Validate database connection
|
|
90
39
|
*/
|
|
91
|
-
export function validateConnection(dbType) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return [2 /*return*/, false];
|
|
101
|
-
}
|
|
102
|
-
return [2 /*return*/];
|
|
103
|
-
});
|
|
104
|
-
});
|
|
40
|
+
export async function validateConnection(dbType) {
|
|
41
|
+
switch (dbType) {
|
|
42
|
+
case 'clickhouse':
|
|
43
|
+
return validateClickHouse();
|
|
44
|
+
case 'bigquery':
|
|
45
|
+
return validateBigQuery();
|
|
46
|
+
default:
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
105
49
|
}
|
|
106
|
-
function validateClickHouse() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
}
|
|
50
|
+
async function validateClickHouse() {
|
|
51
|
+
try {
|
|
52
|
+
const client = getClickHouseClient();
|
|
53
|
+
const result = await client.query({
|
|
54
|
+
query: 'SELECT 1',
|
|
55
|
+
format: 'JSONEachRow',
|
|
129
56
|
});
|
|
130
|
-
|
|
57
|
+
await result.json();
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
131
63
|
}
|
|
132
|
-
function validateBigQuery() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// TODO: Implement when BigQuery support is added
|
|
136
|
-
return [2 /*return*/, false];
|
|
137
|
-
});
|
|
138
|
-
});
|
|
64
|
+
async function validateBigQuery() {
|
|
65
|
+
// TODO: Implement when BigQuery support is added
|
|
66
|
+
return false;
|
|
139
67
|
}
|
|
140
68
|
/**
|
|
141
69
|
* Get table count from database
|
|
142
70
|
*/
|
|
143
|
-
export function getTableCount(dbType) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return [2 /*return*/, 0];
|
|
151
|
-
}
|
|
152
|
-
return [2 /*return*/];
|
|
153
|
-
});
|
|
154
|
-
});
|
|
71
|
+
export async function getTableCount(dbType) {
|
|
72
|
+
switch (dbType) {
|
|
73
|
+
case 'clickhouse':
|
|
74
|
+
return getClickHouseTableCount();
|
|
75
|
+
default:
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
155
78
|
}
|
|
156
79
|
/**
|
|
157
80
|
* Generic helper to execute ClickHouse queries with consistent error handling
|
|
158
81
|
*/
|
|
159
|
-
function executeClickHouseQuery(query, defaultValue) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
}
|
|
82
|
+
async function executeClickHouseQuery(query, defaultValue) {
|
|
83
|
+
try {
|
|
84
|
+
const client = getClickHouseClient();
|
|
85
|
+
const result = await client.query({
|
|
86
|
+
query,
|
|
87
|
+
format: 'JSONEachRow',
|
|
180
88
|
});
|
|
181
|
-
|
|
89
|
+
return (await result.json());
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return defaultValue;
|
|
93
|
+
}
|
|
182
94
|
}
|
|
183
|
-
function getClickHouseTableCount() {
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
});
|
|
95
|
+
async function getClickHouseTableCount() {
|
|
96
|
+
const tables = await executeClickHouseQuery('SHOW TABLES', []);
|
|
97
|
+
return Array.isArray(tables) ? tables.length : 0;
|
|
195
98
|
}
|
|
196
99
|
/**
|
|
197
100
|
* Get list of tables from database
|
|
198
101
|
*/
|
|
199
|
-
export function getTables(dbType) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return [2 /*return*/, []];
|
|
207
|
-
}
|
|
208
|
-
return [2 /*return*/];
|
|
209
|
-
});
|
|
210
|
-
});
|
|
102
|
+
export async function getTables(dbType) {
|
|
103
|
+
switch (dbType) {
|
|
104
|
+
case 'clickhouse':
|
|
105
|
+
return getClickHouseTables();
|
|
106
|
+
default:
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
211
109
|
}
|
|
212
|
-
function getClickHouseTables() {
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
});
|
|
110
|
+
async function getClickHouseTables() {
|
|
111
|
+
const tables = await executeClickHouseQuery('SHOW TABLES', []);
|
|
112
|
+
return tables.map(t => t.name);
|
|
224
113
|
}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* Find the queries file in the project
|
|
3
3
|
*/
|
|
4
4
|
export declare function findQueriesFile(customPath?: string): Promise<string | null>;
|
|
5
|
+
export declare function findApiFileForPath(directory: string): Promise<string | null>;
|
|
5
6
|
/**
|
|
6
7
|
* Find the schema file (generated types)
|
|
7
8
|
*/
|
|
8
|
-
export declare function findSchemaFile(): Promise<string | null>;
|
|
9
|
+
export declare function findSchemaFile(directory?: string): Promise<string | null>;
|
|
10
|
+
export declare function findDatasetsFile(directory?: string): Promise<string | null>;
|
|
9
11
|
/**
|
|
10
12
|
* Find the client file
|
|
11
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-files.d.ts","sourceRoot":"","sources":["../../src/utils/find-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-files.d.ts","sourceRoot":"","sources":["../../src/utils/find-files.ts"],"names":[],"mappings":"AAmCA;;GAEG;AACH,wBAAsB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcjF;AAED,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKlF;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW/E;AAED,wBAAsB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYjF;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
CHANGED
|
@@ -1,79 +1,30 @@
|
|
|
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
1
|
import { access } from 'node:fs/promises';
|
|
38
2
|
import path from 'node:path';
|
|
39
3
|
/**
|
|
40
4
|
* Generic helper to find a file from a list of candidate paths
|
|
41
5
|
*/
|
|
42
|
-
function findFile(candidates) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
});
|
|
6
|
+
async function findFile(candidates) {
|
|
7
|
+
for (const candidate of candidates) {
|
|
8
|
+
const resolved = path.resolve(process.cwd(), candidate);
|
|
9
|
+
try {
|
|
10
|
+
await access(resolved);
|
|
11
|
+
return resolved;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// Continue checking
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
71
18
|
}
|
|
72
19
|
/**
|
|
73
20
|
* Common query file locations to check
|
|
74
21
|
*/
|
|
75
|
-
|
|
22
|
+
const DEFAULT_API_PATHS = [
|
|
76
23
|
'hypequery.ts',
|
|
24
|
+
'analytics/api.ts',
|
|
25
|
+
'src/analytics/api.ts',
|
|
26
|
+
'api.ts',
|
|
27
|
+
'src/api.ts',
|
|
77
28
|
'analytics/queries.ts',
|
|
78
29
|
'src/analytics/queries.ts',
|
|
79
30
|
'queries.ts',
|
|
@@ -82,102 +33,85 @@ var DEFAULT_QUERY_PATHS = [
|
|
|
82
33
|
/**
|
|
83
34
|
* Find the queries file in the project
|
|
84
35
|
*/
|
|
85
|
-
export function findQueriesFile(customPath) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return [2 /*return*/, findFile(DEFAULT_QUERY_PATHS)];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
36
|
+
export async function findQueriesFile(customPath) {
|
|
37
|
+
// If custom path provided, check only that
|
|
38
|
+
if (customPath) {
|
|
39
|
+
const resolved = path.resolve(process.cwd(), customPath);
|
|
40
|
+
try {
|
|
41
|
+
await access(resolved);
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Check default locations
|
|
49
|
+
return findFile(DEFAULT_API_PATHS);
|
|
50
|
+
}
|
|
51
|
+
export async function findApiFileForPath(directory) {
|
|
52
|
+
return findFile([
|
|
53
|
+
path.join(directory, 'api.ts'),
|
|
54
|
+
path.join(directory, 'queries.ts'),
|
|
55
|
+
]);
|
|
109
56
|
}
|
|
110
57
|
/**
|
|
111
58
|
* Find the schema file (generated types)
|
|
112
59
|
*/
|
|
113
|
-
export function findSchemaFile() {
|
|
114
|
-
|
|
115
|
-
return
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
60
|
+
export async function findSchemaFile(directory) {
|
|
61
|
+
if (directory) {
|
|
62
|
+
return path.resolve(process.cwd(), directory, 'schema.ts');
|
|
63
|
+
}
|
|
64
|
+
return findFile([
|
|
65
|
+
'analytics/schema.ts',
|
|
66
|
+
'src/analytics/schema.ts',
|
|
67
|
+
'schema.ts',
|
|
68
|
+
'src/schema.ts',
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
export async function findDatasetsFile(directory) {
|
|
72
|
+
if (directory) {
|
|
73
|
+
return path.resolve(process.cwd(), directory, 'datasets.ts');
|
|
74
|
+
}
|
|
75
|
+
return findFile([
|
|
76
|
+
'analytics/datasets.ts',
|
|
77
|
+
'src/analytics/datasets.ts',
|
|
78
|
+
'datasets.ts',
|
|
79
|
+
'src/datasets.ts',
|
|
80
|
+
'src/datasets/generated.ts',
|
|
81
|
+
]);
|
|
124
82
|
}
|
|
125
83
|
/**
|
|
126
84
|
* Find the client file
|
|
127
85
|
*/
|
|
128
|
-
export function findClientFile() {
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
'src/client.ts',
|
|
136
|
-
])];
|
|
137
|
-
});
|
|
138
|
-
});
|
|
86
|
+
export async function findClientFile() {
|
|
87
|
+
return findFile([
|
|
88
|
+
'analytics/client.ts',
|
|
89
|
+
'src/analytics/client.ts',
|
|
90
|
+
'client.ts',
|
|
91
|
+
'src/client.ts',
|
|
92
|
+
]);
|
|
139
93
|
}
|
|
140
94
|
/**
|
|
141
95
|
* Check if .env file exists
|
|
142
96
|
*/
|
|
143
|
-
export function hasEnvFile() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
});
|
|
97
|
+
export async function hasEnvFile() {
|
|
98
|
+
try {
|
|
99
|
+
await access(path.join(process.cwd(), '.env'));
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
161
105
|
}
|
|
162
106
|
/**
|
|
163
107
|
* Check if .gitignore exists
|
|
164
108
|
*/
|
|
165
|
-
export function hasGitignore() {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
});
|
|
109
|
+
export async function hasGitignore() {
|
|
110
|
+
try {
|
|
111
|
+
await access(path.join(process.cwd(), '.gitignore'));
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
183
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-api.d.ts","sourceRoot":"","sources":["../../src/utils/load-api.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"load-api.d.ts","sourceRoot":"","sources":["../../src/utils/load-api.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,gBA2DrD;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,gBAkClD"}
|