@arrai-innovations/reactive-helpers 21.1.2 → 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 (67) 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/cancellablePromise.js +4 -4
  63. package/utils/classes.js +2 -2
  64. package/utils/deepUnref.js +1 -5
  65. package/utils/isReactiveTyped.js +2 -0
  66. package/utils/keyDiff.js +1 -3
  67. package/utils/relatedCalculatedHelpers.js +2 -0
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2021-2026, Arrai Innovations Inc.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,57 +1,141 @@
1
1
  # reactive-helpers
2
2
 
3
- ![Tests for 14.x](https://docs.arrai-dev.com/reactive-helpers/artifacts/main/tests.svg)
4
- [![Coverage for 14.x](https://docs.arrai-dev.com/reactive-helpers/artifacts/main/tests.coverage.svg)](https://docs.arrai-dev.com/reactive-helpers/artifacts/main/coverage_tests/)
5
- ![ESLint](https://docs.arrai-dev.com/reactive-helpers/artifacts/main/eslint.svg)
6
- ![Prettier](https://docs.arrai-dev.com/reactive-helpers/artifacts/main/prettier.svg)
7
- ![Audit](https://docs.arrai.dev/reactive-helpers/artifacts/main/npm-audit.svg)
3
+ ![Tests](https://docs.arrai.dev/reactive-helpers/artifacts/main/tests.svg)
4
+ [![Coverage](https://docs.arrai.dev/reactive-helpers/artifacts/main/tests.coverage.svg)](https://docs.arrai.dev/reactive-helpers/artifacts/main/coverage_tests/)
5
+ ![ESLint](https://docs.arrai.dev/reactive-helpers/artifacts/main/eslint.svg)
6
+ ![Prettier](https://docs.arrai.dev/reactive-helpers/artifacts/main/prettier.svg)
7
+ ![Audit](https://docs.arrai.dev/reactive-helpers/artifacts/main/pnpm-audit.svg)
8
+ [![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD--3--Clause-blue.svg?style=for-the-badge)](./LICENSE)
8
9
 
9
- Vue.js 3 composition utilities to manage reactive lists, objects and other helpers.
10
+ Vue.js 3 composition utilities to manage reactive lists, objects, loading and error state, and the small helpers that
11
+ support them. The composables give you reactive state plus actions; you supply the data layer (how a list or object
12
+ reaches your backend), so the package stays transport agnostic.
10
13
 
11
14
  <!-- prettier-ignore-start -->
12
15
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
13
16
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
14
17
 
18
+ - [Features](#features)
19
+ - [Requirements](#requirements)
15
20
  - [Install](#install)
16
21
  - [Usage](#usage)
22
+ - [Quick start](#quick-start)
23
+ - [Wiring a data layer](#wiring-a-data-layer)
17
24
  - [Changelog](#changelog)
25
+ - [Contributing](#contributing)
18
26
  - [Development](#development)
27
+ - [License](#license)
19
28
 
20
29
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
21
30
  <!-- prettier-ignore-end -->
22
31
 
32
+ ## Features
33
+
34
+ - **List composables** for managing collections of objects: `useListInstance`, `useList`, `useListFilter`,
35
+ `useListSort`, `useListSearch`, `useListCalculated`, `useListRelated`, and `useListSubscription`.
36
+ - **Object composables** for managing single objects: `useObjectInstance`, `useObject`, `useObjectCalculated`,
37
+ `useObjectRelated`, and `useObjectSubscription`.
38
+ - **Loading and error state** as small, composable primitives: `useLoading`, `useError`, `useLoadingError`, and their
39
+ read-only proxy variants `useProxyLoading`, `useProxyError`, `useProxyLoadingError`.
40
+ - **Standalone helpers** such as `useSearch` (FlexSearch-backed), `useCancellableIntent`, and `useCombineClasses`.
41
+ - **Pluggable CRUD configuration** via `setListCrud` / `setObjectCrud`, so the same composables can drive any backend.
42
+ - **Reactive and object utilities**: `deepUnref`, `assignReactiveObject`, `refIfReactive`, `toRefsIfReactive`,
43
+ `isReactiveTyped`, `set`, `deleteKey`, `keyDiff`, `flattenPaths`, `cancellablePromise`, `cancellableFetch`, and more.
44
+
45
+ Most list and object composables also ship a plural batch variant (for example `useListInstances`,
46
+ `useObjectInstances`) for creating several keyed instances at once. See the full API in
47
+ [docs/README.md](./docs/README.md).
48
+
49
+ ## Requirements
50
+
51
+ - **Vue** `^3.5.13` (peer dependency).
52
+ - **Node.js** with ES module support. This package is ESM only (`"type": "module"`); there is no CommonJS build.
53
+ - Peer dependencies you install alongside it: [`vue`](https://www.npmjs.com/package/vue),
54
+ [`@vueuse/core`](https://www.npmjs.com/package/@vueuse/core), and
55
+ [`lodash-es`](https://www.npmjs.com/package/lodash-es).
56
+
23
57
  ## Install
24
58
 
25
59
  ```bash
26
- $ npm install @arrai-innovations/reactive-helpers
60
+ $ npm install @arrai-innovations/reactive-helpers vue @vueuse/core lodash-es
27
61
  ```
28
62
 
29
63
  ## Usage
30
64
 
31
- The package exposes many composables and helper utilities. A minimal example of using a list instance is shown below.
65
+ ### Quick start
66
+
67
+ The loading and error composables are self contained and need no configuration. They return readonly reactive state
68
+ plus actions to drive it, which is handy for wiring UI to any asynchronous work:
69
+
70
+ ```javascript
71
+ import { useLoadingError } from "@arrai-innovations/reactive-helpers";
72
+
73
+ const { loading, error, errored, setLoading, clearLoading, setError, clearError } = useLoadingError();
74
+
75
+ async function save() {
76
+ setLoading();
77
+ try {
78
+ await doWork();
79
+ clearError();
80
+ } catch (e) {
81
+ setError(e);
82
+ } finally {
83
+ clearLoading();
84
+ }
85
+ }
86
+
87
+ // `loading`, `error`, and `errored` are readonly refs you can render or watch.
88
+ ```
89
+
90
+ ### Wiring a data layer
91
+
92
+ The list and object instance composables manage reactive collections but stay transport agnostic: you provide the CRUD
93
+ handlers that reach your backend. A list handler receives a `pushObjects` callback to feed results (one or more pages)
94
+ into the reactive state and resolves when it is done:
32
95
 
33
96
  ```javascript
34
97
  import { useListInstance } from "@arrai-innovations/reactive-helpers";
35
98
  import { reactive } from "vue";
36
99
 
37
- const props = reactive({
38
- target: { stream: "contacts" },
39
- pkKey: "id",
40
- params: { fields: ["id", "name"] },
100
+ const contacts = useListInstance({
101
+ props: {
102
+ pkKey: "id",
103
+ params: reactive({ fields: ["id", "name"] }),
104
+ target: { stream: "contacts" }, // implementation-specific args passed through to your handlers
105
+ },
106
+ handlers: {
107
+ list: async ({ pushObjects }) => {
108
+ const rows = await fetch("/api/contacts").then((r) => r.json());
109
+ pushObjects(rows);
110
+ return true;
111
+ },
112
+ },
41
113
  });
42
114
 
43
- const contacts = useListInstance({ props });
44
115
  await contacts.list();
45
116
  console.log(contacts.state.objects);
46
117
  ```
47
118
 
48
- See [docs/README.md](./docs/README.md) for a full list of modules, composables, utilities, as well as, their arguments
49
- and properties.
119
+ To share one data layer across every instance instead of passing `handlers` each time, register defaults once with
120
+ `setListCrud` (and `setObjectCrud` for object instances).
121
+
122
+ See [docs/README.md](./docs/README.md) for the full list of modules, composables, and utilities, along with their
123
+ arguments and properties.
50
124
 
51
125
  ## Changelog
52
126
 
53
127
  Since v21.0.0, the changelog is available in the [CHANGELOG.md](./CHANGELOG.md) file.
54
128
 
129
+ ## Contributing
130
+
131
+ Issues and pull requests are welcome. A few things to know before you start:
132
+
133
+ - Commits follow [Conventional Commits](https://www.conventionalcommits.org/) and are validated by commitlint through a
134
+ git hook (installed automatically by `pnpm install`).
135
+ - Run the tests, linters, and formatter before opening a pull request (see [Development](#development)).
136
+ - Generated output under `docs/` and `types/` is committed and checked in CI; regenerate it with `pnpm run docs` and
137
+ `pnpm run types` when you change public APIs or their JSDoc.
138
+
55
139
  ## Development
56
140
 
57
141
  1. Checkout this repo:
@@ -63,34 +147,38 @@ Since v21.0.0, the changelog is available in the [CHANGELOG.md](./CHANGELOG.md)
63
147
  2. Install dependencies:
64
148
 
65
149
  ```bash
66
- $ npm install --dev
150
+ $ pnpm install
67
151
  ```
68
152
 
69
153
  3. Run tests via vitest:
70
154
 
71
155
  ```bash
72
- $ npm test
156
+ $ pnpm test
73
157
  ```
74
158
 
75
159
  4. Run tests with coverage output:
76
160
 
77
161
  ```bash
78
- $ npm run coverage
162
+ $ pnpm coverage
79
163
  ```
80
164
 
81
165
  5. Generate types and typedocs:
82
166
 
83
167
  ```bash
84
- $ npm run docs
168
+ $ pnpm run docs
85
169
  ```
86
170
 
87
171
  6. Type-only workflows:
88
172
 
89
173
  - Generate types without docs:
90
174
  ```bash
91
- $ npm run types
175
+ $ pnpm run types
92
176
  ```
93
177
  - Smoke-check emitted types without regenerating:
94
178
  ```bash
95
- $ npm run types:check -- --skip-gen
179
+ $ pnpm run types:check -- --skip-gen
96
180
  ```
181
+
182
+ ## License
183
+
184
+ [BSD-3-Clause](./LICENSE) © Arrai Innovations Inc.
@@ -5,18 +5,15 @@ import isFunction from "lodash-es/isFunction.js";
5
5
  import { refIfReactive } from "../utils/refIfReactive.js";
6
6
 
7
7
  /**
8
- * Primary key type accepted as input (will be coerced to string).
9
- *
10
- * @typedef {string | number} PkInput
8
+ * @typedef {string | number} PkInput - Primary key type accepted as input (will be coerced to string).
11
9
  */
12
10
 
13
11
  /**
14
- * Primary key type used for storage and output (always a string).
15
- *
16
- * @typedef {string} Pk
12
+ * @typedef {string} Pk - Primary key type used for storage and output (always a string).
17
13
  */
18
14
 
19
15
  /**
16
+ * @internal
20
17
  * @param {string} name - The name of the method.
21
18
  * @returns {(...args: any[]) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<any>} - A function that returns a rejected promise with an error message.
22
19
  */
@@ -26,6 +23,7 @@ export const missingMethod = (name) => () =>
26
23
  // HACK: eslint, tsc, webstorm all can't agree on how to do this right
27
24
  // noinspection JSValidateTypes,JSUnusedLocalSymbols
28
25
  /**
26
+ * @internal
29
27
  * @param {string} name - The name of the method.
30
28
  * @returns {(
31
29
  * (..._args: any[]) => import('../utils/cancellablePromise.js').CancellablePromise<void>
@@ -9,25 +9,23 @@ import { readonly } from "vue";
9
9
  */
10
10
 
11
11
  /**
12
- * @typedef {import("../use/listInstance.js").ClearListFn} ClearObjectsFn
12
+ * @typedef {import("../use/listInstance.js").ClearListFn} ClearObjectsFn - Signature for the handler that clears the objects held by the list.
13
13
  */
14
14
 
15
15
  /**
16
- * @typedef {import("../use/listInstance.js").SetPaginateInfoFn} SetPaginateInfo
16
+ * @typedef {import("../use/listInstance.js").SetPaginateInfoFn} SetPaginateInfo - Signature for the handler that updates the list's pagination information.
17
17
  */
18
18
 
19
19
  /**
20
- * @typedef {import("../use/listInstance.js").SetColumnTotalsFn} SetColumnTotals
20
+ * @typedef {import("../use/listInstance.js").SetColumnTotalsFn} SetColumnTotals - Signature for the handler that updates the list's column totals.
21
21
  */
22
22
 
23
23
  /**
24
- * Additional arguments that can be passed to list crud handlers.
25
- *
26
- * @typedef {{[key:string]: any}} AdditionalListArgs
24
+ * @typedef {{[key:string]: any}} AdditionalListArgs - Additional arguments that can be passed to list crud handlers.
27
25
  */
28
26
 
29
27
  /**
30
- * @typedef {object} ListArgsRaw
28
+ * @typedef {object} ListArgsRaw - Raw arguments for a list operation before run-tracking and additional list CRUD arguments are merged in.
31
29
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
32
30
  * @property {string} pkKey - The key name of the primary key.
33
31
  * @property {object} params - The arguments to be passed for list crud handlers.
@@ -40,29 +38,29 @@ import { readonly } from "vue";
40
38
  */
41
39
 
42
40
  /**
43
- * @typedef {ListArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalListArgs} ListArgs
41
+ * @typedef {ListArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalListArgs} ListArgs - Arguments for a list operation, combining the raw arguments with run-tracking and any additional list CRUD arguments.
44
42
  */
45
43
 
46
44
  /**
47
- * @typedef {object} BulkDeleteArgsRaw
45
+ * @typedef {object} BulkDeleteArgsRaw - Raw arguments for a bulk-delete operation before additional list CRUD arguments are merged in.
48
46
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
49
47
  * @property {import('./commonCrud.js').Pk[]} pks - The ids of the objects to be deleted.
50
48
  * @property {string} pkKey - The key name of the primary key.
51
49
  */
52
50
 
53
51
  /**
54
- * @typedef {BulkDeleteArgsRaw & AdditionalListArgs} BulkDeleteArgs
52
+ * @typedef {BulkDeleteArgsRaw & AdditionalListArgs} BulkDeleteArgs - Arguments for a bulk-delete operation, combining the raw arguments with any additional list CRUD arguments.
55
53
  */
56
54
 
57
55
  /**
58
56
  * @typedef {(
59
57
  * newOrUpdatedOrDeleteObject:import('../use/objectInstance.js').ExistingCrudObject|string,
60
58
  * action: 'create'|'update'|'delete'
61
- * )=>void} applyObjectEvent
59
+ * )=>void} applyObjectEvent - Callback that applies a created, updated, or deleted object event received from a subscription to the list.
62
60
  */
63
61
 
64
62
  /**
65
- * @typedef {object} ListSubscribeArgsRaw
63
+ * @typedef {object} ListSubscribeArgsRaw - Raw arguments for a list subscribe operation before run-tracking and additional list CRUD arguments are merged in.
66
64
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
67
65
  * @property {string} pkKey - The key name of the primary key.
68
66
  * @property {object} params - The arguments to be passed for list crud handlers.
@@ -72,11 +70,11 @@ import { readonly } from "vue";
72
70
  */
73
71
 
74
72
  /**
75
- * @typedef {ListSubscribeArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalListArgs } ListSubscribeArgs
73
+ * @typedef {ListSubscribeArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalListArgs } ListSubscribeArgs - Arguments for a list subscribe operation, combining the raw arguments with run-tracking and any additional list CRUD arguments.
76
74
  */
77
75
 
78
76
  /**
79
- * @typedef {object} ExecuteActionArgsRaw
77
+ * @typedef {object} ExecuteActionArgsRaw - Raw arguments for a list execute-action operation before additional list CRUD arguments are merged in.
80
78
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
81
79
  * @property {import('./commonCrud.js').Pk[]} pks - The ids of the objects to be acted upon.
82
80
  * @property {string} pkKey - The key name of the primary key.
@@ -84,35 +82,35 @@ import { readonly } from "vue";
84
82
  */
85
83
 
86
84
  /**
87
- * @typedef {ExecuteActionArgsRaw & AdditionalListArgs } ExecuteActionArgs
85
+ * @typedef {ExecuteActionArgsRaw & AdditionalListArgs } ExecuteActionArgs - Arguments for a list execute-action operation, combining the raw arguments with any additional list CRUD arguments.
88
86
  */
89
87
 
90
88
  /**
91
- * @callback CrudListFn
89
+ * @callback CrudListFn - Signature for the handler that lists objects from the backing store.
92
90
  * @param {ListArgs} args - The arguments to be passed to the crud handlers.
93
91
  * @returns {import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} - A cancellable promise for the list request.
94
92
  */
95
93
 
96
94
  /**
97
- * @callback CrudBulkDeleteFn
95
+ * @callback CrudBulkDeleteFn - Signature for the handler that bulk-deletes objects from the backing store.
98
96
  * @param {BulkDeleteArgs} args - The arguments to be passed to the crud handlers.
99
97
  * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating success.
100
98
  */
101
99
 
102
100
  /**
103
- * @callback CrudListSubscribeFn
101
+ * @callback CrudListSubscribeFn - Signature for the handler that subscribes to list changes in the backing store.
104
102
  * @param {ListSubscribeArgs} args - The arguments to be passed to the crud handlers.
105
103
  * @returns {import('../utils/cancellablePromise.js').CancellablePromise<void>} - A cancellable promise for the subscription.
106
104
  */
107
105
 
108
106
  /**
109
- * @callback CrudExecuteActionFn
107
+ * @callback CrudExecuteActionFn - Signature for the handler that executes an action on a list of objects in the backing store.
110
108
  * @param {ExecuteActionArgs} args - The arguments to be passed to the crud handlers.
111
109
  * @returns {Promise<object|string|null>} - A promise that resolves the result of the action, returned to the executor.
112
110
  */
113
111
 
114
112
  /**
115
- * @typedef {object} ListCrudHandlers
113
+ * @typedef {object} ListCrudHandlers - The set of optional CRUD handler functions (list, bulkDelete, executeAction, subscribe) for a list.
116
114
  * @property {CrudListFn} [list] - The list function to get a list of items.
117
115
  * @property {CrudBulkDeleteFn} [bulkDelete] - The delete function to bulk delete a list of items.
118
116
  * @property {CrudExecuteActionFn} [executeAction] - The function to execute a certain action on a list of items.
@@ -120,12 +118,12 @@ import { readonly } from "vue";
120
118
  */
121
119
 
122
120
  /**
123
- * @typedef {object} ListTarget
121
+ * @typedef {object} ListTarget - The default target arguments passed through to the list CRUD handlers.
124
122
  * @property {object} args - The default arguments for the crud handlers.
125
123
  */
126
124
 
127
125
  /**
128
- * @typedef {object} ListTargetOption
126
+ * @typedef {object} ListTargetOption - Optional target arguments passed through to the list CRUD handlers.
129
127
  * @property {object} [target={}] - The default arguments for the crud handlers.
130
128
  */
131
129
 
@@ -9,29 +9,25 @@ import { readonly } from "vue";
9
9
  */
10
10
 
11
11
  /**
12
- * @typedef {{[key:string]: any}} TargetArgs
12
+ * @typedef {{[key:string]: any}} TargetArgs - Implementation-specific arguments passed through to the CRUD handlers, such as endpoint identifiers.
13
13
  */
14
14
 
15
15
  /**
16
- * Additional arguments that can be passed to CRUD handlers.
17
- *
18
- * @typedef {{[key:string]: any}} AdditionalCrudArgs
16
+ * @typedef {{[key:string]: any}} AdditionalCrudArgs - Additional arguments that can be passed to CRUD handlers.
19
17
  */
20
18
 
21
19
  /**
22
- * Defines the CRUD-related handlers and additional utilities provided by the object instance.
23
- *
24
- * @typedef {object} ObjectTargetProperties
20
+ * @typedef {object} ObjectTargetProperties - Defines the CRUD-related handlers and additional utilities provided by the object instance.
25
21
  * @property {TargetArgs} args - The arguments to be passed to the crud handlers.
26
22
  */
27
23
 
28
24
  /**
29
- * @typedef {object} ObjectTargetOption
25
+ * @typedef {object} ObjectTargetOption - Optional target arguments passed through to the object CRUD handlers.
30
26
  * @property {TargetArgs} [target={}] - The arguments to be passed to the crud handlers.
31
27
  */
32
28
 
33
29
  /**
34
- * @typedef {object} CreateArgsRaw
30
+ * @typedef {object} CreateArgsRaw - Raw arguments for an object create operation before additional CRUD arguments are merged in.
35
31
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
36
32
  * @property {{[key:string]: any}} object - The data to be acted upon.
37
33
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
@@ -40,11 +36,11 @@ import { readonly } from "vue";
40
36
  */
41
37
 
42
38
  /**
43
- * @typedef {CreateArgsRaw & AdditionalCrudArgs} CreateArgs
39
+ * @typedef {CreateArgsRaw & AdditionalCrudArgs} CreateArgs - Arguments for an object create operation, combining the raw arguments with any additional CRUD arguments.
44
40
  */
45
41
 
46
42
  /**
47
- * @typedef {object} RetrieveArgsRaw
43
+ * @typedef {object} RetrieveArgsRaw - Raw arguments for an object retrieve operation before run-tracking and additional CRUD arguments are merged in.
48
44
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
49
45
  * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
50
46
  * @property {string} pkKey - The key name of the primary key.
@@ -53,11 +49,11 @@ import { readonly } from "vue";
53
49
  */
54
50
 
55
51
  /**
56
- * @typedef {RetrieveArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalCrudArgs} RetrieveArgs
52
+ * @typedef {RetrieveArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalCrudArgs} RetrieveArgs - Arguments for an object retrieve operation, combining the raw arguments with run-tracking and any additional CRUD arguments.
57
53
  */
58
54
 
59
55
  /**
60
- * @typedef {object} UpdateArgsRaw
56
+ * @typedef {object} UpdateArgsRaw - Raw arguments for an object update operation before additional CRUD arguments are merged in.
61
57
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
62
58
  * @property {import('../use/objectInstance.js').ExistingCrudObject} object - The data to be acted upon.
63
59
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
@@ -66,22 +62,23 @@ import { readonly } from "vue";
66
62
  */
67
63
 
68
64
  /**
69
- * @typedef {UpdateArgsRaw & AdditionalCrudArgs} UpdateArgs
65
+ * @typedef {UpdateArgsRaw & AdditionalCrudArgs} UpdateArgs - Arguments for an object update operation, combining the raw arguments with any additional CRUD arguments.
70
66
  */
71
67
 
72
68
  /**
73
- * @typedef {object} DeleteArgsRaw
69
+ * @typedef {object} DeleteArgsRaw - Raw arguments for an object delete operation before additional CRUD arguments are merged in.
74
70
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
75
71
  * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
76
72
  * @property {string} pkKey - The key name of the primary key.
73
+ * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
77
74
  */
78
75
 
79
76
  /**
80
- * @typedef {DeleteArgsRaw & AdditionalCrudArgs} DeleteArgs
77
+ * @typedef {DeleteArgsRaw & AdditionalCrudArgs} DeleteArgs - Arguments for an object delete operation, combining the raw arguments with any additional CRUD arguments.
81
78
  */
82
79
 
83
80
  /**
84
- * @typedef {object} PartialArgsRaw
81
+ * @typedef {object} PartialArgsRaw - Raw arguments for an object patch (partial update) operation before additional CRUD arguments are merged in.
85
82
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
86
83
  * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
87
84
  * @property {string} pkKey - The key name of the primary key.
@@ -90,11 +87,11 @@ import { readonly } from "vue";
90
87
  * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
91
88
  */
92
89
  /**
93
- * @typedef {PartialArgsRaw & AdditionalCrudArgs} PartialArgs
90
+ * @typedef {PartialArgsRaw & AdditionalCrudArgs} PartialArgs - Arguments for an object patch (partial update) operation, combining the raw arguments with any additional CRUD arguments.
94
91
  */
95
92
 
96
93
  /**
97
- * @typedef {object} ObjectExecuteActionArgsRaw
94
+ * @typedef {object} ObjectExecuteActionArgsRaw - Raw arguments for a single-object execute-action operation before additional CRUD arguments are merged in.
98
95
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
99
96
  * @property {string} pk - The id of the objects to be acted upon.
100
97
  * @property {string} pkKey - The key name of the primary key.
@@ -103,17 +100,17 @@ import { readonly } from "vue";
103
100
  */
104
101
 
105
102
  /**
106
- * @typedef {ObjectExecuteActionArgsRaw & AdditionalCrudArgs} ObjectExecuteActionArgs
103
+ * @typedef {ObjectExecuteActionArgsRaw & AdditionalCrudArgs} ObjectExecuteActionArgs - Arguments for a single-object execute-action operation, combining the raw arguments with any additional CRUD arguments.
107
104
  */
108
105
 
109
106
  /**
110
- * @callback CrudSubscribeCallback
107
+ * @callback CrudSubscribeCallback - Callback invoked with the changed object and the action (create, update, or delete) when a subscribed object changes.
111
108
  * @param {import('../use/objectInstance.js').ExistingCrudObject} data - The data to be passed to the callback.
112
109
  * @param {"delete"|"update"|"create"} action - The action that was performed.
113
110
  */
114
111
 
115
112
  /**
116
- * @typedef {object} ObjectSubscribeArgsRaw
113
+ * @typedef {object} ObjectSubscribeArgsRaw - Raw arguments for a single-object subscribe operation before run-tracking and additional CRUD arguments are merged in.
117
114
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
118
115
  * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
119
116
  * @property {string} pkKey - The key name of the primary key.
@@ -123,59 +120,57 @@ import { readonly } from "vue";
123
120
  */
124
121
 
125
122
  /**
126
- * @typedef {ObjectSubscribeArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking & AdditionalCrudArgs} ObjectSubscribeArgs
123
+ * @typedef {ObjectSubscribeArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking & AdditionalCrudArgs} ObjectSubscribeArgs - Arguments for a single-object subscribe operation, combining the raw arguments with run-tracking and any additional CRUD arguments.
127
124
  */
128
125
 
129
126
  /**
130
- * @typedef {import('../utils/cancellablePromise.js').MaybeCancellablePromise<object|string>} CrudResponse
127
+ * @typedef {import('../utils/cancellablePromise.js').MaybeCancellablePromise<object|string>} CrudResponse - The value returned by an object CRUD handler, a possibly-cancellable promise resolving to an object or string.
131
128
  */
132
129
 
133
130
  /**
134
- * @callback CrudCreateFn
131
+ * @callback CrudCreateFn - Signature for the handler that creates an object in the backing store.
135
132
  * @param {CreateArgs} args - The arguments to be passed to the create function.
136
133
  * @returns {CrudResponse} - The response data from the create function.
137
134
  */
138
135
 
139
136
  /**
140
- * @callback CrudRetrieveFn
137
+ * @callback CrudRetrieveFn - Signature for the handler that retrieves an object from the backing store.
141
138
  * @param {RetrieveArgs} args - The arguments to be passed to the retrieve function.
142
139
  * @returns {CrudResponse} - The response data from the retrieve function.
143
140
  */
144
141
 
145
142
  /**
146
- * @callback CrudUpdateFn
143
+ * @callback CrudUpdateFn - Signature for the handler that updates an object in the backing store.
147
144
  * @param {UpdateArgs} args - The arguments to be passed to the update function.
148
145
  * @returns {CrudResponse} - The response data from the update function.
149
146
  */
150
147
 
151
148
  /**
152
- * @callback CrudPatchFn
149
+ * @callback CrudPatchFn - Signature for the handler that partially updates (patches) an object in the backing store.
153
150
  * @param {PartialArgs} args - The arguments to be passed to the patch function.
154
151
  * @returns {CrudResponse} - The response data from the patch function.
155
152
  */
156
153
 
157
154
  /**
158
- * @callback CrudDeleteFn
155
+ * @callback CrudDeleteFn - Signature for the handler that deletes an object from the backing store.
159
156
  * @param {DeleteArgs} args - The arguments to be passed to the delete function.
160
157
  * @returns {CrudResponse} - The response data from the delete function.
161
158
  */
162
159
 
163
160
  /**
164
- * @callback CrudObjectExecuteActionFn
161
+ * @callback CrudObjectExecuteActionFn - Signature for the handler that executes an action on a single object in the backing store.
165
162
  * @param {ObjectExecuteActionArgs} args - The arguments to be passed to the executeAction function.
166
163
  * @returns {CrudResponse} - The response data from the delete function.
167
164
  */
168
165
 
169
166
  /**
170
- * @callback CrudObjectSubscribeFn
167
+ * @callback CrudObjectSubscribeFn - Signature for the handler that subscribes to changes on a single object in the backing store.
171
168
  * @param {ObjectSubscribeArgs} args - The arguments to be passed to the subscribe function.
172
169
  * @returns {import('../utils/cancellablePromise.js').CancellablePromise<void>} - The cancellable promise.
173
170
  */
174
171
 
175
172
  /**
176
- * Defines the CRUD-related handlers and additional utilities provided by the object instance.
177
- *
178
- * @typedef {object} ObjectCrudHandlers
173
+ * @typedef {object} ObjectCrudHandlers - Defines the CRUD-related handlers and additional utilities provided by the object instance.
179
174
  * @property {CrudCreateFn} [create] - A function to be used instead of the default crud create function.
180
175
  * @property {CrudRetrieveFn} [retrieve] - A function to be used instead of the default crud retrieve function.
181
176
  * @property {CrudUpdateFn} [update] - A function to be used instead of the default crud update function.
@@ -187,9 +182,7 @@ import { readonly } from "vue";
187
182
  */
188
183
 
189
184
  /**
190
- * The CRUD arguments.
191
- *
192
- * @typedef {ObjectTargetProperties & ObjectCrudHandlers} ObjectTarget
185
+ * @typedef {ObjectTargetProperties & ObjectCrudHandlers} ObjectTarget - The CRUD arguments.
193
186
  *
194
187
  */
195
188