@vuu-ui/vuu-data-test 4.0.0-alpha.3 → 4.0.0-alpha.31

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 (53) hide show
  1. package/README.md +38 -0
  2. package/package.json +10 -9
  3. package/src/TickingArrayDataSource.js +7 -2
  4. package/src/basket/BasketModule.js +105 -40
  5. package/src/basket/basket-schemas.js +16 -0
  6. package/src/basket/reference-data/constituent-data.js +2 -0
  7. package/src/basket/reference-data/constituents.js +6 -74
  8. package/src/basket/reference-data/prices.js +9 -3
  9. package/src/core/filter/PermissionFilter.js +60 -0
  10. package/src/core/filter/PermissionFilteredTable.js +59 -0
  11. package/src/core/module/VuuModule.js +30 -4
  12. package/src/core/table/TableContainer.js +51 -8
  13. package/src/core/user/CurrentUser.js +13 -0
  14. package/src/index.js +4 -0
  15. package/src/local-datasource-provider/LocalDatasourceProvider.js +64 -44
  16. package/src/module-admin/ModuleAdminModule.js +84 -20
  17. package/src/module-admin/module-admin-schemas.js +5 -9
  18. package/src/module-admin/snapshot-projection.js +3 -31
  19. package/src/notifications/NotificationModule.js +131 -0
  20. package/src/notifications/NotificationsSchema.js +52 -0
  21. package/src/notifications/index.js +6 -0
  22. package/src/notifications/simulated/DismissNotificationRpcHandler.js +36 -0
  23. package/src/notifications/simulated/SimulatedNotificationsModule.js +18 -0
  24. package/src/notifications/simulated/SimulatedNotificationsProvider.js +151 -0
  25. package/src/notifications/simulated/notificationsModule.js +3 -0
  26. package/src/user-admin/UserAdminModule.js +163 -8
  27. package/src/user-admin/initialSnapshot.js +49 -65
  28. package/types/TickingArrayDataSource.d.ts +1 -1
  29. package/types/basket/BasketModule.d.ts +2 -0
  30. package/types/basket/reference-data/constituents.d.ts +3 -3
  31. package/types/basket/reference-data/prices.d.ts +2 -1
  32. package/types/core/filter/PermissionFilter.d.ts +41 -0
  33. package/types/core/filter/PermissionFilteredTable.d.ts +24 -0
  34. package/types/core/module/VuuModule.d.ts +19 -0
  35. package/types/core/table/TableContainer.d.ts +1 -1
  36. package/types/core/user/CurrentUser.d.ts +14 -0
  37. package/types/index.d.ts +4 -0
  38. package/types/local-datasource-provider/LocalDatasourceProvider.d.ts +18 -2
  39. package/types/module-admin/ModuleAdminModule.d.ts +12 -3
  40. package/types/module-admin/index.d.ts +1 -1
  41. package/types/module-admin/snapshot-projection.d.ts +3 -4
  42. package/types/notifications/NotificationModule.d.ts +60 -0
  43. package/types/notifications/NotificationsSchema.d.ts +20 -0
  44. package/types/notifications/index.d.ts +6 -0
  45. package/types/notifications/simulated/DismissNotificationRpcHandler.d.ts +8 -0
  46. package/types/notifications/simulated/SimulatedNotificationsModule.d.ts +9 -0
  47. package/types/notifications/simulated/SimulatedNotificationsProvider.d.ts +21 -0
  48. package/types/notifications/simulated/notificationsModule.d.ts +5 -0
  49. package/types/user-admin/UserAdminModule.d.ts +5 -1
  50. package/src/basket/reference-data/ftse100.js +0 -686
  51. package/src/basket/reference-data/hsi.js +0 -1047
  52. package/src/basket/reference-data/nasdaq100.js +0 -812
  53. package/src/basket/reference-data/sp500.js +0 -315
@@ -1,14 +1,13 @@
1
- import { type ModuleAccessRole, type ModuleDefinition } from "@heswell/module-admin/contracts";
1
+ import { type ManagedModule } from "@heswell/module-admin/contracts";
2
2
  import type { VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
3
  import type { Table } from "../Table";
4
4
  import type { ModuleAdminTableName } from "./module-admin-schemas";
5
5
  type Row = Array<bigint | VuuRowDataItemType>;
6
6
  type Tables = Record<ModuleAdminTableName, Table>;
7
7
  export type ModuleAdminSnapshot = {
8
- moduleAccessRoles: readonly ModuleAccessRole[];
9
- modules: readonly ModuleDefinition[];
10
- timestamp: number;
8
+ modules: readonly ManagedModule[];
11
9
  };
12
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. */
13
12
  export declare const reconcileModuleAdminTables: (snapshot: ModuleAdminSnapshot, tables: Tables) => void;
14
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,5 @@
1
+ /**
2
+ * Simulated notifications. The provider starts generating notifications
3
+ * when the first dataSource is created for the notifications table.
4
+ */
5
+ export declare const notificationsModule: import("..").NotificationModule;
@@ -25,7 +25,11 @@ export declare class UserAdminModule extends VuuModule<UserAdminTableName> {
25
25
  reconcile(): Promise<void>;
26
26
  protected createSessionTable(sourceTable: Table, sessionTableName: string, editSessionMode: import("@vuu-ui/vuu-data-types").EditSessionMode | import("@vuu-ui/vuu-data-types").CopyOption, dataSource: import("../TickingArrayDataSource").TickingArrayDataSource, sessionType?: import("@vuu-ui/vuu-data-types").SessionType): Table;
27
27
  protected beforeSessionSave(sourceTable: Table, sessionTable: Table): Promise<void>;
28
- protected afterSessionSave(sourceTable: Table): Promise<void>;
28
+ protected afterSessionSave(sourceTable: Table, sessionTable: Table): Promise<void>;
29
+ private saveGroupsFromSession;
30
+ private saveGroupRoleAssignments;
31
+ private resolveGroupRoleAssignments;
32
+ private saveClientRolesFromSession;
29
33
  private mutation;
30
34
  private addUser;
31
35
  private updateUser;