@vuu-ui/vuu-data-remote 0.0.26
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/LICENSE +201 -0
- package/README.md +19 -0
- package/cjs/authenticate.js +28 -0
- package/cjs/authenticate.js.map +1 -0
- package/cjs/connection-manager.js +228 -0
- package/cjs/connection-manager.js.map +1 -0
- package/cjs/constants.js +50 -0
- package/cjs/constants.js.map +1 -0
- package/cjs/data-source.js +58 -0
- package/cjs/data-source.js.map +1 -0
- package/cjs/index.js +32 -0
- package/cjs/index.js.map +1 -0
- package/cjs/inlined-worker.js +14 -0
- package/cjs/inlined-worker.js.map +1 -0
- package/cjs/message-utils.js +63 -0
- package/cjs/message-utils.js.map +1 -0
- package/cjs/server-proxy/messages.js +6 -0
- package/cjs/server-proxy/messages.js.map +1 -0
- package/cjs/vuu-data-source.js +574 -0
- package/cjs/vuu-data-source.js.map +1 -0
- package/esm/authenticate.js +26 -0
- package/esm/authenticate.js.map +1 -0
- package/esm/connection-manager.js +223 -0
- package/esm/connection-manager.js.map +1 -0
- package/esm/constants.js +47 -0
- package/esm/constants.js.map +1 -0
- package/esm/data-source.js +51 -0
- package/esm/data-source.js.map +1 -0
- package/esm/index.js +7 -0
- package/esm/index.js.map +1 -0
- package/esm/inlined-worker.js +12 -0
- package/esm/inlined-worker.js.map +1 -0
- package/esm/message-utils.js +56 -0
- package/esm/message-utils.js.map +1 -0
- package/esm/server-proxy/messages.js +4 -0
- package/esm/server-proxy/messages.js.map +1 -0
- package/esm/vuu-data-source.js +572 -0
- package/esm/vuu-data-source.js.map +1 -0
- package/package.json +33 -0
- package/types/authenticate.d.ts +1 -0
- package/types/connection-manager.d.ts +52 -0
- package/types/connectionTypes.d.ts +5 -0
- package/types/constants.d.ts +41 -0
- package/types/data-source.d.ts +8 -0
- package/types/index.d.ts +7 -0
- package/types/inlined-worker.d.ts +1 -0
- package/types/message-utils.d.ts +14 -0
- package/types/server-proxy/array-backed-moving-window.d.ts +28 -0
- package/types/server-proxy/messages.d.ts +38 -0
- package/types/server-proxy/rpc-services.d.ts +2 -0
- package/types/server-proxy/server-proxy.d.ts +62 -0
- package/types/server-proxy/viewport.d.ts +141 -0
- package/types/vuu-data-source.d.ts +63 -0
- package/types/websocket-connection.d.ts +24 -0
- package/types/worker.d.ts +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const MENU_RPC_TYPES = [
|
|
2
|
+
"VIEW_PORT_MENUS_SELECT_RPC",
|
|
3
|
+
"VIEW_PORT_MENU_TABLE_RPC",
|
|
4
|
+
"VIEW_PORT_MENU_ROW_RPC",
|
|
5
|
+
"VIEW_PORT_MENU_CELL_RPC",
|
|
6
|
+
"VP_EDIT_CELL_RPC",
|
|
7
|
+
"VP_EDIT_ROW_RPC",
|
|
8
|
+
"VP_EDIT_ADD_ROW_RPC",
|
|
9
|
+
"VP_EDIT_DELETE_CELL_RPC",
|
|
10
|
+
"VP_EDIT_DELETE_ROW_RPC",
|
|
11
|
+
"VP_EDIT_SUBMIT_FORM_RPC"
|
|
12
|
+
];
|
|
13
|
+
const isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
|
|
14
|
+
const isVuuRpcRequest = (message) => message["type"] === "VIEW_PORT_RPC_CALL";
|
|
15
|
+
const stripRequestId = ({
|
|
16
|
+
requestId,
|
|
17
|
+
...rest
|
|
18
|
+
}) => [requestId, rest];
|
|
19
|
+
const getFirstAndLastRows = (rows) => {
|
|
20
|
+
let firstRow = rows.at(0);
|
|
21
|
+
if (firstRow.updateType === "SIZE") {
|
|
22
|
+
if (rows.length === 1) {
|
|
23
|
+
return rows;
|
|
24
|
+
} else {
|
|
25
|
+
firstRow = rows.at(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const lastRow = rows.at(-1);
|
|
29
|
+
return [firstRow, lastRow];
|
|
30
|
+
};
|
|
31
|
+
const groupRowsByViewport = (rows) => {
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const row of rows) {
|
|
34
|
+
const rowsForViewport = result[row.viewPortId] || (result[row.viewPortId] = []);
|
|
35
|
+
rowsForViewport.push(row);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const createSchemaFromTableMetadata = ({
|
|
40
|
+
columns,
|
|
41
|
+
dataTypes,
|
|
42
|
+
key,
|
|
43
|
+
table
|
|
44
|
+
}) => {
|
|
45
|
+
return {
|
|
46
|
+
table,
|
|
47
|
+
columns: columns.map((col, idx) => ({
|
|
48
|
+
name: col,
|
|
49
|
+
serverDataType: dataTypes[idx]
|
|
50
|
+
})),
|
|
51
|
+
key
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { createSchemaFromTableMetadata, getFirstAndLastRows, groupRowsByViewport, isVuuMenuRpcRequest, isVuuRpcRequest, stripRequestId };
|
|
56
|
+
//# sourceMappingURL=message-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-utils.js","sources":["../src/message-utils.ts"],"sourcesContent":["import {\n TableSchema,\n VuuUIMessageOut,\n WithRequestId,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n ClientToServerMenuRPC,\n ClientToServerViewportRpcCall,\n VuuRow,\n VuuRpcRequest,\n VuuTable,\n VuuTableMeta,\n} from \"@vuu-ui/vuu-protocol-types\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n \"VP_EDIT_CELL_RPC\",\n \"VP_EDIT_ROW_RPC\",\n \"VP_EDIT_ADD_ROW_RPC\",\n \"VP_EDIT_DELETE_CELL_RPC\",\n \"VP_EDIT_DELETE_ROW_RPC\",\n \"VP_EDIT_SUBMIT_FORM_RPC\",\n];\n\nexport const isVuuMenuRpcRequest = (\n message: VuuUIMessageOut | VuuRpcRequest | ClientToServerMenuRPC\n): message is ClientToServerMenuRPC => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isVuuRpcRequest = (\n message:\n | VuuUIMessageOut\n | VuuRpcRequest\n | ClientToServerMenuRPC\n | ClientToServerViewportRpcCall\n): message is ClientToServerViewportRpcCall =>\n message[\"type\"] === \"VIEW_PORT_RPC_CALL\";\n\nexport const stripRequestId = <T>({\n requestId,\n ...rest\n}: WithRequestId<T>): [string, T] => [requestId, rest as T];\n\nexport const getFirstAndLastRows = (\n rows: VuuRow[]\n): [VuuRow, VuuRow] | [VuuRow] => {\n let firstRow = rows.at(0) as VuuRow;\n if (firstRow.updateType === \"SIZE\") {\n if (rows.length === 1) {\n return rows as [VuuRow];\n } else {\n firstRow = rows.at(1) as VuuRow;\n }\n }\n const lastRow = rows.at(-1) as VuuRow;\n return [firstRow, lastRow];\n};\n\nexport type ViewportRowMap = { [key: string]: VuuRow[] };\nexport const groupRowsByViewport = (rows: VuuRow[]): ViewportRowMap => {\n const result: ViewportRowMap = {};\n for (const row of rows) {\n const rowsForViewport =\n result[row.viewPortId] || (result[row.viewPortId] = []);\n rowsForViewport.push(row);\n }\n return result;\n};\n\nexport interface VuuTableMetaWithTable extends VuuTableMeta {\n table: VuuTable;\n}\n\nexport const createSchemaFromTableMetadata = ({\n columns,\n dataTypes,\n key,\n table,\n}: VuuTableMetaWithTable): Readonly<TableSchema> => {\n return {\n table,\n columns: columns.map((col, idx) => ({\n name: col,\n serverDataType: dataTypes[idx],\n })),\n key,\n };\n};\n"],"names":[],"mappings":"AAcA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,wBAAA;AAAA,EACA,yBAAA;AACF,CAAA,CAAA;AAEO,MAAM,sBAAsB,CACjC,OAAA,KACqC,eAAe,QAAS,CAAA,OAAA,CAAQ,MAAM,CAAC,EAAA;AAEvE,MAAM,eAAkB,GAAA,CAC7B,OAMA,KAAA,OAAA,CAAQ,MAAM,CAAM,KAAA,qBAAA;AAEf,MAAM,iBAAiB,CAAI;AAAA,EAChC,SAAA;AAAA,EACA,GAAG,IAAA;AACL,CAAqC,KAAA,CAAC,WAAW,IAAS,EAAA;AAE7C,MAAA,mBAAA,GAAsB,CACjC,IACgC,KAAA;AAChC,EAAI,IAAA,QAAA,GAAW,IAAK,CAAA,EAAA,CAAG,CAAC,CAAA,CAAA;AACxB,EAAI,IAAA,QAAA,CAAS,eAAe,MAAQ,EAAA;AAClC,IAAI,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AACrB,MAAO,OAAA,IAAA,CAAA;AAAA,KACF,MAAA;AACL,MAAW,QAAA,GAAA,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAAA,KACtB;AAAA,GACF;AACA,EAAM,MAAA,OAAA,GAAU,IAAK,CAAA,EAAA,CAAG,CAAE,CAAA,CAAA,CAAA;AAC1B,EAAO,OAAA,CAAC,UAAU,OAAO,CAAA,CAAA;AAC3B,EAAA;AAGa,MAAA,mBAAA,GAAsB,CAAC,IAAmC,KAAA;AACrE,EAAA,MAAM,SAAyB,EAAC,CAAA;AAChC,EAAA,KAAA,MAAW,OAAO,IAAM,EAAA;AACtB,IAAM,MAAA,eAAA,GACJ,OAAO,GAAI,CAAA,UAAU,MAAM,MAAO,CAAA,GAAA,CAAI,UAAU,CAAA,GAAI,EAAC,CAAA,CAAA;AACvD,IAAA,eAAA,CAAgB,KAAK,GAAG,CAAA,CAAA;AAAA,GAC1B;AACA,EAAO,OAAA,MAAA,CAAA;AACT,EAAA;AAMO,MAAM,gCAAgC,CAAC;AAAA,EAC5C,OAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AACF,CAAoD,KAAA;AAClD,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,OAAS,EAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,KAAK,GAAS,MAAA;AAAA,MAClC,IAAM,EAAA,GAAA;AAAA,MACN,cAAA,EAAgB,UAAU,GAAG,CAAA;AAAA,KAC7B,CAAA,CAAA;AAAA,IACF,GAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sources":["../../src/server-proxy/messages.ts"],"sourcesContent":["export const CHANGE_VP_SUCCESS = \"CHANGE_VP_SUCCESS\";\nexport const CHANGE_VP_RANGE_SUCCESS = \"CHANGE_VP_RANGE_SUCCESS\";\nexport const CLOSE_TREE_NODE = \"CLOSE_TREE_NODE\";\nexport const CLOSE_TREE_SUCCESS = \"CLOSE_TREE_SUCCESS\";\nexport const CLOSE_TREE_REJECT = \"CLOSE_TREE_REJECT\";\nexport const CREATE_VISUAL_LINK = \"CREATE_VISUAL_LINK\";\nexport const CREATE_VP = \"CREATE_VP\";\nexport const DISABLE_VP = \"DISABLE_VP\";\nexport const DISABLE_VP_SUCCESS = \"DISABLE_VP_SUCCESS\";\nexport const DISABLE_VP_REJECT = \"DISABLE_VP_REJECT\";\nexport const ENABLE_VP = \"ENABLE_VP\";\nexport const ENABLE_VP_SUCCESS = \"ENABLE_VP_SUCCESS\";\nexport const ENABLE_VP_REJECT = \"ENABLE_VP_REJECT\";\nexport const GET_TABLE_META = \"GET_TABLE_META\";\nexport const GET_VP_VISUAL_LINKS = \"GET_VP_VISUAL_LINKS\";\nexport const GET_VIEW_PORT_MENUS = \"GET_VIEW_PORT_MENUS\";\nexport const VIEW_PORT_MENUS_SELECT_RPC = \"VIEW_PORT_MENUS_SELECT_RPC\";\nexport const VIEW_PORT_MENU_CELL_RPC = \"VIEW_PORT_MENU_CELL_RPC\";\nexport const VIEW_PORT_MENU_TABLE_RPC = \"VIEW_PORT_MENU_TABLE_RPC\";\nexport const VIEW_PORT_MENU_ROW_RPC = \"VIEW_PORT_MENU_ROW_RPC\";\nexport const VIEW_PORT_MENU_RESP = \"VIEW_PORT_MENU_RESP\";\nexport const VIEW_PORT_MENU_REJ = \"VIEW_PORT_MENU_REJ\";\nexport const HB = \"HB\";\nexport const HB_RESP = \"HB_RESP\";\nexport const LOGIN = \"LOGIN\";\nexport const OPEN_TREE_NODE = \"OPEN_TREE_NODE\";\nexport const OPEN_TREE_SUCCESS = \"OPEN_TREE_SUCCESS\";\nexport const OPEN_TREE_REJECT = \"OPEN_TREE_REJECT\";\nexport const REMOVE_VP = \"REMOVE_VP\";\nexport const REMOVE_VP_REJECT = \"REMOVE_VP_REJECT\";\nexport const RPC_CALL = \"RPC_CALL\";\nexport const RPC_RESP = \"RPC_RESP\";\nexport const MENU_RPC_RESP = \"MENU_RPC_RESP\";\nexport const SET_SELECTION = \"SET_SELECTION\";\nexport const SET_SELECTION_SUCCESS = \"SET_SELECTION_SUCCESS\";\n\nexport const TABLE_ROW = \"TABLE_ROW\";\nexport const SIZE = \"SIZE\";\nexport const UPDATE = \"U\";\n"],"names":[],"mappings":"AAaO,MAAM,cAAiB,GAAA;;;;"}
|
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import { parseFilter } from '@vuu-ui/vuu-filter-parser';
|
|
2
|
+
import { logger, EventEmitter, isViewportMenusAction, isVisualLinksAction, debounce, throttle, uuid, isConfigChanged, withConfigDefaults, itemsOrOrderChanged, metadataKeys, vanillaConfig } from '@vuu-ui/vuu-utils';
|
|
3
|
+
import { getServerAPI } from './connection-manager.js';
|
|
4
|
+
import { isDataSourceConfigMessage } from './data-source.js';
|
|
5
|
+
|
|
6
|
+
var __accessCheck = (obj, member, msg) => {
|
|
7
|
+
if (!member.has(obj))
|
|
8
|
+
throw TypeError("Cannot " + msg);
|
|
9
|
+
};
|
|
10
|
+
var __privateGet = (obj, member, getter) => {
|
|
11
|
+
__accessCheck(obj, member, "read from private field");
|
|
12
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
13
|
+
};
|
|
14
|
+
var __privateAdd = (obj, member, value) => {
|
|
15
|
+
if (member.has(obj))
|
|
16
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
17
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
18
|
+
};
|
|
19
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
20
|
+
__accessCheck(obj, member, "write to private field");
|
|
21
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
var _config, _groupBy, _links, _menu, _optimize, _range, _selectedRowsCount, _size, _status, _tableSchema, _title;
|
|
25
|
+
const { info } = logger("VuuDataSource");
|
|
26
|
+
const { KEY } = metadataKeys;
|
|
27
|
+
class VuuDataSource extends EventEmitter {
|
|
28
|
+
constructor({
|
|
29
|
+
bufferSize = 100,
|
|
30
|
+
aggregations,
|
|
31
|
+
columns,
|
|
32
|
+
filter,
|
|
33
|
+
groupBy,
|
|
34
|
+
sort,
|
|
35
|
+
table,
|
|
36
|
+
title,
|
|
37
|
+
viewport,
|
|
38
|
+
visualLink
|
|
39
|
+
}) {
|
|
40
|
+
super();
|
|
41
|
+
this.server = null;
|
|
42
|
+
__privateAdd(this, _config, vanillaConfig);
|
|
43
|
+
__privateAdd(this, _groupBy, []);
|
|
44
|
+
__privateAdd(this, _links, void 0);
|
|
45
|
+
__privateAdd(this, _menu, void 0);
|
|
46
|
+
__privateAdd(this, _optimize, "throttle");
|
|
47
|
+
__privateAdd(this, _range, { from: 0, to: 0 });
|
|
48
|
+
__privateAdd(this, _selectedRowsCount, 0);
|
|
49
|
+
__privateAdd(this, _size, 0);
|
|
50
|
+
__privateAdd(this, _status, "initialising");
|
|
51
|
+
__privateAdd(this, _tableSchema, void 0);
|
|
52
|
+
__privateAdd(this, _title, void 0);
|
|
53
|
+
this.handleMessageFromServer = (message) => {
|
|
54
|
+
if (message.type === "subscribed") {
|
|
55
|
+
__privateSet(this, _status, "subscribed");
|
|
56
|
+
this.tableSchema = message.tableSchema;
|
|
57
|
+
this.clientCallback?.(message);
|
|
58
|
+
} else if (message.type === "disabled") {
|
|
59
|
+
__privateSet(this, _status, "disabled");
|
|
60
|
+
} else if (message.type === "enabled") {
|
|
61
|
+
__privateSet(this, _status, "enabled");
|
|
62
|
+
} else if (isDataSourceConfigMessage(message)) {
|
|
63
|
+
return;
|
|
64
|
+
} else if (message.type === "debounce-begin") {
|
|
65
|
+
this.optimize = "debounce";
|
|
66
|
+
} else {
|
|
67
|
+
if (message.type === "viewport-update" && message.size !== void 0 && message.size !== __privateGet(this, _size)) {
|
|
68
|
+
__privateSet(this, _size, message.size);
|
|
69
|
+
this.emit("resize", message.size);
|
|
70
|
+
}
|
|
71
|
+
if (this.configChangePending) {
|
|
72
|
+
this.setConfigPending();
|
|
73
|
+
}
|
|
74
|
+
if (isViewportMenusAction(message)) {
|
|
75
|
+
__privateSet(this, _menu, message.menu);
|
|
76
|
+
} else if (isVisualLinksAction(message)) {
|
|
77
|
+
__privateSet(this, _links, message.links);
|
|
78
|
+
} else {
|
|
79
|
+
this.clientCallback?.(message);
|
|
80
|
+
}
|
|
81
|
+
if (this.optimize === "debounce") {
|
|
82
|
+
this.revertDebounce();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
this.revertDebounce = debounce(() => {
|
|
87
|
+
this.optimize = "throttle";
|
|
88
|
+
}, 100);
|
|
89
|
+
this.rawRangeRequest = (range) => {
|
|
90
|
+
if (this.viewport && this.server) {
|
|
91
|
+
this.server.send({
|
|
92
|
+
viewport: this.viewport,
|
|
93
|
+
type: "setViewRange",
|
|
94
|
+
range
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
this.debounceRangeRequest = debounce((range) => {
|
|
99
|
+
if (this.viewport && this.server) {
|
|
100
|
+
this.server.send({
|
|
101
|
+
viewport: this.viewport,
|
|
102
|
+
type: "setViewRange",
|
|
103
|
+
range
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, 50);
|
|
107
|
+
this.throttleRangeRequest = throttle((range) => {
|
|
108
|
+
if (this.viewport && this.server) {
|
|
109
|
+
this.server.send({
|
|
110
|
+
viewport: this.viewport,
|
|
111
|
+
type: "setViewRange",
|
|
112
|
+
range
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, 80);
|
|
116
|
+
if (!table)
|
|
117
|
+
throw Error("RemoteDataSource constructor called without table");
|
|
118
|
+
this.bufferSize = bufferSize;
|
|
119
|
+
this.table = table;
|
|
120
|
+
this.viewport = viewport;
|
|
121
|
+
__privateSet(this, _config, {
|
|
122
|
+
...__privateGet(this, _config),
|
|
123
|
+
aggregations: aggregations || __privateGet(this, _config).aggregations,
|
|
124
|
+
columns: columns || __privateGet(this, _config).columns,
|
|
125
|
+
filter: filter || __privateGet(this, _config).filter,
|
|
126
|
+
groupBy: groupBy || __privateGet(this, _config).groupBy,
|
|
127
|
+
sort: sort || __privateGet(this, _config).sort,
|
|
128
|
+
visualLink: visualLink || __privateGet(this, _config).visualLink
|
|
129
|
+
});
|
|
130
|
+
__privateSet(this, _title, title);
|
|
131
|
+
this.rangeRequest = this.throttleRangeRequest;
|
|
132
|
+
}
|
|
133
|
+
async subscribe({
|
|
134
|
+
viewport = this.viewport ?? (this.viewport = uuid()),
|
|
135
|
+
columns,
|
|
136
|
+
aggregations,
|
|
137
|
+
range,
|
|
138
|
+
sort,
|
|
139
|
+
groupBy,
|
|
140
|
+
filter
|
|
141
|
+
}, callback) {
|
|
142
|
+
if (__privateGet(this, _status) === "disabled" || __privateGet(this, _status) === "disabling") {
|
|
143
|
+
this.enable(callback);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.clientCallback = callback;
|
|
147
|
+
if (aggregations || columns || filter || groupBy || sort) {
|
|
148
|
+
__privateSet(this, _config, {
|
|
149
|
+
...__privateGet(this, _config),
|
|
150
|
+
aggregations: aggregations || __privateGet(this, _config).aggregations,
|
|
151
|
+
columns: columns || __privateGet(this, _config).columns,
|
|
152
|
+
filter: filter || __privateGet(this, _config).filter,
|
|
153
|
+
groupBy: groupBy || __privateGet(this, _config).groupBy,
|
|
154
|
+
sort: sort || __privateGet(this, _config).sort
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (range) {
|
|
158
|
+
__privateSet(this, _range, range);
|
|
159
|
+
}
|
|
160
|
+
if (__privateGet(this, _status) !== "initialising" && __privateGet(this, _status) !== "unsubscribed") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
__privateSet(this, _status, "subscribing");
|
|
164
|
+
this.viewport = viewport;
|
|
165
|
+
this.server = await getServerAPI();
|
|
166
|
+
const { bufferSize } = this;
|
|
167
|
+
this.server?.subscribe(
|
|
168
|
+
{
|
|
169
|
+
...__privateGet(this, _config),
|
|
170
|
+
bufferSize,
|
|
171
|
+
viewport,
|
|
172
|
+
table: this.table,
|
|
173
|
+
range: __privateGet(this, _range),
|
|
174
|
+
title: __privateGet(this, _title)
|
|
175
|
+
},
|
|
176
|
+
this.handleMessageFromServer
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
unsubscribe() {
|
|
180
|
+
console.log(`unsubscribe #${this.viewport}`);
|
|
181
|
+
info?.(`unsubscribe #${this.viewport}`);
|
|
182
|
+
if (this.viewport) {
|
|
183
|
+
this.server?.unsubscribe(this.viewport);
|
|
184
|
+
}
|
|
185
|
+
this.server?.destroy(this.viewport);
|
|
186
|
+
this.server = null;
|
|
187
|
+
this.removeAllListeners();
|
|
188
|
+
__privateSet(this, _status, "unsubscribed");
|
|
189
|
+
this.viewport = void 0;
|
|
190
|
+
this.range = { from: 0, to: 0 };
|
|
191
|
+
}
|
|
192
|
+
suspend() {
|
|
193
|
+
console.log(`suspend #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
194
|
+
info?.(`suspend #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
195
|
+
if (this.viewport) {
|
|
196
|
+
__privateSet(this, _status, "suspended");
|
|
197
|
+
this.server?.send({
|
|
198
|
+
type: "suspend",
|
|
199
|
+
viewport: this.viewport
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return this;
|
|
203
|
+
}
|
|
204
|
+
resume() {
|
|
205
|
+
console.log(`resume #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
206
|
+
const isDisabled = __privateGet(this, _status).startsWith("disabl");
|
|
207
|
+
const isSuspended = __privateGet(this, _status) === "suspended";
|
|
208
|
+
info?.(`resume #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
209
|
+
if (this.viewport) {
|
|
210
|
+
if (isDisabled) {
|
|
211
|
+
this.enable();
|
|
212
|
+
} else if (isSuspended) {
|
|
213
|
+
this.server?.send({
|
|
214
|
+
type: "resume",
|
|
215
|
+
viewport: this.viewport
|
|
216
|
+
});
|
|
217
|
+
__privateSet(this, _status, "subscribed");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
disable() {
|
|
223
|
+
info?.(`disable #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
224
|
+
if (this.viewport) {
|
|
225
|
+
__privateSet(this, _status, "disabling");
|
|
226
|
+
this.server?.send({
|
|
227
|
+
viewport: this.viewport,
|
|
228
|
+
type: "disable"
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
enable(callback) {
|
|
234
|
+
info?.(`enable #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
235
|
+
if (this.viewport && (__privateGet(this, _status) === "disabled" || __privateGet(this, _status) === "disabling")) {
|
|
236
|
+
__privateSet(this, _status, "enabling");
|
|
237
|
+
if (callback) {
|
|
238
|
+
this.clientCallback = callback;
|
|
239
|
+
}
|
|
240
|
+
this.server?.send({
|
|
241
|
+
viewport: this.viewport,
|
|
242
|
+
type: "enable"
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
select(selected) {
|
|
248
|
+
__privateSet(this, _selectedRowsCount, selected.length);
|
|
249
|
+
if (this.viewport) {
|
|
250
|
+
this.server?.send({
|
|
251
|
+
viewport: this.viewport,
|
|
252
|
+
type: "select",
|
|
253
|
+
selected
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
openTreeNode(key) {
|
|
258
|
+
if (this.viewport) {
|
|
259
|
+
this.server?.send({
|
|
260
|
+
viewport: this.viewport,
|
|
261
|
+
type: "openTreeNode",
|
|
262
|
+
key
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
closeTreeNode(key) {
|
|
267
|
+
if (this.viewport) {
|
|
268
|
+
this.server?.send({
|
|
269
|
+
viewport: this.viewport,
|
|
270
|
+
type: "closeTreeNode",
|
|
271
|
+
key
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
get tableSchema() {
|
|
276
|
+
return __privateGet(this, _tableSchema);
|
|
277
|
+
}
|
|
278
|
+
set tableSchema(tableSchema) {
|
|
279
|
+
__privateSet(this, _tableSchema, tableSchema);
|
|
280
|
+
}
|
|
281
|
+
get links() {
|
|
282
|
+
return __privateGet(this, _links);
|
|
283
|
+
}
|
|
284
|
+
get menu() {
|
|
285
|
+
return __privateGet(this, _menu);
|
|
286
|
+
}
|
|
287
|
+
get status() {
|
|
288
|
+
return __privateGet(this, _status);
|
|
289
|
+
}
|
|
290
|
+
get optimize() {
|
|
291
|
+
return __privateGet(this, _optimize);
|
|
292
|
+
}
|
|
293
|
+
set optimize(optimize) {
|
|
294
|
+
if (optimize !== __privateGet(this, _optimize)) {
|
|
295
|
+
__privateSet(this, _optimize, optimize);
|
|
296
|
+
switch (optimize) {
|
|
297
|
+
case "none":
|
|
298
|
+
this.rangeRequest = this.rawRangeRequest;
|
|
299
|
+
break;
|
|
300
|
+
case "debounce":
|
|
301
|
+
this.rangeRequest = this.debounceRangeRequest;
|
|
302
|
+
break;
|
|
303
|
+
case "throttle":
|
|
304
|
+
this.rangeRequest = this.throttleRangeRequest;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
this.emit("optimize", optimize);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
get selectedRowsCount() {
|
|
311
|
+
return __privateGet(this, _selectedRowsCount);
|
|
312
|
+
}
|
|
313
|
+
get size() {
|
|
314
|
+
return __privateGet(this, _size);
|
|
315
|
+
}
|
|
316
|
+
get range() {
|
|
317
|
+
return __privateGet(this, _range);
|
|
318
|
+
}
|
|
319
|
+
set range(range) {
|
|
320
|
+
if (range.from !== __privateGet(this, _range).from || range.to !== __privateGet(this, _range).to) {
|
|
321
|
+
__privateSet(this, _range, range);
|
|
322
|
+
this.rangeRequest(range);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
get config() {
|
|
326
|
+
return __privateGet(this, _config);
|
|
327
|
+
}
|
|
328
|
+
set config(config) {
|
|
329
|
+
const configChanges = this.applyConfig(config);
|
|
330
|
+
if (configChanges) {
|
|
331
|
+
if (__privateGet(this, _config) && this.viewport) {
|
|
332
|
+
if (config) {
|
|
333
|
+
this.server?.send({
|
|
334
|
+
viewport: this.viewport,
|
|
335
|
+
type: "config",
|
|
336
|
+
config: __privateGet(this, _config)
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
this.emit("config", __privateGet(this, _config), void 0, configChanges);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
applyConfig(config) {
|
|
344
|
+
const { noChanges, ...otherChanges } = isConfigChanged(
|
|
345
|
+
__privateGet(this, _config),
|
|
346
|
+
config
|
|
347
|
+
);
|
|
348
|
+
if (noChanges !== true) {
|
|
349
|
+
if (config) {
|
|
350
|
+
const newConfig = config?.filter?.filter && config?.filter.filterStruct === void 0 ? {
|
|
351
|
+
...config,
|
|
352
|
+
filter: {
|
|
353
|
+
filter: config.filter.filter,
|
|
354
|
+
filterStruct: parseFilter(config.filter.filter)
|
|
355
|
+
}
|
|
356
|
+
} : config;
|
|
357
|
+
__privateSet(this, _config, withConfigDefaults(newConfig));
|
|
358
|
+
return otherChanges;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
//TODO replace all these individual server calls with calls to setConfig
|
|
363
|
+
get columns() {
|
|
364
|
+
return __privateGet(this, _config).columns;
|
|
365
|
+
}
|
|
366
|
+
set columns(columns) {
|
|
367
|
+
__privateSet(this, _config, {
|
|
368
|
+
...__privateGet(this, _config),
|
|
369
|
+
columns
|
|
370
|
+
});
|
|
371
|
+
if (this.viewport) {
|
|
372
|
+
const message = {
|
|
373
|
+
viewport: this.viewport,
|
|
374
|
+
type: "setColumns",
|
|
375
|
+
columns
|
|
376
|
+
};
|
|
377
|
+
if (this.server) {
|
|
378
|
+
this.server.send(message);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
this.emit("config", __privateGet(this, _config));
|
|
382
|
+
}
|
|
383
|
+
get aggregations() {
|
|
384
|
+
return __privateGet(this, _config).aggregations;
|
|
385
|
+
}
|
|
386
|
+
set aggregations(aggregations) {
|
|
387
|
+
__privateSet(this, _config, {
|
|
388
|
+
...__privateGet(this, _config),
|
|
389
|
+
aggregations
|
|
390
|
+
});
|
|
391
|
+
if (this.viewport) {
|
|
392
|
+
this.server?.send({
|
|
393
|
+
viewport: this.viewport,
|
|
394
|
+
type: "aggregate",
|
|
395
|
+
aggregations
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
this.emit("config", __privateGet(this, _config));
|
|
399
|
+
}
|
|
400
|
+
get sort() {
|
|
401
|
+
return __privateGet(this, _config).sort;
|
|
402
|
+
}
|
|
403
|
+
set sort(sort) {
|
|
404
|
+
__privateSet(this, _config, {
|
|
405
|
+
...__privateGet(this, _config),
|
|
406
|
+
sort
|
|
407
|
+
});
|
|
408
|
+
if (this.viewport) {
|
|
409
|
+
const message = {
|
|
410
|
+
viewport: this.viewport,
|
|
411
|
+
type: "sort",
|
|
412
|
+
sort
|
|
413
|
+
};
|
|
414
|
+
this.server?.send(message);
|
|
415
|
+
}
|
|
416
|
+
this.emit("config", __privateGet(this, _config));
|
|
417
|
+
}
|
|
418
|
+
get filter() {
|
|
419
|
+
return __privateGet(this, _config).filter;
|
|
420
|
+
}
|
|
421
|
+
set filter(filter) {
|
|
422
|
+
this.config = {
|
|
423
|
+
...__privateGet(this, _config),
|
|
424
|
+
filter
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
get groupBy() {
|
|
428
|
+
return __privateGet(this, _config).groupBy;
|
|
429
|
+
}
|
|
430
|
+
set groupBy(groupBy) {
|
|
431
|
+
if (itemsOrOrderChanged(this.groupBy, groupBy)) {
|
|
432
|
+
const wasGrouped = __privateGet(this, _groupBy).length > 0;
|
|
433
|
+
this.config = {
|
|
434
|
+
...__privateGet(this, _config),
|
|
435
|
+
groupBy
|
|
436
|
+
};
|
|
437
|
+
if (!wasGrouped && groupBy.length > 0 && this.viewport) {
|
|
438
|
+
this.clientCallback?.({
|
|
439
|
+
clientViewportId: this.viewport,
|
|
440
|
+
mode: "batch",
|
|
441
|
+
type: "viewport-update",
|
|
442
|
+
size: 0,
|
|
443
|
+
rows: []
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
this.setConfigPending({ groupBy });
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
get title() {
|
|
450
|
+
return __privateGet(this, _title);
|
|
451
|
+
}
|
|
452
|
+
set title(title) {
|
|
453
|
+
__privateSet(this, _title, title);
|
|
454
|
+
if (this.viewport && title) {
|
|
455
|
+
this.server?.send({
|
|
456
|
+
type: "setTitle",
|
|
457
|
+
title,
|
|
458
|
+
viewport: this.viewport
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
get visualLink() {
|
|
463
|
+
return __privateGet(this, _config).visualLink;
|
|
464
|
+
}
|
|
465
|
+
set visualLink(visualLink) {
|
|
466
|
+
__privateSet(this, _config, {
|
|
467
|
+
...__privateGet(this, _config),
|
|
468
|
+
visualLink
|
|
469
|
+
});
|
|
470
|
+
if (visualLink) {
|
|
471
|
+
const {
|
|
472
|
+
parentClientVpId,
|
|
473
|
+
link: { fromColumn, toColumn }
|
|
474
|
+
} = visualLink;
|
|
475
|
+
if (this.viewport) {
|
|
476
|
+
this.server?.send({
|
|
477
|
+
viewport: this.viewport,
|
|
478
|
+
type: "createLink",
|
|
479
|
+
parentClientVpId,
|
|
480
|
+
parentColumnName: toColumn,
|
|
481
|
+
childColumnName: fromColumn
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
if (this.viewport) {
|
|
486
|
+
this.server?.send({
|
|
487
|
+
type: "removeLink",
|
|
488
|
+
viewport: this.viewport
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
this.emit("config", __privateGet(this, _config));
|
|
493
|
+
}
|
|
494
|
+
setConfigPending(config) {
|
|
495
|
+
const pendingConfig = this.configChangePending;
|
|
496
|
+
this.configChangePending = config;
|
|
497
|
+
if (config !== void 0) {
|
|
498
|
+
this.emit("config", config, false);
|
|
499
|
+
} else {
|
|
500
|
+
this.emit("config", pendingConfig, true);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
async rpcCall(rpcRequest) {
|
|
504
|
+
if (this.viewport) {
|
|
505
|
+
return this.server?.rpcCall({
|
|
506
|
+
vpId: this.viewport,
|
|
507
|
+
...rpcRequest
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
async menuRpcCall(rpcRequest) {
|
|
512
|
+
if (this.viewport) {
|
|
513
|
+
return this.server?.rpcCall({
|
|
514
|
+
vpId: this.viewport,
|
|
515
|
+
...rpcRequest
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
applyEdit(row, columnName, value) {
|
|
520
|
+
return this.menuRpcCall({
|
|
521
|
+
rowKey: row[KEY],
|
|
522
|
+
field: columnName,
|
|
523
|
+
value,
|
|
524
|
+
type: "VP_EDIT_CELL_RPC"
|
|
525
|
+
}).then((response) => {
|
|
526
|
+
if (response?.error) {
|
|
527
|
+
return response.error;
|
|
528
|
+
} else {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
insertRow(key, data) {
|
|
534
|
+
return this.menuRpcCall({
|
|
535
|
+
rowKey: key,
|
|
536
|
+
data,
|
|
537
|
+
type: "VP_EDIT_ADD_ROW_RPC"
|
|
538
|
+
}).then((response) => {
|
|
539
|
+
if (response?.error) {
|
|
540
|
+
return response.error;
|
|
541
|
+
} else {
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
deleteRow(rowKey) {
|
|
547
|
+
return this.menuRpcCall({
|
|
548
|
+
rowKey,
|
|
549
|
+
type: "VP_EDIT_DELETE_ROW_RPC"
|
|
550
|
+
}).then((response) => {
|
|
551
|
+
if (response?.error) {
|
|
552
|
+
return response.error;
|
|
553
|
+
} else {
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
_config = new WeakMap();
|
|
560
|
+
_groupBy = new WeakMap();
|
|
561
|
+
_links = new WeakMap();
|
|
562
|
+
_menu = new WeakMap();
|
|
563
|
+
_optimize = new WeakMap();
|
|
564
|
+
_range = new WeakMap();
|
|
565
|
+
_selectedRowsCount = new WeakMap();
|
|
566
|
+
_size = new WeakMap();
|
|
567
|
+
_status = new WeakMap();
|
|
568
|
+
_tableSchema = new WeakMap();
|
|
569
|
+
_title = new WeakMap();
|
|
570
|
+
|
|
571
|
+
export { VuuDataSource };
|
|
572
|
+
//# sourceMappingURL=vuu-data-source.js.map
|