@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
|
@@ -1,25 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A class that wraps a promise and its resolve and reject functions
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
3
5
|
*/
|
|
4
|
-
export class Resolvable {
|
|
6
|
+
export class Resolvable<T> {
|
|
5
7
|
/**
|
|
6
|
-
* @type {Promise}
|
|
8
|
+
* @type {Promise<T>}
|
|
7
9
|
*/
|
|
8
|
-
promise: Promise<
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
promise: Promise<T>;
|
|
11
|
+
/**
|
|
12
|
+
* @type {(value: T) => void}
|
|
13
|
+
*/
|
|
14
|
+
resolve: (value: T) => void;
|
|
15
|
+
/**
|
|
16
|
+
* @type {(reason?: any) => void}
|
|
17
|
+
*/
|
|
18
|
+
reject: (reason?: any) => void;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* A Resolvable with a cancel function.
|
|
22
|
+
*
|
|
23
|
+
* @template T
|
|
16
24
|
*/
|
|
17
|
-
export class CancellableResolvable {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
export class CancellableResolvable<T> {
|
|
26
|
+
/**
|
|
27
|
+
* @type {import("../../utils/cancellablePromise.js").CancellablePromise<T>}
|
|
28
|
+
*/
|
|
29
|
+
promise: import("../../utils/cancellablePromise.js").CancellablePromise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* @type {(value: T) => void}
|
|
32
|
+
*/
|
|
33
|
+
resolve: (value: T) => void;
|
|
34
|
+
/**
|
|
35
|
+
* @type {(reason?: any) => void}
|
|
36
|
+
*/
|
|
37
|
+
reject: (reason?: any) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Cancel-related resolvable.
|
|
40
|
+
*
|
|
41
|
+
* @type {{ promise: Promise<void>, resolve: () => void }}
|
|
42
|
+
*/
|
|
43
|
+
cancel: {
|
|
44
|
+
promise: Promise<void>;
|
|
45
|
+
resolve: () => void;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* @private
|
|
49
|
+
* @type {(value?: any) => void}
|
|
50
|
+
*/
|
|
51
|
+
private _cancelResolve;
|
|
24
52
|
}
|
|
25
|
-
//# sourceMappingURL=crudPromise.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function scopedIt(name: string, fn: () => Promise<void> | void, timeout?: number): void;
|
|
2
|
+
export namespace scopedIt {
|
|
3
|
+
/**
|
|
4
|
+
* Mark a scoped test as TODO.
|
|
5
|
+
* @param {string} name - The name of the test.
|
|
6
|
+
*/
|
|
7
|
+
export function todo(name: string): void;
|
|
8
|
+
export function each(cases: any): (name: any, optionsOrFn: any, maybeFn: any) => any;
|
|
9
|
+
/**
|
|
10
|
+
* Run a test in a Vue effect scope with multiple cases, using `it.for`.
|
|
11
|
+
* @param {Array} cases - The cases to run the test with.
|
|
12
|
+
*/
|
|
13
|
+
function _for(cases: any[]): (name: any, maybeOptionsOrFn: any, maybeFnOrNothing: any) => void;
|
|
14
|
+
export { _for as for };
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,33 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @typedef {number} RunId - A unique identifier for a single execution ("run") of an intent.
|
|
3
|
+
* This is incremented each time `watchArguments` change and the intent re-triggers.
|
|
4
|
+
* Enables distinguishing results or effects from overlapping async runs.
|
|
3
5
|
*/
|
|
4
6
|
/**
|
|
5
7
|
* @typedef {object} CancellableIntentRawState - The raw state of the cancellable intent.
|
|
6
|
-
* @property {
|
|
7
|
-
* @property {boolean
|
|
8
|
-
* @property {number|undefined} resolvingCount - The number of resolving intents.
|
|
9
|
-
* @property {boolean|undefined} resolving - Whether there are resolving intents.
|
|
10
|
-
* @property {boolean} errored - Whether there was an error.
|
|
11
|
-
* @property {Error|null} error - The error that occurred.
|
|
8
|
+
* @property {import('vue').ComputedRef<boolean>|undefined} active - Whether there are active intents.
|
|
9
|
+
* @property {import('vue').ComputedRef<boolean>|undefined} resolving - Whether there are resolving intents.
|
|
12
10
|
* @property {boolean} clearActiveOnResolved - Whether to clear the active state when the promise resolves.
|
|
11
|
+
* @property {RunId|null} lastRunId - The most recent run ID issued for a triggered intent. Useful for associating async results with their originating trigger.
|
|
12
|
+
* @property {import('vue').DeepReadonly<object>} watchArguments - The watch arguments.
|
|
13
|
+
* @property {import('vue').DeepReadonly<object>} guardArguments - The guard arguments.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import("vue").Reactive<
|
|
17
|
+
* CancellableIntentRawState &
|
|
18
|
+
* Pick<import('./error.js').ErrorStatus, 'error' | 'errored'>
|
|
19
|
+
* >} CancellableIntentState - The state of the cancellable intent.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {() => boolean} IsCurrentRunFn - A function that checks if the current run ID matches the last run ID.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* The common run tracking arguments.
|
|
26
|
+
*
|
|
27
|
+
* @typedef {object} CommonRunTracking
|
|
28
|
+
* @property {RunId} runId - The unique identifier for your run.
|
|
29
|
+
* @property {IsCurrentRunFn} isCurrentRun - A function that checks if the current run ID matches your run ID.
|
|
13
30
|
*/
|
|
14
31
|
/**
|
|
15
|
-
* @typedef {import(
|
|
32
|
+
* @typedef {(runTracking: CommonRunTracking) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} AwaitableWithCancel - A function that returns a promise that can be cancelled.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {import("vue").UnwrapNestedRefs<object>|{[key: string]: import('vue').Ref<any>}} WatchGuardArguments - The reactive object to watch for changes.
|
|
16
36
|
*/
|
|
17
37
|
/**
|
|
18
38
|
* @typedef {object} CancellableIntentOptions - The options for the cancellable intent.
|
|
19
|
-
* @property {
|
|
20
|
-
* @property {
|
|
21
|
-
* @property {
|
|
39
|
+
* @property {AwaitableWithCancel} awaitableWithCancel - The function that returns a promise that can be cancelled. Receives the run ID as an argument.
|
|
40
|
+
* @property {WatchGuardArguments} [watchArguments={}] - The reactive object to watch for changes.
|
|
41
|
+
* @property {WatchGuardArguments} [guardArguments={}] - The reactive object to watch for truthiness before running the intent.
|
|
22
42
|
* @property {boolean} [clearActiveOnResolved=true] - Whether to clear the active state when the promise resolves.
|
|
23
43
|
*/
|
|
24
44
|
/**
|
|
25
|
-
*
|
|
45
|
+
* Cancel function signature for cancellable intent.
|
|
46
|
+
*
|
|
47
|
+
* @typedef {Function} CancelFn
|
|
48
|
+
* @param {any} reason - The reason for cancellation.
|
|
49
|
+
* @param {boolean} [forceClearActive=false] - Whether to force clear the active state.
|
|
50
|
+
* @returns {Promise<void>} - A promise that resolves when the cancellation is complete.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {object} MyCancellableIntent - The instance of the cancellable intent.
|
|
26
54
|
* @property {CancellableIntentState} state - The state of the cancellable intent.
|
|
27
|
-
* @property {
|
|
28
|
-
* @property {
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
* @property {() => void} stop - Stop the cancellable intent.
|
|
56
|
+
* @property {CancelFn} cancel - Cancel the cancellable intent.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* @typedef {MyCancellableIntent & Pick<import('./error.js').ErrorStatus, "clearError">} CancellableIntent - The instance of the cancellable intent.
|
|
31
60
|
*/
|
|
32
61
|
/**
|
|
33
62
|
* Calls your awaitable function with the arguments you pass in when the watch arguments change and are all truthy.
|
|
@@ -69,86 +98,130 @@
|
|
|
69
98
|
*/
|
|
70
99
|
export function useCancellableIntent({ awaitableWithCancel, watchArguments, guardArguments, clearActiveOnResolved, }: CancellableIntentOptions): CancellableIntent;
|
|
71
100
|
/**
|
|
72
|
-
* -
|
|
101
|
+
* @module use/cancellableIntent.js - A composable function for handling cancellable intents.
|
|
73
102
|
*/
|
|
74
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Custom error class for list subscription errors.
|
|
105
|
+
*/
|
|
106
|
+
export class CancellableIntentError extends Error {
|
|
75
107
|
/**
|
|
76
|
-
*
|
|
108
|
+
* Creates a new CancellableIntentError.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} message - The error message.
|
|
111
|
+
* @param {string} code - The error code.
|
|
77
112
|
*/
|
|
78
|
-
|
|
113
|
+
constructor(message: string, code: string);
|
|
114
|
+
code: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* - A unique identifier for a single execution ("run") of an intent.
|
|
118
|
+
* This is incremented each time `watchArguments` change and the intent re-triggers.
|
|
119
|
+
* Enables distinguishing results or effects from overlapping async runs.
|
|
120
|
+
*/
|
|
121
|
+
export type RunId = number;
|
|
122
|
+
/**
|
|
123
|
+
* - The raw state of the cancellable intent.
|
|
124
|
+
*/
|
|
125
|
+
export type CancellableIntentRawState = {
|
|
79
126
|
/**
|
|
80
127
|
* - Whether there are active intents.
|
|
81
128
|
*/
|
|
82
|
-
active: boolean | undefined;
|
|
129
|
+
active: import("vue").ComputedRef<boolean> | undefined;
|
|
83
130
|
/**
|
|
84
|
-
* -
|
|
131
|
+
* - Whether there are resolving intents.
|
|
85
132
|
*/
|
|
86
|
-
|
|
133
|
+
resolving: import("vue").ComputedRef<boolean> | undefined;
|
|
87
134
|
/**
|
|
88
|
-
* - Whether
|
|
135
|
+
* - Whether to clear the active state when the promise resolves.
|
|
89
136
|
*/
|
|
90
|
-
|
|
137
|
+
clearActiveOnResolved: boolean;
|
|
91
138
|
/**
|
|
92
|
-
* -
|
|
139
|
+
* - The most recent run ID issued for a triggered intent. Useful for associating async results with their originating trigger.
|
|
93
140
|
*/
|
|
94
|
-
|
|
141
|
+
lastRunId: RunId | null;
|
|
95
142
|
/**
|
|
96
|
-
* - The
|
|
143
|
+
* - The watch arguments.
|
|
97
144
|
*/
|
|
98
|
-
|
|
145
|
+
watchArguments: import("vue").DeepReadonly<object>;
|
|
99
146
|
/**
|
|
100
|
-
* -
|
|
147
|
+
* - The guard arguments.
|
|
101
148
|
*/
|
|
102
|
-
|
|
149
|
+
guardArguments: import("vue").DeepReadonly<object>;
|
|
103
150
|
};
|
|
104
151
|
/**
|
|
105
152
|
* - The state of the cancellable intent.
|
|
106
153
|
*/
|
|
107
|
-
export type CancellableIntentState = import("vue").
|
|
154
|
+
export type CancellableIntentState = import("vue").Reactive<CancellableIntentRawState & Pick<import("./error.js").ErrorStatus, "error" | "errored">>;
|
|
155
|
+
/**
|
|
156
|
+
* - A function that checks if the current run ID matches the last run ID.
|
|
157
|
+
*/
|
|
158
|
+
export type IsCurrentRunFn = () => boolean;
|
|
159
|
+
/**
|
|
160
|
+
* The common run tracking arguments.
|
|
161
|
+
*/
|
|
162
|
+
export type CommonRunTracking = {
|
|
163
|
+
/**
|
|
164
|
+
* - The unique identifier for your run.
|
|
165
|
+
*/
|
|
166
|
+
runId: RunId;
|
|
167
|
+
/**
|
|
168
|
+
* - A function that checks if the current run ID matches your run ID.
|
|
169
|
+
*/
|
|
170
|
+
isCurrentRun: IsCurrentRunFn;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* - A function that returns a promise that can be cancelled.
|
|
174
|
+
*/
|
|
175
|
+
export type AwaitableWithCancel = (runTracking: CommonRunTracking) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* - The reactive object to watch for changes.
|
|
178
|
+
*/
|
|
179
|
+
export type WatchGuardArguments = import("vue").UnwrapNestedRefs<object> | {
|
|
180
|
+
[key: string]: import("vue").Ref<any>;
|
|
181
|
+
};
|
|
108
182
|
/**
|
|
109
183
|
* - The options for the cancellable intent.
|
|
110
184
|
*/
|
|
111
185
|
export type CancellableIntentOptions = {
|
|
112
186
|
/**
|
|
113
|
-
* - The function that returns a promise that can be cancelled.
|
|
187
|
+
* - The function that returns a promise that can be cancelled. Receives the run ID as an argument.
|
|
114
188
|
*/
|
|
115
|
-
awaitableWithCancel:
|
|
189
|
+
awaitableWithCancel: AwaitableWithCancel;
|
|
116
190
|
/**
|
|
117
191
|
* - The reactive object to watch for changes.
|
|
118
192
|
*/
|
|
119
|
-
watchArguments?:
|
|
193
|
+
watchArguments?: WatchGuardArguments;
|
|
120
194
|
/**
|
|
121
195
|
* - The reactive object to watch for truthiness before running the intent.
|
|
122
196
|
*/
|
|
123
|
-
guardArguments?:
|
|
197
|
+
guardArguments?: WatchGuardArguments;
|
|
124
198
|
/**
|
|
125
199
|
* - Whether to clear the active state when the promise resolves.
|
|
126
200
|
*/
|
|
127
201
|
clearActiveOnResolved?: boolean;
|
|
128
202
|
};
|
|
203
|
+
/**
|
|
204
|
+
* Cancel function signature for cancellable intent.
|
|
205
|
+
*/
|
|
206
|
+
export type CancelFn = Function;
|
|
129
207
|
/**
|
|
130
208
|
* - The instance of the cancellable intent.
|
|
131
209
|
*/
|
|
132
|
-
export type
|
|
210
|
+
export type MyCancellableIntent = {
|
|
133
211
|
/**
|
|
134
212
|
* - The state of the cancellable intent.
|
|
135
213
|
*/
|
|
136
214
|
state: CancellableIntentState;
|
|
137
|
-
/**
|
|
138
|
-
* - The watch arguments.
|
|
139
|
-
*/
|
|
140
|
-
watchArguments: import("vue").UnwrapNestedRefs<object>;
|
|
141
|
-
/**
|
|
142
|
-
* - The guard arguments.
|
|
143
|
-
*/
|
|
144
|
-
guardArguments: import("vue").UnwrapNestedRefs<object>;
|
|
145
215
|
/**
|
|
146
216
|
* - Stop the cancellable intent.
|
|
147
217
|
*/
|
|
148
|
-
stop:
|
|
218
|
+
stop: () => void;
|
|
149
219
|
/**
|
|
150
220
|
* - Cancel the cancellable intent.
|
|
151
221
|
*/
|
|
152
|
-
cancel:
|
|
222
|
+
cancel: CancelFn;
|
|
153
223
|
};
|
|
154
|
-
|
|
224
|
+
/**
|
|
225
|
+
* - The instance of the cancellable intent.
|
|
226
|
+
*/
|
|
227
|
+
export type CancellableIntent = MyCancellableIntent & Pick<import("./error.js").ErrorStatus, "clearError">;
|
|
@@ -40,4 +40,3 @@ export function useCombineClasses(...classes: (CSSClasses)[]): import("vue").Ref
|
|
|
40
40
|
export type CSSClasses = (string | string[] | {
|
|
41
41
|
[key: string]: boolean | import("vue").Ref<boolean>;
|
|
42
42
|
} | import("vue").Ref<string | string[]>);
|
|
43
|
-
//# sourceMappingURL=combineClasses.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {() => void} ClearErrorFn
|
|
3
|
+
* @typedef {import("vue").Ref<Error|null>} ErrorRef
|
|
4
|
+
* @typedef {import("vue").Ref<boolean>} ErroredRef
|
|
5
|
+
* @typedef {Readonly<ErrorRef>} ErrorReadonlyRef
|
|
6
|
+
* @typedef {Readonly<ErroredRef>} ErroredReadonlyRef
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The error state API.
|
|
10
|
+
*
|
|
11
|
+
* @typedef {object} ErrorStatus
|
|
12
|
+
* @property {ErrorReadonlyRef} error - The error that occurred.
|
|
13
|
+
* @property {ErroredReadonlyRef} errored - Whether an error has occurred.
|
|
14
|
+
* @property {(error: Error) => void} setError - Set the error state.
|
|
15
|
+
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A composable function for managing error state.
|
|
19
|
+
*
|
|
20
|
+
* @returns {ErrorStatus} - An object containing reactive fields and actions for error state.
|
|
21
|
+
*/
|
|
22
|
+
export function useError(): ErrorStatus;
|
|
23
|
+
export type ClearErrorFn = () => void;
|
|
24
|
+
export type ErrorRef = import("vue").Ref<Error | null>;
|
|
25
|
+
export type ErroredRef = import("vue").Ref<boolean>;
|
|
26
|
+
export type ErrorReadonlyRef = Readonly<ErrorRef>;
|
|
27
|
+
export type ErroredReadonlyRef = Readonly<ErroredRef>;
|
|
28
|
+
/**
|
|
29
|
+
* The error state API.
|
|
30
|
+
*/
|
|
31
|
+
export type ErrorStatus = {
|
|
32
|
+
/**
|
|
33
|
+
* - The error that occurred.
|
|
34
|
+
*/
|
|
35
|
+
error: ErrorReadonlyRef;
|
|
36
|
+
/**
|
|
37
|
+
* - Whether an error has occurred.
|
|
38
|
+
*/
|
|
39
|
+
errored: ErroredReadonlyRef;
|
|
40
|
+
/**
|
|
41
|
+
* - Set the error state.
|
|
42
|
+
*/
|
|
43
|
+
setError: (error: Error) => void;
|
|
44
|
+
/**
|
|
45
|
+
* - Clear the error state.
|
|
46
|
+
*/
|
|
47
|
+
clearError: ClearErrorFn;
|
|
48
|
+
};
|
package/types/use/list.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function useLists(listOptions: {
|
|
|
24
24
|
}): {
|
|
25
25
|
[key: string]: ListManager;
|
|
26
26
|
};
|
|
27
|
-
export function useList({ props, handlers,
|
|
27
|
+
export function useList({ props, handlers, searchThrottle, sortThrottleWait, searchShowAllWhenEmpty }: ListOptions): ListManager;
|
|
28
28
|
/**
|
|
29
29
|
* Defines properties for configuring the list management system.
|
|
30
30
|
*/
|
|
@@ -94,47 +94,25 @@ export type ListOptions = {
|
|
|
94
94
|
/**
|
|
95
95
|
* - Additional handlers to be included in the list manager.
|
|
96
96
|
*/
|
|
97
|
-
handlers
|
|
98
|
-
/**
|
|
99
|
-
* - Indicates whether the list should be paginated.
|
|
100
|
-
*/
|
|
101
|
-
paged: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* - Indicates whether old pages should be kept when paginating.
|
|
104
|
-
*/
|
|
105
|
-
keepOldPages: import("vue").Ref<boolean> | boolean;
|
|
106
|
-
/**
|
|
107
|
-
* - Indicates whether the list should be cleared when the list intent is triggered.
|
|
108
|
-
*/
|
|
109
|
-
clearListOnListIntentTriggered: boolean;
|
|
97
|
+
handlers?: import("../config/listCrud.js").ListCrudHandlers;
|
|
110
98
|
/**
|
|
111
99
|
* - The throttle time for text search.
|
|
112
100
|
*/
|
|
113
|
-
searchThrottle
|
|
101
|
+
searchThrottle?: number;
|
|
114
102
|
/**
|
|
115
103
|
* - The throttle time for sorting.
|
|
116
104
|
*/
|
|
117
|
-
sortThrottleWait
|
|
105
|
+
sortThrottleWait?: number;
|
|
118
106
|
/**
|
|
119
107
|
* - Indicates whether all items should be shown when the search query is empty.
|
|
120
108
|
*/
|
|
121
|
-
searchShowAllWhenEmpty
|
|
109
|
+
searchShowAllWhenEmpty?: boolean;
|
|
122
110
|
};
|
|
123
|
-
/**
|
|
124
|
-
* Represents the combined state definitions for all list-related components.
|
|
125
|
-
* This interface aggregates the raw state from multiple list management functionalities.
|
|
126
|
-
*/
|
|
127
|
-
export type ListRawState = ((import("./listInstance.js").ListInstanceRawState | import("./paginatedListInstance.js").PagedListInstanceRawState) & import("./listSubscription.js").ListSubscriptionRawState & import("./listRelated.js").ListRelatedRawState & import("./listCalculated.js").ListCalculatedRawState & import("./listFilter.js").ListFilterRawState & import("./listSearch.js").ListSearchRawState & import("./listSort.js").ListSortRawState);
|
|
128
|
-
/**
|
|
129
|
-
* Represents the reactive state derived from aggregating states of various list-related components.
|
|
130
|
-
* This state is typically used within Vue components for reactivity and access to updated list properties.
|
|
131
|
-
*/
|
|
132
|
-
export type ListState = import("vue").UnwrapNestedRefs<ListRawState>;
|
|
133
111
|
/**
|
|
134
112
|
* Holds references to instances of all list-related composables, facilitating direct access and management.
|
|
135
113
|
*/
|
|
136
114
|
export type ListManaged = {
|
|
137
|
-
listInstance: import("./listInstance.js").ListInstance
|
|
115
|
+
listInstance: import("./listInstance.js").ListInstance;
|
|
138
116
|
listSubscription: import("./listSubscription.js").ListSubscription;
|
|
139
117
|
listRelated: import("./listRelated.js").ListRelated;
|
|
140
118
|
listCalculated: import("./listCalculated.js").ListCalculated;
|
|
@@ -158,15 +136,14 @@ export type ListManagerProperties = {
|
|
|
158
136
|
/**
|
|
159
137
|
* - Represents the final reactive state in the list processing chain.
|
|
160
138
|
*/
|
|
161
|
-
state:
|
|
139
|
+
state: import("./listSort.js").ListSortState;
|
|
162
140
|
/**
|
|
163
|
-
* -
|
|
141
|
+
* - A function to stop the effect scope and clean up resources.
|
|
164
142
|
*/
|
|
165
|
-
|
|
143
|
+
stop: () => void;
|
|
166
144
|
};
|
|
167
145
|
/**
|
|
168
146
|
* Combines functionality and properties to represent a fully managed list instance,
|
|
169
147
|
* orchestrating various functionalities such as sorting, searching, filtering, and state management.
|
|
170
148
|
*/
|
|
171
149
|
export type ListManager = ListFunctions & ListManagerProperties;
|
|
172
|
-
//# sourceMappingURL=list.d.ts.map
|