@arrai-innovations/reactive-helpers 21.1.2 → 22.0.0
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/LICENSE +28 -0
- package/README.md +109 -21
- package/config/commonCrud.js +4 -6
- package/config/listCrud.js +20 -22
- package/config/objectCrud.js +30 -37
- package/package.json +93 -89
- package/types/config/listCrud.d.ts +83 -26
- package/types/config/objectCrud.d.ts +123 -44
- package/types/use/cancellableIntent.d.ts +27 -31
- package/types/use/combineClasses.d.ts +4 -1
- package/types/use/error.d.ts +39 -19
- package/types/use/list.d.ts +27 -26
- package/types/use/listCalculated.d.ts +21 -39
- package/types/use/listFilter.d.ts +25 -33
- package/types/use/listInstance.d.ts +88 -80
- package/types/use/listRelated.d.ts +26 -46
- package/types/use/listSearch.d.ts +54 -52
- package/types/use/listSort.d.ts +25 -39
- package/types/use/listSubscription.d.ts +28 -35
- package/types/use/loading.d.ts +20 -10
- package/types/use/loadingError.d.ts +12 -3
- package/types/use/object.d.ts +8 -5
- package/types/use/objectCalculated.d.ts +30 -27
- package/types/use/objectInstance.d.ts +67 -73
- package/types/use/objectRelated.d.ts +41 -33
- package/types/use/objectSubscription.d.ts +32 -43
- package/types/use/proxyError.d.ts +15 -6
- package/types/use/proxyLoading.d.ts +11 -5
- package/types/use/proxyLoadingError.d.ts +19 -7
- package/types/use/search.d.ts +33 -29
- package/types/utils/assignReactiveObject.d.ts +3 -0
- package/types/utils/cancellablePromise.d.ts +5 -5
- package/types/utils/classes.d.ts +7 -1
- package/types/utils/deepUnref.d.ts +1 -1
- package/types/utils/isReactiveTyped.d.ts +2 -0
- package/types/utils/keyDiff.d.ts +4 -6
- package/types/utils/relatedCalculatedHelpers.d.ts +2 -0
- package/types/utils/watches.d.ts +1 -1
- package/use/cancellableIntent.js +27 -7
- package/use/combineClasses.js +1 -1
- package/use/error.js +10 -14
- package/use/list.js +6 -18
- package/use/listCalculated.js +7 -22
- package/use/listFilter.js +8 -21
- package/use/listInstance.js +25 -44
- package/use/listRelated.js +9 -28
- package/use/listSearch.js +8 -17
- package/use/listSort.js +27 -41
- package/use/listSubscription.js +10 -25
- package/use/loading.js +5 -7
- package/use/loadingError.js +3 -3
- package/use/object.js +7 -19
- package/use/objectCalculated.js +9 -15
- package/use/objectInstance.js +46 -47
- package/use/objectRelated.js +13 -20
- package/use/objectSubscription.js +11 -25
- package/use/proxyError.js +10 -10
- package/use/proxyLoading.js +5 -5
- package/use/proxyLoadingError.js +10 -8
- package/use/search.js +5 -11
- package/utils/assignReactiveObject.js +3 -3
- package/utils/cancellablePromise.js +4 -4
- package/utils/classes.js +2 -2
- package/utils/deepUnref.js +1 -5
- package/utils/isReactiveTyped.js +2 -0
- package/utils/keyDiff.js +1 -3
- package/utils/relatedCalculatedHelpers.js +2 -0
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The reactive arguments for the list instance.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {object} ListInstanceProps
|
|
2
|
+
* @typedef {object} ListInstanceProps - The reactive arguments for the list instance.
|
|
5
3
|
* @property {string} pkKey - The primary key field for the list objects.
|
|
6
4
|
* @property {object} params - The arguments passed to the server.
|
|
7
5
|
* @property {object} target - Implementation specific arguments.
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
|
-
* The configuration options used to create a list instance.
|
|
11
|
-
*
|
|
12
|
-
* @typedef {object} ListInstanceOptions
|
|
8
|
+
* @typedef {object} ListInstanceOptions - The configuration options used to create a list instance.
|
|
13
9
|
* @property {import('vue').UnwrapNestedRefs<ListInstanceProps>} props - The props for the list instance.
|
|
14
10
|
* @property {object} [handlers] - Default implementation are used as set by `setListCrud`.
|
|
15
11
|
* @property {import('../config/listCrud.js').CrudListFn} [handlers.list] - Provide the implementation for the list
|
|
@@ -22,22 +18,16 @@
|
|
|
22
18
|
* subscribe function.
|
|
23
19
|
*/
|
|
24
20
|
/**
|
|
25
|
-
* The objects by pk.
|
|
26
|
-
*
|
|
27
|
-
* @typedef {{[pk: import('../config/commonCrud.js').Pk]: import('../use/objectInstance.js').ExistingCrudObject}} ObjectsByPk
|
|
21
|
+
* @typedef {{[pk: import('../config/commonCrud.js').Pk]: import('../use/objectInstance.js').ExistingCrudObject}} ObjectsByPk - The objects by pk.
|
|
28
22
|
*/
|
|
29
23
|
/**
|
|
30
|
-
* The objects in order, based on .order & .objects.
|
|
31
|
-
*
|
|
32
|
-
* @typedef {import('vue').ComputedRef<import('../use/objectInstance.js').ExistingCrudObject[]>} ObjectsInOrder
|
|
24
|
+
* @typedef {import('vue').ComputedRef<import('../use/objectInstance.js').ExistingCrudObject[]>} ObjectsInOrder - The objects in order, based on .order & .objects.
|
|
33
25
|
*/
|
|
34
26
|
/**
|
|
35
|
-
* The order of the objects in the list.
|
|
36
|
-
*
|
|
37
|
-
* @typedef {import('vue').ComputedRef<import('../config/commonCrud.js').Pk[]>} ListOrder
|
|
27
|
+
* @typedef {import('vue').ComputedRef<import('../config/commonCrud.js').Pk[]>} ListOrder - The order of the objects in the list.
|
|
38
28
|
*/
|
|
39
29
|
/**
|
|
40
|
-
* @typedef {object} ListInstanceRawStateCrud
|
|
30
|
+
* @typedef {object} ListInstanceRawStateCrud - The raw CRUD handlers and target args stored in a list instance's reactive state.
|
|
41
31
|
* @property {import('vue').Reactive<import('../config/objectCrud.js').TargetArgs|{}>} args - The arguments to be passed to the crud handlers.
|
|
42
32
|
* @property {import('../config/listCrud.js').CrudListFn} list - The list function.
|
|
43
33
|
* @property {import('../config/listCrud.js').CrudListSubscribeFn} subscribe - The subscribe function.
|
|
@@ -45,22 +35,20 @@
|
|
|
45
35
|
* @property {import('../config/listCrud.js').CrudExecuteActionFn} executeAction - The execute action function.
|
|
46
36
|
*/
|
|
47
37
|
/**
|
|
48
|
-
* @typedef {Map<import('../config/commonCrud.js').Pk, import('vue').Reactive<import('../use/objectInstance.js').ExistingCrudObject>>} ObjectsMap
|
|
38
|
+
* @typedef {Map<import('../config/commonCrud.js').Pk, import('vue').Reactive<import('../use/objectInstance.js').ExistingCrudObject>>} ObjectsMap - A Map of primary keys to the list's reactive existing objects.
|
|
49
39
|
*/
|
|
50
40
|
/**
|
|
51
|
-
* @typedef {object} PaginateInfo
|
|
41
|
+
* @typedef {object} PaginateInfo - Pagination details for a list, including total records, total pages, per-page count, and current page.
|
|
52
42
|
* @property {number} [totalRecords] - The total records.
|
|
53
43
|
* @property {number} [totalPages] - The total pages.
|
|
54
44
|
* @property {number} [perPage] - The per page.
|
|
55
45
|
* @property {number} [page] - The page you are giving us results for.
|
|
56
46
|
*/
|
|
57
47
|
/**
|
|
58
|
-
* @typedef {{ [key: string]: number | string }} ColumnTotals
|
|
48
|
+
* @typedef {{ [key: string]: number | string }} ColumnTotals - A map of column names to their aggregate total values for a list.
|
|
59
49
|
*/
|
|
60
50
|
/**
|
|
61
|
-
* The raw state object for the list instance, defining the reactive properties and their types.
|
|
62
|
-
*
|
|
63
|
-
* @typedef {object} ListInstanceRawMyState
|
|
51
|
+
* @typedef {object} ListInstanceRawMyState - The raw state object for the list instance, defining the reactive properties and their types.
|
|
64
52
|
* @property {import('vue').Reactive<ListInstanceRawStateCrud>} crud - CRUD handlers and their configurations for the list.
|
|
65
53
|
* @property {string} pkKey - The primary key field for the list objects.
|
|
66
54
|
* @property {object} params - Arguments passed to the server for listing operations.
|
|
@@ -72,37 +60,31 @@
|
|
|
72
60
|
* @property {import('vue').ShallowReactive<ColumnTotals>} columnTotals - Column totals for the list.
|
|
73
61
|
*/
|
|
74
62
|
/**
|
|
75
|
-
* @typedef {ListInstanceRawMyState & Pick<import('./loadingError.js').LoadingErrorStatus, "loading" | "error" | "errored">} ListInstanceRawState
|
|
63
|
+
* @typedef {ListInstanceRawMyState & Pick<import('./loadingError.js').LoadingErrorStatus, "loading" | "error" | "errored">} ListInstanceRawState - The raw, pre-unwrapped state of a list instance, combining its own state with loading and error status.
|
|
76
64
|
*/
|
|
77
65
|
/**
|
|
78
|
-
* Defines the reactive state used by the list instance.
|
|
79
|
-
*
|
|
80
|
-
* @typedef {import('vue').UnwrapNestedRefs<ListInstanceRawState>} ListInstanceState
|
|
66
|
+
* @typedef {import('vue').UnwrapNestedRefs<ListInstanceRawState>} ListInstanceState - Defines the reactive state used by the list instance.
|
|
81
67
|
*/
|
|
82
68
|
/**
|
|
83
|
-
* @typedef {(newObjects: import('../use/objectInstance.js').ExistingCrudObject[]) => void} PushObjectsFn
|
|
69
|
+
* @typedef {(newObjects: import('../use/objectInstance.js').ExistingCrudObject[]) => void} PushObjectsFn - Signature for the function that pushes a page of newly received objects into the list.
|
|
84
70
|
*/
|
|
85
71
|
/**
|
|
86
|
-
* Options to control which reactive state is reset when clearing the list.
|
|
87
|
-
*
|
|
88
|
-
* @typedef {object} ClearListOptions
|
|
72
|
+
* @typedef {object} ClearListOptions - Options to control which reactive state is reset when clearing the list.
|
|
89
73
|
* @property {boolean} [keepPagination] - When true, keep the current pagination information.
|
|
90
74
|
* @property {boolean} [keepColumnTotals] - When true, keep the current column totals.
|
|
91
75
|
* @property {boolean} [keepError] - When true, keep the current error state.
|
|
92
76
|
*/
|
|
93
77
|
/**
|
|
94
|
-
* @typedef {(options?: ClearListOptions) => void} ClearListFn
|
|
78
|
+
* @typedef {(options?: ClearListOptions) => void} ClearListFn - Signature for the handler that clears the objects held by the list.
|
|
95
79
|
*/
|
|
96
80
|
/**
|
|
97
|
-
* @typedef {(info: PaginateInfo) => void} SetPaginateInfoFn
|
|
81
|
+
* @typedef {(info: PaginateInfo) => void} SetPaginateInfoFn - Signature for the handler that updates the list's pagination information.
|
|
98
82
|
*/
|
|
99
83
|
/**
|
|
100
|
-
* @typedef {(total: ColumnTotals) => void} SetColumnTotalsFn
|
|
84
|
+
* @typedef {(total: ColumnTotals) => void} SetColumnTotalsFn - Signature for the handler that updates the list's column totals.
|
|
101
85
|
*/
|
|
102
86
|
/**
|
|
103
|
-
* Defines the methods provided by the list instance for managing objects in the list.
|
|
104
|
-
*
|
|
105
|
-
* @typedef {object} ListInstanceMyFunctions
|
|
87
|
+
* @typedef {object} ListInstanceMyFunctions - Defines the methods provided by the list instance for managing objects in the list.
|
|
106
88
|
* @property {PushObjectsFn} pushObjects - Customizable callback for handling new objects per page.
|
|
107
89
|
* @property {(object: import('../use/objectInstance.js').ExistingCrudObject) => void} addListObject - Adds an object to the list.
|
|
108
90
|
* @property {(object: import('../use/objectInstance.js').ExistingCrudObject) => void} updateListObject - Updates an object in the list.
|
|
@@ -117,17 +99,13 @@
|
|
|
117
99
|
* @property {(total: ColumnTotals) => void} setColumnTotals - The method to update column totals.
|
|
118
100
|
*/
|
|
119
101
|
/**
|
|
120
|
-
* @typedef {ListInstanceMyFunctions & Pick<import('./loadingError.js').LoadingErrorStatus, "clearError">} ListInstanceFunctions
|
|
102
|
+
* @typedef {ListInstanceMyFunctions & Pick<import('./loadingError.js').LoadingErrorStatus, "clearError">} ListInstanceFunctions - The methods contributed by the list instance, including its CRUD operations plus clearError.
|
|
121
103
|
*/
|
|
122
104
|
/**
|
|
123
|
-
* Helper type to facilitate the combination of state and functions into a single type.
|
|
124
|
-
*
|
|
125
|
-
* @typedef {{state: ListInstanceState}} ListInstanceStateMixIn
|
|
105
|
+
* @typedef {{state: ListInstanceState}} ListInstanceStateMixIn - Helper type to facilitate the combination of state and functions into a single type.
|
|
126
106
|
*/
|
|
127
107
|
/**
|
|
128
|
-
* The list instance, combining state management and functional operations for managing a list of objects.
|
|
129
|
-
*
|
|
130
|
-
* @typedef {ListInstanceStateMixIn & ListInstanceFunctions} ListInstance
|
|
108
|
+
* @typedef {ListInstanceStateMixIn & ListInstanceFunctions} ListInstance - The list instance, combining state management and functional operations for managing a list of objects.
|
|
131
109
|
*/
|
|
132
110
|
/**
|
|
133
111
|
* Creates and manages multiple list instances.
|
|
@@ -217,15 +195,15 @@ export class ListInstanceError extends Error {
|
|
|
217
195
|
*/
|
|
218
196
|
export type ListInstanceProps = {
|
|
219
197
|
/**
|
|
220
|
-
*
|
|
198
|
+
* The primary key field for the list objects.
|
|
221
199
|
*/
|
|
222
200
|
pkKey: string;
|
|
223
201
|
/**
|
|
224
|
-
*
|
|
202
|
+
* The arguments passed to the server.
|
|
225
203
|
*/
|
|
226
204
|
params: object;
|
|
227
205
|
/**
|
|
228
|
-
*
|
|
206
|
+
* Implementation specific arguments.
|
|
229
207
|
*/
|
|
230
208
|
target: object;
|
|
231
209
|
};
|
|
@@ -234,11 +212,11 @@ export type ListInstanceProps = {
|
|
|
234
212
|
*/
|
|
235
213
|
export type ListInstanceOptions = {
|
|
236
214
|
/**
|
|
237
|
-
*
|
|
215
|
+
* The props for the list instance.
|
|
238
216
|
*/
|
|
239
217
|
props: import("vue").UnwrapNestedRefs<ListInstanceProps>;
|
|
240
218
|
/**
|
|
241
|
-
*
|
|
219
|
+
* Default implementation are used as set by `setListCrud`.
|
|
242
220
|
*/
|
|
243
221
|
handlers?: {
|
|
244
222
|
list?: import("../config/listCrud.js").CrudListFn;
|
|
@@ -261,47 +239,59 @@ export type ObjectsInOrder = import("vue").ComputedRef<import("../use/objectInst
|
|
|
261
239
|
* The order of the objects in the list.
|
|
262
240
|
*/
|
|
263
241
|
export type ListOrder = import("vue").ComputedRef<import("../config/commonCrud.js").Pk[]>;
|
|
242
|
+
/**
|
|
243
|
+
* The raw CRUD handlers and target args stored in a list instance's reactive state.
|
|
244
|
+
*/
|
|
264
245
|
export type ListInstanceRawStateCrud = {
|
|
265
246
|
/**
|
|
266
|
-
*
|
|
247
|
+
* The arguments to be passed to the crud handlers.
|
|
267
248
|
*/
|
|
268
249
|
args: import("vue").Reactive<import("../config/objectCrud.js").TargetArgs | {}>;
|
|
269
250
|
/**
|
|
270
|
-
*
|
|
251
|
+
* The list function.
|
|
271
252
|
*/
|
|
272
253
|
list: import("../config/listCrud.js").CrudListFn;
|
|
273
254
|
/**
|
|
274
|
-
*
|
|
255
|
+
* The subscribe function.
|
|
275
256
|
*/
|
|
276
257
|
subscribe: import("../config/listCrud.js").CrudListSubscribeFn;
|
|
277
258
|
/**
|
|
278
|
-
*
|
|
259
|
+
* The bulk delete function.
|
|
279
260
|
*/
|
|
280
261
|
bulkDelete: import("../config/listCrud.js").CrudBulkDeleteFn;
|
|
281
262
|
/**
|
|
282
|
-
*
|
|
263
|
+
* The execute action function.
|
|
283
264
|
*/
|
|
284
265
|
executeAction: import("../config/listCrud.js").CrudExecuteActionFn;
|
|
285
266
|
};
|
|
267
|
+
/**
|
|
268
|
+
* A Map of primary keys to the list's reactive existing objects.
|
|
269
|
+
*/
|
|
286
270
|
export type ObjectsMap = Map<import("../config/commonCrud.js").Pk, import("vue").Reactive<import("../use/objectInstance.js").ExistingCrudObject>>;
|
|
271
|
+
/**
|
|
272
|
+
* Pagination details for a list, including total records, total pages, per-page count, and current page.
|
|
273
|
+
*/
|
|
287
274
|
export type PaginateInfo = {
|
|
288
275
|
/**
|
|
289
|
-
*
|
|
276
|
+
* The total records.
|
|
290
277
|
*/
|
|
291
278
|
totalRecords?: number;
|
|
292
279
|
/**
|
|
293
|
-
*
|
|
280
|
+
* The total pages.
|
|
294
281
|
*/
|
|
295
282
|
totalPages?: number;
|
|
296
283
|
/**
|
|
297
|
-
*
|
|
284
|
+
* The per page.
|
|
298
285
|
*/
|
|
299
286
|
perPage?: number;
|
|
300
287
|
/**
|
|
301
|
-
*
|
|
288
|
+
* The page you are giving us results for.
|
|
302
289
|
*/
|
|
303
290
|
page?: number;
|
|
304
291
|
};
|
|
292
|
+
/**
|
|
293
|
+
* A map of column names to their aggregate total values for a list.
|
|
294
|
+
*/
|
|
305
295
|
export type ColumnTotals = {
|
|
306
296
|
[key: string]: number | string;
|
|
307
297
|
};
|
|
@@ -310,123 +300,141 @@ export type ColumnTotals = {
|
|
|
310
300
|
*/
|
|
311
301
|
export type ListInstanceRawMyState = {
|
|
312
302
|
/**
|
|
313
|
-
*
|
|
303
|
+
* CRUD handlers and their configurations for the list.
|
|
314
304
|
*/
|
|
315
305
|
crud: import("vue").Reactive<ListInstanceRawStateCrud>;
|
|
316
306
|
/**
|
|
317
|
-
*
|
|
307
|
+
* The primary key field for the list objects.
|
|
318
308
|
*/
|
|
319
309
|
pkKey: string;
|
|
320
310
|
/**
|
|
321
|
-
*
|
|
311
|
+
* Arguments passed to the server for listing operations.
|
|
322
312
|
*/
|
|
323
313
|
params: object;
|
|
324
314
|
/**
|
|
325
|
-
*
|
|
315
|
+
* The map of objects stored by their pks.
|
|
326
316
|
*/
|
|
327
317
|
objectsMap: ObjectsMap;
|
|
328
318
|
/**
|
|
329
|
-
*
|
|
319
|
+
* The list objects stored by their pks.
|
|
330
320
|
*/
|
|
331
321
|
objects: ObjectsByPk;
|
|
332
322
|
/**
|
|
333
|
-
*
|
|
323
|
+
* The order of objects in the list.
|
|
334
324
|
*/
|
|
335
325
|
order: ListOrder;
|
|
336
326
|
/**
|
|
337
|
-
*
|
|
327
|
+
* The objects in the order specified by the list.
|
|
338
328
|
*/
|
|
339
329
|
objectsInOrder: ObjectsInOrder;
|
|
340
330
|
/**
|
|
341
|
-
*
|
|
331
|
+
* Pagination information for the list.
|
|
342
332
|
*/
|
|
343
333
|
paginateInfo: import("vue").ShallowReactive<PaginateInfo>;
|
|
344
334
|
/**
|
|
345
|
-
*
|
|
335
|
+
* Column totals for the list.
|
|
346
336
|
*/
|
|
347
337
|
columnTotals: import("vue").ShallowReactive<ColumnTotals>;
|
|
348
338
|
};
|
|
339
|
+
/**
|
|
340
|
+
* The raw, pre-unwrapped state of a list instance, combining its own state with loading and error status.
|
|
341
|
+
*/
|
|
349
342
|
export type ListInstanceRawState = ListInstanceRawMyState & Pick<import("./loadingError.js").LoadingErrorStatus, "loading" | "error" | "errored">;
|
|
350
343
|
/**
|
|
351
344
|
* Defines the reactive state used by the list instance.
|
|
352
345
|
*/
|
|
353
346
|
export type ListInstanceState = import("vue").UnwrapNestedRefs<ListInstanceRawState>;
|
|
347
|
+
/**
|
|
348
|
+
* Signature for the function that pushes a page of newly received objects into the list.
|
|
349
|
+
*/
|
|
354
350
|
export type PushObjectsFn = (newObjects: import("../use/objectInstance.js").ExistingCrudObject[]) => void;
|
|
355
351
|
/**
|
|
356
352
|
* Options to control which reactive state is reset when clearing the list.
|
|
357
353
|
*/
|
|
358
354
|
export type ClearListOptions = {
|
|
359
355
|
/**
|
|
360
|
-
*
|
|
356
|
+
* When true, keep the current pagination information.
|
|
361
357
|
*/
|
|
362
358
|
keepPagination?: boolean;
|
|
363
359
|
/**
|
|
364
|
-
*
|
|
360
|
+
* When true, keep the current column totals.
|
|
365
361
|
*/
|
|
366
362
|
keepColumnTotals?: boolean;
|
|
367
363
|
/**
|
|
368
|
-
*
|
|
364
|
+
* When true, keep the current error state.
|
|
369
365
|
*/
|
|
370
366
|
keepError?: boolean;
|
|
371
367
|
};
|
|
368
|
+
/**
|
|
369
|
+
* Signature for the handler that clears the objects held by the list.
|
|
370
|
+
*/
|
|
372
371
|
export type ClearListFn = (options?: ClearListOptions) => void;
|
|
372
|
+
/**
|
|
373
|
+
* Signature for the handler that updates the list's pagination information.
|
|
374
|
+
*/
|
|
373
375
|
export type SetPaginateInfoFn = (info: PaginateInfo) => void;
|
|
376
|
+
/**
|
|
377
|
+
* Signature for the handler that updates the list's column totals.
|
|
378
|
+
*/
|
|
374
379
|
export type SetColumnTotalsFn = (total: ColumnTotals) => void;
|
|
375
380
|
/**
|
|
376
381
|
* Defines the methods provided by the list instance for managing objects in the list.
|
|
377
382
|
*/
|
|
378
383
|
export type ListInstanceMyFunctions = {
|
|
379
384
|
/**
|
|
380
|
-
*
|
|
385
|
+
* Customizable callback for handling new objects per page.
|
|
381
386
|
*/
|
|
382
387
|
pushObjects: PushObjectsFn;
|
|
383
388
|
/**
|
|
384
|
-
*
|
|
389
|
+
* Adds an object to the list.
|
|
385
390
|
*/
|
|
386
391
|
addListObject: (object: import("../use/objectInstance.js").ExistingCrudObject) => void;
|
|
387
392
|
/**
|
|
388
|
-
*
|
|
393
|
+
* Updates an object in the list.
|
|
389
394
|
*/
|
|
390
395
|
updateListObject: (object: import("../use/objectInstance.js").ExistingCrudObject) => void;
|
|
391
396
|
/**
|
|
392
|
-
*
|
|
397
|
+
* Deletes an object from the list by pk.
|
|
393
398
|
*/
|
|
394
399
|
deleteListObject: (objectId: import("../config/commonCrud.js").PkInput) => void;
|
|
395
400
|
/**
|
|
396
|
-
*
|
|
401
|
+
* Clears the list objects and optionally keeps pagination, totals,
|
|
397
402
|
* or error state.
|
|
398
403
|
*/
|
|
399
404
|
clearList: (options?: ClearListOptions) => void;
|
|
400
405
|
/**
|
|
401
|
-
*
|
|
406
|
+
* Generates a unique fake pk for use within the list.
|
|
402
407
|
*/
|
|
403
408
|
getFakePk: () => import("../config/commonCrud.js").Pk;
|
|
404
409
|
/**
|
|
405
|
-
*
|
|
410
|
+
* Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
|
|
406
411
|
*/
|
|
407
412
|
list: (args?: import("../config/listCrud.js").AdditionalListArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
408
413
|
/**
|
|
409
|
-
*
|
|
414
|
+
* Deletes objects from the list by pk, returning a promise to a boolean indicating success.
|
|
410
415
|
*/
|
|
411
416
|
bulkDelete: (args?: {
|
|
412
417
|
pks?: import("../config/commonCrud.js").Pk[];
|
|
413
418
|
} & import("../config/listCrud.js").AdditionalListArgs) => Promise<boolean>;
|
|
414
419
|
/**
|
|
415
|
-
*
|
|
420
|
+
* Initiates an action on all objects in the list, returning the response, or null if the action failed.
|
|
416
421
|
*/
|
|
417
422
|
executeAction: (args: {
|
|
418
423
|
action: string;
|
|
419
424
|
pks?: import("../config/commonCrud.js").Pk[];
|
|
420
425
|
} & import("../config/listCrud.js").AdditionalListArgs) => Promise<object | string | boolean | null>;
|
|
421
426
|
/**
|
|
422
|
-
*
|
|
427
|
+
* The method to update pagination information.
|
|
423
428
|
*/
|
|
424
429
|
setPaginateInfo: (info: PaginateInfo) => void;
|
|
425
430
|
/**
|
|
426
|
-
*
|
|
431
|
+
* The method to update column totals.
|
|
427
432
|
*/
|
|
428
433
|
setColumnTotals: (total: ColumnTotals) => void;
|
|
429
434
|
};
|
|
435
|
+
/**
|
|
436
|
+
* The methods contributed by the list instance, including its CRUD operations plus clearError.
|
|
437
|
+
*/
|
|
430
438
|
export type ListInstanceFunctions = ListInstanceMyFunctions & Pick<import("./loadingError.js").LoadingErrorStatus, "clearError">;
|
|
431
439
|
/**
|
|
432
440
|
* Helper type to facilitate the combination of state and functions into a single type.
|
|
@@ -5,26 +5,19 @@
|
|
|
5
5
|
* @module use/listRelated.js
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* The rule for defining relationships for objects in a list.
|
|
9
|
-
*
|
|
10
|
-
* @typedef {object} ListRelatedRule
|
|
8
|
+
* @typedef {object} ListRelatedRule - The rule for defining relationships for objects in a list.
|
|
11
9
|
* @property {string} pkKey - Specifies the foreign key used to link objects across lists. Planned to be renamed to
|
|
12
10
|
* 'fkKey' to better reflect its usage.
|
|
13
11
|
* @property {string[]} [order] - Specifies the order in which related objects should be sorted, if applicable.
|
|
14
12
|
* @property {import('./listInstance.js').ObjectsByPk} objects - The objects that can be related based on the foreign key.
|
|
15
13
|
*/
|
|
16
14
|
/**
|
|
17
|
-
* The rules for defining relationships among objects in a list.
|
|
18
|
-
*
|
|
19
15
|
* @typedef {{
|
|
20
16
|
* [rule: string]: ListRelatedRule,
|
|
21
|
-
* }} ListRelatedRules
|
|
17
|
+
* }} ListRelatedRules - The rules for defining relationships among objects in a list.
|
|
22
18
|
*/
|
|
23
19
|
/**
|
|
24
|
-
* Represents the internal state used by the list related composition function. It manages and computes the relationships
|
|
25
|
-
* between objects based on specified rules, providing real-time updates to related objects as the parent state changes.
|
|
26
|
-
*
|
|
27
|
-
* @typedef {object} ListRelatedRawState
|
|
20
|
+
* @typedef {object} ListRelatedRawState - Represents the internal state used by the list related composition function. It manages and computes the relationships between objects based on specified rules, providing real-time updates to related objects as the parent state changes.
|
|
28
21
|
* @property {{
|
|
29
22
|
* [pk: import('../config/commonCrud.js').Pk]: {
|
|
30
23
|
* [rule: string]: import('vue').ComputedRef<any>,
|
|
@@ -47,45 +40,33 @@
|
|
|
47
40
|
* @property {import('vue').Ref<boolean>} running - General flag that indicates if the list-related logic is processing, used to manage UI feedback or prevent concurrent operations.
|
|
48
41
|
*/
|
|
49
42
|
/**
|
|
50
|
-
* The raw state properties for a parent of a list related property.
|
|
51
|
-
*
|
|
52
43
|
* @typedef {(
|
|
53
44
|
* import('./listInstance.js').ListInstanceRawState &
|
|
54
45
|
* Partial<import('./listSubscription.js').ListSubscriptionRawState>
|
|
55
|
-
* )} ListRelatedParentRawState
|
|
46
|
+
* )} ListRelatedParentRawState - The raw state properties for a parent of a list related property.
|
|
56
47
|
*/
|
|
57
48
|
/**
|
|
58
|
-
* The type for a parentState object.
|
|
59
|
-
*
|
|
60
|
-
* @typedef {import('vue').UnwrapNestedRefs<ListRelatedParentRawState>} ListRelatedParentState
|
|
49
|
+
* @typedef {import('vue').UnwrapNestedRefs<ListRelatedParentRawState>} ListRelatedParentState - The type for a parentState object.
|
|
61
50
|
*/
|
|
62
51
|
/**
|
|
63
|
-
* The state for a list related property.
|
|
64
|
-
*
|
|
65
52
|
* @typedef {import('vue').UnwrapNestedRefs<
|
|
66
53
|
* ListRelatedParentRawState &
|
|
67
54
|
* ListRelatedRawState
|
|
68
|
-
* >} ListRelatedState
|
|
55
|
+
* >} ListRelatedState - The state for a list related property.
|
|
69
56
|
*/
|
|
70
57
|
/**
|
|
71
|
-
* The options for the list related composition function.
|
|
72
|
-
*
|
|
73
|
-
* @typedef {object} ListRelatedOptions
|
|
58
|
+
* @typedef {object} ListRelatedOptions - The options for the list related composition function.
|
|
74
59
|
* @property {ListRelatedParentState} parentState - The parent state object.
|
|
75
60
|
* @property {import('vue').Ref<ListRelatedRules>} relatedObjectsRules - The rules for the related objects.
|
|
76
61
|
*/
|
|
77
62
|
/**
|
|
78
|
-
* The properties for the list related composition function.
|
|
79
|
-
*
|
|
80
|
-
* @typedef {object} ListRelatedProperties
|
|
63
|
+
* @typedef {object} ListRelatedProperties - The properties for the list related composition function.
|
|
81
64
|
* @property {ListRelatedState} state - The state for the list related property.
|
|
82
65
|
* @property {ListRelatedParentState} parentState - The parent state object.
|
|
83
66
|
* @property {() => void} stop - Stops all effects of the list related property.
|
|
84
67
|
*/
|
|
85
68
|
/**
|
|
86
|
-
* An instance of `useListRelated`.
|
|
87
|
-
*
|
|
88
|
-
* @typedef {ListRelatedProperties} ListRelated
|
|
69
|
+
* @typedef {ListRelatedProperties} ListRelated - An instance of `useListRelated`.
|
|
89
70
|
*/
|
|
90
71
|
/**
|
|
91
72
|
* Creates and manages multiple instances of list-related properties, linking each to corresponding parent instances
|
|
@@ -182,16 +163,16 @@ export function useListRelated({ parentState, relatedObjectsRules }: ListRelated
|
|
|
182
163
|
*/
|
|
183
164
|
export type ListRelatedRule = {
|
|
184
165
|
/**
|
|
185
|
-
*
|
|
166
|
+
* Specifies the foreign key used to link objects across lists. Planned to be renamed to
|
|
186
167
|
* 'fkKey' to better reflect its usage.
|
|
187
168
|
*/
|
|
188
169
|
pkKey: string;
|
|
189
170
|
/**
|
|
190
|
-
*
|
|
171
|
+
* Specifies the order in which related objects should be sorted, if applicable.
|
|
191
172
|
*/
|
|
192
173
|
order?: string[];
|
|
193
174
|
/**
|
|
194
|
-
*
|
|
175
|
+
* The objects that can be related based on the foreign key.
|
|
195
176
|
*/
|
|
196
177
|
objects: import("./listInstance.js").ObjectsByPk;
|
|
197
178
|
};
|
|
@@ -202,12 +183,11 @@ export type ListRelatedRules = {
|
|
|
202
183
|
[rule: string]: ListRelatedRule;
|
|
203
184
|
};
|
|
204
185
|
/**
|
|
205
|
-
* Represents the internal state used by the list related composition function. It manages and computes the relationships
|
|
206
|
-
* between objects based on specified rules, providing real-time updates to related objects as the parent state changes.
|
|
186
|
+
* Represents the internal state used by the list related composition function. It manages and computes the relationships between objects based on specified rules, providing real-time updates to related objects as the parent state changes.
|
|
207
187
|
*/
|
|
208
188
|
export type ListRelatedRawState = {
|
|
209
189
|
/**
|
|
210
|
-
*
|
|
190
|
+
* Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
|
|
211
191
|
*/
|
|
212
192
|
relatedObjects: {
|
|
213
193
|
[pk: import("../config/commonCrud.js").Pk]: {
|
|
@@ -215,11 +195,11 @@ export type ListRelatedRawState = {
|
|
|
215
195
|
};
|
|
216
196
|
};
|
|
217
197
|
/**
|
|
218
|
-
*
|
|
198
|
+
* Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
219
199
|
*/
|
|
220
200
|
relatedObjectsRules: ListRelatedRules;
|
|
221
201
|
/**
|
|
222
|
-
*
|
|
202
|
+
* Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
223
203
|
*/
|
|
224
204
|
objAndKeyForPkAndRule: {
|
|
225
205
|
[pk: import("../config/commonCrud.js").Pk]: {
|
|
@@ -227,7 +207,7 @@ export type ListRelatedRawState = {
|
|
|
227
207
|
};
|
|
228
208
|
};
|
|
229
209
|
/**
|
|
230
|
-
*
|
|
210
|
+
* Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
|
|
231
211
|
*/
|
|
232
212
|
fkForPkAndRule: {
|
|
233
213
|
[pk: import("../config/commonCrud.js").Pk]: {
|
|
@@ -235,19 +215,19 @@ export type ListRelatedRawState = {
|
|
|
235
215
|
};
|
|
236
216
|
};
|
|
237
217
|
/**
|
|
238
|
-
*
|
|
218
|
+
* Flags whether the watch on parent state objects is currently active, ensuring updates trigger as needed.
|
|
239
219
|
*/
|
|
240
220
|
relatedObjectsParentStateObjectsWatchRunning: boolean;
|
|
241
221
|
/**
|
|
242
|
-
*
|
|
222
|
+
* Indicates if watches on the related objects themselves are active, managing updates efficiently.
|
|
243
223
|
*/
|
|
244
224
|
relatedObjectsWatchRunning: boolean;
|
|
245
225
|
/**
|
|
246
|
-
*
|
|
226
|
+
* Signals whether any computations related to object relationships are currently in progress.
|
|
247
227
|
*/
|
|
248
228
|
relatedRunning: boolean;
|
|
249
229
|
/**
|
|
250
|
-
*
|
|
230
|
+
* General flag that indicates if the list-related logic is processing, used to manage UI feedback or prevent concurrent operations.
|
|
251
231
|
*/
|
|
252
232
|
running: import("vue").Ref<boolean>;
|
|
253
233
|
};
|
|
@@ -268,11 +248,11 @@ export type ListRelatedState = import("vue").UnwrapNestedRefs<ListRelatedParentR
|
|
|
268
248
|
*/
|
|
269
249
|
export type ListRelatedOptions = {
|
|
270
250
|
/**
|
|
271
|
-
*
|
|
251
|
+
* The parent state object.
|
|
272
252
|
*/
|
|
273
253
|
parentState: ListRelatedParentState;
|
|
274
254
|
/**
|
|
275
|
-
*
|
|
255
|
+
* The rules for the related objects.
|
|
276
256
|
*/
|
|
277
257
|
relatedObjectsRules: import("vue").Ref<ListRelatedRules>;
|
|
278
258
|
};
|
|
@@ -281,15 +261,15 @@ export type ListRelatedOptions = {
|
|
|
281
261
|
*/
|
|
282
262
|
export type ListRelatedProperties = {
|
|
283
263
|
/**
|
|
284
|
-
*
|
|
264
|
+
* The state for the list related property.
|
|
285
265
|
*/
|
|
286
266
|
state: ListRelatedState;
|
|
287
267
|
/**
|
|
288
|
-
*
|
|
268
|
+
* The parent state object.
|
|
289
269
|
*/
|
|
290
270
|
parentState: ListRelatedParentState;
|
|
291
271
|
/**
|
|
292
|
-
*
|
|
272
|
+
* Stops all effects of the list related property.
|
|
293
273
|
*/
|
|
294
274
|
stop: () => void;
|
|
295
275
|
};
|