@arrai-innovations/reactive-helpers 13.0.1 → 13.0.3

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.
@@ -3,16 +3,69 @@ import cloneDeep from "lodash-es/cloneDeep.js";
3
3
  import isFunction from "lodash-es/isFunction.js";
4
4
  import { isReactive, toRef } from "vue";
5
5
 
6
+ /**
7
+ * Configuration for the default list crud functions.
8
+ *
9
+ * @module config/listCrud.js
10
+ */
11
+
6
12
  const defaultCrud = {
7
13
  args: {},
8
14
  list: undefined,
9
15
  subscribe: undefined,
10
16
  };
11
17
 
18
+ /**
19
+ * @typedef {object} PaginateInfo
20
+ * @property {number} totalRecords - The total records.
21
+ * @property {number} totalPages - The total pages.
22
+ * @property {number} perPage - The per page.
23
+ */
24
+
25
+ /**
26
+ * @typedef {(
27
+ * newObjects:import('../use/listInstance.js').ListObject,
28
+ * paginationInfo: PaginateInfo|undefined
29
+ * )=>void} PageCallback
30
+ */
31
+
32
+ /**
33
+ * @typedef {object} ListFnArgs
34
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
35
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
36
+ * @property {object} listArgs - The arguments to be passed for list crud functions.
37
+ * @property {PageCallback} pageCallback - The method to call with new page(s) of data received.
38
+ * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to a boolean indicating whether the request has
39
+ * been cancelled.
40
+ */
41
+
42
+ /**
43
+ * @typedef {(
44
+ * newOrUpdatedOrDeleteObject:import('../use/listInstance.js').ListObject|string,
45
+ * action: 'create'|'update'|'delete'
46
+ * )=>void} SubscriptionEventCallback
47
+ */
48
+
49
+ /**
50
+ * @typedef {object} SubscribeFnArgs
51
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
52
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
53
+ * @property {object} listArgs - The arguments to be passed for list crud functions.
54
+ * @property {SubscriptionEventCallback} subscriptionEventCallback - The method to call when new data is received.
55
+ */
56
+
57
+ /**
58
+ * @typedef {(ListFnArgs)=>void} ListFn
59
+ */
60
+
61
+ /**
62
+ * @typedef {(SubscribeFnArgs)=>void} SubscribeFn
63
+ */
64
+
12
65
  /**
13
66
  * @typedef {object} ListCrudFunctions
14
- * @property {Function} [list] - The list function to get a list of items.
15
- * @property {Function} [subscribe] - The subscribe function to get a subscription to a list of items.
67
+ * @property {ListFn} [list] - The list function to get a list of items.
68
+ * @property {SubscribeFn} [subscribe] - The subscribe function to get a subscription to a list of items.
16
69
  */
17
70
 
18
71
  /**
@@ -3,6 +3,12 @@ import cloneDeep from "lodash-es/cloneDeep.js";
3
3
  import isFunction from "lodash-es/isFunction.js";
4
4
  import { isReactive, toRef } from "vue";
5
5
 
6
+ /**
7
+ * Configuration for the default object crud functions.
8
+ *
9
+ * @module config/objectCrud.js
10
+ */
11
+
6
12
  const defaultCrud = {
7
13
  args: {},
8
14
  retrieve: undefined,
@@ -20,16 +26,66 @@ const defaultCrud = {
20
26
  * @property {object} [args={}] - The arguments to be passed to the crud functions.
21
27
  */
22
28
 
29
+ /**
30
+ * @typedef {object} CreateDetailArgs
31
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
32
+ * @property {object} object - The data to be acted upon.
33
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
34
+ */
35
+
36
+ /**
37
+ * @typedef {object} RetrieveDetailArgs
38
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
39
+ * @property {string} id - The id of the object to be acted upon.
40
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
41
+ */
42
+
43
+ /**
44
+ * @typedef {object} UpdateDetailArgs
45
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
46
+ * @property {import('../use/objectInstance.js').CrudObject} object - The data to be acted upon.
47
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
48
+ */
49
+
50
+ /**
51
+ * @typedef {object} DeleteDetailArgs
52
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
53
+ * @property {string} id - The id of the object to be acted upon.
54
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
55
+ */
56
+
57
+ /**
58
+ * @typedef {object} PartialDetailArgs
59
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
60
+ * @property {string} id - The id of the object to be acted upon.
61
+ * @property {object} partialObject - The data to be acted upon.
62
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
63
+ */
64
+
65
+ /**
66
+ * @typedef {object} SubscribeArgs
67
+ * @property {object} crudArgs - The arguments to be passed to the crud functions.
68
+ * @property {string} id - The id of the object to be acted upon.
69
+ * @property {object} retrieveArgs - The arguments to be passed to the retrieve function.
70
+ * @property {(
71
+ * data:import('../use/objectInstance.js').CrudObject, action:string
72
+ * ) => void} callback - The callback to be called when the object is updated.
73
+ */
74
+
75
+ /**
76
+ * @typedef {Promise<object|string>} ResponseData
77
+ */
78
+
23
79
  /**
24
80
  * Defines the CRUD-related functions and additional utilities provided by the object instance.
25
81
  *
26
82
  * @typedef {object} ObjectCrudFunctions
27
- * @property {Function} [create] - A function to be used instead of the default crud create function.
28
- * @property {Function} [retrieve] - A function to be used instead of the default crud retrieve function.
29
- * @property {Function} [update] - A function to be used instead of the default crud update function.
30
- * @property {Function} [delete] - A function to be used instead of the default crud delete function.
31
- * @property {Function} [patch] - A function to be used instead of the default crud patch function.
32
- * @property {Function} [subscribe] - A function to be used instead of the default crud subscribe function.
83
+ * @property {(CreateDetailArgs)=>ResponseData} [create] - A function to be used instead of the default crud create function.
84
+ * @property {(RetrieveDetailArgs)=>ResponseData} [retrieve] - A function to be used instead of the default crud retrieve function.
85
+ * @property {(UpdateDetailArgs)=>ResponseData} [update] - A function to be used instead of the default crud update function.
86
+ * @property {(DeleteDetailArgs)=>ResponseData} [delete] - A function to be used instead of the default crud delete function.
87
+ * @property {(PartialDetailArgs)=>ResponseData} [patch] - A function to be used instead of the default crud patch function.
88
+ * @property {(SubscribeArgs)=>void} [subscribe] - A function to be used instead of the default crud subscribe function.
33
89
  */
34
90
 
35
91
  /**
@@ -26,16 +26,175 @@ The default arguments for the crud functions.
26
26
 
27
27
  ##### list
28
28
 
29
- > **list**: `Function`
29
+ > **list**: [`ListFn`](listCrud.md#listfn)
30
30
 
31
31
  The list function to get a list of items.
32
32
 
33
33
  ##### subscribe
34
34
 
35
- > **subscribe**: `Function`
35
+ > **subscribe**: [`SubscribeFn`](listCrud.md#subscribefn)
36
36
 
37
37
  The subscribe function to get a subscription to a list of items.
38
38
 
39
+ ***
40
+
41
+ ### ListFnArgs
42
+
43
+ #### Properties
44
+
45
+ ##### crudArgs
46
+
47
+ > **crudArgs**: `any`
48
+
49
+ The arguments to be passed to the crud functions.
50
+
51
+ ##### isCancelled
52
+
53
+ > **isCancelled**: `Readonly`\<`Ref`\<`boolean`\>\>
54
+
55
+ A ref to a boolean indicating whether the request has
56
+ been cancelled.
57
+
58
+ ##### listArgs
59
+
60
+ > **listArgs**: `any`
61
+
62
+ The arguments to be passed for list crud functions.
63
+
64
+ ##### pageCallback
65
+
66
+ > **pageCallback**: [`PageCallback`](listCrud.md#pagecallback-1)
67
+
68
+ The method to call with new page(s) of data received.
69
+
70
+ ##### retrieveArgs
71
+
72
+ > **retrieveArgs**: `any`
73
+
74
+ The arguments to be passed to the retrieve function.
75
+
76
+ ***
77
+
78
+ ### PaginateInfo
79
+
80
+ #### Properties
81
+
82
+ ##### perPage
83
+
84
+ > **perPage**: `number`
85
+
86
+ The per page.
87
+
88
+ ##### totalPages
89
+
90
+ > **totalPages**: `number`
91
+
92
+ The total pages.
93
+
94
+ ##### totalRecords
95
+
96
+ > **totalRecords**: `number`
97
+
98
+ The total records.
99
+
100
+ ***
101
+
102
+ ### SubscribeFnArgs
103
+
104
+ #### Properties
105
+
106
+ ##### crudArgs
107
+
108
+ > **crudArgs**: `any`
109
+
110
+ The arguments to be passed to the crud functions.
111
+
112
+ ##### listArgs
113
+
114
+ > **listArgs**: `any`
115
+
116
+ The arguments to be passed for list crud functions.
117
+
118
+ ##### retrieveArgs
119
+
120
+ > **retrieveArgs**: `any`
121
+
122
+ The arguments to be passed to the retrieve function.
123
+
124
+ ##### subscriptionEventCallback
125
+
126
+ > **subscriptionEventCallback**: [`SubscriptionEventCallback`](listCrud.md#subscriptioneventcallback-1)
127
+
128
+ The method to call when new data is received.
129
+
130
+ ## Type Aliases
131
+
132
+ ### ListFn()
133
+
134
+ > **ListFn**\<\>: (`ListFnArgs`) => `void`
135
+
136
+ #### Type Parameters
137
+
138
+ #### Parameters
139
+
140
+ • **ListFnArgs**: `any`
141
+
142
+ #### Returns
143
+
144
+ `void`
145
+
146
+ ***
147
+
148
+ ### PageCallback()
149
+
150
+ > **PageCallback**\<\>: (`newObjects`, `paginationInfo`) => `void`
151
+
152
+ #### Type Parameters
153
+
154
+ #### Parameters
155
+
156
+ • **newObjects**: [`use/listInstance`](../use/listInstance.md)
157
+
158
+ • **paginationInfo**: [`PaginateInfo`](listCrud.md#paginateinfo) \| `undefined`
159
+
160
+ #### Returns
161
+
162
+ `void`
163
+
164
+ ***
165
+
166
+ ### SubscribeFn()
167
+
168
+ > **SubscribeFn**\<\>: (`SubscribeFnArgs`) => `void`
169
+
170
+ #### Type Parameters
171
+
172
+ #### Parameters
173
+
174
+ • **SubscribeFnArgs**: `any`
175
+
176
+ #### Returns
177
+
178
+ `void`
179
+
180
+ ***
181
+
182
+ ### SubscriptionEventCallback()
183
+
184
+ > **SubscriptionEventCallback**\<\>: (`newOrUpdatedOrDeleteObject`, `action`) => `void`
185
+
186
+ #### Type Parameters
187
+
188
+ #### Parameters
189
+
190
+ • **newOrUpdatedOrDeleteObject**: [`use/listInstance`](../use/listInstance.md) \| `string`
191
+
192
+ • **action**: `"create"` \| `"update"` \| `"delete"`
193
+
194
+ #### Returns
195
+
196
+ `void`
197
+
39
198
  ## Functions
40
199
 
41
200
  ### getListCrud()
@@ -54,11 +213,11 @@ The reactive crud object, which will be mutated.
54
213
 
55
214
  The default arguments for the crud functions.
56
215
 
57
- • **reactiveCrud.list**: `Function`
216
+ • **reactiveCrud.list**: [`ListFn`](listCrud.md#listfn)
58
217
 
59
218
  The list function to get a list of items.
60
219
 
61
- • **reactiveCrud.subscribe**: `Function`
220
+ • **reactiveCrud.subscribe**: [`SubscribeFn`](listCrud.md#subscribefn)
62
221
 
63
222
  The subscribe function to get a subscription to a list of items.
64
223
 
@@ -8,6 +8,54 @@
8
8
 
9
9
  ## Interfaces
10
10
 
11
+ ### CreateDetailArgs
12
+
13
+ #### Properties
14
+
15
+ ##### crudArgs
16
+
17
+ > **crudArgs**: `any`
18
+
19
+ The arguments to be passed to the crud functions.
20
+
21
+ ##### object
22
+
23
+ > **object**: `any`
24
+
25
+ The data to be acted upon.
26
+
27
+ ##### retrieveArgs
28
+
29
+ > **retrieveArgs**: `any`
30
+
31
+ The arguments to be passed to the retrieve function.
32
+
33
+ ***
34
+
35
+ ### DeleteDetailArgs
36
+
37
+ #### Properties
38
+
39
+ ##### crudArgs
40
+
41
+ > **crudArgs**: `any`
42
+
43
+ The arguments to be passed to the crud functions.
44
+
45
+ ##### id
46
+
47
+ > **id**: `string`
48
+
49
+ The id of the object to be acted upon.
50
+
51
+ ##### retrieveArgs
52
+
53
+ > **retrieveArgs**: `any`
54
+
55
+ The arguments to be passed to the retrieve function.
56
+
57
+ ***
58
+
11
59
  ### ObjectCrudArgsProperties
12
60
 
13
61
  #### Properties
@@ -24,42 +72,208 @@ The arguments to be passed to the crud functions.
24
72
 
25
73
  #### Properties
26
74
 
27
- ##### create
75
+ ##### create()
28
76
 
29
- > **create**: `Function`
77
+ > **create**: (`CreateDetailArgs`) => [`ResponseData`](objectCrud.md#responsedata)
30
78
 
31
79
  A function to be used instead of the default crud create function.
32
80
 
33
- ##### delete
81
+ ###### Parameters
82
+
83
+ • **CreateDetailArgs**: `any`
84
+
85
+ ###### Returns
86
+
87
+ [`ResponseData`](objectCrud.md#responsedata)
88
+
89
+ ##### delete()
34
90
 
35
- > **delete**: `Function`
91
+ > **delete**: (`DeleteDetailArgs`) => [`ResponseData`](objectCrud.md#responsedata)
36
92
 
37
93
  A function to be used instead of the default crud delete function.
38
94
 
39
- ##### patch
95
+ ###### Parameters
40
96
 
41
- > **patch**: `Function`
97
+ **DeleteDetailArgs**: `any`
98
+
99
+ ###### Returns
100
+
101
+ [`ResponseData`](objectCrud.md#responsedata)
102
+
103
+ ##### patch()
104
+
105
+ > **patch**: (`PartialDetailArgs`) => [`ResponseData`](objectCrud.md#responsedata)
42
106
 
43
107
  A function to be used instead of the default crud patch function.
44
108
 
45
- ##### retrieve
109
+ ###### Parameters
110
+
111
+ • **PartialDetailArgs**: `any`
46
112
 
47
- > **retrieve**: `Function`
113
+ ###### Returns
114
+
115
+ [`ResponseData`](objectCrud.md#responsedata)
116
+
117
+ ##### retrieve()
118
+
119
+ > **retrieve**: (`RetrieveDetailArgs`) => [`ResponseData`](objectCrud.md#responsedata)
48
120
 
49
121
  A function to be used instead of the default crud retrieve function.
50
122
 
51
- ##### subscribe
123
+ ###### Parameters
124
+
125
+ • **RetrieveDetailArgs**: `any`
52
126
 
53
- > **subscribe**: `Function`
127
+ ###### Returns
128
+
129
+ [`ResponseData`](objectCrud.md#responsedata)
130
+
131
+ ##### subscribe()
132
+
133
+ > **subscribe**: (`SubscribeArgs`) => `void`
54
134
 
55
135
  A function to be used instead of the default crud subscribe function.
56
136
 
57
- ##### update
137
+ ###### Parameters
138
+
139
+ • **SubscribeArgs**: `any`
140
+
141
+ ###### Returns
142
+
143
+ `void`
144
+
145
+ ##### update()
58
146
 
59
- > **update**: `Function`
147
+ > **update**: (`UpdateDetailArgs`) => [`ResponseData`](objectCrud.md#responsedata)
60
148
 
61
149
  A function to be used instead of the default crud update function.
62
150
 
151
+ ###### Parameters
152
+
153
+ • **UpdateDetailArgs**: `any`
154
+
155
+ ###### Returns
156
+
157
+ [`ResponseData`](objectCrud.md#responsedata)
158
+
159
+ ***
160
+
161
+ ### PartialDetailArgs
162
+
163
+ #### Properties
164
+
165
+ ##### crudArgs
166
+
167
+ > **crudArgs**: `any`
168
+
169
+ The arguments to be passed to the crud functions.
170
+
171
+ ##### id
172
+
173
+ > **id**: `string`
174
+
175
+ The id of the object to be acted upon.
176
+
177
+ ##### partialObject
178
+
179
+ > **partialObject**: `any`
180
+
181
+ The data to be acted upon.
182
+
183
+ ##### retrieveArgs
184
+
185
+ > **retrieveArgs**: `any`
186
+
187
+ The arguments to be passed to the retrieve function.
188
+
189
+ ***
190
+
191
+ ### RetrieveDetailArgs
192
+
193
+ #### Properties
194
+
195
+ ##### crudArgs
196
+
197
+ > **crudArgs**: `any`
198
+
199
+ The arguments to be passed to the crud functions.
200
+
201
+ ##### id
202
+
203
+ > **id**: `string`
204
+
205
+ The id of the object to be acted upon.
206
+
207
+ ##### retrieveArgs
208
+
209
+ > **retrieveArgs**: `any`
210
+
211
+ The arguments to be passed to the retrieve function.
212
+
213
+ ***
214
+
215
+ ### SubscribeArgs
216
+
217
+ #### Properties
218
+
219
+ ##### callback()
220
+
221
+ > **callback**: (`data`, `action`) => `void`
222
+
223
+ The callback to be called when the object is updated.
224
+
225
+ ###### Parameters
226
+
227
+ • **data**: [`CrudObject`](../use/objectInstance.md#crudobject)
228
+
229
+ • **action**: `string`
230
+
231
+ ###### Returns
232
+
233
+ `void`
234
+
235
+ ##### crudArgs
236
+
237
+ > **crudArgs**: `any`
238
+
239
+ The arguments to be passed to the crud functions.
240
+
241
+ ##### id
242
+
243
+ > **id**: `string`
244
+
245
+ The id of the object to be acted upon.
246
+
247
+ ##### retrieveArgs
248
+
249
+ > **retrieveArgs**: `any`
250
+
251
+ The arguments to be passed to the retrieve function.
252
+
253
+ ***
254
+
255
+ ### UpdateDetailArgs
256
+
257
+ #### Properties
258
+
259
+ ##### crudArgs
260
+
261
+ > **crudArgs**: `any`
262
+
263
+ The arguments to be passed to the crud functions.
264
+
265
+ ##### object
266
+
267
+ > **object**: [`CrudObject`](../use/objectInstance.md#crudobject)
268
+
269
+ The data to be acted upon.
270
+
271
+ ##### retrieveArgs
272
+
273
+ > **retrieveArgs**: `any`
274
+
275
+ The arguments to be passed to the retrieve function.
276
+
63
277
  ## Type Aliases
64
278
 
65
279
  ### ObjectCrudArgs
@@ -68,6 +282,14 @@ A function to be used instead of the default crud update function.
68
282
 
69
283
  #### Type Parameters
70
284
 
285
+ ***
286
+
287
+ ### ResponseData
288
+
289
+ > **ResponseData**\<\>: `Promise`\<`object` \| `string`\>
290
+
291
+ #### Type Parameters
292
+
71
293
  ## Functions
72
294
 
73
295
  ### getObjectCrud()
@@ -6,6 +6,14 @@
6
6
 
7
7
  # use/combineClasses
8
8
 
9
+ ## Type Aliases
10
+
11
+ ### CSSClasses
12
+
13
+ > **CSSClasses**\<\>: `string` \| `string`[] \| `object` \| `Ref`
14
+
15
+ #### Type Parameters
16
+
9
17
  ## Functions
10
18
 
11
19
  ### useCombineClasses()
@@ -18,7 +26,7 @@ Normalize various ways of specifying CSS classes into an object for use in Vue.j
18
26
 
19
27
  #### Parameters
20
28
 
21
- • ...**classes**: (`string` \| `string`[] \| `object` \| `Ref`\<`string` \| `string`[]\>)[]
29
+ • ...**classes**: [`CSSClasses`](combineClasses.md#cssclasses)[]
22
30
 
23
31
  A mixed array containing multiple ways of specifying CSS classes.
24
32
 
@@ -177,9 +177,17 @@ Default implementation are used as set by `setListCrud`.
177
177
 
178
178
  ###### list
179
179
 
180
- > **list**: `Function`
180
+ > **list**: [`ListFn`](../config/listCrud.md#listfn)
181
+
182
+ Provide the implementation for the list
183
+ function.
184
+
185
+ ###### subscribe
186
+
187
+ > **subscribe**: [`SubscribeFn`](../config/listCrud.md#subscribefn)
181
188
 
182
- Provide the implementation for the list function.
189
+ Provide the implementation for the
190
+ subscribe function.
183
191
 
184
192
  ##### keepOldPages
185
193