@vuu-ui/vuu-data-test 2.1.17 → 2.1.19-beta.1

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 (218) hide show
  1. package/package.json +9 -11
  2. package/types/TickingArrayDataSource.d.ts +1 -1
  3. package/types/basket/BasketModule.d.ts +9 -9
  4. package/types/basket/reference-data/prices.d.ts +1 -1
  5. package/types/core/module/VuuModule.d.ts +1 -1
  6. package/types/simul/reference-data/instruments-extended.d.ts +1 -1
  7. package/types/simul/reference-data/instruments.d.ts +1 -1
  8. package/types/simul/reference-data/orders.d.ts +1 -1
  9. package/types/simul/reference-data/parent-child-orders.d.ts +2 -2
  10. package/types/simul/reference-data/prices.d.ts +1 -1
  11. package/cjs/ArrayProxy.js +0 -72
  12. package/cjs/ArrayProxy.js.map +0 -1
  13. package/cjs/RuntimeVisualLink.js +0 -73
  14. package/cjs/RuntimeVisualLink.js.map +0 -1
  15. package/cjs/SessionTable.js +0 -68
  16. package/cjs/SessionTable.js.map +0 -1
  17. package/cjs/Table.js +0 -128
  18. package/cjs/Table.js.map +0 -1
  19. package/cjs/TickingArrayDataSource.js +0 -316
  20. package/cjs/TickingArrayDataSource.js.map +0 -1
  21. package/cjs/UpdateGenerator.js +0 -94
  22. package/cjs/UpdateGenerator.js.map +0 -1
  23. package/cjs/basket/BasketModule.js +0 -282
  24. package/cjs/basket/BasketModule.js.map +0 -1
  25. package/cjs/basket/basket-schemas.js +0 -123
  26. package/cjs/basket/basket-schemas.js.map +0 -1
  27. package/cjs/basket/reference-data/constituents.js +0 -40
  28. package/cjs/basket/reference-data/constituents.js.map +0 -1
  29. package/cjs/basket/reference-data/ftse100.js +0 -105
  30. package/cjs/basket/reference-data/ftse100.js.map +0 -1
  31. package/cjs/basket/reference-data/hsi.js +0 -87
  32. package/cjs/basket/reference-data/hsi.js.map +0 -1
  33. package/cjs/basket/reference-data/nasdaq100.js +0 -108
  34. package/cjs/basket/reference-data/nasdaq100.js.map +0 -1
  35. package/cjs/basket/reference-data/sp500.js +0 -46
  36. package/cjs/basket/reference-data/sp500.js.map +0 -1
  37. package/cjs/core/module/ModuleContainer.js +0 -43
  38. package/cjs/core/module/ModuleContainer.js.map +0 -1
  39. package/cjs/core/module/VuuModule.js +0 -649
  40. package/cjs/core/module/VuuModule.js.map +0 -1
  41. package/cjs/core/table/TableContainer.js +0 -139
  42. package/cjs/core/table/TableContainer.js.map +0 -1
  43. package/cjs/data-utils.js +0 -47
  44. package/cjs/data-utils.js.map +0 -1
  45. package/cjs/index.js +0 -46
  46. package/cjs/index.js.map +0 -1
  47. package/cjs/local-datasource-provider/LocalDatasourceProvider.js +0 -70
  48. package/cjs/local-datasource-provider/LocalDatasourceProvider.js.map +0 -1
  49. package/cjs/makeSuggestions.js +0 -26
  50. package/cjs/makeSuggestions.js.map +0 -1
  51. package/cjs/schemas.js +0 -28
  52. package/cjs/schemas.js.map +0 -1
  53. package/cjs/session-table-utils.js +0 -12
  54. package/cjs/session-table-utils.js.map +0 -1
  55. package/cjs/simul/SimulModule.js +0 -187
  56. package/cjs/simul/SimulModule.js.map +0 -1
  57. package/cjs/simul/reference-data/accounts.js +0 -27
  58. package/cjs/simul/reference-data/accounts.js.map +0 -1
  59. package/cjs/simul/reference-data/algos.js +0 -6
  60. package/cjs/simul/reference-data/algos.js.map +0 -1
  61. package/cjs/simul/reference-data/currencies.js +0 -6
  62. package/cjs/simul/reference-data/currencies.js.map +0 -1
  63. package/cjs/simul/reference-data/instruments-extended.js +0 -19
  64. package/cjs/simul/reference-data/instruments-extended.js.map +0 -1
  65. package/cjs/simul/reference-data/instruments.js +0 -85
  66. package/cjs/simul/reference-data/instruments.js.map +0 -1
  67. package/cjs/simul/reference-data/isin-generator/convert-string-to-base-ten-number.js +0 -6
  68. package/cjs/simul/reference-data/isin-generator/convert-string-to-base-ten-number.js.map +0 -1
  69. package/cjs/simul/reference-data/isin-generator/fixtures/alphabet.js +0 -31
  70. package/cjs/simul/reference-data/isin-generator/fixtures/alphabet.js.map +0 -1
  71. package/cjs/simul/reference-data/isin-generator/fixtures/alphanumeric-values.js +0 -9
  72. package/cjs/simul/reference-data/isin-generator/fixtures/alphanumeric-values.js.map +0 -1
  73. package/cjs/simul/reference-data/isin-generator/fixtures/base-ten-numbers.js +0 -17
  74. package/cjs/simul/reference-data/isin-generator/fixtures/base-ten-numbers.js.map +0 -1
  75. package/cjs/simul/reference-data/isin-generator/generate-cusip-check-code.js +0 -24
  76. package/cjs/simul/reference-data/isin-generator/generate-cusip-check-code.js.map +0 -1
  77. package/cjs/simul/reference-data/isin-generator/generate-cusip-without-check-code.js +0 -13
  78. package/cjs/simul/reference-data/isin-generator/generate-cusip-without-check-code.js.map +0 -1
  79. package/cjs/simul/reference-data/isin-generator/generate-cusip.js +0 -13
  80. package/cjs/simul/reference-data/isin-generator/generate-cusip.js.map +0 -1
  81. package/cjs/simul/reference-data/isin-generator/generate-random-alphanumeric.js +0 -8
  82. package/cjs/simul/reference-data/isin-generator/generate-random-alphanumeric.js.map +0 -1
  83. package/cjs/simul/reference-data/isin-generator/generate-random-base-ten-number.js +0 -6
  84. package/cjs/simul/reference-data/isin-generator/generate-random-base-ten-number.js.map +0 -1
  85. package/cjs/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.js +0 -14
  86. package/cjs/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.js.map +0 -1
  87. package/cjs/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.js +0 -14
  88. package/cjs/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.js.map +0 -1
  89. package/cjs/simul/reference-data/isin-generator/index.js +0 -295
  90. package/cjs/simul/reference-data/isin-generator/index.js.map +0 -1
  91. package/cjs/simul/reference-data/isin-generator/is-odd.js +0 -6
  92. package/cjs/simul/reference-data/isin-generator/is-odd.js.map +0 -1
  93. package/cjs/simul/reference-data/locations.js +0 -17
  94. package/cjs/simul/reference-data/locations.js.map +0 -1
  95. package/cjs/simul/reference-data/lotsizes.js +0 -28
  96. package/cjs/simul/reference-data/lotsizes.js.map +0 -1
  97. package/cjs/simul/reference-data/orderStatus.js +0 -6
  98. package/cjs/simul/reference-data/orderStatus.js.map +0 -1
  99. package/cjs/simul/reference-data/orders.js +0 -55
  100. package/cjs/simul/reference-data/orders.js.map +0 -1
  101. package/cjs/simul/reference-data/parent-child-orders.js +0 -144
  102. package/cjs/simul/reference-data/parent-child-orders.js.map +0 -1
  103. package/cjs/simul/reference-data/prices.js +0 -89
  104. package/cjs/simul/reference-data/prices.js.map +0 -1
  105. package/cjs/simul/reference-data/sides.js +0 -6
  106. package/cjs/simul/reference-data/sides.js.map +0 -1
  107. package/cjs/simul/simul-schemas.js +0 -150
  108. package/cjs/simul/simul-schemas.js.map +0 -1
  109. package/cjs/test/TestModule.js +0 -86
  110. package/cjs/test/TestModule.js.map +0 -1
  111. package/cjs/test/test-schemas.js +0 -52
  112. package/cjs/test/test-schemas.js.map +0 -1
  113. package/cjs/vuu-row-generator.js +0 -74
  114. package/cjs/vuu-row-generator.js.map +0 -1
  115. package/esm/ArrayProxy.js +0 -70
  116. package/esm/ArrayProxy.js.map +0 -1
  117. package/esm/RuntimeVisualLink.js +0 -71
  118. package/esm/RuntimeVisualLink.js.map +0 -1
  119. package/esm/SessionTable.js +0 -65
  120. package/esm/SessionTable.js.map +0 -1
  121. package/esm/Table.js +0 -124
  122. package/esm/Table.js.map +0 -1
  123. package/esm/TickingArrayDataSource.js +0 -314
  124. package/esm/TickingArrayDataSource.js.map +0 -1
  125. package/esm/UpdateGenerator.js +0 -92
  126. package/esm/UpdateGenerator.js.map +0 -1
  127. package/esm/basket/BasketModule.js +0 -278
  128. package/esm/basket/BasketModule.js.map +0 -1
  129. package/esm/basket/basket-schemas.js +0 -120
  130. package/esm/basket/basket-schemas.js.map +0 -1
  131. package/esm/basket/reference-data/constituents.js +0 -38
  132. package/esm/basket/reference-data/constituents.js.map +0 -1
  133. package/esm/basket/reference-data/ftse100.js +0 -103
  134. package/esm/basket/reference-data/ftse100.js.map +0 -1
  135. package/esm/basket/reference-data/hsi.js +0 -85
  136. package/esm/basket/reference-data/hsi.js.map +0 -1
  137. package/esm/basket/reference-data/nasdaq100.js +0 -106
  138. package/esm/basket/reference-data/nasdaq100.js.map +0 -1
  139. package/esm/basket/reference-data/sp500.js +0 -44
  140. package/esm/basket/reference-data/sp500.js.map +0 -1
  141. package/esm/core/module/ModuleContainer.js +0 -41
  142. package/esm/core/module/ModuleContainer.js.map +0 -1
  143. package/esm/core/module/VuuModule.js +0 -647
  144. package/esm/core/module/VuuModule.js.map +0 -1
  145. package/esm/core/table/TableContainer.js +0 -137
  146. package/esm/core/table/TableContainer.js.map +0 -1
  147. package/esm/data-utils.js +0 -43
  148. package/esm/data-utils.js.map +0 -1
  149. package/esm/index.js +0 -16
  150. package/esm/index.js.map +0 -1
  151. package/esm/local-datasource-provider/LocalDatasourceProvider.js +0 -68
  152. package/esm/local-datasource-provider/LocalDatasourceProvider.js.map +0 -1
  153. package/esm/makeSuggestions.js +0 -24
  154. package/esm/makeSuggestions.js.map +0 -1
  155. package/esm/schemas.js +0 -24
  156. package/esm/schemas.js.map +0 -1
  157. package/esm/session-table-utils.js +0 -10
  158. package/esm/session-table-utils.js.map +0 -1
  159. package/esm/simul/SimulModule.js +0 -184
  160. package/esm/simul/SimulModule.js.map +0 -1
  161. package/esm/simul/reference-data/accounts.js +0 -25
  162. package/esm/simul/reference-data/accounts.js.map +0 -1
  163. package/esm/simul/reference-data/algos.js +0 -4
  164. package/esm/simul/reference-data/algos.js.map +0 -1
  165. package/esm/simul/reference-data/currencies.js +0 -4
  166. package/esm/simul/reference-data/currencies.js.map +0 -1
  167. package/esm/simul/reference-data/instruments-extended.js +0 -17
  168. package/esm/simul/reference-data/instruments-extended.js.map +0 -1
  169. package/esm/simul/reference-data/instruments.js +0 -80
  170. package/esm/simul/reference-data/instruments.js.map +0 -1
  171. package/esm/simul/reference-data/isin-generator/convert-string-to-base-ten-number.js +0 -4
  172. package/esm/simul/reference-data/isin-generator/convert-string-to-base-ten-number.js.map +0 -1
  173. package/esm/simul/reference-data/isin-generator/fixtures/alphabet.js +0 -29
  174. package/esm/simul/reference-data/isin-generator/fixtures/alphabet.js.map +0 -1
  175. package/esm/simul/reference-data/isin-generator/fixtures/alphanumeric-values.js +0 -7
  176. package/esm/simul/reference-data/isin-generator/fixtures/alphanumeric-values.js.map +0 -1
  177. package/esm/simul/reference-data/isin-generator/fixtures/base-ten-numbers.js +0 -15
  178. package/esm/simul/reference-data/isin-generator/fixtures/base-ten-numbers.js.map +0 -1
  179. package/esm/simul/reference-data/isin-generator/generate-cusip-check-code.js +0 -22
  180. package/esm/simul/reference-data/isin-generator/generate-cusip-check-code.js.map +0 -1
  181. package/esm/simul/reference-data/isin-generator/generate-cusip-without-check-code.js +0 -11
  182. package/esm/simul/reference-data/isin-generator/generate-cusip-without-check-code.js.map +0 -1
  183. package/esm/simul/reference-data/isin-generator/generate-cusip.js +0 -11
  184. package/esm/simul/reference-data/isin-generator/generate-cusip.js.map +0 -1
  185. package/esm/simul/reference-data/isin-generator/generate-random-alphanumeric.js +0 -6
  186. package/esm/simul/reference-data/isin-generator/generate-random-alphanumeric.js.map +0 -1
  187. package/esm/simul/reference-data/isin-generator/generate-random-base-ten-number.js +0 -4
  188. package/esm/simul/reference-data/isin-generator/generate-random-base-ten-number.js.map +0 -1
  189. package/esm/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.js +0 -12
  190. package/esm/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.js.map +0 -1
  191. package/esm/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.js +0 -12
  192. package/esm/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.js.map +0 -1
  193. package/esm/simul/reference-data/isin-generator/index.js +0 -293
  194. package/esm/simul/reference-data/isin-generator/index.js.map +0 -1
  195. package/esm/simul/reference-data/isin-generator/is-odd.js +0 -4
  196. package/esm/simul/reference-data/isin-generator/is-odd.js.map +0 -1
  197. package/esm/simul/reference-data/locations.js +0 -14
  198. package/esm/simul/reference-data/locations.js.map +0 -1
  199. package/esm/simul/reference-data/lotsizes.js +0 -26
  200. package/esm/simul/reference-data/lotsizes.js.map +0 -1
  201. package/esm/simul/reference-data/orderStatus.js +0 -4
  202. package/esm/simul/reference-data/orderStatus.js.map +0 -1
  203. package/esm/simul/reference-data/orders.js +0 -52
  204. package/esm/simul/reference-data/orders.js.map +0 -1
  205. package/esm/simul/reference-data/parent-child-orders.js +0 -139
  206. package/esm/simul/reference-data/parent-child-orders.js.map +0 -1
  207. package/esm/simul/reference-data/prices.js +0 -86
  208. package/esm/simul/reference-data/prices.js.map +0 -1
  209. package/esm/simul/reference-data/sides.js +0 -4
  210. package/esm/simul/reference-data/sides.js.map +0 -1
  211. package/esm/simul/simul-schemas.js +0 -147
  212. package/esm/simul/simul-schemas.js.map +0 -1
  213. package/esm/test/TestModule.js +0 -84
  214. package/esm/test/TestModule.js.map +0 -1
  215. package/esm/test/test-schemas.js +0 -50
  216. package/esm/test/test-schemas.js.map +0 -1
  217. package/esm/vuu-row-generator.js +0 -68
  218. package/esm/vuu-row-generator.js.map +0 -1
@@ -1,649 +0,0 @@
1
- 'use strict';
2
-
3
- var vuuUtils = require('@vuu-ui/vuu-utils');
4
- var Table = require('../../Table.js');
5
- var SessionTable = require('../../SessionTable.js');
6
- var TickingArrayDataSource = require('../../TickingArrayDataSource.js');
7
- var RuntimeVisualLink = require('../../RuntimeVisualLink.js');
8
- var ModuleContainer = require('./ModuleContainer.js');
9
- var sessionTableUtils = require('../../session-table-utils.js');
10
-
11
- var __defProp = Object.defineProperty;
12
- var __typeError = (msg) => {
13
- throw TypeError(msg);
14
- };
15
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
17
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
18
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
19
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
20
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
21
- var _name, _runtimeVisualLinks, _sessionTableMap, _tableServices, _subscriptionMap, _moduleServices, _moduleMenuServices;
22
- const assertUpdateIsValid = (schema, column, data) => {
23
- const col = schema.columns.find((col2) => col2.name === column);
24
- if (col) {
25
- console.log(`data type ${col.serverDataType} data ${data}`);
26
- } else {
27
- throw Error(
28
- `schema for table ${schema.table.table} does not include column ${column}`
29
- );
30
- }
31
- };
32
- class VuuModule {
33
- constructor(name) {
34
- __privateAdd(this, _name);
35
- __privateAdd(this, _runtimeVisualLinks, /* @__PURE__ */ new Map());
36
- __privateAdd(this, _sessionTableMap, {});
37
- __privateAdd(this, _tableServices);
38
- __privateAdd(this, _subscriptionMap, /* @__PURE__ */ new Map());
39
- __publicField(this, "handlePostSubscribeActivities", ({
40
- clientViewportId,
41
- tableSchema
42
- }) => {
43
- const visualLinks = this.getVisualLinks(tableSchema.table.table);
44
- const { dataSource } = this.getSubscriptionByViewport(clientViewportId);
45
- requestAnimationFrame(() => {
46
- dataSource.links = visualLinks;
47
- });
48
- if (this.visualLinks && dataSource.tableSchema) {
49
- const {
50
- table: { table: sourceTable }
51
- } = dataSource.tableSchema;
52
- for (const [table, links] of Object.entries(
53
- this.visualLinks
54
- )) {
55
- if (links) {
56
- const potentialTargets = links.filter(
57
- (l) => l.toTable === sourceTable
58
- );
59
- if (potentialTargets.length) {
60
- for (const subscriptions of __privateGet(this, _subscriptionMap).values()) {
61
- for (const { dataSource: dataSource2 } of subscriptions) {
62
- if (dataSource2.tableSchema?.table.table === table) {
63
- dataSource2.links = this.getVisualLinks(table);
64
- }
65
- }
66
- }
67
- }
68
- }
69
- }
70
- }
71
- });
72
- __publicField(this, "unregisterViewport", (viewportId) => {
73
- const { dataSource } = this.getSubscriptionByViewport(viewportId);
74
- const tableName = dataSource.tableSchema?.table.table;
75
- if (tableName) {
76
- const subscriptionsForTable = __privateGet(this, _subscriptionMap).get(tableName);
77
- if (subscriptionsForTable) {
78
- for (const { viewportId: vp } of subscriptionsForTable) {
79
- if (vp === viewportId) {
80
- if (subscriptionsForTable.length === 1) {
81
- __privateGet(this, _subscriptionMap).delete(tableName);
82
- } else {
83
- __privateGet(this, _subscriptionMap).set(
84
- tableName,
85
- subscriptionsForTable.filter(
86
- (s) => s.viewportId !== viewportId
87
- )
88
- );
89
- }
90
- }
91
- }
92
- }
93
- }
94
- for (const [tableName2, subscriptions] of __privateGet(this, _subscriptionMap)) {
95
- if (subscriptions[0].viewportId.toString() === viewportId) {
96
- __privateGet(this, _subscriptionMap).delete(tableName2);
97
- }
98
- }
99
- if (this.visualLinks && dataSource.tableSchema) {
100
- const {
101
- table: { table: sourceTable }
102
- } = dataSource.tableSchema;
103
- for (const [table, links] of Object.entries(
104
- this.visualLinks
105
- )) {
106
- if (links) {
107
- const potentialTargets = links.filter(
108
- (l) => l.toTable === sourceTable
109
- );
110
- if (potentialTargets.length) {
111
- for (const subscriptions of __privateGet(this, _subscriptionMap).values()) {
112
- for (const { dataSource: dataSource2 } of subscriptions) {
113
- if (dataSource2.tableSchema?.table.table === table) {
114
- dataSource2.links = this.getVisualLinks(table);
115
- }
116
- }
117
- }
118
- }
119
- }
120
- }
121
- }
122
- });
123
- __publicField(this, "getLinks", (subscriptionMap, vuuLinks) => {
124
- const visualLinks = [];
125
- for (let i = 0; i < vuuLinks.length; i++) {
126
- const subscriptions = subscriptionMap.get(vuuLinks[i].toTable);
127
- if (subscriptions) {
128
- subscriptions.forEach(({ viewportId, dataSource: { status } }) => {
129
- if (status !== "suspended") {
130
- const newLink = {
131
- parentClientVpId: viewportId,
132
- parentVpId: viewportId,
133
- link: vuuLinks[i]
134
- };
135
- visualLinks.push(newLink);
136
- }
137
- });
138
- }
139
- }
140
- return visualLinks;
141
- });
142
- __publicField(this, "visualLinkService", (message) => new Promise((resolve) => {
143
- if (message.type === "CREATE_VISUAL_LINK") {
144
- const { childColumnName, childVpId, parentColumnName, parentVpId } = message;
145
- const childDataSource = this.getSubscribedDataSource(childVpId);
146
- const parentDataSource = this.getSubscribedDataSource(parentVpId);
147
- const runtimeVisualLink = new RuntimeVisualLink.RuntimeVisualLink(
148
- childDataSource,
149
- parentDataSource,
150
- childColumnName,
151
- parentColumnName
152
- );
153
- __privateGet(this, _runtimeVisualLinks).set(childVpId, runtimeVisualLink);
154
- resolve({
155
- clientViewportId: childVpId,
156
- colName: childColumnName,
157
- parentColName: parentColumnName,
158
- parentViewportId: parentVpId,
159
- type: "vuu-link-created"
160
- });
161
- } else {
162
- const runtimeVisualLink = __privateGet(this, _runtimeVisualLinks).get(
163
- message.childVpId
164
- );
165
- if (runtimeVisualLink) {
166
- runtimeVisualLink.remove();
167
- __privateGet(this, _runtimeVisualLinks).delete(message.childVpId);
168
- } else {
169
- throw Error(
170
- `visualLinkService no visual link found for viewport #${message.childVpId}`
171
- );
172
- }
173
- resolve();
174
- }
175
- }));
176
- __publicField(this, "getVisualLinks", (tableName) => {
177
- const linksForTable = this.visualLinks?.[tableName];
178
- return linksForTable === void 0 ? void 0 : this.getLinks(__privateGet(this, _subscriptionMap), linksForTable);
179
- });
180
- __publicField(this, "createDataSource", (tableName, viewport, config) => {
181
- const columnDescriptors = this.getColumnDescriptors(tableName);
182
- const table = this.tables[tableName];
183
- const sessionTable = __privateGet(this, _sessionTableMap)[tableName];
184
- const vuuModule = this;
185
- const dataSource = new TickingArrayDataSource.TickingArrayDataSource({
186
- ...config,
187
- columnDescriptors,
188
- getVisualLinks: this.getVisualLinks,
189
- keyColumn: this.schemas[tableName] === void 0 ? __privateGet(this, _sessionTableMap)[tableName].schema.key : this.schemas[tableName].key,
190
- table: table || sessionTable,
191
- menu: this.menus?.[tableName],
192
- rpcServices: this.getServices(tableName),
193
- rpcMenuServices: this.getMenuServices(tableName),
194
- sessionTables: __privateGet(this, _sessionTableMap),
195
- viewport,
196
- visualLinkService: this.visualLinkService,
197
- vuuModule
198
- });
199
- dataSource.on("subscribed", this.handlePostSubscribeActivities);
200
- dataSource.on("unsubscribed", this.unregisterViewport);
201
- const existingSubscriptions = __privateGet(this, _subscriptionMap).get(tableName);
202
- const subscription = {
203
- viewportId: dataSource.viewport,
204
- dataSource
205
- };
206
- if (existingSubscriptions) {
207
- existingSubscriptions.push(subscription);
208
- } else {
209
- __privateGet(this, _subscriptionMap).set(tableName, [subscription]);
210
- }
211
- return dataSource;
212
- });
213
- __publicField(this, "deleteRow", async (rpcRequest) => {
214
- if (rpcRequest.context.type === "VIEWPORT_CONTEXT") {
215
- const { viewPortId } = rpcRequest.context;
216
- const { key } = rpcRequest.params;
217
- const sessionTable = this.getSessionTable(viewPortId, false);
218
- if (sessionTable) {
219
- sessionTable.delete(key);
220
- return {
221
- type: "SUCCESS_RESULT",
222
- data: void 0
223
- };
224
- } else {
225
- const { dataSource } = this.getSubscriptionByViewport(viewPortId);
226
- if (dataSource.table) {
227
- const table = this.tables[dataSource.table.table];
228
- if (table) {
229
- table.delete(key);
230
- return {
231
- type: "SUCCESS_RESULT",
232
- data: void 0
233
- };
234
- }
235
- }
236
- }
237
- }
238
- return {
239
- type: "ERROR_RESULT",
240
- errorMessage: "something went wrong"
241
- };
242
- });
243
- __publicField(this, "editCell", async (rpcRequest) => {
244
- if (vuuUtils.isEditCellRpcRequest(rpcRequest)) {
245
- const { viewPortId } = rpcRequest.context;
246
- const { column, data, key } = rpcRequest.params;
247
- let targetTable = __privateGet(this, _sessionTableMap)[viewPortId];
248
- if (!targetTable) {
249
- const { dataSource } = this.getSubscriptionByViewport(viewPortId);
250
- if (dataSource.table) {
251
- targetTable = this.tables[dataSource.table.table];
252
- }
253
- }
254
- if (targetTable) {
255
- try {
256
- assertUpdateIsValid(targetTable.schema, column, data);
257
- targetTable.update(key, column, data);
258
- return {
259
- type: "SUCCESS_RESULT",
260
- data: void 0
261
- };
262
- } catch (e) {
263
- const { message } = e;
264
- return {
265
- type: "ERROR_RESULT",
266
- errorMessage: message
267
- };
268
- }
269
- } else {
270
- throw Error("[VuuModule] editCell unable to find table for dataSource");
271
- }
272
- } else {
273
- throw Error(`[VuuModule] editCell invalid rpc type`);
274
- }
275
- });
276
- __publicField(this, "beginEditSessionMenuHandler", async ({
277
- rpcName,
278
- type,
279
- vpId
280
- }) => {
281
- if (type === "VIEW_PORT_MENUS_SELECT_RPC") {
282
- console.log(`rpcName ${rpcName}`);
283
- const result = await this.beginEditSession({
284
- context: {
285
- type: "VIEWPORT_CONTEXT",
286
- viewPortId: vpId
287
- },
288
- params: {
289
- editSessionMode: "selected-rows"
290
- },
291
- rpcName,
292
- type: "RPC_REQUEST"
293
- });
294
- if (vuuUtils.isRpcSuccess(result)) {
295
- const { table } = result.data;
296
- return {
297
- type: "VIEW_PORT_MENU_RESP",
298
- rpcName,
299
- action: {
300
- renderComponent: "grid",
301
- type: "OPEN_DIALOG_ACTION",
302
- table
303
- },
304
- vpId
305
- };
306
- } else {
307
- return {
308
- error: result.errorMessage,
309
- rpcName,
310
- type: "VIEW_PORT_MENU_REJ",
311
- vpId
312
- };
313
- }
314
- } else {
315
- return {
316
- error: "no can do",
317
- rpcName,
318
- type: "VIEW_PORT_MENU_REJ",
319
- vpId
320
- };
321
- }
322
- });
323
- __publicField(this, "beginEditSession", async (rpcRequest) => {
324
- if (vuuUtils.isBeginEditSessionRpcRequest(rpcRequest)) {
325
- const { viewPortId } = rpcRequest.context;
326
- const { editSessionMode = "inline-all-rows" } = rpcRequest.params;
327
- const subscription = this.getSubscriptionByViewport(viewPortId);
328
- const { dataSource } = subscription;
329
- const { table: vuuTable } = dataSource;
330
- if (vuuTable) {
331
- const sourceTable = this.tables[vuuTable.table];
332
- if (sourceTable) {
333
- const sessionTableName = `session-${vuuUtils.uuid()}`;
334
- try {
335
- const sessionTable = this.createSessionTable(
336
- sourceTable,
337
- sessionTableName,
338
- editSessionMode,
339
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
340
- // @ts-ignore
341
- dataSource
342
- );
343
- __privateGet(this, _sessionTableMap)[sessionTableName] = sessionTable;
344
- subscription.sessionTableName = sessionTableName;
345
- return {
346
- data: {
347
- renderComponent: "inline-form",
348
- table: {
349
- module: vuuTable.module,
350
- table: sessionTableName
351
- }
352
- },
353
- type: "SUCCESS_RESULT"
354
- };
355
- } catch (e) {
356
- return {
357
- type: "ERROR_RESULT",
358
- errorMessage: e.message
359
- };
360
- }
361
- }
362
- }
363
- } else {
364
- throw Error(`[VuuModule] endEditSession invalid rpc type`);
365
- }
366
- return {
367
- type: "ERROR_RESULT",
368
- errorMessage: "not implemented yet"
369
- };
370
- });
371
- __publicField(this, "addRow", async (rpcRequest) => {
372
- if (vuuUtils.isAddRowRpcRequest(rpcRequest)) {
373
- const { viewPortId } = rpcRequest.context;
374
- const subscription = this.getSubscriptionByViewport(viewPortId);
375
- const sessionTable = subscription.sessionTableName ? __privateGet(this, _sessionTableMap)[subscription.sessionTableName] : void 0;
376
- if (!sessionTable) {
377
- return {
378
- type: "ERROR_RESULT",
379
- errorMessage: `addRow: no active session table for viewport ${viewPortId}`
380
- };
381
- }
382
- const { data } = rpcRequest.params;
383
- const columnMap = sessionTable.map;
384
- const columnCount = Object.keys(columnMap).length;
385
- const row = new Array(columnCount).fill("");
386
- for (const [col, idx] of Object.entries(columnMap)) {
387
- if (data[col] !== void 0) {
388
- row[idx] = data[col];
389
- }
390
- }
391
- sessionTable.insert(row);
392
- return { type: "SUCCESS_RESULT", data: void 0 };
393
- }
394
- return {
395
- type: "ERROR_RESULT",
396
- errorMessage: "addRow: invalid rpc context"
397
- };
398
- });
399
- __publicField(this, "endEditSession", async (rpcRequest) => {
400
- if (vuuUtils.isEndEditSessionRpcRequest(rpcRequest)) {
401
- const { viewPortId } = rpcRequest.context;
402
- const sessionTable = __privateGet(this, _sessionTableMap)[viewPortId];
403
- delete __privateGet(this, _sessionTableMap)[viewPortId];
404
- const { dataSource } = this.getSubscriptionByViewport(viewPortId);
405
- if (dataSource.table) {
406
- const sourceTable = this.tables[dataSource.table.table];
407
- if (rpcRequest.params.save === true) {
408
- let rejectedCount = 0;
409
- if (SessionTable.isProxySessionTable(sessionTable)) {
410
- const updates = sessionTable.getSessionUpdates();
411
- updates.forEach((rowUpdates, key) => {
412
- const { cellUpdates, lastUpdateTimestamp } = rowUpdates;
413
- const currentRow = sourceTable.findByKey(key);
414
- const lastUpdateTimestampOnTable = currentRow[sourceTable.map.vuuUpdatedTimestamp];
415
- if (lastUpdateTimestamp !== lastUpdateTimestampOnTable) {
416
- rejectedCount += 1;
417
- const sessionTableRow = sessionTable.findByKey(key);
418
- const newRow = sessionTableRow.slice();
419
- const messages = [];
420
- Object.entries(cellUpdates).forEach(([column, value]) => {
421
- messages.push(`${column}:${value}`);
422
- });
423
- newRow[sessionTable.map.vuuMsg] = messages.join(",");
424
- sessionTable.updateRow(newRow);
425
- } else {
426
- const newRow = currentRow.slice();
427
- Object.entries(cellUpdates).forEach(([column, value]) => {
428
- newRow[sourceTable.map[column]] = value;
429
- });
430
- sourceTable.updateRow(newRow);
431
- }
432
- });
433
- updates.clear();
434
- } else {
435
- for (let i = 0; i < sessionTable.data.length; i++) {
436
- const newRow = sessionTable.data[i];
437
- sourceTable.updateRow(newRow);
438
- }
439
- }
440
- if (rejectedCount > 0) {
441
- return {
442
- errorMessage: "stale update",
443
- type: "ERROR_RESULT"
444
- };
445
- } else {
446
- return {
447
- type: "SUCCESS_RESULT",
448
- data: void 0
449
- };
450
- }
451
- } else {
452
- return {
453
- type: "SUCCESS_RESULT",
454
- data: void 0
455
- };
456
- }
457
- } else {
458
- throw Error("[VuuModule], exitEditMode");
459
- }
460
- } else {
461
- throw Error(`[VuuModule] endEditSession invalid rpc type`);
462
- }
463
- });
464
- // Bulk-edit with input in session table
465
- __publicField(this, "applyBulkEdits", async (rpcRequest) => {
466
- if (rpcRequest.context.type === "VIEWPORT_CONTEXT") {
467
- const { viewPortId } = rpcRequest.context;
468
- const sessionTable = this.getSessionTable(viewPortId);
469
- for (let i = 0; i < sessionTable.data.length; i++) {
470
- const newRow = sessionTable.data[i];
471
- const { column, value } = rpcRequest.params;
472
- const keyIndex = sessionTable.map[sessionTable.schema.key];
473
- sessionTable.update(
474
- String(newRow[keyIndex]),
475
- column,
476
- value
477
- );
478
- }
479
- return {
480
- type: "SUCCESS_RESULT",
481
- data: void 0
482
- };
483
- } else {
484
- throw Error(`[VuuModule] applyBulkEdits invalid rpc type`);
485
- }
486
- });
487
- /**
488
- * These services are available on any table. The client must configure the appropriate
489
- * menu item(s) on Table(s). The services to implement these RPC calls are built-in to
490
- * VuuModule
491
- */
492
- __privateAdd(this, _moduleServices, [
493
- {
494
- rpcName: "addRow",
495
- service: this.addRow
496
- },
497
- {
498
- rpcName: "VP_BULK_EDIT_COLUMN_CELLS_RPC",
499
- service: this.applyBulkEdits
500
- },
501
- {
502
- rpcName: "beginEditSession",
503
- service: this.beginEditSession
504
- },
505
- {
506
- rpcName: "endEditSession",
507
- service: this.endEditSession
508
- },
509
- {
510
- rpcName: "editCell",
511
- service: this.editCell
512
- }
513
- ]);
514
- /**
515
- * These services are available on any table. The client must configure the appropriate
516
- * menu item(s) on Table(s). The services to implement these RPC calls are built-in to
517
- * VuuModule
518
- */
519
- __privateAdd(this, _moduleMenuServices, [
520
- {
521
- rpcName: "beginEditSession",
522
- service: this.beginEditSessionMenuHandler
523
- }
524
- ]);
525
- __privateSet(this, _name, name);
526
- ModuleContainer.register(this);
527
- }
528
- getTableSchema(tableName) {
529
- return this.schemas[tableName];
530
- }
531
- getTableList() {
532
- return Object.keys(this.tables);
533
- }
534
- get name() {
535
- return __privateGet(this, _name);
536
- }
537
- getSubscriptionByViewport(viewportId) {
538
- for (const subscriptions of __privateGet(this, _subscriptionMap).values()) {
539
- for (const subscription of subscriptions) {
540
- if (subscription.viewportId === viewportId) {
541
- return subscription;
542
- }
543
- }
544
- }
545
- throw Error(
546
- `[VuuModule] getSubscriptionByViewport, no subscription found for ${viewportId}`
547
- );
548
- }
549
- getSubscribedDataSource(vpId) {
550
- for (const subscriptions of __privateGet(this, _subscriptionMap).values()) {
551
- for (const { viewportId, dataSource } of subscriptions) {
552
- if (viewportId === vpId) {
553
- return dataSource;
554
- }
555
- }
556
- }
557
- throw Error(`getSubscribedDataSource #${vpId} not in subscriptionMap`);
558
- }
559
- getServices(tableName) {
560
- const tableServices = this.services?.[tableName];
561
- if (Array.isArray(tableServices)) {
562
- return __privateGet(this, _moduleServices).concat(tableServices);
563
- } else {
564
- return __privateGet(this, _moduleServices);
565
- }
566
- }
567
- getMenuServices(tableName) {
568
- const tableServices = this.menuServices?.[tableName];
569
- if (Array.isArray(tableServices)) {
570
- return __privateGet(this, _moduleMenuServices).concat(tableServices);
571
- } else {
572
- return __privateGet(this, _moduleMenuServices);
573
- }
574
- }
575
- get sessionTableMap() {
576
- return __privateGet(this, _sessionTableMap);
577
- }
578
- getSessionTable(sessionTableName, throwIfNotFound = true) {
579
- const sessionTable = __privateGet(this, _sessionTableMap)[sessionTableName];
580
- if (sessionTable) {
581
- return sessionTable;
582
- } else if (throwIfNotFound) {
583
- throw Error(
584
- `getSessionTable: no session table with name ${sessionTableName}`
585
- );
586
- }
587
- }
588
- getColumnDescriptors(tableName) {
589
- const schema = this.schemas[tableName] || this.getSessionTable(tableName)?.schema;
590
- if (schema) {
591
- return schema.columns;
592
- } else {
593
- throw Error(
594
- ` no schema found for module ${__privateGet(this, _name)} table ${tableName}`
595
- );
596
- }
597
- }
598
- createSessionTable(sourceTable, sessionTableName, editSessionMode = "inline-all-rows", dataSource) {
599
- if (editSessionMode.endsWith("all-rows")) {
600
- return this.createSessionTableWithAllRows(sourceTable, sessionTableName);
601
- } else if (editSessionMode === "selected-rows") {
602
- return this.createSessionTableFromSelectedRows(
603
- sourceTable,
604
- sessionTableName,
605
- dataSource
606
- );
607
- } else if (editSessionMode === "empty-session-table") {
608
- return this.createEmptySessionTable(sourceTable);
609
- } else {
610
- throw Error(
611
- `[VuuModule] createSessionTable, invalid editSessionMode ${editSessionMode}`
612
- );
613
- }
614
- }
615
- createSessionTableWithAllRows(sourceTable, sessionTableName) {
616
- return SessionTable.SessionTable(sourceTable, sessionTableName);
617
- }
618
- createEmptySessionTable({ schema }) {
619
- return new Table.Table(schema, [], Table.buildDataColumnMapFromSchema(schema));
620
- }
621
- createSessionTableFromSelectedRows({ data, map, schema }, sessionTableName, dataSource) {
622
- const selectedRowIds = dataSource.getSelectedRowIds();
623
- const keyIndex = map[schema.key];
624
- const sessionData = [];
625
- for (let i = 0; i < selectedRowIds.length; i++) {
626
- for (let j = 0; j < data.length; j++) {
627
- if (data[j][keyIndex] === selectedRowIds[i]) {
628
- sessionData.push(data[j]);
629
- }
630
- }
631
- }
632
- const sessionSchema = sessionTableUtils.sessionTableSchema(schema);
633
- return new Table.Table(
634
- sessionSchema,
635
- sessionData,
636
- Table.buildDataColumnMapFromSchema(sessionSchema)
637
- );
638
- }
639
- }
640
- _name = new WeakMap();
641
- _runtimeVisualLinks = new WeakMap();
642
- _sessionTableMap = new WeakMap();
643
- _tableServices = new WeakMap();
644
- _subscriptionMap = new WeakMap();
645
- _moduleServices = new WeakMap();
646
- _moduleMenuServices = new WeakMap();
647
-
648
- exports.VuuModule = VuuModule;
649
- //# sourceMappingURL=VuuModule.js.map