@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import('./loading.js').LoadingProperties & import('./error.js').ErrorProperties} LoadingErrorProperties
|
|
3
|
-
* @typedef {import('./loading.js').LoadingFunctions & import('./error.js').ErrorFunctions} LoadingErrorFunctions
|
|
4
|
-
* @typedef {LoadingErrorProperties & LoadingErrorFunctions} LoadingErrorStatus
|
|
2
|
+
* @typedef {import('./loading.js').LoadingProperties & import('./error.js').ErrorProperties} LoadingErrorProperties - The combined reactive loading and error state members contributed by the useLoadingError composable.
|
|
3
|
+
* @typedef {import('./loading.js').LoadingFunctions & import('./error.js').ErrorFunctions} LoadingErrorFunctions - The combined loading and error state actions contributed by the useLoadingError composable.
|
|
4
|
+
* @typedef {LoadingErrorProperties & LoadingErrorFunctions} LoadingErrorStatus - The combined loading and error state API (properties plus actions) returned by useLoadingError.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* A composable function combining loading and error state management.
|
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
* @returns {LoadingErrorStatus} - An object containing reactive fields and actions for both loading and error state.
|
|
10
10
|
*/
|
|
11
11
|
export function useLoadingError(): LoadingErrorStatus;
|
|
12
|
+
/**
|
|
13
|
+
* The combined reactive loading and error state members contributed by the useLoadingError composable.
|
|
14
|
+
*/
|
|
12
15
|
export type LoadingErrorProperties = import("./loading.js").LoadingProperties & import("./error.js").ErrorProperties;
|
|
16
|
+
/**
|
|
17
|
+
* The combined loading and error state actions contributed by the useLoadingError composable.
|
|
18
|
+
*/
|
|
13
19
|
export type LoadingErrorFunctions = import("./loading.js").LoadingFunctions & import("./error.js").ErrorFunctions;
|
|
20
|
+
/**
|
|
21
|
+
* The combined loading and error state API (properties plus actions) returned by useLoadingError.
|
|
22
|
+
*/
|
|
14
23
|
export type LoadingErrorStatus = LoadingErrorProperties & LoadingErrorFunctions;
|
package/types/use/object.d.ts
CHANGED
|
@@ -17,11 +17,11 @@ export type ObjectManagerProps = import("vue").UnwrapNestedRefs<ObjectManagerRaw
|
|
|
17
17
|
*/
|
|
18
18
|
export type ObjectManagerOptions = {
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* The reactive properties to be passed to the object instance.
|
|
21
21
|
*/
|
|
22
22
|
props: ObjectManagerProps;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* The non-reactive handlers to be passed to the object instance.
|
|
25
25
|
*/
|
|
26
26
|
handlers: import("../config/objectCrud.js").ObjectCrudHandlers;
|
|
27
27
|
};
|
|
@@ -43,16 +43,19 @@ export type ObjectManagerFunctions = (import("./objectInstance.js").ObjectInstan
|
|
|
43
43
|
*/
|
|
44
44
|
export type ObjectManagerProperties = {
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* The managed object.
|
|
47
47
|
*/
|
|
48
48
|
managed: ObjectManaged;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* The state of the managed object.
|
|
51
51
|
*/
|
|
52
52
|
state: import("./objectCalculated.js").ObjectCalculatedState;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Stop the effect scope of the managed object.
|
|
55
55
|
*/
|
|
56
56
|
stop: () => void;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* The fully managed object returned by useObject, combining its properties and functions.
|
|
60
|
+
*/
|
|
58
61
|
export type ObjectManager = ObjectManagerProperties & ObjectManagerFunctions;
|
|
@@ -63,11 +63,9 @@ export function useObjectCalculated({ parentState, calculatedObjectRules }: Obje
|
|
|
63
63
|
* @module use/objectCalculated.js
|
|
64
64
|
*/
|
|
65
65
|
/**
|
|
66
|
-
* The object calculated state keys.
|
|
67
|
-
*
|
|
68
66
|
* @typedef {{
|
|
69
67
|
* [ruleKey: string]: (object: any, relatedObject: any) => any
|
|
70
|
-
* }} ObjectCalculatedRules
|
|
68
|
+
* }} ObjectCalculatedRules - The object calculated state keys.
|
|
71
69
|
*/
|
|
72
70
|
/**
|
|
73
71
|
* @typedef {object} ObjectCalculatedRawState - The raw state for object calculated.
|
|
@@ -87,7 +85,7 @@ export function useObjectCalculated({ parentState, calculatedObjectRules }: Obje
|
|
|
87
85
|
* import('./objectInstance.js').ObjectInstanceRawState &
|
|
88
86
|
* Partial<import('./objectSubscription.js').ObjectSubscriptionRawState> &
|
|
89
87
|
* Partial<import('./objectRelated.js').ObjectRelatedRawState>
|
|
90
|
-
* )} ObjectCalculatedParentRawState
|
|
88
|
+
* )} ObjectCalculatedParentRawState - The raw, pre-unwrapped parent state consumed by the object calculated mixin, aggregating the upstream object composable states.
|
|
91
89
|
*/
|
|
92
90
|
/**
|
|
93
91
|
*
|
|
@@ -97,39 +95,35 @@ export function useObjectCalculated({ parentState, calculatedObjectRules }: Obje
|
|
|
97
95
|
* )>} ObjectCalculatedParentState - The object calculated options.
|
|
98
96
|
*/
|
|
99
97
|
/**
|
|
100
|
-
* The state for object calculated.
|
|
101
|
-
*
|
|
102
98
|
* @typedef {import('vue').UnwrapNestedRefs<
|
|
103
99
|
* ObjectCalculatedParentRawState &
|
|
104
100
|
* ObjectCalculatedRawState
|
|
105
|
-
* >} ObjectCalculatedState
|
|
101
|
+
* >} ObjectCalculatedState - The state for object calculated.
|
|
106
102
|
*/
|
|
107
103
|
/**
|
|
108
|
-
* The properties for object calculated.
|
|
109
|
-
*
|
|
110
|
-
* @typedef {object} ObjectCalculatedProperties
|
|
104
|
+
* @typedef {object} ObjectCalculatedProperties - The properties for object calculated.
|
|
111
105
|
* @property {ObjectCalculatedParentState} parentState - The parent state.
|
|
112
106
|
* @property {ObjectCalculatedState} state - The object calculated state.
|
|
113
107
|
* @property {() => void} stop - Stops composition's effects and cleans up resources.
|
|
114
108
|
*/
|
|
115
109
|
/**
|
|
116
|
-
* The object calculated instance.
|
|
117
|
-
*
|
|
118
|
-
* @typedef {ObjectCalculatedProperties} ObjectCalculated
|
|
110
|
+
* @typedef {ObjectCalculatedProperties} ObjectCalculated - The object calculated instance.
|
|
119
111
|
*/
|
|
120
112
|
/**
|
|
121
113
|
*
|
|
122
114
|
*
|
|
123
|
-
* @typedef {object} ObjectCalculatedRawProps
|
|
115
|
+
* @typedef {object} ObjectCalculatedRawProps - The consumer-supplied props for the object calculated composable, namely the calculated-object rules ref.
|
|
124
116
|
* @property {import('vue').Ref<ObjectCalculatedRules>} calculatedObjectRules - The calculated object rules.
|
|
125
117
|
*/
|
|
126
118
|
/**
|
|
127
119
|
*
|
|
128
120
|
* @typedef {({
|
|
129
121
|
* parentState: ObjectCalculatedParentState,
|
|
130
|
-
* } & ObjectCalculatedRawProps)} ObjectCalculatedOptions
|
|
122
|
+
* } & ObjectCalculatedRawProps)} ObjectCalculatedOptions - The options used to create an object calculated instance (the parent state plus the calculated-object rules).
|
|
131
123
|
*/
|
|
124
|
+
/** @internal */
|
|
132
125
|
export const objectCalculatedStateKeys: string[];
|
|
126
|
+
/** @internal */
|
|
133
127
|
export const objectCalculatedFunctions: any[];
|
|
134
128
|
/**
|
|
135
129
|
* The object calculated state keys.
|
|
@@ -138,39 +132,42 @@ export type ObjectCalculatedRules = {
|
|
|
138
132
|
[ruleKey: string]: (object: any, relatedObject: any) => any;
|
|
139
133
|
};
|
|
140
134
|
/**
|
|
141
|
-
*
|
|
135
|
+
* The raw state for object calculated.
|
|
142
136
|
*/
|
|
143
137
|
export type ObjectCalculatedRawState = {
|
|
144
138
|
/**
|
|
145
|
-
*
|
|
139
|
+
* The calculated object rules.
|
|
146
140
|
*/
|
|
147
141
|
calculatedObjectRules: ObjectCalculatedRules;
|
|
148
142
|
/**
|
|
149
|
-
*
|
|
143
|
+
* The calculated object.
|
|
150
144
|
*/
|
|
151
145
|
calculatedObject: {
|
|
152
146
|
[ruleKey: string]: import("vue").ComputedRef<any>;
|
|
153
147
|
};
|
|
154
148
|
/**
|
|
155
|
-
*
|
|
149
|
+
* Whether the calculated object watch is running.
|
|
156
150
|
*/
|
|
157
151
|
calculatedObjectWatchRunning: boolean;
|
|
158
152
|
/**
|
|
159
|
-
*
|
|
153
|
+
* Whether the parent state object watch is running.
|
|
160
154
|
*/
|
|
161
155
|
parentStateObjectWatchRunning: boolean;
|
|
162
156
|
/**
|
|
163
|
-
*
|
|
157
|
+
* Whether the calculated is running.
|
|
164
158
|
*/
|
|
165
159
|
calculatedRunning: boolean;
|
|
166
160
|
/**
|
|
167
|
-
*
|
|
161
|
+
* Whether the object calculated is running.
|
|
168
162
|
*/
|
|
169
163
|
running: import("vue").Ref<boolean>;
|
|
170
164
|
};
|
|
165
|
+
/**
|
|
166
|
+
* The raw, pre-unwrapped parent state consumed by the object calculated mixin, aggregating the upstream object composable states.
|
|
167
|
+
*/
|
|
171
168
|
export type ObjectCalculatedParentRawState = (import("./objectInstance.js").ObjectInstanceRawState & Partial<import("./objectSubscription.js").ObjectSubscriptionRawState> & Partial<import("./objectRelated.js").ObjectRelatedRawState>);
|
|
172
169
|
/**
|
|
173
|
-
*
|
|
170
|
+
* The object calculated options.
|
|
174
171
|
*/
|
|
175
172
|
export type ObjectCalculatedParentState = import("vue").UnwrapNestedRefs<(ObjectCalculatedParentRawState)>;
|
|
176
173
|
/**
|
|
@@ -182,15 +179,15 @@ export type ObjectCalculatedState = import("vue").UnwrapNestedRefs<ObjectCalcula
|
|
|
182
179
|
*/
|
|
183
180
|
export type ObjectCalculatedProperties = {
|
|
184
181
|
/**
|
|
185
|
-
*
|
|
182
|
+
* The parent state.
|
|
186
183
|
*/
|
|
187
184
|
parentState: ObjectCalculatedParentState;
|
|
188
185
|
/**
|
|
189
|
-
*
|
|
186
|
+
* The object calculated state.
|
|
190
187
|
*/
|
|
191
188
|
state: ObjectCalculatedState;
|
|
192
189
|
/**
|
|
193
|
-
*
|
|
190
|
+
* Stops composition's effects and cleans up resources.
|
|
194
191
|
*/
|
|
195
192
|
stop: () => void;
|
|
196
193
|
};
|
|
@@ -198,12 +195,18 @@ export type ObjectCalculatedProperties = {
|
|
|
198
195
|
* The object calculated instance.
|
|
199
196
|
*/
|
|
200
197
|
export type ObjectCalculated = ObjectCalculatedProperties;
|
|
198
|
+
/**
|
|
199
|
+
* The consumer-supplied props for the object calculated composable, namely the calculated-object rules ref.
|
|
200
|
+
*/
|
|
201
201
|
export type ObjectCalculatedRawProps = {
|
|
202
202
|
/**
|
|
203
|
-
*
|
|
203
|
+
* The calculated object rules.
|
|
204
204
|
*/
|
|
205
205
|
calculatedObjectRules: import("vue").Ref<ObjectCalculatedRules>;
|
|
206
206
|
};
|
|
207
|
+
/**
|
|
208
|
+
* The options used to create an object calculated instance (the parent state plus the calculated-object rules).
|
|
209
|
+
*/
|
|
207
210
|
export type ObjectCalculatedOptions = ({
|
|
208
211
|
parentState: ObjectCalculatedParentState;
|
|
209
212
|
} & ObjectCalculatedRawProps);
|
|
@@ -68,37 +68,28 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
68
68
|
* @module use/objectInstance.js
|
|
69
69
|
*/
|
|
70
70
|
/**
|
|
71
|
-
* The object being managed by the instance. It must include a primary key field as identifying property, matching
|
|
72
|
-
* the name provided to the object/list's `pkKey` value, which is not known statically.
|
|
73
|
-
*
|
|
74
|
-
* @typedef {{[key: string]: any}} ExistingCrudObject
|
|
71
|
+
* @typedef {{[key: string]: any}} ExistingCrudObject - The object being managed by the instance. It must include a primary key field as identifying property, matching the name provided to the object/list's `pkKey` value, which is not known statically.
|
|
75
72
|
*/
|
|
76
73
|
/**
|
|
77
|
-
* The object you would like an object instance to create for you.
|
|
78
|
-
*
|
|
79
|
-
* @typedef {{[key: string]: any}} NewCrudObject
|
|
74
|
+
* @typedef {{[key: string]: any}} NewCrudObject - The object you would like an object instance to create for you.
|
|
80
75
|
*/
|
|
81
76
|
/**
|
|
82
|
-
* @typedef {ExistingCrudObject|NewCrudObject} CrudObject
|
|
77
|
+
* @typedef {ExistingCrudObject|NewCrudObject} CrudObject - An object managed by an object instance, either an existing object or a new object to be created.
|
|
83
78
|
*/
|
|
84
79
|
/**
|
|
85
|
-
* Arguments to be passed to the object instance.
|
|
86
|
-
*
|
|
87
|
-
* @typedef {object} ObjectInstanceOptions
|
|
80
|
+
* @typedef {object} ObjectInstanceOptions - Arguments to be passed to the object instance.
|
|
88
81
|
* @property {import('vue').UnwrapNestedRefs<ObjectInstanceRawProps>} props - The reactive configuration object.
|
|
89
82
|
* @property {import('../config/objectCrud.js').ObjectCrudHandlers} [handlers] - An object of custom crud handlers to use instead of the defaults.
|
|
90
83
|
*/
|
|
91
84
|
/**
|
|
92
|
-
* Reactive arguments to be passed to the object instance.
|
|
93
|
-
*
|
|
94
|
-
* @typedef {object} ObjectInstanceRawProps
|
|
85
|
+
* @typedef {object} ObjectInstanceRawProps - Reactive arguments to be passed to the object instance.
|
|
95
86
|
* @property {import('../config/commonCrud.js').PkInput} [pk] - The pk of the object, optional to support creating new objects.
|
|
96
87
|
* @property {string} pkKey - The pk key of the object.
|
|
97
88
|
* @property {object} params - The arguments to be passed to the retrieve function.
|
|
98
89
|
* @property {import('../config/objectCrud.js').ObjectTarget} target - The arguments to be passed to the crud handlers.
|
|
99
90
|
*/
|
|
100
91
|
/**
|
|
101
|
-
* @typedef {object} ObjectInstanceRawStateCrud
|
|
92
|
+
* @typedef {object} ObjectInstanceRawStateCrud - The raw CRUD handlers and target args stored in an object instance's reactive state.
|
|
102
93
|
* @property {import('vue').Reactive<import('../config/objectCrud.js').TargetArgs|{}>} args - The arguments to be passed to the crud handlers.
|
|
103
94
|
* @property {import('../config/objectCrud.js').CrudCreateFn} create - The create function.
|
|
104
95
|
* @property {import('../config/objectCrud.js').CrudRetrieveFn} retrieve - The retrieve function.
|
|
@@ -109,9 +100,7 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
109
100
|
* @property {import('../config/objectCrud.js').CrudObjectExecuteActionFn} executeAction - The executeAction function.
|
|
110
101
|
*/
|
|
111
102
|
/**
|
|
112
|
-
* The raw state of the object instance.
|
|
113
|
-
*
|
|
114
|
-
* @typedef {object} ObjectInstanceRawMyState
|
|
103
|
+
* @typedef {object} ObjectInstanceRawMyState - The raw state of the object instance.
|
|
115
104
|
* @property {import('vue').Reactive<ObjectInstanceRawStateCrud>} crud - The crud handlers.
|
|
116
105
|
* @property {import('vue').Ref<import('../config/commonCrud.js').Pk|undefined>} pk - The pk of the object.
|
|
117
106
|
* @property {import('vue').Ref<string|undefined>} pkKey - The pk key of the object.
|
|
@@ -120,26 +109,19 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
120
109
|
* @property {boolean} deleted - Whether the object is deleted.
|
|
121
110
|
*/
|
|
122
111
|
/**
|
|
123
|
-
* The raw state of the object instance.
|
|
124
|
-
*
|
|
125
|
-
* @typedef {ObjectInstanceRawMyState & import('./loadingError.js').LoadingErrorProperties} ObjectInstanceRawState
|
|
112
|
+
* @typedef {ObjectInstanceRawMyState & import('./loadingError.js').LoadingErrorProperties} ObjectInstanceRawState - The raw state of the object instance.
|
|
126
113
|
*/
|
|
127
114
|
/**
|
|
128
|
-
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors.
|
|
129
|
-
* Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
130
|
-
*
|
|
131
|
-
* @typedef {import('vue').Reactive<ObjectInstanceRawState>} ObjectInstanceState
|
|
115
|
+
* @typedef {import('vue').Reactive<ObjectInstanceRawState>} ObjectInstanceState - Manages a reactive state of an object including its CRUD status, loading states, and any operational errors. Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
132
116
|
*/
|
|
133
|
-
/** @typedef {{ object: NewCrudObject }} ObjectInstanceCreateArgs */
|
|
134
|
-
/** @typedef {{ object: ExistingCrudObject }} ObjectInstanceUpdateArgs */
|
|
135
|
-
/** @typedef {{ partialObject: ExistingCrudObject }} ObjectInstancePatchArgs */
|
|
117
|
+
/** @typedef {{ object: NewCrudObject }} ObjectInstanceCreateArgs - The argument shape for an object instance's create operation, carrying the new object to create. */
|
|
118
|
+
/** @typedef {{ object: ExistingCrudObject }} ObjectInstanceUpdateArgs - The argument shape for an object instance's update operation, carrying the existing object to update. */
|
|
119
|
+
/** @typedef {{ partialObject: ExistingCrudObject }} ObjectInstancePatchArgs - The argument shape for an object instance's patch operation, carrying the partial object to apply. */
|
|
136
120
|
/**
|
|
137
|
-
* @typedef {{[key:string]: any}} AdditionalArgs
|
|
121
|
+
* @typedef {{[key:string]: any}} AdditionalArgs - Arbitrary extra arguments forwarded through to an object instance's CRUD operations.
|
|
138
122
|
*/
|
|
139
123
|
/**
|
|
140
|
-
* The functions available on the object instance.
|
|
141
|
-
*
|
|
142
|
-
* @typedef {object} ObjectInstanceMyFunctions
|
|
124
|
+
* @typedef {object} ObjectInstanceMyFunctions - The functions available on the object instance.
|
|
143
125
|
* @property {(args: ObjectInstanceCreateArgs & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} create - Called to turn the current object into a new object on the server.
|
|
144
126
|
* @property {(args?: Partial<import('./cancellableIntent.js').CommonRunTracking> & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} retrieve - Called to retrieve the current object by pk from the server.
|
|
145
127
|
* @property {(args: ObjectInstanceUpdateArgs & AdditionalArgs) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<boolean|never>} update - Called to update the current object on the server.
|
|
@@ -149,23 +131,17 @@ export function useObjectInstance({ props, handlers }: ObjectInstanceOptions): O
|
|
|
149
131
|
* @property {() => void} clear - Called to clear the object state.
|
|
150
132
|
*/
|
|
151
133
|
/**
|
|
152
|
-
* The functions available on the object instance, including the ability to clear LoadingError errors.
|
|
153
|
-
*
|
|
154
134
|
* @typedef {(
|
|
155
135
|
* import('./error.js').ErrorReadOnlyFunctions &
|
|
156
136
|
* ObjectInstanceMyFunctions
|
|
157
|
-
* )} ObjectInstanceFunctions
|
|
137
|
+
* )} ObjectInstanceFunctions - The functions available on the object instance, including the ability to clear LoadingError errors.
|
|
158
138
|
*/
|
|
159
139
|
/**
|
|
160
|
-
* The properties of the object instance.
|
|
161
|
-
*
|
|
162
|
-
* @typedef {object} ObjectInstanceProperties
|
|
140
|
+
* @typedef {object} ObjectInstanceProperties - The properties of the object instance.
|
|
163
141
|
* @property {ObjectInstanceState} state - The state of the object instance.
|
|
164
142
|
*/
|
|
165
143
|
/**
|
|
166
|
-
* The instance of the object instance.
|
|
167
|
-
*
|
|
168
|
-
* @typedef {ObjectInstanceFunctions & ObjectInstanceProperties} ObjectInstance
|
|
144
|
+
* @typedef {ObjectInstanceFunctions & ObjectInstanceProperties} ObjectInstance - The instance of the object instance.
|
|
169
145
|
*/
|
|
170
146
|
/**
|
|
171
147
|
* Represents an error related to CRUD operations on an object instance. This error might be thrown
|
|
@@ -181,11 +157,12 @@ export class ObjectError extends Error {
|
|
|
181
157
|
constructor(message: string, code: string);
|
|
182
158
|
code: string;
|
|
183
159
|
}
|
|
160
|
+
/** @internal */
|
|
184
161
|
export const objectInstanceStateKeys: string[];
|
|
162
|
+
/** @internal */
|
|
185
163
|
export const objectInstanceFunctions: string[];
|
|
186
164
|
/**
|
|
187
|
-
* The object being managed by the instance. It must include a primary key field as identifying property, matching
|
|
188
|
-
* the name provided to the object/list's `pkKey` value, which is not known statically.
|
|
165
|
+
* The object being managed by the instance. It must include a primary key field as identifying property, matching the name provided to the object/list's `pkKey` value, which is not known statically.
|
|
189
166
|
*/
|
|
190
167
|
export type ExistingCrudObject = {
|
|
191
168
|
[key: string]: any;
|
|
@@ -196,17 +173,20 @@ export type ExistingCrudObject = {
|
|
|
196
173
|
export type NewCrudObject = {
|
|
197
174
|
[key: string]: any;
|
|
198
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* An object managed by an object instance, either an existing object or a new object to be created.
|
|
178
|
+
*/
|
|
199
179
|
export type CrudObject = ExistingCrudObject | NewCrudObject;
|
|
200
180
|
/**
|
|
201
181
|
* Arguments to be passed to the object instance.
|
|
202
182
|
*/
|
|
203
183
|
export type ObjectInstanceOptions = {
|
|
204
184
|
/**
|
|
205
|
-
*
|
|
185
|
+
* The reactive configuration object.
|
|
206
186
|
*/
|
|
207
187
|
props: import("vue").UnwrapNestedRefs<ObjectInstanceRawProps>;
|
|
208
188
|
/**
|
|
209
|
-
*
|
|
189
|
+
* An object of custom crud handlers to use instead of the defaults.
|
|
210
190
|
*/
|
|
211
191
|
handlers?: import("../config/objectCrud.js").ObjectCrudHandlers;
|
|
212
192
|
};
|
|
@@ -215,53 +195,56 @@ export type ObjectInstanceOptions = {
|
|
|
215
195
|
*/
|
|
216
196
|
export type ObjectInstanceRawProps = {
|
|
217
197
|
/**
|
|
218
|
-
*
|
|
198
|
+
* The pk of the object, optional to support creating new objects.
|
|
219
199
|
*/
|
|
220
200
|
pk?: import("../config/commonCrud.js").PkInput;
|
|
221
201
|
/**
|
|
222
|
-
*
|
|
202
|
+
* The pk key of the object.
|
|
223
203
|
*/
|
|
224
204
|
pkKey: string;
|
|
225
205
|
/**
|
|
226
|
-
*
|
|
206
|
+
* The arguments to be passed to the retrieve function.
|
|
227
207
|
*/
|
|
228
208
|
params: object;
|
|
229
209
|
/**
|
|
230
|
-
*
|
|
210
|
+
* The arguments to be passed to the crud handlers.
|
|
231
211
|
*/
|
|
232
212
|
target: import("../config/objectCrud.js").ObjectTarget;
|
|
233
213
|
};
|
|
214
|
+
/**
|
|
215
|
+
* The raw CRUD handlers and target args stored in an object instance's reactive state.
|
|
216
|
+
*/
|
|
234
217
|
export type ObjectInstanceRawStateCrud = {
|
|
235
218
|
/**
|
|
236
|
-
*
|
|
219
|
+
* The arguments to be passed to the crud handlers.
|
|
237
220
|
*/
|
|
238
221
|
args: import("vue").Reactive<import("../config/objectCrud.js").TargetArgs | {}>;
|
|
239
222
|
/**
|
|
240
|
-
*
|
|
223
|
+
* The create function.
|
|
241
224
|
*/
|
|
242
225
|
create: import("../config/objectCrud.js").CrudCreateFn;
|
|
243
226
|
/**
|
|
244
|
-
*
|
|
227
|
+
* The retrieve function.
|
|
245
228
|
*/
|
|
246
229
|
retrieve: import("../config/objectCrud.js").CrudRetrieveFn;
|
|
247
230
|
/**
|
|
248
|
-
*
|
|
231
|
+
* The update function.
|
|
249
232
|
*/
|
|
250
233
|
update: import("../config/objectCrud.js").CrudUpdateFn;
|
|
251
234
|
/**
|
|
252
|
-
*
|
|
235
|
+
* The patch function.
|
|
253
236
|
*/
|
|
254
237
|
patch: import("../config/objectCrud.js").CrudPatchFn;
|
|
255
238
|
/**
|
|
256
|
-
*
|
|
239
|
+
* The delete function.
|
|
257
240
|
*/
|
|
258
241
|
delete: import("../config/objectCrud.js").CrudDeleteFn;
|
|
259
242
|
/**
|
|
260
|
-
*
|
|
243
|
+
* The subscribe function.
|
|
261
244
|
*/
|
|
262
245
|
subscribe: import("../config/objectCrud.js").CrudObjectSubscribeFn;
|
|
263
246
|
/**
|
|
264
|
-
*
|
|
247
|
+
* The executeAction function.
|
|
265
248
|
*/
|
|
266
249
|
executeAction: import("../config/objectCrud.js").CrudObjectExecuteActionFn;
|
|
267
250
|
};
|
|
@@ -270,29 +253,29 @@ export type ObjectInstanceRawStateCrud = {
|
|
|
270
253
|
*/
|
|
271
254
|
export type ObjectInstanceRawMyState = {
|
|
272
255
|
/**
|
|
273
|
-
*
|
|
256
|
+
* The crud handlers.
|
|
274
257
|
*/
|
|
275
258
|
crud: import("vue").Reactive<ObjectInstanceRawStateCrud>;
|
|
276
259
|
/**
|
|
277
|
-
*
|
|
260
|
+
* The pk of the object.
|
|
278
261
|
*/
|
|
279
262
|
pk: import("vue").Ref<import("../config/commonCrud.js").Pk | undefined>;
|
|
280
263
|
/**
|
|
281
|
-
*
|
|
264
|
+
* The pk key of the object.
|
|
282
265
|
*/
|
|
283
266
|
pkKey: import("vue").Ref<string | undefined>;
|
|
284
267
|
/**
|
|
285
|
-
*
|
|
268
|
+
* The arguments to be passed to the retrieve function.
|
|
286
269
|
*/
|
|
287
270
|
params: import("vue").Ref<{
|
|
288
271
|
[key: string]: any;
|
|
289
272
|
}>;
|
|
290
273
|
/**
|
|
291
|
-
*
|
|
274
|
+
* The object.
|
|
292
275
|
*/
|
|
293
276
|
object: import("vue").Reactive<CrudObject>;
|
|
294
277
|
/**
|
|
295
|
-
*
|
|
278
|
+
* Whether the object is deleted.
|
|
296
279
|
*/
|
|
297
280
|
deleted: boolean;
|
|
298
281
|
};
|
|
@@ -301,19 +284,30 @@ export type ObjectInstanceRawMyState = {
|
|
|
301
284
|
*/
|
|
302
285
|
export type ObjectInstanceRawState = ObjectInstanceRawMyState & import("./loadingError.js").LoadingErrorProperties;
|
|
303
286
|
/**
|
|
304
|
-
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors.
|
|
305
|
-
* Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
287
|
+
* Manages a reactive state of an object including its CRUD status, loading states, and any operational errors. Reactivity ensures that any changes in state immediately reflect in the UI components that depend on this state.
|
|
306
288
|
*/
|
|
307
289
|
export type ObjectInstanceState = import("vue").Reactive<ObjectInstanceRawState>;
|
|
290
|
+
/**
|
|
291
|
+
* The argument shape for an object instance's create operation, carrying the new object to create.
|
|
292
|
+
*/
|
|
308
293
|
export type ObjectInstanceCreateArgs = {
|
|
309
294
|
object: NewCrudObject;
|
|
310
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* The argument shape for an object instance's update operation, carrying the existing object to update.
|
|
298
|
+
*/
|
|
311
299
|
export type ObjectInstanceUpdateArgs = {
|
|
312
300
|
object: ExistingCrudObject;
|
|
313
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* The argument shape for an object instance's patch operation, carrying the partial object to apply.
|
|
304
|
+
*/
|
|
314
305
|
export type ObjectInstancePatchArgs = {
|
|
315
306
|
partialObject: ExistingCrudObject;
|
|
316
307
|
};
|
|
308
|
+
/**
|
|
309
|
+
* Arbitrary extra arguments forwarded through to an object instance's CRUD operations.
|
|
310
|
+
*/
|
|
317
311
|
export type AdditionalArgs = {
|
|
318
312
|
[key: string]: any;
|
|
319
313
|
};
|
|
@@ -322,33 +316,33 @@ export type AdditionalArgs = {
|
|
|
322
316
|
*/
|
|
323
317
|
export type ObjectInstanceMyFunctions = {
|
|
324
318
|
/**
|
|
325
|
-
*
|
|
319
|
+
* Called to turn the current object into a new object on the server.
|
|
326
320
|
*/
|
|
327
321
|
create: (args: ObjectInstanceCreateArgs & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
328
322
|
/**
|
|
329
|
-
*
|
|
323
|
+
* Called to retrieve the current object by pk from the server.
|
|
330
324
|
*/
|
|
331
325
|
retrieve: (args?: Partial<import("./cancellableIntent.js").CommonRunTracking> & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
332
326
|
/**
|
|
333
|
-
*
|
|
327
|
+
* Called to update the current object on the server.
|
|
334
328
|
*/
|
|
335
329
|
update: (args: ObjectInstanceUpdateArgs & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
336
330
|
/**
|
|
337
|
-
*
|
|
331
|
+
* Called to delete the current object on the server.
|
|
338
332
|
*/
|
|
339
333
|
delete: (args?: AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
340
334
|
/**
|
|
341
|
-
*
|
|
335
|
+
* Called to patch the current object on the server.
|
|
342
336
|
*/
|
|
343
337
|
patch: (args: ObjectInstancePatchArgs & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
344
338
|
/**
|
|
345
|
-
*
|
|
339
|
+
* Called to execute certain action on the current object.
|
|
346
340
|
*/
|
|
347
341
|
executeAction: (args: {
|
|
348
342
|
action: string;
|
|
349
343
|
} & AdditionalArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<boolean | never>;
|
|
350
344
|
/**
|
|
351
|
-
*
|
|
345
|
+
* Called to clear the object state.
|
|
352
346
|
*/
|
|
353
347
|
clear: () => void;
|
|
354
348
|
};
|
|
@@ -361,7 +355,7 @@ export type ObjectInstanceFunctions = (import("./error.js").ErrorReadOnlyFunctio
|
|
|
361
355
|
*/
|
|
362
356
|
export type ObjectInstanceProperties = {
|
|
363
357
|
/**
|
|
364
|
-
*
|
|
358
|
+
* The state of the object instance.
|
|
365
359
|
*/
|
|
366
360
|
state: ObjectInstanceState;
|
|
367
361
|
};
|