@quantform/core 0.7.0-beta.8 → 0.7.9
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 +8 -2
- 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 +75 -0
- package/{dist → lib}/cli/internal/workspace.js +1 -2
- 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}/component/distinct-until-timesamp-changed.d.ts.map +1 -1
- package/{dist → lib}/component/distinct-until-timesamp-changed.js +1 -2
- package/lib/component/ohlc-operator.d.ts.map +1 -0
- package/{dist → lib}/component/ohlc-operator.js +3 -4
- package/{dist → lib}/component/ohlc.d.ts.map +1 -1
- package/{dist → lib}/component/timeframe.js +3 -3
- package/{dist → lib}/core.js +4 -5
- 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/commission/commission.js +3 -3
- package/{dist → lib}/instrument/instrument.d.ts +3 -0
- package/lib/instrument/instrument.d.ts.map +1 -0
- package/{dist → lib}/instrument/instrument.js +8 -2
- package/lib/make-test-module.d.ts +13 -0
- package/lib/make-test-module.d.ts.map +1 -0
- package/{dist → lib}/make-test-module.js +13 -4
- package/lib/module.d.ts.map +1 -0
- package/lib/operators.d.ts +5 -0
- package/lib/operators.d.ts.map +1 -0
- package/lib/operators.js +15 -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 +7 -0
- package/lib/replay/replay.d.ts +10 -0
- package/lib/replay/replay.d.ts.map +1 -0
- package/lib/replay/replay.js +8 -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 +38 -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 +21 -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-options.js +2 -2
- 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 +19 -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 +14 -0
- package/lib/session/use-session-object.d.ts +9 -0
- package/lib/session/use-session-object.d.ts.map +1 -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/{dist → lib}/shared/datetime.js +1 -2
- 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}/shared/environment.js +2 -3
- package/{dist → lib}/simulator/use-simulator.js +1 -2
- package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
- package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +2 -2
- 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/storage.d.ts.map +1 -0
- package/{dist → lib}/storage/use-cache.d.ts.map +1 -1
- 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 +12 -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 +32 -0
- package/{dist → lib}/use-hash.js +1 -2
- 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 +82 -0
- package/{dist → lib}/use-timestamp.js +3 -4
- 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} +5 -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} +4 -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/component/ohlc-operator.d.ts.map +0 -1
- 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 +0 -13
- package/dist/make-test-module.d.ts.map +0 -1
- package/dist/missed.d.ts +0 -2
- package/dist/missed.d.ts.map +0 -1
- package/dist/missed.js +0 -4
- package/dist/module.d.ts.map +0 -1
- 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-object.d.ts +0 -18
- package/dist/session/use-session-object.d.ts.map +0 -1
- 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/storage.d.ts.map +0 -1
- 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/missed.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 +1 -1
- /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/pull.d.ts +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +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.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.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}/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.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.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.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.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/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/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.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.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.js +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts +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.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
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { makeTestModule, mockedFunc } from '@lib/make-test-module';
|
|
2
|
-
import { gt, Storage } from '@lib/storage';
|
|
3
|
-
|
|
4
|
-
import { useReplayReader } from './use-replay-reader';
|
|
5
|
-
import { useReplayStorage } from './use-replay-storage';
|
|
6
|
-
|
|
7
|
-
jest.mock('./use-replay-storage', () => ({
|
|
8
|
-
...jest.requireActual('./use-replay-storage'),
|
|
9
|
-
useReplayStorage: jest.fn()
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
describe(useReplayReader.name, () => {
|
|
13
|
-
let fixtures: Awaited<ReturnType<typeof getFixtures>>;
|
|
14
|
-
|
|
15
|
-
beforeEach(async () => {
|
|
16
|
-
fixtures = await getFixtures();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('read sample candle data from storage', async () => {
|
|
20
|
-
await fixtures.givenDataStored(fixtures.sample);
|
|
21
|
-
const data = await fixtures.whenDataRequested();
|
|
22
|
-
|
|
23
|
-
expect(data).toEqual(fixtures.sample);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
async function getFixtures() {
|
|
28
|
-
const { act } = await makeTestModule([]);
|
|
29
|
-
|
|
30
|
-
const dependencies = ['binance:btc-usdt', 'candle', 'h1'];
|
|
31
|
-
const query: jest.MockedFunction<Storage['query']> = jest.fn();
|
|
32
|
-
|
|
33
|
-
mockedFunc(useReplayStorage).mockReturnValue({ query } as any);
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
sample: [
|
|
37
|
-
{ timestamp: 1, payload: { o: 1.1, h: 1.1, l: 1.1, c: 1.1 } },
|
|
38
|
-
{ timestamp: 2, payload: { o: 1.1, h: 2.2, l: 1.1, c: 2.2 } },
|
|
39
|
-
{ timestamp: 3, payload: { o: 1.1, h: 3.3, l: 1.1, c: 3.3 } }
|
|
40
|
-
],
|
|
41
|
-
|
|
42
|
-
givenDataStored<T>(data: { timestamp: number; payload: T }[]) {
|
|
43
|
-
return query.mockReturnValue(
|
|
44
|
-
Promise.resolve(
|
|
45
|
-
data.map(it => ({
|
|
46
|
-
kind: 'sample',
|
|
47
|
-
timestamp: it.timestamp,
|
|
48
|
-
json: JSON.stringify(it.payload)
|
|
49
|
-
}))
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
async whenDataRequested<T>() {
|
|
55
|
-
return await act(() =>
|
|
56
|
-
useReplayReader<T>(dependencies)({
|
|
57
|
-
where: {
|
|
58
|
-
timestamp: gt(0)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Query, QueryObject } from '@lib/storage';
|
|
2
|
-
import { dependency, useHash } from '@lib/use-hash';
|
|
3
|
-
|
|
4
|
-
import { replaySerializableObject, useReplayStorage } from './use-replay-storage';
|
|
5
|
-
|
|
6
|
-
export function useReplayReader<T>(dependencies: dependency[]) {
|
|
7
|
-
const storage = useReplayStorage();
|
|
8
|
-
const key = useHash(dependencies);
|
|
9
|
-
|
|
10
|
-
return async (query: Query<QueryObject>) =>
|
|
11
|
-
(
|
|
12
|
-
await storage.query(replaySerializableObject(key), {
|
|
13
|
-
where: {
|
|
14
|
-
timestamp: query.where?.timestamp
|
|
15
|
-
},
|
|
16
|
-
limit: query.limit,
|
|
17
|
-
orderBy: query.orderBy
|
|
18
|
-
})
|
|
19
|
-
).map(it => ({
|
|
20
|
-
timestamp: it.timestamp,
|
|
21
|
-
payload: JSON.parse(it.json) as T
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { makeTestModule, mockedFunc } from '@lib/make-test-module';
|
|
2
|
-
import { Storage } from '@lib/storage';
|
|
3
|
-
import { useHash } from '@lib/use-hash';
|
|
4
|
-
|
|
5
|
-
import { useReplayStorage } from './use-replay-storage';
|
|
6
|
-
import { useReplayWriter } from './use-replay-writer';
|
|
7
|
-
|
|
8
|
-
jest.mock('./use-replay-storage', () => ({
|
|
9
|
-
...jest.requireActual('./use-replay-storage'),
|
|
10
|
-
useReplayStorage: jest.fn()
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
describe.skip(useReplayWriter.name, () => {
|
|
14
|
-
let fixtures: Awaited<ReturnType<typeof getFixtures>>;
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
fixtures = await getFixtures();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('write sample candle data to storage', async () => {
|
|
21
|
-
await fixtures.whenReplayDataWritten(fixtures.sample);
|
|
22
|
-
await fixtures.thenReplayDataSaved(fixtures.sample);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
async function getFixtures() {
|
|
27
|
-
const { act } = await makeTestModule([]);
|
|
28
|
-
|
|
29
|
-
const dependencies = ['binance:btc-usdt', 'candle', 'h1'];
|
|
30
|
-
const save: Storage['save'] = jest.fn();
|
|
31
|
-
|
|
32
|
-
mockedFunc(useReplayStorage).mockReturnValue({ save } as any);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
sample: [
|
|
36
|
-
{ timestamp: 1, payload: { o: 1.1, h: 1.1, l: 1.1, c: 1.1 } },
|
|
37
|
-
{ timestamp: 2, payload: { o: 1.1, h: 2.2, l: 1.1, c: 2.2 } },
|
|
38
|
-
{ timestamp: 3, payload: { o: 1.1, h: 3.3, l: 1.1, c: 3.3 } }
|
|
39
|
-
],
|
|
40
|
-
|
|
41
|
-
whenReplayDataWritten<T>(data: { timestamp: number; payload: T }[]) {
|
|
42
|
-
return act(() => useReplayWriter(dependencies)(data));
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
async thenReplayDataSaved<T>(data: { timestamp: number; payload: T }[]) {
|
|
46
|
-
expect(save).toHaveBeenCalledWith(
|
|
47
|
-
useHash(dependencies),
|
|
48
|
-
data.map(it => ({
|
|
49
|
-
kind: 'sample',
|
|
50
|
-
timestamp: it.timestamp,
|
|
51
|
-
json: JSON.stringify(it.payload)
|
|
52
|
-
}))
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { dependency, useHash } from '@lib/use-hash';
|
|
2
|
-
|
|
3
|
-
import { replaySerializableObject, useReplayStorage } from './use-replay-storage';
|
|
4
|
-
|
|
5
|
-
export function useReplayWriter<T>(dependencies: dependency[]) {
|
|
6
|
-
const storage = useReplayStorage();
|
|
7
|
-
const key = useHash(dependencies);
|
|
8
|
-
|
|
9
|
-
return (samples: { timestamp: number; payload: T }[]) =>
|
|
10
|
-
storage.save(
|
|
11
|
-
replaySerializableObject(key),
|
|
12
|
-
samples.map(it => ({
|
|
13
|
-
timestamp: it.timestamp,
|
|
14
|
-
json: JSON.stringify(it.payload)
|
|
15
|
-
}))
|
|
16
|
-
);
|
|
17
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
|
|
3
|
-
import { use } from '@lib/use';
|
|
4
|
-
import { dependency } from '@lib/use-hash';
|
|
5
|
-
|
|
6
|
-
export function withReplay<T extends Array<dependency>, U extends Observable<K>, K>(
|
|
7
|
-
fn: (...args: T) => U
|
|
8
|
-
): (...args: T) => U {
|
|
9
|
-
return use(fn);
|
|
10
|
-
}
|
package/src/strat.ts
DELETED
package/src/use-lock.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { filter, finalize, Observable } from 'rxjs';
|
|
2
|
-
|
|
3
|
-
import { use } from '@lib/use';
|
|
4
|
-
import { dependency, useHash } from '@lib/use-hash';
|
|
5
|
-
|
|
6
|
-
export const useExclusiveLock = use(() => {
|
|
7
|
-
const locking = {} as Record<string, boolean>;
|
|
8
|
-
const acquire = (dependencies: dependency[]) => {
|
|
9
|
-
const hash = useHash(dependencies);
|
|
10
|
-
|
|
11
|
-
if (locking[hash]) {
|
|
12
|
-
throw Error('nested locks not allowed');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
locking[hash] = true;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const release = (dependencies: dependency[]) => {
|
|
19
|
-
const hash = useHash(dependencies);
|
|
20
|
-
|
|
21
|
-
if (!locking[hash]) {
|
|
22
|
-
throw Error('nested locks not allowed');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
locking[hash] = false;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const alreadyAcquired = (dependencies: dependency[]) => {
|
|
29
|
-
const hash = useHash(dependencies);
|
|
30
|
-
|
|
31
|
-
return locking[hash] == true;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
acquire,
|
|
36
|
-
release,
|
|
37
|
-
alreadyAcquired
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export function exclusive<T>(dependencies: dependency[]) {
|
|
42
|
-
return (input: Observable<T>) => {
|
|
43
|
-
const { acquire, release, alreadyAcquired } = useExclusiveLock();
|
|
44
|
-
|
|
45
|
-
acquire(dependencies);
|
|
46
|
-
|
|
47
|
-
return input.pipe(
|
|
48
|
-
filter(() => alreadyAcquired(dependencies)),
|
|
49
|
-
finalize(() => release(dependencies))
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
}
|
package/src/use-request.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { from, map, switchMap, throwError } from 'rxjs';
|
|
2
|
-
import { request } from 'undici';
|
|
3
|
-
|
|
4
|
-
import { useTimestamp } from './use-timestamp';
|
|
5
|
-
|
|
6
|
-
export type RequestMethod =
|
|
7
|
-
| 'GET'
|
|
8
|
-
| 'HEAD'
|
|
9
|
-
| 'POST'
|
|
10
|
-
| 'PUT'
|
|
11
|
-
| 'DELETE'
|
|
12
|
-
| 'CONNECT'
|
|
13
|
-
| 'OPTIONS'
|
|
14
|
-
| 'TRACE'
|
|
15
|
-
| 'PATCH';
|
|
16
|
-
|
|
17
|
-
export class RequestNetworkError extends Error {
|
|
18
|
-
constructor(readonly statusCode: number, readonly json: () => Promise<string>) {
|
|
19
|
-
super(`Request network error, received status code: ${statusCode}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useRequest(args: {
|
|
24
|
-
method: RequestMethod;
|
|
25
|
-
url: string;
|
|
26
|
-
headers?: Record<string, any>;
|
|
27
|
-
body?: string;
|
|
28
|
-
}) {
|
|
29
|
-
return from(
|
|
30
|
-
request(args.url, {
|
|
31
|
-
method: args.method,
|
|
32
|
-
headers: args.headers,
|
|
33
|
-
body: args.body
|
|
34
|
-
})
|
|
35
|
-
).pipe(
|
|
36
|
-
switchMap(it => {
|
|
37
|
-
if (it.statusCode !== 200) {
|
|
38
|
-
return throwError(
|
|
39
|
-
() => new RequestNetworkError(it.statusCode, () => it.body.json())
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return from(it.body.json());
|
|
44
|
-
}),
|
|
45
|
-
map(payload => ({ timestamp: useTimestamp(), payload }))
|
|
46
|
-
);
|
|
47
|
-
}
|
package/src/use-state.spec.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { makeTestModule } from '@lib/make-test-module';
|
|
2
|
-
import { useState } from '@lib/use-state';
|
|
3
|
-
|
|
4
|
-
import { dependency } from './use-hash';
|
|
5
|
-
|
|
6
|
-
describe(useState.name, () => {
|
|
7
|
-
let fixtures: Awaited<ReturnType<typeof getFixtures>>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
fixtures = await getFixtures();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('keep same state between multiple requests for the same dependency', async () => {
|
|
14
|
-
const state1 = await fixtures.givenState({ text: 'Hello my state' }, ['my-state']);
|
|
15
|
-
const state2 = await fixtures.givenState({ text: 'Hello my override state' }, [
|
|
16
|
-
'my-state'
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
expect(Object.is(state1, state2)).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
async function getFixtures() {
|
|
24
|
-
const { act } = await makeTestModule([]);
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
givenState<T>(value: T, dependencies: dependency[]) {
|
|
28
|
-
return act(() => useState(value, dependencies));
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
package/src/use-state.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
2
|
-
|
|
3
|
-
import { useMemo } from '@lib/use-memo';
|
|
4
|
-
|
|
5
|
-
import { dependency } from './use-hash';
|
|
6
|
-
|
|
7
|
-
export function useState<T>(
|
|
8
|
-
initialValue: T,
|
|
9
|
-
dependencies: dependency[]
|
|
10
|
-
): [Observable<Readonly<T>>, (value: T | ((p: T) => T)) => Readonly<T>] {
|
|
11
|
-
return useMemo(() => {
|
|
12
|
-
const state = new BehaviorSubject<T>(initialValue);
|
|
13
|
-
|
|
14
|
-
const setState = (newState: T | ((prevState: T) => T | undefined)) => {
|
|
15
|
-
if (newState instanceof Function) {
|
|
16
|
-
const value = newState(state.value);
|
|
17
|
-
|
|
18
|
-
if (value) {
|
|
19
|
-
state.next(value);
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
state.next(newState);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return state.value;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return [state.asObservable(), setState];
|
|
29
|
-
}, dependencies);
|
|
30
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = default_1;
|
|
12
13
|
const child_process_1 = require("child_process");
|
|
13
14
|
const workspace_1 = require("../cli/internal/workspace");
|
|
14
15
|
function default_1() {
|
|
@@ -23,4 +24,3 @@ function default_1() {
|
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
exports.default = default_1;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{dist → lib}/core.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{dist → lib}/module.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|