@arrai-innovations/reactive-helpers 21.0.1 → 21.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.
Files changed (45) hide show
  1. package/README.md +11 -0
  2. package/config/commonCrud.js +12 -0
  3. package/config/listCrud.js +21 -6
  4. package/config/objectCrud.js +53 -11
  5. package/index.js +3 -0
  6. package/package.json +6 -4
  7. package/types/config/commonCrud.d.ts +8 -0
  8. package/types/config/listCrud.d.ts +14 -6
  9. package/types/config/objectCrud.d.ts +48 -10
  10. package/types/index.d.ts +3 -0
  11. package/types/tests/unit/utils/isReactiveTyped.spec.d.ts +1 -0
  12. package/types/tests/unit/utils/refIfReactive.spec.d.ts +1 -0
  13. package/types/tests/unit/utils/toRefsIfReactive.spec.d.ts +1 -0
  14. package/types/use/cancellableIntent.d.ts +16 -12
  15. package/types/use/error.d.ts +35 -7
  16. package/types/use/listCalculated.d.ts +2 -2
  17. package/types/use/listInstance.d.ts +22 -19
  18. package/types/use/listRelated.d.ts +6 -6
  19. package/types/use/listSubscription.d.ts +12 -3
  20. package/types/use/loading.d.ts +16 -7
  21. package/types/use/loadingError.d.ts +6 -2
  22. package/types/use/objectInstance.d.ts +38 -20
  23. package/types/use/objectSubscription.d.ts +22 -5
  24. package/types/use/proxyError.d.ts +21 -18
  25. package/types/use/proxyLoading.d.ts +18 -8
  26. package/types/use/proxyLoadingError.d.ts +20 -5
  27. package/types/utils/isReactiveTyped.d.ts +6 -0
  28. package/types/utils/refIfReactive.d.ts +2 -1
  29. package/types/utils/toRefsIfReactive.d.ts +14 -0
  30. package/use/cancellableIntent.js +8 -7
  31. package/use/error.js +22 -3
  32. package/use/listCalculated.js +1 -1
  33. package/use/listInstance.js +28 -26
  34. package/use/listRelated.js +3 -3
  35. package/use/listSubscription.js +102 -84
  36. package/use/loading.js +11 -3
  37. package/use/loadingError.js +3 -1
  38. package/use/objectInstance.js +77 -23
  39. package/use/objectSubscription.js +25 -26
  40. package/use/proxyError.js +28 -15
  41. package/use/proxyLoading.js +21 -8
  42. package/use/proxyLoadingError.js +33 -7
  43. package/utils/isReactiveTyped.js +10 -0
  44. package/utils/refIfReactive.js +22 -2
  45. package/utils/toRefsIfReactive.js +28 -0
package/README.md CHANGED
@@ -83,3 +83,14 @@ Since v21.0.0, the changelog is available in the [CHANGELOG.md](./CHANGELOG.md)
83
83
  ```bash
84
84
  $ npm run docs
85
85
  ```
86
+
87
+ 6. Type-only workflows:
88
+
89
+ - Generate types without docs:
90
+ ```bash
91
+ $ npm run types
92
+ ```
93
+ - Smoke-check emitted types without regenerating:
94
+ ```bash
95
+ $ npm run types:check -- --skip-gen
96
+ ```
@@ -4,6 +4,18 @@ import { addOrUpdateReactiveObject } from "../utils/assignReactiveObject.js";
4
4
  import isFunction from "lodash-es/isFunction.js";
5
5
  import { refIfReactive } from "../utils/refIfReactive.js";
6
6
 
7
+ /**
8
+ * Primary key type accepted as input (will be coerced to string).
9
+ *
10
+ * @typedef {string | number} PkInput
11
+ */
12
+
13
+ /**
14
+ * Primary key type used for storage and output (always a string).
15
+ *
16
+ * @typedef {string} Pk
17
+ */
18
+
7
19
  /**
8
20
  * @param {string} name - The name of the method.
9
21
  * @returns {(...args: any[]) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<any>} - A function that returns a rejected promise with an error message.
@@ -19,6 +19,13 @@ import { readonly } from "vue";
19
19
  /**
20
20
  * @typedef {import("../use/listInstance.js").SetColumnTotalsFn} SetColumnTotals
21
21
  */
22
+
23
+ /**
24
+ * Additional arguments that can be passed to list crud handlers.
25
+ *
26
+ * @typedef {{[key:string]: any}} AdditionalListArgs
27
+ */
28
+
22
29
  /**
23
30
  * @typedef {object} ListArgsRaw
24
31
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
@@ -33,16 +40,20 @@ import { readonly } from "vue";
33
40
  */
34
41
 
35
42
  /**
36
- * @typedef {ListArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking>} ListArgs
43
+ * @typedef {ListArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalListArgs} ListArgs
37
44
  */
38
45
 
39
46
  /**
40
- * @typedef {object} BulkDeleteArgs
47
+ * @typedef {object} BulkDeleteArgsRaw
41
48
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
42
- * @property {string[]} pks - The ids of the objects to be deleted.
49
+ * @property {import('./commonCrud.js').Pk[]} pks - The ids of the objects to be deleted.
43
50
  * @property {string} pkKey - The key name of the primary key.
44
51
  */
45
52
 
53
+ /**
54
+ * @typedef {BulkDeleteArgsRaw & AdditionalListArgs} BulkDeleteArgs
55
+ */
56
+
46
57
  /**
47
58
  * @typedef {(
48
59
  * newOrUpdatedOrDeleteObject:import('../use/objectInstance.js').ExistingCrudObject|string,
@@ -61,17 +72,21 @@ import { readonly } from "vue";
61
72
  */
62
73
 
63
74
  /**
64
- * @typedef {ListSubscribeArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking>} ListSubscribeArgs
75
+ * @typedef {ListSubscribeArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalListArgs } ListSubscribeArgs
65
76
  */
66
77
 
67
78
  /**
68
- * @typedef {object} ExecuteActionArgs
79
+ * @typedef {object} ExecuteActionArgsRaw
69
80
  * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
70
- * @property {string[]} pks - The ids of the objects to be acted upon.
81
+ * @property {import('./commonCrud.js').Pk[]} pks - The ids of the objects to be acted upon.
71
82
  * @property {string} pkKey - The key name of the primary key.
72
83
  * @property {string} action - The action to execute.
73
84
  */
74
85
 
86
+ /**
87
+ * @typedef {ExecuteActionArgsRaw & AdditionalListArgs } ExecuteActionArgs
88
+ */
89
+
75
90
  /**
76
91
  * @callback CrudListFn
77
92
  * @param {ListArgs} args - The arguments to be passed to the crud handlers.
@@ -12,6 +12,12 @@ import { readonly } from "vue";
12
12
  * @typedef {{[key:string]: any}} TargetArgs
13
13
  */
14
14
 
15
+ /**
16
+ * Additional arguments that can be passed to CRUD handlers.
17
+ *
18
+ * @typedef {{[key:string]: any}} AdditionalCrudArgs
19
+ */
20
+
15
21
  /**
16
22
  * Defines the CRUD-related handlers and additional utilities provided by the object instance.
17
23
  *
@@ -25,7 +31,7 @@ import { readonly } from "vue";
25
31
  */
26
32
 
27
33
  /**
28
- * @typedef {object} CreateArgs
34
+ * @typedef {object} CreateArgsRaw
29
35
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
30
36
  * @property {{[key:string]: any}} object - The data to be acted upon.
31
37
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
@@ -33,21 +39,25 @@ import { readonly } from "vue";
33
39
  * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
34
40
  */
35
41
 
42
+ /**
43
+ * @typedef {CreateArgsRaw & AdditionalCrudArgs} CreateArgs
44
+ */
45
+
36
46
  /**
37
47
  * @typedef {object} RetrieveArgsRaw
38
48
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
39
- * @property {string} pk - The pk of the object to be acted upon.
49
+ * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
40
50
  * @property {string} pkKey - The key name of the primary key.
41
51
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
42
52
  * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
43
53
  */
44
54
 
45
55
  /**
46
- * @typedef {RetrieveArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking} RetrieveArgs
56
+ * @typedef {RetrieveArgsRaw & Partial<import('../use/cancellableIntent.js').CommonRunTracking> & AdditionalCrudArgs} RetrieveArgs
47
57
  */
48
58
 
49
59
  /**
50
- * @typedef {object} UpdateArgs
60
+ * @typedef {object} UpdateArgsRaw
51
61
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
52
62
  * @property {import('../use/objectInstance.js').ExistingCrudObject} object - The data to be acted upon.
53
63
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
@@ -56,21 +66,45 @@ import { readonly } from "vue";
56
66
  */
57
67
 
58
68
  /**
59
- * @typedef {object} DeleteArgs
69
+ * @typedef {UpdateArgsRaw & AdditionalCrudArgs} UpdateArgs
70
+ */
71
+
72
+ /**
73
+ * @typedef {object} DeleteArgsRaw
60
74
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
61
- * @property {string} pk - The pk of the object to be acted upon.
75
+ * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
62
76
  * @property {string} pkKey - The key name of the primary key.
63
77
  */
64
78
 
65
79
  /**
66
- * @typedef {object} PartialArgs
80
+ * @typedef {DeleteArgsRaw & AdditionalCrudArgs} DeleteArgs
81
+ */
82
+
83
+ /**
84
+ * @typedef {object} PartialArgsRaw
67
85
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
68
- * @property {string} pk - The pk of the object to be acted upon.
86
+ * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
69
87
  * @property {string} pkKey - The key name of the primary key.
70
88
  * @property {{[key:string]: any}} partialObject - The data to be acted upon.
71
89
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
72
90
  * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
73
91
  */
92
+ /**
93
+ * @typedef {PartialArgsRaw & AdditionalCrudArgs} PartialArgs
94
+ */
95
+
96
+ /**
97
+ * @typedef {object} ObjectExecuteActionArgsRaw
98
+ * @property {import('../config/objectCrud.js').TargetArgs} target - The arguments to be passed to the crud handlers.
99
+ * @property {string} pk - The id of the objects to be acted upon.
100
+ * @property {string} pkKey - The key name of the primary key.
101
+ * @property {string} action - The action to execute.
102
+ * @property {Readonly<import('vue').Ref<boolean>>} isCancelled - A ref to indicate if the request was cancelled.
103
+ */
104
+
105
+ /**
106
+ * @typedef {ObjectExecuteActionArgsRaw & AdditionalCrudArgs} ObjectExecuteActionArgs
107
+ */
74
108
 
75
109
  /**
76
110
  * @callback CrudSubscribeCallback
@@ -81,7 +115,7 @@ import { readonly } from "vue";
81
115
  /**
82
116
  * @typedef {object} ObjectSubscribeArgsRaw
83
117
  * @property {TargetArgs} target - The arguments to be passed to the crud handlers.
84
- * @property {string} pk - The pk of the object to be acted upon.
118
+ * @property {import('./commonCrud.js').Pk} pk - The pk of the object to be acted upon.
85
119
  * @property {string} pkKey - The key name of the primary key.
86
120
  * @property {{[key:string]: any}} params - The arguments to be passed to the retrieve function.
87
121
  * @property {CrudSubscribeCallback} callback - The callback to be called when the object is updated.
@@ -89,7 +123,7 @@ import { readonly } from "vue";
89
123
  */
90
124
 
91
125
  /**
92
- * @typedef {ObjectSubscribeArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking} ObjectSubscribeArgs
126
+ * @typedef {ObjectSubscribeArgsRaw & import('../use/cancellableIntent.js').CommonRunTracking & AdditionalCrudArgs} ObjectSubscribeArgs
93
127
  */
94
128
 
95
129
  /**
@@ -126,6 +160,12 @@ import { readonly } from "vue";
126
160
  * @returns {CrudResponse} - The response data from the delete function.
127
161
  */
128
162
 
163
+ /**
164
+ * @callback CrudObjectExecuteActionFn
165
+ * @param {ObjectExecuteActionArgs} args - The arguments to be passed to the executeAction function.
166
+ * @returns {CrudResponse} - The response data from the delete function.
167
+ */
168
+
129
169
  /**
130
170
  * @callback CrudObjectSubscribeFn
131
171
  * @param {ObjectSubscribeArgs} args - The arguments to be passed to the subscribe function.
@@ -142,6 +182,8 @@ import { readonly } from "vue";
142
182
  * @property {CrudDeleteFn} [delete] - A function to be used instead of the default crud delete function.
143
183
  * @property {CrudPatchFn} [patch] - A function to be used instead of the default crud patch function.
144
184
  * @property {CrudObjectSubscribeFn} [subscribe] - A function to be used instead of the default crud subscribe function.
185
+ * @property {CrudObjectExecuteActionFn} [executeAction] - The function to execute a certain action on an object.
186
+ *
145
187
  */
146
188
 
147
189
  /**
@@ -152,7 +194,7 @@ import { readonly } from "vue";
152
194
  */
153
195
 
154
196
  const _defaultCrud = createDefaultCrud(
155
- ["retrieve", "create", "update", "patch", "delete", "subscribe"],
197
+ ["retrieve", "create", "update", "patch", "delete", "subscribe", "executeAction"],
156
198
  new Set(["subscribe"])
157
199
  );
158
200
 
package/index.js CHANGED
@@ -33,12 +33,15 @@ export * from "./utils/deleteKey.js";
33
33
  export * from "./utils/flattenPaths.js";
34
34
  export * from "./utils/flattenPathsWithValues.js";
35
35
  export * from "./utils/getFakePk.js";
36
+ export * from "./utils/isReactiveTyped.js";
36
37
  export * from "./utils/keepAliveTry.js";
37
38
  export * from "./utils/keyDiff.js";
38
39
  export * from "./utils/loadingCombine.js";
40
+ export * from "./utils/proxyRunning.js";
39
41
  export * from "./utils/refIfReactive.js";
40
42
  export * from "./utils/relatedCalculatedHelpers.js";
41
43
  export * from "./utils/set.js";
44
+ export * from "./utils/toRefsIfReactive.js";
42
45
  export * from "./utils/transformWalk.js";
43
46
  export * from "./utils/unwrapNested.js";
44
47
  export * from "./utils/watches.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrai-innovations/reactive-helpers",
3
- "version": "21.0.1",
3
+ "version": "21.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",
@@ -32,7 +32,9 @@
32
32
  "prepare": "npx --no-install husky",
33
33
  "docs": "node make_type_doc.js",
34
34
  "docs:check": "node check_type_doc.js",
35
- "docs:clean": "node clean_type_doc.js"
35
+ "docs:clean": "node clean_type_doc.js",
36
+ "types": "node make_types.js",
37
+ "types:check": "node check_types.js"
36
38
  },
37
39
  "repository": {
38
40
  "type": "git",
@@ -70,8 +72,8 @@
70
72
  "jsdom": "^26.0.0",
71
73
  "lint-staged": "^15.2.8",
72
74
  "prettier": "^3.3.3",
73
- "typedoc": "^0.27.1",
74
- "typedoc-plugin-markdown": "^4.3.0",
75
+ "typedoc": "^0.28.15",
76
+ "typedoc-plugin-markdown": "^4.9.0",
75
77
  "typescript": "^5.5.4",
76
78
  "vitest": "^3.1.2"
77
79
  },
@@ -16,3 +16,11 @@ export function assignCrud(target: object, defaultCrud: object, { props, handler
16
16
  export function missingMethod(name: string): (...args: any[]) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<any>;
17
17
  export function requiredCancelMissingMethod(name: string): ((..._args: any[]) => import("../utils/cancellablePromise.js").CancellablePromise<void>);
18
18
  export function createDefaultCrud(keys: string[], cancellableKeys?: Set<string>): object;
19
+ /**
20
+ * Primary key type accepted as input (will be coerced to string).
21
+ */
22
+ export type PkInput = string | number;
23
+ /**
24
+ * Primary key type used for storage and output (always a string).
25
+ */
26
+ export type Pk = string;
@@ -12,6 +12,12 @@ export function getListCrud(target: import("vue").UnwrapNestedRefs<ListCrudHandl
12
12
  export type ClearObjectsFn = import("../use/listInstance.js").ClearListFn;
13
13
  export type SetPaginateInfo = import("../use/listInstance.js").SetPaginateInfoFn;
14
14
  export type SetColumnTotals = import("../use/listInstance.js").SetColumnTotalsFn;
15
+ /**
16
+ * Additional arguments that can be passed to list crud handlers.
17
+ */
18
+ export type AdditionalListArgs = {
19
+ [key: string]: any;
20
+ };
15
21
  export type ListArgsRaw = {
16
22
  /**
17
23
  * - The arguments to be passed to the crud handlers.
@@ -47,8 +53,8 @@ export type ListArgsRaw = {
47
53
  */
48
54
  setColumnTotals: SetColumnTotals;
49
55
  };
50
- export type ListArgs = ListArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking>;
51
- export type BulkDeleteArgs = {
56
+ export type ListArgs = ListArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking> & AdditionalListArgs;
57
+ export type BulkDeleteArgsRaw = {
52
58
  /**
53
59
  * - The arguments to be passed to the crud handlers.
54
60
  */
@@ -56,12 +62,13 @@ export type BulkDeleteArgs = {
56
62
  /**
57
63
  * - The ids of the objects to be deleted.
58
64
  */
59
- pks: string[];
65
+ pks: import("./commonCrud.js").Pk[];
60
66
  /**
61
67
  * - The key name of the primary key.
62
68
  */
63
69
  pkKey: string;
64
70
  };
71
+ export type BulkDeleteArgs = BulkDeleteArgsRaw & AdditionalListArgs;
65
72
  export type applyObjectEvent = (newOrUpdatedOrDeleteObject: import("../use/objectInstance.js").ExistingCrudObject | string, action: "create" | "update" | "delete") => void;
66
73
  export type ListSubscribeArgsRaw = {
67
74
  /**
@@ -86,8 +93,8 @@ export type ListSubscribeArgsRaw = {
86
93
  */
87
94
  isCancelled: Readonly<import("vue").Ref<boolean>>;
88
95
  };
89
- export type ListSubscribeArgs = ListSubscribeArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking>;
90
- export type ExecuteActionArgs = {
96
+ export type ListSubscribeArgs = ListSubscribeArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking> & AdditionalListArgs;
97
+ export type ExecuteActionArgsRaw = {
91
98
  /**
92
99
  * - The arguments to be passed to the crud handlers.
93
100
  */
@@ -95,7 +102,7 @@ export type ExecuteActionArgs = {
95
102
  /**
96
103
  * - The ids of the objects to be acted upon.
97
104
  */
98
- pks: string[];
105
+ pks: import("./commonCrud.js").Pk[];
99
106
  /**
100
107
  * - The key name of the primary key.
101
108
  */
@@ -105,6 +112,7 @@ export type ExecuteActionArgs = {
105
112
  */
106
113
  action: string;
107
114
  };
115
+ export type ExecuteActionArgs = ExecuteActionArgsRaw & AdditionalListArgs;
108
116
  export type CrudListFn = (args: ListArgs) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
109
117
  export type CrudBulkDeleteFn = (args: BulkDeleteArgs) => Promise<boolean>;
110
118
  export type CrudListSubscribeFn = (args: ListSubscribeArgs) => import("../utils/cancellablePromise.js").CancellablePromise<void>;
@@ -12,6 +12,12 @@ export function getObjectCrud(target: import("vue").UnwrapNestedRefs<ObjectTarge
12
12
  export type TargetArgs = {
13
13
  [key: string]: any;
14
14
  };
15
+ /**
16
+ * Additional arguments that can be passed to CRUD handlers.
17
+ */
18
+ export type AdditionalCrudArgs = {
19
+ [key: string]: any;
20
+ };
15
21
  /**
16
22
  * Defines the CRUD-related handlers and additional utilities provided by the object instance.
17
23
  */
@@ -27,7 +33,7 @@ export type ObjectTargetOption = {
27
33
  */
28
34
  target?: TargetArgs;
29
35
  };
30
- export type CreateArgs = {
36
+ export type CreateArgsRaw = {
31
37
  /**
32
38
  * - The arguments to be passed to the crud handlers.
33
39
  */
@@ -53,6 +59,7 @@ export type CreateArgs = {
53
59
  */
54
60
  isCancelled: Readonly<import("vue").Ref<boolean>>;
55
61
  };
62
+ export type CreateArgs = CreateArgsRaw & AdditionalCrudArgs;
56
63
  export type RetrieveArgsRaw = {
57
64
  /**
58
65
  * - The arguments to be passed to the crud handlers.
@@ -61,7 +68,7 @@ export type RetrieveArgsRaw = {
61
68
  /**
62
69
  * - The pk of the object to be acted upon.
63
70
  */
64
- pk: string;
71
+ pk: import("./commonCrud.js").Pk;
65
72
  /**
66
73
  * - The key name of the primary key.
67
74
  */
@@ -77,8 +84,8 @@ export type RetrieveArgsRaw = {
77
84
  */
78
85
  isCancelled: Readonly<import("vue").Ref<boolean>>;
79
86
  };
80
- export type RetrieveArgs = RetrieveArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking;
81
- export type UpdateArgs = {
87
+ export type RetrieveArgs = RetrieveArgsRaw & Partial<import("../use/cancellableIntent.js").CommonRunTracking> & AdditionalCrudArgs;
88
+ export type UpdateArgsRaw = {
82
89
  /**
83
90
  * - The arguments to be passed to the crud handlers.
84
91
  */
@@ -102,7 +109,8 @@ export type UpdateArgs = {
102
109
  */
103
110
  isCancelled: Readonly<import("vue").Ref<boolean>>;
104
111
  };
105
- export type DeleteArgs = {
112
+ export type UpdateArgs = UpdateArgsRaw & AdditionalCrudArgs;
113
+ export type DeleteArgsRaw = {
106
114
  /**
107
115
  * - The arguments to be passed to the crud handlers.
108
116
  */
@@ -110,13 +118,14 @@ export type DeleteArgs = {
110
118
  /**
111
119
  * - The pk of the object to be acted upon.
112
120
  */
113
- pk: string;
121
+ pk: import("./commonCrud.js").Pk;
114
122
  /**
115
123
  * - The key name of the primary key.
116
124
  */
117
125
  pkKey: string;
118
126
  };
119
- export type PartialArgs = {
127
+ export type DeleteArgs = DeleteArgsRaw & AdditionalCrudArgs;
128
+ export type PartialArgsRaw = {
120
129
  /**
121
130
  * - The arguments to be passed to the crud handlers.
122
131
  */
@@ -124,7 +133,7 @@ export type PartialArgs = {
124
133
  /**
125
134
  * - The pk of the object to be acted upon.
126
135
  */
127
- pk: string;
136
+ pk: import("./commonCrud.js").Pk;
128
137
  /**
129
138
  * - The key name of the primary key.
130
139
  */
@@ -146,6 +155,30 @@ export type PartialArgs = {
146
155
  */
147
156
  isCancelled: Readonly<import("vue").Ref<boolean>>;
148
157
  };
158
+ export type PartialArgs = PartialArgsRaw & AdditionalCrudArgs;
159
+ export type ObjectExecuteActionArgsRaw = {
160
+ /**
161
+ * - The arguments to be passed to the crud handlers.
162
+ */
163
+ target: import("../config/objectCrud.js").TargetArgs;
164
+ /**
165
+ * - The id of the objects to be acted upon.
166
+ */
167
+ pk: string;
168
+ /**
169
+ * - The key name of the primary key.
170
+ */
171
+ pkKey: string;
172
+ /**
173
+ * - The action to execute.
174
+ */
175
+ action: string;
176
+ /**
177
+ * - A ref to indicate if the request was cancelled.
178
+ */
179
+ isCancelled: Readonly<import("vue").Ref<boolean>>;
180
+ };
181
+ export type ObjectExecuteActionArgs = ObjectExecuteActionArgsRaw & AdditionalCrudArgs;
149
182
  export type CrudSubscribeCallback = (data: import("../use/objectInstance.js").ExistingCrudObject, action: "delete" | "update" | "create") => any;
150
183
  export type ObjectSubscribeArgsRaw = {
151
184
  /**
@@ -155,7 +188,7 @@ export type ObjectSubscribeArgsRaw = {
155
188
  /**
156
189
  * - The pk of the object to be acted upon.
157
190
  */
158
- pk: string;
191
+ pk: import("./commonCrud.js").Pk;
159
192
  /**
160
193
  * - The key name of the primary key.
161
194
  */
@@ -175,13 +208,14 @@ export type ObjectSubscribeArgsRaw = {
175
208
  */
176
209
  isCancelled: Readonly<import("vue").Ref<boolean>>;
177
210
  };
178
- export type ObjectSubscribeArgs = ObjectSubscribeArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking;
211
+ export type ObjectSubscribeArgs = ObjectSubscribeArgsRaw & import("../use/cancellableIntent.js").CommonRunTracking & AdditionalCrudArgs;
179
212
  export type CrudResponse = import("../utils/cancellablePromise.js").MaybeCancellablePromise<object | string>;
180
213
  export type CrudCreateFn = (args: CreateArgs) => CrudResponse;
181
214
  export type CrudRetrieveFn = (args: RetrieveArgs) => CrudResponse;
182
215
  export type CrudUpdateFn = (args: UpdateArgs) => CrudResponse;
183
216
  export type CrudPatchFn = (args: PartialArgs) => CrudResponse;
184
217
  export type CrudDeleteFn = (args: DeleteArgs) => CrudResponse;
218
+ export type CrudObjectExecuteActionFn = (args: ObjectExecuteActionArgs) => CrudResponse;
185
219
  export type CrudObjectSubscribeFn = (args: ObjectSubscribeArgs) => import("../utils/cancellablePromise.js").CancellablePromise<void>;
186
220
  /**
187
221
  * Defines the CRUD-related handlers and additional utilities provided by the object instance.
@@ -211,6 +245,10 @@ export type ObjectCrudHandlers = {
211
245
  * - A function to be used instead of the default crud subscribe function.
212
246
  */
213
247
  subscribe?: CrudObjectSubscribeFn;
248
+ /**
249
+ * - The function to execute a certain action on an object.
250
+ */
251
+ executeAction?: CrudObjectExecuteActionFn;
214
252
  };
215
253
  /**
216
254
  * The CRUD arguments.
package/types/index.d.ts CHANGED
@@ -32,12 +32,15 @@ export * from "./utils/deleteKey.js";
32
32
  export * from "./utils/flattenPaths.js";
33
33
  export * from "./utils/flattenPathsWithValues.js";
34
34
  export * from "./utils/getFakePk.js";
35
+ export * from "./utils/isReactiveTyped.js";
35
36
  export * from "./utils/keepAliveTry.js";
36
37
  export * from "./utils/keyDiff.js";
37
38
  export * from "./utils/loadingCombine.js";
39
+ export * from "./utils/proxyRunning.js";
38
40
  export * from "./utils/refIfReactive.js";
39
41
  export * from "./utils/relatedCalculatedHelpers.js";
40
42
  export * from "./utils/set.js";
43
+ export * from "./utils/toRefsIfReactive.js";
41
44
  export * from "./utils/transformWalk.js";
42
45
  export * from "./utils/unwrapNested.js";
43
46
  export * from "./utils/watches.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -4,7 +4,7 @@
4
4
  * Enables distinguishing results or effects from overlapping async runs.
5
5
  */
6
6
  /**
7
- * @typedef {object} CancellableIntentRawState - The raw state of the cancellable intent.
7
+ * @typedef {object} CancellableIntentMyState - The raw state of the cancellable intent.
8
8
  * @property {import('vue').ComputedRef<boolean>|undefined} active - Whether there are active intents.
9
9
  * @property {import('vue').ComputedRef<boolean>|undefined} resolving - Whether there are resolving intents.
10
10
  * @property {boolean} clearActiveOnResolved - Whether to clear the active state when the promise resolves.
@@ -13,10 +13,10 @@
13
13
  * @property {import('vue').DeepReadonly<object>} guardArguments - The guard arguments.
14
14
  */
15
15
  /**
16
- * @typedef {import("vue").Reactive<
17
- * CancellableIntentRawState &
18
- * Pick<import('./error.js').ErrorStatus, 'error' | 'errored'>
19
- * >} CancellableIntentState - The state of the cancellable intent.
16
+ * @typedef {CancellableIntentMyState & import('./error.js').ErrorProperties} CancellableIntentRawState - The raw state of the cancellable intent.
17
+ */
18
+ /**
19
+ * @typedef {import("vue").Reactive<CancellableIntentRawState>} CancellableIntentState - The state of the cancellable intent.
20
20
  */
21
21
  /**
22
22
  * @typedef {() => boolean} IsCurrentRunFn - A function that checks if the current run ID matches the last run ID.
@@ -29,7 +29,7 @@
29
29
  * @property {IsCurrentRunFn} isCurrentRun - A function that checks if the current run ID matches your run ID.
30
30
  */
31
31
  /**
32
- * @typedef {(runTracking: CommonRunTracking) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<void>} AwaitableWithCancel - A function that returns a promise that can be cancelled.
32
+ * @typedef {(runTracking: CommonRunTracking) => import('../utils/cancellablePromise.js').MaybeCancellablePromise<unknown>} AwaitableWithCancel - A function that returns a promise that can be cancelled. The return value of the promise is not used.
33
33
  */
34
34
  /**
35
35
  * @typedef {import("vue").UnwrapNestedRefs<object>|{[key: string]: import('vue').Ref<any>}} WatchGuardArguments - The reactive object to watch for changes.
@@ -56,7 +56,7 @@
56
56
  * @property {CancelFn} cancel - Cancel the cancellable intent.
57
57
  */
58
58
  /**
59
- * @typedef {MyCancellableIntent & Pick<import('./error.js').ErrorStatus, "clearError">} CancellableIntent - The instance of the cancellable intent.
59
+ * @typedef {MyCancellableIntent & import('./error.js').ErrorReadOnlyFunctions} CancellableIntent - The instance of the cancellable intent.
60
60
  */
61
61
  /**
62
62
  * Calls your awaitable function with the arguments you pass in when the watch arguments change and are all truthy.
@@ -122,7 +122,7 @@ export type RunId = number;
122
122
  /**
123
123
  * - The raw state of the cancellable intent.
124
124
  */
125
- export type CancellableIntentRawState = {
125
+ export type CancellableIntentMyState = {
126
126
  /**
127
127
  * - Whether there are active intents.
128
128
  */
@@ -148,10 +148,14 @@ export type CancellableIntentRawState = {
148
148
  */
149
149
  guardArguments: import("vue").DeepReadonly<object>;
150
150
  };
151
+ /**
152
+ * - The raw state of the cancellable intent.
153
+ */
154
+ export type CancellableIntentRawState = CancellableIntentMyState & import("./error.js").ErrorProperties;
151
155
  /**
152
156
  * - The state of the cancellable intent.
153
157
  */
154
- export type CancellableIntentState = import("vue").Reactive<CancellableIntentRawState & Pick<import("./error.js").ErrorStatus, "error" | "errored">>;
158
+ export type CancellableIntentState = import("vue").Reactive<CancellableIntentRawState>;
155
159
  /**
156
160
  * - A function that checks if the current run ID matches the last run ID.
157
161
  */
@@ -170,9 +174,9 @@ export type CommonRunTracking = {
170
174
  isCurrentRun: IsCurrentRunFn;
171
175
  };
172
176
  /**
173
- * - A function that returns a promise that can be cancelled.
177
+ * - A function that returns a promise that can be cancelled. The return value of the promise is not used.
174
178
  */
175
- export type AwaitableWithCancel = (runTracking: CommonRunTracking) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<void>;
179
+ export type AwaitableWithCancel = (runTracking: CommonRunTracking) => import("../utils/cancellablePromise.js").MaybeCancellablePromise<unknown>;
176
180
  /**
177
181
  * - The reactive object to watch for changes.
178
182
  */
@@ -224,4 +228,4 @@ export type MyCancellableIntent = {
224
228
  /**
225
229
  * - The instance of the cancellable intent.
226
230
  */
227
- export type CancellableIntent = MyCancellableIntent & Pick<import("./error.js").ErrorStatus, "clearError">;
231
+ export type CancellableIntent = MyCancellableIntent & import("./error.js").ErrorReadOnlyFunctions;