@vuu-ui/vuu-data-test 4.0.0-alpha.11 → 4.0.0-alpha.12

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.0.0-alpha.11",
2
+ "version": "4.0.0-alpha.12",
3
3
  "main": "./src/index.js",
4
4
  "type": "module",
5
5
  "author": "heswell",
@@ -12,14 +12,14 @@
12
12
  "dependencies": {
13
13
  "@heswell/module-admin": "1.0.0",
14
14
  "@heswell/user-admin": "1.0.1",
15
- "@vuu-ui/vuu-data-editing": "4.0.0-alpha.11",
16
- "@vuu-ui/vuu-data-local": "4.0.0-alpha.11",
17
- "@vuu-ui/vuu-utils": "4.0.0-alpha.11"
15
+ "@vuu-ui/vuu-data-editing": "4.0.0-alpha.12",
16
+ "@vuu-ui/vuu-data-local": "4.0.0-alpha.12",
17
+ "@vuu-ui/vuu-utils": "4.0.0-alpha.12"
18
18
  },
19
19
  "devDependencies": {
20
- "@vuu-ui/vuu-data-types": "4.0.0-alpha.11",
21
- "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.11",
22
- "@vuu-ui/vuu-table-types": "4.0.0-alpha.11"
20
+ "@vuu-ui/vuu-data-types": "4.0.0-alpha.12",
21
+ "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.12",
22
+ "@vuu-ui/vuu-table-types": "4.0.0-alpha.12"
23
23
  },
24
24
  "sideEffects": false,
25
25
  "files": [
@@ -1,50 +1,59 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { DataProvider } from "@vuu-ui/core";
3
3
  import { DataProvider as vuu_utils_DataProvider } from "@vuu-ui/vuu-utils";
4
- import ModuleContainer from "../core/module/ModuleContainer.js";
4
+ import ModuleContainer, { ensureVuuModule } from "../core/module/ModuleContainer.js";
5
5
  import TableContainer from "../core/table/TableContainer.js";
6
- const serverAPI = {
7
- getTableList: async ()=>{
8
- const tables = ModuleContainer.moduleNames.reduce((tableList, moduleName)=>{
9
- const moduleTables = ModuleContainer.get(moduleName).getTableList();
10
- moduleTables.forEach((tableName)=>{
11
- const table = TableContainer.getTable(tableName);
12
- tableList.push(table.schema.table);
13
- });
14
- return tableList;
15
- }, []);
16
- return {
17
- tables
18
- };
19
- },
20
- getTableSchema: async ({ module, table })=>ModuleContainer.get(module).getTableSchema(table),
21
- rpcCall: async ()=>{
22
- throw Error("RpcCall no longer supported on LocalDataSourceProvider ServerAPI");
6
+ const createLocalDataSourceProvider = (moduleNames)=>{
7
+ const getModule = (moduleName)=>{
8
+ if (moduleNames && !moduleNames.has(moduleName)) throw Error(`[LocalDataSourceProvider] module ${moduleName} is not available on this server`);
9
+ return ModuleContainer.get(moduleName);
10
+ };
11
+ const serverAPI = {
12
+ getTableList: async ()=>{
13
+ const tables = [];
14
+ for (const moduleName of moduleNames ?? ModuleContainer.moduleNames)for (const tableName of getModule(moduleName).getTableList())tables.push(TableContainer.getTable(tableName).schema.table);
15
+ return {
16
+ tables
17
+ };
18
+ },
19
+ getTableSchema: async ({ module, table })=>getModule(module).getTableSchema(table),
20
+ rpcCall: async ()=>{
21
+ throw Error("RpcCall no longer supported on LocalDataSourceProvider ServerAPI");
22
+ }
23
+ };
24
+ const getServerAPI = async ()=>serverAPI;
25
+ class VuuDataSource {
26
+ constructor({ aggregations, columns, filterSpec, groupBy, session, sort, table, viewport, visualLink }){
27
+ const config = {
28
+ aggregations,
29
+ columns,
30
+ filterSpec,
31
+ groupBy,
32
+ session,
33
+ sort,
34
+ visualLink
35
+ };
36
+ const module = getModule(table.module);
37
+ return module.createDataSource(table.table, viewport, config);
38
+ }
23
39
  }
24
- };
25
- const getServerAPI = async ()=>serverAPI;
26
- class VuuDataSource {
27
- constructor({ aggregations, columns, filterSpec, groupBy, session, sort, table, viewport, visualLink }){
28
- const config = {
29
- aggregations,
30
- columns,
31
- filterSpec,
32
- groupBy,
33
- session,
34
- sort,
35
- visualLink
36
- };
37
- const module = ModuleContainer.get(table.module);
38
- return module.createDataSource(table.table, viewport, config);
39
- }
40
- }
41
- const LocalDataSourceProvider = ({ children })=>/*#__PURE__*/ jsx(vuu_utils_DataProvider, {
42
- VuuDataSource: VuuDataSource,
43
- getServerAPI: getServerAPI,
44
- children: /*#__PURE__*/ jsx(DataProvider, {
40
+ const DataSourceProvider = ({ children })=>/*#__PURE__*/ jsx(vuu_utils_DataProvider, {
45
41
  VuuDataSource: VuuDataSource,
46
42
  getServerAPI: getServerAPI,
47
- children: children
48
- })
49
- });
50
- export { LocalDataSourceProvider };
43
+ children: /*#__PURE__*/ jsx(DataProvider, {
44
+ VuuDataSource: VuuDataSource,
45
+ getServerAPI: getServerAPI,
46
+ children: children
47
+ })
48
+ });
49
+ return DataSourceProvider;
50
+ };
51
+ const LocalDataSourceProvider = createLocalDataSourceProvider();
52
+ const createLocalVuuServer = ({ connectionId, modules })=>{
53
+ modules.forEach(ensureVuuModule);
54
+ return {
55
+ connectionId,
56
+ DataSourceProvider: createLocalDataSourceProvider(new Set(modules.map(({ name })=>name)))
57
+ };
58
+ };
59
+ export { LocalDataSourceProvider, createLocalVuuServer };
@@ -1,4 +1,18 @@
1
+ import { type LocalVuuServer } from "@vuu-ui/core";
1
2
  import type { ReactNode } from "react";
2
- export declare const LocalDataSourceProvider: ({ children, }: {
3
+ import type { VuuModule } from "../core/module/VuuModule";
4
+ /** Data context covering every VuuModule registered in the browser. */
5
+ export declare const LocalDataSourceProvider: ({ children }: {
3
6
  children: ReactNode;
4
7
  }) => import("react").JSX.Element;
8
+ export interface LocalVuuServerOptions {
9
+ /** Matches the `vuu.connectionId` of the modules this server serves. */
10
+ connectionId: string;
11
+ modules: VuuModule<any>[];
12
+ }
13
+ /**
14
+ * Simulates a Vuu server in the browser, publishing the tables of the given
15
+ * modules. Pass the result to a local-mode `AuthenticationProvider` as one of
16
+ * its `localServers`.
17
+ */
18
+ export declare const createLocalVuuServer: ({ connectionId, modules, }: LocalVuuServerOptions) => LocalVuuServer;