@vuu-ui/vuu-data-test 3.5.2 → 3.5.3
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/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 +12 -3
- package/types/module-admin/index.d.ts +1 -1
- package/types/module-admin/snapshot-projection.d.ts +3 -4
- package/types/notifications/NotificationModule.d.ts +39 -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 +2 -0
- package/types/notifications/simulated/SimulatedNotificationsProvider.d.ts +21 -0
- package/types/notifications/simulated/notificationsModule.d.ts +5 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.5.
|
|
2
|
+
"version": "3.5.3",
|
|
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": "3.5.
|
|
13
|
-
"@vuu-ui/vuu-utils": "3.5.
|
|
12
|
+
"@vuu-ui/vuu-data-local": "3.5.3",
|
|
13
|
+
"@vuu-ui/vuu-utils": "3.5.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@vuu-ui/vuu-protocol-types": "3.5.
|
|
17
|
-
"@vuu-ui/vuu-data-types": "3.5.
|
|
18
|
-
"@vuu-ui/vuu-table-types": "3.5.
|
|
16
|
+
"@vuu-ui/vuu-protocol-types": "3.5.3",
|
|
17
|
+
"@vuu-ui/vuu-data-types": "3.5.3",
|
|
18
|
+
"@vuu-ui/vuu-table-types": "3.5.3"
|
|
19
19
|
},
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"files": [
|
|
@@ -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;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import { type ManagedModule } from "@heswell/module-admin/contracts";
|
|
1
2
|
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
-
import { VuuModule } from "../core/module/VuuModule";
|
|
3
|
+
import { VuuModule, type RpcService } from "../core/module/VuuModule";
|
|
3
4
|
import { type Table } from "../Table";
|
|
4
5
|
import { type ModuleAdminTableName } from "./module-admin-schemas";
|
|
5
6
|
import { type ModuleAdminSnapshot } from "./snapshot-projection";
|
|
6
7
|
type ModuleAdminTables = Record<ModuleAdminTableName, Table>;
|
|
7
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
|
+
*/
|
|
8
13
|
export declare class ModuleAdminModule extends VuuModule<ModuleAdminTableName> {
|
|
9
14
|
#private;
|
|
10
|
-
|
|
15
|
+
private readonly now;
|
|
16
|
+
constructor(snapshot?: ModuleAdminSnapshot, now?: () => number);
|
|
17
|
+
/** Current module state. */
|
|
18
|
+
get modules(): readonly ManagedModule[];
|
|
11
19
|
get menus(): {
|
|
12
20
|
modulePermissions: undefined;
|
|
13
21
|
modules: undefined;
|
|
@@ -15,7 +23,8 @@ export declare class ModuleAdminModule extends VuuModule<ModuleAdminTableName> {
|
|
|
15
23
|
protected get includeDefaultServices(): boolean;
|
|
16
24
|
get menuServices(): undefined;
|
|
17
25
|
get schemas(): Record<ModuleAdminTableName, Readonly<TableSchema>>;
|
|
18
|
-
|
|
26
|
+
private service;
|
|
27
|
+
get services(): Record<ModuleAdminTableName, RpcService[]>;
|
|
19
28
|
get tables(): ModuleAdminTables;
|
|
20
29
|
get visualLinks(): undefined;
|
|
21
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ModuleAdminModule, MODULE_ADMIN_INITIAL_SNAPSHOT, moduleAdminModule, } from "./ModuleAdminModule";
|
|
2
2
|
export { MODULE_ADMIN_MODULE_NAME, MODULE_ADMIN_TABLE_SCHEMAS, type ModuleAdminTableName, } from "./module-admin-schemas";
|
|
3
3
|
export { projectModuleAdminSnapshot, reconcileModuleAdminTables, type ModuleAdminSnapshot, } from "./snapshot-projection";
|
|
4
|
-
export type { ModuleAccessRole, ModuleDefinition, ModulePermissionRow, ModuleRow, } from "@heswell/module-admin/contracts";
|
|
4
|
+
export type { ManagedModule, ModuleAccessRole, ModuleConfig, ModuleDefinition, ModulePermissionRow, ModuleRow, } from "@heswell/module-admin/contracts";
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { type
|
|
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
|
-
|
|
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,39 @@
|
|
|
1
|
+
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { type RpcService, VuuModule } from "../core/module/VuuModule";
|
|
3
|
+
import type { PermissionFunction } from "../core/filter/PermissionFilter";
|
|
4
|
+
import { type Table } from "../Table";
|
|
5
|
+
import { type ColumnDefinition } from "./NotificationsSchema";
|
|
6
|
+
export type NotificationsTableName = "notifications";
|
|
7
|
+
/**
|
|
8
|
+
* Source of notifications. Started when the first dataSource is
|
|
9
|
+
* created for the notifications table, or explicitly via module.start().
|
|
10
|
+
*/
|
|
11
|
+
export interface NotificationsProvider {
|
|
12
|
+
start: () => void;
|
|
13
|
+
stop: () => void;
|
|
14
|
+
}
|
|
15
|
+
export type NotificationsProviderFactory = (table: Table) => NotificationsProvider;
|
|
16
|
+
export type NotificationsServiceFactory = (table: Table, module: NotificationModule) => RpcService[];
|
|
17
|
+
/**
|
|
18
|
+
* A generic Notifications module, exposing a single 'notifications' table.
|
|
19
|
+
* The source of notifications (provider), the rows visible to each user
|
|
20
|
+
* (permissionFunction) and any rpc services (serviceFactory) are supplied
|
|
21
|
+
* by the consumer. Any additional columns are appended to the generic
|
|
22
|
+
* notification columns (see NotificationsSchema).
|
|
23
|
+
*/
|
|
24
|
+
export declare class NotificationModule extends VuuModule<NotificationsTableName> {
|
|
25
|
+
#private;
|
|
26
|
+
static readonly NAME = "NOTIFICATIONS";
|
|
27
|
+
static readonly TABLE_NAME: "notifications";
|
|
28
|
+
constructor(providerFactory: NotificationsProviderFactory, permissionFunction: PermissionFunction, serviceFactory: NotificationsServiceFactory, ...additionalColumns: ColumnDefinition[]);
|
|
29
|
+
protected beforeCreateDataSource(): void;
|
|
30
|
+
get isRunning(): boolean;
|
|
31
|
+
start(): void;
|
|
32
|
+
stop(): void;
|
|
33
|
+
get menus(): undefined;
|
|
34
|
+
get menuServices(): undefined;
|
|
35
|
+
get schemas(): Record<"notifications", TableSchema>;
|
|
36
|
+
get services(): Record<"notifications", RpcService[]>;
|
|
37
|
+
get tables(): Record<"notifications", Table>;
|
|
38
|
+
get visualLinks(): undefined;
|
|
39
|
+
}
|
|
@@ -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,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
|
+
}
|