@arrai-innovations/reactive-helpers 13.0.4 → 14.0.1

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.
Files changed (62) hide show
  1. package/README.md +11 -1
  2. package/config/listCrud.js +4 -1
  3. package/config/objectCrud.js +10 -4
  4. package/docs/README.md +2 -1
  5. package/docs/config/listCrud.md +26 -2
  6. package/docs/config/objectCrud.md +59 -15
  7. package/docs/use/list.md +16 -0
  8. package/docs/use/listCalculated.md +58 -39
  9. package/docs/use/listFilter.md +57 -39
  10. package/docs/use/listInstance.md +29 -11
  11. package/docs/use/listRelated.md +47 -28
  12. package/docs/use/listSearch.md +40 -28
  13. package/docs/use/listSort.md +58 -39
  14. package/docs/use/listSubscription.md +8 -2
  15. package/docs/use/loadingError.md +41 -27
  16. package/docs/use/object.md +121 -12
  17. package/docs/use/objectCalculated.md +26 -13
  18. package/docs/use/objectInstance.md +49 -24
  19. package/docs/use/objectRelated.md +27 -14
  20. package/docs/use/objectSubscription.md +18 -9
  21. package/docs/use/paginatedListInstance.md +8 -2
  22. package/docs/use/proxyLoadingError.md +49 -0
  23. package/docs/use/search.md +8 -2
  24. package/docs/utils/classes.md +11 -0
  25. package/docs/utils/compact.md +4 -0
  26. package/docs/utils/{getFakeId.md → getFakePk.md} +7 -7
  27. package/docs/utils/relatedCalculatedHelpers.md +4 -0
  28. package/docs/utils/set.md +60 -0
  29. package/docs/utils/transformWalk.md +29 -0
  30. package/index.js +2 -1
  31. package/package.json +14 -14
  32. package/tests/unit/use/listCalculated.spec.js +4 -4
  33. package/tests/unit/use/listFilter.spec.js +10 -9
  34. package/tests/unit/use/listInstance.spec.js +147 -23
  35. package/tests/unit/use/listRelated.spec.js +5 -5
  36. package/tests/unit/use/listSearch.spec.js +14 -12
  37. package/tests/unit/use/listSort.spec.js +8 -1
  38. package/tests/unit/use/listSubscription.spec.js +119 -10
  39. package/tests/unit/use/loadingError.spec.js +43 -0
  40. package/tests/unit/use/objectInstance.spec.js +575 -46
  41. package/tests/unit/use/objectSubscription.spec.js +152 -23
  42. package/tests/unit/use/proxyLoadingError.spec.js +64 -0
  43. package/tests/unit/use/search.spec.js +11 -11
  44. package/use/list.js +1 -0
  45. package/use/listCalculated.js +3 -2
  46. package/use/listFilter.js +9 -9
  47. package/use/listInstance.js +39 -28
  48. package/use/listKeys.js +4 -3
  49. package/use/listRelated.js +24 -23
  50. package/use/listSearch.js +37 -33
  51. package/use/listSort.js +1 -0
  52. package/use/listSubscription.js +25 -15
  53. package/use/loadingError.js +16 -2
  54. package/use/object.js +8 -13
  55. package/use/objectCalculated.js +2 -1
  56. package/use/objectInstance.js +29 -14
  57. package/use/objectRelated.js +3 -2
  58. package/use/objectSubscription.js +31 -11
  59. package/use/paginatedListInstance.js +1 -1
  60. package/use/proxyLoadingError.js +59 -0
  61. package/use/search.js +13 -4
  62. package/utils/{getFakeId.js → getFakePk.js} +4 -4
@@ -38,7 +38,7 @@ The calculated objects.
38
38
 
39
39
  ###### Index Signature
40
40
 
41
- \[`id`: `string`\]: `object`
41
+ \[`pk`: `string`\]: `object`
42
42
 
43
43
  ###### calculatedObjectsParentStateObjectsWatchRunning
44
44
 
@@ -98,15 +98,15 @@ The last error encountered.
98
98
 
99
99
  Indicates if an error occurred during the last operation.
100
100
 
101
- ###### fkForIdAndRule
101
+ ###### fkForPkAndRule
102
102
 
103
- > **fkForIdAndRule**: `object`
103
+ > **fkForPkAndRule**: `object`
104
104
 
105
- Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
105
+ Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
106
106
 
107
107
  ###### Index Signature
108
108
 
109
- \[`id`: `string`\]: `object`
109
+ \[`pk`: `string`\]: `object`
110
110
 
111
111
  ###### intendToList
112
112
 
@@ -132,21 +132,21 @@ Arguments passed to the server for listing operations.
132
132
 
133
133
  Indicates if the list is currently loading.
134
134
 
135
- ###### objAndKeyForIdAndRule
135
+ ###### objAndKeyForPkAndRule
136
136
 
137
- > **objAndKeyForIdAndRule**: `object`
137
+ > **objAndKeyForPkAndRule**: `object`
138
138
 
139
- Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
139
+ Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
140
140
 
141
141
  ###### Index Signature
142
142
 
143
- \[`id`: `string`\]: `object`
143
+ \[`pk`: `string`\]: `object`
144
144
 
145
145
  ###### objects
146
146
 
147
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
147
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
148
148
 
149
- The list objects stored by their IDs.
149
+ The list objects stored by their pks.
150
150
 
151
151
  ###### objectsInOrder
152
152
 
@@ -160,15 +160,21 @@ The objects in the order specified by the list.
160
160
 
161
161
  The order of objects in the list.
162
162
 
163
+ ###### pkKey
164
+
165
+ > **pkKey**: `string`
166
+
167
+ The primary key field for the list objects.
168
+
163
169
  ###### relatedObjects
164
170
 
165
171
  > **relatedObjects**: `object`
166
172
 
167
- Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
173
+ Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
168
174
 
169
175
  ###### Index Signature
170
176
 
171
- \[`id`: `string`\]: `object`
177
+ \[`pk`: `string`\]: `object`
172
178
 
173
179
  ###### relatedObjectsParentStateObjectsWatchRunning
174
180
 
@@ -260,7 +266,7 @@ The calculated objects.
260
266
 
261
267
  ###### Index Signature
262
268
 
263
- \[`id`: `string`\]: `object`
269
+ \[`pk`: `string`\]: `object`
264
270
 
265
271
  ###### calculatedObjectsParentStateObjectsWatchRunning
266
272
 
@@ -320,15 +326,15 @@ The last error encountered.
320
326
 
321
327
  Indicates if an error occurred during the last operation.
322
328
 
323
- ###### fkForIdAndRule
329
+ ###### fkForPkAndRule
324
330
 
325
- > **fkForIdAndRule**: `object`
331
+ > **fkForPkAndRule**: `object`
326
332
 
327
- Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
333
+ Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
328
334
 
329
335
  ###### Index Signature
330
336
 
331
- \[`id`: `string`\]: `object`
337
+ \[`pk`: `string`\]: `object`
332
338
 
333
339
  ###### intendToList
334
340
 
@@ -354,21 +360,21 @@ Arguments passed to the server for listing operations.
354
360
 
355
361
  Indicates if the list is currently loading.
356
362
 
357
- ###### objAndKeyForIdAndRule
363
+ ###### objAndKeyForPkAndRule
358
364
 
359
- > **objAndKeyForIdAndRule**: `object`
365
+ > **objAndKeyForPkAndRule**: `object`
360
366
 
361
- Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
367
+ Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
362
368
 
363
369
  ###### Index Signature
364
370
 
365
- \[`id`: `string`\]: `object`
371
+ \[`pk`: `string`\]: `object`
366
372
 
367
373
  ###### objects
368
374
 
369
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
375
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
370
376
 
371
- The list objects stored by their IDs.
377
+ The list objects stored by their pks.
372
378
 
373
379
  ###### objectsInOrder
374
380
 
@@ -382,15 +388,21 @@ The objects in the order specified by the list.
382
388
 
383
389
  The order of objects in the list.
384
390
 
391
+ ###### pkKey
392
+
393
+ > **pkKey**: `string`
394
+
395
+ The primary key field for the list objects.
396
+
385
397
  ###### relatedObjects
386
398
 
387
399
  > **relatedObjects**: `object`
388
400
 
389
- Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
401
+ Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
390
402
 
391
403
  ###### Index Signature
392
404
 
393
- \[`id`: `string`\]: `object`
405
+ \[`pk`: `string`\]: `object`
394
406
 
395
407
  ###### relatedObjectsParentStateObjectsWatchRunning
396
408
 
@@ -476,7 +488,7 @@ The calculated objects.
476
488
 
477
489
  ###### Index Signature
478
490
 
479
- \[`id`: `string`\]: `object`
491
+ \[`pk`: `string`\]: `object`
480
492
 
481
493
  ###### calculatedObjectsParentStateObjectsWatchRunning
482
494
 
@@ -542,15 +554,15 @@ Indicates if an error occurred during the last operation.
542
554
 
543
555
  Function to determine if an item should be excluded based on custom logic.
544
556
 
545
- ###### fkForIdAndRule
557
+ ###### fkForPkAndRule
546
558
 
547
- > **fkForIdAndRule**: `object`
559
+ > **fkForPkAndRule**: `object`
548
560
 
549
- Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
561
+ Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
550
562
 
551
563
  ###### Index Signature
552
564
 
553
- \[`id`: `string`\]: `object`
565
+ \[`pk`: `string`\]: `object`
554
566
 
555
567
  ###### inResults
556
568
 
@@ -582,21 +594,21 @@ Arguments passed to the server for listing operations.
582
594
 
583
595
  Indicates if the list is currently loading.
584
596
 
585
- ###### objAndKeyForIdAndRule
597
+ ###### objAndKeyForPkAndRule
586
598
 
587
- > **objAndKeyForIdAndRule**: `object`
599
+ > **objAndKeyForPkAndRule**: `object`
588
600
 
589
- Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
601
+ Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
590
602
 
591
603
  ###### Index Signature
592
604
 
593
- \[`id`: `string`\]: `object`
605
+ \[`pk`: `string`\]: `object`
594
606
 
595
607
  ###### objects
596
608
 
597
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
609
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
598
610
 
599
- The list objects stored by their IDs.
611
+ The list objects stored by their pks.
600
612
 
601
613
  ###### objectsInOrder
602
614
 
@@ -622,15 +634,21 @@ The order of objects in the list.
622
634
 
623
635
  Flag indicating if the order watch is active.
624
636
 
637
+ ###### pkKey
638
+
639
+ > **pkKey**: `string`
640
+
641
+ The primary key field for the list objects.
642
+
625
643
  ###### relatedObjects
626
644
 
627
645
  > **relatedObjects**: `object`
628
646
 
629
- Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
647
+ Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
630
648
 
631
649
  ###### Index Signature
632
650
 
633
- \[`id`: `string`\]: `object`
651
+ \[`pk`: `string`\]: `object`
634
652
 
635
653
  ###### relatedObjectsParentStateObjectsWatchRunning
636
654
 
@@ -105,7 +105,7 @@ Handles new or updated objects, respecting the keepOldPages setting.
105
105
 
106
106
  > **deleteListObject**: (`objectId`) => `void`
107
107
 
108
- Deletes an object from the list by ID.
108
+ Deletes an object from the list by pk.
109
109
 
110
110
  ###### Parameters
111
111
 
@@ -115,11 +115,11 @@ Deletes an object from the list by ID.
115
115
 
116
116
  `void`
117
117
 
118
- ##### getFakeId()
118
+ ##### getFakePk()
119
119
 
120
- > **getFakeId**: () => `string`
120
+ > **getFakePk**: () => `string`
121
121
 
122
- Generates a unique fake ID for use within the list.
122
+ Generates a unique fake pk for use within the list.
123
123
 
124
124
  ###### Returns
125
125
 
@@ -220,6 +220,12 @@ Implementation specific arguments.
220
220
 
221
221
  The arguments passed to the server.
222
222
 
223
+ ###### pkKey
224
+
225
+ > **pkKey**: `string`
226
+
227
+ The primary key field for the list objects.
228
+
223
229
  ###### retrieveArgs
224
230
 
225
231
  > **retrieveArgs**: `any`
@@ -244,6 +250,12 @@ Implementation specific arguments.
244
250
 
245
251
  The arguments passed to the server.
246
252
 
253
+ ##### pkKey
254
+
255
+ > **pkKey**: `string`
256
+
257
+ The primary key field for the list objects.
258
+
247
259
  ##### retrieveArgs
248
260
 
249
261
  > **retrieveArgs**: `any`
@@ -300,9 +312,9 @@ Indicates if the list is currently loading.
300
312
 
301
313
  ##### objects
302
314
 
303
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
315
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
304
316
 
305
- The list objects stored by their IDs.
317
+ The list objects stored by their pks.
306
318
 
307
319
  ##### objectsInOrder
308
320
 
@@ -316,6 +328,12 @@ The objects in the order specified by the list.
316
328
 
317
329
  The order of objects in the list.
318
330
 
331
+ ##### pkKey
332
+
333
+ > **pkKey**: `string`
334
+
335
+ The primary key field for the list objects.
336
+
319
337
  ##### retrieveArgs
320
338
 
321
339
  > **retrieveArgs**: `any`
@@ -372,9 +390,9 @@ Indicates if there are ongoing reactive updates.
372
390
 
373
391
  #### Type declaration
374
392
 
375
- ##### id
393
+ ##### pk
376
394
 
377
- > **id**: `string`
395
+ > **pk**: `string`
378
396
 
379
397
  ***
380
398
 
@@ -386,15 +404,15 @@ Indicates if there are ongoing reactive updates.
386
404
 
387
405
  ***
388
406
 
389
- ### ObjectsById
407
+ ### ObjectsByPk
390
408
 
391
- > **ObjectsById**\<\>: `object`
409
+ > **ObjectsByPk**\<\>: `object`
392
410
 
393
411
  #### Type Parameters
394
412
 
395
413
  #### Index Signature
396
414
 
397
- \[`key`: `string`\]: [`ListObject`](listInstance.md#listobject)
415
+ \[`pk`: `string`\]: [`ListObject`](listInstance.md#listobject)
398
416
 
399
417
  ***
400
418
 
@@ -74,9 +74,9 @@ Indicates if the list is currently loading.
74
74
 
75
75
  ###### objects
76
76
 
77
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
77
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
78
78
 
79
- The list objects stored by their IDs.
79
+ The list objects stored by their pks.
80
80
 
81
81
  ###### objectsInOrder
82
82
 
@@ -90,6 +90,12 @@ The objects in the order specified by the list.
90
90
 
91
91
  The order of objects in the list.
92
92
 
93
+ ###### pkKey
94
+
95
+ > **pkKey**: `string`
96
+
97
+ The primary key field for the list objects.
98
+
93
99
  ###### retrieveArgs
94
100
 
95
101
  > **retrieveArgs**: `any`
@@ -206,9 +212,9 @@ Indicates if the list is currently loading.
206
212
 
207
213
  ###### objects
208
214
 
209
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
215
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
210
216
 
211
- The list objects stored by their IDs.
217
+ The list objects stored by their pks.
212
218
 
213
219
  ###### objectsInOrder
214
220
 
@@ -222,6 +228,12 @@ The objects in the order specified by the list.
222
228
 
223
229
  The order of objects in the list.
224
230
 
231
+ ###### pkKey
232
+
233
+ > **pkKey**: `string`
234
+
235
+ The primary key field for the list objects.
236
+
225
237
  ###### retrieveArgs
226
238
 
227
239
  > **retrieveArgs**: `any`
@@ -294,15 +306,15 @@ The last error encountered.
294
306
 
295
307
  Indicates if an error occurred during the last operation.
296
308
 
297
- ###### fkForIdAndRule
309
+ ###### fkForPkAndRule
298
310
 
299
- > **fkForIdAndRule**: `object`
311
+ > **fkForPkAndRule**: `object`
300
312
 
301
- Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
313
+ Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
302
314
 
303
315
  ###### Index Signature
304
316
 
305
- \[`id`: `string`\]: `object`
317
+ \[`pk`: `string`\]: `object`
306
318
 
307
319
  ###### intendToList
308
320
 
@@ -328,21 +340,21 @@ Arguments passed to the server for listing operations.
328
340
 
329
341
  Indicates if the list is currently loading.
330
342
 
331
- ###### objAndKeyForIdAndRule
343
+ ###### objAndKeyForPkAndRule
332
344
 
333
- > **objAndKeyForIdAndRule**: `object`
345
+ > **objAndKeyForPkAndRule**: `object`
334
346
 
335
- Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
347
+ Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
336
348
 
337
349
  ###### Index Signature
338
350
 
339
- \[`id`: `string`\]: `object`
351
+ \[`pk`: `string`\]: `object`
340
352
 
341
353
  ###### objects
342
354
 
343
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
355
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
344
356
 
345
- The list objects stored by their IDs.
357
+ The list objects stored by their pks.
346
358
 
347
359
  ###### objectsInOrder
348
360
 
@@ -356,15 +368,21 @@ The objects in the order specified by the list.
356
368
 
357
369
  The order of objects in the list.
358
370
 
371
+ ###### pkKey
372
+
373
+ > **pkKey**: `string`
374
+
375
+ The primary key field for the list objects.
376
+
359
377
  ###### relatedObjects
360
378
 
361
379
  > **relatedObjects**: `object`
362
380
 
363
- Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
381
+ Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
364
382
 
365
383
  ###### Index Signature
366
384
 
367
- \[`id`: `string`\]: `object`
385
+ \[`pk`: `string`\]: `object`
368
386
 
369
387
  ###### relatedObjectsParentStateObjectsWatchRunning
370
388
 
@@ -442,35 +460,35 @@ The watches running instance.
442
460
 
443
461
  #### Properties
444
462
 
445
- ##### fkForIdAndRule
463
+ ##### fkForPkAndRule
446
464
 
447
- > **fkForIdAndRule**: `object`
465
+ > **fkForPkAndRule**: `object`
448
466
 
449
- Maintains computed references to the foreign keys for each object ID and rule, crucial for navigating complex data relationships.
467
+ Maintains computed references to the foreign keys for each object pk and rule, crucial for navigating complex data relationships.
450
468
 
451
469
  ###### Index Signature
452
470
 
453
- \[`id`: `string`\]: `object`
471
+ \[`pk`: `string`\]: `object`
454
472
 
455
- ##### objAndKeyForIdAndRule
473
+ ##### objAndKeyForPkAndRule
456
474
 
457
- > **objAndKeyForIdAndRule**: `object`
475
+ > **objAndKeyForPkAndRule**: `object`
458
476
 
459
- Maps each object ID and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
477
+ Maps each object pk and rule to a tuple consisting of the related object and its respective key, facilitating direct data manipulation.
460
478
 
461
479
  ###### Index Signature
462
480
 
463
- \[`id`: `string`\]: `object`
481
+ \[`pk`: `string`\]: `object`
464
482
 
465
483
  ##### relatedObjects
466
484
 
467
485
  > **relatedObjects**: `object`
468
486
 
469
- Stores computed references to related objects, allowing for dynamic access based on object ID and specific rules.
487
+ Stores computed references to related objects, allowing for dynamic access based on object pk and specific rules.
470
488
 
471
489
  ###### Index Signature
472
490
 
473
- \[`id`: `string`\]: `object`
491
+ \[`pk`: `string`\]: `object`
474
492
 
475
493
  ##### relatedObjectsParentStateObjectsWatchRunning
476
494
 
@@ -514,7 +532,7 @@ General flag that indicates if the list-related logic is processing, used to man
514
532
 
515
533
  ##### objects
516
534
 
517
- > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
535
+ > **objects**: [`ObjectsByPk`](listInstance.md#objectsbypk)
518
536
 
519
537
  The objects that can be related based on the foreign key.
520
538
 
@@ -629,6 +647,7 @@ const listInstanceProps = reactive({
629
647
  // whatever arguments are required for your configured list function to get the right list
630
648
  someListFilter: toRef(props, "someListFilter"),
631
649
  },
650
+ pkKey: 'id',
632
651
  retrieveArgs: {
633
652
  // whatever arguments are required for your configured list function to get items back looking as expected
634
653
  },
@@ -641,7 +660,7 @@ const listRelatedProps = reactive({
641
660
  relatedObjectsRules: {
642
661
  someRule: {
643
662
  // 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",
663
+ pkKey: "dot.separated.key.to.pk.on.an.listInstance.object",
645
664
  objects: toRef(props, "objects"),
646
665
  order: toRef(props, "order"),
647
666
  },