@heswell/vuu-data-engine-local 0.0.0-stage → 2.0.0

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.
Files changed (81) hide show
  1. package/README.md +102 -2
  2. package/index.js +9494 -0
  3. package/package.json +37 -4
  4. package/src/ArrayProxy.d.ts +8 -0
  5. package/src/EngineDataSource.d.ts +109 -0
  6. package/src/ModuleDataSource.d.ts +41 -0
  7. package/src/RowKeys.d.ts +17 -0
  8. package/src/RuntimeVisualLink.d.ts +16 -0
  9. package/src/Table.d.ts +46 -0
  10. package/src/UpdateGenerator.d.ts +18 -0
  11. package/src/basket/BasketModule.d.ts +55 -0
  12. package/src/basket/basket-schemas.d.ts +9 -0
  13. package/src/basket/index.d.ts +2 -0
  14. package/src/basket/reference-data/constituents.d.ts +3 -0
  15. package/src/basket/reference-data/ftse100.d.ts +2 -0
  16. package/src/basket/reference-data/hsi.d.ts +2 -0
  17. package/src/basket/reference-data/nasdaq100.d.ts +2 -0
  18. package/src/basket/reference-data/prices.d.ts +24 -0
  19. package/src/basket/reference-data/sp500.d.ts +2 -0
  20. package/src/core/filter/PermissionFilter.d.ts +41 -0
  21. package/src/core/module/ModuleContainer.d.ts +15 -0
  22. package/src/core/module/VuuModule.d.ts +103 -0
  23. package/src/core/table/TableContainer.d.ts +21 -0
  24. package/src/core/user/CurrentUser.d.ts +14 -0
  25. package/src/data-utils.d.ts +7 -0
  26. package/src/default-column-definitions.d.ts +2 -0
  27. package/src/index.d.ts +19 -0
  28. package/src/local-datasource-provider/LocalDatasourceProvider.d.ts +18 -0
  29. package/src/makeSuggestions.d.ts +3 -0
  30. package/src/module-admin/ModuleAdminModule.d.ts +32 -0
  31. package/src/module-admin/index.d.ts +4 -0
  32. package/src/module-admin/module-admin-schemas.d.ts +4 -0
  33. package/src/module-admin/snapshot-projection.d.ts +13 -0
  34. package/src/notifications/NotificationModule.d.ts +39 -0
  35. package/src/notifications/NotificationsSchema.d.ts +20 -0
  36. package/src/notifications/index.d.ts +6 -0
  37. package/src/notifications/simulated/DismissNotificationRpcHandler.d.ts +8 -0
  38. package/src/notifications/simulated/SimulatedNotificationsModule.d.ts +2 -0
  39. package/src/notifications/simulated/SimulatedNotificationsProvider.d.ts +21 -0
  40. package/src/notifications/simulated/notificationsModule.d.ts +5 -0
  41. package/src/rowUpdates.d.ts +15 -0
  42. package/src/schemas.d.ts +10 -0
  43. package/src/session-table-utils.d.ts +6 -0
  44. package/src/simul/SimulModule.d.ts +24 -0
  45. package/src/simul/index.d.ts +2 -0
  46. package/src/simul/reference-data/accounts.d.ts +1 -0
  47. package/src/simul/reference-data/algos.d.ts +1 -0
  48. package/src/simul/reference-data/currencies.d.ts +1 -0
  49. package/src/simul/reference-data/index.d.ts +5 -0
  50. package/src/simul/reference-data/instrument-prices.d.ts +60 -0
  51. package/src/simul/reference-data/instruments-extended.d.ts +1 -0
  52. package/src/simul/reference-data/instruments.d.ts +35 -0
  53. package/src/simul/reference-data/isin-generator/convert-string-to-base-ten-number.d.ts +1 -0
  54. package/src/simul/reference-data/isin-generator/fixtures/alphabet.d.ts +1 -0
  55. package/src/simul/reference-data/isin-generator/fixtures/alphanumeric-values.d.ts +1 -0
  56. package/src/simul/reference-data/isin-generator/fixtures/base-ten-numbers.d.ts +1 -0
  57. package/src/simul/reference-data/isin-generator/generate-cusip-check-code.d.ts +1 -0
  58. package/src/simul/reference-data/isin-generator/generate-cusip-without-check-code.d.ts +1 -0
  59. package/src/simul/reference-data/isin-generator/generate-cusip.d.ts +1 -0
  60. package/src/simul/reference-data/isin-generator/generate-random-alphanumeric.d.ts +1 -0
  61. package/src/simul/reference-data/isin-generator/generate-random-base-ten-number.d.ts +1 -0
  62. package/src/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.d.ts +1 -0
  63. package/src/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.d.ts +1 -0
  64. package/src/simul/reference-data/isin-generator/index.d.ts +1 -0
  65. package/src/simul/reference-data/isin-generator/is-odd.d.ts +1 -0
  66. package/src/simul/reference-data/locations.d.ts +4 -0
  67. package/src/simul/reference-data/lotsizes.d.ts +1 -0
  68. package/src/simul/reference-data/orderStatus.d.ts +1 -0
  69. package/src/simul/reference-data/orders.d.ts +36 -0
  70. package/src/simul/reference-data/parent-child-orders.d.ts +4 -0
  71. package/src/simul/reference-data/priceStrategies.d.ts +1 -0
  72. package/src/simul/reference-data/prices.d.ts +34 -0
  73. package/src/simul/reference-data/sides.d.ts +1 -0
  74. package/src/simul/simul-schemas.d.ts +9 -0
  75. package/src/test/TestModule.d.ts +16 -0
  76. package/src/test/index.d.ts +1 -0
  77. package/src/user-admin/UserAdminModule.d.ts +54 -0
  78. package/src/user-admin/index.d.ts +3 -0
  79. package/src/user-admin/initialSnapshot.d.ts +2 -0
  80. package/src/user-admin/snapshot-projection.d.ts +9 -0
  81. package/src/vuu-row-generator.d.ts +17 -0
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # @heswell/vuu-data-engine-local
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A browser-hosted Vuu data layer built on the runtime-agnostic data engine packages
4
+ [`@heswell/vuu-table`](https://www.npmjs.com/package/@heswell/vuu-table) and
5
+ [`@heswell/vuu-viewport`](https://www.npmjs.com/package/@heswell/vuu-viewport). The same
6
+ engine runs in the vuu-websocket (Bun) server.
7
+
8
+ The package runs alongside `@vuu-ui/vuu-data-test` and has the same public API. It is
9
+ meant to replace the `VuuModule` / `TickingArrayDataSource` core in that package. The
10
+ two packages don't depend on each other.
11
+
12
+ ## Architecture
13
+
14
+ | Component | Role |
15
+ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
16
+ | `Table` | A façade over the engine `Table` that keeps the existing `Table` API. Inserts, updates and deletes go straight to the engine. Every change notifies subscribed viewports. |
17
+ | `TableContainer` | A registry of tables, including join tables. |
18
+ | `EngineDataSource` | A `DataSource` implementation backed by an engine `Viewport`. It handles windowing, sort, filter, groupBy, selection (including select-all), freeze, base filter, link filter and permission filter. Row updates are batched per frame. |
19
+ | `ModuleDataSource` | Extends `EngineDataSource` with the module features: RPC and menu services, edit sessions, and visual links. `TickingArrayDataSource` is a deprecated alias. |
20
+ | `VuuModule` | Creates `ModuleDataSource` instances. Row permissions are passed to the engine as a `permissionFilter` predicate. |
21
+ | `RuntimeVisualLink` | When the parent's selection changes, sets the child's engine link filter. |
22
+ | `UpdateGenerator` / `TickingGenerator` | Simulated ticking data that writes into the engine tables. |
23
+
24
+ ## Differences from `@vuu-ui/vuu-data-test`
25
+
26
+ - `PermissionFilteredTable` has been removed. Use the `permissionFilter` predicate on the data source instead.
27
+ - Visual links use the engine link filter, so the client no longer filters rows by selection.
28
+ - Grouped rows are only available from `getRowAtIndex` when they fall within the client range. Flat rows are available at any index.
29
+ - Re-inserting a row with an existing key updates that row.
30
+ - Table keys must not be empty.
31
+
32
+ ## Running the vuu showcase against the engine
33
+
34
+ In the finos/vuu `vuu-ui` workspace:
35
+
36
+ ```sh
37
+ npm run showcase:engine # equivalent to: VUU_DATA_ENGINE=local npm run showcase
38
+ ```
39
+
40
+ This aliases `@vuu-ui/vuu-data-test` to `@heswell/vuu-data-engine-local` in the showcase
41
+ rsbuild config. The examples themselves don't change.
42
+
43
+ The showcase uses the published package. To publish it from vuu-websocket:
44
+
45
+ ```sh
46
+ npm run pub -- --package=@heswell/vuu-data-engine-local --tag alpha
47
+ ```
48
+
49
+ ## Performance
50
+
51
+ `bench/datasource.bench.ts` compares the legacy `TickingArrayDataSource`
52
+ (`@vuu-ui/vuu-data-test`) with the engine `ModuleDataSource` on the same data and scenarios.
53
+ `@vuu-ui/vuu-data-test` is a dev dependency, used only for this comparison.
54
+
55
+ ```sh
56
+ npm run bench:data-engine-local # 100k rows
57
+ BENCH_ROWS=10000 npm run bench:data-engine-local # smaller run
58
+ ```
59
+
60
+ `requestAnimationFrame` is made synchronous during the bench, so each timing includes delivering
61
+ rows to the client. The bench runs under vitest (Node) using `vitest.config.ts` in this
62
+ package; the tests run under `bun test`. `test/LegacyParity.test.ts` checks that both implementations give the same
63
+ results for the sort, filter and groupBy scenarios.
64
+
65
+ Mean time per operation, 100k rows, Node 24, Apple Silicon:
66
+
67
+ | Scenario | legacy | engine | speed-up |
68
+ | --------------------------------------------- | -------- | ------- | -------- |
69
+ | create + subscribe | 24.1 ms | 8.7 ms | 2.8x |
70
+ | sort numeric column | 62.1 ms | 14.1 ms | 4.4x |
71
+ | sort two columns | 64.6 ms | 17.1 ms | 3.8x |
72
+ | filter | 5.7 ms | 1.3 ms | 4.3x |
73
+ | groupBy ccy, set/clear | 1.6 ms | 1.2 ms | 1.3x |
74
+ | groupBy ccy + exchange, set/clear | 2.2 ms | 2.0 ms | 1.1x |
75
+ | scroll, 100 range changes | 0.82 ms | 0.45 ms | 1.8x |
76
+ | 1000 ticks, random rows | 1543 ms | 0.35 ms | ~4400x |
77
+ | 1000 ticks, rows in viewport | 0.63 ms | 0.10 ms | 6.6x |
78
+ | 1000 ticks, sorted column | 3012 ms | 1.9 ms | ~1600x |
79
+ | 1000 ticks, filtered column | 1903 ms | 0.55 ms | ~3400x |
80
+ | 1000 ticks, grouped | 1205 ms | 0.39 ms | ~3100x |
81
+ | 500 deletes + 500 inserts | 1628 ms | 0.60 ms | ~2700x |
82
+ | 500 deletes + 500 inserts, sorted | 2564 ms | 1.57 ms | ~1600x |
83
+
84
+ Notes:
85
+
86
+ - The legacy update path finds each row with a linear search, so per-update cost grows with
87
+ table size. The engine uses keyed lookup and sends each changed row once.
88
+ - On updates, legacy does not re-sort or re-filter rows. The engine does, so the tick
89
+ comparisons understate the engine's advantage.
90
+ - Scrolling: the engine uses an array-backed row key allocator (`RowKeys`) and prunes its row
91
+ cache incrementally, so range changes cost in proportion to the rows entering or leaving the range.
92
+
93
+ ## Tests
94
+
95
+ ```sh
96
+ bun test packages/vuu-data-engine-local
97
+ ```
98
+
99
+ The tests previously ran under vitest with happy-dom. Under `bun test`, `test/browser-globals.ts`
100
+ provides `requestAnimationFrame` and `window`, and `test/happy-dom.ts` registers a DOM for the
101
+ React test only.
102
+
103
+ `test/EngineDataSource.test.ts` holds the conformance tests for the engine-backed data source.