@quantform/core 0.7.21 → 0.7.24
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/lib/app.d.ts +12 -0
- package/lib/app.d.ts.map +1 -0
- package/lib/app.js +35 -0
- package/lib/cli/build.d.ts.map +1 -1
- package/lib/cli/build.js +8 -18
- package/lib/cli/index.js +3 -12
- package/lib/cli/internal/script.d.ts +1 -1
- package/lib/cli/internal/script.d.ts.map +1 -1
- package/lib/cli/internal/script.js +8 -28
- package/lib/cli/live.js +10 -22
- package/lib/cli/paper.js +10 -22
- package/lib/cli/replay.d.ts.map +1 -1
- package/lib/cli/replay.js +15 -26
- package/lib/index.d.ts +1 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -6
- package/lib/make-test-module.d.ts.map +1 -1
- package/lib/make-test-module.js +18 -20
- package/lib/module.d.ts.map +1 -1
- package/lib/module.js +9 -24
- package/lib/module.spec.js +8 -17
- package/lib/replay/use-replay-options.d.ts +5 -4
- package/lib/replay/use-replay-options.d.ts.map +1 -1
- package/lib/replay/use-replay-options.js +5 -1
- package/lib/replay/use-replay-scheduler.d.ts +7 -6
- package/lib/replay/use-replay-scheduler.d.ts.map +1 -1
- package/lib/replay/use-replay-scheduler.js +64 -70
- package/lib/replay/use-replay-storage-buffer.d.ts +3 -2
- package/lib/replay/use-replay-storage-buffer.d.ts.map +1 -1
- package/lib/replay/use-replay-storage-buffer.js +12 -23
- package/lib/replay/use-replay-storage-cursor.d.ts +9 -8
- package/lib/replay/use-replay-storage-cursor.d.ts.map +1 -1
- package/lib/replay/use-replay-storage-cursor.js +17 -25
- package/lib/replay/use-replay-storage.d.ts +5 -4
- package/lib/replay/use-replay-storage.d.ts.map +1 -1
- package/lib/replay/use-replay-storage.js +32 -39
- package/lib/session/use-session-storage.d.ts +1 -1
- package/lib/session/use-session-storage.d.ts.map +1 -1
- package/lib/session/use-session-storage.js +8 -5
- package/lib/shared/environment.js +1 -1
- package/lib/shared/index.d.ts +0 -1
- package/lib/shared/index.d.ts.map +1 -1
- package/lib/shared/index.js +0 -1
- package/lib/simulator/use-simulator.spec.js +17 -30
- package/lib/storage/in-memory/in-memory-storage.d.ts.map +1 -1
- package/lib/storage/in-memory/in-memory-storage.factory.js +2 -2
- package/lib/storage/in-memory/in-memory-storage.js +56 -55
- package/lib/storage/in-memory/in-memory-storage.spec.js +90 -100
- package/lib/storage/storage.d.ts +9 -8
- package/lib/storage/storage.d.ts.map +1 -1
- package/lib/storage/storage.js +8 -2
- package/lib/storage/use-cache.d.ts +1 -1
- package/lib/storage/use-cache.d.ts.map +1 -1
- package/lib/storage/use-cache.js +5 -5
- package/lib/storage/use-cache.spec.js +14 -25
- package/lib/storage/use-storage.d.ts +1 -1
- package/lib/storage/use-storage.d.ts.map +1 -1
- package/lib/storage/use-storage.js +9 -6
- package/lib/use-execution-mode.js +2 -2
- package/lib/use-hash.spec.js +3 -6
- package/lib/use-logger.d.ts +1 -1
- package/lib/use-logger.d.ts.map +1 -1
- package/lib/use-logger.js +10 -7
- package/lib/use-memo.spec.js +14 -25
- package/lib/use-socket.d.ts +3 -2
- package/lib/use-socket.d.ts.map +1 -1
- package/lib/use-socket.js +2 -2
- package/lib/use-timestamp.d.ts +14 -1
- package/lib/use-timestamp.d.ts.map +1 -1
- package/lib/use-timestamp.js +30 -3
- package/lib/with-request.d.ts +2 -1
- package/lib/with-request.d.ts.map +1 -1
- package/lib/with-request.js +4 -13
- package/package.json +6 -10
- package/src/app.ts +52 -0
- package/src/cli/build.ts +11 -6
- package/src/cli/internal/script.ts +25 -54
- package/src/cli/replay.ts +13 -2
- package/src/index.ts +1 -6
- package/src/make-test-module.ts +12 -2
- package/src/module.ts +0 -3
- package/src/replay/use-replay-options.ts +7 -3
- package/src/replay/use-replay-scheduler.ts +75 -67
- package/src/replay/use-replay-storage-buffer.ts +2 -1
- package/src/replay/use-replay-storage-cursor.ts +33 -28
- package/src/replay/use-replay-storage.ts +36 -27
- package/src/session/use-session-storage.ts +7 -5
- package/src/shared/index.ts +0 -1
- package/src/storage/in-memory/in-memory-storage.spec.ts +55 -54
- package/src/storage/in-memory/in-memory-storage.ts +24 -7
- package/src/storage/storage.ts +16 -7
- package/src/storage/use-cache.ts +4 -4
- package/src/storage/use-storage.ts +8 -6
- package/src/use-hash.spec.ts +3 -6
- package/src/use-logger.ts +9 -6
- package/src/use-socket.ts +5 -5
- package/src/use-timestamp.ts +41 -3
- package/src/with-request.ts +3 -3
- package/lib/asset/asset.d.ts +0 -41
- package/lib/asset/asset.d.ts.map +0 -1
- package/lib/asset/asset.js +0 -76
- package/lib/asset/asset.spec.d.ts +0 -2
- package/lib/asset/asset.spec.d.ts.map +0 -1
- package/lib/asset/asset.spec.js +0 -54
- package/lib/asset/index.d.ts +0 -2
- package/lib/asset/index.d.ts.map +0 -1
- package/lib/asset/index.js +0 -17
- package/lib/component/distinct-until-timesamp-changed.d.ts +0 -5
- package/lib/component/distinct-until-timesamp-changed.d.ts.map +0 -1
- package/lib/component/distinct-until-timesamp-changed.js +0 -9
- package/lib/component/error.d.ts +0 -17
- package/lib/component/error.d.ts.map +0 -1
- package/lib/component/error.js +0 -33
- package/lib/component/index.d.ts +0 -8
- package/lib/component/index.d.ts.map +0 -1
- package/lib/component/index.js +0 -23
- package/lib/component/ohlc-operator.d.ts +0 -11
- package/lib/component/ohlc-operator.d.ts.map +0 -1
- package/lib/component/ohlc-operator.js +0 -69
- package/lib/component/ohlc-operator.spec.d.ts +0 -2
- package/lib/component/ohlc-operator.spec.d.ts.map +0 -1
- package/lib/component/ohlc-operator.spec.js +0 -110
- package/lib/component/ohlc.d.ts +0 -12
- package/lib/component/ohlc.d.ts.map +0 -1
- package/lib/component/ohlc.js +0 -20
- package/lib/component/ohlc.spec.d.ts +0 -2
- package/lib/component/ohlc.spec.d.ts.map +0 -1
- package/lib/component/ohlc.spec.js +0 -25
- package/lib/component/timeframe.d.ts +0 -15
- package/lib/component/timeframe.d.ts.map +0 -1
- package/lib/component/timeframe.js +0 -21
- package/lib/core.d.ts +0 -3
- package/lib/core.d.ts.map +0 -1
- package/lib/core.js +0 -17
- package/lib/instrument/commission/commission.d.ts +0 -16
- package/lib/instrument/commission/commission.d.ts.map +0 -1
- package/lib/instrument/commission/commission.js +0 -28
- package/lib/instrument/commission/commission.spec.d.ts +0 -2
- package/lib/instrument/commission/commission.spec.d.ts.map +0 -1
- package/lib/instrument/commission/commission.spec.js +0 -30
- package/lib/instrument/index.d.ts +0 -3
- package/lib/instrument/index.d.ts.map +0 -1
- package/lib/instrument/index.js +0 -18
- package/lib/instrument/instrument.d.ts +0 -28
- package/lib/instrument/instrument.d.ts.map +0 -1
- package/lib/instrument/instrument.js +0 -53
- package/lib/instrument/instrument.spec.d.ts +0 -2
- package/lib/instrument/instrument.spec.d.ts.map +0 -1
- package/lib/instrument/instrument.spec.js +0 -51
- package/lib/operators.d.ts +0 -5
- package/lib/operators.d.ts.map +0 -1
- package/lib/operators.js +0 -16
- package/lib/shared/datetime.d.ts +0 -3
- package/lib/shared/datetime.d.ts.map +0 -1
- package/lib/shared/datetime.js +0 -7
- package/lib/strategy.d.ts +0 -15
- package/lib/strategy.d.ts.map +0 -1
- package/lib/strategy.js +0 -26
- package/lib/strategy.spec.d.ts +0 -2
- package/lib/strategy.spec.d.ts.map +0 -1
- package/lib/strategy.spec.js +0 -34
- package/lib/when-socket.d.ts +0 -8
- package/lib/when-socket.d.ts.map +0 -1
- package/lib/when-socket.js +0 -53
- package/lib/with-memo.d.ts +0 -5
- package/lib/with-memo.d.ts.map +0 -1
- package/lib/with-memo.js +0 -20
- package/lib/with-memo.spec.d.ts +0 -2
- package/lib/with-memo.spec.d.ts.map +0 -1
- package/lib/with-memo.spec.js +0 -47
- package/src/asset/asset.spec.ts +0 -70
- package/src/asset/asset.ts +0 -89
- package/src/asset/index.ts +0 -1
- package/src/component/distinct-until-timesamp-changed.ts +0 -11
- package/src/component/error.ts +0 -32
- package/src/component/index.ts +0 -7
- package/src/component/ohlc-operator.spec.ts +0 -125
- package/src/component/ohlc-operator.ts +0 -122
- package/src/component/ohlc.spec.ts +0 -30
- package/src/component/ohlc.ts +0 -18
- package/src/component/timeframe.ts +0 -17
- package/src/core.ts +0 -16
- package/src/instrument/commission/commission.spec.ts +0 -35
- package/src/instrument/commission/commission.ts +0 -27
- package/src/instrument/index.ts +0 -2
- package/src/instrument/instrument.spec.ts +0 -76
- package/src/instrument/instrument.ts +0 -65
- package/src/operators.ts +0 -18
- package/src/shared/datetime.ts +0 -5
- package/src/strategy.spec.ts +0 -42
- package/src/strategy.ts +0 -36
- package/src/when-socket.ts +0 -61
- package/src/with-memo.spec.ts +0 -46
- package/src/with-memo.ts +0 -33
package/lib/app.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Dependency } from './module';
|
|
3
|
+
export type AppStart<T> = {
|
|
4
|
+
run: (dependencies: Dependency[]) => Promise<T | undefined>;
|
|
5
|
+
};
|
|
6
|
+
export type AppHandle = {
|
|
7
|
+
use: AppUse;
|
|
8
|
+
start: <T>(strategy: () => Observable<T>) => AppStart<T | undefined>;
|
|
9
|
+
};
|
|
10
|
+
export type AppUse = (module: Dependency | Dependency[]) => AppHandle;
|
|
11
|
+
export declare function app(): AppHandle;
|
|
12
|
+
//# sourceMappingURL=app.d.ts.map
|
package/lib/app.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,UAAU,EAAE,MAAM,MAAM,CAAC;AAExE,OAAO,EAAE,UAAU,EAAU,MAAM,aAAa,CAAC;AAOjD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACxB,GAAG,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACtE,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,KAAK,SAAS,CAAC;AAEtE,wBAAgB,GAAG,IAAI,SAAS,CA+B/B"}
|
package/lib/app.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.app = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const module_1 = require("./module");
|
|
6
|
+
const storage_1 = require("./storage");
|
|
7
|
+
const use_execution_mode_1 = require("./use-execution-mode");
|
|
8
|
+
const use_logger_1 = require("./use-logger");
|
|
9
|
+
const use_memo_1 = require("./use-memo");
|
|
10
|
+
function app() {
|
|
11
|
+
const deps = [
|
|
12
|
+
use_memo_1.useMemo.options(),
|
|
13
|
+
(0, use_logger_1.logger)(new use_logger_1.ConsoleLoggerFactory()),
|
|
14
|
+
use_execution_mode_1.useExecutionMode.paperOptions({ recording: false }),
|
|
15
|
+
storage_1.useStorageFactory.options(new storage_1.InMemoryStorageFactory())
|
|
16
|
+
];
|
|
17
|
+
const start = (strategy) => ({
|
|
18
|
+
async run(dependencies = []) {
|
|
19
|
+
const module = new module_1.Module([...deps, ...dependencies]);
|
|
20
|
+
const { act } = await module.awake();
|
|
21
|
+
return await act(() => (0, rxjs_1.firstValueFrom)(strategy().pipe((0, rxjs_1.defaultIfEmpty)(undefined), (0, rxjs_1.last)())));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const use = (module) => {
|
|
25
|
+
if (Array.isArray(module)) {
|
|
26
|
+
deps.push(...module);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
deps.push(module);
|
|
30
|
+
}
|
|
31
|
+
return { use, start };
|
|
32
|
+
};
|
|
33
|
+
return { use, start };
|
|
34
|
+
}
|
|
35
|
+
exports.app = app;
|
package/lib/cli/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAIA,4BAAkC,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAIA,4BAAkC,OAAO,CAAC,MAAM,CAAC,CAehD"}
|
package/lib/cli/build.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const child_process_1 = require("child_process");
|
|
13
4
|
const workspace_1 = require("../cli/internal/workspace");
|
|
14
|
-
function default_1() {
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
process.once('exit', resolve);
|
|
22
|
-
process.once('error', reject);
|
|
5
|
+
async function default_1() {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const child = (0, child_process_1.spawn)('tsc', ['--project', 'tsconfig.json', '--outDir', (0, workspace_1.buildDirectory)()], {
|
|
8
|
+
cwd: process.cwd(),
|
|
9
|
+
stdio: 'inherit',
|
|
10
|
+
shell: true
|
|
23
11
|
});
|
|
12
|
+
child.once('exit', resolve);
|
|
13
|
+
child.once('error', reject);
|
|
24
14
|
});
|
|
25
15
|
}
|
|
26
16
|
exports.default = default_1;
|
package/lib/cli/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
5
|
};
|
|
@@ -23,9 +14,9 @@ const replay_1 = __importDefault(require("../cli/replay"));
|
|
|
23
14
|
commander_1.program
|
|
24
15
|
.command('build')
|
|
25
16
|
.description('builds a production version of the app')
|
|
26
|
-
.action(() =>
|
|
27
|
-
|
|
28
|
-
})
|
|
17
|
+
.action(async () => {
|
|
18
|
+
await (0, build_1.default)();
|
|
19
|
+
});
|
|
29
20
|
commander_1.program
|
|
30
21
|
.command('live')
|
|
31
22
|
.argument('<name>', 'strategy to execute')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/cli/internal/script.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/cli/internal/script.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,UAAU,EAAE;IAGvC,GAAG;CA0BV"}
|
|
@@ -22,44 +22,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
exports.Script = void 0;
|
|
36
27
|
const path_1 = require("path");
|
|
37
28
|
const rxjs_1 = require("rxjs");
|
|
38
|
-
const core_1 = require("../../core");
|
|
39
|
-
const module_1 = require("../../module");
|
|
40
|
-
const replay_1 = require("../../replay");
|
|
41
29
|
const workspace_1 = require("./workspace");
|
|
42
30
|
class Script {
|
|
43
31
|
constructor(filename, dependencies) {
|
|
44
32
|
this.filename = filename;
|
|
45
33
|
this.dependencies = dependencies;
|
|
46
34
|
}
|
|
47
|
-
run() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
return (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)((0, rxjs_1.forkJoin)(description.before.map(before => before()))
|
|
56
|
-
.pipe((0, rxjs_1.switchMap)(() => (0, rxjs_1.forkJoin)(description.behavior.map(behavior => behavior())).pipe((0, rxjs_1.last)())))
|
|
57
|
-
.pipe((0, rxjs_1.last)()), (0, replay_1.whenReplayFinished)().pipe((0, rxjs_1.last)()), (0, rxjs_1.fromEvent)(process, 'exit'), (0, rxjs_1.fromEvent)(process, 'SIGINT'), (0, rxjs_1.fromEvent)(process, 'SIGUSR1'), (0, rxjs_1.fromEvent)(process, 'SIGUSR2'), (0, rxjs_1.fromEvent)(process, 'uncaughtException')).pipe((0, rxjs_1.catchError)(e => {
|
|
58
|
-
console.error(e);
|
|
59
|
-
return (0, rxjs_1.of)(e);
|
|
60
|
-
}), (0, rxjs_1.take)(1), (0, rxjs_1.switchMap)(it => { var _a; return (_a = (0, rxjs_1.forkJoin)(description.after.map(after => after())).pipe((0, rxjs_1.last)())) !== null && _a !== void 0 ? _a : (0, rxjs_1.of)(it); }), (0, rxjs_1.finalize)(() => process.exit(0))));
|
|
61
|
-
});
|
|
62
|
-
});
|
|
35
|
+
async run() {
|
|
36
|
+
const script = await Promise.resolve(`${(0, path_1.join)((0, workspace_1.buildDirectory)(), this.filename)}`).then(s => __importStar(require(s)));
|
|
37
|
+
const { run } = script.default;
|
|
38
|
+
process.stdin.resume();
|
|
39
|
+
return (0, rxjs_1.firstValueFrom)((0, rxjs_1.merge)(run(this.dependencies), (0, rxjs_1.fromEvent)(process, 'exit'), (0, rxjs_1.fromEvent)(process, 'SIGINT'), (0, rxjs_1.fromEvent)(process, 'SIGUSR1'), (0, rxjs_1.fromEvent)(process, 'SIGUSR2'), (0, rxjs_1.fromEvent)(process, 'uncaughtException')).pipe((0, rxjs_1.catchError)(e => {
|
|
40
|
+
console.error(e);
|
|
41
|
+
return (0, rxjs_1.of)(e);
|
|
42
|
+
}), (0, rxjs_1.take)(1), (0, rxjs_1.finalize)(() => process.exit(0))));
|
|
63
43
|
}
|
|
64
44
|
}
|
|
65
45
|
exports.Script = Script;
|
package/lib/cli/live.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,18 +7,15 @@ const build_1 = __importDefault(require("../cli/build"));
|
|
|
16
7
|
const session_1 = require("../session");
|
|
17
8
|
const use_execution_mode_1 = require("../use-execution-mode");
|
|
18
9
|
const script_1 = require("./internal/script");
|
|
19
|
-
function default_1(name, options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const output = yield script.run();
|
|
30
|
-
console.log(output);
|
|
31
|
-
});
|
|
10
|
+
async function default_1(name, options) {
|
|
11
|
+
if (await (0, build_1.default)()) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const script = new script_1.Script(name, [
|
|
15
|
+
session_1.useSession.options({ id: options.id ?? Date.now().toString() }),
|
|
16
|
+
use_execution_mode_1.useExecutionMode.liveOptions({ recording: options.recording ?? false })
|
|
17
|
+
]);
|
|
18
|
+
const output = await script.run();
|
|
19
|
+
console.log(output);
|
|
32
20
|
}
|
|
33
21
|
exports.default = default_1;
|
package/lib/cli/paper.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,18 +7,15 @@ const build_1 = __importDefault(require("../cli/build"));
|
|
|
16
7
|
const session_1 = require("../session");
|
|
17
8
|
const use_execution_mode_1 = require("../use-execution-mode");
|
|
18
9
|
const script_1 = require("./internal/script");
|
|
19
|
-
function default_1(name, options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const output = yield script.run();
|
|
30
|
-
console.log(output);
|
|
31
|
-
});
|
|
10
|
+
async function default_1(name, options) {
|
|
11
|
+
if (await (0, build_1.default)()) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const script = new script_1.Script(name, [
|
|
15
|
+
session_1.useSession.options({ id: options.id ?? Date.now().toString() }),
|
|
16
|
+
use_execution_mode_1.useExecutionMode.paperOptions({ recording: options.recording ?? false })
|
|
17
|
+
]);
|
|
18
|
+
const output = await script.run();
|
|
19
|
+
console.log(output);
|
|
32
20
|
}
|
|
33
21
|
exports.default = default_1;
|
package/lib/cli/replay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/cli/replay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/cli/replay.ts"],"names":[],"mappings":"AAQA,yBACE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,iBA4BvE"}
|
package/lib/cli/replay.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,23 +7,21 @@ const build_1 = __importDefault(require("../cli/build"));
|
|
|
16
7
|
const replay_1 = require("../replay");
|
|
17
8
|
const session_1 = require("../session");
|
|
18
9
|
const use_execution_mode_1 = require("../use-execution-mode");
|
|
10
|
+
const use_timestamp_1 = require("../use-timestamp");
|
|
19
11
|
const script_1 = require("./internal/script");
|
|
20
|
-
function default_1(name, options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const output = yield script.run();
|
|
35
|
-
console.log(output);
|
|
36
|
-
});
|
|
12
|
+
async function default_1(name, options) {
|
|
13
|
+
if (await (0, build_1.default)()) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const from = (0, use_timestamp_1.convert)((0, use_timestamp_1.s)(options.from ? new Date(options.from).getTime() : 0), 'ms', 'ns');
|
|
17
|
+
const to = (0, use_timestamp_1.convert)((0, use_timestamp_1.s)(options.to ? new Date(options.to).getTime() : new Date().getTime()), 'ms', 'ns');
|
|
18
|
+
const storage = options.storage ?? 'backtest';
|
|
19
|
+
const script = new script_1.Script(name, [
|
|
20
|
+
session_1.useSession.options({ id: options.id ?? Date.now().toString() }),
|
|
21
|
+
(0, replay_1.replayOptions)({ from, to, storage }),
|
|
22
|
+
use_execution_mode_1.useExecutionMode.replayOptions()
|
|
23
|
+
]);
|
|
24
|
+
const output = await script.run();
|
|
25
|
+
console.log(output);
|
|
37
26
|
}
|
|
38
27
|
exports.default = default_1;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './app';
|
|
2
2
|
export * from './shared';
|
|
3
3
|
export * from './storage';
|
|
4
4
|
export * from './module';
|
|
@@ -6,18 +6,13 @@ export * from './use-memo';
|
|
|
6
6
|
export * from './use-timestamp';
|
|
7
7
|
export * from './simulator';
|
|
8
8
|
export * from './make-test-module';
|
|
9
|
-
export * from './core';
|
|
10
9
|
export * from './use-execution-mode';
|
|
11
10
|
export * from './storage';
|
|
12
11
|
export * from './use-logger';
|
|
13
12
|
export * from './replay';
|
|
14
13
|
export * from './use-socket';
|
|
15
|
-
export * from './when-socket';
|
|
16
14
|
export * from './with-request';
|
|
17
|
-
export * from './with-memo';
|
|
18
15
|
export * from './session';
|
|
19
|
-
export * from './strategy';
|
|
20
|
-
export * from './operators';
|
|
21
16
|
export * from './replay';
|
|
22
17
|
export * from './uri';
|
|
23
18
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./app"), exports);
|
|
18
18
|
__exportStar(require("./shared"), exports);
|
|
19
19
|
__exportStar(require("./storage"), exports);
|
|
20
20
|
__exportStar(require("./module"), exports);
|
|
@@ -22,17 +22,12 @@ __exportStar(require("./use-memo"), exports);
|
|
|
22
22
|
__exportStar(require("./use-timestamp"), exports);
|
|
23
23
|
__exportStar(require("./simulator"), exports);
|
|
24
24
|
__exportStar(require("./make-test-module"), exports);
|
|
25
|
-
__exportStar(require("./core"), exports);
|
|
26
25
|
__exportStar(require("./use-execution-mode"), exports);
|
|
27
26
|
__exportStar(require("./storage"), exports);
|
|
28
27
|
__exportStar(require("./use-logger"), exports);
|
|
29
28
|
__exportStar(require("./replay"), exports);
|
|
30
29
|
__exportStar(require("./use-socket"), exports);
|
|
31
|
-
__exportStar(require("./when-socket"), exports);
|
|
32
30
|
__exportStar(require("./with-request"), exports);
|
|
33
|
-
__exportStar(require("./with-memo"), exports);
|
|
34
31
|
__exportStar(require("./session"), exports);
|
|
35
|
-
__exportStar(require("./strategy"), exports);
|
|
36
|
-
__exportStar(require("./operators"), exports);
|
|
37
32
|
__exportStar(require("./replay"), exports);
|
|
38
33
|
__exportStar(require("./uri"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-test-module.d.ts","sourceRoot":"","sources":["../src/make-test-module.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"make-test-module.d.ts","sourceRoot":"","sources":["../src/make-test-module.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAU,MAAM,aAAa,CAAC;AAOjD,wBAAsB,cAAc,CAAC,YAAY,EAAE,UAAU,EAAE;;;GAe9D;AAED,KAAK,gBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEhD,eAAO,MAAM,UAAU,gFAC+B,CAAC;AAEvD,wBAAgB,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,iBAyBnD;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/E,wBAAgB,WAAW,CACzB,CAAC,SAAS,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAC9C,CAAC,SAAS,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EACpD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,qFAQrB"}
|
package/lib/make-test-module.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.mockSubject = exports.toArray = exports.mockedFunc = exports.makeTestModule = void 0;
|
|
13
4
|
const rxjs_1 = require("rxjs");
|
|
14
|
-
const core_1 = require("./core");
|
|
15
5
|
const module_1 = require("./module");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
const storage_1 = require("./storage");
|
|
7
|
+
const use_execution_mode_1 = require("./use-execution-mode");
|
|
8
|
+
const use_logger_1 = require("./use-logger");
|
|
9
|
+
const use_memo_1 = require("./use-memo");
|
|
10
|
+
async function makeTestModule(dependencies) {
|
|
11
|
+
const module = new module_1.Module([
|
|
12
|
+
use_memo_1.useMemo.options(),
|
|
13
|
+
(0, use_logger_1.logger)(new use_logger_1.ConsoleLoggerFactory()),
|
|
14
|
+
use_execution_mode_1.useExecutionMode.paperOptions({ recording: false }),
|
|
15
|
+
storage_1.useStorageFactory.options(new storage_1.InMemoryStorageFactory()),
|
|
16
|
+
...dependencies
|
|
17
|
+
]);
|
|
18
|
+
const { act } = await module.awake();
|
|
19
|
+
return {
|
|
20
|
+
act,
|
|
21
|
+
get: module.get.bind(module)
|
|
22
|
+
};
|
|
25
23
|
}
|
|
26
24
|
exports.makeTestModule = makeTestModule;
|
|
27
25
|
const mockedFunc = (mockedFunc) => mockedFunc;
|
|
@@ -36,7 +34,7 @@ function toArray(observable) {
|
|
|
36
34
|
return it.map(it => clone(it));
|
|
37
35
|
}
|
|
38
36
|
if (typeof it === 'object') {
|
|
39
|
-
return
|
|
37
|
+
return { ...it };
|
|
40
38
|
}
|
|
41
39
|
return it;
|
|
42
40
|
};
|
package/lib/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAEL,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EAEf,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,QAAQ,mBAAa,CAAC;AACnC,eAAO,MAAM,OAAO,eAAS,CAAC;AAC9B,eAAO,MAAM,UAAU,kBAAY,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAEL,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EAEf,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,QAAQ,mBAAa,CAAC;AACnC,eAAO,MAAM,OAAO,eAAS,CAAC;AAC9B,eAAO,MAAM,UAAU,kBAAY,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAoBF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,CAAC,MAAM,CAAC,QAElE;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,oCAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAI5B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAGL,OAAO,CAAC,QAAQ,CAAC,YAAY;IAFzC,OAAO,CAAC,SAAS,CAAC,CAAsB;gBAEX,YAAY,EAAE,UAAU,EAAE;IAEvD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;KAAE,CAAC;IAWxD;;;OAGG;IACH,OAAO;IAQP;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,mBAAmB;IAgB/C;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;IAYnC;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;CAWzC"}
|
package/lib/module.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.Module = exports.throwWithContext = exports.useContext = exports.setAsyncLocalStorage = exports.provideAll = exports.provide = exports.provider = void 0;
|
|
13
4
|
require("reflect-metadata");
|
|
@@ -28,9 +19,6 @@ function notInitializedModuleError() {
|
|
|
28
19
|
function missingInjectionTokenError(token) {
|
|
29
20
|
return new Error(`Unable to resolve unregistered dependency: ${token.toString()}`);
|
|
30
21
|
}
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
22
|
let moduleLocalStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
35
23
|
function setAsyncLocalStorage(als) {
|
|
36
24
|
moduleLocalStorage = als;
|
|
@@ -67,16 +55,14 @@ class Module {
|
|
|
67
55
|
/**
|
|
68
56
|
* Builds and initializes dependencies.
|
|
69
57
|
*/
|
|
70
|
-
awake() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
});
|
|
58
|
+
async awake() {
|
|
59
|
+
this.container = this.buildContainer();
|
|
60
|
+
return {
|
|
61
|
+
/**
|
|
62
|
+
* Associate callback function with current executing module
|
|
63
|
+
*/
|
|
64
|
+
act: (func) => moduleLocalStorage.run(this, func)
|
|
65
|
+
};
|
|
80
66
|
}
|
|
81
67
|
/**
|
|
82
68
|
* Disposes all dependencies instantiated by this module.
|
|
@@ -95,12 +81,11 @@ class Module {
|
|
|
95
81
|
buildContainer() {
|
|
96
82
|
const childContainer = tsyringe_1.container.createChildContainer();
|
|
97
83
|
this.dependencies.forEach(it => {
|
|
98
|
-
var _a;
|
|
99
84
|
if (it.useValue) {
|
|
100
85
|
childContainer.register(it.provide, { useValue: it.useValue });
|
|
101
86
|
}
|
|
102
87
|
else {
|
|
103
|
-
childContainer.register(it.provide,
|
|
88
|
+
childContainer.register(it.provide, it.useClass ?? it.provide, {
|
|
104
89
|
lifecycle: tsyringe_1.Lifecycle.Singleton
|
|
105
90
|
});
|
|
106
91
|
}
|
package/lib/module.spec.js
CHANGED
|
@@ -5,15 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
9
|
const module_1 = require("./module");
|
|
19
10
|
describe(module_1.Module.name, () => {
|
|
@@ -21,28 +12,28 @@ describe(module_1.Module.name, () => {
|
|
|
21
12
|
beforeEach(() => {
|
|
22
13
|
fixtures = getFixtures();
|
|
23
14
|
});
|
|
24
|
-
test('builds empty module', () =>
|
|
15
|
+
test('builds empty module', async () => {
|
|
25
16
|
const module = fixtures.givenModuleCreated([]);
|
|
26
17
|
fixtures.whenModuleBuilt(module);
|
|
27
|
-
})
|
|
28
|
-
test('builds module and resolves single value dependency', () =>
|
|
18
|
+
});
|
|
19
|
+
test('builds module and resolves single value dependency', async () => {
|
|
29
20
|
const definition = fixtures.definitions.singleValue;
|
|
30
21
|
const module = fixtures.givenModuleCreated(definition);
|
|
31
22
|
fixtures.whenModuleBuilt(module);
|
|
32
23
|
fixtures.thenCanResolveDependencies(module, definition);
|
|
33
|
-
})
|
|
34
|
-
test('builds module and resolves single class dependency', () =>
|
|
24
|
+
});
|
|
25
|
+
test('builds module and resolves single class dependency', async () => {
|
|
35
26
|
const definition = fixtures.definitions.singleClass;
|
|
36
27
|
const module = fixtures.givenModuleCreated(definition);
|
|
37
28
|
fixtures.whenModuleBuilt(module);
|
|
38
29
|
fixtures.thenCanResolveDependencies(module, definition);
|
|
39
|
-
})
|
|
40
|
-
test('builds module and resolves many class dependencies', () =>
|
|
30
|
+
});
|
|
31
|
+
test('builds module and resolves many class dependencies', async () => {
|
|
41
32
|
const definition = fixtures.definitions.manyClass;
|
|
42
33
|
const module = fixtures.givenModuleCreated(definition);
|
|
43
34
|
fixtures.whenModuleBuilt(module);
|
|
44
35
|
fixtures.thenCanResolveDependencies(module, definition);
|
|
45
|
-
})
|
|
36
|
+
});
|
|
46
37
|
});
|
|
47
38
|
function getFixtures() {
|
|
48
39
|
return {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Dependency } from '../module';
|
|
2
|
+
import { Timestamp } from '../use-timestamp';
|
|
2
3
|
type ReplayOptions = {
|
|
3
|
-
from:
|
|
4
|
-
to:
|
|
4
|
+
from: Timestamp<'ns'>;
|
|
5
|
+
to: Timestamp<'ns'>;
|
|
5
6
|
limit?: number;
|
|
6
7
|
storage?: string;
|
|
7
8
|
};
|
|
@@ -9,8 +10,8 @@ type ReplayOptions = {
|
|
|
9
10
|
*
|
|
10
11
|
*/
|
|
11
12
|
export declare function replayOptions(options: Omit<ReplayOptions, 'from' | 'to'> & {
|
|
12
|
-
from:
|
|
13
|
-
to:
|
|
13
|
+
from: Timestamp<'ns'>;
|
|
14
|
+
to: Timestamp<'ns'>;
|
|
14
15
|
}): Dependency;
|
|
15
16
|
/**
|
|
16
17
|
* Will return current replay execution options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-replay-options.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"use-replay-options.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG;IAC5C,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CACrB,GACA,UAAU,CASZ;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,qBAAkD,CAAC"}
|
|
@@ -9,7 +9,11 @@ const injectionToken = Symbol('replay-options');
|
|
|
9
9
|
function replayOptions(options) {
|
|
10
10
|
return {
|
|
11
11
|
provide: injectionToken,
|
|
12
|
-
useValue:
|
|
12
|
+
useValue: {
|
|
13
|
+
storage: 'backtest',
|
|
14
|
+
limit: 10000,
|
|
15
|
+
...options
|
|
16
|
+
}
|
|
13
17
|
};
|
|
14
18
|
}
|
|
15
19
|
exports.replayOptions = replayOptions;
|