@arrai-innovations/reactive-helpers 21.0.0 → 21.1.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/README.md +12 -0
- package/config/commonCrud.js +12 -0
- package/config/listCrud.js +21 -6
- package/config/objectCrud.js +53 -11
- package/index.js +3 -0
- package/package.json +6 -4
- package/types/config/commonCrud.d.ts +8 -0
- package/types/config/listCrud.d.ts +14 -6
- package/types/config/objectCrud.d.ts +48 -10
- package/types/index.d.ts +3 -0
- package/types/tests/unit/utils/isReactiveTyped.spec.d.ts +1 -0
- package/types/tests/unit/utils/refIfReactive.spec.d.ts +1 -0
- package/types/tests/unit/utils/toRefsIfReactive.spec.d.ts +1 -0
- package/types/use/cancellableIntent.d.ts +16 -12
- package/types/use/error.d.ts +35 -7
- package/types/use/listCalculated.d.ts +2 -2
- package/types/use/listInstance.d.ts +54 -24
- package/types/use/listRelated.d.ts +6 -6
- package/types/use/listSubscription.d.ts +12 -3
- package/types/use/loading.d.ts +16 -7
- package/types/use/loadingError.d.ts +6 -2
- package/types/use/objectInstance.d.ts +38 -20
- package/types/use/objectSubscription.d.ts +22 -5
- package/types/use/proxyError.d.ts +21 -18
- package/types/use/proxyLoading.d.ts +18 -8
- package/types/use/proxyLoadingError.d.ts +20 -5
- package/types/utils/isReactiveTyped.d.ts +6 -0
- package/types/utils/refIfReactive.d.ts +2 -1
- package/types/utils/toRefsIfReactive.d.ts +14 -0
- package/use/cancellableIntent.js +8 -7
- package/use/error.js +22 -3
- package/use/listCalculated.js +1 -1
- package/use/listInstance.js +52 -33
- package/use/listRelated.js +3 -3
- package/use/listSubscription.js +102 -84
- package/use/loading.js +11 -3
- package/use/loadingError.js +3 -1
- package/use/objectInstance.js +77 -23
- package/use/objectSubscription.js +25 -26
- package/use/proxyError.js +28 -15
- package/use/proxyLoading.js +21 -8
- package/use/proxyLoadingError.js +33 -7
- package/utils/isReactiveTyped.js +10 -0
- package/utils/refIfReactive.js +22 -2
- package/utils/toRefsIfReactive.js +28 -0
package/types/use/error.d.ts
CHANGED
|
@@ -6,14 +6,29 @@
|
|
|
6
6
|
* @typedef {Readonly<ErroredRef>} ErroredReadonlyRef
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @typedef {object} ErrorStatus
|
|
9
|
+
* @typedef {object} ErrorProperties
|
|
12
10
|
* @property {ErrorReadonlyRef} error - The error that occurred.
|
|
13
11
|
* @property {ErroredReadonlyRef} errored - Whether an error has occurred.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {object} ErrorFunctions
|
|
14
15
|
* @property {(error: Error) => void} setError - Set the error state.
|
|
15
16
|
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
16
17
|
*/
|
|
18
|
+
/**
|
|
19
|
+
* Proxies can still clear errors but cannot set them directly.
|
|
20
|
+
*
|
|
21
|
+
* @typedef {object} ErrorReadOnlyFunctions
|
|
22
|
+
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {ErrorProperties & ErrorReadOnlyFunctions} ReadonlyErrorStatus
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The error state API.
|
|
29
|
+
*
|
|
30
|
+
* @typedef {ErrorProperties & ErrorFunctions} ErrorStatus
|
|
31
|
+
*/
|
|
17
32
|
/**
|
|
18
33
|
* A composable function for managing error state.
|
|
19
34
|
*
|
|
@@ -25,10 +40,7 @@ export type ErrorRef = import("vue").Ref<Error | null>;
|
|
|
25
40
|
export type ErroredRef = import("vue").Ref<boolean>;
|
|
26
41
|
export type ErrorReadonlyRef = Readonly<ErrorRef>;
|
|
27
42
|
export type ErroredReadonlyRef = Readonly<ErroredRef>;
|
|
28
|
-
|
|
29
|
-
* The error state API.
|
|
30
|
-
*/
|
|
31
|
-
export type ErrorStatus = {
|
|
43
|
+
export type ErrorProperties = {
|
|
32
44
|
/**
|
|
33
45
|
* - The error that occurred.
|
|
34
46
|
*/
|
|
@@ -37,6 +49,8 @@ export type ErrorStatus = {
|
|
|
37
49
|
* - Whether an error has occurred.
|
|
38
50
|
*/
|
|
39
51
|
errored: ErroredReadonlyRef;
|
|
52
|
+
};
|
|
53
|
+
export type ErrorFunctions = {
|
|
40
54
|
/**
|
|
41
55
|
* - Set the error state.
|
|
42
56
|
*/
|
|
@@ -46,3 +60,17 @@ export type ErrorStatus = {
|
|
|
46
60
|
*/
|
|
47
61
|
clearError: ClearErrorFn;
|
|
48
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Proxies can still clear errors but cannot set them directly.
|
|
65
|
+
*/
|
|
66
|
+
export type ErrorReadOnlyFunctions = {
|
|
67
|
+
/**
|
|
68
|
+
* - Clear the error state.
|
|
69
|
+
*/
|
|
70
|
+
clearError: ClearErrorFn;
|
|
71
|
+
};
|
|
72
|
+
export type ReadonlyErrorStatus = ErrorProperties & ErrorReadOnlyFunctions;
|
|
73
|
+
/**
|
|
74
|
+
* The error state API.
|
|
75
|
+
*/
|
|
76
|
+
export type ErrorStatus = ErrorProperties & ErrorFunctions;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* The raw state for a list calculated.
|
|
28
28
|
*
|
|
29
29
|
* @typedef {object} ListCalculatedRawState - The raw state for a list calculated property.
|
|
30
|
-
* @property {{[pk:
|
|
30
|
+
* @property {{[pk: import('../config/commonCrud.js').Pk]: {[rule: string]: import('vue').ComputedRef<any>}}} calculatedObjects - The calculated objects.
|
|
31
31
|
* @property {ListCalculatedRules} calculatedObjectsRules - The rules for the calculated objects.
|
|
32
32
|
* @property {boolean} calculatedObjectsParentStateObjectsWatchRunning - Whether the parent state objects watch is running.
|
|
33
33
|
* @property {boolean} calculatedObjectsWatchRunning - Whether the calculated objects watch is running.
|
|
@@ -173,7 +173,7 @@ export type ListCalculatedRawState = {
|
|
|
173
173
|
* - The calculated objects.
|
|
174
174
|
*/
|
|
175
175
|
calculatedObjects: {
|
|
176
|
-
[pk:
|
|
176
|
+
[pk: import("../config/commonCrud.js").Pk]: {
|
|
177
177
|
[rule: string]: import("vue").ComputedRef<any>;
|
|
178
178
|
};
|
|
179
179
|
};
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
/**
|
|
25
25
|
* The objects by pk.
|
|
26
26
|
*
|
|
27
|
-
* @typedef {{[pk:
|
|
27
|
+
* @typedef {{[pk: import('../config/commonCrud.js').Pk]: import('../use/objectInstance.js').ExistingCrudObject}} ObjectsByPk
|
|
28
28
|
*/
|
|
29
29
|
/**
|
|
30
30
|
* The objects in order, based on .order & .objects.
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
/**
|
|
35
35
|
* The order of the objects in the list.
|
|
36
36
|
*
|
|
37
|
-
* @typedef {import('vue').ComputedRef<
|
|
37
|
+
* @typedef {import('vue').ComputedRef<import('../config/commonCrud.js').Pk[]>} ListOrder
|
|
38
38
|
*/
|
|
39
39
|
/**
|
|
40
40
|
* @typedef {object} ListInstanceRawStateCrud
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* @property {import('../config/listCrud.js').CrudExecuteActionFn} executeAction - The execute action function.
|
|
46
46
|
*/
|
|
47
47
|
/**
|
|
48
|
-
* @typedef {Map<
|
|
48
|
+
* @typedef {Map<import('../config/commonCrud.js').Pk, import('vue').Reactive<import('../use/objectInstance.js').ExistingCrudObject>>} ObjectsMap
|
|
49
49
|
*/
|
|
50
50
|
/**
|
|
51
51
|
* @typedef {object} PaginateInfo
|
|
@@ -83,7 +83,15 @@
|
|
|
83
83
|
* @typedef {(newObjects: import('../use/objectInstance.js').ExistingCrudObject[]) => void} PushObjectsFn
|
|
84
84
|
*/
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Options to control which reactive state is reset when clearing the list.
|
|
87
|
+
*
|
|
88
|
+
* @typedef {object} ClearListOptions
|
|
89
|
+
* @property {boolean} [keepPagination] - When true, keep the current pagination information.
|
|
90
|
+
* @property {boolean} [keepColumnTotals] - When true, keep the current column totals.
|
|
91
|
+
* @property {boolean} [keepError] - When true, keep the current error state.
|
|
92
|
+
*/
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {(options?: ClearListOptions) => void} ClearListFn
|
|
87
95
|
*/
|
|
88
96
|
/**
|
|
89
97
|
* @typedef {(info: PaginateInfo) => void} SetPaginateInfoFn
|
|
@@ -98,12 +106,13 @@
|
|
|
98
106
|
* @property {PushObjectsFn} pushObjects - Customizable callback for handling new objects per page.
|
|
99
107
|
* @property {(object: import('../use/objectInstance.js').ExistingCrudObject) => void} addListObject - Adds an object to the list.
|
|
100
108
|
* @property {(object: import('../use/objectInstance.js').ExistingCrudObject) => void} updateListObject - Updates an object in the list.
|
|
101
|
-
* @property {(objectId:
|
|
102
|
-
* @property {() => void} clearList - Clears
|
|
103
|
-
*
|
|
104
|
-
* @property {() => import('../
|
|
105
|
-
* @property {(args
|
|
106
|
-
* @property {() => Promise<
|
|
109
|
+
* @property {(objectId: import('../config/commonCrud.js').PkInput) => void} deleteListObject - Deletes an object from the list by pk.
|
|
110
|
+
* @property {(options?: ClearListOptions) => void} clearList - Clears the list objects and optionally keeps pagination, totals,
|
|
111
|
+
* or error state.
|
|
112
|
+
* @property {() => import('../config/commonCrud.js').Pk} getFakePk - Generates a unique fake pk for use within the list.
|
|
113
|
+
* @property {(args?: import('../config/listCrud.js').AdditionalListArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} list - Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
|
|
114
|
+
* @property {(args?: {pks?: import('../config/commonCrud.js').Pk[]} & import('../config/listCrud.js').AdditionalListArgs) => Promise<boolean>} bulkDelete - Deletes objects from the list by pk, returning a promise to a boolean indicating success.
|
|
115
|
+
* @property {(args: {action: string, pks?: import('../config/commonCrud.js').Pk[]} & import('../config/listCrud.js').AdditionalListArgs) => Promise<object|string|boolean|null>} executeAction - Initiates an action on all objects in the list, returning the response, or null if the action failed.
|
|
107
116
|
* @property {(info: PaginateInfo) => void} setPaginateInfo - The method to update pagination information.
|
|
108
117
|
* @property {(total: ColumnTotals) => void} setColumnTotals - The method to update column totals.
|
|
109
118
|
*/
|
|
@@ -242,7 +251,7 @@ export type ListInstanceOptions = {
|
|
|
242
251
|
* The objects by pk.
|
|
243
252
|
*/
|
|
244
253
|
export type ObjectsByPk = {
|
|
245
|
-
[pk:
|
|
254
|
+
[pk: import("../config/commonCrud.js").Pk]: import("../use/objectInstance.js").ExistingCrudObject;
|
|
246
255
|
};
|
|
247
256
|
/**
|
|
248
257
|
* The objects in order, based on .order & .objects.
|
|
@@ -251,7 +260,7 @@ export type ObjectsInOrder = import("vue").ComputedRef<import("../use/objectInst
|
|
|
251
260
|
/**
|
|
252
261
|
* The order of the objects in the list.
|
|
253
262
|
*/
|
|
254
|
-
export type ListOrder = import("vue").ComputedRef<
|
|
263
|
+
export type ListOrder = import("vue").ComputedRef<import("../config/commonCrud.js").Pk[]>;
|
|
255
264
|
export type ListInstanceRawStateCrud = {
|
|
256
265
|
/**
|
|
257
266
|
* - The arguments to be passed to the crud handlers.
|
|
@@ -274,7 +283,7 @@ export type ListInstanceRawStateCrud = {
|
|
|
274
283
|
*/
|
|
275
284
|
executeAction: import("../config/listCrud.js").CrudExecuteActionFn;
|
|
276
285
|
};
|
|
277
|
-
export type ObjectsMap = Map<
|
|
286
|
+
export type ObjectsMap = Map<import("../config/commonCrud.js").Pk, import("vue").Reactive<import("../use/objectInstance.js").ExistingCrudObject>>;
|
|
278
287
|
export type PaginateInfo = {
|
|
279
288
|
/**
|
|
280
289
|
* - The total records.
|
|
@@ -343,7 +352,24 @@ export type ListInstanceRawState = ListInstanceRawMyState & Pick<import("./loadi
|
|
|
343
352
|
*/
|
|
344
353
|
export type ListInstanceState = import("vue").UnwrapNestedRefs<ListInstanceRawState>;
|
|
345
354
|
export type PushObjectsFn = (newObjects: import("../use/objectInstance.js").ExistingCrudObject[]) => void;
|
|
346
|
-
|
|
355
|
+
/**
|
|
356
|
+
* Options to control which reactive state is reset when clearing the list.
|
|
357
|
+
*/
|
|
358
|
+
export type ClearListOptions = {
|
|
359
|
+
/**
|
|
360
|
+
* - When true, keep the current pagination information.
|
|
361
|
+
*/
|
|
362
|
+
keepPagination?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* - When true, keep the current column totals.
|
|
365
|
+
*/
|
|
366
|
+
keepColumnTotals?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* - When true, keep the current error state.
|
|
369
|
+
*/
|
|
370
|
+
keepError?: boolean;
|
|
371
|
+
};
|
|
372
|
+
export type ClearListFn = (options?: ClearListOptions) => void;
|
|
347
373
|
export type SetPaginateInfoFn = (info: PaginateInfo) => void;
|
|
348
374
|
export type SetColumnTotalsFn = (total: ColumnTotals) => void;
|
|
349
375
|
/**
|
|
@@ -365,29 +391,33 @@ export type ListInstanceMyFunctions = {
|
|
|
365
391
|
/**
|
|
366
392
|
* - Deletes an object from the list by pk.
|
|
367
393
|
*/
|
|
368
|
-
deleteListObject: (objectId:
|
|
394
|
+
deleteListObject: (objectId: import("../config/commonCrud.js").PkInput) => void;
|
|
369
395
|
/**
|
|
370
|
-
* - Clears
|
|
396
|
+
* - Clears the list objects and optionally keeps pagination, totals,
|
|
397
|
+
* or error state.
|
|
371
398
|
*/
|
|
372
|
-
clearList: () => void;
|
|
399
|
+
clearList: (options?: ClearListOptions) => void;
|
|
373
400
|
/**
|
|
374
401
|
* - Generates a unique fake pk for use within the list.
|
|
375
402
|
*/
|
|
376
|
-
getFakePk: () =>
|
|
403
|
+
getFakePk: () => import("../config/commonCrud.js").Pk;
|
|
377
404
|
/**
|
|
378
405
|
* - Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
|
|
379
406
|
*/
|
|
380
|
-
list: () => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
407
|
+
list: (args?: import("../config/listCrud.js").AdditionalListArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
381
408
|
/**
|
|
382
409
|
* - Deletes objects from the list by pk, returning a promise to a boolean indicating success.
|
|
383
410
|
*/
|
|
384
|
-
bulkDelete: (args
|
|
385
|
-
pks?:
|
|
386
|
-
}) => Promise<boolean>;
|
|
411
|
+
bulkDelete: (args?: {
|
|
412
|
+
pks?: import("../config/commonCrud.js").Pk[];
|
|
413
|
+
} & import("../config/listCrud.js").AdditionalListArgs) => Promise<boolean>;
|
|
387
414
|
/**
|
|
388
|
-
* - Initiates an action on all objects in the list, returning the response, or
|
|
415
|
+
* - Initiates an action on all objects in the list, returning the response, or null if the action failed.
|
|
389
416
|
*/
|
|
390
|
-
executeAction: (
|
|
417
|
+
executeAction: (args: {
|
|
418
|
+
action: string;
|
|
419
|
+
pks?: import("../config/commonCrud.js").Pk[];
|
|
420
|
+
} & import("../config/listCrud.js").AdditionalListArgs) => Promise<object | string | boolean | null>;
|
|
391
421
|
/**
|
|
392
422
|
* - The method to update pagination information.
|
|
393
423
|
*/
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
*
|
|
27
27
|
* @typedef {object} ListRelatedRawState
|
|
28
28
|
* @property {{
|
|
29
|
-
* [pk:
|
|
29
|
+
* [pk: import('../config/commonCrud.js').Pk]: {
|
|
30
30
|
* [rule: string]: import('vue').ComputedRef<any>,
|
|
31
31
|
* },
|
|
32
32
|
* }} relatedObjects - Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
|
|
33
33
|
* @property {ListRelatedRules} relatedObjectsRules - Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
34
34
|
* @property {{
|
|
35
|
-
* [pk:
|
|
35
|
+
* [pk: import('../config/commonCrud.js').Pk]: {
|
|
36
36
|
* [rule: string]: import('vue').ComputedRef<[object, string]>,
|
|
37
37
|
* },
|
|
38
38
|
* }} objAndKeyForPkAndRule - Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
39
39
|
* @property {{
|
|
40
|
-
* [pk:
|
|
40
|
+
* [pk: import('../config/commonCrud.js').Pk]: {
|
|
41
41
|
* [rule: string]: import('vue').ComputedRef<any>,
|
|
42
42
|
* },
|
|
43
43
|
* }} fkForPkAndRule - Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
|
|
@@ -210,7 +210,7 @@ export type ListRelatedRawState = {
|
|
|
210
210
|
* - Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
|
|
211
211
|
*/
|
|
212
212
|
relatedObjects: {
|
|
213
|
-
[pk:
|
|
213
|
+
[pk: import("../config/commonCrud.js").Pk]: {
|
|
214
214
|
[rule: string]: import("vue").ComputedRef<any>;
|
|
215
215
|
};
|
|
216
216
|
};
|
|
@@ -222,7 +222,7 @@ export type ListRelatedRawState = {
|
|
|
222
222
|
* - Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
223
223
|
*/
|
|
224
224
|
objAndKeyForPkAndRule: {
|
|
225
|
-
[pk:
|
|
225
|
+
[pk: import("../config/commonCrud.js").Pk]: {
|
|
226
226
|
[rule: string]: import("vue").ComputedRef<[object, string]>;
|
|
227
227
|
};
|
|
228
228
|
};
|
|
@@ -230,7 +230,7 @@ export type ListRelatedRawState = {
|
|
|
230
230
|
* - Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
|
|
231
231
|
*/
|
|
232
232
|
fkForPkAndRule: {
|
|
233
|
-
[pk:
|
|
233
|
+
[pk: import("../config/commonCrud.js").Pk]: {
|
|
234
234
|
[rule: string]: import("vue").ComputedRef<any>;
|
|
235
235
|
};
|
|
236
236
|
};
|
|
@@ -47,12 +47,15 @@
|
|
|
47
47
|
*
|
|
48
48
|
* @typedef {ListSubscriptionFunctions & ListSubscriptionProperties} ListSubscription
|
|
49
49
|
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {object} ListSubscriptionOwnOptions
|
|
52
|
+
* @property {import("./listInstance.js").ListInstance} [listInstance] - A list instance to use instead of creating one.
|
|
53
|
+
*/
|
|
50
54
|
/**
|
|
51
55
|
* Defines the settings required to establish a list subscription, detailing how list instances should handle updates
|
|
52
56
|
* and subscriptions based on the given properties.
|
|
53
57
|
*
|
|
54
|
-
* @typedef {
|
|
55
|
-
* @property {import("./listInstance.js").ListInstance} listInstance - A list instance to use instead of creating one.
|
|
58
|
+
* @typedef {import("./listInstance.js").ListInstanceOptions & ListSubscriptionOwnOptions} ListSubscriptionOptions
|
|
56
59
|
*/
|
|
57
60
|
/**
|
|
58
61
|
* A Vue composition function that creates multiple list subscriptions, and returns them as an object.
|
|
@@ -191,8 +194,14 @@ export type ListSubscriptionProperties = {
|
|
|
191
194
|
* An instance of a list subscription, returned by `useListSubscription`.
|
|
192
195
|
*/
|
|
193
196
|
export type ListSubscription = ListSubscriptionFunctions & ListSubscriptionProperties;
|
|
197
|
+
export type ListSubscriptionOwnOptions = {
|
|
198
|
+
/**
|
|
199
|
+
* - A list instance to use instead of creating one.
|
|
200
|
+
*/
|
|
201
|
+
listInstance?: import("./listInstance.js").ListInstance;
|
|
202
|
+
};
|
|
194
203
|
/**
|
|
195
204
|
* Defines the settings required to establish a list subscription, detailing how list instances should handle updates
|
|
196
205
|
* and subscriptions based on the given properties.
|
|
197
206
|
*/
|
|
198
|
-
export type ListSubscriptionOptions =
|
|
207
|
+
export type ListSubscriptionOptions = import("./listInstance.js").ListInstanceOptions & ListSubscriptionOwnOptions;
|
package/types/use/loading.d.ts
CHANGED
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
* @typedef {Readonly<LoadingRef>} LoadingReadonlyRef
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @typedef {object} LoadingStatus
|
|
6
|
+
* @typedef {object} LoadingProperties
|
|
9
7
|
* @property {LoadingReadonlyRef} loading - Whether the component is loading.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} LoadingFunctions
|
|
10
11
|
* @property {() => void} setLoading - Set the loading state to true.
|
|
11
12
|
* @property {() => void} clearLoading - Set the loading state to false.
|
|
12
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* The loading state API.
|
|
16
|
+
*
|
|
17
|
+
* @typedef {LoadingProperties & LoadingFunctions} LoadingStatus
|
|
18
|
+
*/
|
|
13
19
|
/**
|
|
14
20
|
* A composable function for managing loading state.
|
|
15
21
|
*
|
|
@@ -18,14 +24,13 @@
|
|
|
18
24
|
export function useLoading(): LoadingStatus;
|
|
19
25
|
export type LoadingRef = import("vue").Ref<boolean | undefined>;
|
|
20
26
|
export type LoadingReadonlyRef = Readonly<LoadingRef>;
|
|
21
|
-
|
|
22
|
-
* The loading state API.
|
|
23
|
-
*/
|
|
24
|
-
export type LoadingStatus = {
|
|
27
|
+
export type LoadingProperties = {
|
|
25
28
|
/**
|
|
26
29
|
* - Whether the component is loading.
|
|
27
30
|
*/
|
|
28
31
|
loading: LoadingReadonlyRef;
|
|
32
|
+
};
|
|
33
|
+
export type LoadingFunctions = {
|
|
29
34
|
/**
|
|
30
35
|
* - Set the loading state to true.
|
|
31
36
|
*/
|
|
@@ -35,3 +40,7 @@ export type LoadingStatus = {
|
|
|
35
40
|
*/
|
|
36
41
|
clearLoading: () => void;
|
|
37
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* The loading state API.
|
|
45
|
+
*/
|
|
46
|
+
export type LoadingStatus = LoadingProperties & LoadingFunctions;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('./loading.js').
|
|
2
|
+
* @typedef {import('./loading.js').LoadingProperties & import('./error.js').ErrorProperties} LoadingErrorProperties
|
|
3
|
+
* @typedef {import('./loading.js').LoadingFunctions & import('./error.js').ErrorFunctions} LoadingErrorFunctions
|
|
4
|
+
* @typedef {LoadingErrorProperties & LoadingErrorFunctions} LoadingErrorStatus
|
|
3
5
|
*/
|
|
4
6
|
/**
|
|
5
7
|
* A composable function combining loading and error state management.
|
|
@@ -7,4 +9,6 @@
|
|
|
7
9
|
* @returns {LoadingErrorStatus} - An object containing reactive fields and actions for both loading and error state.
|
|
8
10
|
*/
|
|
9
11
|
export function useLoadingError(): LoadingErrorStatus;
|
|
10
|
-
export type
|
|
12
|
+
export type LoadingErrorProperties = import("./loading.js").LoadingProperties & import("./error.js").ErrorProperties;
|
|
13
|
+
export type LoadingErrorFunctions = import("./loading.js").LoadingFunctions & import("./error.js").ErrorFunctions;
|
|
14
|
+
export type LoadingErrorStatus = LoadingErrorProperties & LoadingErrorFunctions;
|
|
@@ -59,11 +59,11 @@ export function useObjectInstances(instanceArgs: {
|
|
|
59
59
|
* ```
|
|
60
60
|
*
|
|
61
61
|
* @param {ObjectInstanceOptions} options - The options to be passed to useObjectInstance.
|
|
62
|
-
* @returns {ObjectInstance} - An object used to manage create, retrieve, update, delete, and
|
|
62
|
+
* @returns {ObjectInstance} - An object used to manage create, retrieve, update, delete, patch, and executeAction operations.
|
|
63
63
|
*/
|
|
64
64
|
export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): ObjectInstance;
|
|
65
65
|
/**
|
|
66
|
-
* A composition function to manage create, retrieve, update, delete, and
|
|
66
|
+
* A composition function to manage create, retrieve, update, delete, patch, and executeAction operations.
|
|
67
67
|
*
|
|
68
68
|
* @module use/objectInstance.js
|
|
69
69
|
*/
|
|
@@ -92,7 +92,7 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
92
92
|
* Reactive arguments to be passed to the object instance.
|
|
93
93
|
*
|
|
94
94
|
* @typedef {object} ObjectInstanceRawProps
|
|
95
|
-
* @property {
|
|
95
|
+
* @property {import('../config/commonCrud.js').PkInput} [pk] - The pk of the object, optional to support creating new objects.
|
|
96
96
|
* @property {string} pkKey - The pk key of the object.
|
|
97
97
|
* @property {object} params - The arguments to be passed to the retrieve function.
|
|
98
98
|
* @property {import('../config/objectCrud.js').ObjectTarget} target - The arguments to be passed to the crud handlers.
|
|
@@ -106,13 +106,14 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
106
106
|
* @property {import('../config/objectCrud.js').CrudPatchFn} patch - The patch function.
|
|
107
107
|
* @property {import('../config/objectCrud.js').CrudDeleteFn} delete - The delete function.
|
|
108
108
|
* @property {import('../config/objectCrud.js').CrudObjectSubscribeFn} subscribe - The subscribe function.
|
|
109
|
+
* @property {import('../config/objectCrud.js').CrudObjectExecuteActionFn} executeAction - The executeAction function.
|
|
109
110
|
*/
|
|
110
111
|
/**
|
|
111
112
|
* The raw state of the object instance.
|
|
112
113
|
*
|
|
113
114
|
* @typedef {object} ObjectInstanceRawMyState
|
|
114
115
|
* @property {import('vue').Reactive<ObjectInstanceRawStateCrud>} crud - The crud handlers.
|
|
115
|
-
* @property {import('vue').Ref<
|
|
116
|
+
* @property {import('vue').Ref<import('../config/commonCrud.js').Pk|undefined>} pk - The pk of the object.
|
|
116
117
|
* @property {import('vue').Ref<string|undefined>} pkKey - The pk key of the object.
|
|
117
118
|
* @property {import('vue').Ref<{[key:string]: any}>} params - The arguments to be passed to the retrieve function.
|
|
118
119
|
* @property {import('vue').Reactive<CrudObject>} object - The object.
|
|
@@ -121,7 +122,7 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
121
122
|
/**
|
|
122
123
|
* The raw state of the object instance.
|
|
123
124
|
*
|
|
124
|
-
* @typedef {ObjectInstanceRawMyState &
|
|
125
|
+
* @typedef {ObjectInstanceRawMyState & import('./loadingError.js').LoadingErrorProperties} ObjectInstanceRawState
|
|
125
126
|
*/
|
|
126
127
|
/**
|
|
127
128
|
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors.
|
|
@@ -132,22 +133,26 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
132
133
|
/** @typedef {{ object: NewCrudObject }} ObjectInstanceCreateArgs */
|
|
133
134
|
/** @typedef {{ object: ExistingCrudObject }} ObjectInstanceUpdateArgs */
|
|
134
135
|
/** @typedef {{ partialObject: ExistingCrudObject }} ObjectInstancePatchArgs */
|
|
136
|
+
/**
|
|
137
|
+
* @typedef {{[key:string]: any}} AdditionalArgs
|
|
138
|
+
*/
|
|
135
139
|
/**
|
|
136
140
|
* The functions available on the object instance.
|
|
137
141
|
*
|
|
138
142
|
* @typedef {object} ObjectInstanceMyFunctions
|
|
139
|
-
* @property {(args: ObjectInstanceCreateArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} create - Called to turn the current object into a new object on the server.
|
|
140
|
-
* @property {(args?: import('./cancellableIntent.js').CommonRunTracking) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} retrieve - Called to retrieve the current object by pk from the server.
|
|
141
|
-
* @property {(args: ObjectInstanceUpdateArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} update - Called to update the current object on the server.
|
|
142
|
-
* @property {() => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} delete - Called to delete the current object on the server.
|
|
143
|
-
* @property {(args: ObjectInstancePatchArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} patch - Called to patch the current object on the server.
|
|
143
|
+
* @property {(args: ObjectInstanceCreateArgs & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} create - Called to turn the current object into a new object on the server.
|
|
144
|
+
* @property {(args?: Partial<import('./cancellableIntent.js').CommonRunTracking> & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} retrieve - Called to retrieve the current object by pk from the server.
|
|
145
|
+
* @property {(args: ObjectInstanceUpdateArgs & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} update - Called to update the current object on the server.
|
|
146
|
+
* @property {(args?: AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} delete - Called to delete the current object on the server.
|
|
147
|
+
* @property {(args: ObjectInstancePatchArgs & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} patch - Called to patch the current object on the server.
|
|
148
|
+
* @property {(args: {action: string} & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} executeAction - Called to execute certain action on the current object.
|
|
144
149
|
* @property {() => void} clear - Called to clear the object state.
|
|
145
150
|
*/
|
|
146
151
|
/**
|
|
147
152
|
* The functions available on the object instance, including the ability to clear LoadingError errors.
|
|
148
153
|
*
|
|
149
154
|
* @typedef {(
|
|
150
|
-
*
|
|
155
|
+
* import('./error.js').ErrorReadOnlyFunctions &
|
|
151
156
|
* ObjectInstanceMyFunctions
|
|
152
157
|
* )} ObjectInstanceFunctions
|
|
153
158
|
*/
|
|
@@ -212,7 +217,7 @@ export type ObjectInstanceRawProps = {
|
|
|
212
217
|
/**
|
|
213
218
|
* - The pk of the object, optional to support creating new objects.
|
|
214
219
|
*/
|
|
215
|
-
pk?:
|
|
220
|
+
pk?: import("../config/commonCrud.js").PkInput;
|
|
216
221
|
/**
|
|
217
222
|
* - The pk key of the object.
|
|
218
223
|
*/
|
|
@@ -255,6 +260,10 @@ export type ObjectInstanceRawStateCrud = {
|
|
|
255
260
|
* - The subscribe function.
|
|
256
261
|
*/
|
|
257
262
|
subscribe: import("../config/objectCrud.js").CrudObjectSubscribeFn;
|
|
263
|
+
/**
|
|
264
|
+
* - The executeAction function.
|
|
265
|
+
*/
|
|
266
|
+
executeAction: import("../config/objectCrud.js").CrudObjectExecuteActionFn;
|
|
258
267
|
};
|
|
259
268
|
/**
|
|
260
269
|
* The raw state of the object instance.
|
|
@@ -267,7 +276,7 @@ export type ObjectInstanceRawMyState = {
|
|
|
267
276
|
/**
|
|
268
277
|
* - The pk of the object.
|
|
269
278
|
*/
|
|
270
|
-
pk: import("vue").Ref<
|
|
279
|
+
pk: import("vue").Ref<import("../config/commonCrud.js").Pk | undefined>;
|
|
271
280
|
/**
|
|
272
281
|
* - The pk key of the object.
|
|
273
282
|
*/
|
|
@@ -290,7 +299,7 @@ export type ObjectInstanceRawMyState = {
|
|
|
290
299
|
/**
|
|
291
300
|
* The raw state of the object instance.
|
|
292
301
|
*/
|
|
293
|
-
export type ObjectInstanceRawState = ObjectInstanceRawMyState &
|
|
302
|
+
export type ObjectInstanceRawState = ObjectInstanceRawMyState & import("./loadingError.js").LoadingErrorProperties;
|
|
294
303
|
/**
|
|
295
304
|
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors.
|
|
296
305
|
* Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
@@ -305,6 +314,9 @@ export type ObjectInstanceUpdateArgs = {
|
|
|
305
314
|
export type ObjectInstancePatchArgs = {
|
|
306
315
|
partialObject: ExistingCrudObject;
|
|
307
316
|
};
|
|
317
|
+
export type AdditionalArgs = {
|
|
318
|
+
[key: string]: any;
|
|
319
|
+
};
|
|
308
320
|
/**
|
|
309
321
|
* The functions available on the object instance.
|
|
310
322
|
*/
|
|
@@ -312,23 +324,29 @@ export type ObjectInstanceMyFunctions = {
|
|
|
312
324
|
/**
|
|
313
325
|
* - Called to turn the current object into a new object on the server.
|
|
314
326
|
*/
|
|
315
|
-
create: (args: ObjectInstanceCreateArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
327
|
+
create: (args: ObjectInstanceCreateArgs & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
316
328
|
/**
|
|
317
329
|
* - Called to retrieve the current object by pk from the server.
|
|
318
330
|
*/
|
|
319
|
-
retrieve: (args?: import("./cancellableIntent.js").CommonRunTracking) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
331
|
+
retrieve: (args?: Partial<import("./cancellableIntent.js").CommonRunTracking> & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
320
332
|
/**
|
|
321
333
|
* - Called to update the current object on the server.
|
|
322
334
|
*/
|
|
323
|
-
update: (args: ObjectInstanceUpdateArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
335
|
+
update: (args: ObjectInstanceUpdateArgs & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
324
336
|
/**
|
|
325
337
|
* - Called to delete the current object on the server.
|
|
326
338
|
*/
|
|
327
|
-
delete: () => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
339
|
+
delete: (args?: AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
328
340
|
/**
|
|
329
341
|
* - Called to patch the current object on the server.
|
|
330
342
|
*/
|
|
331
|
-
patch: (args: ObjectInstancePatchArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
343
|
+
patch: (args: ObjectInstancePatchArgs & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
344
|
+
/**
|
|
345
|
+
* - Called to execute certain action on the current object.
|
|
346
|
+
*/
|
|
347
|
+
executeAction: (args: {
|
|
348
|
+
action: string;
|
|
349
|
+
} & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
332
350
|
/**
|
|
333
351
|
* - Called to clear the object state.
|
|
334
352
|
*/
|
|
@@ -337,7 +355,7 @@ export type ObjectInstanceMyFunctions = {
|
|
|
337
355
|
/**
|
|
338
356
|
* The functions available on the object instance, including the ability to clear LoadingError errors.
|
|
339
357
|
*/
|
|
340
|
-
export type ObjectInstanceFunctions = (
|
|
358
|
+
export type ObjectInstanceFunctions = (import("./error.js").ErrorReadOnlyFunctions & ObjectInstanceMyFunctions);
|
|
341
359
|
/**
|
|
342
360
|
* The properties of the object instance.
|
|
343
361
|
*/
|
|
@@ -43,14 +43,17 @@
|
|
|
43
43
|
* @property {boolean|undefined} intendToSubscribe - Whether the object intends to subscribe.
|
|
44
44
|
*/
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @typedef {object & import('./objectInstance.js').ObjectInstanceOptions} ObjectSubscriptionOptions
|
|
46
|
+
* @typedef {object} ObjectSubscriptionOwnOptions
|
|
49
47
|
* @property {import('./objectInstance.js').ObjectInstance} [objectInstance] - An object instance to use instead of creating a new one.
|
|
50
48
|
* @property {import('vue').UnwrapNestedRefs<(
|
|
51
49
|
* ObjectSubscriptionRawProps & import('./objectInstance.js').ObjectInstanceRawProps
|
|
52
50
|
* )>} props - The reactive args to be passed to useObjectInstance.
|
|
53
|
-
* @property {import('
|
|
51
|
+
* @property {import('../config/objectCrud.js').ObjectCrudHandlers} [handlers] - The handlers to be passed to useObjectInstance.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Options for initializing an object subscription, including reactive props and non-reactive handlers.
|
|
55
|
+
*
|
|
56
|
+
* @typedef {ObjectSubscriptionOwnOptions & import('./objectInstance.js').ObjectInstanceOptions} ObjectSubscriptionOptions
|
|
54
57
|
*/
|
|
55
58
|
/**
|
|
56
59
|
* Initializes multiple object subscriptions based on provided arguments.
|
|
@@ -208,10 +211,24 @@ export type ObjectSubscriptionRawProps = {
|
|
|
208
211
|
*/
|
|
209
212
|
intendToSubscribe: boolean | undefined;
|
|
210
213
|
};
|
|
214
|
+
export type ObjectSubscriptionOwnOptions = {
|
|
215
|
+
/**
|
|
216
|
+
* - An object instance to use instead of creating a new one.
|
|
217
|
+
*/
|
|
218
|
+
objectInstance?: import("./objectInstance.js").ObjectInstance;
|
|
219
|
+
/**
|
|
220
|
+
* - The reactive args to be passed to useObjectInstance.
|
|
221
|
+
*/
|
|
222
|
+
props: import("vue").UnwrapNestedRefs<(ObjectSubscriptionRawProps & import("./objectInstance.js").ObjectInstanceRawProps)>;
|
|
223
|
+
/**
|
|
224
|
+
* - The handlers to be passed to useObjectInstance.
|
|
225
|
+
*/
|
|
226
|
+
handlers?: import("../config/objectCrud.js").ObjectCrudHandlers;
|
|
227
|
+
};
|
|
211
228
|
/**
|
|
212
229
|
* Options for initializing an object subscription, including reactive props and non-reactive handlers.
|
|
213
230
|
*/
|
|
214
|
-
export type ObjectSubscriptionOptions =
|
|
231
|
+
export type ObjectSubscriptionOptions = ObjectSubscriptionOwnOptions & import("./objectInstance.js").ObjectInstanceOptions;
|
|
215
232
|
/**
|
|
216
233
|
* The context bound to shared objectSubscription functions.
|
|
217
234
|
*/
|