@vuu-ui/vuu-data-remote 3.3.4 → 3.3.6
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 +7 -7
- package/src/VuuDataSource.js +26 -34
- package/types/VuuDataSource.d.ts +4 -3
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.3.
|
|
2
|
+
"version": "3.3.6",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-data-types": "3.3.
|
|
15
|
-
"@vuu-ui/vuu-table-types": "3.3.
|
|
16
|
-
"@vuu-ui/vuu-filter-types": "3.3.
|
|
17
|
-
"@vuu-ui/vuu-protocol-types": "3.3.
|
|
14
|
+
"@vuu-ui/vuu-data-types": "3.3.6",
|
|
15
|
+
"@vuu-ui/vuu-table-types": "3.3.6",
|
|
16
|
+
"@vuu-ui/vuu-filter-types": "3.3.6",
|
|
17
|
+
"@vuu-ui/vuu-protocol-types": "3.3.6"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@vuu-ui/vuu-filter-parser": "3.3.
|
|
21
|
-
"@vuu-ui/vuu-utils": "3.3.
|
|
20
|
+
"@vuu-ui/vuu-filter-parser": "3.3.6",
|
|
21
|
+
"@vuu-ui/vuu-utils": "3.3.6"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"README.md",
|
package/src/VuuDataSource.js
CHANGED
|
@@ -26,8 +26,8 @@ class VuuDataSource extends BaseDataSource {
|
|
|
26
26
|
#optimize = "throttle";
|
|
27
27
|
#selectedRowsCount = 0;
|
|
28
28
|
#session;
|
|
29
|
-
#sessionDataSource = void 0;
|
|
30
29
|
#sessionTableMessageColumn = void 0;
|
|
30
|
+
#sourceTableDataSource;
|
|
31
31
|
#status = "initialising";
|
|
32
32
|
#tableSchema;
|
|
33
33
|
isRemote = true;
|
|
@@ -92,12 +92,6 @@ class VuuDataSource extends BaseDataSource {
|
|
|
92
92
|
this.size = message.size;
|
|
93
93
|
this.emit("resize", message.size, this.#maxRangeEnd);
|
|
94
94
|
}
|
|
95
|
-
if (Array.isArray(message.rows) && message.rows.length > 0 && this.#sessionDataSource) {
|
|
96
|
-
this.emit("remote-update-during-local-edit", message.rows);
|
|
97
|
-
console.log(`updates incoming whilst edit in progress ${this.viewport}`);
|
|
98
|
-
console.table(message.rows);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
95
|
} else if ("viewport-clear" === message.type) {
|
|
102
96
|
this.size = 0;
|
|
103
97
|
this.emit("resize", 0);
|
|
@@ -158,6 +152,9 @@ class VuuDataSource extends BaseDataSource {
|
|
|
158
152
|
viewport: this.viewport
|
|
159
153
|
});
|
|
160
154
|
}
|
|
155
|
+
isSessionDataSourceOf(dataSource) {
|
|
156
|
+
return this.#sourceTableDataSource === dataSource;
|
|
157
|
+
}
|
|
161
158
|
resume(callback) {
|
|
162
159
|
const isDisabled = this.#status.startsWith("disabl");
|
|
163
160
|
const isSuspended = "suspended" === this.#status;
|
|
@@ -380,7 +377,6 @@ class VuuDataSource extends BaseDataSource {
|
|
|
380
377
|
}
|
|
381
378
|
set range(range) {
|
|
382
379
|
super.range = range;
|
|
383
|
-
if (this.#sessionDataSource) this.#sessionDataSource.range = range;
|
|
384
380
|
}
|
|
385
381
|
get title() {
|
|
386
382
|
return super.title || `${this.table.module} ${this.table.table}`;
|
|
@@ -436,39 +432,40 @@ class VuuDataSource extends BaseDataSource {
|
|
|
436
432
|
const { table: sessionTable } = rpcResponse.data;
|
|
437
433
|
const effectiveOverrides = overrides ?? this.#session;
|
|
438
434
|
assertExpectedSessionTable(sessionTable, effectiveOverrides?.table);
|
|
439
|
-
|
|
435
|
+
const sessionDataSource = new VuuDataSource({
|
|
440
436
|
...sessionDataSourceConfig(this.config, effectiveOverrides?.columns),
|
|
441
437
|
table: sessionTable,
|
|
442
438
|
viewport: sessionTable.table
|
|
443
439
|
});
|
|
440
|
+
sessionDataSource.#sourceTableDataSource = this;
|
|
441
|
+
return sessionDataSource;
|
|
444
442
|
}
|
|
445
443
|
throw Error(`[VuuDataSource] createSessionDataSource ${rpcResponse?.errorMessage}`);
|
|
446
444
|
}
|
|
447
|
-
async beginEditSession(
|
|
445
|
+
async beginEditSession() {
|
|
448
446
|
const rpcResponse = await this?.rpcRequest?.({
|
|
449
447
|
type: "RPC_REQUEST",
|
|
450
448
|
rpcName: "beginEditSession",
|
|
451
449
|
params: {
|
|
452
|
-
editSessionMode
|
|
450
|
+
editSessionMode: 'all-rows'
|
|
453
451
|
}
|
|
454
452
|
});
|
|
455
453
|
if (isRpcSuccess(rpcResponse)) {
|
|
456
454
|
const { table: sessionTable } = rpcResponse.data;
|
|
457
455
|
const columns = this.#sessionTableMessageColumn ? this.columns.concat(this.#sessionTableMessageColumn) : this.columns;
|
|
458
|
-
|
|
456
|
+
const sessionDataSource = new VuuDataSource({
|
|
459
457
|
...this.config,
|
|
460
458
|
columns,
|
|
461
459
|
table: sessionTable,
|
|
462
460
|
viewport: sessionTable.table
|
|
463
461
|
});
|
|
464
|
-
this
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
462
|
+
sessionDataSource.#sourceTableDataSource = this;
|
|
463
|
+
return sessionDataSource;
|
|
464
|
+
}
|
|
465
|
+
throw Error(`[VuuDataSource] beginEditSession ${rpcResponse.errorMessage}`);
|
|
468
466
|
}
|
|
469
467
|
async editCell(key, column, data) {
|
|
470
|
-
|
|
471
|
-
return rpcHost.rpcRequest?.({
|
|
468
|
+
return this.rpcRequest?.({
|
|
472
469
|
type: "RPC_REQUEST",
|
|
473
470
|
rpcName: "editCell",
|
|
474
471
|
params: {
|
|
@@ -481,10 +478,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
481
478
|
async endEditSession(saveChanges = false, force = false) {
|
|
482
479
|
const type = "RPC_REQUEST";
|
|
483
480
|
const rpcName = "endEditSession";
|
|
484
|
-
const
|
|
485
|
-
const rpcHost = sessionDataSource ?? this;
|
|
486
|
-
if (sessionDataSource) this.#sessionDataSource = void 0;
|
|
487
|
-
const rpcResponse = await rpcHost.rpcRequest?.(saveChanges ? {
|
|
481
|
+
const rpcResponse = await this.rpcRequest(saveChanges ? {
|
|
488
482
|
type,
|
|
489
483
|
rpcName,
|
|
490
484
|
params: {
|
|
@@ -497,12 +491,13 @@ class VuuDataSource extends BaseDataSource {
|
|
|
497
491
|
params: {}
|
|
498
492
|
});
|
|
499
493
|
if (isRpcSuccess(rpcResponse)) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
494
|
+
const sourceTableDataSource = this.#sourceTableDataSource;
|
|
495
|
+
if (sourceTableDataSource) {
|
|
496
|
+
this.#sourceTableDataSource = void 0;
|
|
497
|
+
this.unsubscribe();
|
|
498
|
+
} else this.sendResumeMessage();
|
|
499
|
+
} else if (rpcResponse?.errorMessage === "stale update") throw new StaleUpdateError(rpcResponse.errorMessage);
|
|
500
|
+
else throw Error(rpcResponse?.errorMessage ?? "endEditSession failed");
|
|
506
501
|
}
|
|
507
502
|
async rpcRequest(rpcRequest) {
|
|
508
503
|
if (this.viewport && this.server) return this.server?.rpcCall({
|
|
@@ -524,8 +519,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
524
519
|
return Promise.resolve("not supported");
|
|
525
520
|
}
|
|
526
521
|
async deleteRow(key, mode = "hard") {
|
|
527
|
-
const
|
|
528
|
-
const response = await rpcHost.rpcRequest?.({
|
|
522
|
+
const response = await this.rpcRequest?.({
|
|
529
523
|
type: "RPC_REQUEST",
|
|
530
524
|
rpcName: "deleteRow",
|
|
531
525
|
params: {
|
|
@@ -537,8 +531,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
537
531
|
return response?.errorMessage ?? "deleteRow failed";
|
|
538
532
|
}
|
|
539
533
|
async deleteSelectedRows(mode = "soft") {
|
|
540
|
-
const
|
|
541
|
-
const response = await rpcHost.rpcRequest?.({
|
|
534
|
+
const response = await this.rpcRequest?.({
|
|
542
535
|
type: "RPC_REQUEST",
|
|
543
536
|
rpcName: "deleteSelectedRows",
|
|
544
537
|
params: {
|
|
@@ -562,8 +555,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
562
555
|
return response?.errorMessage ?? "addRow failed";
|
|
563
556
|
}
|
|
564
557
|
async undoRowChange(key) {
|
|
565
|
-
const
|
|
566
|
-
const response = await rpcHost.rpcRequest?.({
|
|
558
|
+
const response = await this.rpcRequest?.({
|
|
567
559
|
type: "RPC_REQUEST",
|
|
568
560
|
rpcName: "undoRowChange",
|
|
569
561
|
params: {
|
package/types/VuuDataSource.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CopyOption, DataSourceBase, SessionType, DataSourceCallbackMessage, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, DeleteRowMode,
|
|
1
|
+
import type { CopyOption, DataSource, DataSourceBase, SessionType, DataSourceCallbackMessage, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, DeleteRowMode, OptimizeStrategy, SessionDataSourceOverrides, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
|
|
2
2
|
import type { MenuRpcResponse } from "@vuu-ui/vuu-data-types";
|
|
3
3
|
import type { LinkDescriptorWithLabel, RpcResultError, RpcResultSuccess, SelectRequest, VuuGroupBy, VuuMenu, VuuRange, VuuRowDataItemType, VuuRpcMenuRequest, VuuRpcResponse, VuuRpcServiceRequest, VuuTable } from "@vuu-ui/vuu-protocol-types";
|
|
4
4
|
import { BaseDataSource, Range } from "@vuu-ui/vuu-utils";
|
|
@@ -23,6 +23,7 @@ export declare class VuuDataSource extends BaseDataSource implements DataSourceB
|
|
|
23
23
|
* some updates.
|
|
24
24
|
*/
|
|
25
25
|
private sendResumeMessage;
|
|
26
|
+
isSessionDataSourceOf(dataSource: DataSource): boolean;
|
|
26
27
|
resume(callback?: DataSourceSubscribeCallback): void;
|
|
27
28
|
freeze(): void;
|
|
28
29
|
unfreeze(): void;
|
|
@@ -59,8 +60,8 @@ export declare class VuuDataSource extends BaseDataSource implements DataSourceB
|
|
|
59
60
|
set visualLink(visualLink: LinkDescriptorWithLabel | undefined);
|
|
60
61
|
remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
|
|
61
62
|
createSessionDataSource(copyOption: CopyOption, sessionType?: SessionType, overrides?: SessionDataSourceOverrides): Promise<VuuDataSource | undefined>;
|
|
62
|
-
beginEditSession(
|
|
63
|
-
editCell(key: string, column: string, data: VuuRowDataItemType): Promise<RpcResultSuccess | RpcResultError
|
|
63
|
+
beginEditSession(): Promise<VuuDataSource>;
|
|
64
|
+
editCell(key: string, column: string, data: VuuRowDataItemType): Promise<RpcResultSuccess | RpcResultError>;
|
|
64
65
|
endEditSession(saveChanges?: boolean, force?: boolean): Promise<void>;
|
|
65
66
|
rpcRequest(rpcRequest: Omit<VuuRpcServiceRequest, "context">): Promise<RpcResultSuccess | RpcResultError>;
|
|
66
67
|
menuRpcCall(rpcRequest: Omit<VuuRpcMenuRequest, "vpId">): Promise<MenuRpcResponse<any> | undefined>;
|