@vuu-ui/vuu-data-types 0.8.93 → 0.8.95

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.
Files changed (2) hide show
  1. package/index.d.ts +131 -69
  2. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -1,8 +1,16 @@
1
+ import type {
2
+ DataSourceFilter,
3
+ MenuRpcResponse,
4
+ Selection,
5
+ TableSchema,
6
+ } from "@vuu-ui/vuu-data-types";
1
7
  import type { Filter } from "@vuu-ui/vuu-filter-types";
2
8
  import type { MenuActionClosePopup } from "@vuu-ui/vuu-popups";
3
9
  import type {
10
+ LinkDescriptorWithLabel,
4
11
  NoAction,
5
12
  OpenDialogAction,
13
+ TypeAheadMethod,
6
14
  VuuAggregation,
7
15
  VuuColumnDataType,
8
16
  VuuColumns,
@@ -11,10 +19,19 @@ import type {
11
19
  VuuGroupBy,
12
20
  VuuLinkDescriptor,
13
21
  VuuMenu,
22
+ VuuRange,
14
23
  VuuRowDataItemType,
24
+ VuuRpcRequest,
25
+ VuuRpcViewportResponse,
15
26
  VuuSort,
16
27
  VuuTable,
17
28
  VuuRpcRequest,
29
+ VuuRpcServiceRequest,
30
+ VuuRpcMenuRequest,
31
+ VuuRpcViewportRequest,
32
+ VuuCreateVisualLink,
33
+ VuuRemoveVisualLink,
34
+ VuuTableList,
18
35
  } from "@vuu-ui/vuu-protocol-types";
19
36
  import type { DataSourceConfigChanges, IEventEmitter } from "@vuu-ui/vuu-utils";
20
37
  import type {
@@ -26,12 +43,10 @@ import type {
26
43
  import type {
27
44
  VuuTableListRequest,
28
45
  VuuTableMetaRequest,
29
- LinkDescriptorWithLabel,
30
- VuuRpcViewportResponse,
31
- TypeAheadMethod,
32
- VuuRange,
33
46
  } from "@vuu-ui/vuu-protocol-types";
34
47
  import { DataValueTypeDescriptor } from "@vuu-ui/vuu-table-types";
48
+ import { PostMessageToClientCallback } from "@vuu-ui/vuu-data-remote";
49
+ import type { DataSourceConfigChanges, IEventEmitter } from "@vuu-ui/vuu-utils";
35
50
 
36
51
  export declare type DataValueValidationSuccessResult = {
37
52
  ok: true;
@@ -155,9 +170,9 @@ type IsExpanded = boolean;
155
170
  type Depth = number;
156
171
  type ChildCount = number;
157
172
  type RowKey = string;
158
- export type IsSelected = number;
173
+ export declare type IsSelected = number;
159
174
 
160
- export type DataSourceRow = [
175
+ export declare type DataSourceRow = [
161
176
  RowIndex,
162
177
  RenderKey,
163
178
  IsLeaf,
@@ -169,7 +184,7 @@ export type DataSourceRow = [
169
184
  ...VuuRowDataItemType[],
170
185
  ];
171
186
 
172
- export type DataSourceRowObject = {
187
+ export declare type DataSourceRowObject = {
173
188
  index: number;
174
189
  key: string;
175
190
  isGroupRow: boolean;
@@ -177,7 +192,7 @@ export type DataSourceRowObject = {
177
192
  data: VuuDataRowDto;
178
193
  };
179
194
 
180
- export type DataSourceRowPredicate = (row: DataSourceRow) => boolean;
195
+ export declare type DataSourceRowPredicate = (row: DataSourceRow) => boolean;
181
196
 
182
197
  export interface ContextMenuItemBase {
183
198
  className?: string;
@@ -191,7 +206,7 @@ export interface ContextMenuLeafItemDescriptor extends ContextMenuItemBase {
191
206
  options?: unknown;
192
207
  }
193
208
 
194
- export type ContextMenuItemDescriptor =
209
+ export declare type ContextMenuItemDescriptor =
195
210
  | ContextMenuLeafItemDescriptor
196
211
  | ContextMenuGroupItemDescriptor;
197
212
 
@@ -209,10 +224,19 @@ export interface DataSourceAggregateMessage
209
224
  type: "aggregate";
210
225
  }
211
226
 
212
- export type DataUpdateMode = "batch" | "update" | "size-only";
227
+ export declare type DataUpdateMode = "batch" | "update" | "size-only";
213
228
 
229
+ export interface DataSourceClearMessage extends MessageWithClientViewportId {
230
+ type: "viewport-clear";
231
+ }
214
232
  export interface DataSourceDataMessage extends MessageWithClientViewportId {
215
233
  mode: DataUpdateMode;
234
+ /**
235
+ * this is needed by the ArrayDataSource, biut not currently used by VuuDataSource.
236
+ * Suspect it will be valuable in any DtaSOurce and should eventually be made a
237
+ * required field.
238
+ */
239
+ range?: VuuRange;
216
240
  rows?: DataSourceRow[];
217
241
  size?: number;
218
242
  type: "viewport-update";
@@ -296,11 +320,11 @@ export interface DataSourceVisualLinksMessage
296
320
  links: VuuLinkDescriptor[];
297
321
  }
298
322
 
299
- export type VuuFeatureMessage =
323
+ export declare type VuuFeatureMessage =
300
324
  | DataSourceMenusMessage
301
325
  | DataSourceVisualLinksMessage;
302
326
 
303
- export type DataSourceConfigMessage =
327
+ export declare type DataSourceConfigMessage =
304
328
  | DataSourceAggregateMessage
305
329
  | DataSourceColumnsMessage
306
330
  | DataSourceFilterMessage
@@ -311,10 +335,11 @@ export type DataSourceConfigMessage =
311
335
  /**
312
336
  * Messages which are routed back to the DataSource
313
337
  */
314
- export type DataSourceCallbackMessage =
338
+ export declare type DataSourceCallbackMessage =
315
339
  | DataSourceConfigMessage
316
340
  | DataSourceColumnsMessage
317
341
  | DataSourceDataMessage
342
+ | DataSourceClearMessage
318
343
  | DataSourceDebounceRequest
319
344
  | DataSourceDisabledMessage
320
345
  | DataSourceEnabledMessage
@@ -324,12 +349,12 @@ export type DataSourceCallbackMessage =
324
349
  | DataSourceVisualLinkRemovedMessage
325
350
  | DataSourceVisualLinksMessage;
326
351
 
327
- export type ConfigChangeColumnsMessage = {
352
+ export declare type ConfigChangeColumnsMessage = {
328
353
  type: "columns";
329
354
  columns?: ColumnDescriptor[];
330
355
  };
331
356
 
332
- export type ConfigChangeMessage =
357
+ export declare type ConfigChangeMessage =
333
358
  | ConfigChangeColumnsMessage
334
359
  | DataSourceAggregateMessage
335
360
  | DataSourceFilterMessage
@@ -338,7 +363,7 @@ export type ConfigChangeMessage =
338
363
  | DataSourceVisualLinkCreatedMessage
339
364
  | DataSourceVisualLinkRemovedMessage;
340
365
 
341
- export type ConfigChangeHandler = (msg: ConfigChangeMessage) => void;
366
+ export declare type ConfigChangeHandler = (msg: ConfigChangeMessage) => void;
342
367
 
343
368
  /**
344
369
  * MenuBuilder describes a factory function that creates
@@ -347,7 +372,7 @@ export type ConfigChangeHandler = (msg: ConfigChangeMessage) => void;
347
372
  * can be used to determine which Menu Items to include
348
373
  * in the menu. Most often used for ContextMenus.
349
374
  */
350
- export type MenuBuilder<L = string, O = unknown> = (
375
+ export declare type MenuBuilder<L = string, O = unknown> = (
351
376
  location: L,
352
377
  options: O,
353
378
  ) => ContextMenuItemDescriptor[];
@@ -360,7 +385,7 @@ export type MenuBuilder<L = string, O = unknown> = (
360
385
  * It should return true if it handled this MenuItem. This allows multiple Menu-
361
386
  * ActionHandlers to be chained.
362
387
  */
363
- export type MenuActionHandler = (
388
+ export declare type MenuActionHandler = (
364
389
  reason: MenuActionClosePopup,
365
390
  ) => boolean | undefined;
366
391
 
@@ -369,7 +394,7 @@ export interface ContextMenuContextType {
369
394
  menuActionHandler: MenuActionHandler;
370
395
  }
371
396
 
372
- export type SchemaColumn = {
397
+ export declare type SchemaColumn = {
373
398
  name: string;
374
399
  serverDataType: VuuColumnDataType;
375
400
  };
@@ -378,11 +403,11 @@ export type SchemaColumn = {
378
403
  * session will be present for session tables only, in which case the table
379
404
  * name represents the 'archetype' table name.
380
405
  */
381
- export type TableSchemaTable = VuuTable & {
406
+ export declare type TableSchemaTable = VuuTable & {
382
407
  session?: string;
383
408
  };
384
409
 
385
- export type TableSchema = {
410
+ export declare type TableSchema = {
386
411
  columns: SchemaColumn[];
387
412
  key: string;
388
413
  table: TableSchemaTable;
@@ -395,6 +420,7 @@ export type TableSchema = {
395
420
  export interface WithFullConfig {
396
421
  readonly aggregations: VuuAggregation[];
397
422
  readonly columns: VuuColumns;
423
+ readonly baseFilterSpec: DataSourceFilter;
398
424
  readonly filterSpec: DataSourceFilter;
399
425
  readonly groupBy: VuuGroupBy;
400
426
  readonly sort: VuuSort;
@@ -427,22 +453,25 @@ export interface SubscribeProps extends Partial<WithFullConfig> {
427
453
  title?: string;
428
454
  }
429
455
 
430
- export type SubscribeCallback = (message: DataSourceCallbackMessage) => void;
431
- export type OptimizeStrategy = "none" | "throttle" | "debounce";
456
+ export declare type SubscribeCallback = (
457
+ message: DataSourceCallbackMessage,
458
+ ) => void;
459
+ export declare type OptimizeStrategy = "none" | "throttle" | "debounce";
432
460
 
433
- export type DataSourceEventHandler = (viewportId: string) => void;
434
- export type RowSelectionEventHandler = (
461
+ export declare type DataSourceEventHandler = (viewportId: string) => void;
462
+ export declare type RowSelectionEventHandler = (
435
463
  selection: Selection,
436
464
  selectedRowCount: number,
437
465
  ) => void;
438
466
 
439
- export type DataSourceEvents = {
467
+ export declare type DataSourceEvents = {
440
468
  config: (
441
469
  config: DataSourceConfig | undefined,
442
470
  confirmed?: boolean,
443
471
  configChanges?: DataSourceConfigChanges,
444
472
  ) => void;
445
473
  optimize: (optimize: OptimizeStrategy) => void;
474
+ "page-count": (pageCount: number) => void;
446
475
  range: (range: VuuRange) => void;
447
476
  resize: (size: number) => void;
448
477
  "row-selection": RowSelectionEventHandler;
@@ -461,31 +490,33 @@ export type DataSourceEvents = {
461
490
  * return Promise<true> indicates success
462
491
  * return Promise<errorMessage> indicates failure
463
492
  */
464
- export type DataSourceEditHandler = (
493
+ export declare type DataSourceEditHandler = (
465
494
  rowKey: string,
466
495
  columnName: string,
467
496
  value: VuuRowDataItemType,
468
497
  ) => Promise<true | string>;
469
498
 
470
- export type DataSourceDeleteHandler = (key: string) => Promise<true | string>;
471
- export type DataSourceInsertHandler = (
499
+ export declare type DataSourceDeleteHandler = (
500
+ key: string,
501
+ ) => Promise<true | string>;
502
+ export declare type DataSourceInsertHandler = (
472
503
  key: string,
473
504
  data: VuuDataRowDto,
474
505
  ) => Promise<true | string>;
475
506
 
476
- export type RpcResponse =
507
+ export declare type RpcResponse =
477
508
  | MenuRpcResponse
478
509
  | VuuUIMessageInRPCEditReject
479
510
  | VuuUIMessageInRPCEditResponse
480
511
  | ViewportRpcResponse;
481
512
 
482
- export type RpcResponseHandler = (
513
+ export declare type RpcResponseHandler = (
483
514
  response: Omit<VuuRpcResponse, "vpId">,
484
515
  ) => boolean;
485
516
 
486
- export type RowSearchPredicate = (row: DataSourceRow) => boolean;
517
+ export declare type RowSearchPredicate = (row: DataSourceRow) => boolean;
487
518
 
488
- export type DataSourceStatus =
519
+ export declare type DataSourceStatus =
489
520
  | "disabled"
490
521
  | "disabling"
491
522
  | "enabled"
@@ -496,7 +527,14 @@ export type DataSourceStatus =
496
527
  | "suspended"
497
528
  | "unsubscribed";
498
529
 
499
- export type SuggestionFetcher = (params: TypeaheadParams) => Promise<string[]>;
530
+ /**
531
+ * Given a Vuu Table and column, returns a list of sorted distinct values
532
+ * for that column. Only first 10 values will ever be returned. User must
533
+ * type additional text to narrow down values.
534
+ */
535
+ export declare type SuggestionFetcher = (
536
+ params: TypeaheadParams,
537
+ ) => Promise<string[] | false>;
500
538
  export type SuggestionProvider = () => SuggestionFetcher;
501
539
 
502
540
  export interface TypeaheadSuggestionProvider {
@@ -506,10 +544,12 @@ export interface TypeaheadSuggestionProvider {
506
544
  ) => Promise<string[]>;
507
545
  }
508
546
 
509
- export type RangeTuple = [from: number, to: number];
510
- export type SelectionItem = number | RangeTuple;
511
- export type Selection = SelectionItem[];
512
- export type SelectionChangeHandler = (selection: Selection) => void;
547
+ export declare type RangeTuple = [from: number, to: number];
548
+ export declare type SelectionItem = number | RangeTuple;
549
+ export declare type Selection = SelectionItem[];
550
+ export declare type SelectionChangeHandler = (selection: Selection) => void;
551
+
552
+ export declare type WithBaseFilter<T> = T & { baseFilter?: DataSourceFilter };
513
553
 
514
554
  export interface DataSource
515
555
  extends IEventEmitter<DataSourceEvents>,
@@ -525,7 +565,7 @@ export interface DataSource
525
565
  * @returns true if config has been applied (will not be if existig config is same)
526
566
  */
527
567
  applyConfig: (
528
- config: DataSourceConfig,
568
+ config: WithBaseFilter<DataSourceConfig>,
529
569
  /**
530
570
  * If new config is missing attributes and these attributes are present on
531
571
  * existing config, shoule the existing attributes be preserved ?
@@ -534,7 +574,7 @@ export interface DataSource
534
574
  ) => DataSourceConfigChanges | undefined;
535
575
  closeTreeNode: (key: string, cascade?: boolean) => void;
536
576
  columns: string[];
537
- config: DataSourceConfig;
577
+ config: WithBaseFilter<DataSourceConfig>;
538
578
  status: DataSourceStatus;
539
579
  /**
540
580
  *
@@ -548,7 +588,7 @@ export interface DataSource
548
588
  * If an suspend is requested and not resumed within 3 seconds, it will automatically be promoted to a disable.,
549
589
  */
550
590
  suspend?: () => void;
551
- resume?: () => void;
591
+ resume?: (callback?: SubscribeCallback) => void;
552
592
 
553
593
  deleteRow?: DataSourceDeleteHandler;
554
594
  /**
@@ -573,6 +613,7 @@ export interface DataSource
573
613
  * Should emit a disabled event
574
614
  */
575
615
  disable?: () => void;
616
+ baseFilter?: DataSourceFilter;
576
617
  filter: DataSourceFilter;
577
618
 
578
619
  /**
@@ -648,21 +689,6 @@ export declare type MenuRpcAction =
648
689
  | NoAction
649
690
  | ShowToastAction;
650
691
 
651
- export type ConnectionStatus =
652
- | "connecting"
653
- | "connection-open-awaiting-session"
654
- | "connected"
655
- | "disconnected"
656
- | "failed"
657
- | "reconnected";
658
-
659
- export interface ConnectionStatusMessage {
660
- type: "connection-status";
661
- reason?: string;
662
- retry?: boolean;
663
- status: ConnectionStatus;
664
- }
665
-
666
692
  export interface ConnectionQualityMetrics {
667
693
  type: "connection-metrics";
668
694
  messagesLength: number;
@@ -677,20 +703,20 @@ export interface ServerProxySubscribeMessage extends WithFullConfig {
677
703
  visualLink?: LinkDescriptorWithLabel;
678
704
  }
679
705
 
680
- // export type VuuUIMessageInConnectionStatus = {
706
+ // export declare type VuuUIMessageInConnectionStatus = {
681
707
  // type: 'connection-status';
682
708
  // };
683
709
 
684
- export type VuuUIMessageInConnected = {
710
+ export declare type VuuUIMessageInConnected = {
685
711
  type: "connected";
686
712
  };
687
713
 
688
- export type VuuUIMessageInConnectionFailed = {
714
+ export declare type VuuUIMessageInConnectionFailed = {
689
715
  type: "connection-failed";
690
716
  reason: string;
691
717
  };
692
718
 
693
- export type VuuUIMessageInWorkerReady = {
719
+ export declare type VuuUIMessageInWorkerReady = {
694
720
  type: "ready";
695
721
  };
696
722
 
@@ -753,7 +779,7 @@ export interface VuuUIMessageInMenuRej {
753
779
  type: "VIEW_PORT_MENU_REJ";
754
780
  }
755
781
 
756
- export type VuuUiMessageInRequestResponse =
782
+ export declare type VuuUiMessageInRequestResponse =
757
783
  | VuuUIMessageInMenuRej
758
784
  | MenuRpcResponse
759
785
  | MenuRpcReject
@@ -764,16 +790,16 @@ export type VuuUiMessageInRequestResponse =
764
790
  | VuuUIMessageInTableList
765
791
  | VuuUIMessageInTableMeta;
766
792
 
767
- export type VuuUIMessageIn =
793
+ export declare type VuuUIMessageIn =
768
794
  | VuuUiMessageInRequestResponse
769
795
  | VuuUIMessageInConnected
770
796
  | VuuUIMessageInConnectionFailed
771
797
  | VuuUIMessageInWorkerReady;
772
798
 
773
- export type WebSocketProtocol = string | string[] | undefined;
799
+ export declare type WebSocketProtocol = string | string[] | undefined;
774
800
 
775
801
  export interface VuuUIMessageOutConnect {
776
- protocol: WebSocketProtocol;
802
+ protocol?: WebSocketProtocol;
777
803
  type: "connect";
778
804
  token: string;
779
805
  url: string;
@@ -782,6 +808,10 @@ export interface VuuUIMessageOutConnect {
782
808
  retryLimitStartup?: number;
783
809
  }
784
810
 
811
+ export interface VuuUIMessageOutDisconnect {
812
+ type: "disconnect";
813
+ }
814
+
785
815
  export interface VuuUIMessageOutSubscribe extends ServerProxySubscribeMessage {
786
816
  type: "subscribe";
787
817
  }
@@ -872,7 +902,7 @@ export interface VuuUIMessageOutConfig extends ViewportMessageOut {
872
902
  type: "config";
873
903
  }
874
904
 
875
- export type VuuUIMessageOutViewport =
905
+ export declare type VuuUIMessageOutViewport =
876
906
  | VuuUIMessageOutAggregate
877
907
  | VuuUIMessageOutCloseTreeNode
878
908
  | VuuUIMessageOutColumns
@@ -896,12 +926,44 @@ export interface TypeAheadRpcRequest {
896
926
  type: "RPC_CALL";
897
927
  }
898
928
 
899
- export type WithRequestId<T> = T & { requestId: string };
929
+ export declare type WithRequestId<T> = T & { requestId: string };
900
930
 
901
- export type VuuUIMessageOut =
931
+ export declare type VuuUIMessageOut =
902
932
  | VuuUIMessageOutConnect
933
+ | VuuUIMessageOutDisconnect
903
934
  | VuuUIMessageOutSubscribe
904
935
  | VuuUIMessageOutUnsubscribe
905
936
  | VuuUIMessageOutViewport
906
- | WithRequestId<VuuTableListRequest>
907
- | WithRequestId<VuuTableMetaRequest>;
937
+ | WithRequestId<VuuTableListRequest | VuuTableMetaRequest>;
938
+
939
+ export type ConnectOptions = {
940
+ url: string;
941
+ token: string;
942
+ username: string;
943
+ protocol?: WebSocketProtocol;
944
+ /** Max number of reconnect attempts in the event of unsuccessful websocket connection at startup */
945
+ retryLimitStartup?: number;
946
+ /** Max number of reconnect attempts in the event of a disconnected websocket connection */
947
+ retryLimitDisconnect?: number;
948
+ };
949
+
950
+ export interface ServerAPI {
951
+ destroy: (viewportId?: string) => void;
952
+ getTableSchema: (table: VuuTable) => Promise<TableSchema>;
953
+ getTableList: (module?: string) => Promise<VuuTableList>;
954
+ // TODO its not really unknown
955
+ rpcCall: <T = unknown>(
956
+ msg:
957
+ | VuuRpcServiceRequest
958
+ | VuuRpcMenuRequest
959
+ | VuuRpcViewportRequest
960
+ | VuuCreateVisualLink
961
+ | VuuRemoveVisualLink,
962
+ ) => Promise<T>;
963
+ send: (message: VuuUIMessageOut) => void;
964
+ subscribe: (
965
+ message: ServerProxySubscribeMessage,
966
+ callback: PostMessageToClientCallback,
967
+ ) => void;
968
+ unsubscribe: (viewport: string) => void;
969
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@vuu-ui/vuu-data-types",
3
- "version": "0.8.93",
3
+ "version": "0.8.95",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
6
6
  "devDependencies": {
7
- "@vuu-ui/vuu-filter-types": "0.8.93",
8
- "@vuu-ui/vuu-protocol-types": "0.8.93"
7
+ "@vuu-ui/vuu-filter-types": "0.8.95",
8
+ "@vuu-ui/vuu-protocol-types": "0.8.95"
9
9
  },
10
10
  "dependencies": {},
11
11
  "peerDependencies": {},