@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
|
@@ -9,7 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.mockedFunc = void 0;
|
|
13
|
+
exports.makeTestModule = makeTestModule;
|
|
14
|
+
exports.toArray = toArray;
|
|
15
|
+
exports.mockSubject = mockSubject;
|
|
13
16
|
const rxjs_1 = require("rxjs");
|
|
14
17
|
const core_1 = require("./core");
|
|
15
18
|
const module_1 = require("./module");
|
|
@@ -23,7 +26,6 @@ function makeTestModule(dependencies) {
|
|
|
23
26
|
};
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
|
-
exports.makeTestModule = makeTestModule;
|
|
27
29
|
const mockedFunc = (mockedFunc) => mockedFunc;
|
|
28
30
|
exports.mockedFunc = mockedFunc;
|
|
29
31
|
function toArray(observable) {
|
|
@@ -40,7 +42,14 @@ function toArray(observable) {
|
|
|
40
42
|
}
|
|
41
43
|
return it;
|
|
42
44
|
};
|
|
43
|
-
observable.
|
|
45
|
+
observable.subscribe({
|
|
46
|
+
next: it => array.push(clone(it)),
|
|
47
|
+
error: it => array.push(it)
|
|
48
|
+
});
|
|
44
49
|
return array;
|
|
45
50
|
}
|
|
46
|
-
|
|
51
|
+
function mockSubject(object, method) {
|
|
52
|
+
const subject = new rxjs_1.Subject();
|
|
53
|
+
jest.spyOn(object, method).mockReturnValue(subject.asObservable());
|
|
54
|
+
return subject;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,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;AAuBF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,MAQrD,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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
export declare function asReadonly<T>(): (input: Observable<T>) => Observable<Readonly<T>>;
|
|
3
|
+
export declare function defined<T>(): (observable: Observable<T | undefined | null>) => Observable<T & {}>;
|
|
4
|
+
export declare function exclude<T, S extends symbol>(s: S): (observable: Observable<T | S>) => Observable<Exclude<T, S>>;
|
|
5
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,MAAM,CAAC;AAE/C,wBAAgB,UAAU,CAAC,CAAC,aACX,UAAU,CAAC,CAAC,CAAC,6BAC7B;AAED,wBAAgB,OAAO,CAAC,CAAC,kBACH,UAAU,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,wBAErD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,gBAC3B,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,+BAKtC"}
|
package/lib/operators.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asReadonly = asReadonly;
|
|
4
|
+
exports.defined = defined;
|
|
5
|
+
exports.exclude = exclude;
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
function asReadonly() {
|
|
8
|
+
return (input) => input.pipe((0, rxjs_1.map)(it => it));
|
|
9
|
+
}
|
|
10
|
+
function defined() {
|
|
11
|
+
return (observable) => observable.pipe((0, rxjs_1.filter)(it => it !== undefined && it !== null));
|
|
12
|
+
}
|
|
13
|
+
function exclude(s) {
|
|
14
|
+
return (observable) => observable.pipe((0, rxjs_1.filter)(it => it !== s), (0, rxjs_1.map)(it => it));
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './use-replay';
|
|
2
|
+
export * from './use-replay-lock';
|
|
3
|
+
export * from './use-replay-options';
|
|
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';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
|
@@ -15,8 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./use-replay"), exports);
|
|
18
|
-
__exportStar(require("./use-replay-
|
|
18
|
+
__exportStar(require("./use-replay-lock"), exports);
|
|
19
19
|
__exportStar(require("./use-replay-options"), exports);
|
|
20
|
-
__exportStar(require("./use-replay-
|
|
21
|
-
__exportStar(require("./use-replay-
|
|
22
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./storage/use-replay-storage"), exports);
|
|
21
|
+
__exportStar(require("./storage/use-replay-storage-buffer"), exports);
|
|
22
|
+
__exportStar(require("./use-replay-manager"), exports);
|
|
23
|
+
__exportStar(require("./when-replay-finished"), exports);
|
|
24
|
+
__exportStar(require("./replay"), exports);
|
|
25
|
+
__exportStar(require("./replay-guard"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { dependency } from '../use-hash';
|
|
3
|
+
export declare function replayGuard<T extends Array<dependency>, K>(fn: (...args: T) => Observable<{
|
|
4
|
+
timestamp: number;
|
|
5
|
+
payload: K;
|
|
6
|
+
}>): (...args: T) => Observable<{
|
|
7
|
+
timestamp: number;
|
|
8
|
+
payload: K;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=replay-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-guard.d.ts","sourceRoot":"","sources":["../../src/replay/replay-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,wBAAgB,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EACxD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,GAChE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,CAE/D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replayGuard = replayGuard;
|
|
4
|
+
const use_replay_lock_1 = require("./use-replay-lock");
|
|
5
|
+
function replayGuard(fn) {
|
|
6
|
+
return (...args) => (0, use_replay_lock_1.useReplayLock)(fn(...args));
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { dependency } from '../use-hash';
|
|
3
|
+
export declare function replay<T extends Array<dependency>, K>(fn: (...args: T) => Observable<{
|
|
4
|
+
timestamp: number;
|
|
5
|
+
payload: K;
|
|
6
|
+
}>, dependencies: dependency[]): (...args: T) => Observable<{
|
|
7
|
+
timestamp: number;
|
|
8
|
+
payload: K;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/replay/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,wBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EACnD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,EACjE,YAAY,EAAE,UAAU,EAAE,GACzB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,CAE/D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replay = replay;
|
|
4
|
+
const with_memo_1 = require("../with-memo");
|
|
5
|
+
const use_replay_1 = require("./use-replay");
|
|
6
|
+
function replay(fn, dependencies) {
|
|
7
|
+
return (0, with_memo_1.withMemo)((...args) => (0, use_replay_1.useReplay)(fn(...args), [...dependencies, ...args]));
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dependency } from '../../use-hash';
|
|
2
|
+
export declare const useReplayStorageBuffer: <T>(dependencies: dependency[]) => {
|
|
3
|
+
size(): number;
|
|
4
|
+
peek(): {
|
|
5
|
+
timestamp: number;
|
|
6
|
+
payload: T;
|
|
7
|
+
};
|
|
8
|
+
dequeue(): {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
payload: T;
|
|
11
|
+
};
|
|
12
|
+
completed(): boolean;
|
|
13
|
+
fetchNextPage(): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=use-replay-storage-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-storage-buffer.d.ts","sourceRoot":"","sources":["../../../src/replay/storage/use-replay-storage-buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,eAAO,MAAM,sBAAsB,GAAa,CAAC;;;mBAMb,MAAM;iBAAW,CAAC;;;mBAAlB,MAAM;iBAAW,CAAC;;;;CAsCpD,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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.useReplayStorageBuffer = void 0;
|
|
13
|
+
const use_replay_options_1 = require("../../replay/use-replay-options");
|
|
14
|
+
const storage_1 = require("../../storage");
|
|
15
|
+
const with_memo_1 = require("../../with-memo");
|
|
16
|
+
const use_replay_storage_1 = require("./use-replay-storage");
|
|
17
|
+
exports.useReplayStorageBuffer = (0, with_memo_1.withMemo)((dependencies) => {
|
|
18
|
+
const { query } = (0, use_replay_storage_1.useReplayStorage)(dependencies);
|
|
19
|
+
const { from, to } = (0, use_replay_options_1.useReplayOptions)();
|
|
20
|
+
console.log(from, to);
|
|
21
|
+
let page = new Array();
|
|
22
|
+
let index = 0;
|
|
23
|
+
let completed = false;
|
|
24
|
+
let count = 0;
|
|
25
|
+
return {
|
|
26
|
+
size() {
|
|
27
|
+
return page.length - index;
|
|
28
|
+
},
|
|
29
|
+
peek() {
|
|
30
|
+
return page[index];
|
|
31
|
+
},
|
|
32
|
+
dequeue() {
|
|
33
|
+
return page[index++];
|
|
34
|
+
},
|
|
35
|
+
completed() {
|
|
36
|
+
return completed;
|
|
37
|
+
},
|
|
38
|
+
fetchNextPage() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (completed) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
index = 0;
|
|
44
|
+
page = yield query({
|
|
45
|
+
where: {
|
|
46
|
+
timestamp: (0, storage_1.between)(from, to)
|
|
47
|
+
},
|
|
48
|
+
limit: 10000,
|
|
49
|
+
offset: count,
|
|
50
|
+
orderBy: 'ASC'
|
|
51
|
+
});
|
|
52
|
+
count += page.length;
|
|
53
|
+
completed = page.length == 0;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dependency } from '../../use-hash';
|
|
2
|
+
export declare const useReplayStorageCursor: () => {
|
|
3
|
+
get<T>(dependencies: dependency[]): {
|
|
4
|
+
size(): number;
|
|
5
|
+
peek(): {
|
|
6
|
+
timestamp: number;
|
|
7
|
+
payload: T;
|
|
8
|
+
};
|
|
9
|
+
dequeue(): {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
payload: T;
|
|
12
|
+
};
|
|
13
|
+
completed(): boolean;
|
|
14
|
+
fetchNextPage(): Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
cursor(): Promise<{
|
|
17
|
+
size(): number;
|
|
18
|
+
peek(): {
|
|
19
|
+
timestamp: number;
|
|
20
|
+
payload: any;
|
|
21
|
+
};
|
|
22
|
+
dequeue(): {
|
|
23
|
+
timestamp: number;
|
|
24
|
+
payload: any;
|
|
25
|
+
};
|
|
26
|
+
completed(): boolean;
|
|
27
|
+
fetchNextPage(): Promise<void>;
|
|
28
|
+
} | undefined>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=use-replay-storage-cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-storage-cursor.d.ts","sourceRoot":"","sources":["../../../src/replay/storage/use-replay-storage-cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAMpD,eAAO,MAAM,sBAAsB;QAK3B,CAAC,gBAAgB,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCnC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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.useReplayStorageCursor = void 0;
|
|
13
|
+
const use_hash_1 = require("../../use-hash");
|
|
14
|
+
const use_logger_1 = require("../../use-logger");
|
|
15
|
+
const with_memo_1 = require("../../with-memo");
|
|
16
|
+
const use_replay_storage_buffer_1 = require("./use-replay-storage-buffer");
|
|
17
|
+
exports.useReplayStorageCursor = (0, with_memo_1.withMemo)(() => {
|
|
18
|
+
const { info } = (0, use_logger_1.useLogger)('useReplayStorageCursor');
|
|
19
|
+
const storages = Array.of();
|
|
20
|
+
return {
|
|
21
|
+
get(dependencies) {
|
|
22
|
+
const storage = (0, use_replay_storage_buffer_1.useReplayStorageBuffer)(dependencies);
|
|
23
|
+
if (!storages.includes(storage)) {
|
|
24
|
+
info('opening a new replay buffer', (0, use_hash_1.useHash)(dependencies));
|
|
25
|
+
storages.push(storage);
|
|
26
|
+
}
|
|
27
|
+
return storage;
|
|
28
|
+
},
|
|
29
|
+
cursor() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
let current;
|
|
32
|
+
for (const storage of storages) {
|
|
33
|
+
if (storage.completed()) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (storage.size() == 0) {
|
|
37
|
+
yield storage.fetchNextPage();
|
|
38
|
+
}
|
|
39
|
+
if (storage.peek()) {
|
|
40
|
+
if (!current || current.peek().timestamp > storage.peek().timestamp) {
|
|
41
|
+
current = storage;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return current;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Query, QueryObject } from '../../storage';
|
|
2
|
+
import { dependency } from '../../use-hash';
|
|
3
|
+
export declare function useReplayStorage<T>(dependencies: dependency[]): {
|
|
4
|
+
query(query: Query<QueryObject>): Promise<{
|
|
5
|
+
timestamp: number;
|
|
6
|
+
payload: T;
|
|
7
|
+
}[]>;
|
|
8
|
+
save(objects: {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
payload: T;
|
|
11
|
+
}[]): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=use-replay-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-storage.d.ts","sourceRoot":"","sources":["../../../src/replay/storage/use-replay-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAEpD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE;iBASvC,KAAK,CAAC,WAAW,CAAC;;iBAGE,CAAC;;kBAG1B;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC,CAAA;KAAE,EAAE;EAUpD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.useReplayStorage = useReplayStorage;
|
|
13
|
+
const storage_1 = require("../../storage");
|
|
14
|
+
const use_hash_1 = require("../../use-hash");
|
|
15
|
+
function useReplayStorage(dependencies) {
|
|
16
|
+
const storage = (0, storage_1.useStorage)(['replay']);
|
|
17
|
+
const storageObjectKey = (0, use_hash_1.useHash)(dependencies);
|
|
18
|
+
const storageObject = storage_1.Storage.createObject(storageObjectKey, {
|
|
19
|
+
timestamp: 'number',
|
|
20
|
+
payload: 'string'
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
query(query) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return (yield storage.query(storageObject, query)).map(it => ({
|
|
26
|
+
timestamp: it.timestamp,
|
|
27
|
+
payload: JSON.parse(it.payload)
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
save(objects) {
|
|
32
|
+
return storage.save(storageObject, objects.map(it => ({
|
|
33
|
+
timestamp: it.timestamp,
|
|
34
|
+
payload: JSON.stringify(it.payload)
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-storage.spec.d.ts","sourceRoot":"","sources":["../../../src/replay/storage/use-replay-storage.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
const make_test_module_1 = require("../../make-test-module");
|
|
13
|
+
const storage_1 = require("../../storage");
|
|
14
|
+
const use_replay_storage_1 = require("./use-replay-storage");
|
|
15
|
+
jest.mock('@lib/storage', () => (Object.assign(Object.assign({}, jest.requireActual('@lib/storage')), { useStorage: jest.fn() })));
|
|
16
|
+
describe(use_replay_storage_1.useReplayStorage.name, () => {
|
|
17
|
+
let fixtures;
|
|
18
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
fixtures = yield getFixtures();
|
|
20
|
+
}));
|
|
21
|
+
describe('query', () => {
|
|
22
|
+
test('happy path', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
yield fixtures.given.stored(fixtures.sample);
|
|
24
|
+
const sample = yield fixtures.when.queried({});
|
|
25
|
+
expect(sample).toEqual(fixtures.sample);
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
describe('save', () => {
|
|
29
|
+
test('happy path', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
yield fixtures.when.saved(fixtures.sample);
|
|
31
|
+
yield fixtures.then.stored(fixtures.sample);
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
function getFixtures() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { act } = yield (0, make_test_module_1.makeTestModule)([]);
|
|
38
|
+
const dependencies = ['binance:btc-usdt', 'candle', 'h1'];
|
|
39
|
+
const save = jest.fn();
|
|
40
|
+
const query = jest.fn();
|
|
41
|
+
(0, make_test_module_1.mockedFunc)(storage_1.useStorage).mockReturnValue({ save, query });
|
|
42
|
+
return {
|
|
43
|
+
sample: [
|
|
44
|
+
{ timestamp: 1, payload: { o: 1.1, h: 1.1, l: 1.1, c: 1.1 } },
|
|
45
|
+
{ timestamp: 2, payload: { o: 1.1, h: 2.2, l: 1.1, c: 2.2 } },
|
|
46
|
+
{ timestamp: 3, payload: { o: 1.1, h: 3.3, l: 1.1, c: 3.3 } }
|
|
47
|
+
],
|
|
48
|
+
given: {
|
|
49
|
+
stored(sample) {
|
|
50
|
+
return query.mockReturnValue(Promise.resolve(sample.map(it => ({
|
|
51
|
+
timestamp: it.timestamp,
|
|
52
|
+
payload: JSON.stringify(it.payload)
|
|
53
|
+
}))));
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
when: {
|
|
57
|
+
saved(sample) {
|
|
58
|
+
return act(() => (0, use_replay_storage_1.useReplayStorage)(dependencies).save(sample));
|
|
59
|
+
},
|
|
60
|
+
queried(query) {
|
|
61
|
+
return act(() => (0, use_replay_storage_1.useReplayStorage)(dependencies).query(query));
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
then: {
|
|
65
|
+
stored(sample) {
|
|
66
|
+
expect(save).toHaveBeenCalledWith(expect.anything(), sample.map(it => ({
|
|
67
|
+
timestamp: it.timestamp,
|
|
68
|
+
payload: JSON.stringify(it.payload)
|
|
69
|
+
})));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-lock.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAE,MAAM,MAAM,CAAC;AAO5C,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAqBpE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useReplayLock = useReplayLock;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const use_execution_mode_1 = require("../use-execution-mode");
|
|
6
|
+
const use_logger_1 = require("../use-logger");
|
|
7
|
+
const use_replay_manager_1 = require("./use-replay-manager");
|
|
8
|
+
function useReplayLock(input) {
|
|
9
|
+
const { isReplay } = (0, use_execution_mode_1.useExecutionMode)();
|
|
10
|
+
if (!isReplay) {
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
const { info } = (0, use_logger_1.useLogger)('replay');
|
|
14
|
+
const { stop, tryContinue } = (0, use_replay_manager_1.useReplayManager)();
|
|
15
|
+
info('lock acquired');
|
|
16
|
+
stop();
|
|
17
|
+
return input.pipe((0, rxjs_1.finalize)(() => {
|
|
18
|
+
info('lock released');
|
|
19
|
+
tryContinue();
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { dependency } from '../use-hash';
|
|
3
|
+
export declare const useReplayManager: () => {
|
|
4
|
+
stream: Observable<[{
|
|
5
|
+
size(): number;
|
|
6
|
+
peek(): {
|
|
7
|
+
timestamp: number;
|
|
8
|
+
payload: any;
|
|
9
|
+
};
|
|
10
|
+
dequeue(): {
|
|
11
|
+
timestamp: number;
|
|
12
|
+
payload: any;
|
|
13
|
+
};
|
|
14
|
+
completed(): boolean;
|
|
15
|
+
fetchNextPage(): Promise<void>;
|
|
16
|
+
}, {
|
|
17
|
+
timestamp: number;
|
|
18
|
+
payload: any;
|
|
19
|
+
}]>;
|
|
20
|
+
timestamp(): number;
|
|
21
|
+
stop(): void;
|
|
22
|
+
tryContinue: () => void;
|
|
23
|
+
watch<T>(dependencies: dependency[]): Observable<{
|
|
24
|
+
timestamp: number;
|
|
25
|
+
payload: T;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=use-replay-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-manager.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAW,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;mBAQqC,MAAM;iBAAW,GAAG;;;;;UAoD5E,CAAC,gBAAgB,UAAU,EAAE,GAAG,UAAU,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC,CAAA;KAAE,CAAC;CAarF,CAAC"}
|
|
@@ -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.useReplayManager = void 0;
|
|
13
|
+
const rxjs_1 = require("rxjs");
|
|
14
|
+
const with_memo_1 = require("../with-memo");
|
|
15
|
+
const use_replay_storage_cursor_1 = require("./storage/use-replay-storage-cursor");
|
|
16
|
+
const use_replay_options_1 = require("./use-replay-options");
|
|
17
|
+
exports.useReplayManager = (0, with_memo_1.withMemo)(() => {
|
|
18
|
+
const { from } = (0, use_replay_options_1.useReplayOptions)();
|
|
19
|
+
const { get, cursor } = (0, use_replay_storage_cursor_1.useReplayStorageCursor)();
|
|
20
|
+
let timestamp = from;
|
|
21
|
+
let stopAcquire = 1;
|
|
22
|
+
const stream$ = new rxjs_1.Subject();
|
|
23
|
+
const processNext = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const storage = yield cursor();
|
|
25
|
+
if (!storage || !storage.peek()) {
|
|
26
|
+
stream$.complete();
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const sample = storage.dequeue();
|
|
30
|
+
timestamp = sample.timestamp;
|
|
31
|
+
stream$.next([storage, sample]);
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
const next = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
if (yield processNext()) {
|
|
36
|
+
if (stopAcquire === 0) {
|
|
37
|
+
setImmediate(next);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const tryContinue = () => {
|
|
42
|
+
if (stopAcquire == 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
stopAcquire = Math.max(0, stopAcquire - 1);
|
|
46
|
+
if (stopAcquire != 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
next();
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
stream: stream$.asObservable(),
|
|
53
|
+
timestamp() {
|
|
54
|
+
return timestamp;
|
|
55
|
+
},
|
|
56
|
+
stop() {
|
|
57
|
+
stopAcquire++;
|
|
58
|
+
},
|
|
59
|
+
tryContinue,
|
|
60
|
+
watch(dependencies) {
|
|
61
|
+
const storage = get(dependencies);
|
|
62
|
+
return (0, rxjs_1.defer)(() => {
|
|
63
|
+
tryContinue();
|
|
64
|
+
return stream$.pipe((0, rxjs_1.filter)(([cur]) => cur === storage), (0, rxjs_1.map)(([, it]) => ({ timestamp: it.timestamp, payload: it.payload })));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useReplayOptions =
|
|
3
|
+
exports.useReplayOptions = void 0;
|
|
4
|
+
exports.replayOptions = replayOptions;
|
|
4
5
|
const module_1 = require("../module");
|
|
5
6
|
const injectionToken = Symbol('replay-options');
|
|
6
7
|
/**
|
|
@@ -12,7 +13,6 @@ function replayOptions(options) {
|
|
|
12
13
|
useValue: options
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
exports.replayOptions = replayOptions;
|
|
16
16
|
/**
|
|
17
17
|
* Will return current replay execution options.
|
|
18
18
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { dependency } from '../use-hash';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function useReplay<T>(input: Observable<{
|
|
4
4
|
timestamp: number;
|
|
5
5
|
payload: T;
|
|
6
|
-
}>, dependencies: dependency[])
|
|
6
|
+
}>, dependencies: dependency[]): Observable<{
|
|
7
7
|
timestamp: number;
|
|
8
8
|
payload: T;
|
|
9
9
|
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAO,MAAM,MAAM,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,wBAAgB,SAAS,CAAC,CAAC,EACzB,KAAK,EAAE,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,EACpD,YAAY,EAAE,UAAU,EAAE;eADK,MAAM;aAAW,CAAC;GAkBlD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useReplay = useReplay;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const use_execution_mode_1 = require("../use-execution-mode");
|
|
6
|
+
const use_replay_storage_1 = require("./storage/use-replay-storage");
|
|
7
|
+
const use_replay_manager_1 = require("./use-replay-manager");
|
|
8
|
+
function useReplay(input, dependencies) {
|
|
9
|
+
const { isReplay, recording } = (0, use_execution_mode_1.useExecutionMode)();
|
|
10
|
+
if (isReplay) {
|
|
11
|
+
const { watch } = (0, use_replay_manager_1.useReplayManager)();
|
|
12
|
+
return watch(dependencies);
|
|
13
|
+
}
|
|
14
|
+
if (recording) {
|
|
15
|
+
const { save } = (0, use_replay_storage_1.useReplayStorage)(dependencies);
|
|
16
|
+
return input.pipe((0, rxjs_1.tap)(it => save([it])));
|
|
17
|
+
}
|
|
18
|
+
return input;
|
|
19
|
+
}
|