bt-core-app 1.4.34 → 1.4.36

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/dist/index.d.ts CHANGED
@@ -13,11 +13,14 @@ import { Store } from 'pinia';
13
13
  import { StoreDefinition } from 'pinia';
14
14
  import { ThemeInstance } from 'vuetify';
15
15
 
16
+ export declare interface ActionOptions extends PathOptions, DoActionOptions {
17
+ }
18
+
16
19
  /**adds and sorts the weekday string */
17
20
  export declare function addWeekday(weekdays?: string, day?: string): string | undefined;
18
21
 
19
- export declare interface ApiActionOptions extends PathOptions, DoActionOptions {
20
- api: BTApi;
22
+ declare interface ApiActionOptions extends PathOptions, DoActionOptions {
23
+ api?: BTApi;
21
24
  }
22
25
 
23
26
  export declare function appendUrl(originalVal?: string, additionalVal?: string): string;
@@ -75,8 +78,6 @@ export declare type BladeMode = 'new' | 'view' | 'edit';
75
78
  export declare type BladeVariant = 'page' | 'blade' | 'freestyle' | 'inline' | 'pane';
76
79
 
77
80
  export declare interface BTActions {
78
- apiGet: (doOptions: ApiActionOptions) => Promise<any>;
79
- apiPost: (doOptions: ApiActionOptions) => Promise<any>;
80
81
  actionLoadingMsg: ShallowRef<string | undefined>;
81
82
  actionErrorMsg: ShallowRef<string | undefined>;
82
83
  clearErrors: () => void;
@@ -95,27 +96,40 @@ export declare interface BTApi {
95
96
  buildQuery: (params: any) => string;
96
97
  buildUrl: (path: PathOptions) => string;
97
98
  deleteItem: (pathOptions: PathOptions) => Promise<string | undefined>;
98
- get: <T>(pathOptions: PathOptions) => Promise<T>;
99
- getAll: <T>(pathOptions: PathOptions) => Promise<T>;
99
+ get: <T>(pathOptions: PathOptions) => Promise<T | undefined>;
100
+ getAll: <T>(pathOptions: PathOptions) => Promise<T | undefined>;
100
101
  post: <T>(pathOptions: PathOptions) => Promise<T | undefined>;
101
102
  patch: <T>(pathOptions: PathOptions) => Promise<T | undefined>;
102
103
  }
103
104
 
105
+ export declare interface BTApiActions {
106
+ apiGet: (doOptions: ApiActionOptions) => Promise<any>;
107
+ apiPost: (doOptions: ApiActionOptions) => Promise<any>;
108
+ actionLoadingMsg: ShallowRef<string | undefined>;
109
+ actionErrorMsg: ShallowRef<string | undefined>;
110
+ clearErrors: () => void;
111
+ doAction: (action: any, options?: DoActionOptions) => Promise<any>;
112
+ isLoading: ComputedRef<boolean>;
113
+ logError: (err?: string | Error) => void;
114
+ }
115
+
104
116
  export declare interface BTAuth {
105
- authState: string;
117
+ authState: Ref<string>;
118
+ /**Global Admin, everything.edit, *.edit */
106
119
  canEdit: (navName?: string) => boolean;
107
120
  canEditPermit: (permit: string) => boolean;
121
+ /**Global Admin, everything.view, *.view */
108
122
  canView: (navName?: string) => boolean;
109
123
  canViewPermit: (permit: string) => boolean;
110
124
  credentials: RemovableRef<any>;
111
125
  doShow: (subcodes?: string[], permissions?: string[], action?: 'view' | 'edit') => boolean;
112
126
  doShowByNav: (navName?: string | AuthItem, includeChildren?: boolean) => boolean;
113
127
  getAuthorizeUrl: (redirectPath?: string) => string;
114
- getTimeZone: () => string;
115
128
  getToken: (code?: string, state?: string) => Promise<void>;
116
129
  isLoggedIn: ComputedRef<boolean>;
117
130
  login: (redirectPath?: string) => void;
118
131
  logout: (navNameRedirect?: string) => void;
132
+ resetAuthState: () => void;
119
133
  setAuth: (jwtToken?: string) => void;
120
134
  timeZone: ComputedRef<string>;
121
135
  tryLogin: () => boolean | undefined;
@@ -132,8 +146,11 @@ export declare interface BTCosmetics {
132
146
  }
133
147
 
134
148
  export declare interface BTDates {
149
+ /**returns start of day */
135
150
  getToday: () => string;
151
+ /**returns start of tomorrow */
136
152
  getTomorrow: () => string;
153
+ /**returns current datetime in tz format */
137
154
  tzDate: (val?: string, fromFormat?: string) => DateTime;
138
155
  tzString: (val?: string, format?: string, fromFormat?: string) => string;
139
156
  utcDate: (val?: string, fromFormat?: string) => DateTime;
@@ -144,6 +161,12 @@ export declare interface BTDemo {
144
161
  endDemo: () => void;
145
162
  isDemoing: Ref<boolean>;
146
163
  startDemo: () => void;
164
+ data: DemoApiGroup[];
165
+ deleteItem: (pathOptions: PathOptions) => Promise<string | undefined>;
166
+ get: (pathOptions: PathOptions) => Promise<any>;
167
+ getAll: (pathOptions: PathOptions) => Promise<any>;
168
+ post: (pathOptions: PathOptions) => Promise<any>;
169
+ patch: (pathOptions: PathOptions) => Promise<any>;
147
170
  }
148
171
 
149
172
  export declare interface BTDocumentMeta {
@@ -165,7 +188,7 @@ export declare interface BTNavigation {
165
188
  findDisplay: (navName?: string | NavigationItem) => string | undefined;
166
189
  findIcon: (navName?: string | NavigationItem) => string | undefined;
167
190
  findItem: (navName?: string | NavigationItem) => NavigationItem | null;
168
- findStoreName: (navName?: string | NavigationItem) => string;
191
+ findStoreName: (navName?: string | NavigationItem) => string | undefined;
169
192
  findPath: (navName?: string | NavigationItem) => string | undefined;
170
193
  findSingleDisplay: (navName?: string | NavigationItem) => string | undefined;
171
194
  updateNavigationProperties: (navName?: string | NavigationItem) => void;
@@ -278,9 +301,14 @@ export declare function createDates(options: CreateDatesOptions): BTDates;
278
301
 
279
302
  export declare interface CreateDatesOptions {
280
303
  getTimeZone: () => string;
304
+ getUTC?: () => DateTime;
281
305
  }
282
306
 
283
- export declare function createDemo(): BTDemo;
307
+ export declare function createDemo(options?: CreateDemoOptions): BTDemo;
308
+
309
+ declare interface CreateDemoOptions {
310
+ apis?: DemoApiGroup[];
311
+ }
284
312
 
285
313
  export declare function createFilters(options: UseFiltersOptions): BTFilters;
286
314
 
@@ -367,6 +395,16 @@ export declare interface DeleteOptions extends PathOptions, DoActionOptions {
367
395
  store?: BTStoreDefinition;
368
396
  }
369
397
 
398
+ declare interface DemoApiGroup {
399
+ nav?: string | string[];
400
+ path?: string;
401
+ data?: any[];
402
+ getAllAction?: (list: any[], params: any) => any[];
403
+ getAction?: (list: any[], id?: string) => any;
404
+ patchAction?: (list: any[], item: any) => any;
405
+ postAction?: (list: any[], item: any) => any;
406
+ }
407
+
370
408
  export declare function distinct(list: any): any;
371
409
 
372
410
  declare interface DoActionOptions {
@@ -378,6 +416,13 @@ declare interface DoActionOptions {
378
416
  throwError?: boolean;
379
417
  }
380
418
 
419
+ export declare interface ExportToCSVOptions {
420
+ items: any[];
421
+ headers?: TableColumn[];
422
+ fileName?: string;
423
+ format: 'array' | 'file';
424
+ }
425
+
381
426
  export declare function extensionExists(elementId?: string): boolean;
382
427
 
383
428
  export declare interface ExternalNavigation {
@@ -493,33 +538,22 @@ export declare interface ListEvents {
493
538
  export declare interface ListProps {
494
539
  additionalUrl?: string;
495
540
  bladeName?: string;
496
- canAdd?: boolean;
497
- canDelete?: boolean;
498
- canEdit?: boolean;
499
- canRestore?: boolean;
500
- canShowInactive?: boolean;
501
541
  canSelect?: boolean;
502
542
  canUnselect?: boolean;
503
543
  confirmOnDelete?: boolean;
504
544
  customFilters?: CustomFilterParam[];
505
545
  defaultFilters?: string[];
506
- dividers?: boolean;
507
546
  eager?: boolean;
508
547
  errorMsg?: string;
509
548
  headers?: TableColumn[];
510
549
  hideActions?: boolean;
511
- hideColumns?: boolean;
512
- hideFilters?: boolean;
513
- hideRefresh?: boolean;
514
- hideSubtoolbarSettings?: boolean;
515
- includeDetails?: boolean;
516
550
  isSingle?: boolean;
517
551
  itemBladeName?: string;
518
552
  itemID?: string;
519
553
  items?: any[];
554
+ /**only used with server pagination */
520
555
  itemsPerPage?: number;
521
556
  itemText?: string;
522
- lines?: 'one' | 'two' | 'three';
523
557
  loadingMsg?: string;
524
558
  localOnly?: boolean;
525
559
  nav?: string;
@@ -527,10 +561,8 @@ export declare interface ListProps {
527
561
  onCanDelete?: (item: any) => boolean;
528
562
  /**when trying to delete in api */
529
563
  onCanDeleteAsync?: OnCanDoAsync;
530
- onGetSaveAsync?: OnDoSuccessAsync;
531
564
  onCanRestore?: (item: any) => boolean;
532
565
  onCanRestoreAsync?: OnCanDoAsync;
533
- onCanSaveAsync?: OnCanDoAsync;
534
566
  onCanSelectItem?: (item: any) => boolean;
535
567
  onDeleteAsync?: OnDoAsync;
536
568
  onDeleteSuccessAsync?: OnDoAsync;
@@ -539,8 +571,6 @@ export declare interface ListProps {
539
571
  onGetSuccessAsync?: OnGetSuccessAsync;
540
572
  onRestoreAsync?: OnDoSuccessAsync;
541
573
  onRestoreSuccessAsync?: OnDoSuccessAsync;
542
- onSaveAsync?: OnDoSuccessAsync;
543
- onSaveSuccessAsync?: OnDoSuccessAsync;
544
574
  onSelectItem?: (item: any) => void;
545
575
  params?: any;
546
576
  proxyID?: string;
@@ -551,8 +581,6 @@ export declare interface ListProps {
551
581
  selectProps?: string[];
552
582
  sortBy?: string;
553
583
  sortOrder?: 'Ascending' | 'Descending';
554
- showListOnly?: boolean;
555
- showTableOnly?: boolean;
556
584
  showSearch?: boolean;
557
585
  startShowingInactive?: boolean;
558
586
  storeMode?: StoreMode;
@@ -857,6 +885,7 @@ export declare interface TableColumn {
857
885
  csvArray?: boolean;
858
886
  csvFilter?: string;
859
887
  csvText?: string;
888
+ display?: boolean;
860
889
  hide?: boolean;
861
890
  itemText?: string;
862
891
  level?: number;
@@ -903,6 +932,8 @@ export declare interface UseActionsOptions extends DoActionOptions {
903
932
  store?: BTStoreDefinition;
904
933
  throwError?: boolean;
905
934
  url?: string;
935
+ /**for basic functionality when no store is provided */
936
+ items?: any[];
906
937
  }
907
938
 
908
939
  export declare function useActionsTracker(useOptions?: DoActionOptions): {
@@ -917,6 +948,16 @@ export declare function useActionsTracker(useOptions?: DoActionOptions): {
917
948
 
918
949
  export declare function useApi(): BTApi;
919
950
 
951
+ export declare function useApiActions(options: UseApiActionsOptions): BTApiActions;
952
+
953
+ export declare interface UseApiActionsOptions extends DoActionOptions {
954
+ nav?: string;
955
+ proxyID?: string;
956
+ throwError?: boolean;
957
+ url?: string;
958
+ api: BTApi;
959
+ }
960
+
920
961
  export declare interface UseApiOptions {
921
962
  auth?: BTAuth;
922
963
  /**overrides the default */
@@ -933,6 +974,8 @@ export declare interface UseApiOptions {
933
974
  defaultReturnText?: boolean;
934
975
  /**defaults to true. Will throw an error on fail */
935
976
  defaultThrowError?: boolean;
977
+ /**demo for providing any demo data */
978
+ demo?: BTDemo;
936
979
  /**defaults to a function that returns '' */
937
980
  findPath?: FindPath;
938
981
  /**if true and logged in then will set an authorization header with 'bearer [token]' */
@@ -1056,19 +1099,14 @@ export declare function useList(props: ListProps, emit?: ListEvents, options?: U
1056
1099
  asyncItems: Ref<any[]>;
1057
1100
  currentPage: Ref<number>;
1058
1101
  deleteItem: (dItem: MaybeRefOrGetter<any>) => void;
1059
- displayHeaders: ComputedRef<never[]>;
1060
- errorMsg: ComputedRef<string | undefined>;
1061
- exportToCSV: () => void;
1062
- filteredItems: ShallowRef<any[]>;
1063
- filters: ComputedRef<string[]>;
1064
- filtersChanged: ComputedRef<boolean>;
1065
- headerOptions: Ref< {
1102
+ displayHeaders: ComputedRef< {
1066
1103
  align?: "start" | "end" | "center" | undefined;
1067
1104
  bool?: number | undefined;
1068
1105
  csv?: boolean | undefined;
1069
1106
  csvArray?: boolean | undefined;
1070
1107
  csvFilter?: string | undefined;
1071
1108
  csvText?: string | undefined;
1109
+ display?: boolean | undefined;
1072
1110
  hide?: boolean | undefined;
1073
1111
  itemText?: string | undefined;
1074
1112
  level?: number | undefined;
@@ -1085,28 +1123,19 @@ export declare function useList(props: ListProps, emit?: ListEvents, options?: U
1085
1123
  title?: string | undefined;
1086
1124
  value?: string | undefined;
1087
1125
  }[]>;
1088
- isDeletable: ComputedRef<(item: any) => boolean>;
1089
- isLoading: ComputedRef<boolean>;
1090
- isRestorable: ComputedRef<(item: any) => boolean>;
1091
- loadingMsg: ComputedRef<string | undefined>;
1092
- refresh: (options?: RefreshOptions) => Promise<void>;
1093
- restoreItem: (dItem: MaybeRefOrGetter<any>) => void;
1094
- searchString: Ref<string | undefined>;
1095
- selectedFilters: Ref<number[]>;
1096
- selectItem: (rItem: any, variant: BladeVariant) => void;
1097
- serverFilters: Ref<string[]>;
1098
- showError: ShallowRef<boolean>;
1099
- showInactive: Ref<boolean>;
1100
- showSearch: ShallowRef<boolean>;
1101
- sortOrder: Ref<"Ascending" | "Descending" | undefined>;
1102
- subtitleOptions: ComputedRef<GroupedHeaderOption[]>;
1103
- tableHeaders: ComputedRef< {
1126
+ errorMsg: ComputedRef<string | undefined>;
1127
+ exportToCSV: () => void;
1128
+ filteredItems: ShallowRef<any[]>;
1129
+ filters: ComputedRef<string[]>;
1130
+ filtersChanged: ComputedRef<boolean>;
1131
+ headerOptions: Ref< {
1104
1132
  align?: "start" | "end" | "center" | undefined;
1105
1133
  bool?: number | undefined;
1106
1134
  csv?: boolean | undefined;
1107
1135
  csvArray?: boolean | undefined;
1108
1136
  csvFilter?: string | undefined;
1109
1137
  csvText?: string | undefined;
1138
+ display?: boolean | undefined;
1110
1139
  hide?: boolean | undefined;
1111
1140
  itemText?: string | undefined;
1112
1141
  level?: number | undefined;
@@ -1123,6 +1152,20 @@ export declare function useList(props: ListProps, emit?: ListEvents, options?: U
1123
1152
  title?: string | undefined;
1124
1153
  value?: string | undefined;
1125
1154
  }[]>;
1155
+ isDeletable: ComputedRef<(item: any) => boolean>;
1156
+ isLoading: ComputedRef<boolean>;
1157
+ isRestorable: ComputedRef<(item: any) => boolean>;
1158
+ loadingMsg: ComputedRef<string | undefined>;
1159
+ refresh: (options?: RefreshOptions) => Promise<void>;
1160
+ restoreItem: (dItem: MaybeRefOrGetter<any>) => void;
1161
+ searchString: Ref<string | undefined>;
1162
+ selectedFilters: Ref<number[]>;
1163
+ selectItem: (rItem: any, variant: BladeVariant) => void;
1164
+ showError: ShallowRef<boolean>;
1165
+ showInactive: Ref<boolean>;
1166
+ showSearch: ShallowRef<boolean>;
1167
+ sortOrder: Ref<"Ascending" | "Descending" | undefined>;
1168
+ subtitleOptions: ComputedRef<GroupedHeaderOption[]>;
1126
1169
  titleOptions: ComputedRef<GroupedHeaderOption[]>;
1127
1170
  toggleSearch: () => void;
1128
1171
  totalPages: Ref<number>;
@@ -1216,7 +1259,7 @@ declare interface UseSessionStoreOptions {
1216
1259
  /**overrides the default */
1217
1260
  buildUrl?: (path: PathOptions) => string;
1218
1261
  /**the name of this store */
1219
- storeName?: string;
1262
+ storeName: string;
1220
1263
  }
1221
1264
 
1222
1265
  export declare function useStore(options: CreateStoreOptions): BTStore;
@@ -1264,7 +1307,7 @@ declare interface UseWholeLastUpdateStoreOptions {
1264
1307
  /**ideally required. For setting unique local storage keys */
1265
1308
  auth?: BTAuth;
1266
1309
  storageMode?: 'session' | 'local-cache';
1267
- storeName?: string;
1310
+ storeName: string;
1268
1311
  }
1269
1312
 
1270
1313
  export declare function validEmail(email?: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-core-app",
3
- "version": "1.4.34",
3
+ "version": "1.4.36",
4
4
  "description": "Core app tools for some basic features like navigation, authentication, server apis, and cosmetics",
5
5
  "homepage": "https://github.com/BlitzItTech/bt-core",
6
6
  "bugs": {