@heswell/vuu-data-engine-local 3.0.0 → 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/91.js +248 -0
- package/README.md +49 -18
- package/index.js +114 -395
- package/legacy.js +5 -2
- package/package.json +6 -2
- package/react.js +64 -0
- package/src/core/engine/LocalEngine.d.ts +2 -1
- package/src/core/module/VuuModule.d.ts +12 -0
- package/src/core/table/TableContainer.d.ts +7 -4
- package/src/index.d.ts +0 -2
- package/src/legacy.d.ts +1 -0
- package/src/react.d.ts +7 -0
package/legacy.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SimulatedNotificationsModule, UserAdminModule, registerDemoModules, ModuleAdminModule } from "./index.js";
|
|
2
|
+
import { getDefaultEngine } from "./91.js";
|
|
2
3
|
const engine = getDefaultEngine();
|
|
3
4
|
const { simulModule: simulModule, basketModule: basketModule, testModule: testModule } = registerDemoModules(engine);
|
|
4
5
|
const moduleAdminModule = engine.register(new ModuleAdminModule());
|
|
5
6
|
const userAdminModule = engine.register(new UserAdminModule());
|
|
6
7
|
const notificationsModule = engine.register(SimulatedNotificationsModule());
|
|
7
|
-
export { AllowAllPermissionFilter, ArrayProxy, BaseUpdateGenerator, BasketModule, DUPLICATE_KEY, DefaultColumnGenerator, DefaultRowGenerator, DenyAllPermissionFilter, DismissNotificationRpcHandler, EngineDataSource,
|
|
8
|
+
export { AllowAllPermissionFilter, ArrayProxy, BaseUpdateGenerator, BasketModule, DUPLICATE_KEY, DefaultColumnGenerator, DefaultRowGenerator, DenyAllPermissionFilter, DismissNotificationRpcHandler, EngineDataSource, MODULE_ADMIN_INITIAL_SNAPSHOT, MODULE_ADMIN_MODULE_NAME, MODULE_ADMIN_TABLE_SCHEMAS, ModuleAdminModule, ModuleDataSource, NotificationModule, NotificationsSchema, PermissionFilter, SAVE_FAILED, SAVE_NOT_PERMITTED, STALE_UPDATE, SimulModule, SimulatedNotificationsModule, SimulatedNotificationsProvider, TestModule, TickingArrayDataSource, USER_ADMIN_INITIAL_SNAPSHOT, UserAdminModule, VUU_SYSTEM_COLUMNS, VuuModule, basketSchemas, defaultApplySessionSave, defaultCanEditSource, defaultGenerators, defaultGetStaleColumns, defaultIsEditableColumn, formatMessage, getAllSchemas, getColumnAndRowGenerator, getCurrentUser, getSchema, isBasketTable, isSimulTable, isSystemColumn, makeSuggestions, populateArray, projectModuleAdminSnapshot, projectUserAdminSnapshot, reconcileModuleAdminTables, reconcileUserAdminTables, registerDemoModules, schemas, setCurrentUser, simulSchemas, tableContainer, testSchemas, toColumn, toRange } from "./index.js";
|
|
9
|
+
export { LocalDataSourceProvider, createDataSourceProvider, createLocalVuuServer } from "./react.js";
|
|
10
|
+
export { LocalEngine, Table, TableContainer, buildDataColumnMap, buildDataColumnMapFromSchema, createJoinTable, createLocalEngine, createTable, ensureVuuModule, getDefaultEngine, resetDefaultEngine } from "./91.js";
|
|
8
11
|
export { basketModule, moduleAdminModule, notificationsModule, simulModule, testModule, userAdminModule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heswell/vuu-data-engine-local",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "In-browser Vuu server (VuuModule, tables, EngineDataSource) built on @heswell/vuu-table and @heswell/vuu-viewport",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"types": "./src/index.d.ts",
|
|
11
11
|
"import": "./index.js"
|
|
12
12
|
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./src/react.d.ts",
|
|
15
|
+
"import": "./react.js"
|
|
16
|
+
},
|
|
13
17
|
"./legacy": {
|
|
14
18
|
"types": "./src/legacy.d.ts",
|
|
15
19
|
"import": "./legacy.js"
|
|
@@ -25,7 +29,7 @@
|
|
|
25
29
|
"@heswell/module-admin": "^2.0.1",
|
|
26
30
|
"@heswell/user-admin": "^1.0.2",
|
|
27
31
|
"@heswell/vuu-table": "^1.0.2",
|
|
28
|
-
"@heswell/vuu-viewport": "^1.1.
|
|
32
|
+
"@heswell/vuu-viewport": "^1.1.5"
|
|
29
33
|
},
|
|
30
34
|
"peerDependencies": {
|
|
31
35
|
"@vuu-ui/core": "^4.0.0-alpha.20",
|
package/react.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DataProvider } from "@vuu-ui/core";
|
|
3
|
+
import { DataProvider as vuu_utils_DataProvider } from "@vuu-ui/vuu-utils";
|
|
4
|
+
import { getDefaultEngine, LocalEngine } from "./91.js";
|
|
5
|
+
const providers = new WeakMap();
|
|
6
|
+
const createDataSourceProvider = (engine)=>{
|
|
7
|
+
const cached = providers.get(engine);
|
|
8
|
+
if (cached) return cached;
|
|
9
|
+
const getModule = (moduleName)=>{
|
|
10
|
+
if (!engine.hasModule(moduleName)) throw Error(`[LocalDataSourceProvider] module ${moduleName} is not available on this server`);
|
|
11
|
+
return engine.getModule(moduleName);
|
|
12
|
+
};
|
|
13
|
+
const serverAPI = {
|
|
14
|
+
getTableList: async ()=>({
|
|
15
|
+
tables: engine.getTableList()
|
|
16
|
+
}),
|
|
17
|
+
getTableSchema: async ({ module, table })=>getModule(module).getTableSchema(table),
|
|
18
|
+
rpcCall: async ()=>{
|
|
19
|
+
throw Error("RpcCall no longer supported on LocalDataSourceProvider ServerAPI");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getServerAPI = async ()=>serverAPI;
|
|
23
|
+
class VuuDataSource {
|
|
24
|
+
constructor({ aggregations, columns, filterSpec, groupBy, session, sort, table, viewport, visualLink }){
|
|
25
|
+
const config = {
|
|
26
|
+
aggregations,
|
|
27
|
+
columns,
|
|
28
|
+
filterSpec,
|
|
29
|
+
groupBy,
|
|
30
|
+
session,
|
|
31
|
+
sort,
|
|
32
|
+
visualLink
|
|
33
|
+
};
|
|
34
|
+
const module = getModule(table.module);
|
|
35
|
+
return module.createDataSource(table.table, viewport, config);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const DataSourceProvider = ({ children })=>/*#__PURE__*/ jsx(vuu_utils_DataProvider, {
|
|
39
|
+
VuuDataSource: VuuDataSource,
|
|
40
|
+
getServerAPI: getServerAPI,
|
|
41
|
+
children: /*#__PURE__*/ jsx(DataProvider, {
|
|
42
|
+
VuuDataSource: VuuDataSource,
|
|
43
|
+
getServerAPI: getServerAPI,
|
|
44
|
+
children: children
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
providers.set(engine, DataSourceProvider);
|
|
48
|
+
return DataSourceProvider;
|
|
49
|
+
};
|
|
50
|
+
const LocalDataSourceProvider = ({ children })=>{
|
|
51
|
+
const DataSourceProvider = createDataSourceProvider(getDefaultEngine());
|
|
52
|
+
return /*#__PURE__*/ jsx(DataSourceProvider, {
|
|
53
|
+
children: children
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const createLocalVuuServer = ({ connectionId, modules, engine = new LocalEngine() })=>{
|
|
57
|
+
for (const module of modules)engine.register(module);
|
|
58
|
+
return {
|
|
59
|
+
connectionId,
|
|
60
|
+
DataSourceProvider: createDataSourceProvider(engine),
|
|
61
|
+
engine
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export { LocalDataSourceProvider, createDataSourceProvider, createLocalVuuServer };
|
|
@@ -13,7 +13,8 @@ export interface LocalEngineOptions {
|
|
|
13
13
|
* two engines (or two modules in one engine) can use the same table names.
|
|
14
14
|
*
|
|
15
15
|
* The engine has no React or DOM dependency. Use `createDataSourceProvider`
|
|
16
|
-
* or `createLocalVuuServer` to expose it to a
|
|
16
|
+
* or `createLocalVuuServer` (from the `/react` entry) to expose it to a
|
|
17
|
+
* React app.
|
|
17
18
|
*/
|
|
18
19
|
export declare class LocalEngine {
|
|
19
20
|
#private;
|
|
@@ -146,7 +146,19 @@ export declare abstract class VuuModule<T extends string = string> implements IV
|
|
|
146
146
|
protected getSessionTable(sessionTableName: string): Table;
|
|
147
147
|
protected getSessionTable(sessionTableName: string, throwIfNotFound: true): Table;
|
|
148
148
|
protected getSessionTable(sessionTableName: string, throwIfNotFound: false): Table | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* deleteRow is only valid in an edit session (as on vuu-server). The
|
|
151
|
+
* `mode` param is accepted for vuu-ui compatibility but ignored: the row
|
|
152
|
+
* is always marked, never removed, so the save can apply it.
|
|
153
|
+
*/
|
|
149
154
|
protected deleteRow: ServiceHandler;
|
|
155
|
+
/**
|
|
156
|
+
* Delete a row directly from the viewport's source table (no edit
|
|
157
|
+
* session). Not registered as a built-in service; subclasses may expose
|
|
158
|
+
* it, e.g. SimulModule's DELETE_ROW. `mode: "soft"` sets the session
|
|
159
|
+
* message column to "SOFT_DELETED" instead.
|
|
160
|
+
*/
|
|
161
|
+
protected deleteSourceRow: ServiceHandler;
|
|
150
162
|
private deleteSelectedRows;
|
|
151
163
|
private undoRowChange;
|
|
152
164
|
private getColumnDescriptors;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JoinType } from "@heswell/vuu-table";
|
|
1
2
|
import type { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
3
|
import { Table } from "../../Table";
|
|
3
4
|
import type { VuuRowDataItemType, VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
@@ -9,10 +10,12 @@ import type { UpdateGenerator } from "../../rowUpdates";
|
|
|
9
10
|
*/
|
|
10
11
|
export declare const createTable: (schema: TableSchema, data?: Array<Array<VuuRowDataItemType | bigint>>, dataMap?: ColumnMap, updateGenerator?: UpdateGenerator) => Table;
|
|
11
12
|
/**
|
|
12
|
-
* Create a materialized
|
|
13
|
-
*
|
|
13
|
+
* Create a materialized join of two tables, backed by an engine JoinTable,
|
|
14
|
+
* maintained incrementally as either source changes. `joinType` defaults to
|
|
15
|
+
* "inner" (only rows with a match in table2). With "leftOuter" every table1
|
|
16
|
+
* row is present and unmatched table2 columns are null, as in vuu-server.
|
|
14
17
|
*/
|
|
15
|
-
export declare const createJoinTable: (joinTable: VuuTable, table1: Table, table2: Table, joinColumn: string) => Table;
|
|
18
|
+
export declare const createJoinTable: (joinTable: VuuTable, table1: Table, table2: Table, joinColumn: string, joinType?: JoinType) => Table;
|
|
16
19
|
/**
|
|
17
20
|
* Tables, keyed by `{module, table}`. Each LocalEngine owns one, populated
|
|
18
21
|
* from the tables of its registered modules. Tables created through
|
|
@@ -25,7 +28,7 @@ export declare class TableContainer {
|
|
|
25
28
|
* Create a join of two tables already in this container. Pass full
|
|
26
29
|
* `{module, table}` references; a bare name is accepted only if unique.
|
|
27
30
|
*/
|
|
28
|
-
createJoinTable(joinTable: VuuTable, table1: VuuTable | string, table2: VuuTable | string, joinColumn: string): Table;
|
|
31
|
+
createJoinTable(joinTable: VuuTable, table1: VuuTable | string, table2: VuuTable | string, joinColumn: string, joinType?: JoinType): Table;
|
|
29
32
|
/**
|
|
30
33
|
* Add a table, keyed by `as` if given, otherwise by its schema's
|
|
31
34
|
* `{module, table}`.
|
package/src/index.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ export { createJoinTable, createTable, TableContainer, } from "./core/table/Tabl
|
|
|
8
8
|
export { tableContainer } from "./core/table/defaultTableContainer";
|
|
9
9
|
export { registerDemoModules, type DemoModules } from "./demo-modules";
|
|
10
10
|
export { BaseUpdateGenerator } from "./UpdateGenerator";
|
|
11
|
-
export * from "./local-datasource-provider/LocalDatasourceProvider";
|
|
12
|
-
export { createDataSourceProvider } from "./local-datasource-provider/createDataSourceProvider";
|
|
13
11
|
export * from "./makeSuggestions";
|
|
14
12
|
export * from "./notifications";
|
|
15
13
|
export * from "./schemas";
|
package/src/legacy.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModuleAdminModule } from "./module-admin/ModuleAdminModule";
|
|
2
2
|
import { UserAdminModule } from "./user-admin/UserAdminModule";
|
|
3
3
|
export * from "./index";
|
|
4
|
+
export * from "./react";
|
|
4
5
|
/** @deprecated */
|
|
5
6
|
export declare const simulModule: import("./simul").SimulModule, basketModule: import("./basket").BasketModule, testModule: import("./test").TestModule;
|
|
6
7
|
/** @deprecated */
|
package/src/react.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React bindings for the local engine. Kept out of the main entry because
|
|
3
|
+
* `@vuu-ui/core` (via `@vuu-ui/vuu-ui-controls`) needs a DOM at import time
|
|
4
|
+
* (`ResizeObserver`); the main entry runs in plain Node/Bun.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./local-datasource-provider/LocalDatasourceProvider";
|
|
7
|
+
export { createDataSourceProvider } from "./local-datasource-provider/createDataSourceProvider";
|