@arrai-innovations/reactive-helpers 21.1.0 → 22.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 (68) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +109 -21
  3. package/config/commonCrud.js +4 -6
  4. package/config/listCrud.js +20 -22
  5. package/config/objectCrud.js +30 -37
  6. package/package.json +93 -89
  7. package/types/config/listCrud.d.ts +83 -26
  8. package/types/config/objectCrud.d.ts +123 -44
  9. package/types/use/cancellableIntent.d.ts +27 -31
  10. package/types/use/combineClasses.d.ts +4 -1
  11. package/types/use/error.d.ts +39 -19
  12. package/types/use/list.d.ts +27 -26
  13. package/types/use/listCalculated.d.ts +21 -39
  14. package/types/use/listFilter.d.ts +25 -33
  15. package/types/use/listInstance.d.ts +88 -80
  16. package/types/use/listRelated.d.ts +26 -46
  17. package/types/use/listSearch.d.ts +54 -52
  18. package/types/use/listSort.d.ts +25 -39
  19. package/types/use/listSubscription.d.ts +28 -35
  20. package/types/use/loading.d.ts +20 -10
  21. package/types/use/loadingError.d.ts +12 -3
  22. package/types/use/object.d.ts +8 -5
  23. package/types/use/objectCalculated.d.ts +30 -27
  24. package/types/use/objectInstance.d.ts +67 -73
  25. package/types/use/objectRelated.d.ts +41 -33
  26. package/types/use/objectSubscription.d.ts +32 -43
  27. package/types/use/proxyError.d.ts +15 -6
  28. package/types/use/proxyLoading.d.ts +11 -5
  29. package/types/use/proxyLoadingError.d.ts +19 -7
  30. package/types/use/search.d.ts +33 -29
  31. package/types/utils/assignReactiveObject.d.ts +3 -0
  32. package/types/utils/cancellablePromise.d.ts +5 -5
  33. package/types/utils/classes.d.ts +7 -1
  34. package/types/utils/deepUnref.d.ts +1 -1
  35. package/types/utils/isReactiveTyped.d.ts +2 -0
  36. package/types/utils/keyDiff.d.ts +4 -6
  37. package/types/utils/relatedCalculatedHelpers.d.ts +2 -0
  38. package/types/utils/watches.d.ts +1 -1
  39. package/use/cancellableIntent.js +27 -7
  40. package/use/combineClasses.js +1 -1
  41. package/use/error.js +10 -14
  42. package/use/list.js +6 -18
  43. package/use/listCalculated.js +7 -22
  44. package/use/listFilter.js +8 -21
  45. package/use/listInstance.js +25 -44
  46. package/use/listRelated.js +9 -28
  47. package/use/listSearch.js +8 -17
  48. package/use/listSort.js +27 -41
  49. package/use/listSubscription.js +10 -25
  50. package/use/loading.js +5 -7
  51. package/use/loadingError.js +3 -3
  52. package/use/object.js +7 -19
  53. package/use/objectCalculated.js +9 -15
  54. package/use/objectInstance.js +46 -47
  55. package/use/objectRelated.js +13 -20
  56. package/use/objectSubscription.js +11 -25
  57. package/use/proxyError.js +10 -10
  58. package/use/proxyLoading.js +5 -5
  59. package/use/proxyLoadingError.js +10 -8
  60. package/use/search.js +5 -11
  61. package/utils/assignReactiveObject.js +3 -3
  62. package/utils/cancellableFetch.js +21 -1
  63. package/utils/cancellablePromise.js +4 -4
  64. package/utils/classes.js +2 -2
  65. package/utils/deepUnref.js +1 -5
  66. package/utils/isReactiveTyped.js +2 -0
  67. package/utils/keyDiff.js +1 -3
  68. package/utils/relatedCalculatedHelpers.js +2 -0
package/package.json CHANGED
@@ -1,91 +1,95 @@
1
1
  {
2
- "name": "@arrai-innovations/reactive-helpers",
3
- "version": "21.1.0",
4
- "description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
5
- "main": "index.js",
6
- "type": "module",
7
- "types": "types/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./index.js",
11
- "types": "./types/index.d.ts"
12
- }
13
- },
14
- "files": [
15
- "index.js",
16
- "README.md",
17
- "use/",
18
- "utils/",
19
- "config/",
20
- "types/"
21
- ],
22
- "directories": {
23
- "use": "use",
24
- "utils": "utils",
25
- "tests": "tests"
26
- },
27
- "scripts": {
28
- "test": "npx --no-install vitest",
29
- "eslint": "npx --no-install eslint --fix index.js config/**/*.js tests/**/*.js use/**/*.js utils/**/*.js",
30
- "prettier": "npx --no-install prettier --write .",
31
- "coverage": "npm test -- run --coverage=true",
32
- "prepare": "npx --no-install husky",
33
- "docs": "node make_type_doc.js",
34
- "docs:check": "node check_type_doc.js",
35
- "docs:clean": "node clean_type_doc.js",
36
- "types": "node make_types.js",
37
- "types:check": "node check_types.js"
38
- },
39
- "repository": {
40
- "type": "git",
41
- "url": "git+https://github.com/arrai-innovations/reactive-helpers.git"
42
- },
43
- "author": "Arrai Innovations Inc. <developers@arrai.com>",
44
- "license": "UNLICENSED",
45
- "bugs": {
46
- "url": "https://github.com/arrai-innovations/reactive-helpers/issues"
47
- },
48
- "homepage": "https://github.com/arrai-innovations/reactive-helpers#readme",
49
- "devDependencies": {
50
- "@arrai-innovations/commitlint-config": "^2.0.0",
51
- "@commitlint/cli": "^19.4.0",
52
- "@godaddy/dmd": "^1.0.4",
53
- "@trivago/prettier-plugin-sort-imports": "^5.2.1",
54
- "@types/browser-util-inspect": "^0.2.4",
55
- "@types/lodash-es": "^4.17.12",
56
- "@typescript-eslint/eslint-plugin": "^7.18.0",
57
- "@typescript-eslint/parser": "^7.18.0",
58
- "@vitest/coverage-istanbul": "^3.1.4",
59
- "@vitest/coverage-v8": "^3.1.4",
60
- "@vue/compiler-sfc": "^3.4.37",
61
- "@vue/eslint-config-prettier": "^9.0.0",
62
- "@vue/test-utils": "^2.3.2",
63
- "doctoc": "^2.1.0",
64
- "eslint": "^8.56.0",
65
- "eslint-plugin-jsdoc": "^48.11.0",
66
- "eslint-plugin-vitest": "~0.5.4",
67
- "eslint-plugin-vitest-globals": "^1.3.1",
68
- "eslint-plugin-vue": "^9.27.0",
69
- "flush-promises": "^1.0.2",
70
- "globals": "^16.0.0",
71
- "husky": "^9.1.7",
72
- "jsdom": "^26.0.0",
73
- "lint-staged": "^15.2.8",
74
- "prettier": "^3.3.3",
75
- "typedoc": "^0.28.15",
76
- "typedoc-plugin-markdown": "^4.9.0",
77
- "typescript": "^5.5.4",
78
- "vitest": "^3.1.2"
79
- },
80
- "dependencies": {
81
- "@jcoreio/async-throttle": "^1.6.0",
82
- "browser-util-inspect": "^0.2.0",
83
- "flexsearch": "0.7.21",
84
- "vue-deepunref": "^1.0.1"
85
- },
86
- "peerDependencies": {
87
- "@vueuse/core": "^13.0.0",
88
- "lodash-es": "^4.17.21",
89
- "vue": "^3.5.13"
2
+ "name": "@arrai-innovations/reactive-helpers",
3
+ "version": "22.0.0",
4
+ "description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "types": "types/index.d.ts",
8
+ "publishConfig": {
9
+ "registry": "https://registry.npmjs.org/",
10
+ "access": "public"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./index.js",
15
+ "types": "./types/index.d.ts"
90
16
  }
91
- }
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "README.md",
21
+ "use/",
22
+ "utils/",
23
+ "config/",
24
+ "types/"
25
+ ],
26
+ "directories": {
27
+ "use": "use",
28
+ "utils": "utils",
29
+ "tests": "tests"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/arrai-innovations/reactive-helpers.git"
34
+ },
35
+ "author": "Arrai Innovations Inc. <developers@arrai.com>",
36
+ "license": "BSD-3-Clause",
37
+ "bugs": {
38
+ "url": "https://github.com/arrai-innovations/reactive-helpers/issues"
39
+ },
40
+ "homepage": "https://github.com/arrai-innovations/reactive-helpers#readme",
41
+ "devDependencies": {
42
+ "@arrai-innovations/commitlint-config": "^2.1.0",
43
+ "@commitlint/cli": "^19.8.1",
44
+ "@eslint/js": "9.39.4",
45
+ "@godaddy/dmd": "^1.0.4",
46
+ "@trivago/prettier-plugin-sort-imports": "^5.2.2",
47
+ "@types/browser-util-inspect": "^0.2.4",
48
+ "@types/lodash-es": "^4.17.12",
49
+ "@vitest/coverage-istanbul": "^4.1.9",
50
+ "@vitest/coverage-v8": "^4.1.9",
51
+ "@vitest/eslint-plugin": "^1.6.20",
52
+ "@vue/compiler-sfc": "^3.5.38",
53
+ "@vue/eslint-config-prettier": "^10.2.0",
54
+ "@vue/test-utils": "^2.4.11",
55
+ "doctoc": "^2.5.0",
56
+ "eslint": "^9.39.4",
57
+ "eslint-config-prettier": "^10.1.8",
58
+ "eslint-plugin-jsdoc": "^63.0.6",
59
+ "eslint-plugin-no-autofix": "^2.1.0",
60
+ "eslint-plugin-vue": "^10.9.2",
61
+ "flush-promises": "^1.0.2",
62
+ "globals": "^16.5.0",
63
+ "jsdom": "^26.1.0",
64
+ "lefthook": "^1.13.6",
65
+ "prettier": "^3.8.4",
66
+ "typedoc": "^0.28.19",
67
+ "typedoc-plugin-markdown": "^4.12.0",
68
+ "typescript": "^5.9.3",
69
+ "vite": "^8.0.16",
70
+ "vitest": "^4.1.9",
71
+ "vue-eslint-parser": "^10.4.1"
72
+ },
73
+ "dependencies": {
74
+ "@jcoreio/async-throttle": "^1.7.0",
75
+ "browser-util-inspect": "^0.2.0",
76
+ "flexsearch": "0.7.21",
77
+ "vue-deepunref": "^1.0.1"
78
+ },
79
+ "peerDependencies": {
80
+ "@vueuse/core": "^13.0.0",
81
+ "lodash-es": "^4.17.23",
82
+ "vue": "^3.5.13"
83
+ },
84
+ "scripts": {
85
+ "test": "vitest",
86
+ "eslint": "eslint --fix index.js config/**/*.js tests/**/*.js use/**/*.js utils/**/*.js",
87
+ "prettier": "prettier --write .",
88
+ "coverage": "vitest run --coverage=true",
89
+ "docs": "node make_type_doc.js",
90
+ "docs:check": "node check_type_doc.js",
91
+ "docs:clean": "node clean_type_doc.js",
92
+ "types": "node make_types.js",
93
+ "types:check": "node check_types.js"
94
+ }
95
+ }
@@ -9,8 +9,17 @@ export function getListCrud(target: import("vue").UnwrapNestedRefs<ListCrudHandl
9
9
  props?: import("vue").UnwrapNestedRefs<ListTargetOption>;
10
10
  handlers?: ListCrudHandlers;
11
11
  }): void;
12
+ /**
13
+ * Signature for the handler that clears the objects held by the list.
14
+ */
12
15
  export type ClearObjectsFn = import("../use/listInstance.js").ClearListFn;
16
+ /**
17
+ * Signature for the handler that updates the list's pagination information.
18
+ */
13
19
  export type SetPaginateInfo = import("../use/listInstance.js").SetPaginateInfoFn;
20
+ /**
21
+ * Signature for the handler that updates the list's column totals.
22
+ */
14
23
  export type SetColumnTotals = import("../use/listInstance.js").SetColumnTotalsFn;
15
24
  /**
16
25
  * Additional arguments that can be passed to list crud handlers.
@@ -18,132 +27,180 @@ export type SetColumnTotals = import("../use/listInstance.js").SetColumnTotalsFn
18
27
  export type AdditionalListArgs = {
19
28
  [key: string]: any;
20
29
  };
30
+ /**
31
+ * Raw arguments for a list operation before run-tracking and additional list CRUD arguments are merged in.
32
+ */
21
33
  export type ListArgsRaw = {
22
34
  /**
23
- * - The arguments to be passed to the crud handlers.
35
+ * The arguments to be passed to the crud handlers.
24
36
  */
25
37
  target: import("../config/objectCrud.js").TargetArgs;
26
38
  /**
27
- * - The key name of the primary key.
39
+ * The key name of the primary key.
28
40
  */
29
41
  pkKey: string;
30
42
  /**
31
- * - The arguments to be passed for list crud handlers.
43
+ * The arguments to be passed for list crud handlers.
32
44
  */
33
45
  params: object;
34
46
  /**
35
- * - The method to call with new page(s) of data received.
47
+ * The method to call with new page(s) of data received.
36
48
  */
37
49
  pushObjects: import("../use/listInstance.js").PushObjectsFn;
38
50
  /**
39
- * - The method to call to clear the objects.
51
+ * The method to call to clear the objects.
40
52
  */
41
53
  clearObjects: ClearObjectsFn;
42
54
  /**
43
- * - A ref to a boolean indicating whether the request has
55
+ * A ref to a boolean indicating whether the request has
44
56
  * been cancelled.
45
57
  */
46
58
  isCancelled: Readonly<import("vue").Ref<boolean>>;
47
59
  /**
48
- * - The method to update pagination information.
60
+ * The method to update pagination information.
49
61
  */
50
62
  setPaginateInfo: SetPaginateInfo;
51
63
  /**
52
- * - The method to update column totals.
64
+ * The method to update column totals.
53
65
  */
54
66
  setColumnTotals: SetColumnTotals;
55
67
  };
68
+ /**
69
+ * Arguments for a list operation, combining the raw arguments with run-tracking and any additional list CRUD arguments.
70
+ */
56
71
  export type ListArgs = ListArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking> & AdditionalListArgs;
72
+ /**
73
+ * Raw arguments for a bulk-delete operation before additional list CRUD arguments are merged in.
74
+ */
57
75
  export type BulkDeleteArgsRaw = {
58
76
  /**
59
- * - The arguments to be passed to the crud handlers.
77
+ * The arguments to be passed to the crud handlers.
60
78
  */
61
79
  target: import("../config/objectCrud.js").TargetArgs;
62
80
  /**
63
- * - The ids of the objects to be deleted.
81
+ * The ids of the objects to be deleted.
64
82
  */
65
83
  pks: import("./commonCrud.js").Pk[];
66
84
  /**
67
- * - The key name of the primary key.
85
+ * The key name of the primary key.
68
86
  */
69
87
  pkKey: string;
70
88
  };
89
+ /**
90
+ * Arguments for a bulk-delete operation, combining the raw arguments with any additional list CRUD arguments.
91
+ */
71
92
  export type BulkDeleteArgs = BulkDeleteArgsRaw & AdditionalListArgs;
93
+ /**
94
+ * Callback that applies a created, updated, or deleted object event received from a subscription to the list.
95
+ */
72
96
  export type applyObjectEvent = (newOrUpdatedOrDeleteObject: import("../use/objectInstance.js").ExistingCrudObject | string, action: "create" | "update" | "delete") => void;
97
+ /**
98
+ * Raw arguments for a list subscribe operation before run-tracking and additional list CRUD arguments are merged in.
99
+ */
73
100
  export type ListSubscribeArgsRaw = {
74
101
  /**
75
- * - The arguments to be passed to the crud handlers.
102
+ * The arguments to be passed to the crud handlers.
76
103
  */
77
104
  target: import("../config/objectCrud.js").TargetArgs;
78
105
  /**
79
- * - The key name of the primary key.
106
+ * The key name of the primary key.
80
107
  */
81
108
  pkKey: string;
82
109
  /**
83
- * - The arguments to be passed for list crud handlers.
110
+ * The arguments to be passed for list crud handlers.
84
111
  */
85
112
  params: object;
86
113
  /**
87
- * - The method to call when new data is received.
114
+ * The method to call when new data is received.
88
115
  */
89
116
  applyObjectEvent: applyObjectEvent;
90
117
  /**
91
- * - A ref to a boolean indicating whether the request has
118
+ * A ref to a boolean indicating whether the request has
92
119
  * been cancelled.
93
120
  */
94
121
  isCancelled: Readonly<import("vue").Ref<boolean>>;
95
122
  };
123
+ /**
124
+ * Arguments for a list subscribe operation, combining the raw arguments with run-tracking and any additional list CRUD arguments.
125
+ */
96
126
  export type ListSubscribeArgs = ListSubscribeArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking> & AdditionalListArgs;
127
+ /**
128
+ * Raw arguments for a list execute-action operation before additional list CRUD arguments are merged in.
129
+ */
97
130
  export type ExecuteActionArgsRaw = {
98
131
  /**
99
- * - The arguments to be passed to the crud handlers.
132
+ * The arguments to be passed to the crud handlers.
100
133
  */
101
134
  target: import("../config/objectCrud.js").TargetArgs;
102
135
  /**
103
- * - The ids of the objects to be acted upon.
136
+ * The ids of the objects to be acted upon.
104
137
  */
105
138
  pks: import("./commonCrud.js").Pk[];
106
139
  /**
107
- * - The key name of the primary key.
140
+ * The key name of the primary key.
108
141
  */
109
142
  pkKey: string;
110
143
  /**
111
- * - The action to execute.
144
+ * The action to execute.
112
145
  */
113
146
  action: string;
114
147
  };
148
+ /**
149
+ * Arguments for a list execute-action operation, combining the raw arguments with any additional list CRUD arguments.
150
+ */
115
151
  export type ExecuteActionArgs = ExecuteActionArgsRaw & AdditionalListArgs;
152
+ /**
153
+ * Signature for the handler that lists objects from the backing store.
154
+ */
116
155
  export type CrudListFn = (args: ListArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
156
+ /**
157
+ * Signature for the handler that bulk-deletes objects from the backing store.
158
+ */
117
159
  export type CrudBulkDeleteFn = (args: BulkDeleteArgs) => Promise<boolean>;
160
+ /**
161
+ * Signature for the handler that subscribes to list changes in the backing store.
162
+ */
118
163
  export type CrudListSubscribeFn = (args: ListSubscribeArgs) => import("../utils/cancellablePromise.js").CancellablePromise<void>;
164
+ /**
165
+ * Signature for the handler that executes an action on a list of objects in the backing store.
166
+ */
119
167
  export type CrudExecuteActionFn = (args: ExecuteActionArgs) => Promise<object | string | null>;
168
+ /**
169
+ * The set of optional CRUD handler functions (list, bulkDelete, executeAction, subscribe) for a list.
170
+ */
120
171
  export type ListCrudHandlers = {
121
172
  /**
122
- * - The list function to get a list of items.
173
+ * The list function to get a list of items.
123
174
  */
124
175
  list?: CrudListFn;
125
176
  /**
126
- * - The delete function to bulk delete a list of items.
177
+ * The delete function to bulk delete a list of items.
127
178
  */
128
179
  bulkDelete?: CrudBulkDeleteFn;
129
180
  /**
130
- * - The function to execute a certain action on a list of items.
181
+ * The function to execute a certain action on a list of items.
131
182
  */
132
183
  executeAction?: CrudExecuteActionFn;
133
184
  /**
134
- * - The subscribe function to get a subscription to a list of items.
185
+ * The subscribe function to get a subscription to a list of items.
135
186
  */
136
187
  subscribe?: CrudListSubscribeFn;
137
188
  };
189
+ /**
190
+ * The default target arguments passed through to the list CRUD handlers.
191
+ */
138
192
  export type ListTarget = {
139
193
  /**
140
- * - The default arguments for the crud handlers.
194
+ * The default arguments for the crud handlers.
141
195
  */
142
196
  args: object;
143
197
  };
198
+ /**
199
+ * Optional target arguments passed through to the list CRUD handlers.
200
+ */
144
201
  export type ListTargetOption = {
145
202
  /**
146
- * - The default arguments for the crud handlers.
203
+ * The default arguments for the crud handlers.
147
204
  */
148
205
  target?: object;
149
206
  };