@heswell/vuu-data-engine-local 0.0.0-stage → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -2
- package/index.js +9494 -0
- package/package.json +37 -4
- package/src/ArrayProxy.d.ts +8 -0
- package/src/EngineDataSource.d.ts +109 -0
- package/src/ModuleDataSource.d.ts +41 -0
- package/src/RowKeys.d.ts +17 -0
- package/src/RuntimeVisualLink.d.ts +16 -0
- package/src/Table.d.ts +46 -0
- package/src/UpdateGenerator.d.ts +18 -0
- package/src/basket/BasketModule.d.ts +55 -0
- package/src/basket/basket-schemas.d.ts +9 -0
- package/src/basket/index.d.ts +2 -0
- package/src/basket/reference-data/constituents.d.ts +3 -0
- package/src/basket/reference-data/ftse100.d.ts +2 -0
- package/src/basket/reference-data/hsi.d.ts +2 -0
- package/src/basket/reference-data/nasdaq100.d.ts +2 -0
- package/src/basket/reference-data/prices.d.ts +24 -0
- package/src/basket/reference-data/sp500.d.ts +2 -0
- package/src/core/filter/PermissionFilter.d.ts +41 -0
- package/src/core/module/ModuleContainer.d.ts +15 -0
- package/src/core/module/VuuModule.d.ts +103 -0
- package/src/core/table/TableContainer.d.ts +21 -0
- package/src/core/user/CurrentUser.d.ts +14 -0
- package/src/data-utils.d.ts +7 -0
- package/src/default-column-definitions.d.ts +2 -0
- package/src/index.d.ts +19 -0
- package/src/local-datasource-provider/LocalDatasourceProvider.d.ts +18 -0
- package/src/makeSuggestions.d.ts +3 -0
- package/src/module-admin/ModuleAdminModule.d.ts +32 -0
- package/src/module-admin/index.d.ts +4 -0
- package/src/module-admin/module-admin-schemas.d.ts +4 -0
- package/src/module-admin/snapshot-projection.d.ts +13 -0
- package/src/notifications/NotificationModule.d.ts +39 -0
- package/src/notifications/NotificationsSchema.d.ts +20 -0
- package/src/notifications/index.d.ts +6 -0
- package/src/notifications/simulated/DismissNotificationRpcHandler.d.ts +8 -0
- package/src/notifications/simulated/SimulatedNotificationsModule.d.ts +2 -0
- package/src/notifications/simulated/SimulatedNotificationsProvider.d.ts +21 -0
- package/src/notifications/simulated/notificationsModule.d.ts +5 -0
- package/src/rowUpdates.d.ts +15 -0
- package/src/schemas.d.ts +10 -0
- package/src/session-table-utils.d.ts +6 -0
- package/src/simul/SimulModule.d.ts +24 -0
- package/src/simul/index.d.ts +2 -0
- package/src/simul/reference-data/accounts.d.ts +1 -0
- package/src/simul/reference-data/algos.d.ts +1 -0
- package/src/simul/reference-data/currencies.d.ts +1 -0
- package/src/simul/reference-data/index.d.ts +5 -0
- package/src/simul/reference-data/instrument-prices.d.ts +60 -0
- package/src/simul/reference-data/instruments-extended.d.ts +1 -0
- package/src/simul/reference-data/instruments.d.ts +35 -0
- package/src/simul/reference-data/isin-generator/convert-string-to-base-ten-number.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/fixtures/alphabet.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/fixtures/alphanumeric-values.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/fixtures/base-ten-numbers.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-cusip-check-code.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-cusip-without-check-code.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-cusip.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-random-alphanumeric.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-random-base-ten-number.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/index.d.ts +1 -0
- package/src/simul/reference-data/isin-generator/is-odd.d.ts +1 -0
- package/src/simul/reference-data/locations.d.ts +4 -0
- package/src/simul/reference-data/lotsizes.d.ts +1 -0
- package/src/simul/reference-data/orderStatus.d.ts +1 -0
- package/src/simul/reference-data/orders.d.ts +36 -0
- package/src/simul/reference-data/parent-child-orders.d.ts +4 -0
- package/src/simul/reference-data/priceStrategies.d.ts +1 -0
- package/src/simul/reference-data/prices.d.ts +34 -0
- package/src/simul/reference-data/sides.d.ts +1 -0
- package/src/simul/simul-schemas.d.ts +9 -0
- package/src/test/TestModule.d.ts +16 -0
- package/src/test/index.d.ts +1 -0
- package/src/user-admin/UserAdminModule.d.ts +54 -0
- package/src/user-admin/index.d.ts +3 -0
- package/src/user-admin/initialSnapshot.d.ts +2 -0
- package/src/user-admin/snapshot-projection.d.ts +9 -0
- package/src/vuu-row-generator.d.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heswell/vuu-data-engine-local",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "In-browser Vuu server (VuuModule, tables, EngineDataSource) built on @heswell/vuu-table and @heswell/vuu-viewport",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"import": "./index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"author": "heswell",
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@heswell/module-admin": "2.0.0",
|
|
22
|
+
"@heswell/user-admin": "1.0.2",
|
|
23
|
+
"@heswell/vuu-table": "1.0.1",
|
|
24
|
+
"@heswell/vuu-viewport": "1.1.2",
|
|
25
|
+
"@vuu-ui/vuu-data-editing": "4.0.0-alpha.20",
|
|
26
|
+
"@vuu-ui/vuu-data-local": "4.0.0-alpha.20",
|
|
27
|
+
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.20",
|
|
28
|
+
"@vuu-ui/vuu-utils": "4.0.0-alpha.20"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@vuu-ui/core": "^4.0.0-alpha.20",
|
|
32
|
+
"@vuu-ui/vuu-data-types": "^4.0.0-alpha.20",
|
|
33
|
+
"@vuu-ui/vuu-filter-types": "^4.0.0-alpha.20",
|
|
34
|
+
"@vuu-ui/vuu-protocol-types": "^4.0.0-alpha.20",
|
|
35
|
+
"@vuu-ui/vuu-table-types": "^4.0.0-alpha.20",
|
|
36
|
+
"react": "^19.2.3"
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": false
|
|
39
|
+
}
|
|
@@ -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,109 @@
|
|
|
1
|
+
import { type DataEngine, type LinkFilter, type RowPredicate, type ViewportEngine } from "@heswell/vuu-viewport";
|
|
2
|
+
import type { DataSourceBase, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceRowWithBigint, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import type { Filter } from "@vuu-ui/vuu-filter-types";
|
|
4
|
+
import type { LinkDescriptorWithLabel, SelectRequest, VuuAggregation, VuuGroupBy, VuuMenu, VuuRowDataItemType, VuuRpcMenuRequest, VuuRpcMenuResponse, VuuRpcServiceRequest, RpcResultError, RpcResultSuccess, VuuSort } from "@vuu-ui/vuu-protocol-types";
|
|
5
|
+
import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
6
|
+
import { type ColumnMap, EventEmitter, Range } from "@vuu-ui/vuu-utils";
|
|
7
|
+
import { Table } from "./Table";
|
|
8
|
+
export interface EngineDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
|
|
9
|
+
/**
|
|
10
|
+
* Columns available to the dataSource, defaults to the columns of the
|
|
11
|
+
* table schema. These are the default columns of the dataSource.
|
|
12
|
+
*/
|
|
13
|
+
columnDescriptors?: readonly ColumnDescriptor[];
|
|
14
|
+
/** Raw data, used to create a Table when no table is provided */
|
|
15
|
+
data?: Array<Array<bigint | VuuRowDataItemType>>;
|
|
16
|
+
/** analytics engine, defaults to the in-memory engine */
|
|
17
|
+
dataEngine?: DataEngine;
|
|
18
|
+
keyColumn?: string;
|
|
19
|
+
menu?: VuuMenu;
|
|
20
|
+
/** row level permission, applied before all other filters */
|
|
21
|
+
permissionFilter?: RowPredicate;
|
|
22
|
+
/** number of rows to fetch either side of the visible range */
|
|
23
|
+
renderBufferSize?: number;
|
|
24
|
+
table?: Table;
|
|
25
|
+
}
|
|
26
|
+
export declare class EngineDataSource extends EventEmitter<DataSourceEvents> implements DataSourceBase<DataSourceRowWithBigint> {
|
|
27
|
+
#private;
|
|
28
|
+
protected clientCallback: DataSourceSubscribeCallback | undefined;
|
|
29
|
+
protected columnDescriptors: readonly ColumnDescriptor[];
|
|
30
|
+
protected _config: WithBaseFilter<WithFullConfig> & {
|
|
31
|
+
visualLink?: LinkDescriptorWithLabel;
|
|
32
|
+
};
|
|
33
|
+
protected _menu: VuuMenu | undefined;
|
|
34
|
+
tableSchema: TableSchema;
|
|
35
|
+
viewport: string;
|
|
36
|
+
constructor({ aggregations, baseFilterSpec, columnDescriptors, columns, data, dataEngine, filterSpec, groupBy, keyColumn, menu, permissionFilter, renderBufferSize, sort, table, title, viewport, }: EngineDataSourceConstructorProps);
|
|
37
|
+
protected get engine(): ViewportEngine<DataSourceRowWithBigint>;
|
|
38
|
+
sendSizeUpdateToClient(): void;
|
|
39
|
+
/** Send every row in the current range, irrespective of what was sent before */
|
|
40
|
+
sendRowsToClient(): void;
|
|
41
|
+
subscribe({ viewport, columns, aggregations, baseFilterSpec, range, sort, groupBy, filterSpec, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
|
|
42
|
+
unsubscribe(): void;
|
|
43
|
+
suspend(): void;
|
|
44
|
+
resume(callback?: DataSourceSubscribeCallback): void;
|
|
45
|
+
disable(): void;
|
|
46
|
+
enable(): void;
|
|
47
|
+
get status(): DataSourceStatus;
|
|
48
|
+
get range(): Range;
|
|
49
|
+
set range(range: Range);
|
|
50
|
+
get maxRangeEnd(): number;
|
|
51
|
+
get pageSize(): number;
|
|
52
|
+
protected setRange(range: Range, forceFullRefresh?: boolean): void;
|
|
53
|
+
get config(): WithBaseFilter<WithFullConfig>;
|
|
54
|
+
set config(config: WithBaseFilter<WithFullConfig>);
|
|
55
|
+
get aggregations(): VuuAggregation[];
|
|
56
|
+
set aggregations(aggregations: VuuAggregation[]);
|
|
57
|
+
get baseFilter(): DataSourceFilter | undefined;
|
|
58
|
+
set baseFilter(baseFilterSpec: DataSourceFilter | undefined);
|
|
59
|
+
get columns(): string[];
|
|
60
|
+
set columns(columns: string[]);
|
|
61
|
+
get filter(): DataSourceFilter;
|
|
62
|
+
set filter(filterSpec: DataSourceFilter);
|
|
63
|
+
setFilter(filter: Filter): void;
|
|
64
|
+
clearFilter(): void;
|
|
65
|
+
get groupBy(): VuuGroupBy;
|
|
66
|
+
set groupBy(groupBy: VuuGroupBy);
|
|
67
|
+
get sort(): VuuSort;
|
|
68
|
+
set sort(sort: VuuSort);
|
|
69
|
+
get visualLink(): LinkDescriptorWithLabel | undefined;
|
|
70
|
+
set visualLink(visualLink: LinkDescriptorWithLabel | undefined);
|
|
71
|
+
setPermissionFilter(permissionFilter: RowPredicate | undefined): void;
|
|
72
|
+
/**
|
|
73
|
+
* Restrict rows to those whose column value is one of values. Used to
|
|
74
|
+
* implement visual linking. Undefined removes the restriction.
|
|
75
|
+
*/
|
|
76
|
+
setLinkFilter(linkFilter: LinkFilter | undefined): void;
|
|
77
|
+
select(selectRequest: Omit<SelectRequest, "vpId">): void;
|
|
78
|
+
get selectedRowsCount(): number;
|
|
79
|
+
/** keys (in the source table) of selected rows */
|
|
80
|
+
getSelectedRowIds(): string[];
|
|
81
|
+
/** distinct values of column across selected rows */
|
|
82
|
+
getSelectedValues(column: string): Set<VuuRowDataItemType>;
|
|
83
|
+
openTreeNode(keyOrIndex: string | number): void;
|
|
84
|
+
closeTreeNode(keyOrIndex: string | number): void;
|
|
85
|
+
get size(): number;
|
|
86
|
+
get table(): import("@vuu-ui/vuu-data-types").TableSchemaTable;
|
|
87
|
+
/** The table backing this dataSource */
|
|
88
|
+
get dataTable(): Table;
|
|
89
|
+
get columnMap(): ColumnMap;
|
|
90
|
+
/**
|
|
91
|
+
* Flat (ungrouped) rows can be resolved at any index. Grouped rows are
|
|
92
|
+
* only available within the current (buffered) client range, consistent
|
|
93
|
+
* with a remote Vuu dataSource.
|
|
94
|
+
*/
|
|
95
|
+
getRowAtIndex(rowIndex: number): DataSourceRowWithBigint | undefined;
|
|
96
|
+
getRowByKey(key: string): DataSourceRowWithBigint | undefined;
|
|
97
|
+
getTypeaheadSuggestions(column: string, pattern?: string): Promise<string[]>;
|
|
98
|
+
get links(): LinkDescriptorWithLabel[] | undefined;
|
|
99
|
+
set links(links: LinkDescriptorWithLabel[] | undefined);
|
|
100
|
+
get menu(): VuuMenu | undefined;
|
|
101
|
+
get title(): string;
|
|
102
|
+
set title(title: string);
|
|
103
|
+
rpcRequest(rpcRequest: Omit<VuuRpcServiceRequest, "context">): Promise<RpcResultSuccess | RpcResultError>;
|
|
104
|
+
menuRpcCall(rpcRequest: Omit<VuuRpcMenuRequest, "vpId">): Promise<VuuRpcMenuResponse>;
|
|
105
|
+
freeze(): void;
|
|
106
|
+
unfreeze(): void;
|
|
107
|
+
get freezeTimestamp(): number | undefined;
|
|
108
|
+
get isFrozen(): boolean;
|
|
109
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DataSourceBase, DataSource, DataSourceRowWithBigint, DataSourceSubscribeCallback, DataSourceSubscribeProps, DataSourceVisualLinkCreatedMessage, DeleteRowMode, CopyOption, EditSessionMode, SessionDataSourceOverrides, SessionType } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { LinkDescriptorWithLabel, RpcResult, RpcResultError, RpcResultSuccess, VuuCreateVisualLink, VuuRemoveVisualLink, VuuRowDataItemType, VuuRpcMenuRequest, VuuRpcMenuResponse, VuuRpcServiceRequest } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import type { IVuuModule, RpcMenuService, RpcService } from "./core/module/VuuModule";
|
|
4
|
+
import { EngineDataSource, type EngineDataSourceConstructorProps } from "./EngineDataSource";
|
|
5
|
+
export type VisualLinkHandler = (message: VuuCreateVisualLink | VuuRemoveVisualLink) => Promise<DataSourceVisualLinkCreatedMessage | undefined>;
|
|
6
|
+
export interface ModuleDataSourceConstructorProps extends EngineDataSourceConstructorProps {
|
|
7
|
+
getVisualLinks?: (tableName: string) => LinkDescriptorWithLabel[] | undefined;
|
|
8
|
+
rpcMenuServices?: RpcMenuService[];
|
|
9
|
+
rpcServices?: RpcService[];
|
|
10
|
+
session?: SessionDataSourceOverrides;
|
|
11
|
+
visualLinkService?: VisualLinkHandler;
|
|
12
|
+
vuuModule?: Pick<IVuuModule, "createDataSource">;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* An EngineDataSource hosted by a VuuModule. Adds RPC services, menus,
|
|
16
|
+
* edit sessions and visual links.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ModuleDataSource extends EngineDataSource {
|
|
19
|
+
#private;
|
|
20
|
+
constructor({ getVisualLinks, rpcServices, rpcMenuServices, session, visualLink, visualLinkService, vuuModule, ...engineDataSourceProps }: ModuleDataSourceConstructorProps);
|
|
21
|
+
subscribe(subscribeProps: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
|
|
22
|
+
set links(links: LinkDescriptorWithLabel[] | undefined);
|
|
23
|
+
get links(): LinkDescriptorWithLabel[] | undefined;
|
|
24
|
+
isSessionDataSourceOf(dataSource: DataSource): boolean;
|
|
25
|
+
createSessionDataSource(copyOption: CopyOption, sessionType?: SessionType, overrides?: SessionDataSourceOverrides): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
|
|
26
|
+
beginEditSession(editSessionMode?: EditSessionMode, overrides?: SessionDataSourceOverrides): Promise<DataSourceBase<DataSourceRowWithBigint> | undefined>;
|
|
27
|
+
editCell(key: string, column: string, data: VuuRowDataItemType): Promise<RpcResultSuccess | RpcResultError>;
|
|
28
|
+
addRow: (rowData?: Record<string, VuuRowDataItemType>) => Promise<RpcResult>;
|
|
29
|
+
deleteRow: (key: string, mode?: DeleteRowMode) => Promise<true | string>;
|
|
30
|
+
deleteSelectedRows: (mode?: DeleteRowMode) => Promise<RpcResultSuccess | RpcResultError>;
|
|
31
|
+
undoRowChange: (key: string) => Promise<RpcResultSuccess | RpcResultError>;
|
|
32
|
+
endEditSession(saveChanges?: boolean): Promise<void>;
|
|
33
|
+
rpcRequest(rpcRequest: Omit<VuuRpcServiceRequest, "context">): Promise<RpcResultSuccess | RpcResultError>;
|
|
34
|
+
menuRpcCall(rpcRequest: Omit<VuuRpcMenuRequest, "vpId">): Promise<VuuRpcMenuResponse>;
|
|
35
|
+
get visualLink(): LinkDescriptorWithLabel | undefined;
|
|
36
|
+
set visualLink(visualLink: LinkDescriptorWithLabel | undefined);
|
|
37
|
+
}
|
|
38
|
+
/** @deprecated legacy name, use ModuleDataSource */
|
|
39
|
+
export declare const TickingArrayDataSource: typeof ModuleDataSource;
|
|
40
|
+
/** @deprecated legacy name, use ModuleDataSource */
|
|
41
|
+
export type TickingArrayDataSource = ModuleDataSource;
|
package/src/RowKeys.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VuuRange } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
/**
|
|
3
|
+
* Assigns stable render keys to row indices in the client range, recycling
|
|
4
|
+
* the keys of rows that leave the range. Same contract as KeySet from
|
|
5
|
+
* vuu-utils, but array backed, so reset costs O(range size) with no Map
|
|
6
|
+
* scans or array shifts.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RowKeys {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(range: VuuRange);
|
|
11
|
+
/**
|
|
12
|
+
* Returns true when keys have been resequenced (range size reduced), in
|
|
13
|
+
* which case all rows must be re-sent to the client.
|
|
14
|
+
*/
|
|
15
|
+
reset(range: VuuRange): boolean;
|
|
16
|
+
keyFor(rowIndex: number): number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RowSelectionEventHandler } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { EngineDataSource } from "./EngineDataSource";
|
|
3
|
+
/**
|
|
4
|
+
* A visual link between two dataSources. Selection in the parent restricts
|
|
5
|
+
* the rows of the child to those whose childColumn value matches the
|
|
6
|
+
* parentColumn value of a selected parent row. Implemented with the engine
|
|
7
|
+
* link filter, so it composes with (and does not overwrite) the child's
|
|
8
|
+
* client filter and baseFilter.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RuntimeVisualLink {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(childDataSource: EngineDataSource, parentDataSource: EngineDataSource, childColumnName: string, parentColumnName: string);
|
|
13
|
+
destroy(): void;
|
|
14
|
+
remove(): void;
|
|
15
|
+
handleParentSelectEvent: RowSelectionEventHandler;
|
|
16
|
+
}
|
package/src/Table.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Table as EngineTable } from "@heswell/vuu-table";
|
|
2
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import { type ColumnMap, EventEmitter } from "@vuu-ui/vuu-utils";
|
|
5
|
+
import type { UpdateGenerator } from "./rowUpdates";
|
|
6
|
+
export type TableRow = Array<VuuRowDataItemType | bigint>;
|
|
7
|
+
export type TableEvents = {
|
|
8
|
+
delete: (key: string) => void;
|
|
9
|
+
insert: (row: TableRow) => void;
|
|
10
|
+
update: (row: TableRow, columnName?: string, sessionId?: string) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Module-facing table API, backed by an `@heswell/vuu-table` engine Table.
|
|
14
|
+
*
|
|
15
|
+
* Rows are stored by the engine. Note that deletes are swap-remove, so the
|
|
16
|
+
* order of `data` is insertion order only until the first delete.
|
|
17
|
+
*
|
|
18
|
+
* Events are emitted from engine table listeners, so changes applied
|
|
19
|
+
* directly to the engine table (e.g. by a JoinTable) are also observed.
|
|
20
|
+
*/
|
|
21
|
+
export declare class Table extends EventEmitter<TableEvents> {
|
|
22
|
+
#private;
|
|
23
|
+
readonly engineTable: EngineTable;
|
|
24
|
+
constructor(schemaOrEngineTable: TableSchema | EngineTable, data?: TableRow[], dataMap?: ColumnMap, updateGenerator?: UpdateGenerator);
|
|
25
|
+
get data(): TableRow[];
|
|
26
|
+
get map(): ColumnMap;
|
|
27
|
+
get schema(): TableSchema;
|
|
28
|
+
get name(): string;
|
|
29
|
+
get rowCount(): number;
|
|
30
|
+
delete(key: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* @param _emitEvent retained for compatibility with vuu-data-test, the
|
|
33
|
+
* engine always notifies dependent viewports of an insert.
|
|
34
|
+
*/
|
|
35
|
+
insert(row: TableRow, _emitEvent?: boolean): void;
|
|
36
|
+
findByKey(key: string): TableRow | undefined;
|
|
37
|
+
update(key: string, columnName: string, value: bigint | VuuRowDataItemType): void;
|
|
38
|
+
updateRow(row: TableRow): void;
|
|
39
|
+
}
|
|
40
|
+
export declare function buildDataColumnMapFromSchema(schema: Readonly<TableSchema>): ColumnMap;
|
|
41
|
+
/**
|
|
42
|
+
* Build a data ColumnMap for a table in the provided schema.
|
|
43
|
+
* A data ColumnMap is a mapping from a raw data array to a map, keyed
|
|
44
|
+
* by column name with no additional metadata.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildDataColumnMap<TableName extends string = string>(schemas: Readonly<Record<TableName, Readonly<TableSchema>>>, tableName: TableName): ColumnMap;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { VuuRange } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import type { UpdateGenerator } from "./rowUpdates";
|
|
3
|
+
import type { 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 type { VuuMenu } from "@vuu-ui/vuu-protocol-types";
|
|
2
|
+
import { type RpcMenuService, type ServiceHandler, VuuModule } from "../core/module/VuuModule";
|
|
3
|
+
import { type 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
|
+
basket: {
|
|
18
|
+
rpcName: string;
|
|
19
|
+
service: ServiceHandler;
|
|
20
|
+
}[];
|
|
21
|
+
basketTrading: {
|
|
22
|
+
rpcName: string;
|
|
23
|
+
service: ServiceHandler;
|
|
24
|
+
}[];
|
|
25
|
+
basketTradingConstituentJoin: {
|
|
26
|
+
rpcName: string;
|
|
27
|
+
service: ServiceHandler;
|
|
28
|
+
}[];
|
|
29
|
+
algoType: undefined;
|
|
30
|
+
basketTradingConstituent: undefined;
|
|
31
|
+
basketConstituent: undefined;
|
|
32
|
+
priceStrategyType: undefined;
|
|
33
|
+
};
|
|
34
|
+
get menuServices(): Record<BasketsTableName, RpcMenuService[] | undefined> | undefined;
|
|
35
|
+
get tables(): Record<BasketsTableName, Table>;
|
|
36
|
+
get visualLinks(): {
|
|
37
|
+
basketConstituent: {
|
|
38
|
+
fromColumn: string;
|
|
39
|
+
toColumn: string;
|
|
40
|
+
toTable: string;
|
|
41
|
+
}[];
|
|
42
|
+
algoType: undefined;
|
|
43
|
+
basket: undefined;
|
|
44
|
+
basketTrading: undefined;
|
|
45
|
+
basketTradingConstituent: undefined;
|
|
46
|
+
basketTradingConstituentJoin: undefined;
|
|
47
|
+
priceStrategyType: undefined;
|
|
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 type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { 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;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ask = number;
|
|
2
|
+
export type askSize = number;
|
|
3
|
+
export type bid = number;
|
|
4
|
+
export type bidSize = number;
|
|
5
|
+
export type close = number;
|
|
6
|
+
export type last = number;
|
|
7
|
+
export type open = number;
|
|
8
|
+
export type phase = "C";
|
|
9
|
+
export type ric = string;
|
|
10
|
+
export type scenario = "close";
|
|
11
|
+
export type PricesDataRow = [
|
|
12
|
+
ask,
|
|
13
|
+
askSize,
|
|
14
|
+
bid,
|
|
15
|
+
bidSize,
|
|
16
|
+
close,
|
|
17
|
+
last,
|
|
18
|
+
open,
|
|
19
|
+
phase,
|
|
20
|
+
ric,
|
|
21
|
+
scenario
|
|
22
|
+
];
|
|
23
|
+
declare const pricesTable: import("../..").Table;
|
|
24
|
+
export default pricesTable;
|
|
@@ -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,15 @@
|
|
|
1
|
+
import type { VuuModule } from "./VuuModule";
|
|
2
|
+
type RegisteredVuuModule = VuuModule<any>;
|
|
3
|
+
declare class ModuleContainer {
|
|
4
|
+
#private;
|
|
5
|
+
private constructor();
|
|
6
|
+
static get instance(): ModuleContainer;
|
|
7
|
+
register(module: RegisteredVuuModule): void;
|
|
8
|
+
unregister(name: string): boolean;
|
|
9
|
+
has(name: string): boolean;
|
|
10
|
+
get(name: string): RegisteredVuuModule;
|
|
11
|
+
get moduleNames(): MapIterator<string>;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: ModuleContainer;
|
|
14
|
+
export default _default;
|
|
15
|
+
export declare const ensureVuuModule: <T extends RegisteredVuuModule>(module: T) => T;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { DataSourceBase, DataSourceConfig, DataSourceRowWithBigint, DataSourceSubscribedMessage, DataSourceVisualLinkCreatedMessage, EditSessionMode, CopyOption, SessionDataSourceOverrides, SessionType, TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { VuuMenu, VuuLink, LinkDescriptorWithLabel, VuuRpcMenuResponse, VuuCreateVisualLink, VuuRemoveVisualLink, VuuRpcServiceRequest, RpcResultSuccess, RpcResultError, VuuRpcMenuRequest } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { Table } from "../../Table";
|
|
4
|
+
import { ModuleDataSource } from "../../ModuleDataSource";
|
|
5
|
+
import { type PermissionFunction } from "../filter/PermissionFilter";
|
|
6
|
+
import { type VuuModuleUser } from "../user/CurrentUser";
|
|
7
|
+
export interface IVuuModule<T extends string = string> {
|
|
8
|
+
createDataSource: (tableName: T, viewport?: string, config?: DataSourceConfig & {
|
|
9
|
+
session?: SessionDataSourceOverrides;
|
|
10
|
+
}) => DataSourceBase<DataSourceRowWithBigint>;
|
|
11
|
+
}
|
|
12
|
+
export type SessionTableMap = Record<string, Table>;
|
|
13
|
+
export type ServiceHandler = (rpcRequest: VuuRpcServiceRequest) => Promise<RpcResultSuccess | RpcResultError>;
|
|
14
|
+
export type MenuServiceHandler = (rpcRequest: VuuRpcMenuRequest) => Promise<VuuRpcMenuResponse>;
|
|
15
|
+
export type RpcService = {
|
|
16
|
+
rpcName: string;
|
|
17
|
+
service: ServiceHandler;
|
|
18
|
+
};
|
|
19
|
+
export type RpcMenuService = {
|
|
20
|
+
rpcName: string;
|
|
21
|
+
service: MenuServiceHandler;
|
|
22
|
+
};
|
|
23
|
+
export type VuuModuleOptions = {
|
|
24
|
+
/** Column written by session services (deleteRow, endEditSession) to report row-level status.
|
|
25
|
+
* Defaults to `"vuuMsg"` which matches the column added by `sessionTableSchema`. */
|
|
26
|
+
sessionTableMessageColumn?: string;
|
|
27
|
+
};
|
|
28
|
+
type Subscription = {
|
|
29
|
+
viewportId: string;
|
|
30
|
+
dataSource: DataSourceBase<DataSourceRowWithBigint>;
|
|
31
|
+
sessionTableName?: string;
|
|
32
|
+
sourceTableName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The table viewed by this subscription. Row permissions are applied
|
|
35
|
+
* by the dataSource engine, not by the table.
|
|
36
|
+
*/
|
|
37
|
+
table: Table;
|
|
38
|
+
user: VuuModuleUser;
|
|
39
|
+
};
|
|
40
|
+
export declare abstract class VuuModule<T extends string = string> implements IVuuModule<T> {
|
|
41
|
+
#private;
|
|
42
|
+
constructor(name: string, { sessionTableMessageColumn }?: VuuModuleOptions);
|
|
43
|
+
protected abstract menus?: Record<T, VuuMenu | undefined> | undefined;
|
|
44
|
+
protected abstract schemas: Record<T, Readonly<TableSchema>>;
|
|
45
|
+
protected abstract tables: Record<T, Table>;
|
|
46
|
+
protected abstract menuServices?: Record<T, RpcMenuService[] | undefined> | undefined;
|
|
47
|
+
protected abstract services?: Record<T, RpcService[] | undefined> | undefined;
|
|
48
|
+
protected abstract visualLinks?: Record<T, VuuLink[] | undefined>;
|
|
49
|
+
protected get includeDefaultServices(): boolean;
|
|
50
|
+
protected beforeSessionSave(_sourceTable: Table, _sessionTable: Table): Promise<void>;
|
|
51
|
+
protected afterSessionSave(_sourceTable: Table, _sessionTable: Table): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Optional, per table. Restricts the rows visible to each viewport, based on
|
|
54
|
+
* the viewport (and the user who owns it).
|
|
55
|
+
*/
|
|
56
|
+
protected permissionFunctions?: Partial<Record<T, PermissionFunction>>;
|
|
57
|
+
/**
|
|
58
|
+
* Invoked before a dataSource is created. Can be used, for example, to
|
|
59
|
+
* lazily start a data provider.
|
|
60
|
+
*/
|
|
61
|
+
protected beforeCreateDataSource?(tableName: T): void;
|
|
62
|
+
getTableSchema(tableName: string): Record<T, Readonly<TableSchema>>[T];
|
|
63
|
+
getTableList(): string[];
|
|
64
|
+
protected handlePostSubscribeActivities: ({ clientViewportId, tableSchema, }: DataSourceSubscribedMessage) => void;
|
|
65
|
+
protected unregisterViewport: (viewportId: string) => void;
|
|
66
|
+
get name(): string;
|
|
67
|
+
getSubscriptionByViewport(viewportId: string): Subscription;
|
|
68
|
+
getSubscribedDataSource(vpId: string): ModuleDataSource;
|
|
69
|
+
getLinks: (subscriptionMap: Map<string, Subscription[]>, vuuLinks: VuuLink[]) => LinkDescriptorWithLabel[];
|
|
70
|
+
visualLinkService: (message: VuuCreateVisualLink | VuuRemoveVisualLink) => Promise<DataSourceVisualLinkCreatedMessage | undefined>;
|
|
71
|
+
getVisualLinks: (tableName: string) => LinkDescriptorWithLabel[] | undefined;
|
|
72
|
+
createDataSource: (tableName: T, viewport?: string, config?: DataSourceConfig & {
|
|
73
|
+
session?: SessionDataSourceOverrides;
|
|
74
|
+
}) => DataSourceBase<DataSourceRowWithBigint>;
|
|
75
|
+
private createPermissionPredicate;
|
|
76
|
+
getServices(tableName: T): RpcService[];
|
|
77
|
+
getMenuServices(tableName: T): RpcMenuService[];
|
|
78
|
+
protected get sessionTableMap(): SessionTableMap;
|
|
79
|
+
protected getSessionTable(sessionTableName: string): Table;
|
|
80
|
+
protected getSessionTable(sessionTableName: string, throwIfNotFound: true): Table;
|
|
81
|
+
protected getSessionTable(sessionTableName: string, throwIfNotFound: false): Table | undefined;
|
|
82
|
+
protected deleteRow: ServiceHandler;
|
|
83
|
+
private deleteSelectedRows;
|
|
84
|
+
private undoRowChange;
|
|
85
|
+
private getColumnDescriptors;
|
|
86
|
+
private editCell;
|
|
87
|
+
private beginEditSessionMenuHandler;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a standalone session table.
|
|
90
|
+
* The `copyOption` determines which rows are copied into the session table.
|
|
91
|
+
* Returns the session table reference so the caller can subscribe to it.
|
|
92
|
+
*/
|
|
93
|
+
private createSessionTableService;
|
|
94
|
+
private beginEditSession;
|
|
95
|
+
private addRow;
|
|
96
|
+
private endEditSession;
|
|
97
|
+
private applyBulkEdits;
|
|
98
|
+
protected createSessionTable(sourceTable: Table, sessionTableName: string, editSessionMode: EditSessionMode | CopyOption, dataSource: ModuleDataSource, sessionType?: SessionType): Table;
|
|
99
|
+
protected createSessionTableWithAllRows({ data, schema }: Table, _sessionTableName: string): Table;
|
|
100
|
+
protected createEmptySessionTable({ schema }: Table, sessionTableName: string, sessionType?: SessionType): Table;
|
|
101
|
+
protected createSessionTableFromSelectedRows({ data, map, schema }: Table, sessionTableName: string, dataSource: ModuleDataSource): Table;
|
|
102
|
+
}
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
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";
|
|
6
|
+
declare class TableContainer {
|
|
7
|
+
#private;
|
|
8
|
+
private constructor();
|
|
9
|
+
static get instance(): TableContainer;
|
|
10
|
+
createTable: (schema: TableSchema, data?: Array<Array<VuuRowDataItemType | bigint>>, dataMap?: ColumnMap, updateGenerator?: UpdateGenerator) => Table;
|
|
11
|
+
/**
|
|
12
|
+
* Create a materialized (inner) join of two existing tables, backed by an
|
|
13
|
+
* engine JoinTable, maintained incrementally as either source changes.
|
|
14
|
+
* Both source tables must already have been created.
|
|
15
|
+
*/
|
|
16
|
+
createJoinTable(joinTable: VuuTable, { table: t1 }: VuuTable, { table: t2 }: VuuTable, joinColumn: string): Table;
|
|
17
|
+
addTable(table: Table): void;
|
|
18
|
+
getTable<T = Table>(tableName: string): NonNullable<T>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: TableContainer;
|
|
21
|
+
export default _default;
|
|
@@ -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,7 @@
|
|
|
1
|
+
export declare function random(min: number, max: number): number;
|
|
2
|
+
export declare function randomPercentage(value: number): number;
|
|
3
|
+
export type PriceGenerator = (min: number, max: number) => number;
|
|
4
|
+
export declare const nextRandomDouble: PriceGenerator;
|
|
5
|
+
export declare const initBidAsk: (priceMaxDelta: number, nextRandomDouble: PriceGenerator) => number[];
|
|
6
|
+
export declare const generateNextBidAsk: (bid: number, ask: number, spreadMultipler: number, priceMaxDelta: number, nextRandomDouble: PriceGenerator) => number[];
|
|
7
|
+
export declare const withNanoMs: (ts: number, nanos?: number) => bigint;
|