@tradejs/infra 1.0.4 → 1.0.6
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 +1 -1
- package/dist/ai.d.mts +36 -0
- package/dist/ai.d.ts +36 -0
- package/dist/ai.js +456 -0
- package/dist/ai.mjs +386 -0
- package/dist/chunk-EFARW5QE.mjs +297 -0
- package/dist/chunk-KVEZORMS.mjs +142 -0
- package/dist/ml.d.mts +2 -20
- package/dist/ml.d.ts +2 -20
- package/dist/ml.js +17 -0
- package/dist/ml.mjs +20 -124
- package/dist/mlDatasetFile-sRGWgR_o.d.mts +24 -0
- package/dist/mlDatasetFile-sRGWgR_o.d.ts +24 -0
- package/dist/redis.mjs +9 -287
- package/dist/userSettings.d.mts +29 -0
- package/dist/userSettings.d.ts +29 -0
- package/dist/userSettings.js +304 -0
- package/dist/userSettings.mjs +48 -0
- package/package.json +21 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getData,
|
|
3
|
+
redisKeys,
|
|
4
|
+
setData
|
|
5
|
+
} from "./chunk-EFARW5QE.mjs";
|
|
6
|
+
|
|
7
|
+
// src/userSettings.ts
|
|
8
|
+
var readString = (value) => typeof value === "string" ? value.trim() : "";
|
|
9
|
+
var readUserString = (record, key) => readString(record?.[key]);
|
|
10
|
+
var getUserRecord = async (userName) => {
|
|
11
|
+
const user = await getData(redisKeys.user(userName), null);
|
|
12
|
+
if (!user || typeof user !== "object") {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return user;
|
|
16
|
+
};
|
|
17
|
+
var getUserSettings = async (userName) => {
|
|
18
|
+
const record = await getUserRecord(userName);
|
|
19
|
+
return {
|
|
20
|
+
userName,
|
|
21
|
+
BYBIT_API_KEY: readUserString(record, "BYBIT_API_KEY"),
|
|
22
|
+
BYBIT_API_SECRET: readUserString(record, "BYBIT_API_SECRET"),
|
|
23
|
+
token: readUserString(record, "token"),
|
|
24
|
+
COINALYZE_API_KEY: readUserString(record, "COINALYZE_API_KEY"),
|
|
25
|
+
OPENAI_API_KEY: readUserString(record, "OPENAI_API_KEY"),
|
|
26
|
+
OPENAI_API_ENDPOINT: readUserString(record, "OPENAI_API_ENDPOINT"),
|
|
27
|
+
TG_BOT_TOKEN: readUserString(record, "TG_BOT_TOKEN"),
|
|
28
|
+
TG_CHAT_ID: readUserString(record, "TG_CHAT_ID")
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var updateUserRecord = async (userName, patch) => {
|
|
32
|
+
const existing = await getUserRecord(userName) ?? {};
|
|
33
|
+
const next = {
|
|
34
|
+
...existing,
|
|
35
|
+
...patch,
|
|
36
|
+
userName,
|
|
37
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
38
|
+
};
|
|
39
|
+
await setData(redisKeys.user(userName), next, {
|
|
40
|
+
expire: 0
|
|
41
|
+
});
|
|
42
|
+
return next;
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
getUserRecord,
|
|
46
|
+
getUserSettings,
|
|
47
|
+
updateUserRecord
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/infra",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Server-only infrastructure adapters for Redis, Timescale, ML, logging, and IO.",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Server-only infrastructure adapters for the TradeJS open-source framework: Redis, Timescale, ML, logging, and IO.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tradejs",
|
|
7
7
|
"trading",
|
|
@@ -11,11 +11,24 @@
|
|
|
11
11
|
"timescale",
|
|
12
12
|
"ml"
|
|
13
13
|
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/tradejs-dev/tradejs.git",
|
|
17
|
+
"directory": "packages/infra"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/tradejs-dev/tradejs/issues"
|
|
21
|
+
},
|
|
14
22
|
"files": [
|
|
15
23
|
"dist",
|
|
16
24
|
"proto"
|
|
17
25
|
],
|
|
18
26
|
"exports": {
|
|
27
|
+
"./ai": {
|
|
28
|
+
"types": "./dist/ai.d.ts",
|
|
29
|
+
"import": "./dist/ai.mjs",
|
|
30
|
+
"require": "./dist/ai.js"
|
|
31
|
+
},
|
|
19
32
|
"./files": {
|
|
20
33
|
"types": "./dist/files.d.ts",
|
|
21
34
|
"import": "./dist/files.mjs",
|
|
@@ -41,6 +54,11 @@
|
|
|
41
54
|
"import": "./dist/redis.mjs",
|
|
42
55
|
"require": "./dist/redis.js"
|
|
43
56
|
},
|
|
57
|
+
"./userSettings": {
|
|
58
|
+
"types": "./dist/userSettings.d.ts",
|
|
59
|
+
"import": "./dist/userSettings.mjs",
|
|
60
|
+
"require": "./dist/userSettings.js"
|
|
61
|
+
},
|
|
44
62
|
"./timescale": {
|
|
45
63
|
"types": "./dist/timescale.d.ts",
|
|
46
64
|
"import": "./dist/timescale.mjs",
|
|
@@ -50,7 +68,7 @@
|
|
|
50
68
|
"dependencies": {
|
|
51
69
|
"@grpc/grpc-js": "^1.10.7",
|
|
52
70
|
"@grpc/proto-loader": "^0.7.13",
|
|
53
|
-
"@tradejs/types": "^1.0.
|
|
71
|
+
"@tradejs/types": "^1.0.6",
|
|
54
72
|
"chalk": "4.1.2",
|
|
55
73
|
"ioredis": "5.8.0",
|
|
56
74
|
"pg": "8.16.3",
|