@arrai-innovations/reactive-helpers 21.1.2 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +109 -21
- package/config/commonCrud.js +4 -6
- package/config/listCrud.js +20 -22
- package/config/objectCrud.js +30 -37
- package/package.json +93 -89
- package/types/config/listCrud.d.ts +83 -26
- package/types/config/objectCrud.d.ts +123 -44
- package/types/use/cancellableIntent.d.ts +27 -31
- package/types/use/combineClasses.d.ts +4 -1
- package/types/use/error.d.ts +39 -19
- package/types/use/list.d.ts +27 -26
- package/types/use/listCalculated.d.ts +21 -39
- package/types/use/listFilter.d.ts +25 -33
- package/types/use/listInstance.d.ts +88 -80
- package/types/use/listRelated.d.ts +26 -46
- package/types/use/listSearch.d.ts +54 -52
- package/types/use/listSort.d.ts +25 -39
- package/types/use/listSubscription.d.ts +28 -35
- package/types/use/loading.d.ts +20 -10
- package/types/use/loadingError.d.ts +12 -3
- package/types/use/object.d.ts +8 -5
- package/types/use/objectCalculated.d.ts +30 -27
- package/types/use/objectInstance.d.ts +67 -73
- package/types/use/objectRelated.d.ts +41 -33
- package/types/use/objectSubscription.d.ts +32 -43
- package/types/use/proxyError.d.ts +15 -6
- package/types/use/proxyLoading.d.ts +11 -5
- package/types/use/proxyLoadingError.d.ts +19 -7
- package/types/use/search.d.ts +33 -29
- package/types/utils/assignReactiveObject.d.ts +3 -0
- package/types/utils/cancellablePromise.d.ts +5 -5
- package/types/utils/classes.d.ts +7 -1
- package/types/utils/deepUnref.d.ts +1 -1
- package/types/utils/isReactiveTyped.d.ts +2 -0
- package/types/utils/keyDiff.d.ts +4 -6
- package/types/utils/relatedCalculatedHelpers.d.ts +2 -0
- package/types/utils/watches.d.ts +1 -1
- package/use/cancellableIntent.js +27 -7
- package/use/combineClasses.js +1 -1
- package/use/error.js +10 -14
- package/use/list.js +6 -18
- package/use/listCalculated.js +7 -22
- package/use/listFilter.js +8 -21
- package/use/listInstance.js +25 -44
- package/use/listRelated.js +9 -28
- package/use/listSearch.js +8 -17
- package/use/listSort.js +27 -41
- package/use/listSubscription.js +10 -25
- package/use/loading.js +5 -7
- package/use/loadingError.js +3 -3
- package/use/object.js +7 -19
- package/use/objectCalculated.js +9 -15
- package/use/objectInstance.js +46 -47
- package/use/objectRelated.js +13 -20
- package/use/objectSubscription.js +11 -25
- package/use/proxyError.js +10 -10
- package/use/proxyLoading.js +5 -5
- package/use/proxyLoadingError.js +10 -8
- package/use/search.js +5 -11
- package/utils/assignReactiveObject.js +3 -3
- package/utils/cancellablePromise.js +4 -4
- package/utils/classes.js +2 -2
- package/utils/deepUnref.js +1 -5
- package/utils/isReactiveTyped.js +2 -0
- package/utils/keyDiff.js +1 -3
- package/utils/relatedCalculatedHelpers.js +2 -0
|
@@ -9,6 +9,9 @@ export function getObjectCrud(target: import("vue").UnwrapNestedRefs<ObjectTarge
|
|
|
9
9
|
props?: import("vue").UnwrapNestedRefs<ObjectTargetOption>;
|
|
10
10
|
handlers?: ObjectCrudHandlers;
|
|
11
11
|
}): void;
|
|
12
|
+
/**
|
|
13
|
+
* Implementation-specific arguments passed through to the CRUD handlers, such as endpoint identifiers.
|
|
14
|
+
*/
|
|
12
15
|
export type TargetArgs = {
|
|
13
16
|
[key: string]: any;
|
|
14
17
|
};
|
|
@@ -23,230 +26,306 @@ export type AdditionalCrudArgs = {
|
|
|
23
26
|
*/
|
|
24
27
|
export type ObjectTargetProperties = {
|
|
25
28
|
/**
|
|
26
|
-
*
|
|
29
|
+
* The arguments to be passed to the crud handlers.
|
|
27
30
|
*/
|
|
28
31
|
args: TargetArgs;
|
|
29
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Optional target arguments passed through to the object CRUD handlers.
|
|
35
|
+
*/
|
|
30
36
|
export type ObjectTargetOption = {
|
|
31
37
|
/**
|
|
32
|
-
*
|
|
38
|
+
* The arguments to be passed to the crud handlers.
|
|
33
39
|
*/
|
|
34
40
|
target?: TargetArgs;
|
|
35
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Raw arguments for an object create operation before additional CRUD arguments are merged in.
|
|
44
|
+
*/
|
|
36
45
|
export type CreateArgsRaw = {
|
|
37
46
|
/**
|
|
38
|
-
*
|
|
47
|
+
* The arguments to be passed to the crud handlers.
|
|
39
48
|
*/
|
|
40
49
|
target: TargetArgs;
|
|
41
50
|
/**
|
|
42
|
-
*
|
|
51
|
+
* The data to be acted upon.
|
|
43
52
|
*/
|
|
44
53
|
object: {
|
|
45
54
|
[key: string]: any;
|
|
46
55
|
};
|
|
47
56
|
/**
|
|
48
|
-
*
|
|
57
|
+
* The arguments to be passed to the retrieve function.
|
|
49
58
|
*/
|
|
50
59
|
params: {
|
|
51
60
|
[key: string]: any;
|
|
52
61
|
};
|
|
53
62
|
/**
|
|
54
|
-
*
|
|
63
|
+
* The key name of the primary key.
|
|
55
64
|
*/
|
|
56
65
|
pkKey: string;
|
|
57
66
|
/**
|
|
58
|
-
*
|
|
67
|
+
* A ref to indicate if the request was cancelled.
|
|
59
68
|
*/
|
|
60
69
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
61
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Arguments for an object create operation, combining the raw arguments with any additional CRUD arguments.
|
|
73
|
+
*/
|
|
62
74
|
export type CreateArgs = CreateArgsRaw & AdditionalCrudArgs;
|
|
75
|
+
/**
|
|
76
|
+
* Raw arguments for an object retrieve operation before run-tracking and additional CRUD arguments are merged in.
|
|
77
|
+
*/
|
|
63
78
|
export type RetrieveArgsRaw = {
|
|
64
79
|
/**
|
|
65
|
-
*
|
|
80
|
+
* The arguments to be passed to the crud handlers.
|
|
66
81
|
*/
|
|
67
82
|
target: TargetArgs;
|
|
68
83
|
/**
|
|
69
|
-
*
|
|
84
|
+
* The pk of the object to be acted upon.
|
|
70
85
|
*/
|
|
71
86
|
pk: import("./commonCrud.js").Pk;
|
|
72
87
|
/**
|
|
73
|
-
*
|
|
88
|
+
* The key name of the primary key.
|
|
74
89
|
*/
|
|
75
90
|
pkKey: string;
|
|
76
91
|
/**
|
|
77
|
-
*
|
|
92
|
+
* The arguments to be passed to the retrieve function.
|
|
78
93
|
*/
|
|
79
94
|
params: {
|
|
80
95
|
[key: string]: any;
|
|
81
96
|
};
|
|
82
97
|
/**
|
|
83
|
-
*
|
|
98
|
+
* A ref to indicate if the request was cancelled.
|
|
84
99
|
*/
|
|
85
100
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
86
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Arguments for an object retrieve operation, combining the raw arguments with run-tracking and any additional CRUD arguments.
|
|
104
|
+
*/
|
|
87
105
|
export type RetrieveArgs = RetrieveArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking> & AdditionalCrudArgs;
|
|
106
|
+
/**
|
|
107
|
+
* Raw arguments for an object update operation before additional CRUD arguments are merged in.
|
|
108
|
+
*/
|
|
88
109
|
export type UpdateArgsRaw = {
|
|
89
110
|
/**
|
|
90
|
-
*
|
|
111
|
+
* The arguments to be passed to the crud handlers.
|
|
91
112
|
*/
|
|
92
113
|
target: TargetArgs;
|
|
93
114
|
/**
|
|
94
|
-
*
|
|
115
|
+
* The data to be acted upon.
|
|
95
116
|
*/
|
|
96
117
|
object: import("../use/objectInstance.js").ExistingCrudObject;
|
|
97
118
|
/**
|
|
98
|
-
*
|
|
119
|
+
* The arguments to be passed to the retrieve function.
|
|
99
120
|
*/
|
|
100
121
|
params: {
|
|
101
122
|
[key: string]: any;
|
|
102
123
|
};
|
|
103
124
|
/**
|
|
104
|
-
*
|
|
125
|
+
* The key name of the primary key.
|
|
105
126
|
*/
|
|
106
127
|
pkKey: string;
|
|
107
128
|
/**
|
|
108
|
-
*
|
|
129
|
+
* A ref to indicate if the request was cancelled.
|
|
109
130
|
*/
|
|
110
131
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
111
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Arguments for an object update operation, combining the raw arguments with any additional CRUD arguments.
|
|
135
|
+
*/
|
|
112
136
|
export type UpdateArgs = UpdateArgsRaw & AdditionalCrudArgs;
|
|
137
|
+
/**
|
|
138
|
+
* Raw arguments for an object delete operation before additional CRUD arguments are merged in.
|
|
139
|
+
*/
|
|
113
140
|
export type DeleteArgsRaw = {
|
|
114
141
|
/**
|
|
115
|
-
*
|
|
142
|
+
* The arguments to be passed to the crud handlers.
|
|
116
143
|
*/
|
|
117
144
|
target: TargetArgs;
|
|
118
145
|
/**
|
|
119
|
-
*
|
|
146
|
+
* The pk of the object to be acted upon.
|
|
120
147
|
*/
|
|
121
148
|
pk: import("./commonCrud.js").Pk;
|
|
122
149
|
/**
|
|
123
|
-
*
|
|
150
|
+
* The key name of the primary key.
|
|
124
151
|
*/
|
|
125
152
|
pkKey: string;
|
|
153
|
+
/**
|
|
154
|
+
* A ref to indicate if the request was cancelled.
|
|
155
|
+
*/
|
|
156
|
+
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
126
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* Arguments for an object delete operation, combining the raw arguments with any additional CRUD arguments.
|
|
160
|
+
*/
|
|
127
161
|
export type DeleteArgs = DeleteArgsRaw & AdditionalCrudArgs;
|
|
162
|
+
/**
|
|
163
|
+
* Raw arguments for an object patch (partial update) operation before additional CRUD arguments are merged in.
|
|
164
|
+
*/
|
|
128
165
|
export type PartialArgsRaw = {
|
|
129
166
|
/**
|
|
130
|
-
*
|
|
167
|
+
* The arguments to be passed to the crud handlers.
|
|
131
168
|
*/
|
|
132
169
|
target: TargetArgs;
|
|
133
170
|
/**
|
|
134
|
-
*
|
|
171
|
+
* The pk of the object to be acted upon.
|
|
135
172
|
*/
|
|
136
173
|
pk: import("./commonCrud.js").Pk;
|
|
137
174
|
/**
|
|
138
|
-
*
|
|
175
|
+
* The key name of the primary key.
|
|
139
176
|
*/
|
|
140
177
|
pkKey: string;
|
|
141
178
|
/**
|
|
142
|
-
*
|
|
179
|
+
* The data to be acted upon.
|
|
143
180
|
*/
|
|
144
181
|
partialObject: {
|
|
145
182
|
[key: string]: any;
|
|
146
183
|
};
|
|
147
184
|
/**
|
|
148
|
-
*
|
|
185
|
+
* The arguments to be passed to the retrieve function.
|
|
149
186
|
*/
|
|
150
187
|
params: {
|
|
151
188
|
[key: string]: any;
|
|
152
189
|
};
|
|
153
190
|
/**
|
|
154
|
-
*
|
|
191
|
+
* A ref to indicate if the request was cancelled.
|
|
155
192
|
*/
|
|
156
193
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
157
194
|
};
|
|
195
|
+
/**
|
|
196
|
+
* Arguments for an object patch (partial update) operation, combining the raw arguments with any additional CRUD arguments.
|
|
197
|
+
*/
|
|
158
198
|
export type PartialArgs = PartialArgsRaw & AdditionalCrudArgs;
|
|
199
|
+
/**
|
|
200
|
+
* Raw arguments for a single-object execute-action operation before additional CRUD arguments are merged in.
|
|
201
|
+
*/
|
|
159
202
|
export type ObjectExecuteActionArgsRaw = {
|
|
160
203
|
/**
|
|
161
|
-
*
|
|
204
|
+
* The arguments to be passed to the crud handlers.
|
|
162
205
|
*/
|
|
163
206
|
target: import("../config/objectCrud.js").TargetArgs;
|
|
164
207
|
/**
|
|
165
|
-
*
|
|
208
|
+
* The id of the objects to be acted upon.
|
|
166
209
|
*/
|
|
167
210
|
pk: string;
|
|
168
211
|
/**
|
|
169
|
-
*
|
|
212
|
+
* The key name of the primary key.
|
|
170
213
|
*/
|
|
171
214
|
pkKey: string;
|
|
172
215
|
/**
|
|
173
|
-
*
|
|
216
|
+
* The action to execute.
|
|
174
217
|
*/
|
|
175
218
|
action: string;
|
|
176
219
|
/**
|
|
177
|
-
*
|
|
220
|
+
* A ref to indicate if the request was cancelled.
|
|
178
221
|
*/
|
|
179
222
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
180
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* Arguments for a single-object execute-action operation, combining the raw arguments with any additional CRUD arguments.
|
|
226
|
+
*/
|
|
181
227
|
export type ObjectExecuteActionArgs = ObjectExecuteActionArgsRaw & AdditionalCrudArgs;
|
|
228
|
+
/**
|
|
229
|
+
* Callback invoked with the changed object and the action (create, update, or delete) when a subscribed object changes.
|
|
230
|
+
*/
|
|
182
231
|
export type CrudSubscribeCallback = (data: import("../use/objectInstance.js").ExistingCrudObject, action: "delete" | "update" | "create") => any;
|
|
232
|
+
/**
|
|
233
|
+
* Raw arguments for a single-object subscribe operation before run-tracking and additional CRUD arguments are merged in.
|
|
234
|
+
*/
|
|
183
235
|
export type ObjectSubscribeArgsRaw = {
|
|
184
236
|
/**
|
|
185
|
-
*
|
|
237
|
+
* The arguments to be passed to the crud handlers.
|
|
186
238
|
*/
|
|
187
239
|
target: TargetArgs;
|
|
188
240
|
/**
|
|
189
|
-
*
|
|
241
|
+
* The pk of the object to be acted upon.
|
|
190
242
|
*/
|
|
191
243
|
pk: import("./commonCrud.js").Pk;
|
|
192
244
|
/**
|
|
193
|
-
*
|
|
245
|
+
* The key name of the primary key.
|
|
194
246
|
*/
|
|
195
247
|
pkKey: string;
|
|
196
248
|
/**
|
|
197
|
-
*
|
|
249
|
+
* The arguments to be passed to the retrieve function.
|
|
198
250
|
*/
|
|
199
251
|
params: {
|
|
200
252
|
[key: string]: any;
|
|
201
253
|
};
|
|
202
254
|
/**
|
|
203
|
-
*
|
|
255
|
+
* The callback to be called when the object is updated.
|
|
204
256
|
*/
|
|
205
257
|
callback: CrudSubscribeCallback;
|
|
206
258
|
/**
|
|
207
|
-
*
|
|
259
|
+
* A ref to indicate if the request was cancelled.
|
|
208
260
|
*/
|
|
209
261
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
210
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* Arguments for a single-object subscribe operation, combining the raw arguments with run-tracking and any additional CRUD arguments.
|
|
265
|
+
*/
|
|
211
266
|
export type ObjectSubscribeArgs = ObjectSubscribeArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking & AdditionalCrudArgs;
|
|
267
|
+
/**
|
|
268
|
+
* The value returned by an object CRUD handler, a possibly-cancellable promise resolving to an object or string.
|
|
269
|
+
*/
|
|
212
270
|
export type CrudResponse = import("../utils/cancellablePromise.js").MaybeCancellablePromise<object | string>;
|
|
271
|
+
/**
|
|
272
|
+
* Signature for the handler that creates an object in the backing store.
|
|
273
|
+
*/
|
|
213
274
|
export type CrudCreateFn = (args: CreateArgs) => CrudResponse;
|
|
275
|
+
/**
|
|
276
|
+
* Signature for the handler that retrieves an object from the backing store.
|
|
277
|
+
*/
|
|
214
278
|
export type CrudRetrieveFn = (args: RetrieveArgs) => CrudResponse;
|
|
279
|
+
/**
|
|
280
|
+
* Signature for the handler that updates an object in the backing store.
|
|
281
|
+
*/
|
|
215
282
|
export type CrudUpdateFn = (args: UpdateArgs) => CrudResponse;
|
|
283
|
+
/**
|
|
284
|
+
* Signature for the handler that partially updates (patches) an object in the backing store.
|
|
285
|
+
*/
|
|
216
286
|
export type CrudPatchFn = (args: PartialArgs) => CrudResponse;
|
|
287
|
+
/**
|
|
288
|
+
* Signature for the handler that deletes an object from the backing store.
|
|
289
|
+
*/
|
|
217
290
|
export type CrudDeleteFn = (args: DeleteArgs) => CrudResponse;
|
|
291
|
+
/**
|
|
292
|
+
* Signature for the handler that executes an action on a single object in the backing store.
|
|
293
|
+
*/
|
|
218
294
|
export type CrudObjectExecuteActionFn = (args: ObjectExecuteActionArgs) => CrudResponse;
|
|
295
|
+
/**
|
|
296
|
+
* Signature for the handler that subscribes to changes on a single object in the backing store.
|
|
297
|
+
*/
|
|
219
298
|
export type CrudObjectSubscribeFn = (args: ObjectSubscribeArgs) => import("../utils/cancellablePromise.js").CancellablePromise<void>;
|
|
220
299
|
/**
|
|
221
300
|
* Defines the CRUD-related handlers and additional utilities provided by the object instance.
|
|
222
301
|
*/
|
|
223
302
|
export type ObjectCrudHandlers = {
|
|
224
303
|
/**
|
|
225
|
-
*
|
|
304
|
+
* A function to be used instead of the default crud create function.
|
|
226
305
|
*/
|
|
227
306
|
create?: CrudCreateFn;
|
|
228
307
|
/**
|
|
229
|
-
*
|
|
308
|
+
* A function to be used instead of the default crud retrieve function.
|
|
230
309
|
*/
|
|
231
310
|
retrieve?: CrudRetrieveFn;
|
|
232
311
|
/**
|
|
233
|
-
*
|
|
312
|
+
* A function to be used instead of the default crud update function.
|
|
234
313
|
*/
|
|
235
314
|
update?: CrudUpdateFn;
|
|
236
315
|
/**
|
|
237
|
-
*
|
|
316
|
+
* A function to be used instead of the default crud delete function.
|
|
238
317
|
*/
|
|
239
318
|
delete?: CrudDeleteFn;
|
|
240
319
|
/**
|
|
241
|
-
*
|
|
320
|
+
* A function to be used instead of the default crud patch function.
|
|
242
321
|
*/
|
|
243
322
|
patch?: CrudPatchFn;
|
|
244
323
|
/**
|
|
245
|
-
*
|
|
324
|
+
* A function to be used instead of the default crud subscribe function.
|
|
246
325
|
*/
|
|
247
326
|
subscribe?: CrudObjectSubscribeFn;
|
|
248
327
|
/**
|
|
249
|
-
*
|
|
328
|
+
* The function to execute a certain action on an object.
|
|
250
329
|
*/
|
|
251
330
|
executeAction?: CrudObjectExecuteActionFn;
|
|
252
331
|
};
|
|
@@ -22,9 +22,7 @@
|
|
|
22
22
|
* @typedef {() => boolean} IsCurrentRunFn - A function that checks if the current run ID matches the last run ID.
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
|
-
* The common run tracking arguments.
|
|
26
|
-
*
|
|
27
|
-
* @typedef {object} CommonRunTracking
|
|
25
|
+
* @typedef {object} CommonRunTracking - The common run tracking arguments.
|
|
28
26
|
* @property {RunId} runId - The unique identifier for your run.
|
|
29
27
|
* @property {IsCurrentRunFn} isCurrentRun - A function that checks if the current run ID matches your run ID.
|
|
30
28
|
*/
|
|
@@ -42,9 +40,7 @@
|
|
|
42
40
|
* @property {boolean} [clearActiveOnResolved=true] - Whether to clear the active state when the promise resolves.
|
|
43
41
|
*/
|
|
44
42
|
/**
|
|
45
|
-
* Cancel function signature for cancellable intent.
|
|
46
|
-
*
|
|
47
|
-
* @typedef {Function} CancelFn
|
|
43
|
+
* @typedef {Function} CancelFn - Cancel function signature for cancellable intent.
|
|
48
44
|
* @param {any} reason - The reason for cancellation.
|
|
49
45
|
* @param {boolean} [forceClearActive=false] - Whether to force clear the active state.
|
|
50
46
|
* @returns {Promise<void>} - A promise that resolves when the cancellation is complete.
|
|
@@ -114,50 +110,50 @@ export class CancellableIntentError extends Error {
|
|
|
114
110
|
code: string;
|
|
115
111
|
}
|
|
116
112
|
/**
|
|
117
|
-
*
|
|
113
|
+
* A unique identifier for a single execution ("run") of an intent.
|
|
118
114
|
* This is incremented each time `watchArguments` change and the intent re-triggers.
|
|
119
115
|
* Enables distinguishing results or effects from overlapping async runs.
|
|
120
116
|
*/
|
|
121
117
|
export type RunId = number;
|
|
122
118
|
/**
|
|
123
|
-
*
|
|
119
|
+
* The raw state of the cancellable intent.
|
|
124
120
|
*/
|
|
125
121
|
export type CancellableIntentMyState = {
|
|
126
122
|
/**
|
|
127
|
-
*
|
|
123
|
+
* Whether there are active intents.
|
|
128
124
|
*/
|
|
129
125
|
active: import("vue").ComputedRef<boolean> | undefined;
|
|
130
126
|
/**
|
|
131
|
-
*
|
|
127
|
+
* Whether there are resolving intents.
|
|
132
128
|
*/
|
|
133
129
|
resolving: import("vue").ComputedRef<boolean> | undefined;
|
|
134
130
|
/**
|
|
135
|
-
*
|
|
131
|
+
* Whether to clear the active state when the promise resolves.
|
|
136
132
|
*/
|
|
137
133
|
clearActiveOnResolved: boolean;
|
|
138
134
|
/**
|
|
139
|
-
*
|
|
135
|
+
* The most recent run ID issued for a triggered intent. Useful for associating async results with their originating trigger.
|
|
140
136
|
*/
|
|
141
137
|
lastRunId: RunId | null;
|
|
142
138
|
/**
|
|
143
|
-
*
|
|
139
|
+
* The watch arguments.
|
|
144
140
|
*/
|
|
145
141
|
watchArguments: import("vue").DeepReadonly<object>;
|
|
146
142
|
/**
|
|
147
|
-
*
|
|
143
|
+
* The guard arguments.
|
|
148
144
|
*/
|
|
149
145
|
guardArguments: import("vue").DeepReadonly<object>;
|
|
150
146
|
};
|
|
151
147
|
/**
|
|
152
|
-
*
|
|
148
|
+
* The raw state of the cancellable intent.
|
|
153
149
|
*/
|
|
154
150
|
export type CancellableIntentRawState = CancellableIntentMyState & import("./error.js").ErrorProperties;
|
|
155
151
|
/**
|
|
156
|
-
*
|
|
152
|
+
* The state of the cancellable intent.
|
|
157
153
|
*/
|
|
158
154
|
export type CancellableIntentState = import("vue").Reactive<CancellableIntentRawState>;
|
|
159
155
|
/**
|
|
160
|
-
*
|
|
156
|
+
* A function that checks if the current run ID matches the last run ID.
|
|
161
157
|
*/
|
|
162
158
|
export type IsCurrentRunFn = () => boolean;
|
|
163
159
|
/**
|
|
@@ -165,42 +161,42 @@ export type IsCurrentRunFn = () => boolean;
|
|
|
165
161
|
*/
|
|
166
162
|
export type CommonRunTracking = {
|
|
167
163
|
/**
|
|
168
|
-
*
|
|
164
|
+
* The unique identifier for your run.
|
|
169
165
|
*/
|
|
170
166
|
runId: RunId;
|
|
171
167
|
/**
|
|
172
|
-
*
|
|
168
|
+
* A function that checks if the current run ID matches your run ID.
|
|
173
169
|
*/
|
|
174
170
|
isCurrentRun: IsCurrentRunFn;
|
|
175
171
|
};
|
|
176
172
|
/**
|
|
177
|
-
*
|
|
173
|
+
* A function that returns a promise that can be cancelled. The return value of the promise is not used.
|
|
178
174
|
*/
|
|
179
175
|
export type AwaitableWithCancel = (runTracking: CommonRunTracking) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<unknown>;
|
|
180
176
|
/**
|
|
181
|
-
*
|
|
177
|
+
* The reactive object to watch for changes.
|
|
182
178
|
*/
|
|
183
179
|
export type WatchGuardArguments = import("vue").UnwrapNestedRefs<object> | {
|
|
184
180
|
[key: string]: import("vue").Ref<any>;
|
|
185
181
|
};
|
|
186
182
|
/**
|
|
187
|
-
*
|
|
183
|
+
* The options for the cancellable intent.
|
|
188
184
|
*/
|
|
189
185
|
export type CancellableIntentOptions = {
|
|
190
186
|
/**
|
|
191
|
-
*
|
|
187
|
+
* The function that returns a promise that can be cancelled. Receives the run ID as an argument.
|
|
192
188
|
*/
|
|
193
189
|
awaitableWithCancel: AwaitableWithCancel;
|
|
194
190
|
/**
|
|
195
|
-
*
|
|
191
|
+
* The reactive object to watch for changes.
|
|
196
192
|
*/
|
|
197
193
|
watchArguments?: WatchGuardArguments;
|
|
198
194
|
/**
|
|
199
|
-
*
|
|
195
|
+
* The reactive object to watch for truthiness before running the intent.
|
|
200
196
|
*/
|
|
201
197
|
guardArguments?: WatchGuardArguments;
|
|
202
198
|
/**
|
|
203
|
-
*
|
|
199
|
+
* Whether to clear the active state when the promise resolves.
|
|
204
200
|
*/
|
|
205
201
|
clearActiveOnResolved?: boolean;
|
|
206
202
|
};
|
|
@@ -209,23 +205,23 @@ export type CancellableIntentOptions = {
|
|
|
209
205
|
*/
|
|
210
206
|
export type CancelFn = Function;
|
|
211
207
|
/**
|
|
212
|
-
*
|
|
208
|
+
* The instance of the cancellable intent.
|
|
213
209
|
*/
|
|
214
210
|
export type MyCancellableIntent = {
|
|
215
211
|
/**
|
|
216
|
-
*
|
|
212
|
+
* The state of the cancellable intent.
|
|
217
213
|
*/
|
|
218
214
|
state: CancellableIntentState;
|
|
219
215
|
/**
|
|
220
|
-
*
|
|
216
|
+
* Stop the cancellable intent.
|
|
221
217
|
*/
|
|
222
218
|
stop: () => void;
|
|
223
219
|
/**
|
|
224
|
-
*
|
|
220
|
+
* Cancel the cancellable intent.
|
|
225
221
|
*/
|
|
226
222
|
cancel: CancelFn;
|
|
227
223
|
};
|
|
228
224
|
/**
|
|
229
|
-
*
|
|
225
|
+
* The instance of the cancellable intent.
|
|
230
226
|
*/
|
|
231
227
|
export type CancellableIntent = MyCancellableIntent & import("./error.js").ErrorReadOnlyFunctions;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* string[] |
|
|
5
5
|
* { [key: string]: boolean | import("vue").Ref<boolean> } |
|
|
6
6
|
* import("vue").Ref<string | string[]>
|
|
7
|
-
* )} CSSClasses
|
|
7
|
+
* )} CSSClasses - The accepted ways of specifying CSS classes to useCombineClasses (a string, array, class-map, or ref thereof).
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Normalize various ways of specifying CSS classes into an object for use in Vue.js with reactivity. If refs are
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
* preserve order of operations in reactive contexts.
|
|
38
38
|
*/
|
|
39
39
|
export function useCombineClasses(...classes: (CSSClasses)[]): import("vue").Ref<import("../utils/classes.js").CombinedClasses>;
|
|
40
|
+
/**
|
|
41
|
+
* The accepted ways of specifying CSS classes to useCombineClasses (a string, array, class-map, or ref thereof).
|
|
42
|
+
*/
|
|
40
43
|
export type CSSClasses = (string | string[] | {
|
|
41
44
|
[key: string]: boolean | import("vue").Ref<boolean>;
|
|
42
45
|
} | import("vue").Ref<string | string[]>);
|
package/types/use/error.d.ts
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
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
|
|
2
|
+
* @typedef {() => void} ClearErrorFn - Signature for the function that clears the current error state.
|
|
3
|
+
* @typedef {import("vue").Ref<Error|null>} ErrorRef - A Vue ref holding the current error, or null when there is none.
|
|
4
|
+
* @typedef {import("vue").Ref<boolean>} ErroredRef - A Vue ref to the boolean indicating whether an error has occurred.
|
|
5
|
+
* @typedef {Readonly<ErrorRef>} ErrorReadonlyRef - A readonly Vue ref holding the current error, or null when there is none.
|
|
6
|
+
* @typedef {Readonly<ErroredRef>} ErroredReadonlyRef - A readonly Vue ref to the boolean indicating whether an error has occurred.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* @typedef {object} ErrorProperties
|
|
9
|
+
* @typedef {object} ErrorProperties - The reactive error-state members (error and errored) contributed by the useError composable.
|
|
10
10
|
* @property {ErrorReadonlyRef} error - The error that occurred.
|
|
11
11
|
* @property {ErroredReadonlyRef} errored - Whether an error has occurred.
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
|
-
* @typedef {object} ErrorFunctions
|
|
14
|
+
* @typedef {object} ErrorFunctions - The error-state actions (setError, clearError) contributed by the useError composable.
|
|
15
15
|
* @property {(error: Error) => void} setError - Set the error state.
|
|
16
16
|
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
|
-
* Proxies can still clear errors but cannot set them directly.
|
|
20
|
-
*
|
|
21
|
-
* @typedef {object} ErrorReadOnlyFunctions
|
|
19
|
+
* @typedef {object} ErrorReadOnlyFunctions - Proxies can still clear errors but cannot set them directly.
|
|
22
20
|
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
23
21
|
*/
|
|
24
22
|
/**
|
|
25
|
-
* @typedef {ErrorProperties & ErrorReadOnlyFunctions} ReadonlyErrorStatus
|
|
23
|
+
* @typedef {ErrorProperties & ErrorReadOnlyFunctions} ReadonlyErrorStatus - The readonly error-state API (error and errored plus clearError) exposed to consumers and proxies.
|
|
26
24
|
*/
|
|
27
25
|
/**
|
|
28
|
-
* The error state API.
|
|
29
|
-
*
|
|
30
|
-
* @typedef {ErrorProperties & ErrorFunctions} ErrorStatus
|
|
26
|
+
* @typedef {ErrorProperties & ErrorFunctions} ErrorStatus - The error state API.
|
|
31
27
|
*/
|
|
32
28
|
/**
|
|
33
29
|
* A composable function for managing error state.
|
|
@@ -35,28 +31,49 @@
|
|
|
35
31
|
* @returns {ErrorStatus} - An object containing reactive fields and actions for error state.
|
|
36
32
|
*/
|
|
37
33
|
export function useError(): ErrorStatus;
|
|
34
|
+
/**
|
|
35
|
+
* Signature for the function that clears the current error state.
|
|
36
|
+
*/
|
|
38
37
|
export type ClearErrorFn = () => void;
|
|
38
|
+
/**
|
|
39
|
+
* A Vue ref holding the current error, or null when there is none.
|
|
40
|
+
*/
|
|
39
41
|
export type ErrorRef = import("vue").Ref<Error | null>;
|
|
42
|
+
/**
|
|
43
|
+
* A Vue ref to the boolean indicating whether an error has occurred.
|
|
44
|
+
*/
|
|
40
45
|
export type ErroredRef = import("vue").Ref<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* A readonly Vue ref holding the current error, or null when there is none.
|
|
48
|
+
*/
|
|
41
49
|
export type ErrorReadonlyRef = Readonly<ErrorRef>;
|
|
50
|
+
/**
|
|
51
|
+
* A readonly Vue ref to the boolean indicating whether an error has occurred.
|
|
52
|
+
*/
|
|
42
53
|
export type ErroredReadonlyRef = Readonly<ErroredRef>;
|
|
54
|
+
/**
|
|
55
|
+
* The reactive error-state members (error and errored) contributed by the useError composable.
|
|
56
|
+
*/
|
|
43
57
|
export type ErrorProperties = {
|
|
44
58
|
/**
|
|
45
|
-
*
|
|
59
|
+
* The error that occurred.
|
|
46
60
|
*/
|
|
47
61
|
error: ErrorReadonlyRef;
|
|
48
62
|
/**
|
|
49
|
-
*
|
|
63
|
+
* Whether an error has occurred.
|
|
50
64
|
*/
|
|
51
65
|
errored: ErroredReadonlyRef;
|
|
52
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* The error-state actions (setError, clearError) contributed by the useError composable.
|
|
69
|
+
*/
|
|
53
70
|
export type ErrorFunctions = {
|
|
54
71
|
/**
|
|
55
|
-
*
|
|
72
|
+
* Set the error state.
|
|
56
73
|
*/
|
|
57
74
|
setError: (error: Error) => void;
|
|
58
75
|
/**
|
|
59
|
-
*
|
|
76
|
+
* Clear the error state.
|
|
60
77
|
*/
|
|
61
78
|
clearError: ClearErrorFn;
|
|
62
79
|
};
|
|
@@ -65,10 +82,13 @@ export type ErrorFunctions = {
|
|
|
65
82
|
*/
|
|
66
83
|
export type ErrorReadOnlyFunctions = {
|
|
67
84
|
/**
|
|
68
|
-
*
|
|
85
|
+
* Clear the error state.
|
|
69
86
|
*/
|
|
70
87
|
clearError: ClearErrorFn;
|
|
71
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* The readonly error-state API (error and errored plus clearError) exposed to consumers and proxies.
|
|
91
|
+
*/
|
|
72
92
|
export type ReadonlyErrorStatus = ErrorProperties & ErrorReadOnlyFunctions;
|
|
73
93
|
/**
|
|
74
94
|
* The error state API.
|