@vuu-ui/vuu-data-remote 2.1.18 → 2.1.19-beta.1
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 +10 -12
- package/types/ConnectionManager.d.ts +2 -2
- package/types/VuuDataSource.d.ts +2 -2
- package/types/inlined-worker.d.ts +1 -1
- package/types/server-proxy/viewport.d.ts +1 -1
- package/cjs/ConnectionManager.js +0 -181
- package/cjs/ConnectionManager.js.map +0 -1
- package/cjs/DedicatedWorker.js +0 -61
- package/cjs/DedicatedWorker.js.map +0 -1
- package/cjs/LostConnectionHandler.js +0 -83
- package/cjs/LostConnectionHandler.js.map +0 -1
- package/cjs/VuuAuthProvider.js +0 -87
- package/cjs/VuuAuthProvider.js.map +0 -1
- package/cjs/VuuAuthenticator.js +0 -57
- package/cjs/VuuAuthenticator.js.map +0 -1
- package/cjs/VuuDataSource.js +0 -638
- package/cjs/VuuDataSource.js.map +0 -1
- package/cjs/WebSocketConnection.js +0 -20
- package/cjs/WebSocketConnection.js.map +0 -1
- package/cjs/authenticate.js +0 -64
- package/cjs/authenticate.js.map +0 -1
- package/cjs/constants.js +0 -50
- package/cjs/constants.js.map +0 -1
- package/cjs/data-source.js +0 -49
- package/cjs/data-source.js.map +0 -1
- package/cjs/index.js +0 -38
- package/cjs/index.js.map +0 -1
- package/cjs/inlined-worker.js +0 -2742
- package/cjs/inlined-worker.js.map +0 -1
- package/cjs/message-utils.js +0 -70
- package/cjs/message-utils.js.map +0 -1
- package/esm/ConnectionManager.js +0 -179
- package/esm/ConnectionManager.js.map +0 -1
- package/esm/DedicatedWorker.js +0 -59
- package/esm/DedicatedWorker.js.map +0 -1
- package/esm/LostConnectionHandler.js +0 -79
- package/esm/LostConnectionHandler.js.map +0 -1
- package/esm/VuuAuthProvider.js +0 -85
- package/esm/VuuAuthProvider.js.map +0 -1
- package/esm/VuuAuthenticator.js +0 -54
- package/esm/VuuAuthenticator.js.map +0 -1
- package/esm/VuuDataSource.js +0 -636
- package/esm/VuuDataSource.js.map +0 -1
- package/esm/WebSocketConnection.js +0 -17
- package/esm/WebSocketConnection.js.map +0 -1
- package/esm/authenticate.js +0 -60
- package/esm/authenticate.js.map +0 -1
- package/esm/constants.js +0 -47
- package/esm/constants.js.map +0 -1
- package/esm/data-source.js +0 -44
- package/esm/data-source.js.map +0 -1
- package/esm/index.js +0 -11
- package/esm/index.js.map +0 -1
- package/esm/inlined-worker.js +0 -2740
- package/esm/inlined-worker.js.map +0 -1
- package/esm/message-utils.js +0 -64
- package/esm/message-utils.js.map +0 -1
package/esm/VuuDataSource.js
DELETED
|
@@ -1,636 +0,0 @@
|
|
|
1
|
-
import { logger, BaseDataSource, debounce, throttle, uuid, combineFilters, Range, isSelectSuccessWithRowCount, isConfigChanged, itemsOrOrderChanged, isRpcSuccess, isInlineEditingSession, StaleUpdateError, isViewportMenusAction, isVisualLinksAction } from '@vuu-ui/vuu-utils';
|
|
2
|
-
import ConnectionManager from './ConnectionManager.js';
|
|
3
|
-
import { isDataSourceConfigMessage } from './data-source.js';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __typeError = (msg) => {
|
|
7
|
-
throw TypeError(msg);
|
|
8
|
-
};
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
12
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
13
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
15
|
-
var _allColumns, _autosubscribeColumns, _pendingVisualLink, _links, _menu, _optimize, _selectedRowsCount, _sessionDataSource, _sessionTableMessageColumn, _status, _tableSchema;
|
|
16
|
-
const { info, infoEnabled } = logger("VuuDataSource");
|
|
17
|
-
const combineColumnsWithAutosubscribeColumns = (columns, autosubscribeColumns = []) => {
|
|
18
|
-
if (autosubscribeColumns.length === 0) {
|
|
19
|
-
return columns;
|
|
20
|
-
} else {
|
|
21
|
-
const out = columns.slice();
|
|
22
|
-
autosubscribeColumns.forEach((name) => {
|
|
23
|
-
if (!out.includes(name)) {
|
|
24
|
-
out.push(name);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
return out;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const _VuuDataSource = class _VuuDataSource extends BaseDataSource {
|
|
31
|
-
constructor({
|
|
32
|
-
sessionTableMessageColumn,
|
|
33
|
-
...props
|
|
34
|
-
}) {
|
|
35
|
-
super(props);
|
|
36
|
-
__publicField(this, "bufferSize");
|
|
37
|
-
__publicField(this, "server", null);
|
|
38
|
-
__publicField(this, "rangeRequest");
|
|
39
|
-
/**
|
|
40
|
-
* this is the combined set of regular columns and autosubscribe columns
|
|
41
|
-
*/
|
|
42
|
-
__privateAdd(this, _allColumns);
|
|
43
|
-
__privateAdd(this, _autosubscribeColumns, []);
|
|
44
|
-
__privateAdd(this, _pendingVisualLink);
|
|
45
|
-
__privateAdd(this, _links);
|
|
46
|
-
__privateAdd(this, _menu);
|
|
47
|
-
__privateAdd(this, _optimize, "throttle");
|
|
48
|
-
__privateAdd(this, _selectedRowsCount, 0);
|
|
49
|
-
__privateAdd(this, _sessionDataSource);
|
|
50
|
-
__privateAdd(this, _sessionTableMessageColumn);
|
|
51
|
-
__privateAdd(this, _status, "initialising");
|
|
52
|
-
__privateAdd(this, _tableSchema);
|
|
53
|
-
__publicField(this, "table");
|
|
54
|
-
__publicField(this, "handleMessageFromServer", (message) => {
|
|
55
|
-
if (message.type === "subscribed") {
|
|
56
|
-
__privateSet(this, _status, "subscribed");
|
|
57
|
-
this.tableSchema = message.tableSchema;
|
|
58
|
-
this._clientCallback?.(message);
|
|
59
|
-
if (__privateGet(this, _pendingVisualLink)) {
|
|
60
|
-
this.visualLink = __privateGet(this, _pendingVisualLink);
|
|
61
|
-
__privateSet(this, _pendingVisualLink, void 0);
|
|
62
|
-
}
|
|
63
|
-
this.emit("subscribed", message);
|
|
64
|
-
} else if (message.type === "disabled") {
|
|
65
|
-
__privateSet(this, _status, "disabled");
|
|
66
|
-
} else if (message.type === "enabled") {
|
|
67
|
-
__privateSet(this, _status, "subscribed");
|
|
68
|
-
this.emit("enabled", this.viewport);
|
|
69
|
-
} else if (isDataSourceConfigMessage(message)) {
|
|
70
|
-
return;
|
|
71
|
-
} else if (message.type === "debounce-begin") {
|
|
72
|
-
this.optimize = "debounce";
|
|
73
|
-
} else {
|
|
74
|
-
if (message.type === "viewport-update") {
|
|
75
|
-
if (message.size !== void 0 && message.size !== this.size) {
|
|
76
|
-
this.size = message.size;
|
|
77
|
-
this.emit("resize", message.size);
|
|
78
|
-
}
|
|
79
|
-
if (Array.isArray(message.rows) && message.rows.length > 0 && __privateGet(this, _sessionDataSource)) {
|
|
80
|
-
this.emit("remote-update-during-local-edit", message.rows);
|
|
81
|
-
console.log(
|
|
82
|
-
`updates incoming whilst edit in progress ${this.viewport}`
|
|
83
|
-
);
|
|
84
|
-
console.table(message.rows);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
} else if (message.type === "viewport-clear") {
|
|
88
|
-
this.size = 0;
|
|
89
|
-
this.emit("resize", 0);
|
|
90
|
-
}
|
|
91
|
-
if (this.isAwaitingConfirmationOfConfigChange) {
|
|
92
|
-
this.confirmConfigChange();
|
|
93
|
-
}
|
|
94
|
-
if (isViewportMenusAction(message)) {
|
|
95
|
-
__privateSet(this, _menu, message.menu);
|
|
96
|
-
} else if (isVisualLinksAction(message)) {
|
|
97
|
-
__privateSet(this, _links, message.links);
|
|
98
|
-
} else {
|
|
99
|
-
if (infoEnabled && message.type === "viewport-update") {
|
|
100
|
-
info(
|
|
101
|
-
`handleMessageFromServer<viewport-update> range (${message.range?.from}:${message.range?.to}) rows ${message.rows?.at(0)?.[0]} - ${message.rows?.at(-1)?.[0]}`
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
this._clientCallback?.(message);
|
|
105
|
-
}
|
|
106
|
-
if (this.optimize === "debounce") {
|
|
107
|
-
this.revertDebounce();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
__publicField(this, "handleSessionMessageFromServer", (msg) => {
|
|
112
|
-
if (msg.type === "subscribed") {
|
|
113
|
-
console.log(`[VuuDataSource subscribed to session table]`);
|
|
114
|
-
} else if (msg.type === "viewport-update") {
|
|
115
|
-
if (msg.size !== void 0 && msg.size !== this.size) {
|
|
116
|
-
this.size = msg.size;
|
|
117
|
-
this.emit("resize", msg.size);
|
|
118
|
-
}
|
|
119
|
-
console.log(`[VuuDataSource] clientCallback with ${msg.type}`);
|
|
120
|
-
this._clientCallback?.(msg);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
__publicField(this, "revertDebounce", debounce(() => {
|
|
124
|
-
this.optimize = "throttle";
|
|
125
|
-
}, 100));
|
|
126
|
-
__publicField(this, "rawRangeRequest", (range) => {
|
|
127
|
-
if (this.viewport && this.server) {
|
|
128
|
-
this.server.send({
|
|
129
|
-
viewport: this.viewport,
|
|
130
|
-
type: "setViewRange",
|
|
131
|
-
range
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
__publicField(this, "debounceRangeRequest", debounce((range) => {
|
|
136
|
-
if (this.viewport && this.server) {
|
|
137
|
-
this.server.send({
|
|
138
|
-
viewport: this.viewport,
|
|
139
|
-
type: "setViewRange",
|
|
140
|
-
range
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}, 50));
|
|
144
|
-
__publicField(this, "throttleRangeRequest", throttle((range) => {
|
|
145
|
-
if (this.viewport && this.server) {
|
|
146
|
-
this.server.send({
|
|
147
|
-
viewport: this.viewport,
|
|
148
|
-
type: "setViewRange",
|
|
149
|
-
range
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}, 80));
|
|
153
|
-
const { bufferSize = 100, table, visualLink } = props;
|
|
154
|
-
if (!table)
|
|
155
|
-
throw Error("RemoteDataSource constructor called without table");
|
|
156
|
-
this.bufferSize = bufferSize;
|
|
157
|
-
this.table = table;
|
|
158
|
-
__privateSet(this, _pendingVisualLink, visualLink);
|
|
159
|
-
__privateSet(this, _sessionTableMessageColumn, sessionTableMessageColumn);
|
|
160
|
-
this.rangeRequest = this.rawRangeRequest;
|
|
161
|
-
if (props.autosubscribeColumns) {
|
|
162
|
-
__privateSet(this, _autosubscribeColumns, props.autosubscribeColumns);
|
|
163
|
-
__privateSet(this, _allColumns, combineColumnsWithAutosubscribeColumns(
|
|
164
|
-
super.columns,
|
|
165
|
-
props.autosubscribeColumns
|
|
166
|
-
));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
async subscribe(subscribeProps, callback) {
|
|
170
|
-
super.subscribe(subscribeProps, callback);
|
|
171
|
-
const { viewport = this.viewport || (this.viewport = uuid()) } = subscribeProps;
|
|
172
|
-
console.log(`[VuuDataSource] subscribe ${this.viewport}`);
|
|
173
|
-
if (__privateGet(this, _status) === "disabled" || __privateGet(this, _status) === "disabling" || __privateGet(this, _status) === "enabling") {
|
|
174
|
-
this.enable(callback);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (__privateGet(this, _status) !== "initialising" && __privateGet(this, _status) !== "unsubscribed") {
|
|
178
|
-
throw Error(
|
|
179
|
-
`[VuuDataSource] invalid status ${__privateGet(this, _status)} for subscribe`
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
__privateSet(this, _status, "subscribing");
|
|
183
|
-
this.server = await ConnectionManager.serverAPI;
|
|
184
|
-
const { bufferSize } = this;
|
|
185
|
-
const { columns, ...dataSourceConfig } = combineFilters(this.config);
|
|
186
|
-
this.server?.subscribe(
|
|
187
|
-
{
|
|
188
|
-
...dataSourceConfig,
|
|
189
|
-
bufferSize,
|
|
190
|
-
columns: this.columns,
|
|
191
|
-
range: this._range.withBuffer,
|
|
192
|
-
table: this.table,
|
|
193
|
-
title: this._title,
|
|
194
|
-
viewport
|
|
195
|
-
},
|
|
196
|
-
this.handleMessageFromServer
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
unsubscribe() {
|
|
200
|
-
if (__privateGet(this, _status) !== "unsubscribed") {
|
|
201
|
-
info?.(`unsubscribe #${this.viewport}`);
|
|
202
|
-
if (this.viewport) {
|
|
203
|
-
this.server?.unsubscribe(this.viewport);
|
|
204
|
-
this.emit("unsubscribed", this.viewport);
|
|
205
|
-
}
|
|
206
|
-
this.server?.destroy(this.viewport);
|
|
207
|
-
this.server = null;
|
|
208
|
-
this.removeAllListeners();
|
|
209
|
-
__privateSet(this, _status, "unsubscribed");
|
|
210
|
-
this.viewport = "";
|
|
211
|
-
this.range = Range(0, 0);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
suspend(escalateToDisable = this._defaultSuspenseProps.escalateToDisable, escalateDelay = this._defaultSuspenseProps.escalateDelay) {
|
|
215
|
-
if (__privateGet(this, _status) !== "unsubscribed") {
|
|
216
|
-
info?.(`suspend #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
217
|
-
if (this.viewport) {
|
|
218
|
-
__privateSet(this, _status, "suspended");
|
|
219
|
-
this.server?.send({
|
|
220
|
-
escalateDelay,
|
|
221
|
-
escalateToDisable,
|
|
222
|
-
type: "suspend",
|
|
223
|
-
viewport: this.viewport
|
|
224
|
-
});
|
|
225
|
-
this.emit("suspended", this.viewport);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Tell the server we wish to resume receiving messages. Server will send a
|
|
231
|
-
* snapshot of rows currently in cache. This can be used to update with
|
|
232
|
-
* latest data, e.g after an edit session during which we might have ignored
|
|
233
|
-
* some updates.
|
|
234
|
-
*/
|
|
235
|
-
sendResumeMessage() {
|
|
236
|
-
this.server?.send({
|
|
237
|
-
type: "resume",
|
|
238
|
-
viewport: this.viewport
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
resume(callback) {
|
|
242
|
-
const isDisabled = __privateGet(this, _status).startsWith("disabl");
|
|
243
|
-
const isSuspended = __privateGet(this, _status) === "suspended";
|
|
244
|
-
info?.(`resume #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
245
|
-
if (callback) {
|
|
246
|
-
this._clientCallback = callback;
|
|
247
|
-
}
|
|
248
|
-
if (this.viewport) {
|
|
249
|
-
if (isDisabled) {
|
|
250
|
-
this.enable();
|
|
251
|
-
} else if (isSuspended) {
|
|
252
|
-
this.sendResumeMessage();
|
|
253
|
-
__privateSet(this, _status, "subscribed");
|
|
254
|
-
this.emit("resumed", this.viewport);
|
|
255
|
-
if (__privateGet(this, _selectedRowsCount) > 0) {
|
|
256
|
-
this.emit("row-selection", __privateGet(this, _selectedRowsCount));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
freeze() {
|
|
262
|
-
super.freeze();
|
|
263
|
-
if (this.viewport) {
|
|
264
|
-
this.server?.send({
|
|
265
|
-
viewport: this.viewport,
|
|
266
|
-
type: "FREEZE_VP"
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
unfreeze() {
|
|
271
|
-
super.unfreeze();
|
|
272
|
-
if (this.viewport) {
|
|
273
|
-
this.server?.send({
|
|
274
|
-
viewport: this.viewport,
|
|
275
|
-
type: "UNFREEZE_VP"
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
disable() {
|
|
280
|
-
info?.(`disable #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
281
|
-
if (this.viewport) {
|
|
282
|
-
__privateSet(this, _status, "disabling");
|
|
283
|
-
this.server?.send({
|
|
284
|
-
viewport: this.viewport,
|
|
285
|
-
type: "disable"
|
|
286
|
-
});
|
|
287
|
-
this.emit("disabled", this.viewport);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
enable(callback) {
|
|
291
|
-
info?.(`enable #${this.viewport}, current status ${__privateGet(this, _status)}`);
|
|
292
|
-
if (this.viewport && (__privateGet(this, _status) === "disabled" || __privateGet(this, _status) === "disabling")) {
|
|
293
|
-
__privateSet(this, _status, "enabling");
|
|
294
|
-
if (callback) {
|
|
295
|
-
this._clientCallback = callback;
|
|
296
|
-
}
|
|
297
|
-
this.server?.send({
|
|
298
|
-
viewport: this.viewport,
|
|
299
|
-
type: "enable"
|
|
300
|
-
});
|
|
301
|
-
this.emit("enabled", this.viewport);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
async select(selectRequest) {
|
|
305
|
-
if (this.viewport && this.server) {
|
|
306
|
-
const response = await this.server.select({
|
|
307
|
-
...selectRequest,
|
|
308
|
-
vpId: this.viewport
|
|
309
|
-
});
|
|
310
|
-
if (isSelectSuccessWithRowCount(response)) {
|
|
311
|
-
console.log(
|
|
312
|
-
`[VuuDataSource] select selectedRowCount ${response.selectedRowCount}`
|
|
313
|
-
);
|
|
314
|
-
__privateSet(this, _selectedRowsCount, response.selectedRowCount);
|
|
315
|
-
this.emit("row-selection", response.selectedRowCount);
|
|
316
|
-
} else {
|
|
317
|
-
console.warn(`select error`);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
openTreeNode(keyOrIndex) {
|
|
322
|
-
if (this.viewport) {
|
|
323
|
-
const [key, index] = typeof keyOrIndex === "string" ? [keyOrIndex] : [void 0, keyOrIndex];
|
|
324
|
-
this.server?.send({
|
|
325
|
-
index,
|
|
326
|
-
key,
|
|
327
|
-
type: "openTreeNode",
|
|
328
|
-
viewport: this.viewport
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
closeTreeNode(keyOrIndex) {
|
|
333
|
-
if (this.viewport) {
|
|
334
|
-
const [key, index] = typeof keyOrIndex === "string" ? [keyOrIndex] : [void 0, keyOrIndex];
|
|
335
|
-
this.server?.send({
|
|
336
|
-
index,
|
|
337
|
-
key,
|
|
338
|
-
type: "closeTreeNode",
|
|
339
|
-
viewport: this.viewport
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
//TODO is this going to be confusing - the lack of symmetry between set and get columns
|
|
344
|
-
// when there are autoSubscribe columns ?
|
|
345
|
-
// alternative would be an allColumns prop, but every datasource would then have to add it.
|
|
346
|
-
get columns() {
|
|
347
|
-
return __privateGet(this, _allColumns) ?? super.columns;
|
|
348
|
-
}
|
|
349
|
-
set columns(columns) {
|
|
350
|
-
super.columns = columns;
|
|
351
|
-
if (__privateGet(this, _autosubscribeColumns).length) {
|
|
352
|
-
__privateSet(this, _allColumns, combineColumnsWithAutosubscribeColumns(
|
|
353
|
-
columns,
|
|
354
|
-
__privateGet(this, _autosubscribeColumns)
|
|
355
|
-
));
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
get tableSchema() {
|
|
359
|
-
return __privateGet(this, _tableSchema);
|
|
360
|
-
}
|
|
361
|
-
set tableSchema(tableSchema) {
|
|
362
|
-
__privateSet(this, _tableSchema, tableSchema);
|
|
363
|
-
}
|
|
364
|
-
get links() {
|
|
365
|
-
return __privateGet(this, _links);
|
|
366
|
-
}
|
|
367
|
-
get menu() {
|
|
368
|
-
return __privateGet(this, _menu);
|
|
369
|
-
}
|
|
370
|
-
get status() {
|
|
371
|
-
return __privateGet(this, _status);
|
|
372
|
-
}
|
|
373
|
-
get optimize() {
|
|
374
|
-
return __privateGet(this, _optimize);
|
|
375
|
-
}
|
|
376
|
-
set optimize(optimize) {
|
|
377
|
-
if (optimize !== __privateGet(this, _optimize)) {
|
|
378
|
-
__privateSet(this, _optimize, optimize);
|
|
379
|
-
switch (optimize) {
|
|
380
|
-
case "none":
|
|
381
|
-
this.rangeRequest = this.rawRangeRequest;
|
|
382
|
-
break;
|
|
383
|
-
case "debounce":
|
|
384
|
-
this.rangeRequest = this.debounceRangeRequest;
|
|
385
|
-
break;
|
|
386
|
-
case "throttle":
|
|
387
|
-
this.rangeRequest = this.throttleRangeRequest;
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
this.emit("optimize", optimize);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
get selectedRowsCount() {
|
|
394
|
-
return __privateGet(this, _selectedRowsCount);
|
|
395
|
-
}
|
|
396
|
-
get config() {
|
|
397
|
-
return super.config;
|
|
398
|
-
}
|
|
399
|
-
set config(config) {
|
|
400
|
-
const { noChanges, columnsChanged } = isConfigChanged(this.config, config);
|
|
401
|
-
if (!noChanges) {
|
|
402
|
-
super.config = config;
|
|
403
|
-
const { columns, ...dataSourceConfig } = combineFilters(this.config);
|
|
404
|
-
const serverConfig = {
|
|
405
|
-
...dataSourceConfig,
|
|
406
|
-
columns: combineColumnsWithAutosubscribeColumns(
|
|
407
|
-
columns,
|
|
408
|
-
__privateGet(this, _autosubscribeColumns)
|
|
409
|
-
)
|
|
410
|
-
};
|
|
411
|
-
if (columnsChanged && __privateGet(this, _autosubscribeColumns).length) {
|
|
412
|
-
__privateSet(this, _allColumns, combineColumnsWithAutosubscribeColumns(
|
|
413
|
-
columns,
|
|
414
|
-
__privateGet(this, _autosubscribeColumns)
|
|
415
|
-
));
|
|
416
|
-
}
|
|
417
|
-
this.server?.send({
|
|
418
|
-
viewport: this.viewport,
|
|
419
|
-
type: "config",
|
|
420
|
-
config: serverConfig
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
set impendingConfig(config) {
|
|
425
|
-
if (config !== this.config) {
|
|
426
|
-
super.impendingConfig = config;
|
|
427
|
-
this.server?.send({
|
|
428
|
-
viewport: this.viewport,
|
|
429
|
-
type: "config",
|
|
430
|
-
config: combineFilters(this.config)
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
get groupBy() {
|
|
435
|
-
return this._configWithVisualLink.groupBy;
|
|
436
|
-
}
|
|
437
|
-
set groupBy(groupBy) {
|
|
438
|
-
if (itemsOrOrderChanged(this.groupBy, groupBy)) {
|
|
439
|
-
const wasGrouped = this.groupBy.length > 0;
|
|
440
|
-
this.impendingConfig = {
|
|
441
|
-
...this._configWithVisualLink,
|
|
442
|
-
groupBy
|
|
443
|
-
};
|
|
444
|
-
if (!wasGrouped && groupBy.length > 0 && this.viewport) {
|
|
445
|
-
this._clientCallback?.({
|
|
446
|
-
clientViewportId: this.viewport,
|
|
447
|
-
mode: "batch",
|
|
448
|
-
type: "viewport-update",
|
|
449
|
-
size: 0,
|
|
450
|
-
rows: []
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
get range() {
|
|
456
|
-
return super.range;
|
|
457
|
-
}
|
|
458
|
-
set range(range) {
|
|
459
|
-
super.range = range;
|
|
460
|
-
if (__privateGet(this, _sessionDataSource)) {
|
|
461
|
-
__privateGet(this, _sessionDataSource).range = range;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
get title() {
|
|
465
|
-
return super.title || `${this.table.module} ${this.table.table}`;
|
|
466
|
-
}
|
|
467
|
-
set title(title) {
|
|
468
|
-
super.title = title;
|
|
469
|
-
if (this.viewport && title) {
|
|
470
|
-
this.server?.send({
|
|
471
|
-
type: "setTitle",
|
|
472
|
-
title,
|
|
473
|
-
viewport: this.viewport
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
get visualLink() {
|
|
478
|
-
return this._configWithVisualLink.visualLink;
|
|
479
|
-
}
|
|
480
|
-
set visualLink(visualLink) {
|
|
481
|
-
this._configWithVisualLink = {
|
|
482
|
-
...this._configWithVisualLink,
|
|
483
|
-
visualLink
|
|
484
|
-
};
|
|
485
|
-
if (visualLink) {
|
|
486
|
-
const {
|
|
487
|
-
parentClientVpId,
|
|
488
|
-
link: { fromColumn, toColumn }
|
|
489
|
-
} = visualLink;
|
|
490
|
-
if (this.viewport) {
|
|
491
|
-
this.server?.rpcCall({
|
|
492
|
-
childColumnName: fromColumn,
|
|
493
|
-
childVpId: this.viewport,
|
|
494
|
-
parentColumnName: toColumn,
|
|
495
|
-
parentVpId: parentClientVpId,
|
|
496
|
-
type: "CREATE_VISUAL_LINK"
|
|
497
|
-
}).then((response) => {
|
|
498
|
-
this.emit("visual-link-created", response);
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
} else {
|
|
502
|
-
if (this.viewport) {
|
|
503
|
-
this.server?.rpcCall({
|
|
504
|
-
type: "REMOVE_VISUAL_LINK",
|
|
505
|
-
childVpId: this.viewport
|
|
506
|
-
}).then(() => {
|
|
507
|
-
this.emit("visual-link-removed");
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
this.emit("config", this._configWithVisualLink, this.range);
|
|
512
|
-
}
|
|
513
|
-
async remoteProcedureCall() {
|
|
514
|
-
return Promise.reject();
|
|
515
|
-
}
|
|
516
|
-
createSessionDataSource(sessionTable) {
|
|
517
|
-
const columns = __privateGet(this, _sessionTableMessageColumn) ? this.columns.concat(__privateGet(this, _sessionTableMessageColumn)) : this.columns;
|
|
518
|
-
return new _VuuDataSource({
|
|
519
|
-
columns,
|
|
520
|
-
table: sessionTable
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
async beginEditSession(editSessionMode = "all-rows") {
|
|
524
|
-
const rpcResponse = await this?.rpcRequest?.({
|
|
525
|
-
type: "RPC_REQUEST",
|
|
526
|
-
rpcName: "beginEditSession",
|
|
527
|
-
params: {
|
|
528
|
-
editSessionMode
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
if (isRpcSuccess(rpcResponse)) {
|
|
532
|
-
const { table: sessionTable } = rpcResponse.data;
|
|
533
|
-
if (isInlineEditingSession(editSessionMode)) {
|
|
534
|
-
const columns = __privateGet(this, _sessionTableMessageColumn) ? this.columns.concat(__privateGet(this, _sessionTableMessageColumn)) : this.columns;
|
|
535
|
-
__privateSet(this, _sessionDataSource, new _VuuDataSource({
|
|
536
|
-
...this.config,
|
|
537
|
-
columns,
|
|
538
|
-
table: sessionTable,
|
|
539
|
-
viewport: sessionTable.table
|
|
540
|
-
}));
|
|
541
|
-
__privateGet(this, _sessionDataSource).subscribe(
|
|
542
|
-
{
|
|
543
|
-
range: this.range
|
|
544
|
-
},
|
|
545
|
-
this.handleSessionMessageFromServer
|
|
546
|
-
);
|
|
547
|
-
} else {
|
|
548
|
-
return new _VuuDataSource({
|
|
549
|
-
...this.config,
|
|
550
|
-
table: sessionTable,
|
|
551
|
-
viewport: sessionTable.table
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
} else {
|
|
555
|
-
throw Error(
|
|
556
|
-
`[VuuDataSource] beginEditSession ${rpcResponse.errorMessage}`
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
async editCell(key, column, data) {
|
|
561
|
-
const rpcHost = __privateGet(this, _sessionDataSource) ?? this;
|
|
562
|
-
return rpcHost.rpcRequest?.({
|
|
563
|
-
type: "RPC_REQUEST",
|
|
564
|
-
rpcName: "editCell",
|
|
565
|
-
params: {
|
|
566
|
-
column,
|
|
567
|
-
data,
|
|
568
|
-
key
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
async endEditSession(saveChanges = false, force = false) {
|
|
573
|
-
const type = "RPC_REQUEST";
|
|
574
|
-
const rpcName = "endEditSession";
|
|
575
|
-
const sessionDataSource = __privateGet(this, _sessionDataSource);
|
|
576
|
-
const rpcHost = sessionDataSource ?? this;
|
|
577
|
-
if (sessionDataSource) {
|
|
578
|
-
__privateSet(this, _sessionDataSource, void 0);
|
|
579
|
-
}
|
|
580
|
-
const rpcResponse = await rpcHost.rpcRequest?.(
|
|
581
|
-
saveChanges ? { type, rpcName, params: { save: true, force } } : { type, rpcName, params: {} }
|
|
582
|
-
);
|
|
583
|
-
if (isRpcSuccess(rpcResponse)) {
|
|
584
|
-
if (sessionDataSource) {
|
|
585
|
-
sessionDataSource?.unsubscribe();
|
|
586
|
-
}
|
|
587
|
-
} else {
|
|
588
|
-
if (rpcResponse?.errorMessage === "stale update") {
|
|
589
|
-
__privateSet(this, _sessionDataSource, sessionDataSource);
|
|
590
|
-
throw new StaleUpdateError(rpcResponse.errorMessage);
|
|
591
|
-
} else {
|
|
592
|
-
throw Error("unknown error");
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
this.sendResumeMessage();
|
|
596
|
-
}
|
|
597
|
-
async rpcRequest(rpcRequest) {
|
|
598
|
-
if (this.viewport && this.server) {
|
|
599
|
-
return this.server?.rpcCall({
|
|
600
|
-
...rpcRequest,
|
|
601
|
-
context: { type: "VIEWPORT_CONTEXT", viewPortId: this.viewport }
|
|
602
|
-
});
|
|
603
|
-
} else {
|
|
604
|
-
throw Error(`rpcCall server or viewport are undefined`);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
async menuRpcCall(rpcRequest) {
|
|
608
|
-
if (this.viewport) {
|
|
609
|
-
return this.server?.rpcCall({
|
|
610
|
-
...rpcRequest,
|
|
611
|
-
vpId: this.viewport
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
insertRow() {
|
|
616
|
-
return Promise.resolve("not supported");
|
|
617
|
-
}
|
|
618
|
-
deleteRow() {
|
|
619
|
-
return Promise.resolve("not supported");
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
_allColumns = new WeakMap();
|
|
623
|
-
_autosubscribeColumns = new WeakMap();
|
|
624
|
-
_pendingVisualLink = new WeakMap();
|
|
625
|
-
_links = new WeakMap();
|
|
626
|
-
_menu = new WeakMap();
|
|
627
|
-
_optimize = new WeakMap();
|
|
628
|
-
_selectedRowsCount = new WeakMap();
|
|
629
|
-
_sessionDataSource = new WeakMap();
|
|
630
|
-
_sessionTableMessageColumn = new WeakMap();
|
|
631
|
-
_status = new WeakMap();
|
|
632
|
-
_tableSchema = new WeakMap();
|
|
633
|
-
let VuuDataSource = _VuuDataSource;
|
|
634
|
-
|
|
635
|
-
export { VuuDataSource };
|
|
636
|
-
//# sourceMappingURL=VuuDataSource.js.map
|