forked from finos/vuu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
1079 lines (960 loc) · 30.3 KB
/
Copy pathindex.d.ts
File metadata and controls
1079 lines (960 loc) · 30.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import type { Filter } from "@vuu-ui/vuu-filter-types";
import type {
LinkDescriptorWithLabel,
NoAction,
OpenDialogAction,
RpcResultError,
RpcResultSuccess,
VuuAggregation,
VuuColumnDataType,
VuuColumns,
VuuDataRowDto,
VuuFilter,
VuuGroupBy,
VuuLinkDescriptor,
VuuMenu,
VuuRange,
VuuRowDataItemType,
VuuRpcViewportResponse,
VuuSort,
VuuTable,
VuuRpcServiceRequest,
VuuRpcMenuRequest,
VuuRpcViewportRequest,
VuuCreateVisualLink,
VuuRemoveVisualLink,
VuuTableList,
VuuLoginSuccessResponse,
SelectRequest,
SelectResponse,
SelectSuccessWithRowCount,
VuuTableListRequest,
VuuTableMetaRequest,
} from "@vuu-ui/vuu-protocol-types";
import type {
DataSourceConfigChanges,
IEventEmitter,
Range,
} from "@vuu-ui/vuu-utils";
import type {
ColumnDescriptor,
DataValueTypeDescriptor,
} from "@vuu-ui/vuu-table-types";
import type { PostMessageToClientCallback } from "@vuu-ui/vuu-data-remote";
export declare type DataValueValidationSuccessResult = {
ok: true;
};
export declare type DataValueValidationFailResult = {
ok: false;
messages: string[];
};
export declare type DataValueValidationResult =
| DataValueValidationSuccessResult
| DataValueValidationFailResult;
export declare type DataValueValidationChecker = (
value: VuuRowDataItemType | undefined,
phase: EditPhase | "*",
) => DataValueValidationResult;
export declare type EditRuleValidationSuccessResult = {
ok: true;
};
export declare type EditRuleValidationFailResult = {
ok: false;
message: string;
};
export declare type EditRuleValidationResult =
| EditRuleValidationSuccessResult
| EditRuleValidationFailResult;
/**
* EditRuleValidator is a function registered with component registry. It can then
* be referenced in editRules applied to table columns or form fields.
*
* @returns value to indicate whether validation rule passed:
* - true value passes validation
* - false value fails validation
* - string value fails validation, this message described failure
*/
export declare type EditRuleValidator = (
editRule: EditValidationRule,
value?: VuuRowDataItemType,
) => EditRuleValidationResult;
export declare type EditPhase = "commit" | "change";
/**
* Edit validation functions (EditRuleValidator) must be registered with the component registry.
* They can then be referenced by name from EditValidationRule(s)
*/
export interface EditValidationRule {
/**
* when is the rule applied
* - 'commit' - when user commits change, e.g. by pressent ENTER (on an input), or TAB
* - 'change' - for a text input, on every keystroke
* */
phase?: EditPhase;
name: string;
message?: string;
value?: string;
}
export declare type DataValueTypeSimple =
| "string"
| "number"
| "boolean"
| "json"
| DateTimeDataValueTypeSimple
| TimeDataValueTypeSimple
| DecimalValueTypeSimple
| "checkbox";
export declare type DataValueType =
| DataValueTypeSimple
| DataValueTypeDescriptor;
export declare type TimeDataValueTypeSimple = "time";
export declare type DateTimeDataValueTypeSimple = "date/time";
export declare type DecimalValueTypeSimple = "decimal" | "scaleddecimal";
export declare type DateTimeDataValueType =
| DateTimeColumnTypeSimple
| (Omit<DataValueTypeDescriptor, "name"> & {
name: DateTimeColumnTypeSimple;
});
export declare type BulkEdit = "bulk" | false | "read-only";
/**
* Controls whether a data value can be edited for row insertion and/or update.
* A boolean applies the same permission to both operations.
*/
export declare type DataEditable =
| boolean
| {
insert: boolean;
update: boolean;
};
export interface DataValueDescriptor {
editable?: DataEditable;
/**
There are three values for editableBulk.
- false user will not see these values when applying a bulk edit.
- "bulk" user can edit these values when applying a bulk edit.
- "read-only" user will see these values when applying a bulk edit, but not be allowed to edit them.
*/
editableBulk?: BulkEdit;
/** Display label for form fields, table column headings etc. */
label?: string;
/** unique name for this data value */
name: string;
/** The type defined on server for this data value */
serverDataType?: VuuColumnDataType;
/** Type hints for the UI that supplement the serverDataType */
type?: DataValueType;
}
export declare type DateTimeDataValueDescriptor = Omit<
DataValueDescriptor,
"type"
> & {
type: DateTimeDataValueType;
};
export declare type TimeDataValueDescriptor = Omit<
DataValueDescriptor,
"type"
> & {
type: TimeDataValueType;
};
export interface DataSourceFilter extends VuuFilter {
filterStruct?: Filter;
}
export interface NamedDataSourceFilter extends DataSourceFilter {
id?: string;
name?: string;
}
type RowIndex = number;
type RenderKey = number;
type IsLeaf = boolean;
type IsExpanded = boolean;
type Depth = number;
type ChildCount = number;
type RowKey = string;
export declare type IsSelected = number;
type Timestamp = number;
type IsNew = boolean;
export declare type DataSourceRow<
T extends bigint | VuuRowDataItemType = VuuRowDataItemType,
> = [
RowIndex,
RenderKey,
IsLeaf,
IsExpanded,
Depth,
ChildCount,
RowKey,
IsSelected,
Timestamp,
IsNew,
...T[],
];
export declare type DataSourceRowWithBigint = DataSourceRow<
bigint | VuuRowDataItemType
>;
export declare type DataSourceRowObject = {
index: number;
key: string;
isGroupRow: boolean;
isSelected: boolean;
data: VuuDataRowDto;
};
export declare type DataSourceRowPredicate = (row: DataSourceRow) => boolean;
export interface MessageWithClientViewportId {
clientViewportId: string;
}
export interface DataSourceAggregateMessage extends MessageWithClientViewportId {
aggregations: VuuAggregation[];
type: "aggregate";
}
export declare type DataUpdateMode = "batch" | "update" | "size-only";
export interface DataSourceClearMessage extends MessageWithClientViewportId {
type: "viewport-clear";
}
export interface DataSourceDataMessage extends MessageWithClientViewportId {
mode: DataUpdateMode;
/**
* this is needed by the ArrayDataSource, biut not currently used by VuuDataSource.
* Suspect it will be valuable in any DtaSOurce and should eventually be made a
* required field.
*/
range?: VuuRange;
rows?: DataSourceRow[];
size?: number;
type: "viewport-update";
}
export interface DataSourceDataSizeMessage extends MessageWithClientViewportId {
mode: "size-only";
size: number;
type: "viewport-update";
}
export interface DataSourceDisabledMessage extends MessageWithClientViewportId {
type: "disabled";
}
export interface DataSourceEnabledMessage extends MessageWithClientViewportId {
type: "enabled";
}
export interface DataSourceFrozenMessage extends MessageWithClientViewportId {
type: "frozen";
}
export interface DataSourceUnfrozenMessage extends MessageWithClientViewportId {
type: "unfrozen";
}
export interface DataSourceColumnsMessage extends MessageWithClientViewportId {
type: "columns";
columns: VuuColumns;
}
export interface DataSourceFilterMessage extends MessageWithClientViewportId {
type: "filter";
filter: DataSourceFilter;
}
export interface DataSourceGroupByMessage extends MessageWithClientViewportId {
type: "groupBy";
groupBy: VuuGroupBy | undefined;
}
export interface DataSourceSetConfigMessage extends MessageWithClientViewportId {
type: "config";
config: WithFullConfig;
}
export interface DataSourceDebounceRequest extends MessageWithClientViewportId {
type: "debounce-begin";
}
export interface DataSourceMenusMessage extends MessageWithClientViewportId {
type: "vuu-menu";
menu: VuuMenu;
}
export interface DataSourceSortMessage extends MessageWithClientViewportId {
type: "sort";
sort: VuuSort;
}
export interface DataSourceSubscribeFailedMessage extends MessageWithClientViewportId {
type: "subscribe-failed";
msg: string;
}
export interface DataSourceSubscribedMessage extends MessageWithClientViewportId {
aggregations: VuuAggregation[];
columns: VuuColumns;
filterSpec: DataSourceFilter;
groupBy: VuuGroupBy;
range: VuuRange;
sort: VuuSort;
tableSchema: Readonly<TableSchema>;
type: "subscribed";
}
export interface DataSourceVisualLinkCreatedMessage extends MessageWithClientViewportId {
colName: string;
parentViewportId: string;
parentColName: string;
type: "vuu-link-created";
}
export interface DataSourceVisualLinkRemovedMessage extends MessageWithClientViewportId {
type: "vuu-link-removed";
}
export interface DataSourceVisualLinksMessage extends MessageWithClientViewportId {
type: "vuu-links";
links: VuuLinkDescriptor[];
}
export declare type VuuFeatureMessage =
| DataSourceMenusMessage
| DataSourceVisualLinksMessage;
export declare type DataSourceConfigMessage =
| DataSourceAggregateMessage
| DataSourceColumnsMessage
| DataSourceFilterMessage
| DataSourceGroupByMessage
| DataSourceSortMessage
| DataSourceSetConfigMessage;
/**
* Messages which are routed back to the DataSource
*/
export declare type DataSourceCallbackMessage =
| DataSourceConfigMessage
| DataSourceColumnsMessage
| DataSourceDataMessage
| DataSourceClearMessage
| DataSourceDebounceRequest
| DataSourceDisabledMessage
| DataSourceEnabledMessage
| DataSourceFrozenMessage
| DataSourceUnfrozenMessage
| DataSourceMenusMessage
| DataSourceSubscribedMessage
| DataSourceSubscribeFailedMessage
| DataSourceVisualLinkCreatedMessage
| DataSourceVisualLinkRemovedMessage
| DataSourceVisualLinksMessage
| WithRequestId<SelectSuccessWithRowCount>;
export declare type ConfigChangeColumnsMessage = {
type: "columns";
columns?: ColumnDescriptor[];
};
export declare type ConfigChangeMessage =
| ConfigChangeColumnsMessage
| DataSourceAggregateMessage
| DataSourceFilterMessage
| DataSourceGroupByMessage
| DataSourceSortMessage
| DataSourceVisualLinkCreatedMessage
| DataSourceVisualLinkRemovedMessage;
export declare type ConfigChangeHandler = (msg: ConfigChangeMessage) => void;
export declare type SchemaColumn = {
editable?: boolean;
name: string;
serverDataType: VuuColumnDataType;
};
/**
* session will be present for session tables only, in which case the table
* name represents the 'archetype' table name.
*/
export declare type TableSchemaTable = VuuTable & {
session?: string;
};
/**
* Restrictions imposed by server on scrolling operations.
*/
export declare type RangeLimits = {
maxRangeEnd: number;
maxRangeWidth: number;
}
export declare type TableSchema = {
columns: readonly SchemaColumn[];
key: readonly string;
rangeLimits?: RangeLimits;
table: readonly TableSchemaTable;
};
/**
* Described the configuration values that should typically be
* persisted across sessions.
*/
export interface WithFullConfig {
readonly aggregations: VuuAggregation[];
readonly columns: VuuColumns;
readonly filterSpec: DataSourceFilter;
readonly groupBy: VuuGroupBy;
readonly sort: VuuSort;
}
export interface DataSourceConfig extends Partial<WithFullConfig> {
visualLink?: LinkDescriptorWithLabel;
}
export interface WithGroupBy extends DataSourceConfig {
groupBy: VuuGroupBy;
}
export interface WithFilter extends DataSourceConfig {
filterSpec: DataSourceFilter;
}
export interface WithSort extends DataSourceConfig {
sort: VuuSort;
}
export interface DataSourceConstructorProps extends WithBaseFilter<DataSourceConfig> {
/**
* If provided, these column names will always be included in subscription, even
* if not directly requested, via columns property. Useful where columns may not
* be required/wanted in table, but are required for other purposes, e.g to support
* filters on columns not in rendered table.
*/
autosubscribeColumns?: string[];
bufferSize?: number;
/**
* For datasources that support edit sessions, some services support an additional
* column on session tables that will be used to return status information for a row
* after an edit session is saved. Default is no additional column.
*/
sessionTableMessageColumn?: string;
suspenseProps?: DataSourceSuspenseProps;
table: VuuTable;
title?: string;
url?: string;
viewport?: string;
}
export interface RemoteModuleConnection {
connectionId: string;
restUrl?: string;
websocketUrl?: string;
}
export interface DataSourceSubscribeProps extends Partial<
WithBaseFilter<WithFullConfig>
> {
viewport?: string;
range?: Range;
revealSelected?: boolean;
selectedKeyValues?: string[];
title?: string;
}
export declare type DataSourceSubscribeCallback = (
message: DataSourceCallbackMessage,
) => void;
export declare type OptimizeStrategy = "none" | "throttle" | "debounce";
export declare type DataSourceEventHandler = (viewportId: string) => void;
export declare type RowSelectionEventHandler = (
selectedRowCount: number,
) => void;
export declare type DataSourceConfigChangeHandler = (
config: ConfigWithVisualLink,
range: Range,
confirmed?: boolean,
configChanges?: DataSourceConfigChanges,
) => void;
export declare type RemoteUpdateHandler = (rows: DataSourceRow[]) => void;
export declare type DataSourceEvents = {
config: DataSourceConfigChangeHandler;
disabled: DataSourceEventHandler;
enabled: DataSourceEventHandler;
freeze: (isFrozen: boolean, freezeTimeStamp: number) => void;
optimize: (optimize: OptimizeStrategy) => void;
"page-count": (pageCount: number) => void;
range: (range: Range) => void;
resize: (size: number, maxScrollEnd?: number) => void;
resumed: DataSourceEventHandler;
"remote-update-during-local-edit": RemoteUpdateHandler;
"row-selection": RowSelectionEventHandler;
subscribed: (subscription: DataSourceSubscribedMessage) => void;
unsubscribed: DataSourceEventHandler;
suspended: DataSourceEventHandler;
"title-changed": (id: string, title: string) => void;
"visual-link-created": (message: DataSourceVisualLinkCreatedMessage) => void;
"visual-link-removed": () => void;
};
/**
* Controls how a row deletion is applied.
* - `"soft"` - marks the row as pending deletion (e.g. sets `vuuMsg` to `"SOFT_DELETED"`)
* without removing it from the table. The deletion is only committed when the edit
* session ends with `saveChanges = true`.
* - `"hard"` - removes the row from the table immediately and irreversibly.
*/
export declare type DeleteRowMode = "soft" | "hard";
export declare type DataSourceDeleteHandler = (
key: string,
mode?: DeleteRowMode,
) => Promise<true | string>;
export declare type DataSourceInsertHandler = (
key: string,
data: VuuDataRowDto,
) => Promise<true | string>;
export declare type RpcResponse =
| MenuRpcResponse
| VuuUIMessageInRPCEditReject
| VuuUIMessageInRPCEditResponse
| ViewportRpcResponse;
export declare type RpcResponseHandler = (
response: Omit<VuuRpcResponse, "vpId">,
) => boolean;
export declare type RowSearchPredicate = (row: DataSourceRow) => boolean;
export declare type DataSourceStatus =
| "disabled"
| "disabling"
| "enabled"
| "enabling"
| "initialising"
| "subscribing"
| "subscribed"
| "suspended"
| "unsubscribed";
/**
* Given a Vuu Table and column, returns a list of sorted distinct values
* for that column. Only first 10 values will ever be returned. User must
* type additional text to narrow down values.
*/
export declare type SuggestionFetcher = (
params: TypeaheadParams,
) => Promise<string[] | false>;
export declare type SuggestionProvider = () => SuggestionFetcher;
export interface TypeaheadSuggestionProvider {
getTypeaheadSuggestions: (
columnName: string,
pattern?: string,
) => Promise<string[]>;
}
export declare type WithBaseFilter<T> = T & {
baseFilterSpec?: DataSourceFilter;
};
export declare type DataSourceSuspenseProps = {
escalateToDisable: boolean;
escalateDelay?: number;
};
/** Controls which source rows are copied into a newly created session table. */
export declare type CopyOption = "All" | "Empty" | "Selected";
/** Controls the intended purpose of a created session table. */
export declare type SessionType = "edit" | "import" | "export";
/**
* Wire-level values used by the legacy beginEditSession menu/server service.
* Client edit lifecycles use CopyOption with createSessionDataSource instead.
*/
export declare type EditSessionMode =
| "inline-all-rows"
| "selected-rows"
| "all-rows"
| "empty-session-table";
export interface EditApi<
T extends DataSourceRow | DataSourceRowWithBigint = DataSourceRow,
> {
addRow?: (
rowData?: Record<string, VuuRowDataItemType>,
) => Promise<RpcResult> | undefined;
deleteRow?: (
key: string,
mode?: DeleteRowMode,
) => Promise<RpcResult> | undefined;
deleteSelectedRows?: (mode?: DeleteRowMode) => Promise<RpcResult> | undefined;
editCell?: (
rowKey: string,
column: string,
value: VuuRowDataItemType,
) => Promise<RpcResult> | undefined;
undoRowChange?: (key: string) => Promise<RpcResult> | undefined;
/**
* Create a session datasource by requesting the server to create a session table
* via the `createSessionTable` RPC and wrapping the returned table.
*/
createSessionDataSource?: (
copyOption: CopyOption,
sessionType?: SessionType,
) => Promise<DataSource<T> | undefined>;
/**
* Legacy session creation API. Prefer createSessionDataSource for new servers.
*/
beginEditSession?: (
editSessionMode?: EditSessionMode,
) => Promise<DataSource<T> | undefined>;
endEditSession?: (
saveChanges?: boolean,
force?: boolean,
) => Promise<RpcResult> | undefined;
}
/**
* Data payload returned in RpcResultSuccess.data by the beginEditSession service.
* Contains the server-assigned session table reference used to create the session datasource.
*/
export declare type BeginEditSessionResult = {
table: VuuTable;
};
export declare type DeleteSelectedRowsResult = {
deletedKeys: string[];
};
export declare type UndoRowChangeResult = {
wasInsertedRow?: boolean;
};
export interface DataSourceBase<
T extends DataSourceRow | DataSourceRowWithBigint = DataSourceRow,
>
extends
EditApi<T>,
IEventEmitter<DataSourceEvents>,
Partial<TypeaheadSuggestionProvider> {
aggregations: VuuAggregation[];
closeTreeNode: (keyOrIndex: string | number, cascade?: boolean) => void;
columns: string[];
config: WithBaseFilter<WithFullConfig>;
/**
* Applies a time filter to the viewport such that no new records created after the
* freeze are sent to client. This makes client's view stable, even when large numbers
* of new records are being created. The price is that view becomes stale. DataSource
* implementation is not required to support this functionality.
*/
freeze?: () => void;
/**
* Removes the 'freeze' filter. See 'freeze' above.
*/
unfreeze?: () => void;
/**
* see 'freeze' above. true if 'freeze' has previoulsy been called.
*/
isFrozen?: boolean;
/**
* see 'freeze' above. If frozen, the time at which freeze was applied.
*/
freezeTimestamp?: number | undefined;
select?: (selectRequest: Omit<SelectRequest, "vpId">) => void;
status: DataSourceStatus;
/**
*
* Similar to disable but intended for pauses of very short duration (default is 3 seconds). Although
* the dataSource will stop sending messages until resumed, it will not disconnect from a remote server.
* It will preserve subscription to the remote server and continue to apply updates to cached data. It
* just won't send updates through to the UI thread (until resumed). Useful in edge cases such as where a
* component is dragged to a new location. When dropped, the component will be unmounted and very quickly
* remounted by React. For the duration of this operation, we suspend updates . Updating an unmounted
* React component would cause a React error.
* If an suspend is requested and not resumed within 3 seconds, it will automatically be promoted to a disable,
* unless escalateToDisable: false is specified. Further, the default escalation delay of 3 seconds can be
* overridden with escalateDelay, which is a millissecond value.
*/
suspend?: (escalateToDisable?: boolean, escalateDelay?: number) => void;
resume?: (callback?: DataSourceSubscribeCallback) => void;
/**
* Returns true when this datasource is a transient session datasource
* created by the supplied source datasource.
*/
isSessionDataSourceOf?: (dataSource: DataSource) => boolean;
deleteRow?: DataSourceDeleteHandler;
/**
* For a dataSource that has been previously disabled and is currently in disabled state , this will restore
* the subscription to active status. Fresh data will be dispatched to client. The enable call optionally
* accepts the same subscribe callback as subscribe. This allows a completely new instance of a component to
* assume ownership of a subscription and receive all messages.
* Should emit an enabled event
*/
enable?: (callback?: DataSourceSubscribeCallback) => void;
/**
* Disables this subscription. A datasource will send no further messages until re-enabled. Example usage
* might be for a component displayed within a set of Tabs. If user switches to another tab, the dataSource
* of the component that is no longer visible can be disabled until it is made visible again.
* Should emit a disabled event
*/
disable?: () => void;
baseFilter?: DataSourceFilter;
/**
* @deprecated use setFilter instead
*/
filter: DataSourceFilter;
/**
* An alternative way to set the dataSource filter, passing in a Filter
* (or ExtendedFilter) object. The real advantage to using this is the additional set
* of capabilities the ExtendedFilter offers.
* Eventually, this will replace the existing filter setter
*/
clearFilter?: () => void;
setFilter?: (filter: Filter) => void;
/**
* Only implemented on JSON DataSource
* @param depth
* @param visibleOnly
* @returns
*/
getChildRows?: (rowKey: string) => T[];
getRowAtIndex?: (rowIndex: number) => T | undefined;
/**
* Only implemented on JSON DataSource
* @param depth
* @param visibleOnly
* @returns
*/
getRowsAtDepth?: (depth: number, visibleOnly?: boolean) => T[];
groupBy?: VuuGroupBy;
insertRow?: DataSourceInsertHandler;
links?: LinkDescriptorWithLabel[];
maxRangeEnd?: number;
menu?: VuuMenu;
menuRpcCall: (
rpcRequest: Omit<VuuRpcMenuRequest, "vpId">,
) => Promise<VuuRpcMenuResponse>;
rpcRequest?: (
request: Omit<VuuRpcServiceRequest, "context">,
) => Promise<RpcResultSuccess | RpcResultError>;
openTreeNode: (keyOrIndex: string | number) => void;
range: Range;
readonly selectedRowsCount: number;
sendBroadcastMessage?: (message: DataSourceBroadcastMessage) => void;
readonly size: number;
sort: VuuSort;
subscribe: (
props: DataSourceSubscribeProps,
callback: DataSourceSubscribeCallback,
) => Promise<void>;
table?: VuuTable;
readonly tableSchema?: TableSchema;
/**
* We allow a title because a context menu action can reference a target table, e.g. as a Visual Link target.
* Users can edit titles on components. If so, and this is a table component, we will display this title in
* the context menu rather than the underlying table name (which may not be unique within the layout)
*/
title: string;
unsubscribe: () => void;
viewport?: string;
visualLink?: LinkDescriptorWithLabel;
}
export declare type DataSource =
| DataSourceBase
| DataSourceBase<DataSourceRowWithBigint>;
export interface MenuRpcResponse<
TAction extends MenuRpcAction = MenuRpcAction,
> {
action: TAction;
error?: string;
requestId: string;
rpcName: string;
tableAlreadyOpen?: boolean;
type: "VIEW_PORT_MENU_RESP";
}
export interface OpenDialogActionWithSchema extends OpenDialogAction {
tableSchema?: TableSchema;
}
export declare type MenuRpcAction =
| OpenDialogActionWithSchema
| NoAction
| ShowToastAction;
export interface ConnectionQualityMetrics {
type: "connection-metrics";
messagesLength: number;
}
export interface ServerProxySubscribeMessage extends WithFullConfig {
bufferSize?: number;
range: VuuRange;
selectedIndexValues?: Selection;
table: VuuTable;
title?: string;
viewport: string;
visualLink?: LinkDescriptorWithLabel;
}
// export declare type VuuUIMessageInConnectionStatus = {
// type: 'connection-status';
// };
export declare type VuuUIMessageInConnected = {
sessionId: string;
type: "connected";
};
export declare type VuuUIMessageInConnectionFailed = {
type: "connection-failed";
reason: string;
};
export declare type VuuUIMessageInWorkerReady = {
type: "ready";
};
export interface ViewportMessageIn {
clientViewportId: string;
}
// TODO use generic to type result
export interface VuuUIMessageInRPC {
action: unknown;
error?: null | unknown;
result: unknown;
requestId: string;
type: "RPC_RESPONSE";
}
export interface VuuUIMessageInTableList {
requestId: string;
type: "TABLE_LIST_RESP";
tables: VuuTable[];
}
export interface VuuUIMessageInTableMeta {
requestId: string;
tableSchema: TableSchema;
type: "TABLE_META_RESP";
}
export interface ViewportRpcResponse {
action: VuuRpcViewportResponse["action"] & {
// for SessionTable editing, we inject the schema after receiving server message
// and before forwarding to UI
tableSchema?: TableSchema;
};
requestId: string;
rpcName?: string;
type: "VIEW_PORT_RPC_RESPONSE";
}
export interface MenuRpcReject extends ViewportMessageIn {
error?: string;
requestId: string;
rpcName?: string;
type: "VIEW_PORT_MENU_REJ";
}
export interface VuuUIMessageInMenuRej {
error: string;
requestId: string;
rpcName: string;
type: "VIEW_PORT_MENU_REJ";
}
export declare type VuuUiMessageInRequestResponse =
| VuuUIMessageInMenuRej
| MenuRpcResponse
| MenuRpcReject
| VuuUIMessageInRPC
| ViewportRpcResponse
| VuuUIMessageInTableList
| VuuUIMessageInTableMeta;
export declare type VuuUIMessageIn =
| (VuuLoginSuccessResponse & { sessionId: string })
| VuuUiMessageInRequestResponse
| VuuUIMessageInConnected
| VuuUIMessageInConnectionFailed
| VuuUIMessageInWorkerReady;
export declare type WebSocketProtocol = string | string[] | undefined;
export interface VuuUIMessageOutConnect {
protocol?: WebSocketProtocol;
type: "connect";
token: string;
url: string;
retryLimitDisconnect?: number;
retryLimitStartup?: number;
}
export interface VuuUIMessageOutDisconnect {
type: "disconnect";
}
export interface VuuUIMessageOutSubscribe extends ServerProxySubscribeMessage {
type: "subscribe";
}
export interface VuuUIMessageOutUnsubscribe {
type: "unsubscribe";
viewport: string;
}
export interface VuuUIMessageOutDisableAllActive {
type: "disable-all-active";
}
export interface VuuUIMessageOutEnableAllActive {
type: "enable-all-active";
}
export interface VuuUIMessageOutSuspend {
/**
* suspend is purely a client-side mechanism to avoid sending
* updates to ui thread. This is intended to be used whilst a component
* is unmounted to avoid a react error, e.g during a drag drop operation.
* Can be escalated to a disable operation which is serverside.
* Default is true.
*/
escalateToDisable?: boolean;
/**
* If escalteToDelay is enabled, the delay, in ms, before escaltion is invoked.
*/
escalateDelay?: number;
type: "suspend";
viewport: string;
}
export interface ViewportMessageOut {
viewport: string;
}
export interface RequestMessage {
requestId: string;
}
export interface VuuUIMessageOutViewRange extends ViewportMessageOut {
type: "setViewRange";
range: {
from: number;
to: number;
};
}
export interface VuuUIMessageOutCloseTreeNode extends ViewportMessageOut {
index?: number;
key?: string;
type: "closeTreeNode";
}
export interface VuuUIMessageOutRemoveLink extends ViewportMessageOut {
type: "removeLink";
}
export interface VuuUIMessageOutSetTitle extends ViewportMessageOut {
title: string;
type: "setTitle";
}
export interface VuuUIMessageOutFreeze extends ViewportMessageOut {
type: "FREEZE_VP";
}
export interface VuuUIMessageOutUnfreeze extends ViewportMessageOut {
type: "UNFREEZE_VP";
}
export interface VuuUIMessageOutDisable extends ViewportMessageOut {
type: "disable";
}
export interface VuuUIMessageOutEnable extends ViewportMessageOut {
type: "enable";
}
export interface VuuUIMessageOutOpenTreeNode extends ViewportMessageOut {
index?: number;
key?: string;
type: "openTreeNode";