@quantform/core 0.7.0-beta.5 → 0.7.0-beta.51
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/jest.config.ts +1 -1
- package/{dist → lib}/asset/asset.d.ts +3 -0
- package/lib/asset/asset.d.ts.map +1 -0
- package/{dist → lib}/asset/asset.js +7 -1
- package/{dist → lib}/cli/index.js +9 -6
- package/lib/cli/internal/script.d.ts +8 -0
- package/lib/cli/internal/script.d.ts.map +1 -0
- package/lib/cli/internal/script.js +65 -0
- package/lib/cli/live.d.ts +5 -0
- package/lib/cli/live.d.ts.map +1 -0
- package/lib/cli/live.js +33 -0
- package/lib/cli/paper.d.ts +5 -0
- package/lib/cli/paper.d.ts.map +1 -0
- package/lib/cli/paper.js +33 -0
- package/lib/cli/pull.d.ts.map +1 -0
- package/lib/cli/pull.js +28 -0
- package/lib/cli/replay.d.ts +6 -0
- package/lib/cli/replay.d.ts.map +1 -0
- package/lib/cli/replay.js +37 -0
- package/{dist → lib}/core.js +3 -3
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/{dist → lib}/index.js +6 -13
- package/{dist → lib}/instrument/instrument.d.ts +3 -0
- package/lib/instrument/instrument.d.ts.map +1 -0
- package/{dist → lib}/instrument/instrument.js +7 -1
- package/{dist → lib}/make-test-module.d.ts +3 -2
- package/lib/make-test-module.d.ts.map +1 -0
- package/{dist → lib}/make-test-module.js +11 -2
- package/lib/operators.d.ts +5 -0
- package/lib/operators.d.ts.map +1 -0
- package/lib/operators.js +16 -0
- package/lib/replay/index.d.ts +10 -0
- package/lib/replay/index.d.ts.map +1 -0
- package/{dist → lib}/replay/index.js +7 -4
- package/lib/replay/replay-guard.d.ts +10 -0
- package/lib/replay/replay-guard.d.ts.map +1 -0
- package/lib/replay/replay-guard.js +8 -0
- package/lib/replay/replay.d.ts +10 -0
- package/lib/replay/replay.d.ts.map +1 -0
- package/lib/replay/replay.js +9 -0
- package/lib/replay/storage/use-replay-storage-buffer.d.ts +15 -0
- package/lib/replay/storage/use-replay-storage-buffer.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage-buffer.js +57 -0
- package/lib/replay/storage/use-replay-storage-cursor.d.ts +30 -0
- package/lib/replay/storage/use-replay-storage-cursor.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage-cursor.js +49 -0
- package/lib/replay/storage/use-replay-storage.d.ts +13 -0
- package/lib/replay/storage/use-replay-storage.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage.js +39 -0
- package/lib/replay/storage/use-replay-storage.spec.d.ts +2 -0
- package/lib/replay/storage/use-replay-storage.spec.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage.spec.js +74 -0
- package/lib/replay/use-replay-lock.d.ts +3 -0
- package/lib/replay/use-replay-lock.d.ts.map +1 -0
- package/lib/replay/use-replay-lock.js +22 -0
- package/lib/replay/use-replay-manager.d.ts +28 -0
- package/lib/replay/use-replay-manager.d.ts.map +1 -0
- package/lib/replay/use-replay-manager.js +68 -0
- package/{dist → lib}/replay/use-replay.d.ts +2 -2
- package/lib/replay/use-replay.d.ts.map +1 -0
- package/lib/replay/use-replay.js +20 -0
- package/lib/replay/use-replay.spec.js +130 -0
- package/lib/replay/when-replay-finished.d.ts +2 -0
- package/lib/replay/when-replay-finished.d.ts.map +1 -0
- package/lib/replay/when-replay-finished.js +15 -0
- package/{dist → lib}/session/use-session-storage.js +2 -2
- package/lib/session/use-session.d.ts +13 -0
- package/lib/session/use-session.d.ts.map +1 -0
- package/lib/session/use-session.js +14 -0
- package/lib/shared/decimals.d.ts +14 -0
- package/lib/shared/decimals.d.ts.map +1 -0
- package/lib/shared/decimals.js +18 -0
- package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
- package/{dist → lib}/storage/index.d.ts +1 -0
- package/{dist → lib}/storage/index.d.ts.map +1 -1
- package/{dist → lib}/storage/index.js +1 -0
- package/lib/storage/use-storage-factory.d.ts +10 -0
- package/lib/storage/use-storage-factory.d.ts.map +1 -0
- package/lib/storage/use-storage-factory.js +13 -0
- package/lib/storage/use-storage.d.ts.map +1 -0
- package/{dist → lib}/storage/use-storage.js +2 -2
- package/lib/strategy.d.ts +15 -0
- package/lib/strategy.d.ts.map +1 -0
- package/lib/strategy.js +26 -0
- package/lib/strategy.spec.d.ts +2 -0
- package/lib/strategy.spec.d.ts.map +1 -0
- package/lib/strategy.spec.js +34 -0
- package/lib/use-execution-mode.d.ts +20 -0
- package/lib/use-execution-mode.d.ts.map +1 -0
- package/lib/use-execution-mode.js +33 -0
- package/{dist → lib}/use-logger.js +5 -5
- package/lib/use-memo.d.ts +8 -0
- package/lib/use-memo.d.ts.map +1 -0
- package/lib/use-memo.js +19 -0
- package/lib/use-socket.d.ts +20 -0
- package/lib/use-socket.d.ts.map +1 -0
- package/lib/use-socket.js +83 -0
- package/{dist → lib}/use-timestamp.js +2 -2
- package/lib/when-socket.d.ts +8 -0
- package/lib/when-socket.d.ts.map +1 -0
- package/{dist/use-socket.js → lib/when-socket.js} +6 -5
- package/lib/with-memo.d.ts +5 -0
- package/lib/with-memo.d.ts.map +1 -0
- package/{dist/use.js → lib/with-memo.js} +5 -5
- package/lib/with-memo.spec.d.ts +2 -0
- package/lib/with-memo.spec.d.ts.map +1 -0
- package/{dist/use.spec.js → lib/with-memo.spec.js} +3 -3
- package/{dist/use-request.d.ts → lib/with-request.d.ts} +6 -6
- package/lib/with-request.d.ts.map +1 -0
- package/lib/with-request.js +68 -0
- package/package.json +5 -5
- package/src/asset/asset.ts +6 -0
- package/src/cli/index.ts +11 -8
- package/src/cli/internal/script.ts +70 -0
- package/src/cli/live.ts +22 -0
- package/src/cli/paper.ts +22 -0
- package/src/cli/pull.ts +6 -66
- package/src/cli/replay.ts +15 -19
- package/src/core.ts +6 -6
- package/src/index.ts +6 -13
- package/src/instrument/instrument.ts +6 -0
- package/src/make-test-module.ts +20 -4
- package/src/operators.ts +18 -0
- package/src/replay/index.ts +7 -4
- package/src/replay/replay-guard.ts +11 -0
- package/src/replay/replay.ts +13 -0
- package/src/replay/storage/use-replay-storage-buffer.ts +52 -0
- package/src/replay/storage/use-replay-storage-cursor.ts +44 -0
- package/src/replay/storage/use-replay-storage.spec.ts +84 -0
- package/src/replay/storage/use-replay-storage.ts +29 -0
- package/src/replay/use-replay-lock.ts +29 -0
- package/src/replay/use-replay-manager.ts +83 -0
- package/src/replay/use-replay.spec.ts +10 -4
- package/src/replay/use-replay.ts +11 -17
- package/src/replay/when-replay-finished.ts +20 -0
- package/src/session/use-session-storage.ts +2 -2
- package/src/session/use-session.ts +16 -4
- package/src/shared/decimals.ts +0 -45
- package/src/simulator/use-simulator.spec.ts +10 -26
- package/src/storage/index.ts +1 -0
- package/src/storage/use-storage-factory.ts +7 -7
- package/src/storage/use-storage.ts +2 -2
- package/src/strategy.spec.ts +42 -0
- package/src/strategy.ts +36 -0
- package/src/use-execution-mode.ts +27 -27
- package/src/use-logger.ts +7 -7
- package/src/use-memo.ts +6 -21
- package/src/use-socket.ts +82 -44
- package/src/use-timestamp.ts +2 -2
- package/src/when-socket.ts +61 -0
- package/src/{use.spec.ts → with-memo.spec.ts} +3 -3
- package/src/{use.ts → with-memo.ts} +4 -4
- package/src/with-request.ts +83 -0
- package/tsconfig.json +2 -2
- package/dist/as-readonly.d.ts +0 -3
- package/dist/as-readonly.d.ts.map +0 -1
- package/dist/as-readonly.js +0 -8
- package/dist/asset/asset.d.ts.map +0 -1
- package/dist/cli/dev.d.ts +0 -2
- package/dist/cli/dev.d.ts.map +0 -1
- package/dist/cli/dev.js +0 -61
- package/dist/cli/pull.d.ts.map +0 -1
- package/dist/cli/pull.js +0 -107
- package/dist/cli/replay.d.ts +0 -2
- package/dist/cli/replay.d.ts.map +0 -1
- package/dist/cli/replay.js +0 -64
- package/dist/cli/run.d.ts +0 -2
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/cli/run.js +0 -62
- package/dist/defined.d.ts +0 -3
- package/dist/defined.d.ts.map +0 -1
- package/dist/defined.js +0 -8
- package/dist/exclude.d.ts +0 -3
- package/dist/exclude.d.ts.map +0 -1
- package/dist/exclude.js +0 -8
- package/dist/index.d.ts +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/instrument/instrument.d.ts.map +0 -1
- package/dist/make-test-module.d.ts.map +0 -1
- package/dist/not-found.d.ts +0 -2
- package/dist/not-found.d.ts.map +0 -1
- package/dist/not-found.js +0 -4
- package/dist/replay/index.d.ts +0 -7
- package/dist/replay/index.d.ts.map +0 -1
- package/dist/replay/use-replay-coordinator.d.ts +0 -10
- package/dist/replay/use-replay-coordinator.d.ts.map +0 -1
- package/dist/replay/use-replay-coordinator.js +0 -119
- package/dist/replay/use-replay-reader.d.ts +0 -7
- package/dist/replay/use-replay-reader.d.ts.map +0 -1
- package/dist/replay/use-replay-reader.js +0 -32
- package/dist/replay/use-replay-reader.spec.d.ts +0 -2
- package/dist/replay/use-replay-reader.spec.d.ts.map +0 -1
- package/dist/replay/use-replay-reader.spec.js +0 -58
- package/dist/replay/use-replay-storage.d.ts +0 -10
- package/dist/replay/use-replay-storage.d.ts.map +0 -1
- package/dist/replay/use-replay-storage.js +0 -10
- package/dist/replay/use-replay-writer.d.ts +0 -6
- package/dist/replay/use-replay-writer.d.ts.map +0 -1
- package/dist/replay/use-replay-writer.js +0 -14
- package/dist/replay/use-replay-writer.spec.d.ts +0 -2
- package/dist/replay/use-replay-writer.spec.d.ts.map +0 -1
- package/dist/replay/use-replay-writer.spec.js +0 -53
- package/dist/replay/use-replay.d.ts.map +0 -1
- package/dist/replay/use-replay.js +0 -32
- package/dist/replay/use-replay.spec.js +0 -106
- package/dist/replay/with-replay.d.ts +0 -4
- package/dist/replay/with-replay.d.ts.map +0 -1
- package/dist/replay/with-replay.js +0 -8
- package/dist/session/use-session.d.ts +0 -4
- package/dist/session/use-session.d.ts.map +0 -1
- package/dist/session/use-session.js +0 -7
- package/dist/shared/decimals.d.ts +0 -30
- package/dist/shared/decimals.d.ts.map +0 -1
- package/dist/shared/decimals.js +0 -61
- package/dist/storage/use-storage-factory.d.ts +0 -10
- package/dist/storage/use-storage-factory.d.ts.map +0 -1
- package/dist/storage/use-storage-factory.js +0 -14
- package/dist/storage/use-storage.d.ts.map +0 -1
- package/dist/strat.d.ts +0 -7
- package/dist/strat.d.ts.map +0 -1
- package/dist/strat.js +0 -7
- package/dist/use-execution-mode.d.ts +0 -29
- package/dist/use-execution-mode.d.ts.map +0 -1
- package/dist/use-execution-mode.js +0 -37
- package/dist/use-lock.d.ts +0 -9
- package/dist/use-lock.d.ts.map +0 -1
- package/dist/use-lock.js +0 -40
- package/dist/use-memo.d.ts +0 -21
- package/dist/use-memo.d.ts.map +0 -1
- package/dist/use-memo.js +0 -35
- package/dist/use-request.d.ts.map +0 -1
- package/dist/use-request.js +0 -27
- package/dist/use-socket.d.ts +0 -6
- package/dist/use-socket.d.ts.map +0 -1
- package/dist/use-state.d.ts +0 -4
- package/dist/use-state.d.ts.map +0 -1
- package/dist/use-state.js +0 -24
- package/dist/use-state.spec.d.ts +0 -2
- package/dist/use-state.spec.d.ts.map +0 -1
- package/dist/use-state.spec.js +0 -36
- package/dist/use.d.ts +0 -5
- package/dist/use.d.ts.map +0 -1
- package/dist/use.spec.d.ts +0 -2
- package/dist/use.spec.d.ts.map +0 -1
- package/src/as-readonly.ts +0 -5
- package/src/cli/dev.ts +0 -31
- package/src/cli/run.ts +0 -29
- package/src/defined.ts +0 -6
- package/src/exclude.ts +0 -9
- package/src/not-found.ts +0 -1
- package/src/replay/use-replay-coordinator.ts +0 -142
- package/src/replay/use-replay-reader.spec.ts +0 -64
- package/src/replay/use-replay-reader.ts +0 -23
- package/src/replay/use-replay-storage.ts +0 -8
- package/src/replay/use-replay-writer.spec.ts +0 -56
- package/src/replay/use-replay-writer.ts +0 -17
- package/src/replay/with-replay.ts +0 -10
- package/src/strat.ts +0 -7
- package/src/use-lock.ts +0 -52
- package/src/use-request.ts +0 -47
- package/src/use-state.spec.ts +0 -31
- package/src/use-state.ts +0 -30
- /package/{dist → lib}/asset/asset.spec.d.ts +0 -0
- /package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
- /package/{dist → lib}/asset/asset.spec.js +0 -0
- /package/{dist → lib}/asset/index.d.ts +0 -0
- /package/{dist → lib}/asset/index.d.ts.map +0 -0
- /package/{dist → lib}/asset/index.js +0 -0
- /package/{dist → lib}/cli/build.d.ts +0 -0
- /package/{dist → lib}/cli/build.d.ts.map +0 -0
- /package/{dist → lib}/cli/build.js +0 -0
- /package/{dist → lib}/cli/index.d.ts +0 -0
- /package/{dist → lib}/cli/index.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
- /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/workspace.js +0 -0
- /package/{dist → lib}/cli/pull.d.ts +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.js +0 -0
- /package/{dist → lib}/component/error.d.ts +0 -0
- /package/{dist → lib}/component/error.d.ts.map +0 -0
- /package/{dist → lib}/component/error.js +0 -0
- /package/{dist → lib}/component/index.d.ts +0 -0
- /package/{dist → lib}/component/index.d.ts.map +0 -0
- /package/{dist → lib}/component/index.js +0 -0
- /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
- /package/{dist → lib}/component/ohlc-operator.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc-operator.js +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
- /package/{dist → lib}/component/ohlc.d.ts +0 -0
- /package/{dist → lib}/component/ohlc.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc.js +0 -0
- /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
- /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc.spec.js +0 -0
- /package/{dist → lib}/component/timeframe.d.ts +0 -0
- /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
- /package/{dist → lib}/component/timeframe.js +0 -0
- /package/{dist → lib}/core.d.ts +0 -0
- /package/{dist → lib}/core.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
- /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.js +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
- /package/{dist → lib}/instrument/index.d.ts +0 -0
- /package/{dist → lib}/instrument/index.d.ts.map +0 -0
- /package/{dist → lib}/instrument/index.js +0 -0
- /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
- /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
- /package/{dist → lib}/instrument/instrument.spec.js +0 -0
- /package/{dist → lib}/module.d.ts +0 -0
- /package/{dist → lib}/module.d.ts.map +0 -0
- /package/{dist → lib}/module.js +0 -0
- /package/{dist → lib}/module.spec.d.ts +0 -0
- /package/{dist → lib}/module.spec.d.ts.map +0 -0
- /package/{dist → lib}/module.spec.js +0 -0
- /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-options.js +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
- /package/{dist → lib}/session/index.d.ts +0 -0
- /package/{dist → lib}/session/index.d.ts.map +0 -0
- /package/{dist → lib}/session/index.js +0 -0
- /package/{dist → lib}/session/use-session-object.d.ts +0 -0
- /package/{dist → lib}/session/use-session-object.d.ts.map +0 -0
- /package/{dist → lib}/session/use-session-object.js +0 -0
- /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
- /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
- /package/{dist → lib}/shared/datetime.d.ts +0 -0
- /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
- /package/{dist → lib}/shared/datetime.js +0 -0
- /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
- /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
- /package/{dist → lib}/shared/decimals.spec.js +0 -0
- /package/{dist → lib}/shared/environment.d.ts +0 -0
- /package/{dist → lib}/shared/environment.d.ts.map +0 -0
- /package/{dist → lib}/shared/environment.js +0 -0
- /package/{dist → lib}/shared/index.d.ts +0 -0
- /package/{dist → lib}/shared/index.d.ts.map +0 -0
- /package/{dist → lib}/shared/index.js +0 -0
- /package/{dist → lib}/simulator/index.d.ts +0 -0
- /package/{dist → lib}/simulator/index.d.ts.map +0 -0
- /package/{dist → lib}/simulator/index.js +0 -0
- /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
- /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
- /package/{dist → lib}/simulator/use-simulator.js +0 -0
- /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
- /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
- /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/index.js +0 -0
- /package/{dist → lib}/storage/storage.d.ts +0 -0
- /package/{dist → lib}/storage/storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/storage.js +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-cache.js +0 -0
- /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
- /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-cache.spec.js +0 -0
- /package/{dist → lib}/storage/use-storage.d.ts +0 -0
- /package/{dist → lib}/use-hash.d.ts +0 -0
- /package/{dist → lib}/use-hash.d.ts.map +0 -0
- /package/{dist → lib}/use-hash.js +0 -0
- /package/{dist → lib}/use-hash.spec.d.ts +0 -0
- /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
- /package/{dist → lib}/use-hash.spec.js +0 -0
- /package/{dist → lib}/use-logger.d.ts +0 -0
- /package/{dist → lib}/use-logger.d.ts.map +0 -0
- /package/{dist → lib}/use-memo.spec.d.ts +0 -0
- /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
- /package/{dist → lib}/use-memo.spec.js +0 -0
- /package/{dist → lib}/use-timestamp.d.ts +0 -0
- /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-request.d.ts","sourceRoot":"","sources":["../src/with-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ,qBAAa,mBAAoB,SAAQ,KAAK;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM;CAGxC;AAED,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACL,EAAE;IACD,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;eAGoC,MAAM;aAAW,OAAO;GA6C5D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.withRequest = exports.RequestNetworkError = void 0;
|
|
13
|
+
const node_crypto_1 = require("node:crypto");
|
|
14
|
+
const rxjs_1 = require("rxjs");
|
|
15
|
+
const undici_1 = require("undici");
|
|
16
|
+
const use_logger_1 = require("./use-logger");
|
|
17
|
+
const use_timestamp_1 = require("./use-timestamp");
|
|
18
|
+
class RequestNetworkError extends Error {
|
|
19
|
+
constructor(statusCode) {
|
|
20
|
+
super(`Request network error, received status code: ${statusCode}`);
|
|
21
|
+
this.statusCode = statusCode;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.RequestNetworkError = RequestNetworkError;
|
|
25
|
+
function withRequest({ method, url, headers, body }) {
|
|
26
|
+
const { error, debug } = (0, use_logger_1.useLogger)(withRequest.name);
|
|
27
|
+
return new rxjs_1.Observable(subscriber => {
|
|
28
|
+
const correlationId = (0, node_crypto_1.randomUUID)();
|
|
29
|
+
debug('requesting', { correlationId, method, url, headers, body });
|
|
30
|
+
(0, undici_1.request)(url, { method, headers, body })
|
|
31
|
+
.then(({ statusCode, body }) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const json = yield body.json();
|
|
33
|
+
debug('received', {
|
|
34
|
+
correlationId,
|
|
35
|
+
method,
|
|
36
|
+
url,
|
|
37
|
+
headers,
|
|
38
|
+
body: json,
|
|
39
|
+
statusCode
|
|
40
|
+
});
|
|
41
|
+
if (statusCode !== 200) {
|
|
42
|
+
error(`errored`, {
|
|
43
|
+
method,
|
|
44
|
+
url,
|
|
45
|
+
headers,
|
|
46
|
+
body,
|
|
47
|
+
statusCode
|
|
48
|
+
});
|
|
49
|
+
subscriber.error(new RequestNetworkError(statusCode));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
subscriber.next({ timestamp: (0, use_timestamp_1.useTimestamp)(), payload: json });
|
|
53
|
+
}
|
|
54
|
+
}))
|
|
55
|
+
.catch((e) => {
|
|
56
|
+
error(`errored`, {
|
|
57
|
+
method,
|
|
58
|
+
url,
|
|
59
|
+
headers,
|
|
60
|
+
body,
|
|
61
|
+
error: e
|
|
62
|
+
});
|
|
63
|
+
subscriber.error(error);
|
|
64
|
+
})
|
|
65
|
+
.finally(() => subscriber.complete());
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.withRequest = withRequest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quantform/core",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.51",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Mateusz Majchrzak",
|
|
6
6
|
"description": "Node.js library for building systematic trading strategies in reactive way.",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"qf": "./
|
|
15
|
+
"qf": "./lib/cli/index.js"
|
|
16
16
|
},
|
|
17
|
-
"main": "
|
|
18
|
-
"typings": "
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"typings": "lib/index.d.ts",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@swc/cli": "^0.1.62",
|
|
21
21
|
"@swc/core": "^1.3.44",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"rxjs": "^7.8.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"rxjs": "^7.
|
|
40
|
+
"rxjs": "^7.8.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsc && tsc-alias",
|
package/src/asset/asset.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { d, decimal } from '@lib/shared';
|
|
|
3
3
|
|
|
4
4
|
export const AssetSelectorSeparator = ':';
|
|
5
5
|
|
|
6
|
+
export class MissingAssetError extends Error {
|
|
7
|
+
constructor(asset: AssetSelector) {
|
|
8
|
+
super(`Missing asset: ${asset}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* Supposed to query specific @see Asset based on string notation.
|
|
8
14
|
*/
|
package/src/cli/index.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { program } from 'commander';
|
|
|
5
5
|
import watch from 'node-watch';
|
|
6
6
|
|
|
7
7
|
import build from '@lib/cli/build';
|
|
8
|
-
import
|
|
8
|
+
import live from '@lib/cli/live';
|
|
9
|
+
import paper from '@lib/cli/paper';
|
|
9
10
|
import pull from '@lib/cli/pull';
|
|
10
|
-
import
|
|
11
|
-
import run from '@lib/cli/run';
|
|
11
|
+
import replay from '@lib/cli/replay';
|
|
12
12
|
|
|
13
13
|
program
|
|
14
14
|
.command('build')
|
|
@@ -18,29 +18,32 @@ program
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
program
|
|
21
|
-
.command('
|
|
21
|
+
.command('live')
|
|
22
22
|
.argument('<name>', 'strategy to execute')
|
|
23
23
|
.option('-i, --id <id>', 'session identifier')
|
|
24
|
+
.option('-r, --recording', 'recording mode for replay purposes')
|
|
24
25
|
.option('-w', 'watch mode')
|
|
25
26
|
.description('executes strategy in live trading mode')
|
|
26
|
-
.action(
|
|
27
|
+
.action(live);
|
|
27
28
|
|
|
28
29
|
program
|
|
29
|
-
.command('
|
|
30
|
+
.command('paper')
|
|
30
31
|
.argument('<name>', 'strategy to execute')
|
|
31
32
|
.option('-i, --id <id>', 'session identifier')
|
|
33
|
+
.option('-r, --recording', 'recording mode for replay purposes')
|
|
32
34
|
.option('-w', 'watch mode')
|
|
33
35
|
.description('executes strategy in paper e.g. simulation mode')
|
|
34
|
-
.action(
|
|
36
|
+
.action(paper);
|
|
35
37
|
|
|
36
38
|
program
|
|
37
39
|
.command('replay')
|
|
38
40
|
.description('executes strategy in backtesting mode for specified period')
|
|
39
41
|
.argument('<name>', 'strategy to execute')
|
|
42
|
+
.option('-i, --id <id>', 'session identifier')
|
|
40
43
|
.option('-f, --from <from>', 'date from')
|
|
41
44
|
.option('-t, --to <to>', 'date to')
|
|
42
45
|
.option('-w', 'watch mode')
|
|
43
|
-
.action(
|
|
46
|
+
.action(replay);
|
|
44
47
|
|
|
45
48
|
program
|
|
46
49
|
.command('pull')
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import {
|
|
3
|
+
catchError,
|
|
4
|
+
finalize,
|
|
5
|
+
firstValueFrom,
|
|
6
|
+
forkJoin,
|
|
7
|
+
fromEvent,
|
|
8
|
+
last,
|
|
9
|
+
merge,
|
|
10
|
+
of,
|
|
11
|
+
switchMap,
|
|
12
|
+
take
|
|
13
|
+
} from 'rxjs';
|
|
14
|
+
|
|
15
|
+
import { core } from '@lib/core';
|
|
16
|
+
import { Dependency, Module } from '@lib/module';
|
|
17
|
+
import { whenReplayFinished } from '@lib/replay';
|
|
18
|
+
import { strategy } from '@lib/strategy';
|
|
19
|
+
|
|
20
|
+
import { buildDirectory } from './workspace';
|
|
21
|
+
|
|
22
|
+
export class Script {
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly filename: string,
|
|
25
|
+
private readonly dependencies: Dependency[]
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
async run() {
|
|
29
|
+
const script = await import(join(buildDirectory(), this.filename));
|
|
30
|
+
|
|
31
|
+
const { dependencies, description } = script.default as ReturnType<typeof strategy>;
|
|
32
|
+
|
|
33
|
+
const module = new Module([...core(), ...dependencies, ...this.dependencies]);
|
|
34
|
+
|
|
35
|
+
const { act } = await module.awake();
|
|
36
|
+
|
|
37
|
+
return await act(() => {
|
|
38
|
+
process.stdin.resume();
|
|
39
|
+
|
|
40
|
+
return firstValueFrom(
|
|
41
|
+
merge(
|
|
42
|
+
forkJoin(description.before.map(before => before()))
|
|
43
|
+
.pipe(
|
|
44
|
+
switchMap(() =>
|
|
45
|
+
forkJoin(description.behavior.map(behavior => behavior())).pipe(last())
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
.pipe(last()),
|
|
49
|
+
whenReplayFinished().pipe(last()),
|
|
50
|
+
fromEvent(process, 'exit'),
|
|
51
|
+
fromEvent(process, 'SIGINT'),
|
|
52
|
+
fromEvent(process, 'SIGUSR1'),
|
|
53
|
+
fromEvent(process, 'SIGUSR2'),
|
|
54
|
+
fromEvent(process, 'uncaughtException')
|
|
55
|
+
).pipe(
|
|
56
|
+
catchError(e => {
|
|
57
|
+
console.error(e);
|
|
58
|
+
|
|
59
|
+
return of(e);
|
|
60
|
+
}),
|
|
61
|
+
take(1),
|
|
62
|
+
switchMap(
|
|
63
|
+
it => forkJoin(description.after.map(after => after())).pipe(last()) ?? of(it)
|
|
64
|
+
),
|
|
65
|
+
finalize(() => process.exit(0))
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
package/src/cli/live.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import build from '@lib/cli/build';
|
|
2
|
+
import { useSession } from '@lib/session';
|
|
3
|
+
import { useExecutionMode } from '@lib/use-execution-mode';
|
|
4
|
+
|
|
5
|
+
import { Script } from './internal/script';
|
|
6
|
+
|
|
7
|
+
export default async function (
|
|
8
|
+
name: string,
|
|
9
|
+
options: { id?: string; recording?: boolean }
|
|
10
|
+
) {
|
|
11
|
+
if (await build()) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const script = new Script(name, [
|
|
16
|
+
useSession.options({ id: options.id ?? Date.now().toString() }),
|
|
17
|
+
useExecutionMode.liveOptions({ recording: options.recording ?? false })
|
|
18
|
+
]);
|
|
19
|
+
const output = await script.run();
|
|
20
|
+
|
|
21
|
+
console.log(output);
|
|
22
|
+
}
|
package/src/cli/paper.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import build from '@lib/cli/build';
|
|
2
|
+
import { useSession } from '@lib/session';
|
|
3
|
+
import { useExecutionMode } from '@lib/use-execution-mode';
|
|
4
|
+
|
|
5
|
+
import { Script } from './internal/script';
|
|
6
|
+
|
|
7
|
+
export default async function (
|
|
8
|
+
name: string,
|
|
9
|
+
options: { id?: string; recording?: boolean }
|
|
10
|
+
) {
|
|
11
|
+
if (await build()) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const script = new Script(name, [
|
|
16
|
+
useSession.options({ id: options.id ?? Date.now().toString() }),
|
|
17
|
+
useExecutionMode.paperOptions({ recording: options.recording ?? false })
|
|
18
|
+
]);
|
|
19
|
+
const output = await script.run();
|
|
20
|
+
|
|
21
|
+
console.log(output);
|
|
22
|
+
}
|
package/src/cli/pull.ts
CHANGED
|
@@ -1,75 +1,15 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
|
|
3
1
|
import build from '@lib/cli/build';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import { strat } from '@lib/strat';
|
|
8
|
-
import { paperExecutionMode } from '@lib/use-execution-mode';
|
|
9
|
-
import { token } from '@lib/use-memo';
|
|
2
|
+
import { useExecutionMode } from '@lib/use-execution-mode';
|
|
3
|
+
|
|
4
|
+
import { Script } from './internal/script';
|
|
10
5
|
|
|
11
6
|
export default async function (name: string, instrument: string, options: any) {
|
|
12
7
|
if (await build()) {
|
|
13
8
|
return;
|
|
14
9
|
}
|
|
15
|
-
await import(join(buildDirectory(), 'index'));
|
|
16
|
-
|
|
17
|
-
const script = (await import(join(buildDirectory(), name))) as ReturnType<typeof strat>;
|
|
18
|
-
|
|
19
|
-
const module = new Module([
|
|
20
|
-
...core(),
|
|
21
|
-
...script.dependencies,
|
|
22
|
-
paperExecutionMode({ recording: false })
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
const { act } = await module.awake();
|
|
26
|
-
|
|
27
|
-
const o = await act(() => script.fn());
|
|
28
|
-
console.log(module.get<any>(token));
|
|
29
|
-
|
|
30
|
-
/*const builder = new SessionBuilder().useSessionId(
|
|
31
|
-
options.id ? Number(options.id) : now()
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
await spawn(name, builder);
|
|
35
|
-
|
|
36
|
-
const session = builder.paper();
|
|
37
|
-
|
|
38
|
-
console.time('Pulling completed in');
|
|
39
|
-
|
|
40
|
-
await session.awake();
|
|
41
|
-
|
|
42
|
-
const bar = new SingleBar(
|
|
43
|
-
{
|
|
44
|
-
format: `Pulling ${instrument} [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}`
|
|
45
|
-
},
|
|
46
|
-
Presets.rect
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const feed = new Feed(builder.storage('feed'));
|
|
50
|
-
const from = options.from ? Date.parse(options.from) : builder.period.from;
|
|
51
|
-
const to = options.to ? Date.parse(options.to) : builder.period.to;
|
|
52
|
-
|
|
53
|
-
bar.start(100, 0);
|
|
54
|
-
|
|
55
|
-
await session.aggregate.feed(
|
|
56
|
-
instrumentOf(instrument),
|
|
57
|
-
from,
|
|
58
|
-
to,
|
|
59
|
-
async (timestamp, events) => {
|
|
60
|
-
const duration = to - from;
|
|
61
|
-
const completed = timestamp - from;
|
|
62
|
-
|
|
63
|
-
await feed.save(events);
|
|
64
|
-
|
|
65
|
-
bar.update(Math.floor((completed / duration) * 100));
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
bar.update(100);
|
|
70
|
-
bar.stop();
|
|
71
10
|
|
|
72
|
-
|
|
11
|
+
const script = new Script(name, [useExecutionMode.idleOptions()]);
|
|
12
|
+
//const output = await script.run();
|
|
73
13
|
|
|
74
|
-
console.
|
|
14
|
+
//console.log(output);
|
|
75
15
|
}
|
package/src/cli/replay.ts
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { lastValueFrom } from 'rxjs';
|
|
3
|
-
|
|
4
1
|
import build from '@lib/cli/build';
|
|
5
|
-
import { buildDirectory } from '@lib/cli/internal/workspace';
|
|
6
|
-
import { core } from '@lib/core';
|
|
7
|
-
import { Dependency, Module } from '@lib/module';
|
|
8
2
|
import { replayOptions } from '@lib/replay';
|
|
9
|
-
import {
|
|
3
|
+
import { useSession } from '@lib/session';
|
|
4
|
+
import { useExecutionMode } from '@lib/use-execution-mode';
|
|
5
|
+
|
|
6
|
+
import { Script } from './internal/script';
|
|
10
7
|
|
|
11
|
-
export default async function (
|
|
8
|
+
export default async function (
|
|
9
|
+
name: string,
|
|
10
|
+
options: { id?: string; from?: string; to?: string }
|
|
11
|
+
) {
|
|
12
12
|
if (await build()) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const from = options.from ? new Date(options.from).getTime() : 0;
|
|
17
|
+
const to = options.to ? new Date(options.to).getTime() : Number.MAX_VALUE;
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
replayOptions(
|
|
23
|
-
replayExecutionMode()
|
|
19
|
+
const script = new Script(name, [
|
|
20
|
+
useSession.options({ id: options.id ?? Date.now().toString() }),
|
|
21
|
+
replayOptions({ from, to }),
|
|
22
|
+
useExecutionMode.replayOptions()
|
|
24
23
|
]);
|
|
25
|
-
|
|
26
|
-
const { act } = await module.awake();
|
|
27
|
-
|
|
28
|
-
const output = await act(() => lastValueFrom(script.default(options)));
|
|
24
|
+
const output = await script.run();
|
|
29
25
|
|
|
30
26
|
console.log(output);
|
|
31
27
|
}
|
package/src/core.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Dependency } from '@lib/module';
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from '@lib/use-memo';
|
|
3
3
|
|
|
4
4
|
import { InMemoryStorageFactory } from './storage';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useStorageFactory } from './storage/use-storage-factory';
|
|
6
|
+
import { useExecutionMode } from './use-execution-mode';
|
|
7
7
|
|
|
8
8
|
export function core(): Dependency[] {
|
|
9
9
|
return [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
useMemo.options(),
|
|
11
|
+
useExecutionMode.paperOptions({ recording: false }),
|
|
12
|
+
useStorageFactory.options(new InMemoryStorageFactory())
|
|
13
13
|
];
|
|
14
14
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,21 +7,14 @@ export * from '@lib/use-timestamp';
|
|
|
7
7
|
export * from '@lib/simulator';
|
|
8
8
|
export * from '@lib/make-test-module';
|
|
9
9
|
export * from '@lib/core';
|
|
10
|
-
export * from '@lib/use-state';
|
|
11
|
-
export * from '@lib/replay/use-replay-coordinator';
|
|
12
10
|
export * from '@lib/use-execution-mode';
|
|
13
|
-
export * from '@lib/storage
|
|
14
|
-
export * from '@lib/storage/use-cache';
|
|
11
|
+
export * from '@lib/storage';
|
|
15
12
|
export * from '@lib/use-logger';
|
|
16
13
|
export * from '@lib/replay';
|
|
17
|
-
export * from '@lib/replay/use-replay-coordinator';
|
|
18
14
|
export * from '@lib/use-socket';
|
|
19
|
-
export * from '@lib/
|
|
20
|
-
export * from '@lib/
|
|
21
|
-
export * from '@lib/
|
|
22
|
-
export * from '@lib/use';
|
|
15
|
+
export * from '@lib/when-socket';
|
|
16
|
+
export * from '@lib/with-request';
|
|
17
|
+
export * from '@lib/with-memo';
|
|
23
18
|
export * from '@lib/session';
|
|
24
|
-
export * from '@lib/
|
|
25
|
-
export * from '@lib/
|
|
26
|
-
export * from '@lib/strat';
|
|
27
|
-
export * from '@lib/not-found';
|
|
19
|
+
export * from '@lib/strategy';
|
|
20
|
+
export * from '@lib/operators';
|
|
@@ -5,6 +5,12 @@ import { Commission } from './commission/commission';
|
|
|
5
5
|
|
|
6
6
|
export const InstrumentSelectorSeparator = '-';
|
|
7
7
|
|
|
8
|
+
export class MissingInstrumentError extends Error {
|
|
9
|
+
constructor(instrument: InstrumentSelector) {
|
|
10
|
+
super(`Missing instrument: ${instrument}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
export class InstrumentSelector {
|
|
9
15
|
readonly id: string;
|
|
10
16
|
readonly base: AssetSelector;
|
package/src/make-test-module.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Observable,
|
|
1
|
+
import { Observable, Subject } from 'rxjs';
|
|
2
2
|
|
|
3
3
|
import { core } from '@lib/core';
|
|
4
4
|
import { Dependency, Module } from '@lib/module';
|
|
@@ -20,9 +20,9 @@ export const mockedFunc = <Func extends MockableFunction>(mockedFunc: Func) =>
|
|
|
20
20
|
mockedFunc as jest.MockedFunction<typeof mockedFunc>;
|
|
21
21
|
|
|
22
22
|
export function toArray<T>(observable: Observable<T>) {
|
|
23
|
-
const array = Array.of<T>();
|
|
23
|
+
const array = Array.of<T | Error>();
|
|
24
24
|
|
|
25
|
-
const clone = (it: T): T => {
|
|
25
|
+
const clone = (it: T | Error): T | Error => {
|
|
26
26
|
if (typeof it === 'symbol') {
|
|
27
27
|
return it;
|
|
28
28
|
}
|
|
@@ -38,9 +38,25 @@ export function toArray<T>(observable: Observable<T>) {
|
|
|
38
38
|
return it;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
observable.
|
|
41
|
+
observable.subscribe({
|
|
42
|
+
next: it => array.push(clone(it)),
|
|
43
|
+
error: it => array.push(it)
|
|
44
|
+
});
|
|
42
45
|
|
|
43
46
|
return array;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export type InferObservableType<T> = T extends Observable<infer U> ? U : never;
|
|
50
|
+
|
|
51
|
+
export function mockSubject<
|
|
52
|
+
T extends jest.FunctionProperties<Required<T>>,
|
|
53
|
+
M extends keyof jest.FunctionProperties<Required<T>>
|
|
54
|
+
>(object: T, method: M) {
|
|
55
|
+
const subject = new Subject<
|
|
56
|
+
InferObservableType<ReturnType<jest.FunctionProperties<Required<T>>[M]>>
|
|
57
|
+
>();
|
|
58
|
+
|
|
59
|
+
jest.spyOn<T, M>(object, method).mockReturnValue(subject.asObservable() as any);
|
|
60
|
+
|
|
61
|
+
return subject;
|
|
62
|
+
}
|
package/src/operators.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { filter, map, Observable } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
export function asReadonly<T>() {
|
|
4
|
+
return (input: Observable<T>) => input.pipe(map(it => it as Readonly<T>));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function defined<T>() {
|
|
8
|
+
return (observable: Observable<T | undefined | null>) =>
|
|
9
|
+
observable.pipe(filter(it => it !== undefined && it !== null));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function exclude<T, S extends symbol>(s: S) {
|
|
13
|
+
return (observable: Observable<T | S>) =>
|
|
14
|
+
observable.pipe(
|
|
15
|
+
filter(it => it !== s),
|
|
16
|
+
map(it => it as Exclude<T, typeof s>)
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/replay/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './use-replay';
|
|
2
|
-
export * from './use-replay-
|
|
2
|
+
export * from './use-replay-lock';
|
|
3
3
|
export * from './use-replay-options';
|
|
4
|
-
export * from './use-replay-
|
|
5
|
-
export * from './use-replay-
|
|
6
|
-
export * from './
|
|
4
|
+
export * from './storage/use-replay-storage';
|
|
5
|
+
export * from './storage/use-replay-storage-buffer';
|
|
6
|
+
export * from './use-replay-manager';
|
|
7
|
+
export * from './when-replay-finished';
|
|
8
|
+
export * from './replay';
|
|
9
|
+
export * from './replay-guard';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
import { dependency } from '@lib/use-hash';
|
|
4
|
+
|
|
5
|
+
import { useReplayLock } from './use-replay-lock';
|
|
6
|
+
|
|
7
|
+
export function replayGuard<T extends Array<dependency>, K>(
|
|
8
|
+
fn: (...args: T) => Observable<{ timestamp: number; payload: K }>
|
|
9
|
+
): (...args: T) => Observable<{ timestamp: number; payload: K }> {
|
|
10
|
+
return (...args: T) => useReplayLock(fn(...args));
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
import { dependency } from '@lib/use-hash';
|
|
4
|
+
import { withMemo } from '@lib/with-memo';
|
|
5
|
+
|
|
6
|
+
import { useReplay } from './use-replay';
|
|
7
|
+
|
|
8
|
+
export function replay<T extends Array<dependency>, K>(
|
|
9
|
+
fn: (...args: T) => Observable<{ timestamp: number; payload: K }>,
|
|
10
|
+
dependencies: dependency[]
|
|
11
|
+
): (...args: T) => Observable<{ timestamp: number; payload: K }> {
|
|
12
|
+
return withMemo((...args: T) => useReplay(fn(...args), [...dependencies, ...args]));
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useReplayOptions } from '@lib/replay/use-replay-options';
|
|
2
|
+
import { between } from '@lib/storage';
|
|
3
|
+
import { dependency } from '@lib/use-hash';
|
|
4
|
+
import { withMemo } from '@lib/with-memo';
|
|
5
|
+
|
|
6
|
+
import { useReplayStorage } from './use-replay-storage';
|
|
7
|
+
|
|
8
|
+
export const useReplayStorageBuffer = withMemo(<T>(dependencies: dependency[]) => {
|
|
9
|
+
const { query } = useReplayStorage<T>(dependencies);
|
|
10
|
+
const { from, to } = useReplayOptions();
|
|
11
|
+
|
|
12
|
+
console.log(from, to);
|
|
13
|
+
|
|
14
|
+
let page = new Array<{ timestamp: number; payload: T }>();
|
|
15
|
+
let index = 0;
|
|
16
|
+
let completed = false;
|
|
17
|
+
let count = 0;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
size() {
|
|
21
|
+
return page.length - index;
|
|
22
|
+
},
|
|
23
|
+
peek() {
|
|
24
|
+
return page[index];
|
|
25
|
+
},
|
|
26
|
+
dequeue() {
|
|
27
|
+
return page[index++];
|
|
28
|
+
},
|
|
29
|
+
completed() {
|
|
30
|
+
return completed;
|
|
31
|
+
},
|
|
32
|
+
async fetchNextPage() {
|
|
33
|
+
if (completed) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
index = 0;
|
|
38
|
+
|
|
39
|
+
page = await query({
|
|
40
|
+
where: {
|
|
41
|
+
timestamp: between(from, to)
|
|
42
|
+
},
|
|
43
|
+
limit: 10000,
|
|
44
|
+
offset: count,
|
|
45
|
+
orderBy: 'ASC'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
count += page.length;
|
|
49
|
+
completed = page.length == 0;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
});
|