@arrai-innovations/reactive-helpers 21.1.2 → 22.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/LICENSE +28 -0
- package/README.md +109 -21
- package/config/commonCrud.js +7 -10
- package/config/listCrud.js +33 -33
- package/config/objectCrud.js +64 -59
- package/package.json +103 -89
- package/types/config/listCrud.d.ts +83 -28
- package/types/config/objectCrud.d.ts +139 -49
- package/types/tests/benchmarks/fixtures.d.ts +60 -0
- package/types/tests/benchmarks/listLayers.bench.d.ts +1 -0
- package/types/tests/benchmarks/listPush.bench.d.ts +1 -0
- package/types/tests/benchmarks/listStream.bench.d.ts +1 -0
- package/types/tests/unit/use/lifecycleCleanup.spec.d.ts +1 -0
- package/types/tests/unit/use/listPerformance.spec.d.ts +1 -0
- package/types/tests/unit/utils/cancellablePromise.spec.d.ts +1 -0
- package/types/use/cancellableIntent.d.ts +36 -33
- package/types/use/combineClasses.d.ts +5 -2
- package/types/use/error.d.ts +39 -19
- package/types/use/list.d.ts +27 -26
- package/types/use/listCalculated.d.ts +38 -55
- package/types/use/listFilter.d.ts +25 -33
- package/types/use/listInstance.d.ts +94 -81
- package/types/use/listRelated.d.ts +37 -57
- package/types/use/listSearch.d.ts +54 -52
- package/types/use/listSort.d.ts +31 -40
- package/types/use/listSubscription.d.ts +33 -36
- package/types/use/loading.d.ts +20 -10
- package/types/use/loadingError.d.ts +12 -3
- package/types/use/object.d.ts +8 -5
- package/types/use/objectCalculated.d.ts +46 -39
- package/types/use/objectInstance.d.ts +70 -74
- package/types/use/objectRelated.d.ts +51 -41
- package/types/use/objectSubscription.d.ts +38 -48
- package/types/use/proxyError.d.ts +15 -6
- package/types/use/proxyLoading.d.ts +11 -5
- package/types/use/proxyLoadingError.d.ts +19 -7
- package/types/use/search.d.ts +33 -29
- package/types/utils/assignReactiveObject.d.ts +3 -0
- package/types/utils/cancellableFetch.d.ts +2 -3
- package/types/utils/cancellablePromise.d.ts +42 -8
- package/types/utils/classes.d.ts +7 -1
- package/types/utils/deepUnref.d.ts +1 -1
- package/types/utils/getFakePk.d.ts +2 -2
- package/types/utils/isReactiveTyped.d.ts +2 -0
- package/types/utils/keyDiff.d.ts +4 -6
- package/types/utils/relatedCalculatedHelpers.d.ts +2 -0
- package/types/utils/watches.d.ts +1 -1
- package/use/cancellableIntent.js +36 -9
- package/use/combineClasses.js +2 -2
- package/use/error.js +10 -14
- package/use/list.js +6 -18
- package/use/listCalculated.js +28 -38
- package/use/listFilter.js +12 -24
- package/use/listInstance.js +101 -60
- package/use/listRelated.js +18 -37
- package/use/listSearch.js +9 -18
- package/use/listSort.js +95 -64
- package/use/listSubscription.js +19 -25
- package/use/loading.js +5 -7
- package/use/loadingError.js +3 -3
- package/use/object.js +14 -27
- package/use/objectCalculated.js +21 -25
- package/use/objectInstance.js +55 -50
- package/use/objectRelated.js +19 -25
- package/use/objectSubscription.js +18 -30
- package/use/proxyError.js +10 -10
- package/use/proxyLoading.js +5 -5
- package/use/proxyLoadingError.js +13 -8
- package/use/search.js +5 -11
- package/utils/assignReactiveObject.js +3 -3
- package/utils/cancellableFetch.js +3 -3
- package/utils/cancellablePromise.js +25 -8
- package/utils/classes.js +2 -2
- package/utils/deepUnref.js +1 -5
- package/utils/getFakePk.js +2 -2
- package/utils/isReactiveTyped.js +2 -0
- package/utils/keyDiff.js +1 -3
- package/utils/relatedCalculatedHelpers.js +2 -0
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {object} ObjectRelatedProperties
|
|
2
|
+
* @typedef {object} ObjectRelatedProperties - The members (state, parentState, stop) contributed by the object related composable.
|
|
3
3
|
* @property {ObjectRelatedState} state - The state of the object related instance.
|
|
4
4
|
* @property {ObjectRelatedParentState} parentState - The parent state.
|
|
5
5
|
* @property {() => void} stop - Stops all effects of the object related instance.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* An instance of an object related reactive object.
|
|
10
|
-
*
|
|
11
|
-
* @typedef {ObjectRelatedProperties} ObjectRelated
|
|
9
|
+
* @typedef {ObjectRelatedProperties} ObjectRelated - An instance of an object related reactive object.
|
|
12
10
|
*/
|
|
13
11
|
/**
|
|
14
|
-
* Non-parent state options for useObjectRelated.
|
|
15
|
-
*
|
|
16
|
-
* @typedef {object} ObjectRelatedRawProps
|
|
12
|
+
* @typedef {object} ObjectRelatedRawProps - Non-parent state options for useObjectRelated.
|
|
17
13
|
* @property {import('vue').Ref<ObjectRelatedRawRules>} relatedObjectRules - The rules for defining relationships for the managed object to other collections of objects.
|
|
18
14
|
*/
|
|
19
15
|
/**
|
|
20
|
-
* Options for useObjectRelated.
|
|
21
|
-
*
|
|
22
16
|
* @typedef {{
|
|
23
17
|
* parentState: ObjectRelatedParentState,
|
|
24
|
-
* } & ObjectRelatedRawProps} ObjectRelatedOptions
|
|
18
|
+
* } & ObjectRelatedRawProps} ObjectRelatedOptions - Options for useObjectRelated.
|
|
25
19
|
*/
|
|
26
20
|
/**
|
|
21
|
+
* Creates multiple object related instances keyed by name from a map of options.
|
|
27
22
|
*
|
|
28
23
|
* @param {{
|
|
29
24
|
* [key: string]: ObjectRelatedOptions
|
|
@@ -88,7 +83,7 @@ export function useObjectRelateds(objectRelatedArgs: {
|
|
|
88
83
|
* order: ['3','1','2'],
|
|
89
84
|
* },
|
|
90
85
|
* secondOrder: {
|
|
91
|
-
* pkKey: '
|
|
86
|
+
* pkKey: 'relatedItem.firstOrder.secondOrderId',
|
|
92
87
|
* objects: someOtherObjectsSource.objects,
|
|
93
88
|
* },
|
|
94
89
|
* },
|
|
@@ -119,28 +114,25 @@ export function useObjectRelated({ parentState, relatedObjectRules }: ObjectRela
|
|
|
119
114
|
* @module use/objectRelated.js
|
|
120
115
|
*/
|
|
121
116
|
/**
|
|
122
|
-
* The rule for defining relationships for the managed object to other collections of objects.
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @property {string} pkKey - The key in the managed object that corresponds to the key in the related object.
|
|
117
|
+
* @typedef {object} ObjectRelatedRule - The rule for defining relationships for the managed object to other collections of objects.
|
|
118
|
+
* @property {string} [pkKey] - The key in the managed object that corresponds to the key in the related object.
|
|
119
|
+
* Defaults to the rule's own key when omitted.
|
|
126
120
|
* @property {import('./listInstance.js').ObjectsByPk} objects - The related objects, indexed by the key in the related object.
|
|
127
|
-
* @property {string[]} order - The order of the related objects, if the related objects are an array.
|
|
121
|
+
* @property {string[]} [order] - The order of the related objects, if the related objects are an array.
|
|
128
122
|
*/
|
|
129
123
|
/**
|
|
130
|
-
* The rules for defining relationships for the managed object to other collections of objects.
|
|
131
|
-
*
|
|
132
124
|
* @typedef {{
|
|
133
125
|
* [rule: string]: ObjectRelatedRule,
|
|
134
|
-
* }} ObjectRelatedRawRules
|
|
126
|
+
* }} ObjectRelatedRawRules - The rules for defining relationships for the managed object to other collections of objects.
|
|
135
127
|
*/
|
|
136
128
|
/**
|
|
137
129
|
*
|
|
138
130
|
*
|
|
139
|
-
* @typedef {object} ObjectRelatedRawState
|
|
131
|
+
* @typedef {object} ObjectRelatedRawState - The raw reactive state of the object related composable, holding its rules, computed relations, and running flags.
|
|
140
132
|
* @property {ObjectRelatedRawRules} relatedObjectRules - The rules for defining relationships for the managed object to other collections of objects.
|
|
141
133
|
* @property {{
|
|
142
|
-
* [rule: string]:
|
|
143
|
-
* }} relatedObject - The related objects,
|
|
134
|
+
* [rule: string]: any,
|
|
135
|
+
* }} relatedObject - The related objects, by rule name. Each entry is backed by a computed, but it is read through a reactive proxy that unwraps it, so reads yield the related object (or array of related objects) and never carry a `.value`.
|
|
144
136
|
* @property {boolean} relatedObjectWatchRunning - Whether the related object watch is running.
|
|
145
137
|
* @property {boolean} parentStateObjectWatchRunning - Whether the parent state object watch is running.
|
|
146
138
|
* @property {boolean} relatedRunning - Whether the related objects are loading.
|
|
@@ -152,12 +144,12 @@ export function useObjectRelated({ parentState, relatedObjectRules }: ObjectRela
|
|
|
152
144
|
* @typedef {(
|
|
153
145
|
* import('./objectInstance.js').ObjectInstanceRawState &
|
|
154
146
|
* Partial<import('./objectSubscription.js').ObjectSubscriptionRawState>
|
|
155
|
-
* )} ObjectRelatedParentRawState
|
|
147
|
+
* )} ObjectRelatedParentRawState - The raw, pre-unwrapped parent state consumed by the object related mixin (object instance plus optional subscription state).
|
|
156
148
|
*/
|
|
157
149
|
/**
|
|
158
150
|
*
|
|
159
151
|
*
|
|
160
|
-
* @typedef {import('vue').UnwrapNestedRefs<ObjectRelatedParentRawState>} ObjectRelatedParentState
|
|
152
|
+
* @typedef {import('vue').UnwrapNestedRefs<ObjectRelatedParentRawState>} ObjectRelatedParentState - The unwrapped reactive parent state consumed by the object related mixin.
|
|
161
153
|
*/
|
|
162
154
|
/**
|
|
163
155
|
*
|
|
@@ -165,21 +157,26 @@ export function useObjectRelated({ parentState, relatedObjectRules }: ObjectRela
|
|
|
165
157
|
* @typedef {import('vue').UnwrapNestedRefs<(
|
|
166
158
|
* ObjectRelatedParentRawState &
|
|
167
159
|
* ObjectRelatedRawState
|
|
168
|
-
* )>} ObjectRelatedState
|
|
160
|
+
* )>} ObjectRelatedState - The unwrapped reactive state of the object related composable, combining the parent state with its own related state.
|
|
169
161
|
*/
|
|
162
|
+
/** @internal */
|
|
170
163
|
export const objectRelatedStateKeys: string[];
|
|
164
|
+
/** @internal */
|
|
171
165
|
export const objectRelatedFunctions: any[];
|
|
166
|
+
/**
|
|
167
|
+
* The members (state, parentState, stop) contributed by the object related composable.
|
|
168
|
+
*/
|
|
172
169
|
export type ObjectRelatedProperties = {
|
|
173
170
|
/**
|
|
174
|
-
*
|
|
171
|
+
* The state of the object related instance.
|
|
175
172
|
*/
|
|
176
173
|
state: ObjectRelatedState;
|
|
177
174
|
/**
|
|
178
|
-
*
|
|
175
|
+
* The parent state.
|
|
179
176
|
*/
|
|
180
177
|
parentState: ObjectRelatedParentState;
|
|
181
178
|
/**
|
|
182
|
-
*
|
|
179
|
+
* Stops all effects of the object related instance.
|
|
183
180
|
*/
|
|
184
181
|
stop: () => void;
|
|
185
182
|
};
|
|
@@ -192,7 +189,7 @@ export type ObjectRelated = ObjectRelatedProperties;
|
|
|
192
189
|
*/
|
|
193
190
|
export type ObjectRelatedRawProps = {
|
|
194
191
|
/**
|
|
195
|
-
*
|
|
192
|
+
* The rules for defining relationships for the managed object to other collections of objects.
|
|
196
193
|
*/
|
|
197
194
|
relatedObjectRules: import("vue").Ref<ObjectRelatedRawRules>;
|
|
198
195
|
};
|
|
@@ -207,17 +204,18 @@ export type ObjectRelatedOptions = {
|
|
|
207
204
|
*/
|
|
208
205
|
export type ObjectRelatedRule = {
|
|
209
206
|
/**
|
|
210
|
-
*
|
|
207
|
+
* The key in the managed object that corresponds to the key in the related object.
|
|
208
|
+
* Defaults to the rule's own key when omitted.
|
|
211
209
|
*/
|
|
212
|
-
pkKey
|
|
210
|
+
pkKey?: string;
|
|
213
211
|
/**
|
|
214
|
-
*
|
|
212
|
+
* The related objects, indexed by the key in the related object.
|
|
215
213
|
*/
|
|
216
214
|
objects: import("./listInstance.js").ObjectsByPk;
|
|
217
215
|
/**
|
|
218
|
-
*
|
|
216
|
+
* The order of the related objects, if the related objects are an array.
|
|
219
217
|
*/
|
|
220
|
-
order
|
|
218
|
+
order?: string[];
|
|
221
219
|
};
|
|
222
220
|
/**
|
|
223
221
|
* The rules for defining relationships for the managed object to other collections of objects.
|
|
@@ -225,34 +223,46 @@ export type ObjectRelatedRule = {
|
|
|
225
223
|
export type ObjectRelatedRawRules = {
|
|
226
224
|
[rule: string]: ObjectRelatedRule;
|
|
227
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* The raw reactive state of the object related composable, holding its rules, computed relations, and running flags.
|
|
228
|
+
*/
|
|
228
229
|
export type ObjectRelatedRawState = {
|
|
229
230
|
/**
|
|
230
|
-
*
|
|
231
|
+
* The rules for defining relationships for the managed object to other collections of objects.
|
|
231
232
|
*/
|
|
232
233
|
relatedObjectRules: ObjectRelatedRawRules;
|
|
233
234
|
/**
|
|
234
|
-
*
|
|
235
|
+
* The related objects, by rule name. Each entry is backed by a computed, but it is read through a reactive proxy that unwraps it, so reads yield the related object (or array of related objects) and never carry a `.value`.
|
|
235
236
|
*/
|
|
236
237
|
relatedObject: {
|
|
237
|
-
[rule: string]:
|
|
238
|
+
[rule: string]: any;
|
|
238
239
|
};
|
|
239
240
|
/**
|
|
240
|
-
*
|
|
241
|
+
* Whether the related object watch is running.
|
|
241
242
|
*/
|
|
242
243
|
relatedObjectWatchRunning: boolean;
|
|
243
244
|
/**
|
|
244
|
-
*
|
|
245
|
+
* Whether the parent state object watch is running.
|
|
245
246
|
*/
|
|
246
247
|
parentStateObjectWatchRunning: boolean;
|
|
247
248
|
/**
|
|
248
|
-
*
|
|
249
|
+
* Whether the related objects are loading.
|
|
249
250
|
*/
|
|
250
251
|
relatedRunning: boolean;
|
|
251
252
|
/**
|
|
252
|
-
*
|
|
253
|
+
* Whether the related objects are loading or the parent state is loading.
|
|
253
254
|
*/
|
|
254
255
|
running: boolean;
|
|
255
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* The raw, pre-unwrapped parent state consumed by the object related mixin (object instance plus optional subscription state).
|
|
259
|
+
*/
|
|
256
260
|
export type ObjectRelatedParentRawState = (import("./objectInstance.js").ObjectInstanceRawState & Partial<import("./objectSubscription.js").ObjectSubscriptionRawState>);
|
|
261
|
+
/**
|
|
262
|
+
* The unwrapped reactive parent state consumed by the object related mixin.
|
|
263
|
+
*/
|
|
257
264
|
export type ObjectRelatedParentState = import("vue").UnwrapNestedRefs<ObjectRelatedParentRawState>;
|
|
265
|
+
/**
|
|
266
|
+
* The unwrapped reactive state of the object related composable, combining the parent state with its own related state.
|
|
267
|
+
*/
|
|
258
268
|
export type ObjectRelatedState = import("vue").UnwrapNestedRefs<(ObjectRelatedParentRawState & ObjectRelatedRawState)>;
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The raw state of the object subscription.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {object} ObjectSubscriptionRawState
|
|
2
|
+
* @typedef {object} ObjectSubscriptionRawState - The raw state of the object subscription.
|
|
5
3
|
* @property {import('vue').Ref<boolean>} intendToRetrieve - Whether the object intends to retrieve.
|
|
6
4
|
* @property {import('vue').Ref<boolean>} intendToSubscribe - Whether the object intends to subscribe.
|
|
7
5
|
* @property {import('vue').Ref<boolean|undefined>} subscribed - Whether the object is subscribed.
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
|
-
* The state of the object subscription, including both subscription and object instance states.
|
|
11
|
-
*
|
|
12
8
|
* @typedef {import('vue').Reactive<
|
|
13
9
|
* ObjectSubscriptionRawState &
|
|
14
10
|
* import('./objectInstance.js').ObjectInstanceRawState
|
|
15
|
-
* >} ObjectSubscriptionState
|
|
11
|
+
* >} ObjectSubscriptionState - The state of the object subscription, including both subscription and object instance states.
|
|
16
12
|
*/
|
|
17
13
|
/**
|
|
18
|
-
* Functions available for object subscription management.
|
|
19
|
-
*
|
|
20
|
-
* @typedef {object} ObjectSubscriptionFunctions
|
|
14
|
+
* @typedef {object} ObjectSubscriptionFunctions - Functions available for object subscription management.
|
|
21
15
|
* @property {() => void} clearError - Clears any errors related to the subscription, and resets the loading state.
|
|
22
16
|
*/
|
|
23
17
|
/**
|
|
24
|
-
* Properties of the object subscription.
|
|
25
|
-
*
|
|
26
|
-
* @typedef {object} ObjectSubscriptionProperties
|
|
18
|
+
* @typedef {object} ObjectSubscriptionProperties - Properties of the object subscription.
|
|
27
19
|
* @property {ObjectSubscriptionState} state - The object instance properties.
|
|
28
20
|
* @property {import('./objectInstance.js').ObjectInstance} objectInstance - The object instance.
|
|
29
21
|
* @property {import('./cancellableIntent.js').CancellableIntent} subscribeIntent - The subscribe intent.
|
|
@@ -31,19 +23,15 @@
|
|
|
31
23
|
* @property {() => void} stop - Stops the subscription reactive effects.
|
|
32
24
|
*/
|
|
33
25
|
/**
|
|
34
|
-
* The object subscription instance, combining state, properties, and functions.
|
|
35
|
-
*
|
|
36
|
-
* @typedef {ObjectSubscriptionProperties & ObjectSubscriptionFunctions} ObjectSubscription
|
|
26
|
+
* @typedef {ObjectSubscriptionProperties & ObjectSubscriptionFunctions} ObjectSubscription - The object subscription instance, combining state, properties, and functions.
|
|
37
27
|
*/
|
|
38
28
|
/**
|
|
39
|
-
* Raw props for the object subscription.
|
|
40
|
-
*
|
|
41
|
-
* @typedef {object} ObjectSubscriptionRawProps
|
|
29
|
+
* @typedef {object} ObjectSubscriptionRawProps - Raw props for the object subscription.
|
|
42
30
|
* @property {boolean|undefined} intendToRetrieve - Whether the object intends to retrieve.
|
|
43
31
|
* @property {boolean|undefined} intendToSubscribe - Whether the object intends to subscribe.
|
|
44
32
|
*/
|
|
45
33
|
/**
|
|
46
|
-
* @typedef {object} ObjectSubscriptionOwnOptions
|
|
34
|
+
* @typedef {object} ObjectSubscriptionOwnOptions - The options specific to an object subscription (reactive props, an optional instance to reuse, and handlers).
|
|
47
35
|
* @property {import('./objectInstance.js').ObjectInstance} [objectInstance] - An object instance to use instead of creating a new one.
|
|
48
36
|
* @property {import('vue').UnwrapNestedRefs<(
|
|
49
37
|
* ObjectSubscriptionRawProps & import('./objectInstance.js').ObjectInstanceRawProps
|
|
@@ -51,9 +39,7 @@
|
|
|
51
39
|
* @property {import('../config/objectCrud.js').ObjectCrudHandlers} [handlers] - The handlers to be passed to useObjectInstance.
|
|
52
40
|
*/
|
|
53
41
|
/**
|
|
54
|
-
* Options for initializing an object subscription, including reactive props and non-reactive handlers.
|
|
55
|
-
*
|
|
56
|
-
* @typedef {ObjectSubscriptionOwnOptions & import('./objectInstance.js').ObjectInstanceOptions} ObjectSubscriptionOptions
|
|
42
|
+
* @typedef {ObjectSubscriptionOwnOptions & import('./objectInstance.js').ObjectInstanceOptions} ObjectSubscriptionOptions - Options for initializing an object subscription, including reactive props and non-reactive handlers.
|
|
57
43
|
*/
|
|
58
44
|
/**
|
|
59
45
|
* Initializes multiple object subscriptions based on provided arguments.
|
|
@@ -67,9 +53,7 @@ export function useObjectSubscriptions(subscriptionArgs: {
|
|
|
67
53
|
[key: string]: ObjectSubscription;
|
|
68
54
|
};
|
|
69
55
|
/**
|
|
70
|
-
* The context bound to shared objectSubscription functions.
|
|
71
|
-
*
|
|
72
|
-
* @typedef {object} ObjectSubscriptionContext
|
|
56
|
+
* @typedef {object} ObjectSubscriptionContext - The context bound to shared objectSubscription functions.
|
|
73
57
|
* @property {ObjectSubscriptionState} state - The object subscription state.
|
|
74
58
|
* @property {import('./objectInstance.js').ObjectInstance} objectInstance - The object instance.
|
|
75
59
|
* @property {import('./cancellableIntent.js').CancellableIntent} subscribeIntent - The subscribe intent.
|
|
@@ -82,7 +66,7 @@ export function useObjectSubscriptions(subscriptionArgs: {
|
|
|
82
66
|
* ```
|
|
83
67
|
* <script setup>
|
|
84
68
|
* import { useObjectSubscription } from "@arrai-innovations/reactive-helpers";
|
|
85
|
-
* import { reactive,
|
|
69
|
+
* import { reactive, toRef } from "vue";
|
|
86
70
|
*
|
|
87
71
|
* const pkKey = "id";
|
|
88
72
|
* const props = defineProps({
|
|
@@ -101,11 +85,12 @@ export function useObjectSubscriptions(subscriptionArgs: {
|
|
|
101
85
|
* params: {
|
|
102
86
|
* fields: ['foo', 'bar'],
|
|
103
87
|
* },
|
|
104
|
-
* intendToRetrieve:
|
|
105
|
-
* intendToSubscribe:
|
|
88
|
+
* intendToRetrieve: true,
|
|
89
|
+
* intendToSubscribe: true,
|
|
90
|
+
* });
|
|
91
|
+
* const objectSubscription = useObjectSubscription({
|
|
92
|
+
* props: objectSubscriptionProps,
|
|
106
93
|
* });
|
|
107
|
-
* objectSubscriptionProps.intendToRetrieve = objectSubscriptionProps.intendToSubscribe = computed(()=> !!props.pk);
|
|
108
|
-
* const objectSubscription = useObjectSubscription(objectSubscriptionProps);
|
|
109
94
|
* </script>
|
|
110
95
|
* <template>
|
|
111
96
|
* <div v-if="objectSubscription.state.loading">Loading...</div>
|
|
@@ -137,22 +122,24 @@ export class ObjectSubscriptionError extends Error {
|
|
|
137
122
|
constructor(message: string, code: string);
|
|
138
123
|
code: string;
|
|
139
124
|
}
|
|
125
|
+
/** @internal */
|
|
140
126
|
export const objectSubscriptionStateKeys: string[];
|
|
127
|
+
/** @internal */
|
|
141
128
|
export const objectSubscriptionFunctions: string[];
|
|
142
129
|
/**
|
|
143
130
|
* The raw state of the object subscription.
|
|
144
131
|
*/
|
|
145
132
|
export type ObjectSubscriptionRawState = {
|
|
146
133
|
/**
|
|
147
|
-
*
|
|
134
|
+
* Whether the object intends to retrieve.
|
|
148
135
|
*/
|
|
149
136
|
intendToRetrieve: import("vue").Ref<boolean>;
|
|
150
137
|
/**
|
|
151
|
-
*
|
|
138
|
+
* Whether the object intends to subscribe.
|
|
152
139
|
*/
|
|
153
140
|
intendToSubscribe: import("vue").Ref<boolean>;
|
|
154
141
|
/**
|
|
155
|
-
*
|
|
142
|
+
* Whether the object is subscribed.
|
|
156
143
|
*/
|
|
157
144
|
subscribed: import("vue").Ref<boolean | undefined>;
|
|
158
145
|
};
|
|
@@ -165,7 +152,7 @@ export type ObjectSubscriptionState = import("vue").Reactive<ObjectSubscriptionR
|
|
|
165
152
|
*/
|
|
166
153
|
export type ObjectSubscriptionFunctions = {
|
|
167
154
|
/**
|
|
168
|
-
*
|
|
155
|
+
* Clears any errors related to the subscription, and resets the loading state.
|
|
169
156
|
*/
|
|
170
157
|
clearError: () => void;
|
|
171
158
|
};
|
|
@@ -174,23 +161,23 @@ export type ObjectSubscriptionFunctions = {
|
|
|
174
161
|
*/
|
|
175
162
|
export type ObjectSubscriptionProperties = {
|
|
176
163
|
/**
|
|
177
|
-
*
|
|
164
|
+
* The object instance properties.
|
|
178
165
|
*/
|
|
179
166
|
state: ObjectSubscriptionState;
|
|
180
167
|
/**
|
|
181
|
-
*
|
|
168
|
+
* The object instance.
|
|
182
169
|
*/
|
|
183
170
|
objectInstance: import("./objectInstance.js").ObjectInstance;
|
|
184
171
|
/**
|
|
185
|
-
*
|
|
172
|
+
* The subscribe intent.
|
|
186
173
|
*/
|
|
187
174
|
subscribeIntent: import("./cancellableIntent.js").CancellableIntent;
|
|
188
175
|
/**
|
|
189
|
-
*
|
|
176
|
+
* The retrieve intent.
|
|
190
177
|
*/
|
|
191
178
|
retrieveIntent: import("./cancellableIntent.js").CancellableIntent;
|
|
192
179
|
/**
|
|
193
|
-
*
|
|
180
|
+
* Stops the subscription reactive effects.
|
|
194
181
|
*/
|
|
195
182
|
stop: () => void;
|
|
196
183
|
};
|
|
@@ -203,25 +190,28 @@ export type ObjectSubscription = ObjectSubscriptionProperties & ObjectSubscripti
|
|
|
203
190
|
*/
|
|
204
191
|
export type ObjectSubscriptionRawProps = {
|
|
205
192
|
/**
|
|
206
|
-
*
|
|
193
|
+
* Whether the object intends to retrieve.
|
|
207
194
|
*/
|
|
208
195
|
intendToRetrieve: boolean | undefined;
|
|
209
196
|
/**
|
|
210
|
-
*
|
|
197
|
+
* Whether the object intends to subscribe.
|
|
211
198
|
*/
|
|
212
199
|
intendToSubscribe: boolean | undefined;
|
|
213
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* The options specific to an object subscription (reactive props, an optional instance to reuse, and handlers).
|
|
203
|
+
*/
|
|
214
204
|
export type ObjectSubscriptionOwnOptions = {
|
|
215
205
|
/**
|
|
216
|
-
*
|
|
206
|
+
* An object instance to use instead of creating a new one.
|
|
217
207
|
*/
|
|
218
208
|
objectInstance?: import("./objectInstance.js").ObjectInstance;
|
|
219
209
|
/**
|
|
220
|
-
*
|
|
210
|
+
* The reactive args to be passed to useObjectInstance.
|
|
221
211
|
*/
|
|
222
212
|
props: import("vue").UnwrapNestedRefs<(ObjectSubscriptionRawProps & import("./objectInstance.js").ObjectInstanceRawProps)>;
|
|
223
213
|
/**
|
|
224
|
-
*
|
|
214
|
+
* The handlers to be passed to useObjectInstance.
|
|
225
215
|
*/
|
|
226
216
|
handlers?: import("../config/objectCrud.js").ObjectCrudHandlers;
|
|
227
217
|
};
|
|
@@ -234,19 +224,19 @@ export type ObjectSubscriptionOptions = ObjectSubscriptionOwnOptions & import(".
|
|
|
234
224
|
*/
|
|
235
225
|
export type ObjectSubscriptionContext = {
|
|
236
226
|
/**
|
|
237
|
-
*
|
|
227
|
+
* The object subscription state.
|
|
238
228
|
*/
|
|
239
229
|
state: ObjectSubscriptionState;
|
|
240
230
|
/**
|
|
241
|
-
*
|
|
231
|
+
* The object instance.
|
|
242
232
|
*/
|
|
243
233
|
objectInstance: import("./objectInstance.js").ObjectInstance;
|
|
244
234
|
/**
|
|
245
|
-
*
|
|
235
|
+
* The subscribe intent.
|
|
246
236
|
*/
|
|
247
237
|
subscribeIntent: import("./cancellableIntent.js").CancellableIntent;
|
|
248
238
|
/**
|
|
249
|
-
*
|
|
239
|
+
* The retrieve intent.
|
|
250
240
|
*/
|
|
251
241
|
retrieveIntent: import("./cancellableIntent.js").CancellableIntent;
|
|
252
242
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('./error.js').ReadonlyErrorStatus | import("vue").Reactive<import('./error.js').ReadonlyErrorStatus>} WatchableError
|
|
3
|
-
* @typedef {import('vue').
|
|
2
|
+
* @typedef {import('./error.js').ReadonlyErrorStatus | import("vue").Reactive<import('./error.js').ReadonlyErrorStatus>} WatchableError - An error source (a possibly-reactive readonly error status) that useProxyError can aggregate.
|
|
3
|
+
* @typedef {import('vue').MaybeRefOrGetter<WatchableError>} MaybeRefWatchableError - A watchable error source that may itself be wrapped in a ref or getter.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* A composable function for aggregating error state across multiple sources.
|
|
7
7
|
*
|
|
8
|
-
* @param {import('vue').
|
|
8
|
+
* @param {import('vue').MaybeRefOrGetter<MaybeRefWatchableError[]>} errors - The error states to monitor.
|
|
9
9
|
* @returns {import('./error.js').ReadonlyErrorStatus} An object containing aggregated reactive fields and actions for error state.
|
|
10
10
|
*/
|
|
11
|
-
export function useProxyError(errors: import("vue").
|
|
11
|
+
export function useProxyError(errors: import("vue").MaybeRefOrGetter<MaybeRefWatchableError[]>): import("./error.js").ReadonlyErrorStatus;
|
|
12
12
|
/**
|
|
13
|
-
* @typedef {{ state: import('vue').Reactive<import('./error.js').ErrorProperties> } & import('./error.js').ErrorReadOnlyFunctions} SeparateStateError
|
|
13
|
+
* @typedef {{ state: import('vue').Reactive<import('./error.js').ErrorProperties> } & import('./error.js').ErrorReadOnlyFunctions} SeparateStateError - An error source whose reactive properties live under a state member, alongside its clearError action.
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
16
|
* Adapt an object with reactive error state into a WatchableError shape.
|
|
@@ -23,8 +23,17 @@ export function useProxyError(errors: import("vue").MaybeRef<MaybeRefWatchableEr
|
|
|
23
23
|
* @returns {WatchableError} - The adapted WatchableError object.
|
|
24
24
|
*/
|
|
25
25
|
export function asWatchableError(source: import("vue").MaybeRef<SeparateStateError | WatchableError>): WatchableError;
|
|
26
|
+
/**
|
|
27
|
+
* An error source (a possibly-reactive readonly error status) that useProxyError can aggregate.
|
|
28
|
+
*/
|
|
26
29
|
export type WatchableError = import("./error.js").ReadonlyErrorStatus | import("vue").Reactive<import("./error.js").ReadonlyErrorStatus>;
|
|
27
|
-
|
|
30
|
+
/**
|
|
31
|
+
* A watchable error source that may itself be wrapped in a ref or getter.
|
|
32
|
+
*/
|
|
33
|
+
export type MaybeRefWatchableError = import("vue").MaybeRefOrGetter<WatchableError>;
|
|
34
|
+
/**
|
|
35
|
+
* An error source whose reactive properties live under a state member, alongside its clearError action.
|
|
36
|
+
*/
|
|
28
37
|
export type SeparateStateError = {
|
|
29
38
|
state: import("vue").Reactive<import("./error.js").ErrorProperties>;
|
|
30
39
|
} & import("./error.js").ErrorReadOnlyFunctions;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('./loading.js').LoadingProperties | import("vue").Reactive<import('./loading.js').LoadingProperties>} WatchableLoading
|
|
3
|
-
* @typedef {import('vue').
|
|
2
|
+
* @typedef {import('./loading.js').LoadingProperties | import("vue").Reactive<import('./loading.js').LoadingProperties>} WatchableLoading - A loading source (possibly-reactive loading properties) that useProxyLoading can aggregate.
|
|
3
|
+
* @typedef {import('vue').MaybeRefOrGetter<WatchableLoading>} MaybeRefWatchableLoading - A watchable loading source that may itself be wrapped in a ref or getter.
|
|
4
4
|
* @typedef {import('./loading.js').LoadingProperties} ReadonlyLoadingStatus
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* A composable function for aggregating loading state across multiple sources.
|
|
8
8
|
*
|
|
9
|
-
* @param {import('vue').
|
|
9
|
+
* @param {import('vue').MaybeRefOrGetter<MaybeRefWatchableLoading[]>} loadings - The loading states to monitor.
|
|
10
10
|
* @returns {ReadonlyLoadingStatus} An object containing the aggregated loading field.
|
|
11
11
|
*/
|
|
12
|
-
export function useProxyLoading(loadings: import("vue").
|
|
12
|
+
export function useProxyLoading(loadings: import("vue").MaybeRefOrGetter<MaybeRefWatchableLoading[]>): ReadonlyLoadingStatus;
|
|
13
13
|
/**
|
|
14
14
|
* Adapt an object with reactive loading state into a WatchableLoading shape.
|
|
15
15
|
* Accepts either an object with a `state` property or an object that already exposes `loading`.
|
|
@@ -20,6 +20,12 @@ export function useProxyLoading(loadings: import("vue").MaybeRef<MaybeRefWatchab
|
|
|
20
20
|
export function asWatchableLoading(source: import("vue").MaybeRef<{
|
|
21
21
|
state: WatchableLoading;
|
|
22
22
|
} | WatchableLoading>): WatchableLoading;
|
|
23
|
+
/**
|
|
24
|
+
* A loading source (possibly-reactive loading properties) that useProxyLoading can aggregate.
|
|
25
|
+
*/
|
|
23
26
|
export type WatchableLoading = import("./loading.js").LoadingProperties | import("vue").Reactive<import("./loading.js").LoadingProperties>;
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A watchable loading source that may itself be wrapped in a ref or getter.
|
|
29
|
+
*/
|
|
30
|
+
export type MaybeRefWatchableLoading = import("vue").MaybeRefOrGetter<WatchableLoading>;
|
|
25
31
|
export type ReadonlyLoadingStatus = import("./loading.js").LoadingProperties;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('./proxyLoading.js').WatchableLoading & import('./proxyError.js').WatchableError} WatchableLoadingError
|
|
3
|
-
* @typedef {import('vue').
|
|
4
|
-
* @typedef {import('./loading.js').LoadingProperties & import('./error.js').ReadonlyErrorStatus} ProxyLoadingError
|
|
2
|
+
* @typedef {import('./proxyLoading.js').WatchableLoading & import('./proxyError.js').WatchableError} WatchableLoadingError - A combined loading-and-error source that useProxyLoadingError can aggregate.
|
|
3
|
+
* @typedef {import('vue').MaybeRefOrGetter<WatchableLoadingError>} MaybeRefWatchableLoadingError - A watchable combined loading-and-error source that may itself be wrapped in a ref or getter.
|
|
4
|
+
* @typedef {import('./loading.js').LoadingProperties & import('./error.js').ReadonlyErrorStatus} ProxyLoadingError - The aggregated loading and error state returned by useProxyLoadingError.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* A composable function combining aggregated loading and error state. Use `asWatchableLoadingError` to convert <List|Object><Instance|Subscription> to WatchableLoadingError.
|
|
8
8
|
*
|
|
9
|
-
* @param {import('vue').
|
|
9
|
+
* @param {import('vue').MaybeRefOrGetter<MaybeRefWatchableLoadingError[]>} loadingErrors - The loading and error states to monitor.
|
|
10
10
|
* @returns {ProxyLoadingError} - An object containing aggregated reactive fields and actions for both loading and error state.
|
|
11
11
|
*/
|
|
12
|
-
export function useProxyLoadingError(loadingErrors: import("vue").
|
|
12
|
+
export function useProxyLoadingError(loadingErrors: import("vue").MaybeRefOrGetter<MaybeRefWatchableLoadingError[]>): ProxyLoadingError;
|
|
13
13
|
/**
|
|
14
|
-
* @typedef {{ state: import('vue').Reactive<import('./error.js').ErrorProperties> } & import('./error.js').ErrorReadOnlyFunctions} SeparateStateLoadingError
|
|
14
|
+
* @typedef {{ state: import('vue').Reactive<import('./error.js').ErrorProperties> } & import('./error.js').ErrorReadOnlyFunctions} SeparateStateLoadingError - A combined loading-and-error source whose reactive properties live under a state member, alongside its clearError action.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
17
|
* Adapt an object that exposes loading/error state and clearError into a WatchableLoadingError shape.
|
|
@@ -20,9 +20,21 @@ export function useProxyLoadingError(loadingErrors: import("vue").MaybeRef<Maybe
|
|
|
20
20
|
* @returns {WatchableLoadingError} - The adapted WatchableLoadingError object.
|
|
21
21
|
*/
|
|
22
22
|
export function asWatchableLoadingError(source: import("vue").MaybeRef<SeparateStateLoadingError | WatchableLoadingError>): WatchableLoadingError;
|
|
23
|
+
/**
|
|
24
|
+
* A combined loading-and-error source that useProxyLoadingError can aggregate.
|
|
25
|
+
*/
|
|
23
26
|
export type WatchableLoadingError = import("./proxyLoading.js").WatchableLoading & import("./proxyError.js").WatchableError;
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A watchable combined loading-and-error source that may itself be wrapped in a ref or getter.
|
|
29
|
+
*/
|
|
30
|
+
export type MaybeRefWatchableLoadingError = import("vue").MaybeRefOrGetter<WatchableLoadingError>;
|
|
31
|
+
/**
|
|
32
|
+
* The aggregated loading and error state returned by useProxyLoadingError.
|
|
33
|
+
*/
|
|
25
34
|
export type ProxyLoadingError = import("./loading.js").LoadingProperties & import("./error.js").ReadonlyErrorStatus;
|
|
35
|
+
/**
|
|
36
|
+
* A combined loading-and-error source whose reactive properties live under a state member, alongside its clearError action.
|
|
37
|
+
*/
|
|
26
38
|
export type SeparateStateLoadingError = {
|
|
27
39
|
state: import("vue").Reactive<import("./error.js").ErrorProperties>;
|
|
28
40
|
} & import("./error.js").ErrorReadOnlyFunctions;
|