@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
@@ -1,64 +0,0 @@
1
- import { useProxyLoadingError } from "../../../use/proxyLoadingError.js";
2
- import { ref } from "vue";
3
- import { describe, it, expect } from "vitest";
4
-
5
- describe("useProxyLoadingError", () => {
6
- let loadingError1, loadingError2;
7
-
8
- beforeEach(() => {
9
- loadingError1 = {
10
- loading: ref(false),
11
- error: ref(null),
12
- errored: ref(false),
13
- clearError: vi.fn(),
14
- };
15
- loadingError2 = {
16
- loading: ref(false),
17
- error: ref(null),
18
- errored: ref(false),
19
- clearError: vi.fn(),
20
- };
21
- });
22
-
23
- it("should initialize with default states when no errors", () => {
24
- const proxyLoadingError = useProxyLoadingError([loadingError1, loadingError2]);
25
- expect(proxyLoadingError.loading.value).toBe(false);
26
- expect(proxyLoadingError.error.value).toBe(null);
27
- expect(proxyLoadingError.errored.value).toBe(false);
28
- });
29
-
30
- it("should reflect loading state when one source is loading", () => {
31
- loadingError1.loading.value = true;
32
- const proxyLoadingError = useProxyLoadingError([loadingError1, loadingError2]);
33
- expect(proxyLoadingError.loading.value).toBe(true);
34
- });
35
-
36
- it("should reflect error state when one source has an error", () => {
37
- const error = new Error("Test Error");
38
- loadingError2.error.value = error;
39
- loadingError2.errored.value = true;
40
- const proxyLoadingError = useProxyLoadingError([loadingError1, loadingError2]);
41
- expect(proxyLoadingError.error.value).toBe(error);
42
- expect(proxyLoadingError.errored.value).toBe(true);
43
- });
44
-
45
- it("should clear all errors when clearError is called", () => {
46
- const proxyLoadingError = useProxyLoadingError([loadingError1, loadingError2]);
47
- proxyLoadingError.clearError();
48
- expect(loadingError1.clearError).toHaveBeenCalled();
49
- expect(loadingError2.clearError).toHaveBeenCalled();
50
- });
51
-
52
- it("should reflect correct aggregate state when combining multiple sources", () => {
53
- loadingError1.loading.value = true;
54
- loadingError2.errored.value = true;
55
- const error = new Error("Another Error");
56
- loadingError2.error.value = error;
57
-
58
- const proxyLoadingError = useProxyLoadingError([loadingError1, loadingError2]);
59
-
60
- expect(proxyLoadingError.loading.value).toBe(true); // One source is loading
61
- expect(proxyLoadingError.errored.value).toBe(true); // One source has an error
62
- expect(proxyLoadingError.error.value).toBe(error); // Error is aggregated
63
- });
64
- });
@@ -1,248 +0,0 @@
1
- import { doAwaitNot } from "../../../utils/watches.js";
2
- import { reactive } from "vue";
3
-
4
- describe("use/search", () => {
5
- let useSearch;
6
- beforeEach(async () => {
7
- const searchModule = await import("../../../use/search.js");
8
- useSearch = searchModule.useSearch;
9
- });
10
- it("should allow adding items to the index", async () => {
11
- const search = useSearch({
12
- props: reactive({
13
- customDocumentOptions: {
14
- tokenize: "forward",
15
- document: {
16
- index: ["field1", "field2"],
17
- },
18
- },
19
- pkKey: "notId",
20
- }),
21
- throttle: 50,
22
- });
23
- search.addIndex({
24
- notId: 1,
25
- field1: "test index value field1 one",
26
- field2: "test index value field2 one",
27
- });
28
- search.addIndex({
29
- notId: 2,
30
- field1: "test index value field1 two",
31
- field2: "test index value field2 two",
32
- });
33
- search.addIndex({
34
- notId: 3,
35
- field1: "test index value field1 three",
36
- field2: "test index value field2 three",
37
- });
38
- await doAwaitNot({
39
- obj: search.state,
40
- prop: "running",
41
- });
42
- expect(Object.keys(search.state.results)).toEqual([]);
43
- search.state.search = "test";
44
- await doAwaitNot({
45
- obj: search.state,
46
- prop: "running",
47
- });
48
- expect(Object.keys(search.state.results)).toEqual(["1", "2", "3"]);
49
- });
50
- it("should allow removing items from the index", async () => {
51
- const search = useSearch({
52
- props: reactive({
53
- customDocumentOptions: {
54
- tokenize: "forward",
55
- document: {
56
- index: ["field1", "field2"],
57
- },
58
- },
59
- pkKey: "notPk",
60
- }),
61
- throttle: 50,
62
- });
63
- search.addIndex({
64
- notPk: 1,
65
- field1: "test index value field1 one",
66
- field2: "test index value field2 one",
67
- });
68
- search.addIndex({
69
- notPk: 2,
70
- field1: "test index value field1 two",
71
- field2: "test index value field2 two",
72
- });
73
- search.addIndex({
74
- notPk: 3,
75
- field1: "test index value field1 three",
76
- field2: "test index value field2 three",
77
- });
78
- search.state.search = "test";
79
- await doAwaitNot({
80
- obj: search.state,
81
- prop: "running",
82
- });
83
-
84
- expect(Object.keys(search.state.results)).toEqual(["1", "2", "3"]);
85
- search.removeIndex(2);
86
- await doAwaitNot({
87
- obj: search.state,
88
- prop: "running",
89
- });
90
- expect(Object.keys(search.state.results)).toEqual(["1", "3"]);
91
- });
92
- it("should allow updating items in the index", async () => {
93
- const search = useSearch({
94
- props: reactive({
95
- customDocumentOptions: {
96
- tokenize: "forward",
97
- document: {
98
- index: ["field1", "field2"],
99
- },
100
- },
101
- pkKey: "id",
102
- }),
103
- throttle: 50,
104
- });
105
- search.addIndex({
106
- id: 1,
107
- field1: "test index value field1 one",
108
- field2: "test index value field2 one",
109
- });
110
- search.addIndex({
111
- id: 2,
112
- field1: "test index value field1 two",
113
- field2: "test index value field2 two",
114
- });
115
- search.addIndex({
116
- id: 3,
117
- field1: "test index value field1 three",
118
- field2: "test index value field2 three",
119
- });
120
- search.state.search = "test";
121
- await doAwaitNot({
122
- obj: search.state,
123
- prop: "running",
124
- });
125
- expect(Object.keys(search.state.results)).toEqual(["1", "2", "3"]);
126
- search.updateIndex({
127
- id: 2,
128
- field1: "twest index value field1 two updated",
129
- field2: "twest index value field2 two updated",
130
- });
131
- await doAwaitNot({
132
- obj: search.state,
133
- prop: "running",
134
- });
135
- expect(Object.keys(search.state.results)).toEqual(["1", "3"]);
136
- search.state.search = "two";
137
- await doAwaitNot({
138
- obj: search.state,
139
- prop: "running",
140
- });
141
- expect(Object.keys(search.state.results)).toEqual(["2"]);
142
- });
143
- it("should allow clearing all items from the index", async () => {
144
- const search = useSearch({
145
- props: reactive({
146
- customDocumentOptions: {
147
- tokenize: "forward",
148
- document: {
149
- index: ["field1", "field2"],
150
- },
151
- },
152
- pkKey: "id",
153
- }),
154
- throttle: 50,
155
- });
156
- search.addIndex({
157
- id: 1,
158
- field1: "test index value field1 one",
159
- field2: "test index value field2 one",
160
- });
161
- search.addIndex({
162
- id: 2,
163
- field1: "test index value field1 two",
164
- field2: "test index value field2 two",
165
- });
166
- search.addIndex({
167
- id: 3,
168
- field1: "test index value field1 three",
169
- field2: "test index value field2 three",
170
- });
171
- search.state.search = "test";
172
- await doAwaitNot({
173
- obj: search.state,
174
- prop: "running",
175
- });
176
- expect(Object.keys(search.state.results)).toEqual(["1", "2", "3"]);
177
- search.clearIndex();
178
- expect(Object.keys(search.state.results)).toEqual([]);
179
- });
180
- it("should allow changing the index fields", async () => {
181
- const searchProps = reactive({
182
- customDocumentOptions: {
183
- tokenize: "forward",
184
- document: {
185
- index: ["field1", "field2"],
186
- },
187
- },
188
- pkKey: "id",
189
- });
190
- const search = useSearch({
191
- props: searchProps,
192
- throttle: 50,
193
- });
194
- search.addIndex({
195
- id: 1,
196
- field1: "test index value field1 one",
197
- field2: "test index value field2 one",
198
- });
199
- search.addIndex({
200
- id: 2,
201
- field1: "test index value field1 two",
202
- field2: "test index value field2 two",
203
- });
204
- search.addIndex({
205
- id: 3,
206
- field1: "test index value field1 three",
207
- field2: "test index value field2 three",
208
- });
209
- search.state.search = "field2";
210
- await doAwaitNot({
211
- obj: search.state,
212
- prop: "running",
213
- });
214
- expect(Object.keys(search.state.results)).toEqual(["1", "2", "3"]);
215
- // implied clearIndex
216
- searchProps.customDocumentOptions.document.index = ["field1"];
217
- // indexes cannot be added until search.events newIndex is fired
218
- let eventResolve = null;
219
- const eventPromise = new Promise((resolve) => {
220
- eventResolve = resolve;
221
- });
222
- search.events.addEventListener("newIndex", eventResolve);
223
- await eventPromise;
224
- search.addIndex({
225
- id: 1,
226
- field1: "test index value field1 one",
227
- });
228
- search.addIndex({
229
- id: 2,
230
- field1: "test index value field1 two",
231
- });
232
- search.addIndex({
233
- id: 3,
234
- field1: "test index value field1 three",
235
- });
236
- await doAwaitNot({
237
- obj: search.state,
238
- prop: "running",
239
- });
240
- expect(Object.keys(search.state.results)).toEqual([]);
241
- search.state.search = "field1";
242
- await doAwaitNot({
243
- obj: search.state,
244
- prop: "running",
245
- });
246
- expect(Object.keys(search.state.results)).toEqual(["1", "2", "3"]);
247
- });
248
- });