@arrai-innovations/reactive-helpers 18.0.1 → 18.0.2

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 (215) hide show
  1. package/package.json +17 -2
  2. package/types/config/listCrud.d.ts +153 -0
  3. package/types/config/listCrud.d.ts.map +1 -0
  4. package/types/config/objectCrud.d.ts +171 -0
  5. package/types/config/objectCrud.d.ts.map +1 -0
  6. package/types/index.d.ts +37 -0
  7. package/types/index.d.ts.map +1 -0
  8. package/types/tests/unit/config/listCrud.spec.d.ts +2 -0
  9. package/types/tests/unit/config/listCrud.spec.d.ts.map +1 -0
  10. package/types/tests/unit/config/objectCrud.spec.d.ts +2 -0
  11. package/types/tests/unit/config/objectCrud.spec.d.ts.map +1 -0
  12. package/types/tests/unit/crudPromise.d.ts +25 -0
  13. package/types/tests/unit/crudPromise.d.ts.map +1 -0
  14. package/types/tests/unit/expectHelpers.d.ts +2 -0
  15. package/types/tests/unit/expectHelpers.d.ts.map +1 -0
  16. package/types/tests/unit/mockOnUnmounted.d.ts +2 -0
  17. package/types/tests/unit/mockOnUnmounted.d.ts.map +1 -0
  18. package/types/tests/unit/poll.d.ts +2 -0
  19. package/types/tests/unit/poll.d.ts.map +1 -0
  20. package/types/tests/unit/use/cancellableIntent.spec.d.ts +2 -0
  21. package/types/tests/unit/use/cancellableIntent.spec.d.ts.map +1 -0
  22. package/types/tests/unit/use/listCalculated.spec.d.ts +2 -0
  23. package/types/tests/unit/use/listCalculated.spec.d.ts.map +1 -0
  24. package/types/tests/unit/use/listFilter.spec.d.ts +2 -0
  25. package/types/tests/unit/use/listFilter.spec.d.ts.map +1 -0
  26. package/types/tests/unit/use/listInstance.spec.d.ts +2 -0
  27. package/types/tests/unit/use/listInstance.spec.d.ts.map +1 -0
  28. package/types/tests/unit/use/listRelated.spec.d.ts +2 -0
  29. package/types/tests/unit/use/listRelated.spec.d.ts.map +1 -0
  30. package/types/tests/unit/use/listSearch.spec.d.ts +2 -0
  31. package/types/tests/unit/use/listSearch.spec.d.ts.map +1 -0
  32. package/types/tests/unit/use/listSort.spec.d.ts +2 -0
  33. package/types/tests/unit/use/listSort.spec.d.ts.map +1 -0
  34. package/types/tests/unit/use/listSubscription.spec.d.ts +2 -0
  35. package/types/tests/unit/use/listSubscription.spec.d.ts.map +1 -0
  36. package/types/tests/unit/use/loadingError.spec.d.ts +2 -0
  37. package/types/tests/unit/use/loadingError.spec.d.ts.map +1 -0
  38. package/types/tests/unit/use/objectInstance.spec.d.ts +2 -0
  39. package/types/tests/unit/use/objectInstance.spec.d.ts.map +1 -0
  40. package/types/tests/unit/use/objectSubscription.spec.d.ts +2 -0
  41. package/types/tests/unit/use/objectSubscription.spec.d.ts.map +1 -0
  42. package/types/tests/unit/use/proxyLoadingError.spec.d.ts +2 -0
  43. package/types/tests/unit/use/proxyLoadingError.spec.d.ts.map +1 -0
  44. package/types/tests/unit/use/search.spec.d.ts +2 -0
  45. package/types/tests/unit/use/search.spec.d.ts.map +1 -0
  46. package/types/tests/unit/utils/assignReactiveObject.spec.d.ts +2 -0
  47. package/types/tests/unit/utils/assignReactiveObject.spec.d.ts.map +1 -0
  48. package/types/tests/unit/utils/classes.spec.d.ts +2 -0
  49. package/types/tests/unit/utils/classes.spec.d.ts.map +1 -0
  50. package/types/tests/unit/utils/deleteKey.spec.d.ts +2 -0
  51. package/types/tests/unit/utils/deleteKey.spec.d.ts.map +1 -0
  52. package/types/tests/unit/utils/flattenPaths.spec.d.ts +2 -0
  53. package/types/tests/unit/utils/flattenPaths.spec.d.ts.map +1 -0
  54. package/types/tests/unit/utils/keyDiff.spec.d.ts +2 -0
  55. package/types/tests/unit/utils/keyDiff.spec.d.ts.map +1 -0
  56. package/types/tests/unit/utils/set.spec.d.ts +2 -0
  57. package/types/tests/unit/utils/set.spec.d.ts.map +1 -0
  58. package/types/tests/unit/utils/watches.spec.d.ts +2 -0
  59. package/types/tests/unit/utils/watches.spec.d.ts.map +1 -0
  60. package/types/use/cancellableIntent.d.ts +129 -0
  61. package/types/use/cancellableIntent.d.ts.map +1 -0
  62. package/types/use/combineClasses.d.ts +43 -0
  63. package/types/use/combineClasses.d.ts.map +1 -0
  64. package/types/use/list.d.ts +176 -0
  65. package/types/use/list.d.ts.map +1 -0
  66. package/types/use/listCalculated.d.ts +192 -0
  67. package/types/use/listCalculated.d.ts.map +1 -0
  68. package/types/use/listFilter.d.ts +203 -0
  69. package/types/use/listFilter.d.ts.map +1 -0
  70. package/types/use/listInstance.d.ts +357 -0
  71. package/types/use/listInstance.d.ts.map +1 -0
  72. package/types/use/listKeys.d.ts +15 -0
  73. package/types/use/listKeys.d.ts.map +1 -0
  74. package/types/use/listRelated.d.ts +239 -0
  75. package/types/use/listRelated.d.ts.map +1 -0
  76. package/types/use/listSearch.d.ts +298 -0
  77. package/types/use/listSearch.d.ts.map +1 -0
  78. package/types/use/listSort.d.ts +235 -0
  79. package/types/use/listSort.d.ts.map +1 -0
  80. package/types/use/listSubscription.d.ts +218 -0
  81. package/types/use/listSubscription.d.ts.map +1 -0
  82. package/types/use/loadingError.d.ts +81 -0
  83. package/types/use/loadingError.d.ts.map +1 -0
  84. package/types/use/object.d.ts +67 -0
  85. package/types/use/object.d.ts.map +1 -0
  86. package/types/use/objectCalculated.d.ts +215 -0
  87. package/types/use/objectCalculated.d.ts.map +1 -0
  88. package/types/use/objectInstance.d.ts +289 -0
  89. package/types/use/objectInstance.d.ts.map +1 -0
  90. package/types/use/objectRelated.d.ts +264 -0
  91. package/types/use/objectRelated.d.ts.map +1 -0
  92. package/types/use/objectSubscription.d.ts +249 -0
  93. package/types/use/objectSubscription.d.ts.map +1 -0
  94. package/types/use/paginatedListInstance.d.ts +51 -0
  95. package/types/use/paginatedListInstance.d.ts.map +1 -0
  96. package/types/use/proxyLoadingError.d.ts +36 -0
  97. package/types/use/proxyLoadingError.d.ts.map +1 -0
  98. package/types/use/search.d.ts +144 -0
  99. package/types/use/search.d.ts.map +1 -0
  100. package/types/use/watchesRunning.d.ts +63 -0
  101. package/types/use/watchesRunning.d.ts.map +1 -0
  102. package/types/utils/assignReactiveObject.d.ts +115 -0
  103. package/types/utils/assignReactiveObject.d.ts.map +1 -0
  104. package/types/utils/classes.d.ts +22 -0
  105. package/types/utils/classes.d.ts.map +1 -0
  106. package/types/utils/compact.d.ts +4 -0
  107. package/types/utils/compact.d.ts.map +1 -0
  108. package/types/utils/deleteKey.d.ts +16 -0
  109. package/types/utils/deleteKey.d.ts.map +1 -0
  110. package/types/utils/flattenPaths.d.ts +23 -0
  111. package/types/utils/flattenPaths.d.ts.map +1 -0
  112. package/types/utils/getFakePk.d.ts +13 -0
  113. package/types/utils/getFakePk.d.ts.map +1 -0
  114. package/types/utils/keepAliveTry.d.ts +15 -0
  115. package/types/utils/keepAliveTry.d.ts.map +1 -0
  116. package/types/utils/keyDiff.d.ts +63 -0
  117. package/types/utils/keyDiff.d.ts.map +1 -0
  118. package/types/utils/loadingCombine.d.ts +9 -0
  119. package/types/utils/loadingCombine.d.ts.map +1 -0
  120. package/types/utils/proxyRunning.d.ts +9 -0
  121. package/types/utils/proxyRunning.d.ts.map +1 -0
  122. package/types/utils/relatedCalculatedHelpers.d.ts +5 -0
  123. package/types/utils/relatedCalculatedHelpers.d.ts.map +1 -0
  124. package/types/utils/set.d.ts +7 -0
  125. package/types/utils/set.d.ts.map +1 -0
  126. package/types/utils/transformWalk.d.ts +2 -0
  127. package/types/utils/transformWalk.d.ts.map +1 -0
  128. package/types/utils/watches.d.ts +155 -0
  129. package/types/utils/watches.d.ts.map +1 -0
  130. package/.circleci/config.yml +0 -88
  131. package/.commitlintrc.json +0 -3
  132. package/.editorconfig +0 -5
  133. package/.husky/commit-msg +0 -3
  134. package/.husky/pre-commit +0 -3
  135. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  136. package/.idea/encodings.xml +0 -6
  137. package/.idea/inspectionProfiles/Project_Default.xml +0 -7
  138. package/.idea/modules.xml +0 -8
  139. package/.idea/prettier.xml +0 -8
  140. package/.idea/reactive-helpers.iml +0 -15
  141. package/.prettierignore +0 -5
  142. package/.prettierrc.cjs +0 -5
  143. package/.vscode/extensions.json +0 -3
  144. package/docs/README.md +0 -45
  145. package/docs/config/listCrud.md +0 -422
  146. package/docs/config/objectCrud.md +0 -427
  147. package/docs/use/cancellableIntent.md +0 -165
  148. package/docs/use/combineClasses.md +0 -62
  149. package/docs/use/list.md +0 -361
  150. package/docs/use/listCalculated.md +0 -794
  151. package/docs/use/listFilter.md +0 -897
  152. package/docs/use/listInstance.md +0 -559
  153. package/docs/use/listKeys.md +0 -91
  154. package/docs/use/listRelated.md +0 -706
  155. package/docs/use/listSearch.md +0 -903
  156. package/docs/use/listSort.md +0 -1171
  157. package/docs/use/listSubscription.md +0 -393
  158. package/docs/use/loadingError.md +0 -115
  159. package/docs/use/object.md +0 -668
  160. package/docs/use/objectCalculated.md +0 -741
  161. package/docs/use/objectInstance.md +0 -685
  162. package/docs/use/objectRelated.md +0 -723
  163. package/docs/use/objectSubscription.md +0 -538
  164. package/docs/use/paginatedListInstance.md +0 -155
  165. package/docs/use/proxyLoadingError.md +0 -51
  166. package/docs/use/search.md +0 -321
  167. package/docs/use/watchesRunning.md +0 -84
  168. package/docs/utils/assignReactiveObject.md +0 -413
  169. package/docs/utils/classes.md +0 -139
  170. package/docs/utils/compact.md +0 -67
  171. package/docs/utils/deleteKey.md +0 -61
  172. package/docs/utils/flattenPaths.md +0 -53
  173. package/docs/utils/getFakePk.md +0 -39
  174. package/docs/utils/keepAliveTry.md +0 -59
  175. package/docs/utils/keyDiff.md +0 -117
  176. package/docs/utils/loadingCombine.md +0 -30
  177. package/docs/utils/proxyRunning.md +0 -39
  178. package/docs/utils/relatedCalculatedHelpers.md +0 -93
  179. package/docs/utils/set.md +0 -223
  180. package/docs/utils/transformWalk.md +0 -68
  181. package/docs/utils/watches.md +0 -489
  182. package/eslint.config.js +0 -125
  183. package/lint-staged.config.js +0 -10
  184. package/makeTypeDoc.sh +0 -25
  185. package/make_type_doc.js +0 -59
  186. package/tests/unit/config/listCrud.spec.js +0 -114
  187. package/tests/unit/config/objectCrud.spec.js +0 -160
  188. package/tests/unit/crudPromise.js +0 -40
  189. package/tests/unit/expectHelpers.js +0 -6
  190. package/tests/unit/mockOnUnmounted.js +0 -9
  191. package/tests/unit/poll.js +0 -50
  192. package/tests/unit/use/cancellableIntent.spec.js +0 -152
  193. package/tests/unit/use/listCalculated.spec.js +0 -135
  194. package/tests/unit/use/listFilter.spec.js +0 -484
  195. package/tests/unit/use/listInstance.spec.js +0 -1166
  196. package/tests/unit/use/listRelated.spec.js +0 -260
  197. package/tests/unit/use/listSearch.spec.js +0 -586
  198. package/tests/unit/use/listSort.spec.js +0 -418
  199. package/tests/unit/use/listSubscription.spec.js +0 -845
  200. package/tests/unit/use/loadingError.spec.js +0 -43
  201. package/tests/unit/use/objectInstance.spec.js +0 -1525
  202. package/tests/unit/use/objectSubscription.spec.js +0 -849
  203. package/tests/unit/use/proxyLoadingError.spec.js +0 -64
  204. package/tests/unit/use/search.spec.js +0 -248
  205. package/tests/unit/utils/assignReactiveObject.spec.js +0 -593
  206. package/tests/unit/utils/classes.spec.js +0 -427
  207. package/tests/unit/utils/deleteKey.spec.js +0 -265
  208. package/tests/unit/utils/flattenPaths.spec.js +0 -126
  209. package/tests/unit/utils/keyDiff.spec.js +0 -110
  210. package/tests/unit/utils/set.spec.js +0 -81
  211. package/tests/unit/utils/watches.spec.js +0 -276
  212. package/tsconfig.json +0 -19
  213. package/typedoc-local-plugins/customize-output.js +0 -13
  214. package/typedoc.json +0 -11
  215. package/vitest.config.js +0 -11
@@ -0,0 +1,203 @@
1
+ /**
2
+ * @typedef {import('vue').Ref<import('./listInstance.js').ListObject>[]} ObjectsInOrderRefs
3
+ */
4
+ /**
5
+ * @typedef {Function} ListFilterAllowedFilter - A function that returns true if an item should be included.
6
+ */
7
+ /**
8
+ * @typedef {Function} ListFilterExcludedFilter - A function that returns true if an item should be excluded.
9
+ */
10
+ /**
11
+ * Defines the structure of the reactive state used by the list filter. This state includes both filters and
12
+ * the results of applying these filters to a list.
13
+ *
14
+ * @typedef {object} ListFilterRawState
15
+ * @property {ListFilterAllowedFilter} [allowedFilter] - Function to determine if an item should be included based on custom logic.
16
+ * @property {ListFilterExcludedFilter} [excludedFilter] - Function to determine if an item should be excluded based on custom logic.
17
+ * @property {object} inResults - A map of items to boolean values indicating filter results.
18
+ * @property {boolean} objectsWatchRunning - Flag indicating if the object watch is active.
19
+ * @property {boolean} resultsWatchRunning - Flag indicating if the results watch is active.
20
+ * @property {boolean} running - Flag indicating if any part of the filter logic is currently processing.
21
+ * @property {boolean} orderWatchRunning - Flag indicating if the order watch is active.
22
+ */
23
+ /**
24
+ *
25
+ *
26
+ * @typedef {(
27
+ * import('./listInstance.js').ListInstanceRawState &
28
+ * Partial<import('./listSubscription.js').ListSubscriptionRawState> &
29
+ * Partial<import('./listRelated.js').ListRelatedRawState> &
30
+ * Partial<import('./listCalculated.js').ListCalculatedRawState>
31
+ * )} ListFilterParentRawState
32
+ */
33
+ /**
34
+ * The parent state for a list filter.
35
+ *
36
+ * @typedef {import('vue').UnwrapNestedRefs<(
37
+ * ListFilterParentRawState
38
+ * )>} ListFilterParentState
39
+ */
40
+ /**
41
+ * Describes the combined state from various list-related composables that might interact with the list filter.
42
+ *
43
+ * @typedef {import('vue').UnwrapNestedRefs<
44
+ * ListFilterParentRawState &
45
+ * ListFilterRawState
46
+ * >} ListFilterState
47
+ */
48
+ /**
49
+ * Configuration options for initializing a list filter. Includes references to the parent state and filter functions.
50
+ *
51
+ * @typedef {object} ListFilterOptions
52
+ * @property {ListFilterParentState} parentState - The parent state.
53
+ * @property {import('vue').Ref<Function>|Function} [allowedFilter] - A function that returns true if an item should be included, which can be reactive.
54
+ * @property {import('vue').Ref<Function>|Function} [excludedFilter] - A function that returns true if an item should be excluded, which can be reactive.
55
+ */
56
+ /**
57
+ * The properties of a list filter, including its state and associated Vue composition API utilities.
58
+ *
59
+ * @typedef {object} ListFilterProperties
60
+ * @property {ListFilterState} state - The reactive state managing the filter logic and results.
61
+ * @property {ListFilterParentState} parentState - The state of the list being filtered.
62
+ * @property {import('vue').EffectScope} effectScope - Scoped reactivity for this filter instance.
63
+ */
64
+ /**
65
+ * Represents an instance of a list filter, including its state and associated Vue composition API utilities.
66
+ *
67
+ * @typedef {ListFilterProperties} ListFilter
68
+ *
69
+ */
70
+ /**
71
+ * Helper function to create multiple instances of list filters based on provided configurations.
72
+ *
73
+ * @param {{[key: string]: ListFilterOptions}} listFilterArgs - Configuration for each filter instance.
74
+ * @returns {{[key: string]: ListFilter}} An object containing instances of list filters.
75
+ */
76
+ export function useListFilters(listFilterArgs: {
77
+ [key: string]: ListFilterOptions;
78
+ }): {
79
+ [key: string]: ListFilter;
80
+ };
81
+ /**
82
+ * Initializes and manages a list filter instance, setting up reactive states and dependencies
83
+ * to dynamically adjust the visible items based on the provided filter functions.
84
+ *
85
+ * @example
86
+ * ```vue
87
+ * <script setup>
88
+ * import { defineProps, reactive, toRef, computed } from 'vue';
89
+ * import { useListInstance, useListFilter } from '@arrai-innovations/reactive-helpers';
90
+ *
91
+ * const props = defineProps({
92
+ * someListFilter: String
93
+ * });
94
+ *
95
+ * const listInstance = useListInstance({ props });
96
+ * const filterConditions = reactive({
97
+ * allowedFilter: (item) => item.isActive,
98
+ * excludedFilter: (item) => !item.isValid
99
+ * });
100
+ *
101
+ * const listFilter = useListFilter({
102
+ * parentState: listInstance.state,
103
+ * ...filterConditions
104
+ * });
105
+ * // listFilter.state.objectsInOrder now contains the reactive filtered items from listInstance.state.objectsInOrder
106
+ * </script>
107
+ * ```
108
+ *
109
+ * @param {ListFilterOptions} options - The options for the list filter including filters and parent state.
110
+ * @returns {ListFilter} A fully configured list filter instance, providing reactive filtered results.
111
+ */
112
+ export function useListFilter({ parentState, allowedFilter, excludedFilter }: ListFilterOptions): ListFilter;
113
+ export type ObjectsInOrderRefs = import("vue").Ref<import("./listInstance.js").ListObject>[];
114
+ /**
115
+ * - A function that returns true if an item should be included.
116
+ */
117
+ export type ListFilterAllowedFilter = Function;
118
+ /**
119
+ * - A function that returns true if an item should be excluded.
120
+ */
121
+ export type ListFilterExcludedFilter = Function;
122
+ /**
123
+ * Defines the structure of the reactive state used by the list filter. This state includes both filters and
124
+ * the results of applying these filters to a list.
125
+ */
126
+ export type ListFilterRawState = {
127
+ /**
128
+ * - Function to determine if an item should be included based on custom logic.
129
+ */
130
+ allowedFilter?: ListFilterAllowedFilter;
131
+ /**
132
+ * - Function to determine if an item should be excluded based on custom logic.
133
+ */
134
+ excludedFilter?: ListFilterExcludedFilter;
135
+ /**
136
+ * - A map of items to boolean values indicating filter results.
137
+ */
138
+ inResults: object;
139
+ /**
140
+ * - Flag indicating if the object watch is active.
141
+ */
142
+ objectsWatchRunning: boolean;
143
+ /**
144
+ * - Flag indicating if the results watch is active.
145
+ */
146
+ resultsWatchRunning: boolean;
147
+ /**
148
+ * - Flag indicating if any part of the filter logic is currently processing.
149
+ */
150
+ running: boolean;
151
+ /**
152
+ * - Flag indicating if the order watch is active.
153
+ */
154
+ orderWatchRunning: boolean;
155
+ };
156
+ export type ListFilterParentRawState = (import("./listInstance.js").ListInstanceRawState & Partial<import("./listSubscription.js").ListSubscriptionRawState> & Partial<import("./listRelated.js").ListRelatedRawState> & Partial<import("./listCalculated.js").ListCalculatedRawState>);
157
+ /**
158
+ * The parent state for a list filter.
159
+ */
160
+ export type ListFilterParentState = import("vue").UnwrapNestedRefs<(ListFilterParentRawState)>;
161
+ /**
162
+ * Describes the combined state from various list-related composables that might interact with the list filter.
163
+ */
164
+ export type ListFilterState = import("vue").UnwrapNestedRefs<ListFilterParentRawState & ListFilterRawState>;
165
+ /**
166
+ * Configuration options for initializing a list filter. Includes references to the parent state and filter functions.
167
+ */
168
+ export type ListFilterOptions = {
169
+ /**
170
+ * - The parent state.
171
+ */
172
+ parentState: ListFilterParentState;
173
+ /**
174
+ * - A function that returns true if an item should be included, which can be reactive.
175
+ */
176
+ allowedFilter?: import("vue").Ref<Function> | Function;
177
+ /**
178
+ * - A function that returns true if an item should be excluded, which can be reactive.
179
+ */
180
+ excludedFilter?: import("vue").Ref<Function> | Function;
181
+ };
182
+ /**
183
+ * The properties of a list filter, including its state and associated Vue composition API utilities.
184
+ */
185
+ export type ListFilterProperties = {
186
+ /**
187
+ * - The reactive state managing the filter logic and results.
188
+ */
189
+ state: ListFilterState;
190
+ /**
191
+ * - The state of the list being filtered.
192
+ */
193
+ parentState: ListFilterParentState;
194
+ /**
195
+ * - Scoped reactivity for this filter instance.
196
+ */
197
+ effectScope: import("vue").EffectScope;
198
+ };
199
+ /**
200
+ * Represents an instance of a list filter, including its state and associated Vue composition API utilities.
201
+ */
202
+ export type ListFilter = ListFilterProperties;
203
+ //# sourceMappingURL=listFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listFilter.d.ts","sourceRoot":"","sources":["../../use/listFilter.js"],"names":[],"mappings":"AAqCA;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAIH;;;;;GAKG;AAEH;;;;;GAKG;AACH,+CAHW;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAC,GAChC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAC,CASvC;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,8EAHW,iBAAiB,GACf,UAAU,CAiKtB;iCA1SY,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,mBAAmB,EAAE,UAAU,CAAC,EAAE;;;;;;;;;;;;;;;;;oBAgB1D,uBAAuB;;;;qBACvB,wBAAwB;;;;eACxB,MAAM;;;;yBACN,OAAO;;;;yBACP,OAAO;;;;aACP,OAAO;;;;uBACP,OAAO;;uCAMR,CACZ,OAAa,mBAAmB,EAAE,oBAAoB,GAChD,OAAO,CAAC,OAAO,uBAAuB,EAAE,wBAAwB,CAAC,GACjE,OAAO,CAAC,OAAO,kBAAkB,EAAE,mBAAmB,CAAC,GACvD,OAAO,CAAC,OAAO,qBAAqB,EAAE,sBAAsB,CAAC,CAChE;;;;oCAMS,OAAO,KAAK,EAAE,gBAAgB,CAAC,CACrC,wBAAwB,CAC3B,CAAC;;;;8BAMQ,OAAO,KAAK,EAAE,gBAAgB,CACpC,wBAAwB,GACxB,kBAAkB,CACrB;;;;;;;;iBAOU,qBAAqB;;;;oBACrB,OAAO,KAAK,EAAE,GAAG,UAAU,WAAS;;;;qBACpC,OAAO,KAAK,EAAE,GAAG,UAAU,WAAS;;;;;;;;;WAOpC,eAAe;;;;iBACf,qBAAqB;;;;iBACrB,OAAO,KAAK,EAAE,WAAW;;;;;yBAQ1B,oBAAoB"}
@@ -0,0 +1,357 @@
1
+ /**
2
+ * The reactive arguments for the list instance.
3
+ *
4
+ * @typedef {object} ListInstanceProps
5
+ * @property {string} pkKey - The primary key field for the list objects.
6
+ * @property {object} retrieveArgs - The arguments passed to the server.
7
+ * @property {object} listArgs - The arguments passed to the server.
8
+ * @property {object} crudArgs - Implementation specific arguments.
9
+ */
10
+ /**
11
+ * The configuration options used to create a list instance.
12
+ *
13
+ * @typedef {object} ListInstanceOptions
14
+ * @property {import('vue').UnwrapNestedRefs<ListInstanceProps>} props - The props for the list instance.
15
+ * @property {object} [functions] - Default implementation are used as set by `setListCrud`.
16
+ * @property {import('../config/listCrud.js').ListFn} [functions.list] - Provide the implementation for the list
17
+ * function.
18
+ * @property {import('../config/listCrud.js').BulkDeleteFn} [functions.bulkDelete] - Provide the implementation for the bulkDelete
19
+ * function.
20
+ * @property {import('../config/listCrud.js').ExecuteActionFn} [functions.executeAction] - Provide the implementation for the executeAction
21
+ * function.
22
+ * @property {import('../config/listCrud.js').SubscribeFn} [functions.subscribe] - Provide the implementation for the
23
+ * subscribe function.
24
+ * @property {boolean} keepOldPages - If true, pages will not be cleared when defaultPageCallback is called.
25
+ */
26
+ /**
27
+ * The objects by pk.
28
+ *
29
+ * @typedef {{[pk: string]: ListObject}} ObjectsByPk
30
+ */
31
+ /**
32
+ * The objects in order, based on .order & .objects.
33
+ *
34
+ * @typedef {import('vue').ComputedRef<ListObject[]>} ObjectsInOrder
35
+ */
36
+ /**
37
+ * The order of the objects in the list.
38
+ *
39
+ * @typedef {import('vue').ComputedRef<string[]>} ListOrder
40
+ */
41
+ /**
42
+ * The raw state object for the list instance, defining the reactive properties and their types.
43
+ *
44
+ * @typedef {object} ListInstanceRawState
45
+ * @property {object} crud - CRUD functions and their configurations for the list.
46
+ * @property {object} crud.args - Arguments for the CRUD functions.
47
+ * @property {Function} [crud.list] - Function to list objects.
48
+ * @property {string} pkKey - The primary key field for the list objects.
49
+ * @property {object} retrieveArgs - Arguments passed to the server for retrieval operations.
50
+ * @property {object} listArgs - Arguments passed to the server for listing operations.
51
+ * @property {ObjectsByPk} objects - The list objects stored by their pks.
52
+ * @property {boolean} running - Indicates if there are ongoing reactive updates.
53
+ * @property {Readonly<import('vue').Ref<boolean>>} [loading] - Indicates if the list is currently loading.
54
+ * @property {Readonly<import('vue').Ref<boolean>>} errored - Indicates if an error occurred during the last operation.
55
+ * @property {Readonly<import('vue').Ref<Error|null>>} error - The last error encountered.
56
+ * @property {ListOrder} order - The order of objects in the list.
57
+ * @property {ObjectsInOrder} objectsInOrder - The objects in the order specified by the list.
58
+ */
59
+ /**
60
+ * Defines the reactive state used by the list instance.
61
+ *
62
+ * @typedef {import('vue').UnwrapNestedRefs<ListInstanceRawState>} ListInstanceState
63
+ */
64
+ /**
65
+ * Defines the methods provided by the list instance for managing objects in the list.
66
+ *
67
+ * @typedef {object} ListInstanceFunctions
68
+ * @property {(newObjects: ListObject[]) => void} defaultPageCallback - Handles new or updated objects, respecting the keepOldPages setting.
69
+ * @property {(newObjects: ListObject[]) => void} pageCallback - Customizable callback for handling new objects per page.
70
+ * @property {(object: ListObject) => void} addListObject - Adds an object to the list.
71
+ * @property {(object: ListObject) => void} updateListObject - Updates an object in the list.
72
+ * @property {(objectId: string) => void} deleteListObject - Deletes an object from the list by pk.
73
+ * @property {() => void} clearList - Clears all objects and errors from the list.
74
+ * @property {() => string} getFakePk - Generates a unique fake pk for use within the list.
75
+ * @property {() => Promise<boolean>} list - Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
76
+ * @property {() => Promise<boolean>} bulkDelete - Initiates a bulk delete operation on all objects in the list, returning a promise to a boolean indicating success.
77
+ * @property {() => Promise<object|string|false>} executeAction - Initiates an action on all objects in the list, returning the response, or false if the action failed.
78
+ */
79
+ /**
80
+ * Helper type to facilitate the combination of state and functions into a single type.
81
+ *
82
+ * @typedef {{state: ListInstanceState}} ListInstanceStateMixIn
83
+ */
84
+ /**
85
+ * The list instance, combining state management and functional operations for managing a list of objects.
86
+ *
87
+ * @typedef {ListInstanceStateMixIn & ListInstanceFunctions} ListInstance
88
+ */
89
+ /**
90
+ * Creates and manages multiple list instances.
91
+ *
92
+ * @param {{[key: string]: ListInstanceOptions}} listInstanceArgs - The arguments for each list instance.
93
+ * @returns {{[key: string]: ListInstance}} An object of list instances.
94
+ */
95
+ export function useListInstances(listInstanceArgs: {
96
+ [key: string]: ListInstanceOptions;
97
+ }): {
98
+ [key: string]: ListInstance;
99
+ };
100
+ /**
101
+ * Creates and manages a reactive list of objects, providing utilities to add, update, delete, and fetch objects
102
+ * according to the specified CRUD operations.
103
+ *
104
+ * @example
105
+ * ```vue
106
+ * <script setup>
107
+ * import { useListInstance } from "@arrai-innovations/reactive-helpers";
108
+ * import { reactive, toRef } from "vue";
109
+ *
110
+ * const props = defineProps({
111
+ * // whatever props are required for your configured list instance
112
+ * someListFilter: {
113
+ * type: string,
114
+ * default: "",
115
+ * },
116
+ * });
117
+ *
118
+ * const listInstanceProps = reactive({
119
+ * crudArgs: {
120
+ * // whatever arguments are required for your configured list crud function to get the right endpoint
121
+ * },
122
+ * listArgs: {
123
+ * // whatever arguments are required for your configured list function to get the right list
124
+ * someListFilter: toRef(props, "someListFilter"),
125
+ * },
126
+ * retrieveArgs: {
127
+ * // whatever arguments are required for your configured list function to get items back looking as expected
128
+ * },
129
+ * });
130
+ * const listInstance = useListInstance({ props: listInstanceProps });
131
+ * watch(toRef(props, "someListFilter"), (newValue, oldValue) => {
132
+ * if (newValue !== oldValue && !isEmpty(newValue)) {
133
+ * listInstance.list();
134
+ * }
135
+ * }, {
136
+ * immediate: true,
137
+ * deep: true,
138
+ * });
139
+ * </script>
140
+ * <template>
141
+ * <ul>
142
+ * <!-- reactive list of objects, re-retrieving the list as someListFilter changes. -->
143
+ * <li v-for="obj in listInstance.state.objectsInOrder">
144
+ * {{ obj }}
145
+ * </li>
146
+ * </ul>
147
+ * </template>
148
+ * ```
149
+ *
150
+ * @param {ListInstanceOptions} options - Specifies the configuration options for creating a list instance, including
151
+ * properties for CRUD operations and UI behaviors like page persistence.
152
+ * @returns {ListInstance} The list instance.
153
+ * @throws {ListInstanceError} If the props or keepOldPages are missing.
154
+ */
155
+ export function useListInstance({ props, functions, keepOldPages }: ListInstanceOptions): ListInstance;
156
+ /**
157
+ * A composable function for managing a list of objects.
158
+ *
159
+ * @module use/listInstance.js
160
+ */
161
+ /**
162
+ * Defines the structure for the objects stored within the list, each identified by a unique pk and capable of
163
+ * holding various key-value pairs.
164
+ *
165
+ * @typedef {{pk: string, [key: string]: any}} ListObject
166
+ */
167
+ /**
168
+ * Defines a custom error class specific to list instance operations, encapsulating details about errors that occur
169
+ * during list manipulation and processing.
170
+ */
171
+ export class ListInstanceError extends Error {
172
+ /**
173
+ * Creates an instance of ListInstanceError.
174
+ *
175
+ * @param {string} message - The error message.
176
+ * @param {string} code - The error code.
177
+ */
178
+ constructor(message: string, code: string);
179
+ code: string;
180
+ }
181
+ /**
182
+ * The reactive arguments for the list instance.
183
+ */
184
+ export type ListInstanceProps = {
185
+ /**
186
+ * - The primary key field for the list objects.
187
+ */
188
+ pkKey: string;
189
+ /**
190
+ * - The arguments passed to the server.
191
+ */
192
+ retrieveArgs: object;
193
+ /**
194
+ * - The arguments passed to the server.
195
+ */
196
+ listArgs: object;
197
+ /**
198
+ * - Implementation specific arguments.
199
+ */
200
+ crudArgs: object;
201
+ };
202
+ /**
203
+ * The configuration options used to create a list instance.
204
+ */
205
+ export type ListInstanceOptions = {
206
+ /**
207
+ * - The props for the list instance.
208
+ */
209
+ props: import("vue").UnwrapNestedRefs<ListInstanceProps>;
210
+ /**
211
+ * - Default implementation are used as set by `setListCrud`.
212
+ */
213
+ functions?: {
214
+ list?: import("../config/listCrud.js").ListFn;
215
+ bulkDelete?: import("../config/listCrud.js").BulkDeleteFn;
216
+ executeAction?: import("../config/listCrud.js").ExecuteActionFn;
217
+ subscribe?: import("../config/listCrud.js").SubscribeFn;
218
+ };
219
+ /**
220
+ * - If true, pages will not be cleared when defaultPageCallback is called.
221
+ */
222
+ keepOldPages: boolean;
223
+ };
224
+ /**
225
+ * The objects by pk.
226
+ */
227
+ export type ObjectsByPk = {
228
+ [pk: string]: ListObject;
229
+ };
230
+ /**
231
+ * The objects in order, based on .order & .objects.
232
+ */
233
+ export type ObjectsInOrder = import("vue").ComputedRef<ListObject[]>;
234
+ /**
235
+ * The order of the objects in the list.
236
+ */
237
+ export type ListOrder = import("vue").ComputedRef<string[]>;
238
+ /**
239
+ * The raw state object for the list instance, defining the reactive properties and their types.
240
+ */
241
+ export type ListInstanceRawState = {
242
+ /**
243
+ * - CRUD functions and their configurations for the list.
244
+ */
245
+ crud: {
246
+ args: object;
247
+ list?: Function;
248
+ };
249
+ /**
250
+ * - The primary key field for the list objects.
251
+ */
252
+ pkKey: string;
253
+ /**
254
+ * - Arguments passed to the server for retrieval operations.
255
+ */
256
+ retrieveArgs: object;
257
+ /**
258
+ * - Arguments passed to the server for listing operations.
259
+ */
260
+ listArgs: object;
261
+ /**
262
+ * - The list objects stored by their pks.
263
+ */
264
+ objects: ObjectsByPk;
265
+ /**
266
+ * - Indicates if there are ongoing reactive updates.
267
+ */
268
+ running: boolean;
269
+ /**
270
+ * - Indicates if the list is currently loading.
271
+ */
272
+ loading?: Readonly<import("vue").Ref<boolean>>;
273
+ /**
274
+ * - Indicates if an error occurred during the last operation.
275
+ */
276
+ errored: Readonly<import("vue").Ref<boolean>>;
277
+ /**
278
+ * - The last error encountered.
279
+ */
280
+ error: Readonly<import("vue").Ref<Error | null>>;
281
+ /**
282
+ * - The order of objects in the list.
283
+ */
284
+ order: ListOrder;
285
+ /**
286
+ * - The objects in the order specified by the list.
287
+ */
288
+ objectsInOrder: ObjectsInOrder;
289
+ };
290
+ /**
291
+ * Defines the reactive state used by the list instance.
292
+ */
293
+ export type ListInstanceState = import("vue").UnwrapNestedRefs<ListInstanceRawState>;
294
+ /**
295
+ * Defines the methods provided by the list instance for managing objects in the list.
296
+ */
297
+ export type ListInstanceFunctions = {
298
+ /**
299
+ * - Handles new or updated objects, respecting the keepOldPages setting.
300
+ */
301
+ defaultPageCallback: (newObjects: ListObject[]) => void;
302
+ /**
303
+ * - Customizable callback for handling new objects per page.
304
+ */
305
+ pageCallback: (newObjects: ListObject[]) => void;
306
+ /**
307
+ * - Adds an object to the list.
308
+ */
309
+ addListObject: (object: ListObject) => void;
310
+ /**
311
+ * - Updates an object in the list.
312
+ */
313
+ updateListObject: (object: ListObject) => void;
314
+ /**
315
+ * - Deletes an object from the list by pk.
316
+ */
317
+ deleteListObject: (objectId: string) => void;
318
+ /**
319
+ * - Clears all objects and errors from the list.
320
+ */
321
+ clearList: () => void;
322
+ /**
323
+ * - Generates a unique fake pk for use within the list.
324
+ */
325
+ getFakePk: () => string;
326
+ /**
327
+ * - Initiates a fetch to retrieve objects according to the CRUD configuration, returning a promise to a boolean indicating success.
328
+ */
329
+ list: () => Promise<boolean>;
330
+ /**
331
+ * - Initiates a bulk delete operation on all objects in the list, returning a promise to a boolean indicating success.
332
+ */
333
+ bulkDelete: () => Promise<boolean>;
334
+ /**
335
+ * - Initiates an action on all objects in the list, returning the response, or false if the action failed.
336
+ */
337
+ executeAction: () => Promise<object | string | false>;
338
+ };
339
+ /**
340
+ * Helper type to facilitate the combination of state and functions into a single type.
341
+ */
342
+ export type ListInstanceStateMixIn = {
343
+ state: ListInstanceState;
344
+ };
345
+ /**
346
+ * The list instance, combining state management and functional operations for managing a list of objects.
347
+ */
348
+ export type ListInstance = ListInstanceStateMixIn & ListInstanceFunctions;
349
+ /**
350
+ * Defines the structure for the objects stored within the list, each identified by a unique pk and capable of
351
+ * holding various key-value pairs.
352
+ */
353
+ export type ListObject = {
354
+ pk: string;
355
+ [key: string]: any;
356
+ };
357
+ //# sourceMappingURL=listInstance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listInstance.d.ts","sourceRoot":"","sources":["../../use/listInstance.js"],"names":[],"mappings":"AAsCA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AACH,mDAHW;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAAC,GAClC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAC,CASzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,oEALW,mBAAmB,GAEjB,YAAY,CAwTxB;AA5fD;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH;IACI;;;;;OAKG;IACH,qBAHW,MAAM,QACN,MAAM,EAMhB;IADG,aAAgB;CAEvB;;;;;;;;WAMa,MAAM;;;;kBACN,MAAM;;;;cACN,MAAM;;;;cACN,MAAM;;;;;;;;;WAON,OAAO,KAAK,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;;;;gBAE5D;QAA8D,IAAI,GAAvD,OAAO,uBAAuB,EAAE,MAAM;QAEoB,UAAU,GAAnE,OAAO,uBAAuB,EAAE,YAAY;QAEiB,aAAa,GAAzE,OAAO,uBAAuB,EAAE,eAAe;QAEO,SAAS,GAAjE,OAAO,uBAAuB,EAAE,WAAW;KAEtD;;;;kBAAW,OAAO;;;;;0BAMR;IAAC,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAA;CAAC;;;;6BAM1B,OAAO,KAAK,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC;;;;wBAMvC,OAAO,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;;;;;;;;UAQ7C;QAAwB,IAAI,EAAjB,MAAM;QACU,IAAI;KAC/B;;;;WAAW,MAAM;;;;kBACN,MAAM;;;;cACN,MAAM;;;;aACN,WAAW;;;;aACX,OAAO;;;;cACP,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;aACpC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;WACpC,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,KAAK,GAAC,IAAI,CAAC,CAAC;;;;WACvC,SAAS;;;;oBACT,cAAc;;;;;gCAMf,OAAO,KAAK,EAAE,gBAAgB,CAAC,oBAAoB,CAAC;;;;;;;;yBAOnD,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,IAAI;;;;kBAClC,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,IAAI;;;;mBAClC,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;;;;sBAC5B,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;;;;sBAC5B,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI;;;;eAC1B,MAAM,IAAI;;;;eACV,MAAM,MAAM;;;;UACZ,MAAM,OAAO,CAAC,OAAO,CAAC;;;;gBACtB,MAAM,OAAO,CAAC,OAAO,CAAC;;;;mBACtB,MAAM,OAAO,CAAC,MAAM,GAAC,MAAM,GAAC,KAAK,CAAC;;;;;qCAMnC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAC;;;;2BAM1B,sBAAsB,GAAG,qBAAqB;;;;;yBApH9C;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC"}
@@ -0,0 +1,15 @@
1
+ export const listInstanceStateKeys: string[];
2
+ export const listInstanceFunctions: string[];
3
+ export const listSubscriptionStateKeys: string[];
4
+ export const listSubscriptionFunctions: string[];
5
+ export const listRelatedStateKeys: string[];
6
+ export const listRelatedFunctions: any[];
7
+ export const listCalculatedStateKeys: string[];
8
+ export const listCalculatedFunctions: any[];
9
+ export const listFilterStateKeys: string[];
10
+ export const listFilterFunctions: any[];
11
+ export const listSearchStateKeys: string[];
12
+ export const listSearchFunctions: any[];
13
+ export const listSortStateKeys: string[];
14
+ export const listSortFunctions: any[];
15
+ //# sourceMappingURL=listKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listKeys.d.ts","sourceRoot":"","sources":["../../use/listKeys.js"],"names":[],"mappings":"AAAA,6CAiBE;AACF,6CAYE;AAEF,iDAOE;AACF,iDAAoF;AAEpF,4CAQE;AACF,yCAAuC;AAEvC,+CAME;AACF,4CAA0C;AAE1C,2CAWE;AACF,wCAAsC;AAEtC,2CAcE;AACF,wCAAsC;AACtC,yCAWE;AACF,sCAAoC"}