@arrai-innovations/reactive-helpers 11.4.2 → 13.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/.husky/pre-commit +0 -1
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.prettierignore +1 -0
- package/README.md +11 -10
- package/config/listCrud.js +32 -1
- package/config/objectCrud.js +47 -1
- package/docs/README.md +43 -0
- package/docs/config/listCrud.md +97 -0
- package/docs/config/objectCrud.md +123 -0
- package/docs/use/cancellableIntent.md +163 -0
- package/docs/use/combineClasses.md +52 -0
- package/docs/use/list.md +285 -0
- package/docs/use/listCalculated.md +773 -0
- package/docs/use/listFilter.md +877 -0
- package/docs/use/listInstance.md +483 -0
- package/docs/use/listKeys.md +91 -0
- package/docs/use/listRelated.md +685 -0
- package/docs/use/listSearch.md +889 -0
- package/docs/use/listSort.md +1144 -0
- package/docs/use/listSubscription.md +379 -0
- package/docs/use/loadingError.md +21 -0
- package/docs/use/object.md +437 -0
- package/docs/use/objectCalculated.md +606 -0
- package/docs/use/objectInstance.md +486 -0
- package/docs/use/objectRelated.md +588 -0
- package/docs/use/objectSubscription.md +459 -0
- package/docs/use/paginatedListInstance.md +147 -0
- package/docs/use/search.md +311 -0
- package/docs/use/watchesRunning.md +80 -0
- package/docs/utils/assignReactiveObject.md +351 -0
- package/docs/utils/classes.md +100 -0
- package/docs/utils/compact.md +57 -0
- package/docs/utils/deleteKey.md +53 -0
- package/docs/utils/flattenPaths.md +45 -0
- package/docs/utils/getFakeId.md +34 -0
- package/docs/utils/keyDiff.md +101 -0
- package/docs/utils/loadingCombine.md +28 -0
- package/docs/utils/proxyRunning.md +33 -0
- package/docs/utils/relatedCalculatedHelpers.md +75 -0
- package/docs/utils/set.md +139 -0
- package/docs/utils/transformWalk.md +33 -0
- package/docs/utils/watches.md +441 -0
- package/eslint.config.js +125 -0
- package/index.js +34 -3
- package/lint-staged.config.js +5 -1
- package/makeTypeDoc.sh +25 -0
- package/package.json +27 -19
- package/tests/unit/config/listCrud.spec.js +5 -0
- package/tests/unit/config/objectCrud.spec.js +5 -0
- package/tests/unit/crudPromise.js +22 -3
- package/tests/unit/mockOnUnmounted.js +1 -1
- package/tests/unit/use/cancellableIntent.spec.js +2 -0
- package/tests/unit/use/listCalculated.spec.js +4 -3
- package/tests/unit/use/listFilter.spec.js +11 -7
- package/tests/unit/use/listInstance.spec.js +32 -14
- package/tests/unit/use/listRelated.spec.js +3 -2
- package/tests/unit/use/listSearch.spec.js +9 -7
- package/tests/unit/use/listSort.spec.js +29 -22
- package/tests/unit/use/listSubscription.spec.js +11 -5
- package/tests/unit/use/objectInstance.spec.js +15 -2
- package/tests/unit/use/objectSubscription.spec.js +31 -16
- package/tests/unit/use/search.spec.js +2 -2
- package/tests/unit/utils/assignReactiveObject.spec.js +21 -13
- package/tests/unit/utils/classes.spec.js +7 -6
- package/tests/unit/utils/watches.spec.js +4 -4
- package/tsconfig.json +19 -0
- package/typedoc-local-plugins/customize-output.js +13 -0
- package/typedoc.json +12 -0
- package/use/cancellableIntent.js +73 -2
- package/use/combineClasses.js +41 -31
- package/use/list.js +139 -5
- package/use/listCalculated.js +175 -10
- package/use/listFilter.js +175 -21
- package/use/listInstance.js +215 -94
- package/use/listRelated.js +260 -72
- package/use/listSearch.js +178 -57
- package/use/listSort.js +188 -21
- package/use/listSubscription.js +211 -63
- package/use/loadingError.js +43 -0
- package/use/object.js +187 -23
- package/use/objectCalculated.js +168 -16
- package/use/objectInstance.js +183 -102
- package/use/objectRelated.js +276 -84
- package/use/objectSubscription.js +169 -17
- package/use/paginatedListInstance.js +30 -1
- package/use/search.js +39 -23
- package/use/watchesRunning.js +41 -6
- package/utils/assignReactiveObject.js +139 -88
- package/utils/classes.js +57 -48
- package/utils/compact.js +28 -2
- package/utils/deleteKey.js +14 -1
- package/utils/flattenPaths.js +19 -9
- package/utils/getFakeId.js +11 -1
- package/utils/keyDiff.js +26 -35
- package/utils/loadingCombine.js +7 -4
- package/utils/proxyRunning.js +16 -8
- package/utils/relatedCalculatedHelpers.js +17 -0
- package/utils/set.js +66 -0
- package/utils/transformWalk.js +7 -6
- package/utils/watches.js +205 -71
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -25
- package/.jsdoc2md.json +0 -4
- package/config/index.js +0 -2
- package/docs.md +0 -1002
- package/jsdoc-to-markdown.sh +0 -16
- package/tests/unit/.eslintrc.cjs +0 -11
- package/tests/unit/config/index.spec.js +0 -18
- package/tests/unit/use/index.spec.js +0 -18
- package/tests/unit/utils/index.spec.js +0 -18
- package/use/index.js +0 -19
- package/utils/debugMessage.js +0 -209
- package/utils/debugWatch.js +0 -29
- package/utils/index.js +0 -16
- package/utils/lifecycleDebug.js +0 -126
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
[**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@arrai-innovations/reactive-helpers](../README.md) / use/listRelated
|
|
6
|
+
|
|
7
|
+
# use/listRelated
|
|
8
|
+
|
|
9
|
+
## Interfaces
|
|
10
|
+
|
|
11
|
+
### ListRelatedOptions
|
|
12
|
+
|
|
13
|
+
#### Properties
|
|
14
|
+
|
|
15
|
+
##### parentState
|
|
16
|
+
|
|
17
|
+
> **parentState**: `object`
|
|
18
|
+
|
|
19
|
+
The parent state object.
|
|
20
|
+
|
|
21
|
+
###### crud
|
|
22
|
+
|
|
23
|
+
> **crud**: `object`
|
|
24
|
+
|
|
25
|
+
CRUD functions and their configurations for the list.
|
|
26
|
+
|
|
27
|
+
###### crud.args
|
|
28
|
+
|
|
29
|
+
> **args**: `any`
|
|
30
|
+
|
|
31
|
+
Arguments for the CRUD functions.
|
|
32
|
+
|
|
33
|
+
###### crud.list
|
|
34
|
+
|
|
35
|
+
> **list**: `Function`
|
|
36
|
+
|
|
37
|
+
Function to list objects.
|
|
38
|
+
|
|
39
|
+
###### error
|
|
40
|
+
|
|
41
|
+
> **error**: `Error`
|
|
42
|
+
|
|
43
|
+
The last error encountered.
|
|
44
|
+
|
|
45
|
+
###### errored
|
|
46
|
+
|
|
47
|
+
> **errored**: `boolean`
|
|
48
|
+
|
|
49
|
+
Indicates if an error occurred during the last operation.
|
|
50
|
+
|
|
51
|
+
###### intendToList
|
|
52
|
+
|
|
53
|
+
> **intendToList**: `boolean`
|
|
54
|
+
|
|
55
|
+
If this is true, the list should be fetched, or re-fetched if arguments change.
|
|
56
|
+
|
|
57
|
+
###### intendToSubscribe
|
|
58
|
+
|
|
59
|
+
> **intendToSubscribe**: `boolean`
|
|
60
|
+
|
|
61
|
+
If this is true, the subscription should start or restart if arguments change.
|
|
62
|
+
|
|
63
|
+
###### listArgs
|
|
64
|
+
|
|
65
|
+
> **listArgs**: `any`
|
|
66
|
+
|
|
67
|
+
Arguments passed to the server for listing operations.
|
|
68
|
+
|
|
69
|
+
###### loading
|
|
70
|
+
|
|
71
|
+
> **loading**: `boolean`
|
|
72
|
+
|
|
73
|
+
Indicates if the list is currently loading.
|
|
74
|
+
|
|
75
|
+
###### objects
|
|
76
|
+
|
|
77
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
78
|
+
|
|
79
|
+
The list objects stored by their IDs.
|
|
80
|
+
|
|
81
|
+
###### objectsInOrder
|
|
82
|
+
|
|
83
|
+
> **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
|
|
84
|
+
|
|
85
|
+
The objects in the order specified by the list.
|
|
86
|
+
|
|
87
|
+
###### order
|
|
88
|
+
|
|
89
|
+
> **order**: `string`[]
|
|
90
|
+
|
|
91
|
+
The order of objects in the list.
|
|
92
|
+
|
|
93
|
+
###### retrieveArgs
|
|
94
|
+
|
|
95
|
+
> **retrieveArgs**: `any`
|
|
96
|
+
|
|
97
|
+
Arguments passed to the server for retrieval operations.
|
|
98
|
+
|
|
99
|
+
###### running
|
|
100
|
+
|
|
101
|
+
> **running**: `boolean`
|
|
102
|
+
|
|
103
|
+
Indicates if there are ongoing reactive updates.
|
|
104
|
+
|
|
105
|
+
###### subscribed
|
|
106
|
+
|
|
107
|
+
> **subscribed**: `boolean`
|
|
108
|
+
|
|
109
|
+
Whether the subscription is active.
|
|
110
|
+
|
|
111
|
+
###### subscriptionError
|
|
112
|
+
|
|
113
|
+
> **subscriptionError**: `Error`
|
|
114
|
+
|
|
115
|
+
The error that occurred.
|
|
116
|
+
|
|
117
|
+
###### subscriptionErrored
|
|
118
|
+
|
|
119
|
+
> **subscriptionErrored**: `boolean`
|
|
120
|
+
|
|
121
|
+
Whether the subscription has errored.
|
|
122
|
+
|
|
123
|
+
###### subscriptionLoading
|
|
124
|
+
|
|
125
|
+
> **subscriptionLoading**: `boolean`
|
|
126
|
+
|
|
127
|
+
Whether the subscription is loading.
|
|
128
|
+
|
|
129
|
+
##### relatedObjectsRules
|
|
130
|
+
|
|
131
|
+
> **relatedObjectsRules**: `Ref`\<`object`\>
|
|
132
|
+
|
|
133
|
+
The rules for the related objects.
|
|
134
|
+
|
|
135
|
+
***
|
|
136
|
+
|
|
137
|
+
### ListRelatedProperties
|
|
138
|
+
|
|
139
|
+
#### Properties
|
|
140
|
+
|
|
141
|
+
##### effectScope
|
|
142
|
+
|
|
143
|
+
> **effectScope**: `EffectScope`
|
|
144
|
+
|
|
145
|
+
The effect scope for the list related property.
|
|
146
|
+
|
|
147
|
+
##### parentState
|
|
148
|
+
|
|
149
|
+
> **parentState**: `object`
|
|
150
|
+
|
|
151
|
+
The parent state object.
|
|
152
|
+
|
|
153
|
+
###### crud
|
|
154
|
+
|
|
155
|
+
> **crud**: `object`
|
|
156
|
+
|
|
157
|
+
CRUD functions and their configurations for the list.
|
|
158
|
+
|
|
159
|
+
###### crud.args
|
|
160
|
+
|
|
161
|
+
> **args**: `any`
|
|
162
|
+
|
|
163
|
+
Arguments for the CRUD functions.
|
|
164
|
+
|
|
165
|
+
###### crud.list
|
|
166
|
+
|
|
167
|
+
> **list**: `Function`
|
|
168
|
+
|
|
169
|
+
Function to list objects.
|
|
170
|
+
|
|
171
|
+
###### error
|
|
172
|
+
|
|
173
|
+
> **error**: `Error`
|
|
174
|
+
|
|
175
|
+
The last error encountered.
|
|
176
|
+
|
|
177
|
+
###### errored
|
|
178
|
+
|
|
179
|
+
> **errored**: `boolean`
|
|
180
|
+
|
|
181
|
+
Indicates if an error occurred during the last operation.
|
|
182
|
+
|
|
183
|
+
###### intendToList
|
|
184
|
+
|
|
185
|
+
> **intendToList**: `boolean`
|
|
186
|
+
|
|
187
|
+
If this is true, the list should be fetched, or re-fetched if arguments change.
|
|
188
|
+
|
|
189
|
+
###### intendToSubscribe
|
|
190
|
+
|
|
191
|
+
> **intendToSubscribe**: `boolean`
|
|
192
|
+
|
|
193
|
+
If this is true, the subscription should start or restart if arguments change.
|
|
194
|
+
|
|
195
|
+
###### listArgs
|
|
196
|
+
|
|
197
|
+
> **listArgs**: `any`
|
|
198
|
+
|
|
199
|
+
Arguments passed to the server for listing operations.
|
|
200
|
+
|
|
201
|
+
###### loading
|
|
202
|
+
|
|
203
|
+
> **loading**: `boolean`
|
|
204
|
+
|
|
205
|
+
Indicates if the list is currently loading.
|
|
206
|
+
|
|
207
|
+
###### objects
|
|
208
|
+
|
|
209
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
210
|
+
|
|
211
|
+
The list objects stored by their IDs.
|
|
212
|
+
|
|
213
|
+
###### objectsInOrder
|
|
214
|
+
|
|
215
|
+
> **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
|
|
216
|
+
|
|
217
|
+
The objects in the order specified by the list.
|
|
218
|
+
|
|
219
|
+
###### order
|
|
220
|
+
|
|
221
|
+
> **order**: `string`[]
|
|
222
|
+
|
|
223
|
+
The order of objects in the list.
|
|
224
|
+
|
|
225
|
+
###### retrieveArgs
|
|
226
|
+
|
|
227
|
+
> **retrieveArgs**: `any`
|
|
228
|
+
|
|
229
|
+
Arguments passed to the server for retrieval operations.
|
|
230
|
+
|
|
231
|
+
###### running
|
|
232
|
+
|
|
233
|
+
> **running**: `boolean`
|
|
234
|
+
|
|
235
|
+
Indicates if there are ongoing reactive updates.
|
|
236
|
+
|
|
237
|
+
###### subscribed
|
|
238
|
+
|
|
239
|
+
> **subscribed**: `boolean`
|
|
240
|
+
|
|
241
|
+
Whether the subscription is active.
|
|
242
|
+
|
|
243
|
+
###### subscriptionError
|
|
244
|
+
|
|
245
|
+
> **subscriptionError**: `Error`
|
|
246
|
+
|
|
247
|
+
The error that occurred.
|
|
248
|
+
|
|
249
|
+
###### subscriptionErrored
|
|
250
|
+
|
|
251
|
+
> **subscriptionErrored**: `boolean`
|
|
252
|
+
|
|
253
|
+
Whether the subscription has errored.
|
|
254
|
+
|
|
255
|
+
###### subscriptionLoading
|
|
256
|
+
|
|
257
|
+
> **subscriptionLoading**: `boolean`
|
|
258
|
+
|
|
259
|
+
Whether the subscription is loading.
|
|
260
|
+
|
|
261
|
+
##### state
|
|
262
|
+
|
|
263
|
+
> **state**: `object`
|
|
264
|
+
|
|
265
|
+
The state for the list related property.
|
|
266
|
+
|
|
267
|
+
###### crud
|
|
268
|
+
|
|
269
|
+
> **crud**: `object`
|
|
270
|
+
|
|
271
|
+
CRUD functions and their configurations for the list.
|
|
272
|
+
|
|
273
|
+
###### crud.args
|
|
274
|
+
|
|
275
|
+
> **args**: `any`
|
|
276
|
+
|
|
277
|
+
Arguments for the CRUD functions.
|
|
278
|
+
|
|
279
|
+
###### crud.list
|
|
280
|
+
|
|
281
|
+
> **list**: `Function`
|
|
282
|
+
|
|
283
|
+
Function to list objects.
|
|
284
|
+
|
|
285
|
+
###### error
|
|
286
|
+
|
|
287
|
+
> **error**: `Error`
|
|
288
|
+
|
|
289
|
+
The last error encountered.
|
|
290
|
+
|
|
291
|
+
###### errored
|
|
292
|
+
|
|
293
|
+
> **errored**: `boolean`
|
|
294
|
+
|
|
295
|
+
Indicates if an error occurred during the last operation.
|
|
296
|
+
|
|
297
|
+
###### fkForIdAndRule
|
|
298
|
+
|
|
299
|
+
> **fkForIdAndRule**: `object`
|
|
300
|
+
|
|
301
|
+
Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
|
|
302
|
+
|
|
303
|
+
###### Index Signature
|
|
304
|
+
|
|
305
|
+
\[`id`: `string`\]: `object`
|
|
306
|
+
|
|
307
|
+
###### intendToList
|
|
308
|
+
|
|
309
|
+
> **intendToList**: `boolean`
|
|
310
|
+
|
|
311
|
+
If this is true, the list should be fetched, or re-fetched if arguments change.
|
|
312
|
+
|
|
313
|
+
###### intendToSubscribe
|
|
314
|
+
|
|
315
|
+
> **intendToSubscribe**: `boolean`
|
|
316
|
+
|
|
317
|
+
If this is true, the subscription should start or restart if arguments change.
|
|
318
|
+
|
|
319
|
+
###### listArgs
|
|
320
|
+
|
|
321
|
+
> **listArgs**: `any`
|
|
322
|
+
|
|
323
|
+
Arguments passed to the server for listing operations.
|
|
324
|
+
|
|
325
|
+
###### loading
|
|
326
|
+
|
|
327
|
+
> **loading**: `boolean`
|
|
328
|
+
|
|
329
|
+
Indicates if the list is currently loading.
|
|
330
|
+
|
|
331
|
+
###### objAndKeyForIdAndRule
|
|
332
|
+
|
|
333
|
+
> **objAndKeyForIdAndRule**: `object`
|
|
334
|
+
|
|
335
|
+
Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
336
|
+
|
|
337
|
+
###### Index Signature
|
|
338
|
+
|
|
339
|
+
\[`id`: `string`\]: `object`
|
|
340
|
+
|
|
341
|
+
###### objects
|
|
342
|
+
|
|
343
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
344
|
+
|
|
345
|
+
The list objects stored by their IDs.
|
|
346
|
+
|
|
347
|
+
###### objectsInOrder
|
|
348
|
+
|
|
349
|
+
> **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
|
|
350
|
+
|
|
351
|
+
The objects in the order specified by the list.
|
|
352
|
+
|
|
353
|
+
###### order
|
|
354
|
+
|
|
355
|
+
> **order**: `string`[]
|
|
356
|
+
|
|
357
|
+
The order of objects in the list.
|
|
358
|
+
|
|
359
|
+
###### relatedObjects
|
|
360
|
+
|
|
361
|
+
> **relatedObjects**: `object`
|
|
362
|
+
|
|
363
|
+
Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
|
|
364
|
+
|
|
365
|
+
###### Index Signature
|
|
366
|
+
|
|
367
|
+
\[`id`: `string`\]: `object`
|
|
368
|
+
|
|
369
|
+
###### relatedObjectsParentStateObjectsWatchRunning
|
|
370
|
+
|
|
371
|
+
> **relatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
372
|
+
|
|
373
|
+
Flags whether the watch on parent state objects is currently active, ensuring updates trigger as needed.
|
|
374
|
+
|
|
375
|
+
###### relatedObjectsRules
|
|
376
|
+
|
|
377
|
+
> **relatedObjectsRules**: `object`
|
|
378
|
+
|
|
379
|
+
Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
380
|
+
|
|
381
|
+
###### Index Signature
|
|
382
|
+
|
|
383
|
+
\[`rule`: `string`\]: [`ListRelatedRule`](listRelated.md#listrelatedrule)
|
|
384
|
+
|
|
385
|
+
###### relatedObjectsWatchRunning
|
|
386
|
+
|
|
387
|
+
> **relatedObjectsWatchRunning**: `boolean`
|
|
388
|
+
|
|
389
|
+
Indicates if watches on the related objects themselves are active, managing updates efficiently.
|
|
390
|
+
|
|
391
|
+
###### relatedRunning
|
|
392
|
+
|
|
393
|
+
> **relatedRunning**: `boolean`
|
|
394
|
+
|
|
395
|
+
Signals whether any computations related to object relationships are currently in progress.
|
|
396
|
+
|
|
397
|
+
###### retrieveArgs
|
|
398
|
+
|
|
399
|
+
> **retrieveArgs**: `any`
|
|
400
|
+
|
|
401
|
+
Arguments passed to the server for retrieval operations.
|
|
402
|
+
|
|
403
|
+
###### running
|
|
404
|
+
|
|
405
|
+
> **running**: `boolean`
|
|
406
|
+
|
|
407
|
+
Indicates if there are ongoing reactive updates.
|
|
408
|
+
|
|
409
|
+
###### subscribed
|
|
410
|
+
|
|
411
|
+
> **subscribed**: `boolean`
|
|
412
|
+
|
|
413
|
+
Whether the subscription is active.
|
|
414
|
+
|
|
415
|
+
###### subscriptionError
|
|
416
|
+
|
|
417
|
+
> **subscriptionError**: `Error`
|
|
418
|
+
|
|
419
|
+
The error that occurred.
|
|
420
|
+
|
|
421
|
+
###### subscriptionErrored
|
|
422
|
+
|
|
423
|
+
> **subscriptionErrored**: `boolean`
|
|
424
|
+
|
|
425
|
+
Whether the subscription has errored.
|
|
426
|
+
|
|
427
|
+
###### subscriptionLoading
|
|
428
|
+
|
|
429
|
+
> **subscriptionLoading**: `boolean`
|
|
430
|
+
|
|
431
|
+
Whether the subscription is loading.
|
|
432
|
+
|
|
433
|
+
##### watchesRunning
|
|
434
|
+
|
|
435
|
+
> **watchesRunning**: [`WatchesRunning`](watchesRunning.md#watchesrunning)
|
|
436
|
+
|
|
437
|
+
The watches running instance.
|
|
438
|
+
|
|
439
|
+
***
|
|
440
|
+
|
|
441
|
+
### ListRelatedRawState
|
|
442
|
+
|
|
443
|
+
#### Properties
|
|
444
|
+
|
|
445
|
+
##### fkForIdAndRule
|
|
446
|
+
|
|
447
|
+
> **fkForIdAndRule**: `object`
|
|
448
|
+
|
|
449
|
+
Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
|
|
450
|
+
|
|
451
|
+
###### Index Signature
|
|
452
|
+
|
|
453
|
+
\[`id`: `string`\]: `object`
|
|
454
|
+
|
|
455
|
+
##### objAndKeyForIdAndRule
|
|
456
|
+
|
|
457
|
+
> **objAndKeyForIdAndRule**: `object`
|
|
458
|
+
|
|
459
|
+
Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
|
|
460
|
+
|
|
461
|
+
###### Index Signature
|
|
462
|
+
|
|
463
|
+
\[`id`: `string`\]: `object`
|
|
464
|
+
|
|
465
|
+
##### relatedObjects
|
|
466
|
+
|
|
467
|
+
> **relatedObjects**: `object`
|
|
468
|
+
|
|
469
|
+
Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
|
|
470
|
+
|
|
471
|
+
###### Index Signature
|
|
472
|
+
|
|
473
|
+
\[`id`: `string`\]: `object`
|
|
474
|
+
|
|
475
|
+
##### relatedObjectsParentStateObjectsWatchRunning
|
|
476
|
+
|
|
477
|
+
> **relatedObjectsParentStateObjectsWatchRunning**: `boolean`
|
|
478
|
+
|
|
479
|
+
Flags whether the watch on parent state objects is currently active, ensuring updates trigger as needed.
|
|
480
|
+
|
|
481
|
+
##### relatedObjectsRules
|
|
482
|
+
|
|
483
|
+
> **relatedObjectsRules**: `object`
|
|
484
|
+
|
|
485
|
+
Defines the rules for establishing relationships, such as foreign key links and sorting orders.
|
|
486
|
+
|
|
487
|
+
###### Index Signature
|
|
488
|
+
|
|
489
|
+
\[`rule`: `string`\]: [`ListRelatedRule`](listRelated.md#listrelatedrule)
|
|
490
|
+
|
|
491
|
+
##### relatedObjectsWatchRunning
|
|
492
|
+
|
|
493
|
+
> **relatedObjectsWatchRunning**: `boolean`
|
|
494
|
+
|
|
495
|
+
Indicates if watches on the related objects themselves are active, managing updates efficiently.
|
|
496
|
+
|
|
497
|
+
##### relatedRunning
|
|
498
|
+
|
|
499
|
+
> **relatedRunning**: `boolean`
|
|
500
|
+
|
|
501
|
+
Signals whether any computations related to object relationships are currently in progress.
|
|
502
|
+
|
|
503
|
+
##### running
|
|
504
|
+
|
|
505
|
+
> **running**: `Ref`\<`boolean`\>
|
|
506
|
+
|
|
507
|
+
General flag that indicates if the list-related logic is processing, used to manage UI feedback or prevent concurrent operations.
|
|
508
|
+
|
|
509
|
+
***
|
|
510
|
+
|
|
511
|
+
### ListRelatedRule
|
|
512
|
+
|
|
513
|
+
#### Properties
|
|
514
|
+
|
|
515
|
+
##### objects
|
|
516
|
+
|
|
517
|
+
> **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
|
|
518
|
+
|
|
519
|
+
The objects that can be related based on the foreign key.
|
|
520
|
+
|
|
521
|
+
##### order
|
|
522
|
+
|
|
523
|
+
> **order**: `string`[]
|
|
524
|
+
|
|
525
|
+
Specifies the order in which related objects should be sorted, if applicable.
|
|
526
|
+
|
|
527
|
+
##### pkKey
|
|
528
|
+
|
|
529
|
+
> **pkKey**: `string`
|
|
530
|
+
|
|
531
|
+
Specifies the foreign key used to link objects across lists. Planned to be renamed to
|
|
532
|
+
'fkKey' to better reflect its usage.
|
|
533
|
+
|
|
534
|
+
## Type Aliases
|
|
535
|
+
|
|
536
|
+
### ListRelated
|
|
537
|
+
|
|
538
|
+
> **ListRelated**\<\>: [`ListRelatedProperties`](listRelated.md#listrelatedproperties)
|
|
539
|
+
|
|
540
|
+
#### Type Parameters
|
|
541
|
+
|
|
542
|
+
***
|
|
543
|
+
|
|
544
|
+
### ListRelatedParentRawState
|
|
545
|
+
|
|
546
|
+
> **ListRelatedParentRawState**\<\>: [`use/listInstance`](listInstance.md) & `Partial`\<[`use/listSubscription`](listSubscription.md)\>
|
|
547
|
+
|
|
548
|
+
#### Type Parameters
|
|
549
|
+
|
|
550
|
+
***
|
|
551
|
+
|
|
552
|
+
### ListRelatedParentState
|
|
553
|
+
|
|
554
|
+
> **ListRelatedParentState**\<\>: `UnwrapNestedRefs`
|
|
555
|
+
|
|
556
|
+
#### Type Parameters
|
|
557
|
+
|
|
558
|
+
***
|
|
559
|
+
|
|
560
|
+
### ListRelatedRules
|
|
561
|
+
|
|
562
|
+
> **ListRelatedRules**\<\>: `UnwrapNestedRefs`
|
|
563
|
+
|
|
564
|
+
#### Type Parameters
|
|
565
|
+
|
|
566
|
+
***
|
|
567
|
+
|
|
568
|
+
### ListRelatedState
|
|
569
|
+
|
|
570
|
+
> **ListRelatedState**\<\>: `UnwrapNestedRefs`
|
|
571
|
+
|
|
572
|
+
#### Type Parameters
|
|
573
|
+
|
|
574
|
+
## Functions
|
|
575
|
+
|
|
576
|
+
### useListRelated()
|
|
577
|
+
|
|
578
|
+
> **useListRelated**(`options`): [`ListRelatedProperties`](listRelated.md#listrelatedproperties)
|
|
579
|
+
|
|
580
|
+
Initializes and returns an instance of a related objects manager. This function sets up reactive states
|
|
581
|
+
and computations that dynamically adjust as the parent list's state changes. It uses defined rules
|
|
582
|
+
for object relationships to compute and update related objects in real-time, ensuring that changes in the parent
|
|
583
|
+
state are reflected in the relationships defined by the rules.
|
|
584
|
+
|
|
585
|
+
#### Parameters
|
|
586
|
+
|
|
587
|
+
• **options**: [`ListRelatedOptions`](listRelated.md#listrelatedoptions)
|
|
588
|
+
|
|
589
|
+
The configuration options including the parent state and rules for related
|
|
590
|
+
objects.
|
|
591
|
+
|
|
592
|
+
#### Returns
|
|
593
|
+
|
|
594
|
+
[`ListRelatedProperties`](listRelated.md#listrelatedproperties)
|
|
595
|
+
|
|
596
|
+
- A reactive instance that manages related objects, providing real-time updates and
|
|
597
|
+
maintaining the integrity of object relationships as per the specified rules.
|
|
598
|
+
|
|
599
|
+
#### Example
|
|
600
|
+
|
|
601
|
+
```vue
|
|
602
|
+
<script setup>
|
|
603
|
+
import { useListInstance, useListRelated } from "@arrai-innovations/reactive-helpers";
|
|
604
|
+
import { reactive, toRef } from "vue";
|
|
605
|
+
|
|
606
|
+
const props = defineProps({
|
|
607
|
+
someListFilter: {
|
|
608
|
+
type: String,
|
|
609
|
+
default: "",
|
|
610
|
+
description: "The filter to apply to the list.",
|
|
611
|
+
},
|
|
612
|
+
objects: {
|
|
613
|
+
type: Object,
|
|
614
|
+
default: () => ({}),
|
|
615
|
+
description: "The objects to relate to.",
|
|
616
|
+
},
|
|
617
|
+
order: {
|
|
618
|
+
type: Array,
|
|
619
|
+
default: () => [],
|
|
620
|
+
description: "The order of the list.",
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
const listInstanceProps = reactive({
|
|
625
|
+
crudArgs: {
|
|
626
|
+
// whatever arguments are required for your configured list crud function to get the right endpoint
|
|
627
|
+
},
|
|
628
|
+
listArgs: {
|
|
629
|
+
// whatever arguments are required for your configured list function to get the right list
|
|
630
|
+
someListFilter: toRef(props, "someListFilter"),
|
|
631
|
+
},
|
|
632
|
+
retrieveArgs: {
|
|
633
|
+
// whatever arguments are required for your configured list function to get items back looking as expected
|
|
634
|
+
},
|
|
635
|
+
intendToList: false,
|
|
636
|
+
});
|
|
637
|
+
listInstanceProps.intendToList = computed(()=> !!props.someListFilter);
|
|
638
|
+
const listInstance = useListInstance({ props: listInstanceProps });
|
|
639
|
+
const listRelatedProps = reactive({
|
|
640
|
+
parentState: listInstance.state, // reactive-to-reactive so no need for toRef
|
|
641
|
+
relatedObjectsRules: {
|
|
642
|
+
someRule: {
|
|
643
|
+
// this can point to a key or an array of keys to relate to
|
|
644
|
+
pkKey: "dot.separated.key.to.id.on.an.listInstance.object",
|
|
645
|
+
objects: toRef(props, "objects"),
|
|
646
|
+
order: toRef(props, "order"),
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
});
|
|
650
|
+
const listRelated = useListRelated(listRelatedProps);
|
|
651
|
+
</script>
|
|
652
|
+
<template>
|
|
653
|
+
<ul>
|
|
654
|
+
<!-- reactive list of objects, re-retrieving the list as someListFilter changes. -->
|
|
655
|
+
<li v-for="obj in listInstance.state.objectsInOrder">
|
|
656
|
+
{{ obj }}
|
|
657
|
+
<div>
|
|
658
|
+
<!-- the related object or objects based on the rule -->
|
|
659
|
+
{{ listRelated.state.relatedObjects[obj.id].someRule }}
|
|
660
|
+
</div>
|
|
661
|
+
</li>
|
|
662
|
+
</ul>
|
|
663
|
+
</template>
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
***
|
|
667
|
+
|
|
668
|
+
### useListRelateds()
|
|
669
|
+
|
|
670
|
+
> **useListRelateds**(`listRelatedArgs`): `object`
|
|
671
|
+
|
|
672
|
+
Creates and manages multiple instances of list-related properties, linking each to corresponding parent instances
|
|
673
|
+
based on provided configuration.
|
|
674
|
+
|
|
675
|
+
#### Parameters
|
|
676
|
+
|
|
677
|
+
• **listRelatedArgs**
|
|
678
|
+
|
|
679
|
+
The options for the list related properties.
|
|
680
|
+
|
|
681
|
+
#### Returns
|
|
682
|
+
|
|
683
|
+
`object`
|
|
684
|
+
|
|
685
|
+
- The instances of the list related properties.
|