@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.
Files changed (115) hide show
  1. package/.husky/pre-commit +0 -1
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.prettierignore +1 -0
  4. package/README.md +11 -10
  5. package/config/listCrud.js +32 -1
  6. package/config/objectCrud.js +47 -1
  7. package/docs/README.md +43 -0
  8. package/docs/config/listCrud.md +97 -0
  9. package/docs/config/objectCrud.md +123 -0
  10. package/docs/use/cancellableIntent.md +163 -0
  11. package/docs/use/combineClasses.md +52 -0
  12. package/docs/use/list.md +285 -0
  13. package/docs/use/listCalculated.md +773 -0
  14. package/docs/use/listFilter.md +877 -0
  15. package/docs/use/listInstance.md +483 -0
  16. package/docs/use/listKeys.md +91 -0
  17. package/docs/use/listRelated.md +685 -0
  18. package/docs/use/listSearch.md +889 -0
  19. package/docs/use/listSort.md +1144 -0
  20. package/docs/use/listSubscription.md +379 -0
  21. package/docs/use/loadingError.md +21 -0
  22. package/docs/use/object.md +437 -0
  23. package/docs/use/objectCalculated.md +606 -0
  24. package/docs/use/objectInstance.md +486 -0
  25. package/docs/use/objectRelated.md +588 -0
  26. package/docs/use/objectSubscription.md +459 -0
  27. package/docs/use/paginatedListInstance.md +147 -0
  28. package/docs/use/search.md +311 -0
  29. package/docs/use/watchesRunning.md +80 -0
  30. package/docs/utils/assignReactiveObject.md +351 -0
  31. package/docs/utils/classes.md +100 -0
  32. package/docs/utils/compact.md +57 -0
  33. package/docs/utils/deleteKey.md +53 -0
  34. package/docs/utils/flattenPaths.md +45 -0
  35. package/docs/utils/getFakeId.md +34 -0
  36. package/docs/utils/keyDiff.md +101 -0
  37. package/docs/utils/loadingCombine.md +28 -0
  38. package/docs/utils/proxyRunning.md +33 -0
  39. package/docs/utils/relatedCalculatedHelpers.md +75 -0
  40. package/docs/utils/set.md +139 -0
  41. package/docs/utils/transformWalk.md +33 -0
  42. package/docs/utils/watches.md +441 -0
  43. package/eslint.config.js +125 -0
  44. package/index.js +34 -3
  45. package/lint-staged.config.js +5 -1
  46. package/makeTypeDoc.sh +25 -0
  47. package/package.json +27 -19
  48. package/tests/unit/config/listCrud.spec.js +5 -0
  49. package/tests/unit/config/objectCrud.spec.js +5 -0
  50. package/tests/unit/crudPromise.js +22 -3
  51. package/tests/unit/mockOnUnmounted.js +1 -1
  52. package/tests/unit/use/cancellableIntent.spec.js +2 -0
  53. package/tests/unit/use/listCalculated.spec.js +4 -3
  54. package/tests/unit/use/listFilter.spec.js +11 -7
  55. package/tests/unit/use/listInstance.spec.js +32 -14
  56. package/tests/unit/use/listRelated.spec.js +3 -2
  57. package/tests/unit/use/listSearch.spec.js +9 -7
  58. package/tests/unit/use/listSort.spec.js +29 -22
  59. package/tests/unit/use/listSubscription.spec.js +11 -5
  60. package/tests/unit/use/objectInstance.spec.js +15 -2
  61. package/tests/unit/use/objectSubscription.spec.js +31 -16
  62. package/tests/unit/use/search.spec.js +2 -2
  63. package/tests/unit/utils/assignReactiveObject.spec.js +21 -13
  64. package/tests/unit/utils/classes.spec.js +7 -6
  65. package/tests/unit/utils/watches.spec.js +4 -4
  66. package/tsconfig.json +19 -0
  67. package/typedoc-local-plugins/customize-output.js +13 -0
  68. package/typedoc.json +12 -0
  69. package/use/cancellableIntent.js +73 -2
  70. package/use/combineClasses.js +41 -31
  71. package/use/list.js +139 -5
  72. package/use/listCalculated.js +175 -10
  73. package/use/listFilter.js +175 -21
  74. package/use/listInstance.js +215 -94
  75. package/use/listRelated.js +260 -72
  76. package/use/listSearch.js +178 -57
  77. package/use/listSort.js +188 -21
  78. package/use/listSubscription.js +211 -63
  79. package/use/loadingError.js +43 -0
  80. package/use/object.js +187 -23
  81. package/use/objectCalculated.js +168 -16
  82. package/use/objectInstance.js +183 -102
  83. package/use/objectRelated.js +276 -84
  84. package/use/objectSubscription.js +169 -17
  85. package/use/paginatedListInstance.js +30 -1
  86. package/use/search.js +39 -23
  87. package/use/watchesRunning.js +41 -6
  88. package/utils/assignReactiveObject.js +139 -88
  89. package/utils/classes.js +57 -48
  90. package/utils/compact.js +28 -2
  91. package/utils/deleteKey.js +14 -1
  92. package/utils/flattenPaths.js +19 -9
  93. package/utils/getFakeId.js +11 -1
  94. package/utils/keyDiff.js +26 -35
  95. package/utils/loadingCombine.js +7 -4
  96. package/utils/proxyRunning.js +16 -8
  97. package/utils/relatedCalculatedHelpers.js +17 -0
  98. package/utils/set.js +66 -0
  99. package/utils/transformWalk.js +7 -6
  100. package/utils/watches.js +205 -71
  101. package/.eslintignore +0 -2
  102. package/.eslintrc.cjs +0 -25
  103. package/.jsdoc2md.json +0 -4
  104. package/config/index.js +0 -2
  105. package/docs.md +0 -1002
  106. package/jsdoc-to-markdown.sh +0 -16
  107. package/tests/unit/.eslintrc.cjs +0 -11
  108. package/tests/unit/config/index.spec.js +0 -18
  109. package/tests/unit/use/index.spec.js +0 -18
  110. package/tests/unit/utils/index.spec.js +0 -18
  111. package/use/index.js +0 -19
  112. package/utils/debugMessage.js +0 -209
  113. package/utils/debugWatch.js +0 -29
  114. package/utils/index.js +0 -16
  115. package/utils/lifecycleDebug.js +0 -126
@@ -0,0 +1,379 @@
1
+ [**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
2
+
3
+ ***
4
+
5
+ [@arrai-innovations/reactive-helpers](../README.md) / use/listSubscription
6
+
7
+ # use/listSubscription
8
+
9
+ ## Classes
10
+
11
+ ### ListSubscriptionError
12
+
13
+ Custom error class for list subscription errors.
14
+
15
+ #### Extends
16
+
17
+ - `Error`
18
+
19
+ #### Constructors
20
+
21
+ ##### new ListSubscriptionError()
22
+
23
+ > **new ListSubscriptionError**(`message`, `code`): [`ListSubscriptionError`](listSubscription.md#listsubscriptionerror)
24
+
25
+ Creates a new ListSubscriptionError.
26
+
27
+ ###### Parameters
28
+
29
+ • **message**: `string`
30
+
31
+ The error message.
32
+
33
+ • **code**: `string`
34
+
35
+ The error code.
36
+
37
+ ###### Returns
38
+
39
+ [`ListSubscriptionError`](listSubscription.md#listsubscriptionerror)
40
+
41
+ ###### Overrides
42
+
43
+ `Error.constructor`
44
+
45
+ #### Properties
46
+
47
+ ##### code
48
+
49
+ > **code**: `string`
50
+
51
+ ##### name
52
+
53
+ > **name**: `string`
54
+
55
+ ###### Inherited from
56
+
57
+ `Error.name`
58
+
59
+ ## Interfaces
60
+
61
+ ### ListSubscriptionFunctions
62
+
63
+ #### Properties
64
+
65
+ ##### clearError
66
+
67
+ > **clearError**: `Function`
68
+
69
+ Clear the subscription error and the underlying list instance error.
70
+
71
+ ##### subscribe
72
+
73
+ > **subscribe**: `Function`
74
+
75
+ Trigger a subscription to the list.
76
+
77
+ ##### unsubscribe
78
+
79
+ > **unsubscribe**: `Function`
80
+
81
+ Unsubscribe from the list.
82
+
83
+ ***
84
+
85
+ ### ListSubscriptionProperties
86
+
87
+ #### Properties
88
+
89
+ ##### effectScope
90
+
91
+ > **effectScope**: `EffectScope`
92
+
93
+ The effect scope of the list subscription.
94
+
95
+ ##### listInstance
96
+
97
+ > **listInstance**: [`ListInstance`](listInstance.md#listinstance)
98
+
99
+ The list instance used by the subscription.
100
+
101
+ ##### listIntent
102
+
103
+ > **listIntent**: [`CancellableIntent`](cancellableIntent.md#cancellableintent)
104
+
105
+ The `CancellableIntent` instance managing if the list should be (re)fetched.
106
+
107
+ ##### state
108
+
109
+ > **state**: `object`
110
+
111
+ The reactive state of the list subscription.
112
+
113
+ ###### crud
114
+
115
+ > **crud**: `object`
116
+
117
+ CRUD functions and their configurations for the list.
118
+
119
+ ###### crud.args
120
+
121
+ > **args**: `any`
122
+
123
+ Arguments for the CRUD functions.
124
+
125
+ ###### crud.list
126
+
127
+ > **list**: `Function`
128
+
129
+ Function to list objects.
130
+
131
+ ###### error
132
+
133
+ > **error**: `Error`
134
+
135
+ The last error encountered.
136
+
137
+ ###### errored
138
+
139
+ > **errored**: `boolean`
140
+
141
+ Indicates if an error occurred during the last operation.
142
+
143
+ ###### intendToList
144
+
145
+ > **intendToList**: `boolean`
146
+
147
+ If this is true, the list should be fetched, or re-fetched if arguments change.
148
+
149
+ ###### intendToSubscribe
150
+
151
+ > **intendToSubscribe**: `boolean`
152
+
153
+ If this is true, the subscription should start or restart if arguments change.
154
+
155
+ ###### listArgs
156
+
157
+ > **listArgs**: `any`
158
+
159
+ Arguments passed to the server for listing operations.
160
+
161
+ ###### loading
162
+
163
+ > **loading**: `boolean`
164
+
165
+ Indicates if the list is currently loading.
166
+
167
+ ###### objects
168
+
169
+ > **objects**: [`ObjectsById`](listInstance.md#objectsbyid)
170
+
171
+ The list objects stored by their IDs.
172
+
173
+ ###### objectsInOrder
174
+
175
+ > **objectsInOrder**: [`ListObject`](listInstance.md#listobject)[]
176
+
177
+ The objects in the order specified by the list.
178
+
179
+ ###### order
180
+
181
+ > **order**: `string`[]
182
+
183
+ The order of objects in the list.
184
+
185
+ ###### retrieveArgs
186
+
187
+ > **retrieveArgs**: `any`
188
+
189
+ Arguments passed to the server for retrieval operations.
190
+
191
+ ###### running
192
+
193
+ > **running**: `boolean`
194
+
195
+ Indicates if there are ongoing reactive updates.
196
+
197
+ ###### subscribed
198
+
199
+ > **subscribed**: `boolean`
200
+
201
+ Whether the subscription is active.
202
+
203
+ ###### subscriptionError
204
+
205
+ > **subscriptionError**: `Error`
206
+
207
+ The error that occurred.
208
+
209
+ ###### subscriptionErrored
210
+
211
+ > **subscriptionErrored**: `boolean`
212
+
213
+ Whether the subscription has errored.
214
+
215
+ ###### subscriptionLoading
216
+
217
+ > **subscriptionLoading**: `boolean`
218
+
219
+ Whether the subscription is loading.
220
+
221
+ ##### subscribeIntent
222
+
223
+ > **subscribeIntent**: [`CancellableIntent`](cancellableIntent.md#cancellableintent)
224
+
225
+ The `CancellableIntent` instance managing if the subscription should be (un)subscribed.
226
+
227
+ ***
228
+
229
+ ### ListSubscriptionRawState
230
+
231
+ #### Properties
232
+
233
+ ##### intendToList
234
+
235
+ > **intendToList**: `boolean`
236
+
237
+ If this is true, the list should be fetched, or re-fetched if arguments change.
238
+
239
+ ##### intendToSubscribe
240
+
241
+ > **intendToSubscribe**: `boolean`
242
+
243
+ If this is true, the subscription should start or restart if arguments change.
244
+
245
+ ##### subscribed
246
+
247
+ > **subscribed**: `boolean`
248
+
249
+ Whether the subscription is active.
250
+
251
+ ##### subscriptionError
252
+
253
+ > **subscriptionError**: `Readonly`\<`Ref`\<`Error`\>\>
254
+
255
+ The error that occurred.
256
+
257
+ ##### subscriptionErrored
258
+
259
+ > **subscriptionErrored**: `Readonly`\<`Ref`\<`boolean`\>\>
260
+
261
+ Whether the subscription has errored.
262
+
263
+ ##### subscriptionLoading
264
+
265
+ > **subscriptionLoading**: `Readonly`\<`Ref`\<`boolean`\>\>
266
+
267
+ Whether the subscription is loading.
268
+
269
+ ## Type Aliases
270
+
271
+ ### ListSubscription
272
+
273
+ > **ListSubscription**\<\>: [`ListSubscriptionFunctions`](listSubscription.md#listsubscriptionfunctions) & [`ListSubscriptionProperties`](listSubscription.md#listsubscriptionproperties)
274
+
275
+ #### Type Parameters
276
+
277
+ ***
278
+
279
+ ### ListSubscriptionOptions
280
+
281
+ > **ListSubscriptionOptions**\<\>: `object` & [`use/listInstance`](listInstance.md)
282
+
283
+ #### Type Parameters
284
+
285
+ ***
286
+
287
+ ### ListSubscriptionState
288
+
289
+ > **ListSubscriptionState**\<\>: `UnwrapNestedRefs`
290
+
291
+ #### Type Parameters
292
+
293
+ ## Functions
294
+
295
+ ### useListSubscription()
296
+
297
+ > **useListSubscription**(`options`): [`ListSubscription`](listSubscription.md#listsubscription)
298
+
299
+ A composition function that creates a reactive object that manages a list of objects, as returned by
300
+ `useListInstance`, causing the list to be re-fetched as needed and listening for updates to the list.
301
+
302
+ #### Parameters
303
+
304
+ • **options**: `any`
305
+
306
+ The options for the list subscription.
307
+
308
+ #### Returns
309
+
310
+ [`ListSubscription`](listSubscription.md#listsubscription)
311
+
312
+ - Returns a robust list subscription object that manages a list instance with
313
+ capabilities to subscribe and unsubscribe to data sources, alongside handling real-time data updates.
314
+
315
+ #### Example
316
+
317
+ ```vue
318
+ <script setup>
319
+ import { useListSubscription } from "@arrai-innovations/reactive-helpers";
320
+ import { reactive, toRef } from "vue";
321
+
322
+ const props = defineProps({
323
+ // whatever props are required for your configured list instance
324
+ someListFilter: {
325
+ type: String,
326
+ default: "",
327
+ },
328
+ });
329
+
330
+ const listSubscriptionProps = reactive({
331
+ crudArgs: {
332
+ // whatever arguments are required for your configured list crud function to get the right endpoint
333
+ },
334
+ listArgs: {
335
+ // whatever arguments are required for your configured list function to get the right list
336
+ someListFilter: toRef(props, "someListFilter"),
337
+ },
338
+ retrieveArgs: {
339
+ // whatever arguments are required for your configured list function to get items back looking as expected
340
+ },
341
+ intendToList: false,
342
+ intendToSubscribe: false,
343
+ });
344
+ listSubscriptionProps.intendToList = listSubscriptionProps.intendToSubscribe = computed(()=> !!props.someListFilter);
345
+ const listSubscription = useListSubscription({ props: listSubscriptionProps });
346
+ </script>
347
+ <template>
348
+ <ul>
349
+ <!-- reactive list of objects, responding to updates via configured subscription function. -->
350
+ <li v-for="obj in listSubscription.state.objectsInOrder">
351
+ {{ obj }}
352
+ </li>
353
+ </ul>
354
+ </template>
355
+ ```
356
+
357
+ #### Throws
358
+
359
+ - If both listInstance and props are passed, or if neither are passed.
360
+
361
+ ***
362
+
363
+ ### useListSubscriptions()
364
+
365
+ > **useListSubscriptions**(`listSubscriptionArgs`): `object`
366
+
367
+ A Vue composition function that creates multiple list subscriptions, and returns them as an object.
368
+
369
+ #### Parameters
370
+
371
+ • **listSubscriptionArgs**
372
+
373
+ Each desired list instance options, keyed by an instance name.
374
+
375
+ #### Returns
376
+
377
+ `object`
378
+
379
+ - Each list instance, keyed by the instance name.
@@ -0,0 +1,21 @@
1
+ [**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
2
+
3
+ ***
4
+
5
+ [@arrai-innovations/reactive-helpers](../README.md) / use/loadingError
6
+
7
+ # use/loadingError
8
+
9
+ ## Functions
10
+
11
+ ### default()
12
+
13
+ > **default**(): `any`
14
+
15
+ A composable function for managing loading and error states.
16
+
17
+ #### Returns
18
+
19
+ `any`
20
+
21
+ - An object containing reactive fields and actions for loading and error states.