@vuu-ui/vuu-data-test 4.0.0-alpha.9 → 4.0.0-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 (93) hide show
  1. package/README.md +0 -8
  2. package/package.json +8 -10
  3. package/src/Table.js +5 -8
  4. package/src/TickingArrayDataSource.js +7 -2
  5. package/src/core/module/ModuleContainer.js +0 -8
  6. package/src/core/module/VuuModule.js +6 -28
  7. package/src/core/table/TableContainer.js +1 -1
  8. package/src/index.js +0 -3
  9. package/src/local-datasource-provider/LocalDatasourceProvider.js +5 -9
  10. package/src/schemas.js +2 -8
  11. package/types/TickingArrayDataSource.d.ts +1 -1
  12. package/types/core/module/ModuleContainer.d.ts +3 -6
  13. package/types/core/module/VuuModule.d.ts +0 -3
  14. package/types/core/table/TableContainer.d.ts +5 -5
  15. package/types/index.d.ts +0 -3
  16. package/types/local-datasource-provider/LocalDatasourceProvider.d.ts +2 -2
  17. package/types/schemas.d.ts +3 -5
  18. package/types/vuu-row-generator.d.ts +1 -1
  19. package/src/module-admin/ModuleAdminModule.js +0 -60
  20. package/src/module-admin/index.js +0 -3
  21. package/src/module-admin/module-admin-schemas.js +0 -99
  22. package/src/module-admin/snapshot-projection.js +0 -57
  23. package/src/user-admin/UserAdminModule.js +0 -412
  24. package/src/user-admin/index.js +0 -3
  25. package/src/user-admin/initialSnapshot.js +0 -477
  26. package/src/user-admin/snapshot-projection.js +0 -151
  27. package/types/module-admin/ModuleAdminModule.d.ts +0 -23
  28. package/types/module-admin/index.d.ts +0 -4
  29. package/types/module-admin/module-admin-schemas.d.ts +0 -4
  30. package/types/module-admin/snapshot-projection.d.ts +0 -14
  31. package/types/src/ArrayProxy.d.ts +0 -8
  32. package/types/src/RuntimeVisualLink.d.ts +0 -9
  33. package/types/src/Table.d.ts +0 -34
  34. package/types/src/TickingArrayDataSource.d.ts +0 -44
  35. package/types/src/UpdateGenerator.d.ts +0 -18
  36. package/types/src/basket/BasketModule.d.ts +0 -55
  37. package/types/src/basket/basket-schemas.d.ts +0 -9
  38. package/types/src/basket/index.d.ts +0 -2
  39. package/types/src/basket/reference-data/constituents.d.ts +0 -3
  40. package/types/src/basket/reference-data/ftse100.d.ts +0 -2
  41. package/types/src/basket/reference-data/hsi.d.ts +0 -2
  42. package/types/src/basket/reference-data/nasdaq100.d.ts +0 -2
  43. package/types/src/basket/reference-data/prices.d.ts +0 -24
  44. package/types/src/basket/reference-data/sp500.d.ts +0 -2
  45. package/types/src/core/module/ModuleContainer.d.ts +0 -11
  46. package/types/src/core/module/VuuModule.d.ts +0 -81
  47. package/types/src/core/table/TableContainer.d.ts +0 -16
  48. package/types/src/data-utils.d.ts +0 -7
  49. package/types/src/default-column-definitions.d.ts +0 -2
  50. package/types/src/index.d.ts +0 -12
  51. package/types/src/local-datasource-provider/LocalDatasourceProvider.d.ts +0 -4
  52. package/types/src/makeSuggestions.d.ts +0 -3
  53. package/types/src/rowUpdates.d.ts +0 -15
  54. package/types/src/schemas.d.ts +0 -8
  55. package/types/src/session-table-utils.d.ts +0 -6
  56. package/types/src/simul/SimulModule.d.ts +0 -24
  57. package/types/src/simul/index.d.ts +0 -2
  58. package/types/src/simul/reference-data/accounts.d.ts +0 -1
  59. package/types/src/simul/reference-data/algos.d.ts +0 -1
  60. package/types/src/simul/reference-data/currencies.d.ts +0 -1
  61. package/types/src/simul/reference-data/index.d.ts +0 -5
  62. package/types/src/simul/reference-data/instrument-prices.d.ts +0 -60
  63. package/types/src/simul/reference-data/instruments-extended.d.ts +0 -1
  64. package/types/src/simul/reference-data/instruments.d.ts +0 -35
  65. package/types/src/simul/reference-data/isin-generator/convert-string-to-base-ten-number.d.ts +0 -1
  66. package/types/src/simul/reference-data/isin-generator/fixtures/alphabet.d.ts +0 -1
  67. package/types/src/simul/reference-data/isin-generator/fixtures/alphanumeric-values.d.ts +0 -1
  68. package/types/src/simul/reference-data/isin-generator/fixtures/base-ten-numbers.d.ts +0 -1
  69. package/types/src/simul/reference-data/isin-generator/generate-cusip-check-code.d.ts +0 -1
  70. package/types/src/simul/reference-data/isin-generator/generate-cusip-without-check-code.d.ts +0 -1
  71. package/types/src/simul/reference-data/isin-generator/generate-cusip.d.ts +0 -1
  72. package/types/src/simul/reference-data/isin-generator/generate-random-alphanumeric.d.ts +0 -1
  73. package/types/src/simul/reference-data/isin-generator/generate-random-base-ten-number.d.ts +0 -1
  74. package/types/src/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.d.ts +0 -1
  75. package/types/src/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.d.ts +0 -1
  76. package/types/src/simul/reference-data/isin-generator/index.d.ts +0 -1
  77. package/types/src/simul/reference-data/isin-generator/is-odd.d.ts +0 -1
  78. package/types/src/simul/reference-data/locations.d.ts +0 -4
  79. package/types/src/simul/reference-data/lotsizes.d.ts +0 -1
  80. package/types/src/simul/reference-data/orderStatus.d.ts +0 -1
  81. package/types/src/simul/reference-data/orders.d.ts +0 -36
  82. package/types/src/simul/reference-data/parent-child-orders.d.ts +0 -4
  83. package/types/src/simul/reference-data/priceStrategies.d.ts +0 -1
  84. package/types/src/simul/reference-data/prices.d.ts +0 -34
  85. package/types/src/simul/reference-data/sides.d.ts +0 -1
  86. package/types/src/simul/simul-schemas.d.ts +0 -9
  87. package/types/src/test/TestModule.d.ts +0 -16
  88. package/types/src/test/index.d.ts +0 -1
  89. package/types/src/vuu-row-generator.d.ts +0 -17
  90. package/types/user-admin/UserAdminModule.d.ts +0 -50
  91. package/types/user-admin/index.d.ts +0 -3
  92. package/types/user-admin/initialSnapshot.d.ts +0 -2
  93. package/types/user-admin/snapshot-projection.d.ts +0 -9
package/README.md CHANGED
@@ -1,8 +0,0 @@
1
- # `@vuu-ui/vuu-data-test`
2
-
3
- ## Admin test module dependencies
4
-
5
- The `USER_ADMIN` and `MODULE_DISCOVERY` test modules use the published
6
- `@heswell/user-admin` and `@heswell/module-admin` packages. Standard
7
- `npm install` setup is sufficient. Browser code imports only the browser-safe
8
- `contracts` subpath for module-admin.
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
- "version": "4.0.0-alpha.9",
2
+ "version": "4.0.0-beta.1",
3
3
  "main": "./src/index.js",
4
- "type": "module",
5
4
  "author": "heswell",
6
5
  "license": "Apache-2.0",
7
6
  "scripts": {
@@ -10,16 +9,13 @@
10
9
  "type-defs": "node ../../scripts/build-type-defs.mjs"
11
10
  },
12
11
  "dependencies": {
13
- "@heswell/module-admin": "1.0.0",
14
- "@heswell/user-admin": "1.0.1",
15
- "@vuu-ui/vuu-data-editing": "4.0.0-alpha.9",
16
- "@vuu-ui/vuu-data-local": "4.0.0-alpha.9",
17
- "@vuu-ui/vuu-utils": "4.0.0-alpha.9"
12
+ "@vuu-ui/vuu-data-local": "4.0.0-beta.1",
13
+ "@vuu-ui/vuu-utils": "4.0.0-beta.1"
18
14
  },
19
15
  "devDependencies": {
20
- "@vuu-ui/vuu-data-types": "4.0.0-alpha.9",
21
- "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.9",
22
- "@vuu-ui/vuu-table-types": "4.0.0-alpha.9"
16
+ "@vuu-ui/vuu-protocol-types": "4.0.0-beta.1",
17
+ "@vuu-ui/vuu-data-types": "4.0.0-beta.1",
18
+ "@vuu-ui/vuu-table-types": "4.0.0-beta.1"
23
19
  },
24
20
  "sideEffects": false,
25
21
  "files": [
@@ -30,10 +26,12 @@
30
26
  "exports": {
31
27
  ".": {
32
28
  "import": "./src/index.js",
29
+ "default": "./src/index.js",
33
30
  "types": "./types/index.d.ts"
34
31
  }
35
32
  },
36
33
  "module": "./src/index.js",
37
34
  "name": "@vuu-ui/vuu-data-test",
35
+ "type": "module",
38
36
  "types": "types/index.d.ts"
39
37
  }
package/src/Table.js CHANGED
@@ -20,7 +20,7 @@ class Table extends EventEmitter {
20
20
  }
21
21
  buildIndex() {
22
22
  for(let i = 0; i < this.#data.length; i++){
23
- const key = String(this.#data[i][this.#indexOfKey]);
23
+ const key = this.#data[i][this.#indexOfKey];
24
24
  this.#index.set(key, i);
25
25
  }
26
26
  }
@@ -41,17 +41,14 @@ class Table extends EventEmitter {
41
41
  if (-1 !== index) {
42
42
  this.#index.delete(key);
43
43
  this.#data.splice(index, 1);
44
- for(let i = index; i < this.#data.length; i++)this.#index.set(String(this.#data[i][this.#indexOfKey]), i);
44
+ for(let i = index; i < this.#data.length; i++)this.#index.set(this.#data[i][this.#indexOfKey], i);
45
45
  if (emitEvent) this.emit("delete", key);
46
46
  } else throw Error(`[Table] delete key ${key} not found`);
47
47
  }
48
48
  insert(row, emitEvent = true) {
49
49
  const index = this.#data.length;
50
- const createdTime = Date.now();
51
- row[this.#dataMap.vuuUpdatedTimestamp] = createdTime;
52
- row[this.#dataMap.vuuCreatedTimestamp] = createdTime;
53
50
  this.#data.push(row);
54
- const key = String(row[this.#indexOfKey]);
51
+ const key = row[this.#indexOfKey];
55
52
  this.#index.set(key, index);
56
53
  if (emitEvent) this.emit("insert", row);
57
54
  }
@@ -60,7 +57,7 @@ class Table extends EventEmitter {
60
57
  return this.#data[index];
61
58
  }
62
59
  update(key, columnName, value) {
63
- const rowIndex = this.#data.findIndex((row)=>String(row[this.#indexOfKey]) === key);
60
+ const rowIndex = this.#data.findIndex((row)=>row[this.#indexOfKey] === key);
64
61
  const colIndex = this.#dataMap[columnName];
65
62
  if (-1 !== rowIndex) {
66
63
  const row = this.#data[rowIndex];
@@ -77,7 +74,7 @@ class Table extends EventEmitter {
77
74
  }
78
75
  updateRow(row) {
79
76
  const key = row[this.#indexOfKey];
80
- const rowIndex = this.#data.findIndex((row)=>String(row[this.#indexOfKey]) === String(key));
77
+ const rowIndex = this.#data.findIndex((row)=>row[this.#indexOfKey] === key);
81
78
  if (-1 !== rowIndex) {
82
79
  const tsIndex = this.#dataMap.vuuUpdatedTimestamp;
83
80
  const lastUpdated = Date.now();
@@ -181,14 +181,19 @@ class TickingArrayDataSource extends ArrayDataSource {
181
181
  get columns() {
182
182
  return super.columns;
183
183
  }
184
- async endEditSession(saveChanges = false) {
184
+ async endEditSession(saveChanges = false, force = false) {
185
+ if ("unsubscribed" === this.status || !this.viewport) {
186
+ if (!saveChanges) return;
187
+ throw Error("Cannot save changes: datasource is unsubscribed");
188
+ }
185
189
  const type = "RPC_REQUEST";
186
190
  const rpcName = "endEditSession";
187
191
  const rpcResponse = await this.rpcRequest(saveChanges ? {
188
192
  type,
189
193
  rpcName,
190
194
  params: {
191
- save: true
195
+ save: true,
196
+ force
192
197
  }
193
198
  } : {
194
199
  type,
@@ -8,9 +8,6 @@ class ModuleContainer {
8
8
  register(module) {
9
9
  this.#modules.set(module.name, module);
10
10
  }
11
- has(name) {
12
- return this.#modules.has(name);
13
- }
14
11
  get(name) {
15
12
  const module = this.#modules.get(name);
16
13
  if (module) return module;
@@ -21,9 +18,4 @@ class ModuleContainer {
21
18
  }
22
19
  }
23
20
  var module_ModuleContainer = ModuleContainer.instance;
24
- const ensureVuuModule = (module)=>{
25
- if (!ModuleContainer.instance.has(module.name)) ModuleContainer.instance.register(module);
26
- return module;
27
- };
28
21
  export default module_ModuleContainer;
29
- export { ensureVuuModule };
@@ -22,11 +22,6 @@ class VuuModule {
22
22
  this.#sessionTableMessageColumn = sessionTableMessageColumn;
23
23
  ModuleContainer.register(this);
24
24
  }
25
- get includeDefaultServices() {
26
- return true;
27
- }
28
- async beforeSessionSave(_sourceTable, _sessionTable) {}
29
- async afterSessionSave(_sourceTable, _sessionTable) {}
30
25
  getTableSchema(tableName) {
31
26
  return this.schemas[tableName] ?? this.#sessionTableMap[tableName]?.schema;
32
27
  }
@@ -160,9 +155,8 @@ class VuuModule {
160
155
  };
161
156
  getServices(tableName) {
162
157
  const tableServices = this.services?.[tableName];
163
- const defaultServices = this.includeDefaultServices ? this.#moduleServices : [];
164
- if (Array.isArray(tableServices)) return defaultServices.concat(tableServices);
165
- return defaultServices;
158
+ if (Array.isArray(tableServices)) return this.#moduleServices.concat(tableServices);
159
+ return this.#moduleServices;
166
160
  }
167
161
  getMenuServices(tableName) {
168
162
  const tableServices = this.menuServices?.[tableName];
@@ -227,9 +221,7 @@ class VuuModule {
227
221
  }
228
222
  return {
229
223
  type: "SUCCESS_RESULT",
230
- data: {
231
- deletedKeys: selectedRowIds
232
- }
224
+ data: void 0
233
225
  };
234
226
  }
235
227
  return {
@@ -477,7 +469,9 @@ class VuuModule {
477
469
  sessionTable.insert(row);
478
470
  return {
479
471
  type: "SUCCESS_RESULT",
480
- data: void 0
472
+ data: {
473
+ key: rowKey
474
+ }
481
475
  };
482
476
  }
483
477
  return {
@@ -500,14 +494,6 @@ class VuuModule {
500
494
  data: void 0
501
495
  };
502
496
  {
503
- try {
504
- await this.beforeSessionSave(sourceTable, sessionTable);
505
- } catch (error) {
506
- return {
507
- errorMessage: error instanceof Error ? error.message : "Unable to prepare session changes",
508
- type: "ERROR_RESULT"
509
- };
510
- }
511
497
  let rejectedCount = 0;
512
498
  const vuuMsgIdx = sessionTable.map[this.#sessionTableMessageColumn];
513
499
  const actionIdx = sessionTable.map.vuuAction;
@@ -542,14 +528,6 @@ class VuuModule {
542
528
  errorMessage: "stale update",
543
529
  type: "ERROR_RESULT"
544
530
  };
545
- try {
546
- await this.afterSessionSave(sourceTable, sessionTable);
547
- } catch (error) {
548
- return {
549
- errorMessage: error instanceof Error ? error.message : "Unable to finalize session changes",
550
- type: "ERROR_RESULT"
551
- };
552
- }
553
531
  return {
554
532
  type: "SUCCESS_RESULT",
555
533
  data: void 0
@@ -10,7 +10,7 @@ class TableContainer {
10
10
  return TableContainer.#instance;
11
11
  }
12
12
  #tables = new Map();
13
- createTable = (schema, data = [], dataMap = buildDataColumnMapFromSchema(schema), updateGenerator)=>{
13
+ createTable = (schema, data, dataMap, updateGenerator)=>{
14
14
  const table = new Table(schema, data, dataMap, updateGenerator);
15
15
  this.addTable(table);
16
16
  return table;
package/src/index.js CHANGED
@@ -5,11 +5,8 @@ export * from "./makeSuggestions.js";
5
5
  export * from "./schemas.js";
6
6
  export * from "./simul/index.js";
7
7
  export * from "./basket/index.js";
8
- export * from "./module-admin/index.js";
9
- export * from "./user-admin/index.js";
10
8
  export * from "./test/index.js";
11
9
  export * from "./TickingArrayDataSource.js";
12
10
  export * from "./vuu-row-generator.js";
13
- export { ensureVuuModule } from "./core/module/ModuleContainer.js";
14
11
  export { default as tableContainer } from "./core/table/TableContainer.js";
15
12
  export { Table, buildDataColumnMap, buildDataColumnMapFromSchema } from "./Table.js";
@@ -1,6 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { DataProvider } from "@vuu-ui/core";
3
- import { DataProvider as vuu_utils_DataProvider } from "@vuu-ui/vuu-utils";
2
+ import { DataProvider } from "@vuu-ui/vuu-utils";
4
3
  import ModuleContainer from "../core/module/ModuleContainer.js";
5
4
  import TableContainer from "../core/table/TableContainer.js";
6
5
  const serverAPI = {
@@ -24,9 +23,10 @@ const serverAPI = {
24
23
  };
25
24
  const getServerAPI = async ()=>serverAPI;
26
25
  class VuuDataSource {
27
- constructor({ aggregations, columns, filterSpec, groupBy, session, sort, table, viewport, visualLink }){
26
+ constructor({ aggregations, baseFilterSpec, columns, filterSpec, groupBy, session, sort, table, viewport, visualLink }){
28
27
  const config = {
29
28
  aggregations,
29
+ baseFilterSpec,
30
30
  columns,
31
31
  filterSpec,
32
32
  groupBy,
@@ -38,13 +38,9 @@ class VuuDataSource {
38
38
  return module.createDataSource(table.table, viewport, config);
39
39
  }
40
40
  }
41
- const LocalDataSourceProvider = ({ children })=>/*#__PURE__*/ jsx(vuu_utils_DataProvider, {
41
+ const LocalDataSourceProvider = ({ children })=>/*#__PURE__*/ jsx(DataProvider, {
42
42
  VuuDataSource: VuuDataSource,
43
43
  getServerAPI: getServerAPI,
44
- children: /*#__PURE__*/ jsx(DataProvider, {
45
- VuuDataSource: VuuDataSource,
46
- getServerAPI: getServerAPI,
47
- children: children
48
- })
44
+ children: children
49
45
  });
50
46
  export { LocalDataSourceProvider };
package/src/schemas.js CHANGED
@@ -1,21 +1,15 @@
1
1
  import { schemas } from "./basket/basket-schemas.js";
2
2
  import { schemas as simul_schemas_js_schemas } from "./simul/simul-schemas.js";
3
3
  import { testModule } from "./test/TestModule.js";
4
- import { USER_ADMIN_TABLE_SCHEMAS } from "@heswell/user-admin/contracts";
5
- import { MODULE_ADMIN_TABLE_SCHEMAS } from "./module-admin/index.js";
6
4
  const schemas_schemas = {
7
5
  ...schemas,
8
6
  ...simul_schemas_js_schemas,
9
- ...testModule.schemas,
10
- ...USER_ADMIN_TABLE_SCHEMAS,
11
- ...MODULE_ADMIN_TABLE_SCHEMAS
7
+ ...testModule.schemas
12
8
  };
13
9
  const allSchemas = {
14
10
  ...schemas,
15
11
  ...simul_schemas_js_schemas,
16
- ...testModule.schemas,
17
- ...USER_ADMIN_TABLE_SCHEMAS,
18
- ...MODULE_ADMIN_TABLE_SCHEMAS
12
+ ...testModule.schemas
19
13
  };
20
14
  const getAllSchemas = ()=>schemas_schemas;
21
15
  const getSchema = (tableName)=>{
@@ -33,7 +33,7 @@ export declare class TickingArrayDataSource extends ArrayDataSource {
33
33
  undoRowChange: (key: string) => Promise<RpcResultSuccess | RpcResultError>;
34
34
  set columns(columns: string[]);
35
35
  get columns(): string[];
36
- endEditSession(saveChanges?: boolean): Promise<void>;
36
+ endEditSession(saveChanges?: boolean, force?: boolean): Promise<void>;
37
37
  rpcRequest(rpcRequest: Omit<VuuRpcServiceRequest, "context">): Promise<RpcResultSuccess | RpcResultError>;
38
38
  menuRpcCall(rpcRequest: Omit<VuuRpcMenuRequest, "vpId">): Promise<VuuRpcMenuResponse>;
39
39
  getTypeaheadSuggestions(column: string, pattern?: string): Promise<string[]>;
@@ -1,14 +1,11 @@
1
- import type { VuuModule } from "./VuuModule";
2
- type RegisteredVuuModule = VuuModule<any>;
1
+ import { VuuModule } from "./VuuModule";
3
2
  declare class ModuleContainer {
4
3
  #private;
5
4
  private constructor();
6
5
  static get instance(): ModuleContainer;
7
- register(module: RegisteredVuuModule): void;
8
- has(name: string): boolean;
9
- get(name: string): RegisteredVuuModule;
6
+ register(module: VuuModule<any>): void;
7
+ get(name: string): VuuModule<string>;
10
8
  get moduleNames(): MapIterator<string>;
11
9
  }
12
10
  declare const _default: ModuleContainer;
13
11
  export default _default;
14
- export declare const ensureVuuModule: <T extends RegisteredVuuModule>(module: T) => T;
@@ -38,9 +38,6 @@ export declare abstract class VuuModule<T extends string = string> implements IV
38
38
  protected abstract menuServices?: Record<T, RpcMenuService[] | undefined> | undefined;
39
39
  protected abstract services?: Record<T, RpcService[] | undefined> | undefined;
40
40
  protected abstract visualLinks?: Record<T, VuuLink[] | undefined>;
41
- protected get includeDefaultServices(): boolean;
42
- protected beforeSessionSave(_sourceTable: Table, _sessionTable: Table): Promise<void>;
43
- protected afterSessionSave(_sourceTable: Table, _sessionTable: Table): Promise<void>;
44
41
  getTableSchema(tableName: string): Record<T, Readonly<TableSchema>>[T];
45
42
  getTableList(): string[];
46
43
  protected handlePostSubscribeActivities: ({ clientViewportId, tableSchema, }: DataSourceSubscribedMessage) => void;
@@ -1,13 +1,13 @@
1
- import type { TableSchema } from "@vuu-ui/vuu-data-types";
1
+ import { TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import { Table } from "../../Table";
3
- import type { VuuRowDataItemType, VuuTable } from "@vuu-ui/vuu-protocol-types";
4
- import type { ColumnMap } from "@vuu-ui/vuu-utils";
5
- import type { UpdateGenerator } from "../../rowUpdates";
3
+ import { VuuRowDataItemType, VuuTable } from "@vuu-ui/vuu-protocol-types";
4
+ import { ColumnMap } from "@vuu-ui/vuu-utils";
5
+ import { UpdateGenerator } from "../../rowUpdates";
6
6
  declare class TableContainer {
7
7
  #private;
8
8
  private constructor();
9
9
  static get instance(): TableContainer;
10
- createTable: (schema: TableSchema, data?: Array<Array<VuuRowDataItemType | bigint>>, dataMap?: ColumnMap, updateGenerator?: UpdateGenerator) => Table;
10
+ createTable: (schema: TableSchema, data: Array<Array<VuuRowDataItemType | bigint>>, dataMap: ColumnMap, updateGenerator?: UpdateGenerator) => Table;
11
11
  createJoinTable(joinTable: VuuTable, { table: t1 }: VuuTable, { table: t2 }: VuuTable, joinColumn: string): Table;
12
12
  addTable(table: Table): void;
13
13
  getTable<T = Table>(tableName: string): NonNullable<T>;
package/types/index.d.ts CHANGED
@@ -1,14 +1,11 @@
1
1
  export * from "./ArrayProxy";
2
2
  export * from "./core/module/VuuModule";
3
- export { ensureVuuModule } from "./core/module/ModuleContainer";
4
3
  export { default as tableContainer } from "./core/table/TableContainer";
5
4
  export * from "./local-datasource-provider/LocalDatasourceProvider";
6
5
  export * from "./makeSuggestions";
7
6
  export * from "./schemas";
8
7
  export * from "./simul";
9
8
  export * from "./basket";
10
- export * from "./module-admin";
11
- export * from "./user-admin";
12
9
  export { buildDataColumnMap, buildDataColumnMapFromSchema, Table, type TableEvents, } from "./Table";
13
10
  export * from "./test";
14
11
  export * from "./TickingArrayDataSource";
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import { ReactNode } from "react";
2
2
  export declare const LocalDataSourceProvider: ({ children, }: {
3
3
  children: ReactNode;
4
- }) => import("react").JSX.Element;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,8 @@
1
- import type { TableSchema } from "@vuu-ui/vuu-data-types";
1
+ import { TableSchema } from "@vuu-ui/vuu-data-types";
2
2
  import { type BasketsTableName } from "./basket/basket-schemas";
3
3
  import { type SimulTableName } from "./simul/simul-schemas";
4
- import { type TestTableName } from "./test/TestModule";
5
- import { type UserAdminTableName } from "@heswell/user-admin/contracts";
6
- import { type ModuleAdminTableName } from "./module-admin";
7
- export type VuuTableName = BasketsTableName | SimulTableName | TestTableName | UserAdminTableName | ModuleAdminTableName;
4
+ import { TestTableName } from "./test/TestModule";
5
+ export type VuuTableName = BasketsTableName | SimulTableName | TestTableName;
8
6
  export declare const schemas: Record<VuuTableName, TableSchema>;
9
7
  export declare const getAllSchemas: () => Record<VuuTableName, TableSchema>;
10
8
  export declare const getSchema: (tableName: VuuTableName) => Readonly<TableSchema>;
@@ -1,6 +1,6 @@
1
1
  import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
2
  import type { VuuRowDataItemType, VuuTable } from "@vuu-ui/vuu-protocol-types";
3
- import type { UpdateGenerator } from "./rowUpdates";
3
+ import { UpdateGenerator } from "./rowUpdates";
4
4
  type GenerateRowFunc = (index: number) => VuuRowDataItemType[];
5
5
  export type RowGeneratorFactory = (columns: string[]) => GenerateRowFunc;
6
6
  export type ColumnGeneratorFn = (columns?: number | string[], columnConfig?: {
@@ -1,60 +0,0 @@
1
- import { DEFAULT_MODULE_DEFINITIONS } from "@heswell/module-admin/contracts";
2
- import { VuuModule } from "../core/module/VuuModule.js";
3
- import TableContainer from "../core/table/TableContainer.js";
4
- import { buildDataColumnMapFromSchema } from "../Table.js";
5
- import { MODULE_ADMIN_MODULE_NAME, MODULE_ADMIN_TABLE_SCHEMAS } from "./module-admin-schemas.js";
6
- import { reconcileModuleAdminTables } from "./snapshot-projection.js";
7
- const createTable = (tableName)=>{
8
- const schema = MODULE_ADMIN_TABLE_SCHEMAS[tableName];
9
- return TableContainer.createTable(schema, [], buildDataColumnMapFromSchema(schema));
10
- };
11
- const createTables = ()=>({
12
- modulePermissions: createTable("modulePermissions"),
13
- modules: createTable("modules")
14
- });
15
- const MODULE_ADMIN_INITIAL_SNAPSHOT = {
16
- moduleAccessRoles: [
17
- {
18
- moduleName: "moduleAdmin",
19
- role: "module-admin-access"
20
- },
21
- {
22
- moduleName: "userAdmin",
23
- role: "user-admin-access"
24
- },
25
- {
26
- moduleName: "basket-trading",
27
- role: "basket-trading-access"
28
- }
29
- ],
30
- modules: DEFAULT_MODULE_DEFINITIONS,
31
- timestamp: 1710000000000
32
- };
33
- class ModuleAdminModule extends VuuModule {
34
- #tables;
35
- constructor(snapshot = MODULE_ADMIN_INITIAL_SNAPSHOT){
36
- super(MODULE_ADMIN_MODULE_NAME);
37
- this.#tables = createTables();
38
- reconcileModuleAdminTables(snapshot, this.#tables);
39
- }
40
- get menus() {
41
- return {
42
- modulePermissions: void 0,
43
- modules: void 0
44
- };
45
- }
46
- get includeDefaultServices() {
47
- return false;
48
- }
49
- get menuServices() {}
50
- get schemas() {
51
- return MODULE_ADMIN_TABLE_SCHEMAS;
52
- }
53
- get services() {}
54
- get tables() {
55
- return this.#tables;
56
- }
57
- get visualLinks() {}
58
- }
59
- const moduleAdminModule = new ModuleAdminModule();
60
- export { MODULE_ADMIN_INITIAL_SNAPSHOT, ModuleAdminModule, moduleAdminModule };
@@ -1,3 +0,0 @@
1
- export { MODULE_ADMIN_INITIAL_SNAPSHOT, ModuleAdminModule, moduleAdminModule } from "./ModuleAdminModule.js";
2
- export { MODULE_ADMIN_MODULE_NAME, MODULE_ADMIN_TABLE_SCHEMAS } from "./module-admin-schemas.js";
3
- export { projectModuleAdminSnapshot, reconcileModuleAdminTables } from "./snapshot-projection.js";
@@ -1,99 +0,0 @@
1
- import { VUU_DEFAULT_COLUMNS } from "../default-column-definitions.js";
2
- const DEFAULT_RANGE_LIMITS = {
3
- maxRangeEnd: 1000000,
4
- maxRangeWidth: 1000
5
- };
6
- const MODULE_ADMIN_MODULE_NAME = "MODULE_DISCOVERY";
7
- const MODULE_ADMIN_TABLE_SCHEMAS = {
8
- modules: {
9
- columns: [
10
- {
11
- name: "id",
12
- serverDataType: "int"
13
- },
14
- {
15
- name: "name",
16
- serverDataType: "string"
17
- },
18
- {
19
- name: "title",
20
- serverDataType: "string"
21
- },
22
- {
23
- name: "description",
24
- serverDataType: "string"
25
- },
26
- {
27
- name: "version",
28
- serverDataType: "int"
29
- },
30
- {
31
- name: "enabled",
32
- serverDataType: "boolean"
33
- },
34
- {
35
- name: "location",
36
- serverDataType: "string"
37
- },
38
- {
39
- name: "path",
40
- serverDataType: "string"
41
- },
42
- {
43
- name: "mfComponent",
44
- serverDataType: "string"
45
- },
46
- {
47
- name: "mfScope",
48
- serverDataType: "string"
49
- },
50
- {
51
- name: "mfUrl",
52
- serverDataType: "string"
53
- },
54
- {
55
- name: "vuuConnectionId",
56
- serverDataType: "string"
57
- },
58
- {
59
- name: "vuuWebsocketUrl",
60
- serverDataType: "string"
61
- },
62
- {
63
- name: "vuuRestUrl",
64
- serverDataType: "string"
65
- },
66
- ...VUU_DEFAULT_COLUMNS
67
- ],
68
- key: "id",
69
- rangeLimits: DEFAULT_RANGE_LIMITS,
70
- table: {
71
- module: MODULE_ADMIN_MODULE_NAME,
72
- table: "modules"
73
- }
74
- },
75
- modulePermissions: {
76
- columns: [
77
- {
78
- name: "id",
79
- serverDataType: "int"
80
- },
81
- {
82
- name: "module_id",
83
- serverDataType: "int"
84
- },
85
- {
86
- name: "role",
87
- serverDataType: "string"
88
- },
89
- ...VUU_DEFAULT_COLUMNS
90
- ],
91
- key: "id",
92
- rangeLimits: DEFAULT_RANGE_LIMITS,
93
- table: {
94
- module: MODULE_ADMIN_MODULE_NAME,
95
- table: "modulePermissions"
96
- }
97
- }
98
- };
99
- export { MODULE_ADMIN_MODULE_NAME, MODULE_ADMIN_TABLE_SCHEMAS };
@@ -1,57 +0,0 @@
1
- import { moduleDefinitionsToRows, modulePermissionsFor } from "@heswell/module-admin/contracts";
2
- const rowsEqual = (left, right)=>left.length === right.length && left.every((value, index)=>value === right[index]);
3
- const systemValues = (timestamp)=>({
4
- vuuCreatedTimestamp: timestamp,
5
- vuuMsg: "",
6
- vuuUpdatedTimestamp: timestamp
7
- });
8
- const toRow = (table, values)=>table.schema.columns.map(({ name })=>values[name] ?? "");
9
- const moduleValues = ([id, name, title, description, version, enabled, location, path, mfComponent, mfScope, mfUrl, vuuConnectionId, vuuWebsocketUrl, vuuRestUrl], timestamp)=>({
10
- ...systemValues(timestamp),
11
- description,
12
- enabled,
13
- id,
14
- location,
15
- mfComponent,
16
- mfScope,
17
- mfUrl,
18
- name,
19
- path,
20
- title,
21
- version,
22
- vuuConnectionId,
23
- vuuRestUrl,
24
- vuuWebsocketUrl
25
- });
26
- const permissionValues = ([id, moduleId, role], timestamp)=>({
27
- ...systemValues(timestamp),
28
- id,
29
- module_id: moduleId,
30
- role
31
- });
32
- const projectModuleAdminSnapshot = (snapshot, tables)=>({
33
- modulePermissions: modulePermissionsFor(snapshot.modules, snapshot.moduleAccessRoles).map((row)=>toRow(tables.modulePermissions, permissionValues(row, snapshot.timestamp))),
34
- modules: moduleDefinitionsToRows(snapshot.modules).map((row)=>toRow(tables.modules, moduleValues(row, snapshot.timestamp)))
35
- });
36
- const reconcileModuleAdminTables = (snapshot, tables)=>{
37
- const projected = projectModuleAdminSnapshot(snapshot, tables);
38
- for (const tableName of Object.keys(tables)){
39
- const table = tables[tableName];
40
- const desiredRows = projected[tableName];
41
- const keyIndex = table.map[table.schema.key];
42
- const desiredKeys = new Set(desiredRows.map((row)=>String(row[keyIndex])));
43
- for (const existingRow of [
44
- ...table.data
45
- ]){
46
- const key = String(existingRow[keyIndex]);
47
- if (!desiredKeys.has(key)) table.delete(key);
48
- }
49
- for (const row of desiredRows){
50
- const key = String(row[keyIndex]);
51
- const existingRow = table.findByKey(key);
52
- if (void 0 === existingRow) table.insert(row);
53
- else if (!rowsEqual(existingRow, row)) table.updateRow(row);
54
- }
55
- }
56
- };
57
- export { projectModuleAdminSnapshot, reconcileModuleAdminTables };