@arrai-innovations/reactive-helpers 18.0.2 → 18.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/config/listCrud.js +1 -1
- package/config/objectCrud.js +129 -47
- package/index.js +3 -0
- package/package.json +2 -2
- package/types/config/listCrud.d.ts +1 -1
- package/types/config/objectCrud.d.ts +99 -33
- package/types/config/objectCrud.d.ts.map +1 -1
- package/types/index.d.ts +3 -0
- package/types/use/cancellableIntent.d.ts +2 -13
- package/types/use/cancellableIntent.d.ts.map +1 -1
- package/types/use/listInstance.d.ts +2 -2
- package/types/use/listInstance.d.ts.map +1 -1
- package/types/use/loadingError.d.ts +30 -6
- package/types/use/loadingError.d.ts.map +1 -1
- package/types/use/objectInstance.d.ts +83 -31
- package/types/use/objectInstance.d.ts.map +1 -1
- package/types/use/objectSubscription.d.ts +33 -29
- package/types/use/objectSubscription.d.ts.map +1 -1
- package/types/use/proxyLoadingError.d.ts +8 -23
- package/types/use/proxyLoadingError.d.ts.map +1 -1
- package/types/utils/cancellableFetch.d.ts +12 -0
- package/types/utils/cancellableFetch.d.ts.map +1 -0
- package/types/utils/cancellablePromise.d.ts +40 -0
- package/types/utils/cancellablePromise.d.ts.map +1 -0
- package/types/utils/deepUnref.d.ts +26 -0
- package/types/utils/deepUnref.d.ts.map +1 -0
- package/use/cancellableIntent.js +8 -13
- package/use/listInstance.js +39 -40
- package/use/listSearch.js +1 -1
- package/use/loadingError.js +30 -6
- package/use/objectInstance.js +225 -125
- package/use/objectSubscription.js +81 -82
- package/use/proxyLoadingError.js +14 -27
- package/use/search.js +1 -1
- package/utils/cancellableFetch.js +22 -0
- package/utils/cancellablePromise.js +70 -0
- package/utils/classes.js +5 -5
- package/utils/deepUnref.js +28 -0
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
* @property {(objectId: string) => void} deleteListObject - Deletes an object from the list by pk.
|
|
73
73
|
* @property {() => void} clearList - Clears all objects and errors from the list.
|
|
74
74
|
* @property {() => string} getFakePk - Generates a unique fake pk for use within the list.
|
|
75
|
-
* @property {() =>
|
|
75
|
+
* @property {() => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} list - Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
|
|
76
76
|
* @property {() => Promise<boolean>} bulkDelete - Initiates a bulk delete operation on all objects in the list, returning a promise to a boolean indicating success.
|
|
77
77
|
* @property {() => Promise<object|string|false>} executeAction - Initiates an action on all objects in the list, returning the response, or false if the action failed.
|
|
78
78
|
*/
|
|
@@ -326,7 +326,7 @@ export type ListInstanceFunctions = {
|
|
|
326
326
|
/**
|
|
327
327
|
* - Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
|
|
328
328
|
*/
|
|
329
|
-
list: () =>
|
|
329
|
+
list: () => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
330
330
|
/**
|
|
331
331
|
* - Initiates a bulk delete operation on all objects in the list, returning a promise to a boolean indicating success.
|
|
332
332
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listInstance.d.ts","sourceRoot":"","sources":["../../use/listInstance.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listInstance.d.ts","sourceRoot":"","sources":["../../use/listInstance.js"],"names":[],"mappings":"AAuCA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AACH,mDAHW;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAAC,GAClC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAC,CASzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,oEALW,mBAAmB,GAEjB,YAAY,CAsTxB;AA1fD;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH;IACI;;;;;OAKG;IACH,qBAHW,MAAM,QACN,MAAM,EAMhB;IADG,aAAgB;CAEvB;;;;;;;;WAMa,MAAM;;;;kBACN,MAAM;;;;cACN,MAAM;;;;cACN,MAAM;;;;;;;;;WAON,OAAO,KAAK,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;;;;gBAE5D;QAA8D,IAAI,GAAvD,OAAO,uBAAuB,EAAE,MAAM;QAEoB,UAAU,GAAnE,OAAO,uBAAuB,EAAE,YAAY;QAEiB,aAAa,GAAzE,OAAO,uBAAuB,EAAE,eAAe;QAEO,SAAS,GAAjE,OAAO,uBAAuB,EAAE,WAAW;KAEtD;;;;kBAAW,OAAO;;;;;0BAMR;IAAC,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAA;CAAC;;;;6BAM1B,OAAO,KAAK,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC;;;;wBAMvC,OAAO,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;;;;;;;;UAQ7C;QAAwB,IAAI,EAAjB,MAAM;QACU,IAAI;KAC/B;;;;WAAW,MAAM;;;;kBACN,MAAM;;;;cACN,MAAM;;;;aACN,WAAW;;;;aACX,OAAO;;;;cACP,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;aACpC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;WACpC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,KAAK,GAAC,IAAI,CAAC,CAAC;;;;WACvC,SAAS;;;;oBACT,cAAc;;;;;gCAMf,OAAO,KAAK,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;;;;;;;;yBAOnD,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,IAAI;;;;kBAClC,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,IAAI;;;;mBAClC,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;;;;sBAC5B,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;;;;sBAC5B,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI;;;;eAC1B,MAAM,IAAI;;;;eACV,MAAM,MAAM;;;;UACZ,MAAM,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,OAAO,GAAC,KAAK,CAAC;;;;gBACrF,MAAM,OAAO,CAAC,OAAO,CAAC;;;;mBACtB,MAAM,OAAO,CAAC,MAAM,GAAC,MAAM,GAAC,KAAK,CAAC;;;;;qCAMnC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAC;;;;2BAM1B,sBAAsB,GAAG,qBAAqB;;;;;yBApH9C;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC"}
|
|
@@ -4,13 +4,31 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {() => void} ClearErrorFn - Clear the error state.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("vue").Ref<boolean|undefined>} LoadingRef
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import("vue").Ref<Error|null>} ErrorRef
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import("vue").Ref<boolean>} ErroredRef
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Readonly<LoadingRef>} LoadingReadonlyRef
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Readonly<ErrorRef>} ErrorReadonlyRef
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Readonly<ErroredRef>} ErroredReadonlyRef
|
|
24
|
+
*/
|
|
7
25
|
/**
|
|
8
26
|
* The common API for loading and error states.
|
|
9
27
|
*
|
|
10
28
|
* @typedef {object} LoadingErrorStatus
|
|
11
|
-
* @property {
|
|
12
|
-
* @property {
|
|
13
|
-
* @property {
|
|
29
|
+
* @property {LoadingReadonlyRef} loading - Whether the component is loading.
|
|
30
|
+
* @property {ErrorReadonlyRef} error - The error that occurred.
|
|
31
|
+
* @property {ErroredReadonlyRef} errored - Whether an error has occurred.
|
|
14
32
|
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
15
33
|
*/
|
|
16
34
|
/**
|
|
@@ -36,6 +54,12 @@ export function useLoadingError(): LoadingError;
|
|
|
36
54
|
* - Clear the error state.
|
|
37
55
|
*/
|
|
38
56
|
export type ClearErrorFn = () => void;
|
|
57
|
+
export type LoadingRef = import("vue").Ref<boolean | undefined>;
|
|
58
|
+
export type ErrorRef = import("vue").Ref<Error | null>;
|
|
59
|
+
export type ErroredRef = import("vue").Ref<boolean>;
|
|
60
|
+
export type LoadingReadonlyRef = Readonly<LoadingRef>;
|
|
61
|
+
export type ErrorReadonlyRef = Readonly<ErrorRef>;
|
|
62
|
+
export type ErroredReadonlyRef = Readonly<ErroredRef>;
|
|
39
63
|
/**
|
|
40
64
|
* The common API for loading and error states.
|
|
41
65
|
*/
|
|
@@ -43,15 +67,15 @@ export type LoadingErrorStatus = {
|
|
|
43
67
|
/**
|
|
44
68
|
* - Whether the component is loading.
|
|
45
69
|
*/
|
|
46
|
-
loading:
|
|
70
|
+
loading: LoadingReadonlyRef;
|
|
47
71
|
/**
|
|
48
72
|
* - The error that occurred.
|
|
49
73
|
*/
|
|
50
|
-
error:
|
|
74
|
+
error: ErrorReadonlyRef;
|
|
51
75
|
/**
|
|
52
76
|
* - Whether an error has occurred.
|
|
53
77
|
*/
|
|
54
|
-
errored:
|
|
78
|
+
errored: ErroredReadonlyRef;
|
|
55
79
|
/**
|
|
56
80
|
* - Clear the error state.
|
|
57
81
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadingError.d.ts","sourceRoot":"","sources":["../../use/loadingError.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH,mCAFa,YAAY,CA6BxB;;;;
|
|
1
|
+
{"version":3,"file":"loadingError.d.ts","sourceRoot":"","sources":["../../use/loadingError.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;;;GAIG;AACH,mCAFa,YAAY,CA6BxB;;;;2BApFY,MAAM,IAAI;yBAIV,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,GAAC,SAAS,CAAC;uBAIpC,OAAO,KAAK,EAAE,GAAG,CAAC,KAAK,GAAC,IAAI,CAAC;yBAI7B,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;iCAI1B,QAAQ,CAAC,UAAU,CAAC;+BAIpB,QAAQ,CAAC,QAAQ,CAAC;iCAIlB,QAAQ,CAAC,UAAU,CAAC;;;;;;;;aAOnB,kBAAkB;;;;WAClB,gBAAgB;;;;aAChB,kBAAkB;;;;gBAClB,YAAY;;;;;;;;;gBAOZ,MAAM,IAAI;;;;kBACV,MAAM,IAAI;;;;cACV,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;;;;2BAMvB,kBAAkB,GAAG,qBAAqB"}
|
|
@@ -70,14 +70,20 @@ export function useObjectInstance({ props, functions }: ObjectInstanceOptions):
|
|
|
70
70
|
/**
|
|
71
71
|
* The object being managed by the instance. Empty object is the default.
|
|
72
72
|
*
|
|
73
|
-
* @typedef {{pkKey: string, [key: string]: any}
|
|
73
|
+
* @typedef {{pkKey: string, [key: string]: any}} ExistingCrudObject
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {{[key: string]: any}} NewCrudObject
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {ExistingCrudObject|NewCrudObject} CrudObject
|
|
74
80
|
*/
|
|
75
81
|
/**
|
|
76
82
|
* Arguments to be passed to the object instance.
|
|
77
83
|
*
|
|
78
84
|
* @typedef {object} ObjectInstanceOptions
|
|
79
85
|
* @property {import('vue').UnwrapNestedRefs<ObjectInstanceRawProps>} props - The reactive configuration object.
|
|
80
|
-
* @property {import('../config/objectCrud.js').ObjectCrudFunctions} functions - An object of custom crud functions to use instead of the defaults.
|
|
86
|
+
* @property {import('../config/objectCrud.js').ObjectCrudFunctions} [functions] - An object of custom crud functions to use instead of the defaults.
|
|
81
87
|
*/
|
|
82
88
|
/**
|
|
83
89
|
* Reactive arguments to be passed to the object instance.
|
|
@@ -88,35 +94,45 @@ export function useObjectInstance({ props, functions }: ObjectInstanceOptions):
|
|
|
88
94
|
* @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
|
|
89
95
|
* @property {import('../config/objectCrud.js').ObjectCrudArgs} crudArgs - The arguments to be passed to the crud functions.
|
|
90
96
|
*/
|
|
97
|
+
/**
|
|
98
|
+
* @typedef {object} ObjectInstanceRawStateCrud
|
|
99
|
+
* @property {import('vue').Reactive<import('../config/objectCrud.js').ObjectCrudArgsArgs|{}>} args - The arguments to be passed to the crud functions.
|
|
100
|
+
* @property {import('../config/objectCrud.js').CrudCreateFn} create - The create function.
|
|
101
|
+
* @property {import('../config/objectCrud.js').CrudRetrieveFn} retrieve - The retrieve function.
|
|
102
|
+
* @property {import('../config/objectCrud.js').CrudUpdateFn} update - The update function.
|
|
103
|
+
* @property {import('../config/objectCrud.js').CrudPatchFn} patch - The patch function.
|
|
104
|
+
* @property {import('../config/objectCrud.js').CrudDeleteFn} delete - The delete function.
|
|
105
|
+
* @property {import('../config/objectCrud.js').CrudSubscribeFn} subscribe - The subscribe function.
|
|
106
|
+
*/
|
|
91
107
|
/**
|
|
92
108
|
* The raw state of the object instance.
|
|
93
109
|
*
|
|
94
110
|
* @typedef {object} ObjectInstanceRawState
|
|
95
|
-
* @property {import('
|
|
96
|
-
* @property {string} pk - The pk of the object.
|
|
97
|
-
* @property {string} pkKey - The pk key of the object.
|
|
98
|
-
* @property {
|
|
99
|
-
* @property {CrudObject} object - The object.
|
|
111
|
+
* @property {import('vue').ShallowReactive<ObjectInstanceRawStateCrud>} crud - The crud functions.
|
|
112
|
+
* @property {import('vue').Ref<string|undefined>} pk - The pk of the object.
|
|
113
|
+
* @property {import('vue').Ref<string|undefined>} pkKey - The pk key of the object.
|
|
114
|
+
* @property {import('vue').Ref<{[key:string]: any}>} retrieveArgs - The arguments to be passed to the retrieve function.
|
|
115
|
+
* @property {import('vue').Reactive<CrudObject>} object - The object.
|
|
100
116
|
* @property {Readonly<import('vue').Ref<boolean>>} loading - Whether the object is loading.
|
|
101
117
|
* @property {Readonly<import('vue').Ref<boolean>>} errored - Whether the object errored.
|
|
102
118
|
* @property {Readonly<import('vue').Ref<Error|null>>} error - The error.
|
|
103
|
-
* @property {
|
|
119
|
+
* @property {boolean} deleted - Whether the object is deleted.
|
|
104
120
|
*/
|
|
105
121
|
/**
|
|
106
122
|
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors.
|
|
107
123
|
* Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
108
124
|
*
|
|
109
|
-
* @typedef {import('vue').
|
|
125
|
+
* @typedef {import('vue').Reactive<ObjectInstanceRawState>} ObjectInstanceState
|
|
110
126
|
*/
|
|
111
127
|
/**
|
|
112
128
|
* The functions available on the object instance.
|
|
113
129
|
*
|
|
114
130
|
* @typedef {object} ObjectInstanceFunctions
|
|
115
|
-
* @property {(args: { object: object }) =>
|
|
116
|
-
* @property {() =>
|
|
117
|
-
* @property {(args: { object:
|
|
118
|
-
* @property {() =>
|
|
119
|
-
* @property {(args: { partialObject:
|
|
131
|
+
* @property {(args: { object: object }) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean>} create - Called to turn the current object into a new object on the server.
|
|
132
|
+
* @property {() => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean>} retrieve - Called to retrieve the current object by pk from the server.
|
|
133
|
+
* @property {(args: { object: ExistingCrudObject }) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean>} update - Called to update the current object on the server.
|
|
134
|
+
* @property {() => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean>} delete - Called to delete the current object on the server.
|
|
135
|
+
* @property {(args: { partialObject: ExistingCrudObject }) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean>} patch - Called to patch the current object on the server.
|
|
120
136
|
* @property {import('./loadingError.js').ClearErrorFn} clearError - Called to clear the error state.
|
|
121
137
|
* @property {() => void} clear - Called to clear the object state.
|
|
122
138
|
*/
|
|
@@ -150,10 +166,14 @@ export const objectInstanceFunctions: string[];
|
|
|
150
166
|
/**
|
|
151
167
|
* The object being managed by the instance. Empty object is the default.
|
|
152
168
|
*/
|
|
153
|
-
export type
|
|
169
|
+
export type ExistingCrudObject = {
|
|
154
170
|
pkKey: string;
|
|
155
171
|
[key: string]: any;
|
|
156
|
-
}
|
|
172
|
+
};
|
|
173
|
+
export type NewCrudObject = {
|
|
174
|
+
[key: string]: any;
|
|
175
|
+
};
|
|
176
|
+
export type CrudObject = ExistingCrudObject | NewCrudObject;
|
|
157
177
|
/**
|
|
158
178
|
* Arguments to be passed to the object instance.
|
|
159
179
|
*/
|
|
@@ -165,7 +185,7 @@ export type ObjectInstanceOptions = {
|
|
|
165
185
|
/**
|
|
166
186
|
* - An object of custom crud functions to use instead of the defaults.
|
|
167
187
|
*/
|
|
168
|
-
functions
|
|
188
|
+
functions?: import("../config/objectCrud.js").ObjectCrudFunctions;
|
|
169
189
|
};
|
|
170
190
|
/**
|
|
171
191
|
* Reactive arguments to be passed to the object instance.
|
|
@@ -188,6 +208,36 @@ export type ObjectInstanceRawProps = {
|
|
|
188
208
|
*/
|
|
189
209
|
crudArgs: import("../config/objectCrud.js").ObjectCrudArgs;
|
|
190
210
|
};
|
|
211
|
+
export type ObjectInstanceRawStateCrud = {
|
|
212
|
+
/**
|
|
213
|
+
* - The arguments to be passed to the crud functions.
|
|
214
|
+
*/
|
|
215
|
+
args: import("vue").Reactive<import("../config/objectCrud.js").ObjectCrudArgsArgs | {}>;
|
|
216
|
+
/**
|
|
217
|
+
* - The create function.
|
|
218
|
+
*/
|
|
219
|
+
create: import("../config/objectCrud.js").CrudCreateFn;
|
|
220
|
+
/**
|
|
221
|
+
* - The retrieve function.
|
|
222
|
+
*/
|
|
223
|
+
retrieve: import("../config/objectCrud.js").CrudRetrieveFn;
|
|
224
|
+
/**
|
|
225
|
+
* - The update function.
|
|
226
|
+
*/
|
|
227
|
+
update: import("../config/objectCrud.js").CrudUpdateFn;
|
|
228
|
+
/**
|
|
229
|
+
* - The patch function.
|
|
230
|
+
*/
|
|
231
|
+
patch: import("../config/objectCrud.js").CrudPatchFn;
|
|
232
|
+
/**
|
|
233
|
+
* - The delete function.
|
|
234
|
+
*/
|
|
235
|
+
delete: import("../config/objectCrud.js").CrudDeleteFn;
|
|
236
|
+
/**
|
|
237
|
+
* - The subscribe function.
|
|
238
|
+
*/
|
|
239
|
+
subscribe: import("../config/objectCrud.js").CrudSubscribeFn;
|
|
240
|
+
};
|
|
191
241
|
/**
|
|
192
242
|
* The raw state of the object instance.
|
|
193
243
|
*/
|
|
@@ -195,23 +245,25 @@ export type ObjectInstanceRawState = {
|
|
|
195
245
|
/**
|
|
196
246
|
* - The crud functions.
|
|
197
247
|
*/
|
|
198
|
-
crud: import("
|
|
248
|
+
crud: import("vue").ShallowReactive<ObjectInstanceRawStateCrud>;
|
|
199
249
|
/**
|
|
200
250
|
* - The pk of the object.
|
|
201
251
|
*/
|
|
202
|
-
pk: string
|
|
252
|
+
pk: import("vue").Ref<string | undefined>;
|
|
203
253
|
/**
|
|
204
254
|
* - The pk key of the object.
|
|
205
255
|
*/
|
|
206
|
-
pkKey: string
|
|
256
|
+
pkKey: import("vue").Ref<string | undefined>;
|
|
207
257
|
/**
|
|
208
258
|
* - The arguments to be passed to the retrieve function.
|
|
209
259
|
*/
|
|
210
|
-
retrieveArgs:
|
|
260
|
+
retrieveArgs: import("vue").Ref<{
|
|
261
|
+
[key: string]: any;
|
|
262
|
+
}>;
|
|
211
263
|
/**
|
|
212
264
|
* - The object.
|
|
213
265
|
*/
|
|
214
|
-
object: CrudObject
|
|
266
|
+
object: import("vue").Reactive<CrudObject>;
|
|
215
267
|
/**
|
|
216
268
|
* - Whether the object is loading.
|
|
217
269
|
*/
|
|
@@ -227,13 +279,13 @@ export type ObjectInstanceRawState = {
|
|
|
227
279
|
/**
|
|
228
280
|
* - Whether the object is deleted.
|
|
229
281
|
*/
|
|
230
|
-
deleted:
|
|
282
|
+
deleted: boolean;
|
|
231
283
|
};
|
|
232
284
|
/**
|
|
233
285
|
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors.
|
|
234
286
|
* Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
235
287
|
*/
|
|
236
|
-
export type ObjectInstanceState = import("vue").
|
|
288
|
+
export type ObjectInstanceState = import("vue").Reactive<ObjectInstanceRawState>;
|
|
237
289
|
/**
|
|
238
290
|
* The functions available on the object instance.
|
|
239
291
|
*/
|
|
@@ -243,27 +295,27 @@ export type ObjectInstanceFunctions = {
|
|
|
243
295
|
*/
|
|
244
296
|
create: (args: {
|
|
245
297
|
object: object;
|
|
246
|
-
}) =>
|
|
298
|
+
}) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean>;
|
|
247
299
|
/**
|
|
248
300
|
* - Called to retrieve the current object by pk from the server.
|
|
249
301
|
*/
|
|
250
|
-
retrieve: () =>
|
|
302
|
+
retrieve: () => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean>;
|
|
251
303
|
/**
|
|
252
304
|
* - Called to update the current object on the server.
|
|
253
305
|
*/
|
|
254
306
|
update: (args: {
|
|
255
|
-
object:
|
|
256
|
-
}) =>
|
|
307
|
+
object: ExistingCrudObject;
|
|
308
|
+
}) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean>;
|
|
257
309
|
/**
|
|
258
310
|
* - Called to delete the current object on the server.
|
|
259
311
|
*/
|
|
260
|
-
delete: () =>
|
|
312
|
+
delete: () => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean>;
|
|
261
313
|
/**
|
|
262
314
|
* - Called to patch the current object on the server.
|
|
263
315
|
*/
|
|
264
316
|
patch: (args: {
|
|
265
|
-
partialObject:
|
|
266
|
-
}) =>
|
|
317
|
+
partialObject: ExistingCrudObject;
|
|
318
|
+
}) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean>;
|
|
267
319
|
/**
|
|
268
320
|
* - Called to clear the error state.
|
|
269
321
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectInstance.d.ts","sourceRoot":"","sources":["../../use/objectInstance.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"objectInstance.d.ts","sourceRoot":"","sources":["../../use/objectInstance.js"],"names":[],"mappings":"AAuIA;;;;;GAKG;AACH,iDAHW;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAAC,GACpC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAC,CAS3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wDAHW,qBAAqB,GACnB,cAAc,CAkR1B;AApdD;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;GAGG;AACH;IACI;;;;;OAKG;IACH,qBAHW,MAAM,QACN,MAAM,EAMhB;IADG,aAAgB;CAEvB;AAED,+CAUE;AAEF,+CAAkH;;;;iCAtHrG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC;4BAInC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC;yBAIpB,kBAAkB,GAAC,aAAa;;;;;;;;WAO/B,OAAO,KAAK,EAAE,gBAAgB,CAAC,sBAAsB,CAAC;;;;gBACtD,OAAO,yBAAyB,EAAE,mBAAmB;;;;;;;;;SAOrD,MAAM;;;;WACN,MAAM;;;;kBACN,MAAM;;;;cACN,OAAO,yBAAyB,EAAE,cAAc;;;;;;UAKhD,OAAO,KAAK,EAAE,QAAQ,CAAC,OAAO,yBAAyB,EAAE,kBAAkB,GAAC,EAAE,CAAC;;;;YAC/E,OAAO,yBAAyB,EAAE,YAAY;;;;cAC9C,OAAO,yBAAyB,EAAE,cAAc;;;;YAChD,OAAO,yBAAyB,EAAE,YAAY;;;;WAC9C,OAAO,yBAAyB,EAAE,WAAW;;;;YAC7C,OAAO,yBAAyB,EAAE,YAAY;;;;eAC9C,OAAO,yBAAyB,EAAE,eAAe;;;;;;;;;UAOjD,OAAO,KAAK,EAAE,eAAe,CAAC,0BAA0B,CAAC;;;;QACzD,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,GAAC,SAAS,CAAC;;;;WACnC,OAAO,KAAK,EAAE,GAAG,CAAC,MAAM,GAAC,SAAS,CAAC;;;;kBACnC,OAAO,KAAK,EAAE,GAAG,CAAC;QAAC,CAAC,GAAG,EAAC,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;;;;YACtC,OAAO,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC;;;;aAClC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;aACpC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;WACpC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,KAAK,GAAC,IAAI,CAAC,CAAC;;;;aACvC,OAAO;;;;;;kCAOR,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC;;;;;;;;YAO7C,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,OAAO,CAAC;;;;cACvG,MAAM,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,OAAO,CAAC;;;;YAC/E,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,kBAAkB,CAAA;KAAE,KAAK,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,OAAO,CAAC;;;;YACnH,MAAM,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,OAAO,CAAC;;;;WAC/E,CAAC,IAAI,EAAE;QAAE,aAAa,EAAE,kBAAkB,CAAA;KAAE,KAAK,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,OAAO,CAAC;;;;gBAC1H,OAAO,mBAAmB,EAAE,YAAY;;;;WACxC,MAAM,IAAI;;;;;;;;;WAOV,mBAAmB;;;;;6BAMpB,uBAAuB,GAAG,wBAAwB"}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* The raw state of the object subscription.
|
|
3
3
|
*
|
|
4
4
|
* @typedef {object} ObjectSubscriptionRawState
|
|
5
|
-
* @property {
|
|
6
|
-
* @property {
|
|
7
|
-
* @property {
|
|
8
|
-
* @property {boolean} intendToRetrieve - Whether the object intends to retrieve.
|
|
9
|
-
* @property {boolean} intendToSubscribe - Whether the object intends to subscribe.
|
|
10
|
-
* @property {boolean} subscribed - Whether the object is subscribed.
|
|
5
|
+
* @property {import('./loadingError.js').LoadingReadonlyRef} subscriptionLoading - Whether the subscription is loading.
|
|
6
|
+
* @property {import('./loadingError.js').ErroredReadonlyRef} subscriptionErrored - Whether the subscription has errored.
|
|
7
|
+
* @property {import('./loadingError.js').ErrorReadonlyRef} subscriptionError - The error that occurred.
|
|
8
|
+
* @property {import('vue').Ref<boolean>} intendToRetrieve - Whether the object intends to retrieve.
|
|
9
|
+
* @property {import('vue').Ref<boolean>} intendToSubscribe - Whether the object intends to subscribe.
|
|
10
|
+
* @property {import('vue').Ref<boolean|undefined>} subscribed - Whether the object is subscribed.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* The state of the object subscription, including both subscription and object instance states.
|
|
14
14
|
*
|
|
15
|
-
* @typedef {import('vue').
|
|
15
|
+
* @typedef {import('vue').Reactive<
|
|
16
16
|
* ObjectSubscriptionRawState &
|
|
17
17
|
* import('./objectInstance.js').ObjectInstanceRawState
|
|
18
18
|
* >} ObjectSubscriptionState
|
|
@@ -21,12 +21,15 @@
|
|
|
21
21
|
* Functions available for object subscription management.
|
|
22
22
|
*
|
|
23
23
|
* @typedef {object} ObjectSubscriptionFunctions
|
|
24
|
-
* @property {(
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* @property {(
|
|
25
|
+
* (options?: { retrieve?: boolean }) => boolean
|
|
26
|
+
* )} subscribe - Subscribes to updates from an object, managing subscription state and handling errors internally.
|
|
27
|
+
* Ensures that only one active subscription can exist at a time to prevent duplicate calls. Returns a promise that
|
|
28
|
+
* resolves to true if the subscription was successful, and false if it failed.
|
|
27
29
|
* @property {() => boolean} unsubscribe - Unsubscribes from the object, resetting related state flags. Returns
|
|
28
30
|
* true if the object was unsubscribed, and false if it was not subscribed.
|
|
29
|
-
* @property {(data: import('./objectInstance.js').
|
|
31
|
+
* @property {(data: import('./objectInstance.js').ExistingCrudObject) => void} updateFromSubscription - Update the
|
|
32
|
+
* object from a subscription.
|
|
30
33
|
* @property {() => void} deleteFromSubscription - Delete the object from a subscription.
|
|
31
34
|
* @property {() => void} clearError - Clears any errors related to the subscription, and resets the loading state.
|
|
32
35
|
*/
|
|
@@ -49,8 +52,8 @@
|
|
|
49
52
|
* Raw props for the object subscription.
|
|
50
53
|
*
|
|
51
54
|
* @typedef {object} ObjectSubscriptionRawProps
|
|
52
|
-
* @property {boolean}
|
|
53
|
-
* @property {boolean}
|
|
55
|
+
* @property {boolean|undefined} intendToRetrieve - Whether the object intends to retrieve.
|
|
56
|
+
* @property {boolean|undefined} intendToSubscribe - Whether the object intends to subscribe.
|
|
54
57
|
*/
|
|
55
58
|
/**
|
|
56
59
|
* Options for initializing an object subscription, including reactive props and non-reactive functions.
|
|
@@ -144,53 +147,54 @@ export type ObjectSubscriptionRawState = {
|
|
|
144
147
|
/**
|
|
145
148
|
* - Whether the subscription is loading.
|
|
146
149
|
*/
|
|
147
|
-
subscriptionLoading:
|
|
150
|
+
subscriptionLoading: import("./loadingError.js").LoadingReadonlyRef;
|
|
148
151
|
/**
|
|
149
152
|
* - Whether the subscription has errored.
|
|
150
153
|
*/
|
|
151
|
-
subscriptionErrored:
|
|
154
|
+
subscriptionErrored: import("./loadingError.js").ErroredReadonlyRef;
|
|
152
155
|
/**
|
|
153
156
|
* - The error that occurred.
|
|
154
157
|
*/
|
|
155
|
-
subscriptionError:
|
|
158
|
+
subscriptionError: import("./loadingError.js").ErrorReadonlyRef;
|
|
156
159
|
/**
|
|
157
160
|
* - Whether the object intends to retrieve.
|
|
158
161
|
*/
|
|
159
|
-
intendToRetrieve: boolean
|
|
162
|
+
intendToRetrieve: import("vue").Ref<boolean>;
|
|
160
163
|
/**
|
|
161
164
|
* - Whether the object intends to subscribe.
|
|
162
165
|
*/
|
|
163
|
-
intendToSubscribe: boolean
|
|
166
|
+
intendToSubscribe: import("vue").Ref<boolean>;
|
|
164
167
|
/**
|
|
165
168
|
* - Whether the object is subscribed.
|
|
166
169
|
*/
|
|
167
|
-
subscribed: boolean
|
|
170
|
+
subscribed: import("vue").Ref<boolean | undefined>;
|
|
168
171
|
};
|
|
169
172
|
/**
|
|
170
173
|
* The state of the object subscription, including both subscription and object instance states.
|
|
171
174
|
*/
|
|
172
|
-
export type ObjectSubscriptionState = import("vue").
|
|
175
|
+
export type ObjectSubscriptionState = import("vue").Reactive<ObjectSubscriptionRawState & import("./objectInstance.js").ObjectInstanceRawState>;
|
|
173
176
|
/**
|
|
174
177
|
* Functions available for object subscription management.
|
|
175
178
|
*/
|
|
176
179
|
export type ObjectSubscriptionFunctions = {
|
|
177
180
|
/**
|
|
178
|
-
* - Subscribes to updates from an object, managing subscription state and
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
+
* - Subscribes to updates from an object, managing subscription state and handling errors internally.
|
|
182
|
+
* Ensures that only one active subscription can exist at a time to prevent duplicate calls. Returns a promise that
|
|
183
|
+
* resolves to true if the subscription was successful, and false if it failed.
|
|
181
184
|
*/
|
|
182
|
-
subscribe: (
|
|
185
|
+
subscribe: ((options?: {
|
|
183
186
|
retrieve?: boolean;
|
|
184
|
-
}) => boolean;
|
|
187
|
+
}) => boolean);
|
|
185
188
|
/**
|
|
186
189
|
* - Unsubscribes from the object, resetting related state flags. Returns
|
|
187
190
|
* true if the object was unsubscribed, and false if it was not subscribed.
|
|
188
191
|
*/
|
|
189
192
|
unsubscribe: () => boolean;
|
|
190
193
|
/**
|
|
191
|
-
* - Update the
|
|
194
|
+
* - Update the
|
|
195
|
+
* object from a subscription.
|
|
192
196
|
*/
|
|
193
|
-
updateFromSubscription: (data: import("./objectInstance.js").
|
|
197
|
+
updateFromSubscription: (data: import("./objectInstance.js").ExistingCrudObject) => void;
|
|
194
198
|
/**
|
|
195
199
|
* - Delete the object from a subscription.
|
|
196
200
|
*/
|
|
@@ -236,11 +240,11 @@ export type ObjectSubscriptionRawProps = {
|
|
|
236
240
|
/**
|
|
237
241
|
* - Whether the object intends to retrieve.
|
|
238
242
|
*/
|
|
239
|
-
intendToRetrieve
|
|
243
|
+
intendToRetrieve: boolean | undefined;
|
|
240
244
|
/**
|
|
241
245
|
* - Whether the object intends to subscribe.
|
|
242
246
|
*/
|
|
243
|
-
intendToSubscribe
|
|
247
|
+
intendToSubscribe: boolean | undefined;
|
|
244
248
|
};
|
|
245
249
|
/**
|
|
246
250
|
* Options for initializing an object subscription, including reactive props and non-reactive functions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectSubscription.d.ts","sourceRoot":"","sources":["../../use/objectSubscription.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"objectSubscription.d.ts","sourceRoot":"","sources":["../../use/objectSubscription.js"],"names":[],"mappings":"AAgDA;;;;;;;;;;GAUG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;GASG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,yDAHW;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAA;CAAC,GACxC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAA;CAAC,CAS/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,4EAHW,yBAAyB,GACvB,kBAAkB,CA0M9B;AApXD;;;;GAIG;AAEH;;GAEG;AACH;IACI;;;;;OAKG;IACH,qBAHW,MAAM,QACN,MAAM,EAMhB;IADG,aAAgB;CAEvB;AAED,mDAOE;AAEF,mDAME;;;;;;;;yBAMY,OAAO,mBAAmB,EAAE,kBAAkB;;;;yBAC9C,OAAO,mBAAmB,EAAE,kBAAkB;;;;uBAC9C,OAAO,mBAAmB,EAAE,gBAAgB;;;;sBAC5C,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;;;;uBAC1B,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC;;;;gBAC1B,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,GAAC,SAAS,CAAC;;;;;sCAMrC,OAAO,KAAK,EAAE,QAAQ,CAC5B,0BAA0B,GAChC,OAAa,qBAAqB,EAAE,sBAAsB,CACvD;;;;;;;;;;eAOU,CACb,CAAO,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAChD;;;;;iBAGU,MAAM,OAAO;;;;;4BAEb,CAAC,IAAI,EAAE,OAAO,qBAAqB,EAAE,kBAAkB,KAAK,IAAI;;;;4BAEhE,MAAM,IAAI;;;;gBACV,MAAM,IAAI;;;;;;;;;WAOV,uBAAuB;;;;oBACvB,OAAO,qBAAqB,EAAE,cAAc;;;;qBAC5C,OAAO,wBAAwB,EAAE,iBAAiB;;;;oBAClD,OAAO,wBAAwB,EAAE,iBAAiB;;;;iBAClD,OAAO,KAAK,EAAE,WAAW;;;;;iCAM1B,4BAA4B,GAAG,2BAA2B;;;;;;;;sBAOzD,OAAO,GAAC,SAAS;;;;uBACjB,OAAO,GAAC,SAAS;;;;;wCAMlB,MAAM,GAAG,OAAO,qBAAqB,EAAE,qBAAqB"}
|
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {(
|
|
3
|
-
* import('./loadingError.js').LoadingErrorStatus[]
|
|
4
|
-
* )} WatchableLoadingErrorsRaw
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* A watchable collection of loading errors.
|
|
8
3
|
*
|
|
9
4
|
* @typedef {(
|
|
10
|
-
* import('vue').UnwrapNestedRefs<
|
|
11
|
-
* import('vue').Ref<
|
|
12
|
-
*
|
|
13
|
-
* )}
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* The instance of useProxyLoadingError.
|
|
17
|
-
*
|
|
18
|
-
* @typedef {import('./loadingError.js').LoadingErrorStatus} ProxyLoadingError
|
|
5
|
+
* import('vue').UnwrapNestedRefs<import('./loadingError.js').LoadingErrorStatus> |
|
|
6
|
+
* import('vue').Ref<import('./loadingError.js').LoadingErrorStatus> |
|
|
7
|
+
* import('./loadingError.js').LoadingErrorStatus
|
|
8
|
+
* )} WatchableLoadingError
|
|
19
9
|
*/
|
|
20
10
|
/**
|
|
21
11
|
* A composable function for managing aggregated loading and error states across multiple sources.
|
|
22
12
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @returns {
|
|
13
|
+
* @param {WatchableLoadingError[]} loadingErrors - A collection of loading error statuses to monitor and aggregate.
|
|
14
|
+
* @returns {import('./loadingError.js').LoadingErrorStatus} An object containing aggregated reactive fields and actions for loading and error states.
|
|
25
15
|
*/
|
|
26
|
-
export function useProxyLoadingError(loadingErrors:
|
|
27
|
-
export type WatchableLoadingErrorsRaw = (import("./loadingError.js").LoadingErrorStatus[]);
|
|
16
|
+
export function useProxyLoadingError(loadingErrors: WatchableLoadingError[]): import("./loadingError.js").LoadingErrorStatus;
|
|
28
17
|
/**
|
|
29
18
|
* A watchable collection of loading errors.
|
|
30
19
|
*/
|
|
31
|
-
export type
|
|
32
|
-
/**
|
|
33
|
-
* The instance of useProxyLoadingError.
|
|
34
|
-
*/
|
|
35
|
-
export type ProxyLoadingError = import("./loadingError.js").LoadingErrorStatus;
|
|
20
|
+
export type WatchableLoadingError = (import("vue").UnwrapNestedRefs<import("./loadingError.js").LoadingErrorStatus> | import("vue").Ref<import("./loadingError.js").LoadingErrorStatus> | import("./loadingError.js").LoadingErrorStatus);
|
|
36
21
|
//# sourceMappingURL=proxyLoadingError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyLoadingError.d.ts","sourceRoot":"","sources":["../../use/proxyLoadingError.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proxyLoadingError.d.ts","sourceRoot":"","sources":["../../use/proxyLoadingError.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,oDAHW,qBAAqB,EAAE,GACrB,OAAO,mBAAmB,EAAE,kBAAkB,CA2B1D;;;;oCAtCY,CACZ,OAAa,KAAK,EAAE,gBAAgB,CAAC,OAAO,mBAAmB,EAAE,kBAAkB,CAAC,GACpF,OAAa,KAAK,EAAE,GAAG,CAAC,OAAO,mBAAmB,EAAE,kBAAkB,CAAC,GACvE,OAAa,mBAAmB,EAAE,kBAAkB,CACjD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A wrapper around fetch that adds cancellation via AbortController and returns a CancellablePromise.
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {RequestInfo} input - The URL or Request object to fetch.
|
|
6
|
+
* @param {RequestInit} init - The options for the fetch request.
|
|
7
|
+
* @param {(response: Response) => Promise<T>} transform - A function to transform the response.
|
|
8
|
+
* @returns {CancellablePromise<T>} A cancellable promise that resolves to the transformed response.
|
|
9
|
+
*/
|
|
10
|
+
export function cancellableFetch<T>(input: RequestInfo, init: RequestInit, transform: (response: Response) => Promise<T>): CancellablePromise<T>;
|
|
11
|
+
import { CancellablePromise } from "./cancellablePromise.js";
|
|
12
|
+
//# sourceMappingURL=cancellableFetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancellableFetch.d.ts","sourceRoot":"","sources":["../../utils/cancellableFetch.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,iCANa,CAAC,SACH,WAAW,QACX,WAAW,aACX,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAChC,kBAAkB,CAAC,CAAC,CAAC,CAYjC;mCArBkC,yBAAyB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a promise and optionally adds a cancel method if provided.
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {Promise<T>} inner - The inner promise to wrap.
|
|
6
|
+
* @param {(() => Promise<void> | void)=} cancel - Optional cancel function.
|
|
7
|
+
* @returns {MaybeCancellablePromise<T>} The wrapped promise with an optional cancel method.
|
|
8
|
+
*/
|
|
9
|
+
export function wrapMaybeCancellable<T>(inner: Promise<T>, cancel?: (() => Promise<void> | void) | undefined): MaybeCancellablePromise<T>;
|
|
10
|
+
export function CancellablePromise<T>(promise: Promise<T>, cancel: () => (Promise<void> | void)): CancellablePromise<T>;
|
|
11
|
+
/**
|
|
12
|
+
* A Promise that can be cancelled.
|
|
13
|
+
*/
|
|
14
|
+
export type CancellablePromise<T> = Promise<T> & {
|
|
15
|
+
cancel: (reason?: any) => Promise<void> | void;
|
|
16
|
+
};
|
|
17
|
+
export namespace CancellablePromise {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a rejected 'cancellable' promise.
|
|
20
|
+
*
|
|
21
|
+
* @param {any} reason - The reason for the rejection.
|
|
22
|
+
* @returns {MaybeCancellablePromise<never>} A rejected 'cancellable' promise.
|
|
23
|
+
*/
|
|
24
|
+
function reject(reason: any): MaybeCancellablePromise<never>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a resolved 'cancellable' promise.
|
|
27
|
+
*
|
|
28
|
+
* @template T
|
|
29
|
+
* @param {T} value - The value to resolve the promise with.
|
|
30
|
+
* @returns {MaybeCancellablePromise<T>} A resolved 'cancellable' promise.
|
|
31
|
+
*/
|
|
32
|
+
function resolve<T_1>(value: T_1): MaybeCancellablePromise<T_1>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A possibly cancellable promise.
|
|
36
|
+
*/
|
|
37
|
+
export type MaybeCancellablePromise<T> = Promise<T> & {
|
|
38
|
+
cancel?: (reason?: any) => Promise<void> | void;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=cancellablePromise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancellablePromise.d.ts","sourceRoot":"","sources":["../../utils/cancellablePromise.js"],"names":[],"mappings":"AAiDA;;;;;;;GAOG;AACH,qCALa,CAAC,SACH,OAAO,CAAC,CAAC,CAAC,WACV,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,YAAC,GAC3B,uBAAuB,CAAC,CAAC,CAAC,CActC;AA/CM,mCALM,CAAC,WACH,OAAO,CAAC,CAAC,CAAC,UACV,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI,CAAC,GACxB,kBAAkB,CAAC,CAAC,CAAC,CAMjC;;;;+BAvBY,CAAC,IACD,OAAO,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE;;IAwB5E;;;;;OAKG;IACH,wBAHW,GAAG,GACD,uBAAuB,CAAC,KAAK,CAAC,CAI1C;IAED;;;;;;OAMG;IACH,6BAHW,GAAC,GACC,uBAAuB,CAAC,GAAC,CAAC,CAItC;;;;;oCArCY,CAAC,IACD,OAAO,CAAC,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively unwraps refs from a nested object, array, or primitive.
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @typedef {T extends import('vue').Ref<infer U>
|
|
6
|
+
* ? DeepUnwrap<U>
|
|
7
|
+
* : T extends Array<infer V>
|
|
8
|
+
* ? Array<DeepUnwrap<V>>
|
|
9
|
+
* : T extends object
|
|
10
|
+
* ? { [K in keyof T]: DeepUnwrap<T[K]> }
|
|
11
|
+
* : T
|
|
12
|
+
* } DeepUnwrap
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Safe, recursively-typed deep unref.
|
|
16
|
+
*
|
|
17
|
+
* @template T
|
|
18
|
+
* @param {T} val - The value to deeply unwrap.
|
|
19
|
+
* @returns {DeepUnwrap<T>} - The deeply unwrapped value.
|
|
20
|
+
*/
|
|
21
|
+
export const deepUnref: any;
|
|
22
|
+
/**
|
|
23
|
+
* Recursively unwraps refs from a nested object, array, or primitive.
|
|
24
|
+
*/
|
|
25
|
+
export type DeepUnwrap<T_1> = T_1 extends import("vue").Ref<infer U> ? DeepUnwrap<U> : T_1 extends Array<infer V> ? Array<DeepUnwrap<V>> : T_1 extends object ? { [K in keyof T_1]: DeepUnwrap<T_1[K]>; } : T_1;
|
|
26
|
+
//# sourceMappingURL=deepUnref.d.ts.map
|