@vuu-ui/vuu-data-test 4.0.0-beta.6 → 4.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.
- package/package.json +6 -6
- package/src/core/module/VuuModule.js +1 -3
- package/src/simul/reference-data/instruments-extended.js +58 -7
- package/src/simul/simul-schemas.js +22 -2
- package/types/core/filter/PermissionFilter.d.ts +41 -0
- package/types/core/filter/PermissionFilteredTable.d.ts +24 -0
- package/types/core/user/CurrentUser.d.ts +14 -0
- package/types/module-admin/ModuleAdminModule.d.ts +32 -0
- package/types/module-admin/index.d.ts +4 -0
- package/types/module-admin/module-admin-schemas.d.ts +4 -0
- package/types/module-admin/snapshot-projection.d.ts +13 -0
- package/types/notifications/NotificationModule.d.ts +60 -0
- package/types/notifications/NotificationsSchema.d.ts +20 -0
- package/types/notifications/index.d.ts +6 -0
- package/types/notifications/simulated/DismissNotificationRpcHandler.d.ts +8 -0
- package/types/notifications/simulated/SimulatedNotificationsModule.d.ts +9 -0
- package/types/notifications/simulated/SimulatedNotificationsProvider.d.ts +21 -0
- package/types/notifications/simulated/notificationsModule.d.ts +5 -0
- package/types/src/ArrayProxy.d.ts +8 -0
- package/types/src/RuntimeVisualLink.d.ts +9 -0
- package/types/src/Table.d.ts +34 -0
- package/types/src/TickingArrayDataSource.d.ts +44 -0
- package/types/src/UpdateGenerator.d.ts +18 -0
- package/types/src/basket/BasketModule.d.ts +55 -0
- package/types/src/basket/basket-schemas.d.ts +9 -0
- package/types/src/basket/index.d.ts +2 -0
- package/types/src/basket/reference-data/constituents.d.ts +3 -0
- package/types/src/basket/reference-data/ftse100.d.ts +2 -0
- package/types/src/basket/reference-data/hsi.d.ts +2 -0
- package/types/src/basket/reference-data/nasdaq100.d.ts +2 -0
- package/types/src/basket/reference-data/prices.d.ts +24 -0
- package/types/src/basket/reference-data/sp500.d.ts +2 -0
- package/types/src/core/module/ModuleContainer.d.ts +11 -0
- package/types/src/core/module/VuuModule.d.ts +81 -0
- package/types/src/core/table/TableContainer.d.ts +16 -0
- package/types/src/data-utils.d.ts +7 -0
- package/types/src/default-column-definitions.d.ts +2 -0
- package/types/src/index.d.ts +12 -0
- package/types/src/local-datasource-provider/LocalDatasourceProvider.d.ts +4 -0
- package/types/src/makeSuggestions.d.ts +3 -0
- package/types/src/rowUpdates.d.ts +15 -0
- package/types/src/schemas.d.ts +8 -0
- package/types/src/session-table-utils.d.ts +6 -0
- package/types/src/simul/SimulModule.d.ts +24 -0
- package/types/src/simul/index.d.ts +2 -0
- package/types/src/simul/reference-data/accounts.d.ts +1 -0
- package/types/src/simul/reference-data/algos.d.ts +1 -0
- package/types/src/simul/reference-data/currencies.d.ts +1 -0
- package/types/src/simul/reference-data/index.d.ts +5 -0
- package/types/src/simul/reference-data/instrument-prices.d.ts +60 -0
- package/types/src/simul/reference-data/instruments-extended.d.ts +1 -0
- package/types/src/simul/reference-data/instruments.d.ts +35 -0
- package/types/src/simul/reference-data/isin-generator/convert-string-to-base-ten-number.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/fixtures/alphabet.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/fixtures/alphanumeric-values.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/fixtures/base-ten-numbers.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-cusip-check-code.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-cusip-without-check-code.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-cusip.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-random-alphanumeric.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-random-base-ten-number.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/index.d.ts +1 -0
- package/types/src/simul/reference-data/isin-generator/is-odd.d.ts +1 -0
- package/types/src/simul/reference-data/locations.d.ts +4 -0
- package/types/src/simul/reference-data/lotsizes.d.ts +1 -0
- package/types/src/simul/reference-data/orderStatus.d.ts +1 -0
- package/types/src/simul/reference-data/orders.d.ts +36 -0
- package/types/src/simul/reference-data/parent-child-orders.d.ts +4 -0
- package/types/src/simul/reference-data/priceStrategies.d.ts +1 -0
- package/types/src/simul/reference-data/prices.d.ts +34 -0
- package/types/src/simul/reference-data/sides.d.ts +1 -0
- package/types/src/simul/simul-schemas.d.ts +9 -0
- package/types/src/test/TestModule.d.ts +16 -0
- package/types/src/test/index.d.ts +1 -0
- package/types/src/vuu-row-generator.d.ts +17 -0
- package/types/user-admin/UserAdminModule.d.ts +54 -0
- package/types/user-admin/index.d.ts +3 -0
- package/types/user-admin/initialSnapshot.d.ts +2 -0
- package/types/user-admin/snapshot-projection.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.0.0
|
|
2
|
+
"version": "4.0.0",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@vuu-ui/vuu-data-local": "4.0.0
|
|
13
|
-
"@vuu-ui/vuu-utils": "4.0.0
|
|
12
|
+
"@vuu-ui/vuu-data-local": "4.0.0",
|
|
13
|
+
"@vuu-ui/vuu-utils": "4.0.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@vuu-ui/vuu-protocol-types": "4.0.0
|
|
17
|
-
"@vuu-ui/vuu-data-types": "4.0.0
|
|
18
|
-
"@vuu-ui/vuu-table-types": "4.0.0
|
|
16
|
+
"@vuu-ui/vuu-protocol-types": "4.0.0",
|
|
17
|
+
"@vuu-ui/vuu-data-types": "4.0.0",
|
|
18
|
+
"@vuu-ui/vuu-table-types": "4.0.0"
|
|
19
19
|
},
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"files": [
|
|
@@ -1,12 +1,63 @@
|
|
|
1
|
-
import { random } from "../../data-utils.js";
|
|
2
1
|
import { buildDataColumnMap } from "../../Table.js";
|
|
3
2
|
import { schemas } from "../simul-schemas.js";
|
|
4
|
-
import { instrumentsData } from "./instruments.js";
|
|
3
|
+
import { InstrumentColumnMap, instrumentsData } from "./instruments.js";
|
|
5
4
|
import TableContainer from "../../core/table/TableContainer.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const createRandom = (seed)=>()=>{
|
|
6
|
+
seed = seed + 0x6d2b79f5 | 0;
|
|
7
|
+
let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
|
|
8
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
9
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
10
|
+
};
|
|
11
|
+
const randomInt = (next, min, max)=>Math.floor(next() * (max - min + 1)) + min;
|
|
12
|
+
const toScaledDecimal = (value, decimals)=>String(Math.round(value * 10 ** decimals));
|
|
13
|
+
const scaledDecimalEdgeCases = (decimals)=>[
|
|
14
|
+
"0",
|
|
15
|
+
toScaledDecimal(-1234.5, decimals),
|
|
16
|
+
toScaledDecimal(100, decimals),
|
|
17
|
+
"1",
|
|
18
|
+
"-1",
|
|
19
|
+
toScaledDecimal(1.5, decimals)
|
|
20
|
+
];
|
|
21
|
+
const scaledDecimalColumn = (seed, decimals, min, max)=>{
|
|
22
|
+
const next = createRandom(seed);
|
|
23
|
+
const edgeCases = scaledDecimalEdgeCases(decimals);
|
|
24
|
+
const scale = 10 ** decimals;
|
|
25
|
+
return (rowIndex)=>rowIndex < edgeCases.length ? edgeCases[rowIndex] : String(randomInt(next, min * scale, max * scale));
|
|
26
|
+
};
|
|
27
|
+
const nextNotional = scaledDecimalColumn(2, 2, -1000000, 10000000);
|
|
28
|
+
const nextClosePrice = scaledDecimalColumn(4, 4, 0, 5000);
|
|
29
|
+
const nextFxRate = scaledDecimalColumn(6, 6, 0.5, 2);
|
|
30
|
+
const nextWeight = scaledDecimalColumn(8, 8, 0, 0.05);
|
|
31
|
+
const nextRandom = createRandom(1);
|
|
32
|
+
const ONE_DAY = 86400000;
|
|
33
|
+
const today = new Date();
|
|
34
|
+
today.setHours(0, 0, 0, 0);
|
|
35
|
+
const startOfToday = today.getTime();
|
|
36
|
+
const columns = schemas.instrumentsExtended.columns;
|
|
37
|
+
const instrumentsExtendedData = instrumentsData.map((instrument, rowIndex)=>{
|
|
38
|
+
const values = {
|
|
39
|
+
bbg: instrument[InstrumentColumnMap.bbg],
|
|
40
|
+
currency: instrument[InstrumentColumnMap.currency],
|
|
41
|
+
description: instrument[InstrumentColumnMap.description],
|
|
42
|
+
exchange: instrument[InstrumentColumnMap.exchange],
|
|
43
|
+
isin: instrument[InstrumentColumnMap.string],
|
|
44
|
+
lotSize: instrument[InstrumentColumnMap.number],
|
|
45
|
+
ric: instrument[InstrumentColumnMap.ric],
|
|
46
|
+
side: nextRandom() < 0.5 ? "B" : "S",
|
|
47
|
+
supported: nextRandom() < 0.5,
|
|
48
|
+
wishlist: nextRandom() < 0.5,
|
|
49
|
+
lastUpdated: instrument[InstrumentColumnMap.vuuUpdatedTimestamp],
|
|
50
|
+
price: Math.round(100000 * nextRandom()) / 100,
|
|
51
|
+
notional: nextNotional(rowIndex),
|
|
52
|
+
closePrice: nextClosePrice(rowIndex),
|
|
53
|
+
fxRate: nextFxRate(rowIndex),
|
|
54
|
+
weight: nextWeight(rowIndex),
|
|
55
|
+
tradeDate: startOfToday - rowIndex % 30 * ONE_DAY,
|
|
56
|
+
vuuCreatedTimestamp: instrument[InstrumentColumnMap.vuuCreatedTimestamp],
|
|
57
|
+
vuuUpdatedTimestamp: instrument[InstrumentColumnMap.vuuUpdatedTimestamp],
|
|
58
|
+
vuuMsg: ""
|
|
59
|
+
};
|
|
60
|
+
return columns.map(({ name })=>values[name]);
|
|
61
|
+
});
|
|
11
62
|
const instrumentsExtendedTable = TableContainer.createTable(schemas.instrumentsExtended, instrumentsExtendedData, buildDataColumnMap(schemas, "instrumentsExtended"));
|
|
12
63
|
export { instrumentsExtendedTable };
|
|
@@ -73,6 +73,10 @@ const schemas = {
|
|
|
73
73
|
name: "ric",
|
|
74
74
|
serverDataType: "string"
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
name: "side",
|
|
78
|
+
serverDataType: "char"
|
|
79
|
+
},
|
|
76
80
|
{
|
|
77
81
|
name: "supported",
|
|
78
82
|
serverDataType: "boolean"
|
|
@@ -90,8 +94,24 @@ const schemas = {
|
|
|
90
94
|
serverDataType: "double"
|
|
91
95
|
},
|
|
92
96
|
{
|
|
93
|
-
name: "
|
|
94
|
-
serverDataType: "
|
|
97
|
+
name: "notional",
|
|
98
|
+
serverDataType: "scaleddecimal2"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "closePrice",
|
|
102
|
+
serverDataType: "scaleddecimal4"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "fxRate",
|
|
106
|
+
serverDataType: "scaleddecimal6"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "weight",
|
|
110
|
+
serverDataType: "scaleddecimal8"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "tradeDate",
|
|
114
|
+
serverDataType: "epochtimestamp"
|
|
95
115
|
},
|
|
96
116
|
...VUU_DEFAULT_COLUMNS
|
|
97
117
|
],
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import type { VuuModuleUser } from "../user/CurrentUser";
|
|
3
|
+
import type { ColumnMap } from "@vuu-ui/vuu-utils";
|
|
4
|
+
import type tableContainer from "../table/TableContainer";
|
|
5
|
+
export type TableRow = Array<bigint | VuuRowDataItemType>;
|
|
6
|
+
export type RowPredicate = (row: TableRow) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Read access to a single row, by column name.
|
|
9
|
+
*/
|
|
10
|
+
export interface RowData {
|
|
11
|
+
get: (columnName: string) => bigint | VuuRowDataItemType | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Restricts the rows of a table visible through a viewport, typically
|
|
15
|
+
* based on the user that owns the viewport. Permission filters are applied
|
|
16
|
+
* in addition to any client filter.
|
|
17
|
+
*/
|
|
18
|
+
export interface PermissionFilter {
|
|
19
|
+
/**
|
|
20
|
+
* Bind this permission filter to the column layout of a table, returning a
|
|
21
|
+
* predicate that can be evaluated against raw table rows.
|
|
22
|
+
*/
|
|
23
|
+
createPredicate: (columnMap: ColumnMap) => RowPredicate;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The subset of viewport state available to a PermissionFunction.
|
|
27
|
+
*/
|
|
28
|
+
export interface PermissionViewport {
|
|
29
|
+
id: string;
|
|
30
|
+
user: VuuModuleUser;
|
|
31
|
+
}
|
|
32
|
+
export type TableContainer = typeof tableContainer;
|
|
33
|
+
/**
|
|
34
|
+
* Creates the PermissionFilter for a viewport. Configured per table on a VuuModule.
|
|
35
|
+
*/
|
|
36
|
+
export type PermissionFunction = (viewport: PermissionViewport, tableContainer: TableContainer) => PermissionFilter;
|
|
37
|
+
export declare const AllowAllPermissionFilter: PermissionFilter;
|
|
38
|
+
export declare const DenyAllPermissionFilter: PermissionFilter;
|
|
39
|
+
export declare function PermissionFilter(rowPredicate: (row: RowData) => boolean): PermissionFilter;
|
|
40
|
+
export declare function PermissionFilter(columnName: string, allowedValues: Set<string>): PermissionFilter;
|
|
41
|
+
export declare function PermissionFilter(filters: Iterable<PermissionFilter>): PermissionFilter;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Table } from "../../Table";
|
|
2
|
+
import type { RowPredicate } from "./PermissionFilter";
|
|
3
|
+
/**
|
|
4
|
+
* A per-viewport view of a source table, containing only those rows that
|
|
5
|
+
* satisfy a permission predicate. Changes to the source table are mirrored,
|
|
6
|
+
* an update that moves a row into or out of the permitted set is emitted as
|
|
7
|
+
* an insert or delete.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PermissionFilteredTable extends Table {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(source: Table, predicate: RowPredicate);
|
|
12
|
+
get source(): Table;
|
|
13
|
+
/**
|
|
14
|
+
* Start mirroring changes from the source table. Invoked on construction,
|
|
15
|
+
* only needs to be called again following dispose.
|
|
16
|
+
*/
|
|
17
|
+
attach(): void;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
private contains;
|
|
20
|
+
private handleSourceInsert;
|
|
21
|
+
private handleSourceUpdate;
|
|
22
|
+
private handleSourceDelete;
|
|
23
|
+
private replaceRow;
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user that owns a viewport, as seen by permission functions and
|
|
3
|
+
* rpc services.
|
|
4
|
+
*/
|
|
5
|
+
export interface VuuModuleUser {
|
|
6
|
+
authorizations: string[];
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const getCurrentUser: () => VuuModuleUser;
|
|
10
|
+
/**
|
|
11
|
+
* Applies to viewports created after the change. Pass undefined to restore
|
|
12
|
+
* the default user.
|
|
13
|
+
*/
|
|
14
|
+
export declare const setCurrentUser: (user?: string | VuuModuleUser) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ManagedModule } from "@heswell/module-admin/contracts";
|
|
2
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import { VuuModule, type RpcService } from "../core/module/VuuModule";
|
|
4
|
+
import { type Table } from "../Table";
|
|
5
|
+
import { type ModuleAdminTableName } from "./module-admin-schemas";
|
|
6
|
+
import { type ModuleAdminSnapshot } from "./snapshot-projection";
|
|
7
|
+
type ModuleAdminTables = Record<ModuleAdminTableName, Table>;
|
|
8
|
+
export declare const MODULE_ADMIN_INITIAL_SNAPSHOT: ModuleAdminSnapshot;
|
|
9
|
+
/**
|
|
10
|
+
* In-browser MODULE_DISCOVERY server. Supports the module admin RPCs from
|
|
11
|
+
* `@heswell/module-admin/contracts` on both tables; state is held in memory.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ModuleAdminModule extends VuuModule<ModuleAdminTableName> {
|
|
14
|
+
#private;
|
|
15
|
+
private readonly now;
|
|
16
|
+
constructor(snapshot?: ModuleAdminSnapshot, now?: () => number);
|
|
17
|
+
/** Current module state. */
|
|
18
|
+
get modules(): readonly ManagedModule[];
|
|
19
|
+
get menus(): {
|
|
20
|
+
modulePermissions: undefined;
|
|
21
|
+
modules: undefined;
|
|
22
|
+
};
|
|
23
|
+
protected get includeDefaultServices(): boolean;
|
|
24
|
+
get menuServices(): undefined;
|
|
25
|
+
get schemas(): Record<ModuleAdminTableName, Readonly<TableSchema>>;
|
|
26
|
+
private service;
|
|
27
|
+
get services(): Record<ModuleAdminTableName, RpcService[]>;
|
|
28
|
+
get tables(): ModuleAdminTables;
|
|
29
|
+
get visualLinks(): undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare const moduleAdminModule: ModuleAdminModule;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ModuleAdminModule, MODULE_ADMIN_INITIAL_SNAPSHOT, moduleAdminModule, } from "./ModuleAdminModule";
|
|
2
|
+
export { MODULE_ADMIN_MODULE_NAME, MODULE_ADMIN_TABLE_SCHEMAS, type ModuleAdminTableName, } from "./module-admin-schemas";
|
|
3
|
+
export { projectModuleAdminSnapshot, reconcileModuleAdminTables, type ModuleAdminSnapshot, } from "./snapshot-projection";
|
|
4
|
+
export type { ManagedModule, ModuleAccessRole, ModuleConfig, ModuleDefinition, ModulePermissionRow, ModuleRow, } from "@heswell/module-admin/contracts";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
export declare const MODULE_ADMIN_MODULE_NAME = "MODULE_DISCOVERY";
|
|
3
|
+
export type ModuleAdminTableName = "modules" | "modulePermissions";
|
|
4
|
+
export declare const MODULE_ADMIN_TABLE_SCHEMAS: Readonly<Record<ModuleAdminTableName, Readonly<TableSchema>>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ManagedModule } from "@heswell/module-admin/contracts";
|
|
2
|
+
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import type { Table } from "../Table";
|
|
4
|
+
import type { ModuleAdminTableName } from "./module-admin-schemas";
|
|
5
|
+
type Row = Array<bigint | VuuRowDataItemType>;
|
|
6
|
+
type Tables = Record<ModuleAdminTableName, Table>;
|
|
7
|
+
export type ModuleAdminSnapshot = {
|
|
8
|
+
modules: readonly ManagedModule[];
|
|
9
|
+
};
|
|
10
|
+
export declare const projectModuleAdminSnapshot: (snapshot: ModuleAdminSnapshot, tables: Tables) => Record<ModuleAdminTableName, Row[]>;
|
|
11
|
+
/** Brings the tables into line with the snapshot, emitting row-level updates. */
|
|
12
|
+
export declare const reconcileModuleAdminTables: (snapshot: ModuleAdminSnapshot, tables: Tables) => void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { type RpcService, VuuModule } from "../core/module/VuuModule";
|
|
4
|
+
import type { PermissionFunction } from "../core/filter/PermissionFilter";
|
|
5
|
+
import { type Table } from "../Table";
|
|
6
|
+
import { type ColumnDefinition } from "./NotificationsSchema";
|
|
7
|
+
export type NotificationsTableName = "notifications";
|
|
8
|
+
/**
|
|
9
|
+
* Source of notifications. Started when the first dataSource is
|
|
10
|
+
* created for the notifications table, or explicitly via module.start().
|
|
11
|
+
*/
|
|
12
|
+
export interface NotificationsProvider {
|
|
13
|
+
start: () => void;
|
|
14
|
+
stop: () => void;
|
|
15
|
+
}
|
|
16
|
+
export type NotificationsProviderFactory = (table: Table) => NotificationsProvider;
|
|
17
|
+
/**
|
|
18
|
+
* A notification to publish. Values are keyed by column name; columns not
|
|
19
|
+
* supplied are defaulted. `expiryTime` (epoch ms) schedules deletion of the row.
|
|
20
|
+
*/
|
|
21
|
+
export interface NotificationInput {
|
|
22
|
+
id?: string;
|
|
23
|
+
type?: string;
|
|
24
|
+
expiryTime?: number;
|
|
25
|
+
title?: string;
|
|
26
|
+
message?: string;
|
|
27
|
+
level?: string;
|
|
28
|
+
audience?: string;
|
|
29
|
+
[columnName: string]: VuuRowDataItemType | undefined;
|
|
30
|
+
}
|
|
31
|
+
export type NotificationsServiceFactory = (table: Table, module: NotificationModule) => RpcService[];
|
|
32
|
+
/**
|
|
33
|
+
* A generic Notifications module, exposing a single 'notifications' table.
|
|
34
|
+
* The source of notifications (provider), the rows visible to each user
|
|
35
|
+
* (permissionFunction) and any rpc services (serviceFactory) are supplied
|
|
36
|
+
* by the consumer. Any additional columns are appended to the generic
|
|
37
|
+
* notification columns (see NotificationsSchema).
|
|
38
|
+
*/
|
|
39
|
+
export declare class NotificationModule extends VuuModule<NotificationsTableName> {
|
|
40
|
+
#private;
|
|
41
|
+
static readonly NAME = "NOTIFICATIONS";
|
|
42
|
+
static readonly TABLE_NAME: "notifications";
|
|
43
|
+
constructor(providerFactory: NotificationsProviderFactory, permissionFunction: PermissionFunction, serviceFactory: NotificationsServiceFactory, ...additionalColumns: ColumnDefinition[]);
|
|
44
|
+
protected beforeCreateDataSource(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Inserts a notification row, as a server-side publisher would. Defaults:
|
|
47
|
+
* a random `id`, `type` "toast", `level` "INFO", `audience` "all" and
|
|
48
|
+
* empty strings for other string columns. Returns the row id.
|
|
49
|
+
*/
|
|
50
|
+
publish(notification?: NotificationInput): string;
|
|
51
|
+
get isRunning(): boolean;
|
|
52
|
+
start(): void;
|
|
53
|
+
stop(): void;
|
|
54
|
+
get menus(): undefined;
|
|
55
|
+
get menuServices(): undefined;
|
|
56
|
+
get schemas(): Record<"notifications", TableSchema>;
|
|
57
|
+
get services(): Record<"notifications", RpcService[]>;
|
|
58
|
+
get tables(): Record<"notifications", Table>;
|
|
59
|
+
get visualLinks(): undefined;
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SchemaColumn } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
/**
|
|
3
|
+
* Accepts either a SchemaColumn or a column definition in the Scala server
|
|
4
|
+
* 'name:Type' format, e.g. "source:String", "priority:Int".
|
|
5
|
+
*/
|
|
6
|
+
export type ColumnDefinition = SchemaColumn | string;
|
|
7
|
+
export declare const toColumn: (columnDefinition: ColumnDefinition) => SchemaColumn;
|
|
8
|
+
export declare const NotificationsSchema: {
|
|
9
|
+
Id: string;
|
|
10
|
+
Type: string;
|
|
11
|
+
ExpiryTime: string;
|
|
12
|
+
Title: string;
|
|
13
|
+
Message: string;
|
|
14
|
+
Level: string;
|
|
15
|
+
Audience: string;
|
|
16
|
+
/**
|
|
17
|
+
* The generic notification columns, plus any additional columns.
|
|
18
|
+
*/
|
|
19
|
+
allFrom: (...additionalColumns: ColumnDefinition[]) => SchemaColumn[];
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./NotificationModule";
|
|
2
|
+
export * from "./NotificationsSchema";
|
|
3
|
+
export * from "./simulated/DismissNotificationRpcHandler";
|
|
4
|
+
export * from "./simulated/SimulatedNotificationsModule";
|
|
5
|
+
export * from "./simulated/SimulatedNotificationsProvider";
|
|
6
|
+
export * from "./simulated/notificationsModule";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RpcService } from "../../core/module/VuuModule";
|
|
2
|
+
import type { Table } from "../../Table";
|
|
3
|
+
import type { NotificationModule } from "../NotificationModule";
|
|
4
|
+
/**
|
|
5
|
+
* Marks the notifications selected in the requesting viewport as dismissed
|
|
6
|
+
* by the user that owns the viewport.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DismissNotificationRpcHandler: (table: Table, module: NotificationModule) => RpcService[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NotificationModule } from "../NotificationModule";
|
|
2
|
+
export interface SimulatedNotificationsModuleOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Generate random notifications. When false, notifications are only
|
|
5
|
+
* created by calls to `publish`. Default true.
|
|
6
|
+
*/
|
|
7
|
+
simulate?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const SimulatedNotificationsModule: ({ simulate, }?: SimulatedNotificationsModuleOptions) => NotificationModule;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Table } from "../../Table";
|
|
2
|
+
import type { NotificationsProvider } from "../NotificationModule";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal implementation of the subset of Java String.format used by
|
|
5
|
+
* the message templates: %d, %0nd and %%. Args are consumed in order.
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatMessage: (format: string, ...args: number[]) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Generates random notifications. Seeds an initial set of notifications on
|
|
10
|
+
* start then, on each cycle, deletes expired notifications and adds a new
|
|
11
|
+
* notification if fewer than the maximum are active.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SimulatedNotificationsProvider implements NotificationsProvider {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(table: Table);
|
|
16
|
+
start(): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
runOnce: () => void;
|
|
19
|
+
private generateRandomNotification;
|
|
20
|
+
private toDataRow;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RowAtIndexFunc<T = unknown> = (index: number) => T | undefined;
|
|
2
|
+
export declare class ArrayProxy<T = string> {
|
|
3
|
+
#private;
|
|
4
|
+
length: number;
|
|
5
|
+
constructor(size: number, getRow: RowAtIndexFunc);
|
|
6
|
+
map: (func: (item: T, i: number) => unknown) => ArrayProxy<string>;
|
|
7
|
+
slice: (from: number, to: number) => unknown[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataSourceBase, DataSourceRowWithBigint, RowSelectionEventHandler } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
export declare class RuntimeVisualLink {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(childDataSource: DataSourceBase<DataSourceRowWithBigint>, parentDataSource: DataSourceBase<DataSourceRowWithBigint>, childColumnName: string, parentColumnName: string);
|
|
5
|
+
destroy(): void;
|
|
6
|
+
remove(): void;
|
|
7
|
+
handleParentSelectEvent: RowSelectionEventHandler;
|
|
8
|
+
private pickUniqueSelectedValues;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { ColumnMap, EventEmitter } from "@vuu-ui/vuu-utils";
|
|
4
|
+
import { UpdateGenerator } from "./rowUpdates";
|
|
5
|
+
export type TableEvents = {
|
|
6
|
+
delete: (key: string) => void;
|
|
7
|
+
insert: (row: Array<bigint | VuuRowDataItemType>) => void;
|
|
8
|
+
update: (row: Array<bigint | VuuRowDataItemType>, columnName?: string, sessionId?: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare class Table extends EventEmitter<TableEvents> {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(schema: TableSchema, data: Array<Array<VuuRowDataItemType | bigint>>, dataMap: ColumnMap, updateGenerator?: UpdateGenerator);
|
|
13
|
+
private buildIndex;
|
|
14
|
+
get data(): (bigint | VuuRowDataItemType)[][];
|
|
15
|
+
get map(): ColumnMap;
|
|
16
|
+
get schema(): TableSchema;
|
|
17
|
+
get name(): string;
|
|
18
|
+
delete(key: string, emitEvent?: boolean): void;
|
|
19
|
+
insert(row: Array<bigint | VuuRowDataItemType>, emitEvent?: boolean): void;
|
|
20
|
+
findByKey(key: string): (bigint | VuuRowDataItemType)[];
|
|
21
|
+
update(key: string, columnName: string, value: bigint | VuuRowDataItemType): void;
|
|
22
|
+
updateRow(row: Array<bigint | VuuRowDataItemType>): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function buildDataColumnMapFromSchema(schema: Readonly<TableSchema>): ColumnMap;
|
|
25
|
+
/**
|
|
26
|
+
* Build a data ColumnMap for a table in the provided schema.
|
|
27
|
+
* A data ColumnMap is a mapping from a raw data array to a map, keyed
|
|
28
|
+
* by column name with no additional metadata.
|
|
29
|
+
*
|
|
30
|
+
* @param schemas
|
|
31
|
+
* @param tableName
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildDataColumnMap<TableName extends string = string>(schemas: Readonly<Record<TableName, Readonly<TableSchema>>>, tableName: TableName): ColumnMap;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ArrayDataSource, type ArrayDataSourceConstructorProps } from "@vuu-ui/vuu-data-local";
|
|
2
|
+
import type { DataSourceBase, DataSource, DataSourceRowWithBigint, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceVisualLinkCreatedMessage, DeleteRowMode, CopyOption, EditSessionMode, SessionDataSourceOverrides, SessionType } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import type { LinkDescriptorWithLabel, RpcResult, RpcResultError, RpcResultSuccess, VuuCreateVisualLink, VuuMenu, VuuRemoveVisualLink, VuuRowDataItemType, VuuRpcMenuRequest, VuuRpcMenuResponse, VuuRpcServiceRequest } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import type { IVuuModule, RpcMenuService, RpcService } from "./core/module/VuuModule";
|
|
5
|
+
import type { Table } from "./Table";
|
|
6
|
+
export type VisualLinkHandler = (message: VuuCreateVisualLink | VuuRemoveVisualLink) => Promise<DataSourceVisualLinkCreatedMessage | void>;
|
|
7
|
+
export interface TickingArrayDataSourceConstructorProps extends Omit<ArrayDataSourceConstructorProps, "data"> {
|
|
8
|
+
data?: Array<VuuRowDataItemType[]>;
|
|
9
|
+
getVisualLinks?: (tableName: string) => LinkDescriptorWithLabel[] | undefined;
|
|
10
|
+
menu?: VuuMenu;
|
|
11
|
+
rpcMenuServices?: RpcMenuService[];
|
|
12
|
+
rpcServices?: RpcService[];
|
|
13
|
+
table?: Table;
|
|
14
|
+
visualLinkService?: VisualLinkHandler;
|
|
15
|
+
vuuModule?: IVuuModule;
|
|
16
|
+
}
|
|
17
|
+
export declare class TickingArrayDataSource extends ArrayDataSource {
|
|
18
|
+
#private;
|
|
19
|
+
constructor({ data, getVisualLinks, rpcServices, rpcMenuServices, session, table, menu, visualLink, visualLinkService, vuuModule, ...arrayDataSourceProps }: TickingArrayDataSourceConstructorProps);
|
|
20
|
+
updateRowWithSessionCheck: (row: Array<bigint | VuuRowDataItemType>, columnName?: string, sessionId?: string) => void;
|
|
21
|
+
subscribe(subscribeProps: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
|
|
22
|
+
unsubscribe(): void;
|
|
23
|
+
set links(links: LinkDescriptorWithLabel[] | undefined);
|
|
24
|
+
get links(): LinkDescriptorWithLabel[] | undefined;
|
|
25
|
+
getSelectedRowIds(): string[];
|
|
26
|
+
isSessionDataSourceOf(dataSource: DataSource): boolean;
|
|
27
|
+
createSessionDataSource(copyOption: CopyOption, sessionType?: SessionType, overrides?: SessionDataSourceOverrides): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
|
|
28
|
+
beginEditSession(editSessionMode?: EditSessionMode, overrides?: SessionDataSourceOverrides): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
|
|
29
|
+
editCell(key: string, column: string, data: VuuRowDataItemType): Promise<RpcResultError | RpcResultSuccess>;
|
|
30
|
+
addRow: (rowData?: Record<string, VuuRowDataItemType>) => Promise<RpcResult>;
|
|
31
|
+
deleteRow: (key: string, mode?: DeleteRowMode) => Promise<true | string>;
|
|
32
|
+
deleteSelectedRows: (mode?: DeleteRowMode) => Promise<RpcResultSuccess | RpcResultError>;
|
|
33
|
+
undoRowChange: (key: string) => Promise<RpcResultSuccess | RpcResultError>;
|
|
34
|
+
set columns(columns: string[]);
|
|
35
|
+
get columns(): string[];
|
|
36
|
+
endEditSession(saveChanges?: boolean): Promise<void>;
|
|
37
|
+
rpcRequest(rpcRequest: Omit<VuuRpcServiceRequest, "context">): Promise<RpcResultSuccess | RpcResultError>;
|
|
38
|
+
menuRpcCall(rpcRequest: Omit<VuuRpcMenuRequest, "vpId">): Promise<VuuRpcMenuResponse>;
|
|
39
|
+
getTypeaheadSuggestions(column: string, pattern?: string): Promise<string[]>;
|
|
40
|
+
get visualLink(): LinkDescriptorWithLabel | undefined;
|
|
41
|
+
set visualLink(visualLink: LinkDescriptorWithLabel | undefined);
|
|
42
|
+
freeze(): void;
|
|
43
|
+
unfreeze(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { VuuRange } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import type { UpdateGenerator } from "./rowUpdates";
|
|
3
|
+
import { Table } from "./Table";
|
|
4
|
+
export declare class BaseUpdateGenerator implements UpdateGenerator {
|
|
5
|
+
private table;
|
|
6
|
+
private range;
|
|
7
|
+
private updating;
|
|
8
|
+
private timer;
|
|
9
|
+
private tickingColumns;
|
|
10
|
+
constructor(tickingColumns: {
|
|
11
|
+
[key: string]: number;
|
|
12
|
+
});
|
|
13
|
+
setRange(range: VuuRange): void;
|
|
14
|
+
setTable(table: Table): void;
|
|
15
|
+
private startUpdating;
|
|
16
|
+
private stopUpdating;
|
|
17
|
+
update: () => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VuuMenu } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import { RpcMenuService, ServiceHandler, VuuModule } from "../core/module/VuuModule";
|
|
3
|
+
import { BasketsTableName } from "./basket-schemas";
|
|
4
|
+
import { type Table } from "../Table";
|
|
5
|
+
export declare const createBasketTradingRow: (basketId: string, basketName: string, side?: string, status?: string) => (string | number)[];
|
|
6
|
+
/**
|
|
7
|
+
* This is an example of how we might extend the built-in VuuModule to
|
|
8
|
+
* implement a module-specific service in such a way that it can invoke
|
|
9
|
+
* methods on the VuuModule.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BasketModule extends VuuModule<BasketsTableName> {
|
|
12
|
+
#private;
|
|
13
|
+
constructor();
|
|
14
|
+
get menus(): Record<BasketsTableName, VuuMenu | undefined>;
|
|
15
|
+
get schemas(): Readonly<Record<BasketsTableName, Readonly<import("@vuu-ui/vuu-data-types").TableSchema>>>;
|
|
16
|
+
get services(): {
|
|
17
|
+
algoType: undefined;
|
|
18
|
+
basketTradingConstituent: undefined;
|
|
19
|
+
basketConstituent: undefined;
|
|
20
|
+
priceStrategyType: undefined;
|
|
21
|
+
basket: {
|
|
22
|
+
rpcName: string;
|
|
23
|
+
service: ServiceHandler;
|
|
24
|
+
}[];
|
|
25
|
+
basketTrading: {
|
|
26
|
+
rpcName: string;
|
|
27
|
+
service: ServiceHandler;
|
|
28
|
+
}[];
|
|
29
|
+
basketTradingConstituentJoin: {
|
|
30
|
+
rpcName: string;
|
|
31
|
+
service: ServiceHandler;
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
get menuServices(): Record<BasketsTableName, RpcMenuService[] | undefined> | undefined;
|
|
35
|
+
get tables(): Record<BasketsTableName, Table>;
|
|
36
|
+
get visualLinks(): {
|
|
37
|
+
algoType: undefined;
|
|
38
|
+
basket: undefined;
|
|
39
|
+
basketTrading: undefined;
|
|
40
|
+
basketTradingConstituent: undefined;
|
|
41
|
+
basketTradingConstituentJoin: undefined;
|
|
42
|
+
priceStrategyType: undefined;
|
|
43
|
+
basketConstituent: {
|
|
44
|
+
fromColumn: string;
|
|
45
|
+
toColumn: string;
|
|
46
|
+
toTable: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
private createTradingBasket;
|
|
50
|
+
private createNewBasket;
|
|
51
|
+
private sendToMarket;
|
|
52
|
+
private takeOffMarket;
|
|
53
|
+
private addConstituent;
|
|
54
|
+
}
|
|
55
|
+
export declare const basketModule: BasketModule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
export type BasketsTableName = "algoType" | "basket" | "basketConstituent" | "basketTrading" | "basketTradingConstituent" | "basketTradingConstituentJoin" | "priceStrategyType";
|
|
4
|
+
export declare const schemas: Readonly<Record<BasketsTableName, Readonly<TableSchema>>>;
|
|
5
|
+
export type BasketVuuTable = {
|
|
6
|
+
module: "BASKET";
|
|
7
|
+
table: BasketsTableName;
|
|
8
|
+
};
|
|
9
|
+
export declare const isBasketTable: (table: VuuTable) => table is BasketVuuTable;
|