@vuu-ui/vuu-data-remote 3.3.5 → 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 +24 -33
- 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}`;
|
|
@@ -441,35 +437,35 @@ class VuuDataSource extends BaseDataSource {
|
|
|
441
437
|
table: sessionTable,
|
|
442
438
|
viewport: sessionTable.table
|
|
443
439
|
});
|
|
440
|
+
sessionDataSource.#sourceTableDataSource = this;
|
|
444
441
|
return sessionDataSource;
|
|
445
442
|
}
|
|
446
443
|
throw Error(`[VuuDataSource] createSessionDataSource ${rpcResponse?.errorMessage}`);
|
|
447
444
|
}
|
|
448
|
-
async beginEditSession(
|
|
445
|
+
async beginEditSession() {
|
|
449
446
|
const rpcResponse = await this?.rpcRequest?.({
|
|
450
447
|
type: "RPC_REQUEST",
|
|
451
448
|
rpcName: "beginEditSession",
|
|
452
449
|
params: {
|
|
453
|
-
editSessionMode
|
|
450
|
+
editSessionMode: 'all-rows'
|
|
454
451
|
}
|
|
455
452
|
});
|
|
456
453
|
if (isRpcSuccess(rpcResponse)) {
|
|
457
454
|
const { table: sessionTable } = rpcResponse.data;
|
|
458
455
|
const columns = this.#sessionTableMessageColumn ? this.columns.concat(this.#sessionTableMessageColumn) : this.columns;
|
|
459
|
-
|
|
456
|
+
const sessionDataSource = new VuuDataSource({
|
|
460
457
|
...this.config,
|
|
461
458
|
columns,
|
|
462
459
|
table: sessionTable,
|
|
463
460
|
viewport: sessionTable.table
|
|
464
461
|
});
|
|
465
|
-
this
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
462
|
+
sessionDataSource.#sourceTableDataSource = this;
|
|
463
|
+
return sessionDataSource;
|
|
464
|
+
}
|
|
465
|
+
throw Error(`[VuuDataSource] beginEditSession ${rpcResponse.errorMessage}`);
|
|
469
466
|
}
|
|
470
467
|
async editCell(key, column, data) {
|
|
471
|
-
|
|
472
|
-
return rpcHost.rpcRequest?.({
|
|
468
|
+
return this.rpcRequest?.({
|
|
473
469
|
type: "RPC_REQUEST",
|
|
474
470
|
rpcName: "editCell",
|
|
475
471
|
params: {
|
|
@@ -482,10 +478,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
482
478
|
async endEditSession(saveChanges = false, force = false) {
|
|
483
479
|
const type = "RPC_REQUEST";
|
|
484
480
|
const rpcName = "endEditSession";
|
|
485
|
-
const
|
|
486
|
-
const rpcHost = sessionDataSource ?? this;
|
|
487
|
-
if (sessionDataSource) this.#sessionDataSource = void 0;
|
|
488
|
-
const rpcResponse = await rpcHost.rpcRequest?.(saveChanges ? {
|
|
481
|
+
const rpcResponse = await this.rpcRequest(saveChanges ? {
|
|
489
482
|
type,
|
|
490
483
|
rpcName,
|
|
491
484
|
params: {
|
|
@@ -498,12 +491,13 @@ class VuuDataSource extends BaseDataSource {
|
|
|
498
491
|
params: {}
|
|
499
492
|
});
|
|
500
493
|
if (isRpcSuccess(rpcResponse)) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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");
|
|
507
501
|
}
|
|
508
502
|
async rpcRequest(rpcRequest) {
|
|
509
503
|
if (this.viewport && this.server) return this.server?.rpcCall({
|
|
@@ -525,8 +519,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
525
519
|
return Promise.resolve("not supported");
|
|
526
520
|
}
|
|
527
521
|
async deleteRow(key, mode = "hard") {
|
|
528
|
-
const
|
|
529
|
-
const response = await rpcHost.rpcRequest?.({
|
|
522
|
+
const response = await this.rpcRequest?.({
|
|
530
523
|
type: "RPC_REQUEST",
|
|
531
524
|
rpcName: "deleteRow",
|
|
532
525
|
params: {
|
|
@@ -538,8 +531,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
538
531
|
return response?.errorMessage ?? "deleteRow failed";
|
|
539
532
|
}
|
|
540
533
|
async deleteSelectedRows(mode = "soft") {
|
|
541
|
-
const
|
|
542
|
-
const response = await rpcHost.rpcRequest?.({
|
|
534
|
+
const response = await this.rpcRequest?.({
|
|
543
535
|
type: "RPC_REQUEST",
|
|
544
536
|
rpcName: "deleteSelectedRows",
|
|
545
537
|
params: {
|
|
@@ -563,8 +555,7 @@ class VuuDataSource extends BaseDataSource {
|
|
|
563
555
|
return response?.errorMessage ?? "addRow failed";
|
|
564
556
|
}
|
|
565
557
|
async undoRowChange(key) {
|
|
566
|
-
const
|
|
567
|
-
const response = await rpcHost.rpcRequest?.({
|
|
558
|
+
const response = await this.rpcRequest?.({
|
|
568
559
|
type: "RPC_REQUEST",
|
|
569
560
|
rpcName: "undoRowChange",
|
|
570
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>;
|