@arrai-innovations/reactive-helpers 18.1.0 → 20.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.
- package/README.md +51 -54
- package/config/commonCrud.js +75 -0
- package/config/listCrud.js +69 -70
- package/config/objectCrud.js +61 -110
- package/index.js +3 -1
- package/package.json +5 -4
- package/types/config/commonCrud.d.ts +19 -0
- package/types/config/commonCrud.d.ts.map +1 -0
- package/types/config/listCrud.d.ts +59 -62
- package/types/config/listCrud.d.ts.map +1 -1
- package/types/config/objectCrud.d.ts +51 -55
- package/types/config/objectCrud.d.ts.map +1 -1
- package/types/index.d.ts +3 -1
- package/types/use/cancellableIntent.d.ts +43 -7
- package/types/use/cancellableIntent.d.ts.map +1 -1
- package/types/use/list.d.ts +8 -12
- package/types/use/list.d.ts.map +1 -1
- package/types/use/listCalculated.d.ts +2 -3
- package/types/use/listCalculated.d.ts.map +1 -1
- package/types/use/listInstance.d.ts +22 -35
- package/types/use/listInstance.d.ts.map +1 -1
- package/types/use/listKeys.d.ts.map +1 -1
- package/types/use/listRelated.d.ts +2 -5
- package/types/use/listRelated.d.ts.map +1 -1
- package/types/use/listSort.d.ts +2 -3
- package/types/use/listSort.d.ts.map +1 -1
- package/types/use/listSubscription.d.ts +3 -6
- package/types/use/listSubscription.d.ts.map +1 -1
- package/types/use/object.d.ts +4 -4
- package/types/use/object.d.ts.map +1 -1
- package/types/use/objectCalculated.d.ts +2 -2
- package/types/use/objectInstance.d.ts +22 -22
- package/types/use/objectInstance.d.ts.map +1 -1
- package/types/use/objectRelated.d.ts +2 -2
- package/types/use/objectSubscription.d.ts +7 -7
- package/types/use/objectSubscription.d.ts.map +1 -1
- package/types/utils/refIfReactive.d.ts +2 -0
- package/types/utils/refIfReactive.d.ts.map +1 -0
- package/types/utils/unwrapNested.d.ts +2 -0
- package/types/utils/unwrapNested.d.ts.map +1 -0
- package/use/cancellableIntent.js +24 -16
- package/use/list.js +16 -20
- package/use/listCalculated.js +2 -3
- package/use/listInstance.js +42 -49
- package/use/listKeys.js +1 -2
- package/use/listRelated.js +2 -5
- package/use/listSort.js +2 -3
- package/use/listSubscription.js +14 -23
- package/use/object.js +6 -6
- package/use/objectCalculated.js +2 -2
- package/use/objectInstance.js +34 -34
- package/use/objectRelated.js +2 -2
- package/use/objectSubscription.js +18 -18
- package/utils/refIfReactive.js +18 -0
- package/utils/unwrapNested.js +25 -0
package/config/objectCrud.js
CHANGED
|
@@ -1,100 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assignCrud, createDefaultCrud } from "./commonCrud.js";
|
|
2
2
|
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
3
|
-
import
|
|
4
|
-
import { isReactive, readonly, toRef } from "vue";
|
|
5
|
-
import { CancellablePromise } from "../utils/cancellablePromise.js";
|
|
3
|
+
import { readonly } from "vue";
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
* Configuration for the default object crud
|
|
6
|
+
* Configuration for the default object crud handlers.
|
|
9
7
|
*
|
|
10
8
|
* @module config/objectCrud.js
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
|
-
* @
|
|
15
|
-
* @param {string} name - The name of the method.
|
|
16
|
-
* @returns {(...args:any[]) => import('../utils/cancellablePromise.js')
|
|
17
|
-
* .MaybeCancellablePromise<T>} - A function that returns a rejected promise with an error message.
|
|
18
|
-
*/
|
|
19
|
-
const missingMethod = (name) => () => {
|
|
20
|
-
return CancellablePromise.reject(new Error(`Crud method "${name}" is not implemented.`));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @template T
|
|
25
|
-
* @param {string} name - The name of the method.
|
|
26
|
-
* @returns {(...args:any[]) => import('../utils/cancellablePromise.js')
|
|
27
|
-
* .CancellablePromise<T>} - A function that returns a rejected promise with an error message.
|
|
28
|
-
*/
|
|
29
|
-
const requiredCancelMissingMethod = (name) => () => {
|
|
30
|
-
return CancellablePromise(
|
|
31
|
-
new Promise(() => {
|
|
32
|
-
return Promise.reject(new Error(`Crud method "${name}" is not implemented.`));
|
|
33
|
-
}),
|
|
34
|
-
() => {
|
|
35
|
-
// do nothing
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @typedef {{[key:string]: any}} ObjectCrudArgsArgs
|
|
12
|
+
* @typedef {{[key:string]: any}} ObjectTargetArgs
|
|
42
13
|
*/
|
|
43
14
|
|
|
44
15
|
/**
|
|
45
|
-
* Defines the CRUD-related
|
|
16
|
+
* Defines the CRUD-related handlers and additional utilities provided by the object instance.
|
|
46
17
|
*
|
|
47
|
-
* @typedef {object}
|
|
48
|
-
* @property {
|
|
18
|
+
* @typedef {object} ObjectTargetProperties
|
|
19
|
+
* @property {ObjectTargetArgs} args - The arguments to be passed to the crud handlers.
|
|
49
20
|
*/
|
|
50
21
|
|
|
51
22
|
/**
|
|
52
|
-
* @typedef {object}
|
|
53
|
-
* @property {
|
|
23
|
+
* @typedef {object} ObjectTargetOption
|
|
24
|
+
* @property {ObjectTargetArgs} [target={}] - The arguments to be passed to the crud handlers.
|
|
54
25
|
*/
|
|
55
26
|
|
|
56
27
|
/**
|
|
57
|
-
* @typedef {object}
|
|
58
|
-
* @property {{[key:string]: any}}
|
|
28
|
+
* @typedef {object} CreateArgs
|
|
29
|
+
* @property {{[key:string]: any}} target - The arguments to be passed to the crud handlers.
|
|
59
30
|
* @property {{[key:string]: any}} object - The data to be acted upon.
|
|
60
|
-
* @property {{[key:string]: any}}
|
|
31
|
+
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
61
32
|
* @property {string} pkKey - The key name of the primary key.
|
|
62
33
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
63
34
|
*/
|
|
64
35
|
|
|
65
36
|
/**
|
|
66
|
-
* @typedef {object}
|
|
67
|
-
* @property {{[key:string]: any}}
|
|
37
|
+
* @typedef {object} RetrieveArgs
|
|
38
|
+
* @property {{[key:string]: any}} target - The arguments to be passed to the crud handlers.
|
|
68
39
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
69
40
|
* @property {string} pkKey - The key name of the primary key.
|
|
70
|
-
* @property {{[key:string]: any}}
|
|
41
|
+
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
71
42
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
72
43
|
*/
|
|
73
44
|
|
|
74
45
|
/**
|
|
75
|
-
* @typedef {object}
|
|
76
|
-
* @property {{[key:string]: any}}
|
|
46
|
+
* @typedef {object} UpdateArgs
|
|
47
|
+
* @property {{[key:string]: any}} target - The arguments to be passed to the crud handlers.
|
|
77
48
|
* @property {import('../use/objectInstance.js').ExistingCrudObject} object - The data to be acted upon.
|
|
78
|
-
* @property {{[key:string]: any}}
|
|
49
|
+
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
79
50
|
* @property {string} pkKey - The key name of the primary key.
|
|
80
51
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
81
52
|
*/
|
|
82
53
|
|
|
83
54
|
/**
|
|
84
|
-
* @typedef {object}
|
|
85
|
-
* @property {{[key:string]: any}}
|
|
55
|
+
* @typedef {object} DeleteArgs
|
|
56
|
+
* @property {{[key:string]: any}} target - The arguments to be passed to the crud handlers.
|
|
86
57
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
87
58
|
* @property {string} pkKey - The key name of the primary key.
|
|
88
59
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
89
60
|
*/
|
|
90
61
|
|
|
91
62
|
/**
|
|
92
|
-
* @typedef {object}
|
|
93
|
-
* @property {{[key:string]: any}}
|
|
63
|
+
* @typedef {object} PartialArgs
|
|
64
|
+
* @property {{[key:string]: any}} target - The arguments to be passed to the crud handlers.
|
|
94
65
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
95
66
|
* @property {string} pkKey - The key name of the primary key.
|
|
96
67
|
* @property {{[key:string]: any}} partialObject - The data to be acted upon.
|
|
97
|
-
* @property {{[key:string]: any}}
|
|
68
|
+
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
98
69
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
99
70
|
*/
|
|
100
71
|
|
|
@@ -105,11 +76,11 @@ const requiredCancelMissingMethod = (name) => () => {
|
|
|
105
76
|
*/
|
|
106
77
|
|
|
107
78
|
/**
|
|
108
|
-
* @typedef {object}
|
|
109
|
-
* @property {{[key:string]: any}}
|
|
79
|
+
* @typedef {object} ObjectSubscribeArgs
|
|
80
|
+
* @property {{[key:string]: any}} target - The arguments to be passed to the crud handlers.
|
|
110
81
|
* @property {string} pk - The pk of the object to be acted upon.
|
|
111
82
|
* @property {string} pkKey - The key name of the primary key.
|
|
112
|
-
* @property {{[key:string]: any}}
|
|
83
|
+
* @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
|
|
113
84
|
* @property {CrudSubscribeCallback} callback - The callback to be called when the object is updated.
|
|
114
85
|
* @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
|
|
115
86
|
*/
|
|
@@ -120,116 +91,96 @@ const requiredCancelMissingMethod = (name) => () => {
|
|
|
120
91
|
|
|
121
92
|
/**
|
|
122
93
|
* @callback CrudCreateFn
|
|
123
|
-
* @param {
|
|
94
|
+
* @param {CreateArgs} args - The arguments to be passed to the create function.
|
|
124
95
|
* @returns {CrudResponse} - The response data from the create function.
|
|
125
96
|
*/
|
|
126
97
|
|
|
127
98
|
/**
|
|
128
99
|
* @callback CrudRetrieveFn
|
|
129
|
-
* @param {
|
|
100
|
+
* @param {RetrieveArgs} args - The arguments to be passed to the retrieve function.
|
|
130
101
|
* @returns {CrudResponse} - The response data from the retrieve function.
|
|
131
102
|
*/
|
|
132
103
|
|
|
133
104
|
/**
|
|
134
105
|
* @callback CrudUpdateFn
|
|
135
|
-
* @param {
|
|
106
|
+
* @param {UpdateArgs} args - The arguments to be passed to the update function.
|
|
136
107
|
* @returns {CrudResponse} - The response data from the update function.
|
|
137
108
|
*/
|
|
138
109
|
|
|
139
110
|
/**
|
|
140
111
|
* @callback CrudPatchFn
|
|
141
|
-
* @param {
|
|
112
|
+
* @param {PartialArgs} args - The arguments to be passed to the patch function.
|
|
142
113
|
* @returns {CrudResponse} - The response data from the patch function.
|
|
143
114
|
*/
|
|
144
115
|
|
|
145
116
|
/**
|
|
146
117
|
* @callback CrudDeleteFn
|
|
147
|
-
* @param {
|
|
118
|
+
* @param {DeleteArgs} args - The arguments to be passed to the delete function.
|
|
148
119
|
* @returns {CrudResponse} - The response data from the delete function.
|
|
149
120
|
*/
|
|
150
121
|
|
|
151
122
|
/**
|
|
152
|
-
* @callback
|
|
153
|
-
* @param {
|
|
123
|
+
* @callback CrudObjectSubscribeFn
|
|
124
|
+
* @param {ObjectSubscribeArgs} args - The arguments to be passed to the subscribe function.
|
|
154
125
|
* @returns {import('../utils/cancellablePromise.js').CancellablePromise<void>} - The cancellable promise.
|
|
155
126
|
*/
|
|
156
127
|
|
|
157
128
|
/**
|
|
158
|
-
* Defines the CRUD-related
|
|
129
|
+
* Defines the CRUD-related handlers and additional utilities provided by the object instance.
|
|
159
130
|
*
|
|
160
|
-
* @typedef {object}
|
|
131
|
+
* @typedef {object} ObjectCrudHandlers
|
|
161
132
|
* @property {CrudCreateFn} [create] - A function to be used instead of the default crud create function.
|
|
162
133
|
* @property {CrudRetrieveFn} [retrieve] - A function to be used instead of the default crud retrieve function.
|
|
163
134
|
* @property {CrudUpdateFn} [update] - A function to be used instead of the default crud update function.
|
|
164
135
|
* @property {CrudDeleteFn} [delete] - A function to be used instead of the default crud delete function.
|
|
165
136
|
* @property {CrudPatchFn} [patch] - A function to be used instead of the default crud patch function.
|
|
166
|
-
* @property {
|
|
137
|
+
* @property {CrudObjectSubscribeFn} [subscribe] - A function to be used instead of the default crud subscribe function.
|
|
167
138
|
*/
|
|
168
139
|
|
|
169
140
|
/**
|
|
170
141
|
* The CRUD arguments.
|
|
171
142
|
*
|
|
172
|
-
* @typedef {
|
|
143
|
+
* @typedef {ObjectTargetProperties & ObjectCrudHandlers} ObjectTarget
|
|
173
144
|
*
|
|
174
145
|
*/
|
|
175
146
|
|
|
176
|
-
const _defaultCrud =
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
update: /** @type {CrudUpdateFn} */ missingMethod("update"),
|
|
181
|
-
patch: /** @type {CrudPatchFn} */ missingMethod("patch"),
|
|
182
|
-
delete: /** @type {CrudDeleteFn} */ missingMethod("delete"),
|
|
183
|
-
subscribe: /** @type {CrudSubscribeFn} */ requiredCancelMissingMethod("subscribe"),
|
|
184
|
-
};
|
|
147
|
+
const _defaultCrud = createDefaultCrud(
|
|
148
|
+
["retrieve", "create", "update", "patch", "delete", "subscribe"],
|
|
149
|
+
new Set(["subscribe"])
|
|
150
|
+
);
|
|
185
151
|
|
|
186
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The default object crud handlers.
|
|
154
|
+
*
|
|
155
|
+
* @type {Readonly<ObjectCrudHandlers>}
|
|
156
|
+
*/
|
|
157
|
+
export const defaultObjectCrud = readonly(_defaultCrud);
|
|
187
158
|
|
|
188
159
|
/**
|
|
189
|
-
* Set the object crud
|
|
160
|
+
* Set the object crud handlers.
|
|
190
161
|
*
|
|
191
|
-
* @param {
|
|
162
|
+
* @param {ObjectTarget} options - The options for the object crud handlers.
|
|
192
163
|
* @throws {Error} - if unknown keys are passed.
|
|
193
164
|
*/
|
|
194
|
-
export const setObjectCrud = ({
|
|
195
|
-
_defaultCrud.retrieve = retrieve ?? missingMethod("retrieve");
|
|
196
|
-
_defaultCrud.create = create ?? missingMethod("create");
|
|
197
|
-
_defaultCrud.update = update ?? missingMethod("update");
|
|
198
|
-
_defaultCrud.patch = patch ?? missingMethod("patch");
|
|
199
|
-
_defaultCrud.delete = deleteFn ?? missingMethod("delete");
|
|
200
|
-
_defaultCrud.subscribe = subscribe ?? requiredCancelMissingMethod("subscribe");
|
|
201
|
-
// defensive cloning
|
|
165
|
+
export const setObjectCrud = ({ args = {}, ...rest }) => {
|
|
202
166
|
Object.assign(_defaultCrud.args, cloneDeep(args));
|
|
203
|
-
|
|
204
|
-
|
|
167
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
168
|
+
if (!(key in _defaultCrud)) {
|
|
169
|
+
throw new Error(`Unknown key "${key}" passed to setObjectCrud`);
|
|
170
|
+
}
|
|
171
|
+
_defaultCrud[key] = value ?? _defaultCrud[key];
|
|
205
172
|
}
|
|
206
173
|
};
|
|
207
174
|
|
|
208
175
|
/**
|
|
209
|
-
* Get the previously set object crud
|
|
176
|
+
* Get the previously set object crud handlers.
|
|
210
177
|
*
|
|
211
|
-
* @param {import("vue").UnwrapNestedRefs<
|
|
178
|
+
* @param {import("vue").UnwrapNestedRefs<ObjectTargetProperties>} target - The reactive object you want to add the resulting crud to.
|
|
212
179
|
* @param {object} options - The options for the reactive crud object.
|
|
213
|
-
* @param {import("vue").UnwrapNestedRefs<
|
|
214
|
-
* @param {
|
|
180
|
+
* @param {import("vue").UnwrapNestedRefs<ObjectTargetOption>} [options.props] - The props with any passed target.
|
|
181
|
+
* @param {ObjectCrudHandlers} [options.handlers] - Any functions to override the default crud functions.
|
|
215
182
|
* @throws {Error} - If an invalid function is passed, or if the function is not a function.
|
|
216
183
|
*/
|
|
217
|
-
export const getObjectCrud = (
|
|
218
|
-
|
|
219
|
-
Object.assign(reactiveCrud, cloneDeep(_defaultCrud));
|
|
220
|
-
if (props?.crudArgs) {
|
|
221
|
-
addOrUpdateReactiveObject(reactiveCrud.args, props.crudArgs);
|
|
222
|
-
}
|
|
223
|
-
if (functions) {
|
|
224
|
-
for (const [key, value] of Object.entries(functions)) {
|
|
225
|
-
if (isFunction(value) && key in reactiveCrud) {
|
|
226
|
-
reactiveCrud[key] = isReactive(functions)
|
|
227
|
-
? // @ts-ignore - key is a keyof ObjectCrudFunctions...
|
|
228
|
-
toRef(functions, key)
|
|
229
|
-
: value;
|
|
230
|
-
} else {
|
|
231
|
-
throw Error(`Invalid function "${key}" for getObjectCrud: invalid key or not a function.`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
184
|
+
export const getObjectCrud = (target, options) => {
|
|
185
|
+
assignCrud(target, _defaultCrud, options);
|
|
235
186
|
};
|
package/index.js
CHANGED
|
@@ -5,9 +5,9 @@ export * from "./use/cancellableIntent.js";
|
|
|
5
5
|
export * from "./use/combineClasses.js";
|
|
6
6
|
export * from "./use/list.js";
|
|
7
7
|
export * from "./use/listCalculated.js";
|
|
8
|
-
export * from "./use/listKeys.js";
|
|
9
8
|
export * from "./use/listFilter.js";
|
|
10
9
|
export * from "./use/listInstance.js";
|
|
10
|
+
export * from "./use/listKeys.js";
|
|
11
11
|
export * from "./use/listRelated.js";
|
|
12
12
|
export * from "./use/listSearch.js";
|
|
13
13
|
export * from "./use/listSort.js";
|
|
@@ -34,7 +34,9 @@ export * from "./utils/getFakePk.js";
|
|
|
34
34
|
export * from "./utils/keepAliveTry.js";
|
|
35
35
|
export * from "./utils/keyDiff.js";
|
|
36
36
|
export * from "./utils/loadingCombine.js";
|
|
37
|
+
export * from "./utils/refIfReactive.js";
|
|
37
38
|
export * from "./utils/relatedCalculatedHelpers.js";
|
|
38
39
|
export * from "./utils/set.js";
|
|
39
40
|
export * from "./utils/transformWalk.js";
|
|
41
|
+
export * from "./utils/unwrapNested.js";
|
|
40
42
|
export * from "./utils/watches.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrai-innovations/reactive-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0",
|
|
4
4
|
"description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"prettier": "npx --no-install prettier --write .",
|
|
31
31
|
"coverage": "npm test -- run --coverage=true",
|
|
32
32
|
"prepare": "npx --no-install husky",
|
|
33
|
-
"docs": "node make_type_doc.js"
|
|
33
|
+
"docs": "node make_type_doc.js",
|
|
34
|
+
"docs:check": "node check_type_doc.js"
|
|
34
35
|
},
|
|
35
36
|
"repository": {
|
|
36
37
|
"type": "git",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"@types/lodash-es": "^4.17.12",
|
|
52
53
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
53
54
|
"@typescript-eslint/parser": "^7.18.0",
|
|
54
|
-
"@vitest/coverage-v8": "^3.
|
|
55
|
+
"@vitest/coverage-v8": "^3.1.2",
|
|
55
56
|
"@vue/compiler-sfc": "^3.4.37",
|
|
56
57
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
57
58
|
"@vue/test-utils": "^2.3.2",
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"typedoc": "^0.27.1",
|
|
71
72
|
"typedoc-plugin-markdown": "^4.3.0",
|
|
72
73
|
"typescript": "^5.5.4",
|
|
73
|
-
"vitest": "^3.
|
|
74
|
+
"vitest": "^3.1.2"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
77
|
"@jcoreio/async-throttle": "^1.6.0",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assigns the default CRUD handlers to the target object.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} target - The reactive object to assign to.
|
|
5
|
+
* @param {object} defaultCrud - The default CRUD definition (usually created by `createDefaultCrud`).
|
|
6
|
+
* @param {object} [options] - The options object.
|
|
7
|
+
* @param {object} [options.props] - The props object.
|
|
8
|
+
* @param {object} [options.handlers] - The functions to assign.
|
|
9
|
+
* @param {Set<string>} [options.validKeys] - The valid keys for the handlers.
|
|
10
|
+
*/
|
|
11
|
+
export function assignCrud(target: object, defaultCrud: object, { props, handlers, validKeys }?: {
|
|
12
|
+
props?: object;
|
|
13
|
+
handlers?: object;
|
|
14
|
+
validKeys?: Set<string>;
|
|
15
|
+
}): void;
|
|
16
|
+
export function missingMethod(name: string): (...args: any[]) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<any>;
|
|
17
|
+
export function requiredCancelMissingMethod(name: string): ((..._args: any[]) => import("../utils/cancellablePromise.js").CancellablePromise<void>);
|
|
18
|
+
export function createDefaultCrud(keys: string[], cancellableKeys?: Set<string>): object;
|
|
19
|
+
//# sourceMappingURL=commonCrud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonCrud.d.ts","sourceRoot":"","sources":["../../config/commonCrud.js"],"names":[],"mappings":"AA4CA;;;;;;;;;GASG;AACH,mCAPW,MAAM,eACN,MAAM,mCAEd;IAAyB,KAAK,GAAtB,MAAM;IACW,QAAQ,GAAzB,MAAM;IACgB,SAAS,GAA/B,GAAG,CAAC,MAAM,CAAC;CACrB,QAqBA;AAhEM,oCAHI,MAAM,GACJ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,GAAG,CAAC,CAGjB;AAU9E,kDALI,MAAM,GACJ,CACZ,CAAO,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,OAAO,gCAAgC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CACzF,CAOwG;AAUrG,wCAJI,MAAM,EAAE,oBACR,GAAG,CAAC,MAAM,CAAC,GACT,MAAM,CAQlB"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The default list crud handlers.
|
|
3
|
+
*
|
|
4
|
+
* @type {Readonly<ListCrudHandlers>}
|
|
5
|
+
*/
|
|
6
|
+
export const defaultListCrud: Readonly<ListCrudHandlers>;
|
|
7
|
+
export function setListCrud({ args, ...rest }: ListCrudHandlers & Partial<ListTarget>): void;
|
|
8
|
+
export function getListCrud(target: import("vue").UnwrapNestedRefs<ListCrudHandlers & ListTarget>, options: {
|
|
9
|
+
props?: import("vue").UnwrapNestedRefs<ListTargetOption>;
|
|
10
|
+
handlers?: ListCrudHandlers;
|
|
7
11
|
}): void;
|
|
8
12
|
export type PaginateInfo = {
|
|
9
13
|
/**
|
|
@@ -20,23 +24,19 @@ export type PaginateInfo = {
|
|
|
20
24
|
perPage: number;
|
|
21
25
|
};
|
|
22
26
|
export type PageCallback = (newObjects: import("../use/listInstance.js").ListObject, paginationInfo: PaginateInfo | undefined) => void;
|
|
23
|
-
export type
|
|
27
|
+
export type ListArgs = {
|
|
24
28
|
/**
|
|
25
|
-
* - The arguments to be passed to the crud
|
|
29
|
+
* - The arguments to be passed to the crud handlers.
|
|
26
30
|
*/
|
|
27
|
-
|
|
31
|
+
target: object;
|
|
28
32
|
/**
|
|
29
33
|
* - The key name of the primary key.
|
|
30
34
|
*/
|
|
31
35
|
pkKey: string;
|
|
32
36
|
/**
|
|
33
|
-
* - The arguments to be passed
|
|
37
|
+
* - The arguments to be passed for list crud handlers.
|
|
34
38
|
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* - The arguments to be passed for list crud functions.
|
|
38
|
-
*/
|
|
39
|
-
listArgs: object;
|
|
39
|
+
params: object;
|
|
40
40
|
/**
|
|
41
41
|
* - The method to call with new page(s) of data received.
|
|
42
42
|
*/
|
|
@@ -47,11 +47,11 @@ export type ListFnArgs = {
|
|
|
47
47
|
*/
|
|
48
48
|
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
49
49
|
};
|
|
50
|
-
export type
|
|
50
|
+
export type BulkDeleteArgs = {
|
|
51
51
|
/**
|
|
52
|
-
* - The arguments to be passed to the crud
|
|
52
|
+
* - The arguments to be passed to the crud handlers.
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
target: object;
|
|
55
55
|
/**
|
|
56
56
|
* - The ids of the objects to be deleted.
|
|
57
57
|
*/
|
|
@@ -60,35 +60,41 @@ export type DeleteFnArgs = {
|
|
|
60
60
|
* - The key name of the primary key.
|
|
61
61
|
*/
|
|
62
62
|
pkKey: string;
|
|
63
|
+
/**
|
|
64
|
+
* - A ref to a boolean indicating whether the request has
|
|
65
|
+
* been cancelled.
|
|
66
|
+
*/
|
|
67
|
+
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
63
68
|
};
|
|
64
69
|
export type SubscriptionEventCallback = (newOrUpdatedOrDeleteObject: import("../use/listInstance.js").ListObject | string, action: "create" | "update" | "delete") => void;
|
|
65
|
-
export type
|
|
70
|
+
export type ListSubscribeArgs = {
|
|
66
71
|
/**
|
|
67
|
-
* - The arguments to be passed to the crud
|
|
72
|
+
* - The arguments to be passed to the crud handlers.
|
|
68
73
|
*/
|
|
69
|
-
|
|
74
|
+
target: object;
|
|
70
75
|
/**
|
|
71
76
|
* - The key name of the primary key.
|
|
72
77
|
*/
|
|
73
78
|
pkKey: string;
|
|
74
79
|
/**
|
|
75
|
-
* - The arguments to be passed
|
|
80
|
+
* - The arguments to be passed for list crud handlers.
|
|
76
81
|
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* - The arguments to be passed for list crud functions.
|
|
80
|
-
*/
|
|
81
|
-
listArgs: object;
|
|
82
|
+
params: object;
|
|
82
83
|
/**
|
|
83
84
|
* - The method to call when new data is received.
|
|
84
85
|
*/
|
|
85
86
|
subscriptionEventCallback: SubscriptionEventCallback;
|
|
87
|
+
/**
|
|
88
|
+
* - A ref to a boolean indicating whether the request has
|
|
89
|
+
* been cancelled.
|
|
90
|
+
*/
|
|
91
|
+
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
86
92
|
};
|
|
87
|
-
export type
|
|
93
|
+
export type ExecuteActionArgs = {
|
|
88
94
|
/**
|
|
89
|
-
* - The arguments to be passed to the crud
|
|
95
|
+
* - The arguments to be passed to the crud handlers.
|
|
90
96
|
*/
|
|
91
|
-
|
|
97
|
+
target: object;
|
|
92
98
|
/**
|
|
93
99
|
* - The ids of the objects to be acted upon.
|
|
94
100
|
*/
|
|
@@ -101,53 +107,44 @@ export type ExecuteActionFnArgs = {
|
|
|
101
107
|
* - The action to execute.
|
|
102
108
|
*/
|
|
103
109
|
action: string;
|
|
110
|
+
/**
|
|
111
|
+
* - A ref to a boolean indicating whether the request has
|
|
112
|
+
* been cancelled.
|
|
113
|
+
*/
|
|
114
|
+
isCancelled: Readonly<import("vue").Ref<boolean>>;
|
|
104
115
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
export type
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* - The delete function to bulk delete a list of items.
|
|
113
|
-
*/
|
|
114
|
-
export type BulkDeleteFn = (DeleteFnArgs: any) => Promise<boolean> & {
|
|
115
|
-
cancel: () => Promise<void> | void;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* - The subscribe function to set up a subscription to a list of items.
|
|
119
|
-
*/
|
|
120
|
-
export type SubscribeFn = (SubscribeFnArgs: any) => Promise<boolean> & {
|
|
121
|
-
cancel: () => Promise<void> | void;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* - The function to execute a certain action on a list of items, returning the response data or false.
|
|
125
|
-
*/
|
|
126
|
-
export type ExecuteActionFn = (ExecuteActionFnArgs: any) => Promise<import("./objectCrud.js").CrudResponse | false> & {
|
|
127
|
-
cancel: () => Promise<void> | void;
|
|
128
|
-
};
|
|
129
|
-
export type ListCrudFunctions = {
|
|
116
|
+
export type CrudListFn = (args: ListArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
|
|
117
|
+
export type CrudBulkDeleteFn = (args: BulkDeleteArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
|
|
118
|
+
export type CrudListSubscribeFn = (args: ListSubscribeArgs) => import("../utils/cancellablePromise.js").CancellablePromise<void>;
|
|
119
|
+
export type CrudExecuteActionFn = (args: ExecuteActionArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<object | string | null>;
|
|
120
|
+
export type ListCrudHandlers = {
|
|
130
121
|
/**
|
|
131
122
|
* - The list function to get a list of items.
|
|
132
123
|
*/
|
|
133
|
-
list?:
|
|
124
|
+
list?: CrudListFn;
|
|
134
125
|
/**
|
|
135
126
|
* - The delete function to bulk delete a list of items.
|
|
136
127
|
*/
|
|
137
|
-
bulkDelete?:
|
|
128
|
+
bulkDelete?: CrudBulkDeleteFn;
|
|
138
129
|
/**
|
|
139
130
|
* - The function to execute a certain action on a list of items.
|
|
140
131
|
*/
|
|
141
|
-
executeAction?:
|
|
132
|
+
executeAction?: CrudExecuteActionFn;
|
|
142
133
|
/**
|
|
143
134
|
* - The subscribe function to get a subscription to a list of items.
|
|
144
135
|
*/
|
|
145
|
-
subscribe?:
|
|
136
|
+
subscribe?: CrudListSubscribeFn;
|
|
137
|
+
};
|
|
138
|
+
export type ListTarget = {
|
|
139
|
+
/**
|
|
140
|
+
* - The default arguments for the crud handlers.
|
|
141
|
+
*/
|
|
142
|
+
args: object;
|
|
146
143
|
};
|
|
147
|
-
export type
|
|
144
|
+
export type ListTargetOption = {
|
|
148
145
|
/**
|
|
149
|
-
* - The default arguments for the crud
|
|
146
|
+
* - The default arguments for the crud handlers.
|
|
150
147
|
*/
|
|
151
|
-
|
|
148
|
+
target?: object;
|
|
152
149
|
};
|
|
153
150
|
//# sourceMappingURL=listCrud.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listCrud.d.ts","sourceRoot":"","sources":["../../config/listCrud.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listCrud.d.ts","sourceRoot":"","sources":["../../config/listCrud.js"],"names":[],"mappings":"AAkHA;;;;GAIG;AACH,8BAFU,QAAQ,CAAC,gBAAgB,CAAC,CAEkB;AAS/C,+CAJI,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,GAEpC,IAAI,CAUhB;AAWM,oCANI,OAAO,KAAK,EAAE,gBAAgB,CAAC,gBAAgB,GAAG,UAAU,CAAC,WAErE;IAAmE,KAAK,GAAhE,OAAO,KAAK,EAAE,gBAAgB,CAAC,gBAAgB,CAAC;IACrB,QAAQ,GAAnC,gBAAgB;CACxB,QAIF;;;;;kBAzIa,MAAM;;;;gBACN,MAAM;;;;aACN,MAAM;;2BAIP,CACN,UAAU,EAAC,OAAO,wBAAwB,EAAE,UAAU,EACtD,cAAc,EAAE,YAAY,GAAC,SAAS,KACvC,IAAI;;;;;YAKI,MAAM;;;;WACN,MAAM;;;;YACN,MAAM;;;;kBACN,YAAY;;;;;iBACZ,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;;;YAMpC,MAAM;;;;SACN,MAAM,EAAE;;;;WACR,MAAM;;;;;iBACN,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;wCAKrC,CACN,0BAA0B,EAAC,OAAO,wBAAwB,EAAE,UAAU,GAAC,MAAM,EAC7E,MAAM,EAAE,QAAQ,GAAC,QAAQ,GAAC,QAAQ,KACnC,IAAI;;;;;YAKI,MAAM;;;;WACN,MAAM;;;;YACN,MAAM;;;;+BACN,yBAAyB;;;;;iBACzB,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;;;;;YAMpC,MAAM;;;;SACN,MAAM,EAAE;;;;WACR,MAAM;;;;YACN,MAAM;;;;;iBACN,QAAQ,CAAC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;;gCAMvC,QAAQ,KACN,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,IAAI,CAAC;sCAKxE,cAAc,KACZ,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,IAAI,CAAC;yCAKxE,iBAAiB,KACf,OAAO,gCAAgC,EAAE,kBAAkB,CAAC,IAAI,CAAC;yCAKnE,iBAAiB,KACf,OAAO,gCAAgC,EAAE,uBAAuB,CAAC,MAAM,GAAC,MAAM,GAAC,IAAI,CAAC;;;;;WAKnF,UAAU;;;;iBACV,gBAAgB;;;;oBAChB,mBAAmB;;;;gBACnB,mBAAmB;;;;;;UAKnB,MAAM;;;;;;aAKN,MAAM"}
|