@arrai-innovations/reactive-helpers 22.0.0 → 22.1.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.
- package/README.md +3 -3
- package/config/commonCrud.js +3 -4
- package/config/listCrud.js +13 -11
- package/config/objectCrud.js +36 -24
- package/package.json +11 -1
- package/types/config/listCrud.d.ts +6 -8
- package/types/config/objectCrud.d.ts +33 -22
- package/types/tests/benchmarks/fixtures.d.ts +60 -0
- package/types/tests/benchmarks/listLayers.bench.d.ts +1 -0
- package/types/tests/benchmarks/listPush.bench.d.ts +1 -0
- package/types/tests/benchmarks/listStream.bench.d.ts +1 -0
- package/types/tests/unit/use/lifecycleCleanup.spec.d.ts +1 -0
- package/types/tests/unit/use/listPerformance.spec.d.ts +1 -0
- package/types/tests/unit/utils/cancellablePromise.spec.d.ts +1 -0
- package/types/use/cancellableIntent.d.ts +9 -2
- package/types/use/combineClasses.d.ts +1 -1
- package/types/use/listCalculated.d.ts +21 -20
- package/types/use/listInstance.d.ts +6 -1
- package/types/use/listRelated.d.ts +15 -15
- package/types/use/listSort.d.ts +6 -1
- package/types/use/listSubscription.d.ts +6 -2
- package/types/use/objectCalculated.d.ts +18 -14
- package/types/use/objectInstance.d.ts +4 -2
- package/types/use/objectRelated.d.ts +11 -9
- package/types/use/objectSubscription.d.ts +6 -5
- package/types/utils/cancellableFetch.d.ts +2 -3
- package/types/utils/cancellablePromise.d.ts +39 -5
- package/types/utils/getFakePk.d.ts +2 -2
- package/use/cancellableIntent.js +9 -2
- package/use/combineClasses.js +1 -1
- package/use/listCalculated.js +22 -17
- package/use/listFilter.js +4 -3
- package/use/listInstance.js +76 -16
- package/use/listRelated.js +9 -9
- package/use/listSearch.js +1 -1
- package/use/listSort.js +68 -23
- package/use/listSubscription.js +10 -1
- package/use/object.js +7 -8
- package/use/objectCalculated.js +13 -11
- package/use/objectInstance.js +9 -3
- package/use/objectRelated.js +6 -5
- package/use/objectSubscription.js +7 -5
- package/use/proxyLoadingError.js +3 -0
- package/utils/cancellableFetch.js +3 -3
- package/utils/cancellablePromise.js +21 -4
- package/utils/getFakePk.js +2 -2
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ reaches your backend), so the package stays transport agnostic.
|
|
|
44
44
|
|
|
45
45
|
Most list and object composables also ship a plural batch variant (for example `useListInstances`,
|
|
46
46
|
`useObjectInstances`) for creating several keyed instances at once. See the full API in
|
|
47
|
-
[docs/
|
|
47
|
+
[docs/reference/api/index.md](./docs/reference/api/index.md).
|
|
48
48
|
|
|
49
49
|
## Requirements
|
|
50
50
|
|
|
@@ -119,8 +119,8 @@ console.log(contacts.state.objects);
|
|
|
119
119
|
To share one data layer across every instance instead of passing `handlers` each time, register defaults once with
|
|
120
120
|
`setListCrud` (and `setObjectCrud` for object instances).
|
|
121
121
|
|
|
122
|
-
See [docs/
|
|
123
|
-
arguments and properties.
|
|
122
|
+
See [docs/reference/api/index.md](./docs/reference/api/index.md) for the full list of modules, composables, and
|
|
123
|
+
utilities, along with their arguments and properties.
|
|
124
124
|
|
|
125
125
|
## Changelog
|
|
126
126
|
|
package/config/commonCrud.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeCancellable } from "../utils/cancellablePromise.js";
|
|
2
2
|
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
3
3
|
import { addOrUpdateReactiveObject } from "../utils/assignReactiveObject.js";
|
|
4
4
|
import isFunction from "lodash-es/isFunction.js";
|
|
@@ -17,8 +17,7 @@ import { refIfReactive } from "../utils/refIfReactive.js";
|
|
|
17
17
|
* @param {string} name - The name of the method.
|
|
18
18
|
* @returns {(...args: any[]) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<any>} - A function that returns a rejected promise with an error message.
|
|
19
19
|
*/
|
|
20
|
-
export const missingMethod = (name) => () =>
|
|
21
|
-
CancellablePromise.reject(new Error(`Crud method "${name}" is not implemented.`));
|
|
20
|
+
export const missingMethod = (name) => () => Promise.reject(new Error(`Crud method "${name}" is not implemented.`));
|
|
22
21
|
|
|
23
22
|
// HACK: eslint, tsc, webstorm all can't agree on how to do this right
|
|
24
23
|
// noinspection JSValidateTypes,JSUnusedLocalSymbols
|
|
@@ -34,7 +33,7 @@ export const requiredCancelMissingMethod =
|
|
|
34
33
|
/* eslint-disable no-unused-vars */
|
|
35
34
|
// @ts-ignore - refuses to accept returned CancellablePromise<void> = imported CancellablePromise<void>
|
|
36
35
|
(..._args) =>
|
|
37
|
-
|
|
36
|
+
makeCancellable(Promise.reject(new Error(`Crud method "${name}" is not implemented.`)), () => {});
|
|
38
37
|
/* eslint-enable no-unused-vars */
|
|
39
38
|
|
|
40
39
|
/**
|
package/config/listCrud.js
CHANGED
|
@@ -28,11 +28,10 @@ import { readonly } from "vue";
|
|
|
28
28
|
* @typedef {object} ListArgsRaw - Raw arguments for a list operation before run-tracking and additional list CRUD arguments are merged in.
|
|
29
29
|
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
30
30
|
* @property {string} pkKey - The key name of the primary key.
|
|
31
|
-
* @property {object} params -
|
|
31
|
+
* @property {object} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
32
32
|
* @property {import("../use/listInstance.js").PushObjectsFn} pushObjects - The method to call with new page(s) of data received.
|
|
33
33
|
* @property {ClearObjectsFn} clearObjects - The method to call to clear the objects.
|
|
34
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
35
|
-
* been cancelled.
|
|
34
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
36
35
|
* @property {SetPaginateInfo} setPaginateInfo - The method to update pagination information.
|
|
37
36
|
* @property {SetColumnTotals} setColumnTotals - The method to update column totals.
|
|
38
37
|
*/
|
|
@@ -44,7 +43,7 @@ import { readonly } from "vue";
|
|
|
44
43
|
/**
|
|
45
44
|
* @typedef {object} BulkDeleteArgsRaw - Raw arguments for a bulk-delete operation before additional list CRUD arguments are merged in.
|
|
46
45
|
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
47
|
-
* @property {import('./commonCrud.js').Pk[]} pks - The
|
|
46
|
+
* @property {import('./commonCrud.js').Pk[]} pks - The pks of the objects to be deleted.
|
|
48
47
|
* @property {string} pkKey - The key name of the primary key.
|
|
49
48
|
*/
|
|
50
49
|
|
|
@@ -63,10 +62,9 @@ import { readonly } from "vue";
|
|
|
63
62
|
* @typedef {object} ListSubscribeArgsRaw - Raw arguments for a list subscribe operation before run-tracking and additional list CRUD arguments are merged in.
|
|
64
63
|
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
65
64
|
* @property {string} pkKey - The key name of the primary key.
|
|
66
|
-
* @property {object} params -
|
|
65
|
+
* @property {object} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
67
66
|
* @property {applyObjectEvent} applyObjectEvent - The method to call when new data is received.
|
|
68
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
69
|
-
* been cancelled.
|
|
67
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
70
68
|
*/
|
|
71
69
|
|
|
72
70
|
/**
|
|
@@ -76,7 +74,7 @@ import { readonly } from "vue";
|
|
|
76
74
|
/**
|
|
77
75
|
* @typedef {object} ExecuteActionArgsRaw - Raw arguments for a list execute-action operation before additional list CRUD arguments are merged in.
|
|
78
76
|
* @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
79
|
-
* @property {import('./commonCrud.js').Pk[]} pks - The
|
|
77
|
+
* @property {import('./commonCrud.js').Pk[]} pks - The pks of the objects to be acted upon.
|
|
80
78
|
* @property {string} pkKey - The key name of the primary key.
|
|
81
79
|
* @property {string} action - The action to execute.
|
|
82
80
|
*/
|
|
@@ -88,13 +86,16 @@ import { readonly } from "vue";
|
|
|
88
86
|
/**
|
|
89
87
|
* @callback CrudListFn - Signature for the handler that lists objects from the backing store.
|
|
90
88
|
* @param {ListArgs} args - The arguments to be passed to the crud handlers.
|
|
91
|
-
* @returns {import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} - A
|
|
89
|
+
* @returns {import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} - A promise whose resolution means
|
|
90
|
+
* the fetch is complete. Rows reach the list only through `pushObjects`, so the resolved value is ignored. Carry a
|
|
91
|
+
* `cancel` method to let the library abandon a superseded run.
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* @callback CrudBulkDeleteFn - Signature for the handler that bulk-deletes objects from the backing store.
|
|
96
96
|
* @param {BulkDeleteArgs} args - The arguments to be passed to the crud handlers.
|
|
97
|
-
* @returns {Promise<boolean>} - A promise
|
|
97
|
+
* @returns {Promise<boolean>} - A promise whose resolution means the bulk delete succeeded; the resolved value is not
|
|
98
|
+
* inspected, and the instance then empties the list.
|
|
98
99
|
*/
|
|
99
100
|
|
|
100
101
|
/**
|
|
@@ -106,7 +107,8 @@ import { readonly } from "vue";
|
|
|
106
107
|
/**
|
|
107
108
|
* @callback CrudExecuteActionFn - Signature for the handler that executes an action on a list of objects in the backing store.
|
|
108
109
|
* @param {ExecuteActionArgs} args - The arguments to be passed to the crud handlers.
|
|
109
|
-
* @returns {Promise<object|string|null>} - A promise
|
|
110
|
+
* @returns {Promise<object|string|null>} - A promise resolving the action's result, which `listInstance.executeAction`
|
|
111
|
+
* passes through to its caller.
|
|
110
112
|
*/
|
|
111
113
|
|
|
112
114
|
/**
|
package/config/objectCrud.js
CHANGED
|
@@ -29,10 +29,10 @@ import { readonly } from "vue";
|
|
|
29
29
|
/**
|
|
30
30
|
* @typedef {object} CreateArgsRaw - Raw arguments for an object create operation before additional CRUD arguments are merged in.
|
|
31
31
|
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
32
|
-
* @property {{[key:string]: any}} object - The
|
|
33
|
-
* @property {{[key:string]: any}} params -
|
|
32
|
+
* @property {{[key:string]: any}} object - The new object to create; it carries no primary key yet.
|
|
33
|
+
* @property {{[key:string]: any}} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
34
34
|
* @property {string} pkKey - The key name of the primary key.
|
|
35
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
35
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -44,8 +44,8 @@ import { readonly } from "vue";
|
|
|
44
44
|
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
45
45
|
* @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
|
|
46
46
|
* @property {string} pkKey - The key name of the primary key.
|
|
47
|
-
* @property {{[key:string]: any}} params -
|
|
48
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
47
|
+
* @property {{[key:string]: any}} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
48
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -55,10 +55,10 @@ import { readonly } from "vue";
|
|
|
55
55
|
/**
|
|
56
56
|
* @typedef {object} UpdateArgsRaw - Raw arguments for an object update operation before additional CRUD arguments are merged in.
|
|
57
57
|
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
58
|
-
* @property {import('../use/objectInstance.js').ExistingCrudObject} object - The
|
|
59
|
-
* @property {{[key:string]: any}} params -
|
|
58
|
+
* @property {import('../use/objectInstance.js').ExistingCrudObject} object - The complete object to update; its primary key rides inside it, at `object[pkKey]`.
|
|
59
|
+
* @property {{[key:string]: any}} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
60
60
|
* @property {string} pkKey - The key name of the primary key.
|
|
61
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
61
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -70,7 +70,7 @@ import { readonly } from "vue";
|
|
|
70
70
|
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
71
71
|
* @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
|
|
72
72
|
* @property {string} pkKey - The key name of the primary key.
|
|
73
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
73
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
74
74
|
*/
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -82,9 +82,9 @@ import { readonly } from "vue";
|
|
|
82
82
|
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
83
83
|
* @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
|
|
84
84
|
* @property {string} pkKey - The key name of the primary key.
|
|
85
|
-
* @property {{[key:string]: any}} partialObject - The
|
|
86
|
-
* @property {{[key:string]: any}} params -
|
|
87
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
85
|
+
* @property {{[key:string]: any}} partialObject - The changed fields only.
|
|
86
|
+
* @property {{[key:string]: any}} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
87
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
88
88
|
*/
|
|
89
89
|
/**
|
|
90
90
|
* @typedef {PartialArgsRaw & AdditionalCrudArgs} PartialArgs - Arguments for an object patch (partial update) operation, combining the raw arguments with any additional CRUD arguments.
|
|
@@ -92,11 +92,11 @@ import { readonly } from "vue";
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* @typedef {object} ObjectExecuteActionArgsRaw - Raw arguments for a single-object execute-action operation before additional CRUD arguments are merged in.
|
|
95
|
-
* @property {
|
|
96
|
-
* @property {
|
|
95
|
+
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
96
|
+
* @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
|
|
97
97
|
* @property {string} pkKey - The key name of the primary key.
|
|
98
98
|
* @property {string} action - The action to execute.
|
|
99
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
99
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
100
100
|
*/
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -114,9 +114,9 @@ import { readonly } from "vue";
|
|
|
114
114
|
* @property {TargetArgs} target - The arguments to be passed to the crud handlers.
|
|
115
115
|
* @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
|
|
116
116
|
* @property {string} pkKey - The key name of the primary key.
|
|
117
|
-
* @property {{[key:string]: any}} params -
|
|
117
|
+
* @property {{[key:string]: any}} params - Your listing or retrieval arguments, passed through to the crud handlers.
|
|
118
118
|
* @property {CrudSubscribeCallback} callback - The callback to be called when the object is updated.
|
|
119
|
-
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref
|
|
119
|
+
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A readonly ref that becomes true once the request is cancelled.
|
|
120
120
|
*/
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -124,43 +124,55 @@ import { readonly } from "vue";
|
|
|
124
124
|
*/
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* @typedef {import('../utils/cancellablePromise.js').MaybeCancellablePromise<object
|
|
127
|
+
* @typedef {import('../utils/cancellablePromise.js').MaybeCancellablePromise<object>} CrudResponse -
|
|
128
|
+
* The value returned by an object CRUD handler whose resolved value becomes the record: create, retrieve, update, and
|
|
129
|
+
* patch. A possibly-cancellable promise resolving to the complete record. The instance mirrors the resolved value
|
|
130
|
+
* into `state.object`, so a partial record drops the fields it omits, and a resolved value that is not an object (a
|
|
131
|
+
* bare primary key string, for instance) fails the assignment and is stored in `state.error`.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @typedef {import('../utils/cancellablePromise.js').MaybeCancellablePromise<object|string|void>} CrudCompletionResponse -
|
|
136
|
+
* The value returned by an object CRUD handler whose resolved value is ignored: delete, and executeAction. A
|
|
137
|
+
* possibly-cancellable promise whose resolution signals success and nothing more, so it may resolve a record, a
|
|
138
|
+
* primary key string, or nothing at all.
|
|
128
139
|
*/
|
|
129
140
|
|
|
130
141
|
/**
|
|
131
142
|
* @callback CrudCreateFn - Signature for the handler that creates an object in the backing store.
|
|
132
143
|
* @param {CreateArgs} args - The arguments to be passed to the create function.
|
|
133
|
-
* @returns {CrudResponse} -
|
|
144
|
+
* @returns {CrudResponse} - A promise resolving the created record in full.
|
|
134
145
|
*/
|
|
135
146
|
|
|
136
147
|
/**
|
|
137
148
|
* @callback CrudRetrieveFn - Signature for the handler that retrieves an object from the backing store.
|
|
138
149
|
* @param {RetrieveArgs} args - The arguments to be passed to the retrieve function.
|
|
139
|
-
* @returns {CrudResponse} -
|
|
150
|
+
* @returns {CrudResponse} - A promise resolving the retrieved record in full.
|
|
140
151
|
*/
|
|
141
152
|
|
|
142
153
|
/**
|
|
143
154
|
* @callback CrudUpdateFn - Signature for the handler that updates an object in the backing store.
|
|
144
155
|
* @param {UpdateArgs} args - The arguments to be passed to the update function.
|
|
145
|
-
* @returns {CrudResponse} -
|
|
156
|
+
* @returns {CrudResponse} - A promise resolving the updated record in full.
|
|
146
157
|
*/
|
|
147
158
|
|
|
148
159
|
/**
|
|
149
160
|
* @callback CrudPatchFn - Signature for the handler that partially updates (patches) an object in the backing store.
|
|
150
161
|
* @param {PartialArgs} args - The arguments to be passed to the patch function.
|
|
151
|
-
* @returns {CrudResponse} -
|
|
162
|
+
* @returns {CrudResponse} - A promise resolving the patched record in full, not just the changed fields.
|
|
152
163
|
*/
|
|
153
164
|
|
|
154
165
|
/**
|
|
155
166
|
* @callback CrudDeleteFn - Signature for the handler that deletes an object from the backing store.
|
|
156
167
|
* @param {DeleteArgs} args - The arguments to be passed to the delete function.
|
|
157
|
-
* @returns {
|
|
168
|
+
* @returns {CrudCompletionResponse} - A promise whose resolution means the delete succeeded; its value is ignored.
|
|
158
169
|
*/
|
|
159
170
|
|
|
160
171
|
/**
|
|
161
172
|
* @callback CrudObjectExecuteActionFn - Signature for the handler that executes an action on a single object in the backing store.
|
|
162
173
|
* @param {ObjectExecuteActionArgs} args - The arguments to be passed to the executeAction function.
|
|
163
|
-
* @returns {
|
|
174
|
+
* @returns {CrudCompletionResponse} - A promise whose resolution means the action succeeded; its value is ignored, and
|
|
175
|
+
* `objectInstance.executeAction` resolves `true`.
|
|
164
176
|
*/
|
|
165
177
|
|
|
166
178
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrai-innovations/reactive-helpers",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.1.0",
|
|
4
4
|
"description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"typedoc-plugin-markdown": "^4.12.0",
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
69
|
"vite": "^8.0.16",
|
|
70
|
+
"vitepress": "^1.6.4",
|
|
70
71
|
"vitest": "^4.1.9",
|
|
71
72
|
"vue-eslint-parser": "^10.4.1"
|
|
72
73
|
},
|
|
@@ -82,6 +83,12 @@
|
|
|
82
83
|
"vue": "^3.5.13"
|
|
83
84
|
},
|
|
84
85
|
"scripts": {
|
|
86
|
+
"benchmark": "vitest bench --run",
|
|
87
|
+
"benchmark:list": "vitest bench --run tests/benchmarks/listPush.bench.js",
|
|
88
|
+
"benchmark:list:ci": "vitest bench --run tests/benchmarks/listPush.bench.js --outputJson benchmark-results/list-push.json",
|
|
89
|
+
"benchmark:check": "node check_benchmark.js",
|
|
90
|
+
"benchmark:layers": "vitest bench --run tests/benchmarks/listLayers.bench.js",
|
|
91
|
+
"benchmark:stream": "vitest bench --run tests/benchmarks/listStream.bench.js",
|
|
85
92
|
"test": "vitest",
|
|
86
93
|
"eslint": "eslint --fix index.js config/**/*.js tests/**/*.js use/**/*.js utils/**/*.js",
|
|
87
94
|
"prettier": "prettier --write .",
|
|
@@ -89,6 +96,9 @@
|
|
|
89
96
|
"docs": "node make_type_doc.js",
|
|
90
97
|
"docs:check": "node check_type_doc.js",
|
|
91
98
|
"docs:clean": "node clean_type_doc.js",
|
|
99
|
+
"docs:site:dev": "vitepress dev docs",
|
|
100
|
+
"docs:site:build": "vitepress build docs",
|
|
101
|
+
"docs:site:preview": "vitepress preview docs",
|
|
92
102
|
"types": "node make_types.js",
|
|
93
103
|
"types:check": "node check_types.js"
|
|
94
104
|
}
|
|
@@ -40,7 +40,7 @@ export type ListArgsRaw = {
|
|
|
40
40
|
*/
|
|
41
41
|
pkKey: string;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
44
44
|
*/
|
|
45
45
|
params: object;
|
|
46
46
|
/**
|
|
@@ -52,8 +52,7 @@ export type ListArgsRaw = {
|
|
|
52
52
|
*/
|
|
53
53
|
clearObjects: ClearObjectsFn;
|
|
54
54
|
/**
|
|
55
|
-
* A ref
|
|
56
|
-
* been cancelled.
|
|
55
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
57
56
|
*/
|
|
58
57
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
59
58
|
/**
|
|
@@ -78,7 +77,7 @@ export type BulkDeleteArgsRaw = {
|
|
|
78
77
|
*/
|
|
79
78
|
target: import("../config/objectCrud.js").TargetArgs;
|
|
80
79
|
/**
|
|
81
|
-
* The
|
|
80
|
+
* The pks of the objects to be deleted.
|
|
82
81
|
*/
|
|
83
82
|
pks: import("./commonCrud.js").Pk[];
|
|
84
83
|
/**
|
|
@@ -107,7 +106,7 @@ export type ListSubscribeArgsRaw = {
|
|
|
107
106
|
*/
|
|
108
107
|
pkKey: string;
|
|
109
108
|
/**
|
|
110
|
-
*
|
|
109
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
111
110
|
*/
|
|
112
111
|
params: object;
|
|
113
112
|
/**
|
|
@@ -115,8 +114,7 @@ export type ListSubscribeArgsRaw = {
|
|
|
115
114
|
*/
|
|
116
115
|
applyObjectEvent: applyObjectEvent;
|
|
117
116
|
/**
|
|
118
|
-
* A ref
|
|
119
|
-
* been cancelled.
|
|
117
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
120
118
|
*/
|
|
121
119
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
122
120
|
};
|
|
@@ -133,7 +131,7 @@ export type ExecuteActionArgsRaw = {
|
|
|
133
131
|
*/
|
|
134
132
|
target: import("../config/objectCrud.js").TargetArgs;
|
|
135
133
|
/**
|
|
136
|
-
* The
|
|
134
|
+
* The pks of the objects to be acted upon.
|
|
137
135
|
*/
|
|
138
136
|
pks: import("./commonCrud.js").Pk[];
|
|
139
137
|
/**
|
|
@@ -48,13 +48,13 @@ export type CreateArgsRaw = {
|
|
|
48
48
|
*/
|
|
49
49
|
target: TargetArgs;
|
|
50
50
|
/**
|
|
51
|
-
* The
|
|
51
|
+
* The new object to create; it carries no primary key yet.
|
|
52
52
|
*/
|
|
53
53
|
object: {
|
|
54
54
|
[key: string]: any;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
58
58
|
*/
|
|
59
59
|
params: {
|
|
60
60
|
[key: string]: any;
|
|
@@ -64,7 +64,7 @@ export type CreateArgsRaw = {
|
|
|
64
64
|
*/
|
|
65
65
|
pkKey: string;
|
|
66
66
|
/**
|
|
67
|
-
* A ref
|
|
67
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
68
68
|
*/
|
|
69
69
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
70
70
|
};
|
|
@@ -89,13 +89,13 @@ export type RetrieveArgsRaw = {
|
|
|
89
89
|
*/
|
|
90
90
|
pkKey: string;
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
93
93
|
*/
|
|
94
94
|
params: {
|
|
95
95
|
[key: string]: any;
|
|
96
96
|
};
|
|
97
97
|
/**
|
|
98
|
-
* A ref
|
|
98
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
99
99
|
*/
|
|
100
100
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
101
101
|
};
|
|
@@ -112,11 +112,11 @@ export type UpdateArgsRaw = {
|
|
|
112
112
|
*/
|
|
113
113
|
target: TargetArgs;
|
|
114
114
|
/**
|
|
115
|
-
* The
|
|
115
|
+
* The complete object to update; its primary key rides inside it, at `object[pkKey]`.
|
|
116
116
|
*/
|
|
117
117
|
object: import("../use/objectInstance.js").ExistingCrudObject;
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
119
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
120
120
|
*/
|
|
121
121
|
params: {
|
|
122
122
|
[key: string]: any;
|
|
@@ -126,7 +126,7 @@ export type UpdateArgsRaw = {
|
|
|
126
126
|
*/
|
|
127
127
|
pkKey: string;
|
|
128
128
|
/**
|
|
129
|
-
* A ref
|
|
129
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
130
130
|
*/
|
|
131
131
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
132
132
|
};
|
|
@@ -151,7 +151,7 @@ export type DeleteArgsRaw = {
|
|
|
151
151
|
*/
|
|
152
152
|
pkKey: string;
|
|
153
153
|
/**
|
|
154
|
-
* A ref
|
|
154
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
155
155
|
*/
|
|
156
156
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
157
157
|
};
|
|
@@ -176,19 +176,19 @@ export type PartialArgsRaw = {
|
|
|
176
176
|
*/
|
|
177
177
|
pkKey: string;
|
|
178
178
|
/**
|
|
179
|
-
* The
|
|
179
|
+
* The changed fields only.
|
|
180
180
|
*/
|
|
181
181
|
partialObject: {
|
|
182
182
|
[key: string]: any;
|
|
183
183
|
};
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
185
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
186
186
|
*/
|
|
187
187
|
params: {
|
|
188
188
|
[key: string]: any;
|
|
189
189
|
};
|
|
190
190
|
/**
|
|
191
|
-
* A ref
|
|
191
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
192
192
|
*/
|
|
193
193
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
194
194
|
};
|
|
@@ -203,11 +203,11 @@ export type ObjectExecuteActionArgsRaw = {
|
|
|
203
203
|
/**
|
|
204
204
|
* The arguments to be passed to the crud handlers.
|
|
205
205
|
*/
|
|
206
|
-
target:
|
|
206
|
+
target: TargetArgs;
|
|
207
207
|
/**
|
|
208
|
-
* The
|
|
208
|
+
* The pk of the object to be acted upon.
|
|
209
209
|
*/
|
|
210
|
-
pk:
|
|
210
|
+
pk: import("./commonCrud.js").Pk;
|
|
211
211
|
/**
|
|
212
212
|
* The key name of the primary key.
|
|
213
213
|
*/
|
|
@@ -217,7 +217,7 @@ export type ObjectExecuteActionArgsRaw = {
|
|
|
217
217
|
*/
|
|
218
218
|
action: string;
|
|
219
219
|
/**
|
|
220
|
-
* A ref
|
|
220
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
221
221
|
*/
|
|
222
222
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
223
223
|
};
|
|
@@ -246,7 +246,7 @@ export type ObjectSubscribeArgsRaw = {
|
|
|
246
246
|
*/
|
|
247
247
|
pkKey: string;
|
|
248
248
|
/**
|
|
249
|
-
*
|
|
249
|
+
* Your listing or retrieval arguments, passed through to the crud handlers.
|
|
250
250
|
*/
|
|
251
251
|
params: {
|
|
252
252
|
[key: string]: any;
|
|
@@ -256,7 +256,7 @@ export type ObjectSubscribeArgsRaw = {
|
|
|
256
256
|
*/
|
|
257
257
|
callback: CrudSubscribeCallback;
|
|
258
258
|
/**
|
|
259
|
-
* A ref
|
|
259
|
+
* A readonly ref that becomes true once the request is cancelled.
|
|
260
260
|
*/
|
|
261
261
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
262
262
|
};
|
|
@@ -265,9 +265,20 @@ export type ObjectSubscribeArgsRaw = {
|
|
|
265
265
|
*/
|
|
266
266
|
export type ObjectSubscribeArgs = ObjectSubscribeArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking & AdditionalCrudArgs;
|
|
267
267
|
/**
|
|
268
|
-
*
|
|
268
|
+
* -
|
|
269
|
+
* The value returned by an object CRUD handler whose resolved value becomes the record: create, retrieve, update, and
|
|
270
|
+
* patch. A possibly-cancellable promise resolving to the complete record. The instance mirrors the resolved value
|
|
271
|
+
* into `state.object`, so a partial record drops the fields it omits, and a resolved value that is not an object (a
|
|
272
|
+
* bare primary key string, for instance) fails the assignment and is stored in `state.error`.
|
|
273
|
+
*/
|
|
274
|
+
export type CrudResponse = import("../utils/cancellablePromise.js").MaybeCancellablePromise<object>;
|
|
275
|
+
/**
|
|
276
|
+
* -
|
|
277
|
+
* The value returned by an object CRUD handler whose resolved value is ignored: delete, and executeAction. A
|
|
278
|
+
* possibly-cancellable promise whose resolution signals success and nothing more, so it may resolve a record, a
|
|
279
|
+
* primary key string, or nothing at all.
|
|
269
280
|
*/
|
|
270
|
-
export type
|
|
281
|
+
export type CrudCompletionResponse = import("../utils/cancellablePromise.js").MaybeCancellablePromise<object | string | void>;
|
|
271
282
|
/**
|
|
272
283
|
* Signature for the handler that creates an object in the backing store.
|
|
273
284
|
*/
|
|
@@ -287,11 +298,11 @@ export type CrudPatchFn = (args: PartialArgs) => CrudResponse;
|
|
|
287
298
|
/**
|
|
288
299
|
* Signature for the handler that deletes an object from the backing store.
|
|
289
300
|
*/
|
|
290
|
-
export type CrudDeleteFn = (args: DeleteArgs) =>
|
|
301
|
+
export type CrudDeleteFn = (args: DeleteArgs) => CrudCompletionResponse;
|
|
291
302
|
/**
|
|
292
303
|
* Signature for the handler that executes an action on a single object in the backing store.
|
|
293
304
|
*/
|
|
294
|
-
export type CrudObjectExecuteActionFn = (args: ObjectExecuteActionArgs) =>
|
|
305
|
+
export type CrudObjectExecuteActionFn = (args: ObjectExecuteActionArgs) => CrudCompletionResponse;
|
|
295
306
|
/**
|
|
296
307
|
* Signature for the handler that subscribes to changes on a single object in the backing store.
|
|
297
308
|
*/
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export namespace benchmarkOptions {
|
|
2
|
+
let iterations: number;
|
|
3
|
+
let time: number;
|
|
4
|
+
let warmupIterations: number;
|
|
5
|
+
let warmupTime: number;
|
|
6
|
+
}
|
|
7
|
+
export function makeRows(count: number, start?: number): {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
}[];
|
|
11
|
+
export function makeRichRows(count: number, start?: number): {
|
|
12
|
+
id: number;
|
|
13
|
+
name: string;
|
|
14
|
+
organization: number;
|
|
15
|
+
}[];
|
|
16
|
+
/** Related objects the populated related rule resolves against. */
|
|
17
|
+
export const relatedOrganizations: {
|
|
18
|
+
[k: string]: {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export namespace emptyRules {
|
|
24
|
+
let allowedFilter: any;
|
|
25
|
+
let calculatedObjectsRules: {};
|
|
26
|
+
let excludedFilter: any;
|
|
27
|
+
let orderByRules: any[];
|
|
28
|
+
let relatedObjectsRules: {};
|
|
29
|
+
let textSearchRules: any[];
|
|
30
|
+
let textSearchValue: string;
|
|
31
|
+
}
|
|
32
|
+
export namespace populatedRules {
|
|
33
|
+
export function allowedFilter_1(object: any): boolean;
|
|
34
|
+
export { allowedFilter_1 as allowedFilter };
|
|
35
|
+
export namespace calculatedObjectsRules_1 {
|
|
36
|
+
function doubled(object: any): number;
|
|
37
|
+
}
|
|
38
|
+
export { calculatedObjectsRules_1 as calculatedObjectsRules };
|
|
39
|
+
let excludedFilter_1: any;
|
|
40
|
+
export { excludedFilter_1 as excludedFilter };
|
|
41
|
+
let orderByRules_1: {
|
|
42
|
+
key: string;
|
|
43
|
+
desc: boolean;
|
|
44
|
+
localeCompare: boolean;
|
|
45
|
+
}[];
|
|
46
|
+
export { orderByRules_1 as orderByRules };
|
|
47
|
+
export namespace relatedObjectsRules_1 {
|
|
48
|
+
namespace org {
|
|
49
|
+
export let pkKey: string;
|
|
50
|
+
export { relatedOrganizations as objects };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export { relatedObjectsRules_1 as relatedObjectsRules };
|
|
54
|
+
let textSearchRules_1: any[];
|
|
55
|
+
export { textSearchRules_1 as textSearchRules };
|
|
56
|
+
let textSearchValue_1: string;
|
|
57
|
+
export { textSearchValue_1 as textSearchValue };
|
|
58
|
+
}
|
|
59
|
+
export function makeList(rules?: object): ReturnType<typeof useList>;
|
|
60
|
+
import { useList } from "../../use/list.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -57,12 +57,19 @@
|
|
|
57
57
|
/**
|
|
58
58
|
* Calls your awaitable function with the arguments you pass in when the watch arguments change and are all truthy.
|
|
59
59
|
* Watch arguments should be a reactive object.
|
|
60
|
-
*
|
|
60
|
+
*
|
|
61
|
+
* If the watch arguments change again before the promise resolves, the in-flight promise is cancelled only when it
|
|
62
|
+
* carries a `cancel` method (a `MaybeCancellablePromise`); a plain promise is left to run to completion. That
|
|
63
|
+
* distinction is visible through the composables built on this one. `useObjectSubscription` calls
|
|
64
|
+
* `objectInstance.retrieve()` again for the new key, and that call returns the promise already in flight for the
|
|
65
|
+
* previous key, so the stale record is assigned and the new key is never fetched. `useListSubscription` guards its
|
|
66
|
+
* list intent on the list's own loading state, so the superseded run is left to finish and the list is then listed
|
|
67
|
+
* again with the current arguments.
|
|
61
68
|
*
|
|
62
69
|
* @example
|
|
63
70
|
* ```vue
|
|
64
71
|
* <script setup>
|
|
65
|
-
* import { useCancellableIntent } from "@
|
|
72
|
+
* import { useCancellableIntent } from "@arrai-innovations/reactive-helpers";
|
|
66
73
|
* import { ref, computed, onMounted, onUnmounted } from "vue";
|
|
67
74
|
*
|
|
68
75
|
* const myValue = ref(0);
|