wenay-common2 1.0.46 → 1.0.49
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 +51 -37
- package/lib/Common/Color.d.ts +3 -0
- package/lib/Common/Color.js +4 -0
- package/lib/Common/ObserveAll2/index.d.ts +2 -0
- package/lib/Common/ObserveAll2/index.js +18 -0
- package/lib/Common/ObserveAll2/reactive2.d.ts +33 -0
- package/lib/Common/ObserveAll2/reactive2.js +254 -0
- package/lib/Common/ObserveAll2/store.d.ts +98 -0
- package/lib/Common/ObserveAll2/store.js +381 -0
- package/lib/Common/Time.d.ts +8 -0
- package/lib/Common/Time.js +41 -14
- package/lib/Common/async/PromiseArrayListen.d.ts +3 -3
- package/lib/Common/async/PromiseArrayListen.js +10 -13
- package/lib/Common/async/createIterableObject.js +1 -1
- package/lib/Common/async/waitRun.d.ts +11 -4
- package/lib/Common/async/waitRun.js +74 -44
- package/lib/Common/core/Decorator.d.ts +3 -1
- package/lib/Common/core/Decorator.js +5 -2
- package/lib/Common/core/common.d.ts +25 -7
- package/lib/Common/core/common.js +114 -34
- package/lib/Common/data/ByteStream.d.ts +1 -1
- package/lib/Common/data/ByteStream.js +21 -8
- package/lib/Common/data/List.d.ts +5 -0
- package/lib/Common/data/List.js +13 -4
- package/lib/Common/data/ListNodeAnd.js +2 -2
- package/lib/Common/data/objectPath.d.ts +4 -0
- package/lib/Common/data/objectPath.js +8 -3
- package/lib/Common/events/Listen.d.ts +1 -55
- package/lib/Common/events/Listen.js +15 -154
- package/lib/Common/events/Listen2.d.ts +1 -0
- package/lib/Common/events/Listen2.js +17 -0
- package/lib/Common/events/Listen3.d.ts +197 -0
- package/lib/Common/events/Listen3.js +249 -0
- package/lib/Common/events/SocketBuffer.d.ts +14 -9
- package/lib/Common/events/SocketServerHook.d.ts +26 -13
- package/lib/Common/events/SocketServerHook.js +2 -1
- package/lib/Common/events/UseListenTransform.d.ts +10 -5
- package/lib/Common/events/event.d.ts +12 -0
- package/lib/Common/events/event.js +10 -6
- package/lib/Common/events/joinListens.d.ts +2 -0
- package/lib/Common/events/joinListens.js +13 -12
- package/lib/Common/funcTimeWait.d.ts +28 -0
- package/lib/Common/funcTimeWait.js +18 -1
- package/lib/Common/isProxy.d.ts +1 -0
- package/lib/Common/isProxy.js +2 -0
- package/lib/Common/node_console.d.ts +2 -0
- package/lib/Common/node_console.js +3 -76
- package/lib/Common/rcp/createRpcServerAutoWithProtocolDetection.d.ts +2 -0
- package/lib/Common/rcp/createRpcServerAutoWithProtocolDetection.js +63 -30
- package/lib/Common/rcp/listen-deep.d.ts +13 -5
- package/lib/Common/rcp/listen-socket.d.ts +21 -3
- package/lib/Common/rcp/listen-socket.js +126 -17
- package/lib/Common/rcp/oldCommonsServer.d.ts +1 -1
- package/lib/Common/rcp/oldCommonsServer.js +15 -1
- package/lib/Common/rcp/old/320/241ommonsServerMini.js +1 -0
- package/lib/Common/rcp/rpc-caps.d.ts +10 -0
- package/lib/Common/rcp/rpc-caps.js +16 -0
- package/lib/Common/rcp/rpc-client.d.ts +23 -1
- package/lib/Common/rcp/rpc-client.js +306 -25
- package/lib/Common/rcp/rpc-clientHub.d.ts +7 -1
- package/lib/Common/rcp/rpc-clientHub.js +25 -2
- package/lib/Common/rcp/rpc-index.d.ts +3 -0
- package/lib/Common/rcp/rpc-index.js +3 -0
- package/lib/Common/rcp/rpc-inproc.d.ts +17 -0
- package/lib/Common/rcp/rpc-inproc.js +30 -0
- package/lib/Common/rcp/rpc-off.d.ts +10 -0
- package/lib/Common/rcp/rpc-off.js +22 -0
- package/lib/Common/rcp/rpc-protocol.d.ts +6 -0
- package/lib/Common/rcp/rpc-protocol.js +4 -2
- package/lib/Common/rcp/rpc-server-auto.d.ts +14 -3
- package/lib/Common/rcp/rpc-server-auto.js +81 -6
- package/lib/Common/rcp/rpc-server.d.ts +17 -2
- package/lib/Common/rcp/rpc-server.js +127 -31
- package/lib/Common/rcp/rpc-shape.d.ts +17 -0
- package/lib/Common/rcp/rpc-shape.js +42 -0
- package/lib/Common/rcp/rpc-walk.js +29 -11
- package/lib/Exchange/Bars.d.ts +3 -0
- package/lib/Exchange/Bars.js +4 -1
- package/lib/Exchange/CParams.d.ts +2 -0
- package/lib/Exchange/CParams.js +21 -14
- package/lib/Exchange/MarketData.d.ts +6 -0
- package/lib/Exchange/MarketData.js +4 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/server/WebHook3.js +22 -9
- package/package.json +3 -1
|
@@ -218,5 +218,7 @@ export type SimpleParamsMutable<T> = T extends const_Date ? const_Date : Mutable
|
|
|
218
218
|
};
|
|
219
219
|
export type SimpleParams<T = IParams> = ReadonlyFull<SimpleParamsMutable<T>>;
|
|
220
220
|
export declare function GetSimpleParams<T extends ReadonlyFull<IParams>>(params: T): SimpleParamsMutable<T>;
|
|
221
|
+
export declare const toValues: typeof GetSimpleParams;
|
|
221
222
|
export declare function mergeParamValuesToInfos<TParams extends IParamsReadonly | IParams, TParams2 extends IParamsReadonly | IParams>(srcObj: TParams, valuesObj: SimpleParams<TParams2> | TParams2): TParams;
|
|
223
|
+
export declare const fromValues: typeof mergeParamValuesToInfos;
|
|
222
224
|
export {};
|
package/lib/Exchange/CParams.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CParamsReadonly = exports.CParams = void 0;
|
|
3
|
+
exports.fromValues = exports.toValues = exports.CParamsReadonly = exports.CParams = void 0;
|
|
4
4
|
exports.isParamBase = isParamBase;
|
|
5
5
|
exports.isParamGroupOrArray = isParamGroupOrArray;
|
|
6
6
|
exports.isParamGroup = isParamGroup;
|
|
@@ -11,12 +11,11 @@ exports.enableAllParams = enableAllParams;
|
|
|
11
11
|
exports.GetSimpleParams = GetSimpleParams;
|
|
12
12
|
exports.mergeParamValuesToInfos = mergeParamValuesToInfos;
|
|
13
13
|
const common_1 = require("../Common/core/common");
|
|
14
|
-
{
|
|
14
|
+
function _typeCheck_DateTimeStr() {
|
|
15
15
|
let ts = "2025-06-01 16:25:25";
|
|
16
|
+
return ts;
|
|
16
17
|
}
|
|
17
|
-
{
|
|
18
|
-
let x = { value: 5, range: [5, 6] };
|
|
19
|
-
}
|
|
18
|
+
function _typeCheck_IParamEnum2() { let x = { value: 5, range: [5, 6] }; return x; }
|
|
20
19
|
let dd;
|
|
21
20
|
function isParamBase(param) {
|
|
22
21
|
return typeof param == "object" && !Array.isArray(param) && !(param instanceof Date);
|
|
@@ -89,11 +88,14 @@ function enableAllParams(params, enabled = true) {
|
|
|
89
88
|
}
|
|
90
89
|
return paramsInfoClone;
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
function _typeCheck_CParamsReadonly() {
|
|
92
|
+
class C extends CParams {
|
|
93
|
+
lastBar = { name: "Last_Bar", value: 0, range: { defaultMin: -10000, max: 0, step: 1 } };
|
|
94
|
+
}
|
|
95
|
+
let xxx = {};
|
|
96
|
+
let bbb = xxx;
|
|
97
|
+
return bbb;
|
|
94
98
|
}
|
|
95
|
-
let xxx = {};
|
|
96
|
-
let bbb = xxx;
|
|
97
99
|
const param = {
|
|
98
100
|
p0: { name: "MA0", value: [10, 20], range: [10, 20, 30] },
|
|
99
101
|
p1: { name: "MA1", commentary: ["fgf"], value: 20, range: { min: 10, max: 20, step: 2 } },
|
|
@@ -178,11 +180,15 @@ function GetSimpleParams(params) {
|
|
|
178
180
|
}
|
|
179
181
|
return simpleParams;
|
|
180
182
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
let
|
|
184
|
-
let
|
|
185
|
-
let
|
|
183
|
+
exports.toValues = GetSimpleParams;
|
|
184
|
+
function _typeCheck_GetSimpleParams() {
|
|
185
|
+
let p = GetSimpleParams(new Test());
|
|
186
|
+
let p0 = p.p1;
|
|
187
|
+
let p3 = p.p3;
|
|
188
|
+
let p4 = p.p4;
|
|
189
|
+
let p5 = p.p5?.p1;
|
|
190
|
+
return [p0, p3, p4, p5];
|
|
191
|
+
}
|
|
186
192
|
function convert_(valuesObj, srcObj) {
|
|
187
193
|
let resObj = {};
|
|
188
194
|
if (srcObj instanceof Array)
|
|
@@ -232,6 +238,7 @@ function convert_(valuesObj, srcObj) {
|
|
|
232
238
|
function mergeParamValuesToInfos(srcObj, valuesObj) {
|
|
233
239
|
return convert_(isSimpleParams(valuesObj) ? valuesObj : GetSimpleParams(valuesObj), srcObj);
|
|
234
240
|
}
|
|
241
|
+
exports.fromValues = mergeParamValuesToInfos;
|
|
235
242
|
function test() {
|
|
236
243
|
{
|
|
237
244
|
const p = new Test();
|
|
@@ -45,6 +45,7 @@ export declare class CQuotesHistory {
|
|
|
45
45
|
private _Bars;
|
|
46
46
|
protected _GetBars(tf: TF): IBars | null;
|
|
47
47
|
Bars(tf: TF): IBarsImmutable | null;
|
|
48
|
+
get(tf: TF): IBarsImmutable | null;
|
|
48
49
|
}
|
|
49
50
|
export declare class CQuotesHistoryMutable extends CQuotesHistory {
|
|
50
51
|
private _endTickTime?;
|
|
@@ -52,12 +53,17 @@ export declare class CQuotesHistoryMutable extends CQuotesHistory {
|
|
|
52
53
|
constructor(name?: string);
|
|
53
54
|
AddEndBars(bars: IBars): boolean;
|
|
54
55
|
AddEndBars(bars: readonly CBar[] | CBar, tf: TF): boolean;
|
|
56
|
+
append(bars: IBars): boolean;
|
|
57
|
+
append(bars: readonly CBar[] | CBar, tf: TF): boolean;
|
|
55
58
|
AddStartBars(bars: IBars): boolean;
|
|
56
59
|
AddStartBars(bars: readonly CBar[] | CBar, tf: TF): boolean;
|
|
60
|
+
prepend(bars: IBars): boolean;
|
|
61
|
+
prepend(bars: readonly CBar[] | CBar, tf: TF): boolean;
|
|
57
62
|
private checkBars;
|
|
58
63
|
protected _AddBarsExt(Bars: readonly CBar[] | CBar | IBars, tf: TF | undefined, toEnd: boolean): boolean;
|
|
59
64
|
AddTicks(ticks: readonly ITick[]): boolean;
|
|
60
65
|
AddTick(tick: ITick): boolean;
|
|
66
|
+
addTicks(ticks: readonly ITick[]): boolean;
|
|
61
67
|
private getOrSetMutableBars;
|
|
62
68
|
AddNewTicks(ticks: readonly ITick[]): void;
|
|
63
69
|
AddNewTick(tick: ITick): void;
|
|
@@ -189,6 +189,7 @@ class CQuotesHistory {
|
|
|
189
189
|
bars.Mutable = false;
|
|
190
190
|
return bars;
|
|
191
191
|
}
|
|
192
|
+
get(tf) { return this.Bars(tf); }
|
|
192
193
|
}
|
|
193
194
|
exports.CQuotesHistory = CQuotesHistory;
|
|
194
195
|
class CQuotesHistoryMutable extends CQuotesHistory {
|
|
@@ -198,7 +199,9 @@ class CQuotesHistoryMutable extends CQuotesHistory {
|
|
|
198
199
|
super([], name);
|
|
199
200
|
}
|
|
200
201
|
AddEndBars(bars, tf) { return this._AddBarsExt(bars, tf, true); }
|
|
202
|
+
append(bars, tf) { return this._AddBarsExt(bars, tf, true); }
|
|
201
203
|
AddStartBars(bars, tf) { return this._AddBarsExt(bars, tf, false); }
|
|
204
|
+
prepend(bars, tf) { return this._AddBarsExt(bars, tf, false); }
|
|
202
205
|
checkBars(bars, tf) {
|
|
203
206
|
let period = new Bars_1.Period(tf);
|
|
204
207
|
for (let i = 1; i < bars.length; i++)
|
|
@@ -265,6 +268,7 @@ class CQuotesHistoryMutable extends CQuotesHistory {
|
|
|
265
268
|
return this.AddEndBars(newbars);
|
|
266
269
|
}
|
|
267
270
|
AddTick(tick) { return this.AddTicks([tick]); }
|
|
271
|
+
addTicks(ticks) { return this.AddTicks(ticks); }
|
|
268
272
|
getOrSetMutableBars(tf) {
|
|
269
273
|
let bars = this._GetBars(tf) ?? new CBarsInternal(tf);
|
|
270
274
|
let mutableBars;
|
package/lib/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./Common/data/List";
|
|
|
12
12
|
export * from "./Common/data/ListNodeAnd";
|
|
13
13
|
export * from "./Common/data/objectPath";
|
|
14
14
|
export * from "./Common/events/Listen";
|
|
15
|
+
export * as ListenNext from "./Common/events/Listen2";
|
|
15
16
|
export * from "./Common/events/event";
|
|
16
17
|
export * from "./Common/events/SocketBuffer";
|
|
17
18
|
export * from "./Common/events/SocketServerHook";
|
|
@@ -31,3 +32,4 @@ export * as Bars from "./Exchange/Bars";
|
|
|
31
32
|
export * as Params from "./Exchange/CParams";
|
|
32
33
|
export * as Time from "./Common/Time";
|
|
33
34
|
export * as Color from "./Common/Color";
|
|
35
|
+
export * as ObserveAll2 from "./Common/ObserveAll2";
|
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Color = exports.Time = exports.Params = exports.Bars = exports.Math = void 0;
|
|
39
|
+
exports.ObserveAll2 = exports.Color = exports.Time = exports.Params = exports.Bars = exports.Math = exports.ListenNext = void 0;
|
|
40
40
|
__exportStar(require("./Common/node_console"), exports);
|
|
41
41
|
__exportStar(require("./Common/core/Decorator"), exports);
|
|
42
42
|
__exportStar(require("./Common/core/BaseTypes"), exports);
|
|
@@ -51,6 +51,7 @@ __exportStar(require("./Common/data/List"), exports);
|
|
|
51
51
|
__exportStar(require("./Common/data/ListNodeAnd"), exports);
|
|
52
52
|
__exportStar(require("./Common/data/objectPath"), exports);
|
|
53
53
|
__exportStar(require("./Common/events/Listen"), exports);
|
|
54
|
+
exports.ListenNext = __importStar(require("./Common/events/Listen2"));
|
|
54
55
|
__exportStar(require("./Common/events/event"), exports);
|
|
55
56
|
__exportStar(require("./Common/events/SocketBuffer"), exports);
|
|
56
57
|
__exportStar(require("./Common/events/SocketServerHook"), exports);
|
|
@@ -70,3 +71,4 @@ exports.Bars = __importStar(require("./Exchange/Bars"));
|
|
|
70
71
|
exports.Params = __importStar(require("./Exchange/CParams"));
|
|
71
72
|
exports.Time = __importStar(require("./Common/Time"));
|
|
72
73
|
exports.Color = __importStar(require("./Common/Color"));
|
|
74
|
+
exports.ObserveAll2 = __importStar(require("./Common/ObserveAll2"));
|
package/lib/server/WebHook3.js
CHANGED
|
@@ -56,9 +56,14 @@ const loadSubscribers = () => {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
const Queue = (0, waitRun_1.createAsyncQueue)(1);
|
|
59
|
+
let _tmpSeq = 0;
|
|
59
60
|
const saveSubscribers = (subs) => {
|
|
60
61
|
const obj = Object.fromEntries([...subs].map(([k, s]) => [k, { url: s.url, tag: s.tag, expireAt: s.expireAt }]));
|
|
61
|
-
Queue.enqueue(() =>
|
|
62
|
+
Queue.enqueue(async () => {
|
|
63
|
+
const tmp = `${SUBSCRIBERS_FILE}.${++_tmpSeq}.tmp`;
|
|
64
|
+
await fs.promises.writeFile(tmp, JSON.stringify(obj, null, 2), 'utf-8');
|
|
65
|
+
await fs.promises.rename(tmp, SUBSCRIBERS_FILE);
|
|
66
|
+
});
|
|
62
67
|
};
|
|
63
68
|
const normalizeIP = (ip) => ip?.startsWith('::ffff:') ? ip.slice(7) : ip;
|
|
64
69
|
const buildSelfWebhookUrl = (clientIp, raw) => {
|
|
@@ -175,6 +180,8 @@ const createWebhookClient = (options) => {
|
|
|
175
180
|
app.use(express_1.default.json());
|
|
176
181
|
const activeTags = new Set();
|
|
177
182
|
const timers = new Map();
|
|
183
|
+
const handlers = new Map();
|
|
184
|
+
const registeredPaths = new Set();
|
|
178
185
|
const headers = { authorization: authToken };
|
|
179
186
|
const makeUrl = (tag) => `:${clientPort}/webHook_${tag}`;
|
|
180
187
|
const connect = async (tag, handler) => {
|
|
@@ -183,7 +190,19 @@ const createWebhookClient = (options) => {
|
|
|
183
190
|
return;
|
|
184
191
|
}
|
|
185
192
|
const path = `/webHook_${tag}`;
|
|
186
|
-
|
|
193
|
+
handlers.set(tag, handler);
|
|
194
|
+
if (!registeredPaths.has(path)) {
|
|
195
|
+
registeredPaths.add(path);
|
|
196
|
+
app.post(path, (req, res) => {
|
|
197
|
+
const h = handlers.get(tag);
|
|
198
|
+
if (!h) {
|
|
199
|
+
res.status(404).end();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
h(req.body);
|
|
203
|
+
res.end();
|
|
204
|
+
});
|
|
205
|
+
}
|
|
187
206
|
await axios_1.default.post(`${serverUrl}/webHook_subscribe`, { url: makeUrl(tag), tag }, { headers });
|
|
188
207
|
activeTags.add(tag);
|
|
189
208
|
if (autoRenew) {
|
|
@@ -203,13 +222,7 @@ const createWebhookClient = (options) => {
|
|
|
203
222
|
clearInterval(t);
|
|
204
223
|
timers.delete(tag);
|
|
205
224
|
}
|
|
206
|
-
|
|
207
|
-
if (stack) {
|
|
208
|
-
const path = `/webHook_${tag}`;
|
|
209
|
-
const idx = stack.findIndex((layer) => layer.route?.path === path);
|
|
210
|
-
if (idx !== -1)
|
|
211
|
-
stack.splice(idx, 1);
|
|
212
|
-
}
|
|
225
|
+
handlers.delete(tag);
|
|
213
226
|
}));
|
|
214
227
|
};
|
|
215
228
|
const getMySubscriptions = async () => (await axios_1.default.get(`${serverUrl}/webHook_client_subscriptions`, { headers })).data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wenay-common2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "Common library",
|
|
5
5
|
"strict": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": "./lib/index.js",
|
|
26
|
+
"./observe-all2": "./lib/Common/ObserveAll2/index.js",
|
|
27
|
+
"./listen2": "./lib/Common/events/Listen2.js",
|
|
26
28
|
"./lib/client": "./lib/client.js",
|
|
27
29
|
"./lib/server": "./lib/server.js",
|
|
28
30
|
"./client": "./lib/client.js",
|