@dataramen/cli 0.0.10 → 0.0.12
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/bin/run.js +2 -169
- package/dist/code/cli.js +2 -169
- package/dist/code/proxy.js +6 -6
- package/dist/package.json +1 -1
- package/package.json +7 -2
- package/dist/code/api/chat/router.js +0 -55
- package/dist/code/api/dataSources/router.js +0 -147
- package/dist/code/api/dataSources/types.js +0 -2
- package/dist/code/api/dataSources/validators.js +0 -22
- package/dist/code/api/project/router.js +0 -100
- package/dist/code/api/queries/router.js +0 -122
- package/dist/code/api/runner/router.js +0 -22
- package/dist/code/api/status/router.js +0 -17
- package/dist/code/api/teams/router.js +0 -35
- package/dist/code/api/userSettings/router.js +0 -54
- package/dist/code/api/users/router.js +0 -91
- package/dist/code/api/workbooks/router.js +0 -123
- package/dist/code/api/workbooks/types.js +0 -2
- package/dist/code/env.js +0 -25
- package/dist/code/index.js +0 -86
- package/dist/code/repository/db.js +0 -58
- package/dist/code/repository/tables/databaseInspection.js +0 -40
- package/dist/code/repository/tables/datasource.js +0 -86
- package/dist/code/repository/tables/query.js +0 -50
- package/dist/code/repository/tables/teams.js +0 -48
- package/dist/code/repository/tables/userSettings.js +0 -39
- package/dist/code/repository/tables/users.js +0 -42
- package/dist/code/repository/tables/workbook.js +0 -43
- package/dist/code/services/connectorManager/index.js +0 -38
- package/dist/code/services/connectorManager/types.js +0 -2
- package/dist/code/services/files/index.js +0 -44
- package/dist/code/services/mysqlConnector/index.js +0 -180
- package/dist/code/services/oauthClient/oauth2Client.js +0 -10
- package/dist/code/services/openai/index.js +0 -20
- package/dist/code/services/openai/types.js +0 -2
- package/dist/code/services/pgConnector/index.js +0 -220
- package/dist/code/services/userSqlPromptRunner/index.js +0 -207
- package/dist/code/types/connectors.js +0 -2
- package/dist/code/utils/createRouter.js +0 -10
- package/dist/code/utils/httpError.js +0 -13
- package/dist/code/utils/prompts.js +0 -11
- package/dist/code/utils/queryUtils.js +0 -18
- package/dist/code/utils/rawSql.js +0 -32
- package/dist/code/utils/request.js +0 -35
- package/dist/code/utils/token.js +0 -8
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpError = void 0;
|
|
4
|
-
class HttpError extends Error {
|
|
5
|
-
status;
|
|
6
|
-
message;
|
|
7
|
-
constructor(status, message) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.status = status;
|
|
10
|
-
this.message = message;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.HttpError = HttpError;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildDbString = void 0;
|
|
4
|
-
const buildDbString = (dbInspection) => {
|
|
5
|
-
return dbInspection.map((inspection) => {
|
|
6
|
-
// todo: FK
|
|
7
|
-
const columns = inspection.columns?.map((column) => `${column.name}: ${column.type}`).join(", ");
|
|
8
|
-
return `${inspection.tableName}: (${columns})`;
|
|
9
|
-
}).join("\n");
|
|
10
|
-
};
|
|
11
|
-
exports.buildDbString = buildDbString;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseOrderQueryParam = parseOrderQueryParam;
|
|
4
|
-
function parseOrderQueryParam(orderBy, defaultOrder = undefined) {
|
|
5
|
-
try {
|
|
6
|
-
if (orderBy) {
|
|
7
|
-
const parts = orderBy.split("&");
|
|
8
|
-
const order = {};
|
|
9
|
-
for (const part of parts) {
|
|
10
|
-
const split = part.split(":");
|
|
11
|
-
order[split[0]] = split[1];
|
|
12
|
-
}
|
|
13
|
-
return order;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
catch (e) { }
|
|
17
|
-
return defaultOrder;
|
|
18
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyRawPagination = applyRawPagination;
|
|
4
|
-
exports.replaceSqlVariables = replaceSqlVariables;
|
|
5
|
-
exports.detectQueryType = detectQueryType;
|
|
6
|
-
const httpError_1 = require("./httpError");
|
|
7
|
-
function applyRawPagination(sql, limit, offset) {
|
|
8
|
-
const sqlWithoutSemicolon = sql.replace(/;\s*$/, '');
|
|
9
|
-
return `${sqlWithoutSemicolon.trim()} LIMIT ${limit} OFFSET ${offset}`;
|
|
10
|
-
}
|
|
11
|
-
function replaceSqlVariables(sql, values) {
|
|
12
|
-
return sql.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, (match, key) => {
|
|
13
|
-
if (!(key in values)) {
|
|
14
|
-
throw new Error(`Missing value for SQL variable: ${key}`);
|
|
15
|
-
}
|
|
16
|
-
return String(values[key]); // Raw replacement (no escaping/quoting)
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
// todo: improve
|
|
20
|
-
function detectQueryType(sql) {
|
|
21
|
-
// Remove leading whitespace and comments
|
|
22
|
-
const cleanedSql = sql
|
|
23
|
-
.replace(/--.*$/gm, '') // Remove single-line comments
|
|
24
|
-
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove block comments
|
|
25
|
-
.trim();
|
|
26
|
-
// Match the first keyword after any optional opening parentheses (e.g., CTEs)
|
|
27
|
-
const match = cleanedSql.match(/^\s*(\(?\s*)*([a-zA-Z]+)/);
|
|
28
|
-
if (!match) {
|
|
29
|
-
throw new httpError_1.HttpError(400, "Failed to detect query type");
|
|
30
|
-
}
|
|
31
|
-
return match[2].toUpperCase();
|
|
32
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRequestUserId = exports.getRequestUserToken = exports.getRequestParams = exports.getRequestQuery = exports.getRequestPayload = void 0;
|
|
4
|
-
const getRequestPayload = (request, validator) => {
|
|
5
|
-
const payload = request.body;
|
|
6
|
-
if (validator) {
|
|
7
|
-
validator(payload);
|
|
8
|
-
}
|
|
9
|
-
return payload;
|
|
10
|
-
};
|
|
11
|
-
exports.getRequestPayload = getRequestPayload;
|
|
12
|
-
const getRequestQuery = (request, validator) => {
|
|
13
|
-
const query = request.query;
|
|
14
|
-
if (validator) {
|
|
15
|
-
validator(query);
|
|
16
|
-
}
|
|
17
|
-
return query;
|
|
18
|
-
};
|
|
19
|
-
exports.getRequestQuery = getRequestQuery;
|
|
20
|
-
const getRequestParams = (request, validator) => {
|
|
21
|
-
const params = request.params;
|
|
22
|
-
if (validator) {
|
|
23
|
-
validator(params);
|
|
24
|
-
}
|
|
25
|
-
return params;
|
|
26
|
-
};
|
|
27
|
-
exports.getRequestParams = getRequestParams;
|
|
28
|
-
const getRequestUserToken = (request) => {
|
|
29
|
-
return request.headers["phoenix-user-token"];
|
|
30
|
-
};
|
|
31
|
-
exports.getRequestUserToken = getRequestUserToken;
|
|
32
|
-
const getRequestUserId = (request) => {
|
|
33
|
-
return request.headers["phoenix-user-id"];
|
|
34
|
-
};
|
|
35
|
-
exports.getRequestUserId = getRequestUserId;
|
package/dist/code/utils/token.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeOpenAIToken = void 0;
|
|
4
|
-
const PLACEHOLDER = "********************************************";
|
|
5
|
-
const sanitizeOpenAIToken = (token) => {
|
|
6
|
-
return token.slice(0, 4) + PLACEHOLDER + token.slice(token.length - 4);
|
|
7
|
-
};
|
|
8
|
-
exports.sanitizeOpenAIToken = sanitizeOpenAIToken;
|