@arrai-innovations/reactive-helpers 20.1.2 → 21.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/README.md +22 -893
- package/config/listCrud.js +30 -27
- package/config/objectCrud.js +20 -13
- package/index.js +5 -3
- package/package.json +5 -3
- package/types/config/commonCrud.d.ts +0 -1
- package/types/config/listCrud.d.ts +28 -41
- package/types/config/objectCrud.d.ts +14 -29
- package/types/index.d.ts +5 -4
- package/types/tests/unit/config/listCrud.spec.d.ts +0 -1
- package/types/tests/unit/config/objectCrud.spec.d.ts +0 -1
- package/types/tests/unit/crudPromise.d.ts +42 -15
- package/types/tests/unit/mockOnUnmounted.d.ts +0 -1
- package/types/tests/unit/poll.d.ts +0 -1
- package/types/tests/unit/scopedIt.d.ts +15 -0
- package/types/tests/unit/setup.d.ts +2 -0
- package/types/tests/unit/use/cancellableIntent.spec.d.ts +0 -1
- package/types/tests/unit/use/combineClasses.spec.d.ts +1 -0
- package/types/tests/unit/use/list.spec.d.ts +1 -0
- package/types/tests/unit/use/listCalculated.spec.d.ts +0 -1
- package/types/tests/unit/use/listFilter.spec.d.ts +0 -1
- package/types/tests/unit/use/listInstance.spec.d.ts +0 -1
- package/types/tests/unit/use/listRelated.spec.d.ts +0 -1
- package/types/tests/unit/use/listSearch.spec.d.ts +0 -1
- package/types/tests/unit/use/listSort.spec.d.ts +0 -1
- package/types/tests/unit/use/listSubscription.spec.d.ts +0 -1
- package/types/tests/unit/use/loadingError.spec.d.ts +0 -1
- package/types/tests/unit/use/object.spec.d.ts +1 -0
- package/types/tests/unit/use/objectCalculated.spec.d.ts +1 -0
- package/types/tests/unit/use/objectInstance.spec.d.ts +0 -1
- package/types/tests/unit/use/objectRelated.spec.d.ts +1 -0
- package/types/tests/unit/use/objectSubscription.spec.d.ts +0 -1
- package/types/tests/unit/use/proxyLoadingError.spec.d.ts +0 -1
- package/types/tests/unit/use/search.error.spec.d.ts +1 -0
- package/types/tests/unit/use/search.spec.d.ts +0 -1
- package/types/tests/unit/utils/assignReactiveObject.extra.spec.d.ts +1 -0
- package/types/tests/unit/utils/assignReactiveObject.refs.spec.d.ts +1 -0
- package/types/tests/unit/utils/assignReactiveObject.spec.d.ts +0 -1
- package/types/tests/unit/utils/cancellableFetch.spec.d.ts +1 -0
- package/types/tests/unit/utils/classes.spec.d.ts +0 -1
- package/types/tests/unit/utils/compact.spec.d.ts +1 -0
- package/types/tests/unit/utils/deepUnref.spec.d.ts +1 -0
- package/types/tests/unit/utils/deleteKey.spec.d.ts +0 -1
- package/types/tests/unit/utils/flattenPaths.spec.d.ts +0 -1
- package/types/tests/unit/utils/flattenPathsWithValues.spec.d.ts +1 -0
- package/types/tests/unit/utils/getFakePk.spec.d.ts +1 -0
- package/types/tests/unit/utils/keepAliveTry.spec.d.ts +1 -0
- package/types/tests/unit/utils/keyDiff.spec.d.ts +0 -1
- package/types/tests/unit/utils/set.spec.d.ts +0 -1
- package/types/tests/unit/utils/transformWalk.spec.d.ts +1 -0
- package/types/tests/unit/utils/unwrapNested.spec.d.ts +1 -0
- package/types/tests/unit/utils/watches.spec.d.ts +0 -1
- package/types/use/cancellableIntent.d.ts +121 -48
- package/types/use/combineClasses.d.ts +0 -1
- package/types/use/error.d.ts +48 -0
- package/types/use/list.d.ts +9 -32
- package/types/use/listCalculated.d.ts +107 -49
- package/types/use/listFilter.d.ts +13 -31
- package/types/use/listInstance.d.ts +137 -71
- package/types/use/listRelated.d.ts +106 -43
- package/types/use/listSearch.d.ts +24 -12
- package/types/use/listSort.d.ts +3 -34
- package/types/use/listSubscription.d.ts +40 -57
- package/types/use/loading.d.ts +37 -0
- package/types/use/loadingError.d.ts +5 -100
- package/types/use/object.d.ts +3 -12
- package/types/use/objectCalculated.d.ts +3 -9
- package/types/use/objectInstance.d.ts +59 -47
- package/types/use/objectRelated.d.ts +3 -9
- package/types/use/objectSubscription.d.ts +33 -51
- package/types/use/proxyError.d.ts +27 -0
- package/types/use/proxyLoading.d.ts +15 -0
- package/types/use/proxyLoadingError.d.ts +8 -16
- package/types/use/search.d.ts +2 -3
- package/types/utils/assignReactiveObject.d.ts +0 -1
- package/types/utils/cancellableFetch.d.ts +0 -1
- package/types/utils/cancellablePromise.d.ts +0 -1
- package/types/utils/classes.d.ts +2 -8
- package/types/utils/compact.d.ts +0 -1
- package/types/utils/deepUnref.d.ts +2 -23
- package/types/utils/deleteKey.d.ts +6 -6
- package/types/utils/flattenPaths.d.ts +0 -1
- package/types/utils/flattenPathsWithValues.d.ts +29 -0
- package/types/utils/getFakePk.d.ts +0 -1
- package/types/utils/keepAliveTry.d.ts +0 -1
- package/types/utils/keyDiff.d.ts +9 -10
- package/types/utils/loadingCombine.d.ts +0 -1
- package/types/utils/proxyRunning.d.ts +2 -3
- package/types/utils/refIfReactive.d.ts +0 -1
- package/types/utils/relatedCalculatedHelpers.d.ts +0 -1
- package/types/utils/set.d.ts +0 -1
- package/types/utils/transformWalk.d.ts +0 -1
- package/types/utils/unwrapNested.d.ts +0 -1
- package/types/utils/watches.d.ts +0 -1
- package/use/cancellableIntent.js +185 -100
- package/use/error.js +44 -0
- package/use/list.js +51 -111
- package/use/listCalculated.js +75 -98
- package/use/listFilter.js +91 -186
- package/use/listInstance.js +357 -282
- package/use/listRelated.js +52 -72
- package/use/listSearch.js +49 -86
- package/use/listSort.js +121 -237
- package/use/listSubscription.js +181 -274
- package/use/loading.js +35 -0
- package/use/loadingError.js +7 -81
- package/use/object.js +47 -67
- package/use/objectCalculated.js +103 -65
- package/use/objectInstance.js +253 -241
- package/use/objectRelated.js +48 -30
- package/use/objectSubscription.js +110 -175
- package/use/proxyError.js +48 -0
- package/use/proxyLoading.js +22 -0
- package/use/proxyLoadingError.js +9 -35
- package/use/search.js +4 -2
- package/utils/assignReactiveObject.js +8 -8
- package/utils/classes.js +7 -28
- package/utils/deepUnref.js +15 -2
- package/utils/deleteKey.js +13 -5
- package/utils/flattenPathsWithValues.js +65 -0
- package/utils/keyDiff.js +5 -5
- package/utils/proxyRunning.js +16 -10
- package/types/config/commonCrud.d.ts.map +0 -1
- package/types/config/listCrud.d.ts.map +0 -1
- package/types/config/objectCrud.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/tests/unit/config/listCrud.spec.d.ts.map +0 -1
- package/types/tests/unit/config/objectCrud.spec.d.ts.map +0 -1
- package/types/tests/unit/crudPromise.d.ts.map +0 -1
- package/types/tests/unit/expectHelpers.d.ts +0 -2
- package/types/tests/unit/expectHelpers.d.ts.map +0 -1
- package/types/tests/unit/mockOnUnmounted.d.ts.map +0 -1
- package/types/tests/unit/poll.d.ts.map +0 -1
- package/types/tests/unit/use/cancellableIntent.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listCalculated.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listFilter.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listInstance.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listRelated.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listSearch.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listSort.spec.d.ts.map +0 -1
- package/types/tests/unit/use/listSubscription.spec.d.ts.map +0 -1
- package/types/tests/unit/use/loadingError.spec.d.ts.map +0 -1
- package/types/tests/unit/use/objectInstance.spec.d.ts.map +0 -1
- package/types/tests/unit/use/objectSubscription.spec.d.ts.map +0 -1
- package/types/tests/unit/use/proxyLoadingError.spec.d.ts.map +0 -1
- package/types/tests/unit/use/search.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/assignReactiveObject.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/classes.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/deleteKey.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/flattenPaths.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/keyDiff.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/set.spec.d.ts.map +0 -1
- package/types/tests/unit/utils/watches.spec.d.ts.map +0 -1
- package/types/use/cancellableIntent.d.ts.map +0 -1
- package/types/use/combineClasses.d.ts.map +0 -1
- package/types/use/list.d.ts.map +0 -1
- package/types/use/listCalculated.d.ts.map +0 -1
- package/types/use/listFilter.d.ts.map +0 -1
- package/types/use/listInstance.d.ts.map +0 -1
- package/types/use/listKeys.d.ts +0 -15
- package/types/use/listKeys.d.ts.map +0 -1
- package/types/use/listRelated.d.ts.map +0 -1
- package/types/use/listSearch.d.ts.map +0 -1
- package/types/use/listSort.d.ts.map +0 -1
- package/types/use/listSubscription.d.ts.map +0 -1
- package/types/use/loadingError.d.ts.map +0 -1
- package/types/use/object.d.ts.map +0 -1
- package/types/use/objectCalculated.d.ts.map +0 -1
- package/types/use/objectInstance.d.ts.map +0 -1
- package/types/use/objectRelated.d.ts.map +0 -1
- package/types/use/objectSubscription.d.ts.map +0 -1
- package/types/use/paginatedListInstance.d.ts +0 -60
- package/types/use/paginatedListInstance.d.ts.map +0 -1
- package/types/use/proxyLoadingError.d.ts.map +0 -1
- package/types/use/search.d.ts.map +0 -1
- package/types/use/watchesRunning.d.ts +0 -63
- package/types/use/watchesRunning.d.ts.map +0 -1
- package/types/utils/assignReactiveObject.d.ts.map +0 -1
- package/types/utils/cancellableFetch.d.ts.map +0 -1
- package/types/utils/cancellablePromise.d.ts.map +0 -1
- package/types/utils/classes.d.ts.map +0 -1
- package/types/utils/compact.d.ts.map +0 -1
- package/types/utils/deepUnref.d.ts.map +0 -1
- package/types/utils/deleteKey.d.ts.map +0 -1
- package/types/utils/flattenPaths.d.ts.map +0 -1
- package/types/utils/getFakePk.d.ts.map +0 -1
- package/types/utils/keepAliveTry.d.ts.map +0 -1
- package/types/utils/keyDiff.d.ts.map +0 -1
- package/types/utils/loadingCombine.d.ts.map +0 -1
- package/types/utils/proxyRunning.d.ts.map +0 -1
- package/types/utils/refIfReactive.d.ts.map +0 -1
- package/types/utils/relatedCalculatedHelpers.d.ts.map +0 -1
- package/types/utils/set.d.ts.map +0 -1
- package/types/utils/transformWalk.d.ts.map +0 -1
- package/types/utils/unwrapNested.d.ts.map +0 -1
- package/types/utils/watches.d.ts.map +0 -1
- package/use/listKeys.js +0 -105
- package/use/paginatedListInstance.js +0 -126
- package/use/watchesRunning.js +0 -69
package/config/listCrud.js
CHANGED
|
@@ -9,88 +9,91 @@ import { readonly } from "vue";
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @typedef {
|
|
13
|
-
* @property {number} [totalRecords] - The total records.
|
|
14
|
-
* @property {number} [totalPages] - The total pages.
|
|
15
|
-
* @property {number} [perPage] - The per page.
|
|
16
|
-
* @property {number} [page] - The page you are giving us results for.
|
|
12
|
+
* @typedef {import("../use/listInstance.js").ClearListFn} ClearObjectsFn
|
|
17
13
|
*/
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
|
-
* @typedef {(
|
|
21
|
-
* newObjects:import('../use/listInstance.js').ListObject,
|
|
22
|
-
* paginationInfo?: PaginateInfo,
|
|
23
|
-
* )=>void} PageCallback
|
|
16
|
+
* @typedef {import("../use/listInstance.js").SetPaginateInfoFn} SetPaginateInfo
|
|
24
17
|
*/
|
|
25
18
|
|
|
26
19
|
/**
|
|
27
|
-
* @typedef {
|
|
28
|
-
|
|
20
|
+
* @typedef {import("../use/listInstance.js").SetColumnTotalsFn} SetColumnTotals
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {object} ListArgsRaw
|
|
24
|
+
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
29
25
|
* @property {string} pkKey - The key name of the primary key.
|
|
30
26
|
* @property {object} params - The arguments to be passed for list crud handlers.
|
|
31
|
-
* @property {
|
|
27
|
+
* @property {import("../use/listInstance.js").PushObjectsFn} pushObjects - The method to call with new page(s) of data received.
|
|
28
|
+
* @property {ClearObjectsFn} clearObjects - The method to call to clear the objects.
|
|
32
29
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to a boolean indicating whether the request has
|
|
33
30
|
* been cancelled.
|
|
31
|
+
* @property {SetPaginateInfo} setPaginateInfo - The method to update pagination information.
|
|
32
|
+
* @property {SetColumnTotals} setColumnTotals - The method to update column totals.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {ListArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking>} ListArgs
|
|
34
37
|
*/
|
|
35
38
|
|
|
36
39
|
/**
|
|
37
40
|
* @typedef {object} BulkDeleteArgs
|
|
38
|
-
* @property {
|
|
41
|
+
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
39
42
|
* @property {string[]} pks - The ids of the objects to be deleted.
|
|
40
43
|
* @property {string} pkKey - The key name of the primary key.
|
|
41
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to a boolean indicating whether the request has
|
|
42
|
-
* been cancelled.
|
|
43
44
|
*/
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* @typedef {(
|
|
47
|
-
* newOrUpdatedOrDeleteObject:import('../use/
|
|
48
|
+
* newOrUpdatedOrDeleteObject:import('../use/objectInstance.js').ExistingCrudObject|string,
|
|
48
49
|
* action: 'create'|'update'|'delete'
|
|
49
|
-
* )=>void}
|
|
50
|
+
* )=>void} applyObjectEvent
|
|
50
51
|
*/
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
|
-
* @typedef {object}
|
|
54
|
-
* @property {
|
|
54
|
+
* @typedef {object} ListSubscribeArgsRaw
|
|
55
|
+
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
55
56
|
* @property {string} pkKey - The key name of the primary key.
|
|
56
57
|
* @property {object} params - The arguments to be passed for list crud handlers.
|
|
57
|
-
* @property {
|
|
58
|
+
* @property {applyObjectEvent} applyObjectEvent - The method to call when new data is received.
|
|
58
59
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to a boolean indicating whether the request has
|
|
59
60
|
* been cancelled.
|
|
60
61
|
*/
|
|
61
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {ListSubscribeArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking>} ListSubscribeArgs
|
|
65
|
+
*/
|
|
66
|
+
|
|
62
67
|
/**
|
|
63
68
|
* @typedef {object} ExecuteActionArgs
|
|
64
|
-
* @property {
|
|
69
|
+
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
65
70
|
* @property {string[]} pks - The ids of the objects to be acted upon.
|
|
66
71
|
* @property {string} pkKey - The key name of the primary key.
|
|
67
72
|
* @property {string} action - The action to execute.
|
|
68
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to a boolean indicating whether the request has
|
|
69
|
-
* been cancelled.
|
|
70
73
|
*/
|
|
71
74
|
|
|
72
75
|
/**
|
|
73
76
|
* @callback CrudListFn
|
|
74
77
|
* @param {ListArgs} args - The arguments to be passed to the crud handlers.
|
|
75
|
-
* @returns {import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} - A promise
|
|
78
|
+
* @returns {import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} - A cancellable promise for the list request.
|
|
76
79
|
*/
|
|
77
80
|
|
|
78
81
|
/**
|
|
79
82
|
* @callback CrudBulkDeleteFn
|
|
80
83
|
* @param {BulkDeleteArgs} args - The arguments to be passed to the crud handlers.
|
|
81
|
-
* @returns {
|
|
84
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating success.
|
|
82
85
|
*/
|
|
83
86
|
|
|
84
87
|
/**
|
|
85
88
|
* @callback CrudListSubscribeFn
|
|
86
89
|
* @param {ListSubscribeArgs} args - The arguments to be passed to the crud handlers.
|
|
87
|
-
* @returns {import('../utils/cancellablePromise.js').CancellablePromise<void>} - A promise
|
|
90
|
+
* @returns {import('../utils/cancellablePromise.js').CancellablePromise<void>} - A cancellable promise for the subscription.
|
|
88
91
|
*/
|
|
89
92
|
|
|
90
93
|
/**
|
|
91
94
|
* @callback CrudExecuteActionFn
|
|
92
95
|
* @param {ExecuteActionArgs} args - The arguments to be passed to the crud handlers.
|
|
93
|
-
* @returns {
|
|
96
|
+
* @returns {Promise<object|string|null>} - A promise that resolves the result of the action, returned to the executor.
|
|
94
97
|
*/
|
|
95
98
|
|
|
96
99
|
/**
|
package/config/objectCrud.js
CHANGED
|
@@ -9,24 +9,24 @@ import { readonly } from "vue";
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @typedef {{[key:string]: any}}
|
|
12
|
+
* @typedef {{[key:string]: any}} TargetArgs
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Defines the CRUD-related handlers and additional utilities provided by the object instance.
|
|
17
17
|
*
|
|
18
18
|
* @typedef {object} ObjectTargetProperties
|
|
19
|
-
* @property {
|
|
19
|
+
* @property {TargetArgs} args - The arguments to be passed to the crud handlers.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @typedef {object} ObjectTargetOption
|
|
24
|
-
* @property {
|
|
24
|
+
* @property {TargetArgs} [target={}] - The arguments to be passed to the crud handlers.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @typedef {object} CreateArgs
|
|
29
|
-
* @property {
|
|
29
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
30
30
|
* @property {{[key:string]: any}} object - The data to be acted upon.
|
|
31
31
|
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
32
32
|
* @property {string} pkKey - The key name of the primary key.
|
|
@@ -34,17 +34,21 @@ import { readonly } from "vue";
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* @typedef {object}
|
|
38
|
-
* @property {
|
|
37
|
+
* @typedef {object} RetrieveArgsRaw
|
|
38
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
39
39
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
40
40
|
* @property {string} pkKey - The key name of the primary key.
|
|
41
41
|
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
42
42
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {RetrieveArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking} RetrieveArgs
|
|
47
|
+
*/
|
|
48
|
+
|
|
45
49
|
/**
|
|
46
50
|
* @typedef {object} UpdateArgs
|
|
47
|
-
* @property {
|
|
51
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
48
52
|
* @property {import('../use/objectInstance.js').ExistingCrudObject} object - The data to be acted upon.
|
|
49
53
|
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
50
54
|
* @property {string} pkKey - The key name of the primary key.
|
|
@@ -53,15 +57,14 @@ import { readonly } from "vue";
|
|
|
53
57
|
|
|
54
58
|
/**
|
|
55
59
|
* @typedef {object} DeleteArgs
|
|
56
|
-
* @property {
|
|
60
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
57
61
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
58
62
|
* @property {string} pkKey - The key name of the primary key.
|
|
59
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
60
63
|
*/
|
|
61
64
|
|
|
62
65
|
/**
|
|
63
66
|
* @typedef {object} PartialArgs
|
|
64
|
-
* @property {
|
|
67
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
65
68
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
66
69
|
* @property {string} pkKey - The key name of the primary key.
|
|
67
70
|
* @property {{[key:string]: any}} partialObject - The data to be acted upon.
|
|
@@ -72,12 +75,12 @@ import { readonly } from "vue";
|
|
|
72
75
|
/**
|
|
73
76
|
* @callback CrudSubscribeCallback
|
|
74
77
|
* @param {import('../use/objectInstance.js').ExistingCrudObject} data - The data to be passed to the callback.
|
|
75
|
-
* @param {
|
|
78
|
+
* @param {"delete"|"update"|"create"} action - The action that was performed.
|
|
76
79
|
*/
|
|
77
80
|
|
|
78
81
|
/**
|
|
79
|
-
* @typedef {object}
|
|
80
|
-
* @property {
|
|
82
|
+
* @typedef {object} ObjectSubscribeArgsRaw
|
|
83
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
81
84
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
82
85
|
* @property {string} pkKey - The key name of the primary key.
|
|
83
86
|
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
@@ -85,6 +88,10 @@ import { readonly } from "vue";
|
|
|
85
88
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
86
89
|
*/
|
|
87
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {ObjectSubscribeArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking} ObjectSubscribeArgs
|
|
93
|
+
*/
|
|
94
|
+
|
|
88
95
|
/**
|
|
89
96
|
* @typedef {import('../utils/cancellablePromise.js').MaybeCancellablePromise<object|string>} CrudResponse
|
|
90
97
|
*/
|
package/index.js
CHANGED
|
@@ -3,25 +3,26 @@ export * from "./config/listCrud.js";
|
|
|
3
3
|
export * from "./config/objectCrud.js";
|
|
4
4
|
export * from "./use/cancellableIntent.js";
|
|
5
5
|
export * from "./use/combineClasses.js";
|
|
6
|
+
export * from "./use/error.js";
|
|
6
7
|
export * from "./use/list.js";
|
|
7
8
|
export * from "./use/listCalculated.js";
|
|
8
9
|
export * from "./use/listFilter.js";
|
|
9
10
|
export * from "./use/listInstance.js";
|
|
10
|
-
export * from "./use/listKeys.js";
|
|
11
11
|
export * from "./use/listRelated.js";
|
|
12
12
|
export * from "./use/listSearch.js";
|
|
13
13
|
export * from "./use/listSort.js";
|
|
14
14
|
export * from "./use/listSubscription.js";
|
|
15
|
+
export * from "./use/loading.js";
|
|
15
16
|
export * from "./use/loadingError.js";
|
|
16
17
|
export * from "./use/object.js";
|
|
17
18
|
export * from "./use/objectCalculated.js";
|
|
18
19
|
export * from "./use/objectInstance.js";
|
|
19
20
|
export * from "./use/objectRelated.js";
|
|
20
21
|
export * from "./use/objectSubscription.js";
|
|
21
|
-
export * from "./use/
|
|
22
|
+
export * from "./use/proxyError.js";
|
|
22
23
|
export * from "./use/proxyLoadingError.js";
|
|
24
|
+
export * from "./use/proxyLoading.js";
|
|
23
25
|
export * from "./use/search.js";
|
|
24
|
-
export * from "./use/watchesRunning.js";
|
|
25
26
|
export * from "./utils/assignReactiveObject.js";
|
|
26
27
|
export * from "./utils/cancellableFetch.js";
|
|
27
28
|
export * from "./utils/cancellablePromise.js";
|
|
@@ -30,6 +31,7 @@ export * from "./utils/compact.js";
|
|
|
30
31
|
export * from "./utils/deepUnref.js";
|
|
31
32
|
export * from "./utils/deleteKey.js";
|
|
32
33
|
export * from "./utils/flattenPaths.js";
|
|
34
|
+
export * from "./utils/flattenPathsWithValues.js";
|
|
33
35
|
export * from "./utils/getFakePk.js";
|
|
34
36
|
export * from "./utils/keepAliveTry.js";
|
|
35
37
|
export * from "./utils/keyDiff.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrai-innovations/reactive-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0",
|
|
4
4
|
"description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"coverage": "npm test -- run --coverage=true",
|
|
32
32
|
"prepare": "npx --no-install husky",
|
|
33
33
|
"docs": "node make_type_doc.js",
|
|
34
|
-
"docs:check": "node check_type_doc.js"
|
|
34
|
+
"docs:check": "node check_type_doc.js",
|
|
35
|
+
"docs:clean": "node clean_type_doc.js"
|
|
35
36
|
},
|
|
36
37
|
"repository": {
|
|
37
38
|
"type": "git",
|
|
@@ -52,7 +53,8 @@
|
|
|
52
53
|
"@types/lodash-es": "^4.17.12",
|
|
53
54
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
54
55
|
"@typescript-eslint/parser": "^7.18.0",
|
|
55
|
-
"@vitest/coverage-
|
|
56
|
+
"@vitest/coverage-istanbul": "^3.1.4",
|
|
57
|
+
"@vitest/coverage-v8": "^3.1.4",
|
|
56
58
|
"@vue/compiler-sfc": "^3.4.37",
|
|
57
59
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
58
60
|
"@vue/test-utils": "^2.3.2",
|
|
@@ -16,4 +16,3 @@ export function assignCrud(target: object, defaultCrud: object, { props, handler
|
|
|
16
16
|
export function missingMethod(name: string): (...args: any[]) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<any>;
|
|
17
17
|
export function requiredCancelMissingMethod(name: string): ((..._args: any[]) => import("../utils/cancellablePromise.js").CancellablePromise<void>);
|
|
18
18
|
export function createDefaultCrud(keys: string[], cancellableKeys?: Set<string>): object;
|
|
19
|
-
//# sourceMappingURL=commonCrud.d.ts.map
|
|
@@ -9,30 +9,14 @@ export function getListCrud(target: import("vue").UnwrapNestedRefs<ListCrudHandl
|
|
|
9
9
|
props?: import("vue").UnwrapNestedRefs<ListTargetOption>;
|
|
10
10
|
handlers?: ListCrudHandlers;
|
|
11
11
|
}): void;
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
totalRecords?: number;
|
|
17
|
-
/**
|
|
18
|
-
* - The total pages.
|
|
19
|
-
*/
|
|
20
|
-
totalPages?: number;
|
|
21
|
-
/**
|
|
22
|
-
* - The per page.
|
|
23
|
-
*/
|
|
24
|
-
perPage?: number;
|
|
25
|
-
/**
|
|
26
|
-
* - The page you are giving us results for.
|
|
27
|
-
*/
|
|
28
|
-
page?: number;
|
|
29
|
-
};
|
|
30
|
-
export type PageCallback = (newObjects: import("../use/listInstance.js").ListObject, paginationInfo?: PaginateInfo) => void;
|
|
31
|
-
export type ListArgs = {
|
|
12
|
+
export type ClearObjectsFn = import("../use/listInstance.js").ClearListFn;
|
|
13
|
+
export type SetPaginateInfo = import("../use/listInstance.js").SetPaginateInfoFn;
|
|
14
|
+
export type SetColumnTotals = import("../use/listInstance.js").SetColumnTotalsFn;
|
|
15
|
+
export type ListArgsRaw = {
|
|
32
16
|
/**
|
|
33
17
|
* - The arguments to be passed to the crud handlers.
|
|
34
18
|
*/
|
|
35
|
-
target:
|
|
19
|
+
target: import("../config/objectCrud.js").TargetArgs;
|
|
36
20
|
/**
|
|
37
21
|
* - The key name of the primary key.
|
|
38
22
|
*/
|
|
@@ -44,18 +28,31 @@ export type ListArgs = {
|
|
|
44
28
|
/**
|
|
45
29
|
* - The method to call with new page(s) of data received.
|
|
46
30
|
*/
|
|
47
|
-
|
|
31
|
+
pushObjects: import("../use/listInstance.js").PushObjectsFn;
|
|
32
|
+
/**
|
|
33
|
+
* - The method to call to clear the objects.
|
|
34
|
+
*/
|
|
35
|
+
clearObjects: ClearObjectsFn;
|
|
48
36
|
/**
|
|
49
37
|
* - A ref to a boolean indicating whether the request has
|
|
50
38
|
* been cancelled.
|
|
51
39
|
*/
|
|
52
40
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
41
|
+
/**
|
|
42
|
+
* - The method to update pagination information.
|
|
43
|
+
*/
|
|
44
|
+
setPaginateInfo: SetPaginateInfo;
|
|
45
|
+
/**
|
|
46
|
+
* - The method to update column totals.
|
|
47
|
+
*/
|
|
48
|
+
setColumnTotals: SetColumnTotals;
|
|
53
49
|
};
|
|
50
|
+
export type ListArgs = ListArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking>;
|
|
54
51
|
export type BulkDeleteArgs = {
|
|
55
52
|
/**
|
|
56
53
|
* - The arguments to be passed to the crud handlers.
|
|
57
54
|
*/
|
|
58
|
-
target:
|
|
55
|
+
target: import("../config/objectCrud.js").TargetArgs;
|
|
59
56
|
/**
|
|
60
57
|
* - The ids of the objects to be deleted.
|
|
61
58
|
*/
|
|
@@ -64,18 +61,13 @@ export type BulkDeleteArgs = {
|
|
|
64
61
|
* - The key name of the primary key.
|
|
65
62
|
*/
|
|
66
63
|
pkKey: string;
|
|
67
|
-
/**
|
|
68
|
-
* - A ref to a boolean indicating whether the request has
|
|
69
|
-
* been cancelled.
|
|
70
|
-
*/
|
|
71
|
-
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
72
64
|
};
|
|
73
|
-
export type
|
|
74
|
-
export type
|
|
65
|
+
export type applyObjectEvent = (newOrUpdatedOrDeleteObject: import("../use/objectInstance.js").ExistingCrudObject | string, action: "create" | "update" | "delete") => void;
|
|
66
|
+
export type ListSubscribeArgsRaw = {
|
|
75
67
|
/**
|
|
76
68
|
* - The arguments to be passed to the crud handlers.
|
|
77
69
|
*/
|
|
78
|
-
target:
|
|
70
|
+
target: import("../config/objectCrud.js").TargetArgs;
|
|
79
71
|
/**
|
|
80
72
|
* - The key name of the primary key.
|
|
81
73
|
*/
|
|
@@ -87,18 +79,19 @@ export type ListSubscribeArgs = {
|
|
|
87
79
|
/**
|
|
88
80
|
* - The method to call when new data is received.
|
|
89
81
|
*/
|
|
90
|
-
|
|
82
|
+
applyObjectEvent: applyObjectEvent;
|
|
91
83
|
/**
|
|
92
84
|
* - A ref to a boolean indicating whether the request has
|
|
93
85
|
* been cancelled.
|
|
94
86
|
*/
|
|
95
87
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
96
88
|
};
|
|
89
|
+
export type ListSubscribeArgs = ListSubscribeArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking>;
|
|
97
90
|
export type ExecuteActionArgs = {
|
|
98
91
|
/**
|
|
99
92
|
* - The arguments to be passed to the crud handlers.
|
|
100
93
|
*/
|
|
101
|
-
target:
|
|
94
|
+
target: import("../config/objectCrud.js").TargetArgs;
|
|
102
95
|
/**
|
|
103
96
|
* - The ids of the objects to be acted upon.
|
|
104
97
|
*/
|
|
@@ -111,16 +104,11 @@ export type ExecuteActionArgs = {
|
|
|
111
104
|
* - The action to execute.
|
|
112
105
|
*/
|
|
113
106
|
action: string;
|
|
114
|
-
/**
|
|
115
|
-
* - A ref to a boolean indicating whether the request has
|
|
116
|
-
* been cancelled.
|
|
117
|
-
*/
|
|
118
|
-
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
119
107
|
};
|
|
120
108
|
export type CrudListFn = (args: ListArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
|
|
121
|
-
export type CrudBulkDeleteFn = (args: BulkDeleteArgs) =>
|
|
109
|
+
export type CrudBulkDeleteFn = (args: BulkDeleteArgs) => Promise<boolean>;
|
|
122
110
|
export type CrudListSubscribeFn = (args: ListSubscribeArgs) => import("../utils/cancellablePromise.js").CancellablePromise<void>;
|
|
123
|
-
export type CrudExecuteActionFn = (args: ExecuteActionArgs) =>
|
|
111
|
+
export type CrudExecuteActionFn = (args: ExecuteActionArgs) => Promise<object | string | null>;
|
|
124
112
|
export type ListCrudHandlers = {
|
|
125
113
|
/**
|
|
126
114
|
* - The list function to get a list of items.
|
|
@@ -151,4 +139,3 @@ export type ListTargetOption = {
|
|
|
151
139
|
*/
|
|
152
140
|
target?: object;
|
|
153
141
|
};
|
|
154
|
-
//# sourceMappingURL=listCrud.d.ts.map
|
|
@@ -9,7 +9,7 @@ export function getObjectCrud(target: import("vue").UnwrapNestedRefs<ObjectTarge
|
|
|
9
9
|
props?: import("vue").UnwrapNestedRefs<ObjectTargetOption>;
|
|
10
10
|
handlers?: ObjectCrudHandlers;
|
|
11
11
|
}): void;
|
|
12
|
-
export type
|
|
12
|
+
export type TargetArgs = {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
@@ -19,21 +19,19 @@ export type ObjectTargetProperties = {
|
|
|
19
19
|
/**
|
|
20
20
|
* - The arguments to be passed to the crud handlers.
|
|
21
21
|
*/
|
|
22
|
-
args:
|
|
22
|
+
args: TargetArgs;
|
|
23
23
|
};
|
|
24
24
|
export type ObjectTargetOption = {
|
|
25
25
|
/**
|
|
26
26
|
* - The arguments to be passed to the crud handlers.
|
|
27
27
|
*/
|
|
28
|
-
target?:
|
|
28
|
+
target?: TargetArgs;
|
|
29
29
|
};
|
|
30
30
|
export type CreateArgs = {
|
|
31
31
|
/**
|
|
32
32
|
* - The arguments to be passed to the crud handlers.
|
|
33
33
|
*/
|
|
34
|
-
target:
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
};
|
|
34
|
+
target: TargetArgs;
|
|
37
35
|
/**
|
|
38
36
|
* - The data to be acted upon.
|
|
39
37
|
*/
|
|
@@ -55,13 +53,11 @@ export type CreateArgs = {
|
|
|
55
53
|
*/
|
|
56
54
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
57
55
|
};
|
|
58
|
-
export type
|
|
56
|
+
export type RetrieveArgsRaw = {
|
|
59
57
|
/**
|
|
60
58
|
* - The arguments to be passed to the crud handlers.
|
|
61
59
|
*/
|
|
62
|
-
target:
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
};
|
|
60
|
+
target: TargetArgs;
|
|
65
61
|
/**
|
|
66
62
|
* - The pk of the object to be acted upon.
|
|
67
63
|
*/
|
|
@@ -81,13 +77,12 @@ export type RetrieveArgs = {
|
|
|
81
77
|
*/
|
|
82
78
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
83
79
|
};
|
|
80
|
+
export type RetrieveArgs = RetrieveArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking;
|
|
84
81
|
export type UpdateArgs = {
|
|
85
82
|
/**
|
|
86
83
|
* - The arguments to be passed to the crud handlers.
|
|
87
84
|
*/
|
|
88
|
-
target:
|
|
89
|
-
[key: string]: any;
|
|
90
|
-
};
|
|
85
|
+
target: TargetArgs;
|
|
91
86
|
/**
|
|
92
87
|
* - The data to be acted upon.
|
|
93
88
|
*/
|
|
@@ -111,9 +106,7 @@ export type DeleteArgs = {
|
|
|
111
106
|
/**
|
|
112
107
|
* - The arguments to be passed to the crud handlers.
|
|
113
108
|
*/
|
|
114
|
-
target:
|
|
115
|
-
[key: string]: any;
|
|
116
|
-
};
|
|
109
|
+
target: TargetArgs;
|
|
117
110
|
/**
|
|
118
111
|
* - The pk of the object to be acted upon.
|
|
119
112
|
*/
|
|
@@ -122,18 +115,12 @@ export type DeleteArgs = {
|
|
|
122
115
|
* - The key name of the primary key.
|
|
123
116
|
*/
|
|
124
117
|
pkKey: string;
|
|
125
|
-
/**
|
|
126
|
-
* - A ref to indicate if the request was cancelled.
|
|
127
|
-
*/
|
|
128
|
-
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
129
118
|
};
|
|
130
119
|
export type PartialArgs = {
|
|
131
120
|
/**
|
|
132
121
|
* - The arguments to be passed to the crud handlers.
|
|
133
122
|
*/
|
|
134
|
-
target:
|
|
135
|
-
[key: string]: any;
|
|
136
|
-
};
|
|
123
|
+
target: TargetArgs;
|
|
137
124
|
/**
|
|
138
125
|
* - The pk of the object to be acted upon.
|
|
139
126
|
*/
|
|
@@ -159,14 +146,12 @@ export type PartialArgs = {
|
|
|
159
146
|
*/
|
|
160
147
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
161
148
|
};
|
|
162
|
-
export type CrudSubscribeCallback = (data: import("../use/objectInstance.js").ExistingCrudObject, action:
|
|
163
|
-
export type
|
|
149
|
+
export type CrudSubscribeCallback = (data: import("../use/objectInstance.js").ExistingCrudObject, action: "delete" | "update" | "create") => any;
|
|
150
|
+
export type ObjectSubscribeArgsRaw = {
|
|
164
151
|
/**
|
|
165
152
|
* - The arguments to be passed to the crud handlers.
|
|
166
153
|
*/
|
|
167
|
-
target:
|
|
168
|
-
[key: string]: any;
|
|
169
|
-
};
|
|
154
|
+
target: TargetArgs;
|
|
170
155
|
/**
|
|
171
156
|
* - The pk of the object to be acted upon.
|
|
172
157
|
*/
|
|
@@ -190,6 +175,7 @@ export type ObjectSubscribeArgs = {
|
|
|
190
175
|
*/
|
|
191
176
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
192
177
|
};
|
|
178
|
+
export type ObjectSubscribeArgs = ObjectSubscribeArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking;
|
|
193
179
|
export type CrudResponse = import("../utils/cancellablePromise.js").MaybeCancellablePromise<object | string>;
|
|
194
180
|
export type CrudCreateFn = (args: CreateArgs) => CrudResponse;
|
|
195
181
|
export type CrudRetrieveFn = (args: RetrieveArgs) => CrudResponse;
|
|
@@ -230,4 +216,3 @@ export type ObjectCrudHandlers = {
|
|
|
230
216
|
* The CRUD arguments.
|
|
231
217
|
*/
|
|
232
218
|
export type ObjectTarget = ObjectTargetProperties & ObjectCrudHandlers;
|
|
233
|
-
//# sourceMappingURL=objectCrud.d.ts.map
|
package/types/index.d.ts
CHANGED
|
@@ -2,25 +2,26 @@ export * from "./config/listCrud.js";
|
|
|
2
2
|
export * from "./config/objectCrud.js";
|
|
3
3
|
export * from "./use/cancellableIntent.js";
|
|
4
4
|
export * from "./use/combineClasses.js";
|
|
5
|
+
export * from "./use/error.js";
|
|
5
6
|
export * from "./use/list.js";
|
|
6
7
|
export * from "./use/listCalculated.js";
|
|
7
8
|
export * from "./use/listFilter.js";
|
|
8
9
|
export * from "./use/listInstance.js";
|
|
9
|
-
export * from "./use/listKeys.js";
|
|
10
10
|
export * from "./use/listRelated.js";
|
|
11
11
|
export * from "./use/listSearch.js";
|
|
12
12
|
export * from "./use/listSort.js";
|
|
13
13
|
export * from "./use/listSubscription.js";
|
|
14
|
+
export * from "./use/loading.js";
|
|
14
15
|
export * from "./use/loadingError.js";
|
|
15
16
|
export * from "./use/object.js";
|
|
16
17
|
export * from "./use/objectCalculated.js";
|
|
17
18
|
export * from "./use/objectInstance.js";
|
|
18
19
|
export * from "./use/objectRelated.js";
|
|
19
20
|
export * from "./use/objectSubscription.js";
|
|
20
|
-
export * from "./use/
|
|
21
|
+
export * from "./use/proxyError.js";
|
|
21
22
|
export * from "./use/proxyLoadingError.js";
|
|
23
|
+
export * from "./use/proxyLoading.js";
|
|
22
24
|
export * from "./use/search.js";
|
|
23
|
-
export * from "./use/watchesRunning.js";
|
|
24
25
|
export * from "./utils/assignReactiveObject.js";
|
|
25
26
|
export * from "./utils/cancellableFetch.js";
|
|
26
27
|
export * from "./utils/cancellablePromise.js";
|
|
@@ -29,6 +30,7 @@ export * from "./utils/compact.js";
|
|
|
29
30
|
export * from "./utils/deepUnref.js";
|
|
30
31
|
export * from "./utils/deleteKey.js";
|
|
31
32
|
export * from "./utils/flattenPaths.js";
|
|
33
|
+
export * from "./utils/flattenPathsWithValues.js";
|
|
32
34
|
export * from "./utils/getFakePk.js";
|
|
33
35
|
export * from "./utils/keepAliveTry.js";
|
|
34
36
|
export * from "./utils/keyDiff.js";
|
|
@@ -39,4 +41,3 @@ export * from "./utils/set.js";
|
|
|
39
41
|
export * from "./utils/transformWalk.js";
|
|
40
42
|
export * from "./utils/unwrapNested.js";
|
|
41
43
|
export * from "./utils/watches.js";
|
|
42
|
-
//# sourceMappingURL=index.d.ts.map
|