@leancodepl/react-query-cqrs-client 8.3.0 → 8.3.2
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/index.cjs.js +8 -6
- package/index.esm.js +8 -6
- package/package.json +4 -4
- package/src/lib/mkCqrsClient.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -163,9 +163,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
163
163
|
"invalidateQueries"
|
|
164
164
|
]);
|
|
165
165
|
return reactQuery.useMutation(_extends({
|
|
166
|
-
mutationKey:
|
|
167
|
-
type
|
|
168
|
-
],
|
|
166
|
+
mutationKey: useApiOperation.key,
|
|
169
167
|
mutationFn: (variables)=>rxjs.firstValueFrom(useApiOperation.fetcher(variables))
|
|
170
168
|
}, options, {
|
|
171
169
|
async onSuccess (data, variables, context) {
|
|
@@ -180,6 +178,9 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
180
178
|
}), queryClient);
|
|
181
179
|
}
|
|
182
180
|
useApiOperation.type = type;
|
|
181
|
+
useApiOperation.key = [
|
|
182
|
+
useApiOperation.type
|
|
183
|
+
];
|
|
183
184
|
useApiOperation.fetcher = (variables)=>fetcher(variables).pipe(uncapitalizedParse());
|
|
184
185
|
return useApiOperation;
|
|
185
186
|
},
|
|
@@ -195,9 +196,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
195
196
|
"onSettled"
|
|
196
197
|
]);
|
|
197
198
|
return reactQuery.useMutation(_extends({}, options, {
|
|
198
|
-
mutationKey:
|
|
199
|
-
type
|
|
200
|
-
],
|
|
199
|
+
mutationKey: useApiCommand.key,
|
|
201
200
|
mutationFn: (variables)=>{
|
|
202
201
|
if (!handler) {
|
|
203
202
|
return rxjs.firstValueFrom(useApiCommand.fetcher(variables));
|
|
@@ -228,6 +227,9 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
228
227
|
}), queryClient);
|
|
229
228
|
}
|
|
230
229
|
useApiCommand.type = type;
|
|
230
|
+
useApiCommand.key = [
|
|
231
|
+
useApiCommand.type
|
|
232
|
+
];
|
|
231
233
|
useApiCommand.fetcher = (variables)=>fetcher(variables);
|
|
232
234
|
useApiCommand.call = (variables, handler)=>{
|
|
233
235
|
const $response = useApiCommand.fetcher(variables);
|
package/index.esm.js
CHANGED
|
@@ -161,9 +161,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
161
161
|
"invalidateQueries"
|
|
162
162
|
]);
|
|
163
163
|
return useMutation(_extends({
|
|
164
|
-
mutationKey:
|
|
165
|
-
type
|
|
166
|
-
],
|
|
164
|
+
mutationKey: useApiOperation.key,
|
|
167
165
|
mutationFn: (variables)=>firstValueFrom(useApiOperation.fetcher(variables))
|
|
168
166
|
}, options, {
|
|
169
167
|
async onSuccess (data, variables, context) {
|
|
@@ -178,6 +176,9 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
178
176
|
}), queryClient);
|
|
179
177
|
}
|
|
180
178
|
useApiOperation.type = type;
|
|
179
|
+
useApiOperation.key = [
|
|
180
|
+
useApiOperation.type
|
|
181
|
+
];
|
|
181
182
|
useApiOperation.fetcher = (variables)=>fetcher(variables).pipe(uncapitalizedParse());
|
|
182
183
|
return useApiOperation;
|
|
183
184
|
},
|
|
@@ -193,9 +194,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
193
194
|
"onSettled"
|
|
194
195
|
]);
|
|
195
196
|
return useMutation(_extends({}, options, {
|
|
196
|
-
mutationKey:
|
|
197
|
-
type
|
|
198
|
-
],
|
|
197
|
+
mutationKey: useApiCommand.key,
|
|
199
198
|
mutationFn: (variables)=>{
|
|
200
199
|
if (!handler) {
|
|
201
200
|
return firstValueFrom(useApiCommand.fetcher(variables));
|
|
@@ -226,6 +225,9 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
226
225
|
}), queryClient);
|
|
227
226
|
}
|
|
228
227
|
useApiCommand.type = type;
|
|
228
|
+
useApiCommand.key = [
|
|
229
|
+
useApiCommand.type
|
|
230
|
+
];
|
|
229
231
|
useApiCommand.fetcher = (variables)=>fetcher(variables);
|
|
230
232
|
useApiCommand.call = (variables, handler)=>{
|
|
231
233
|
const $response = useApiCommand.fetcher(variables);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/react-query-cqrs-client",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/cqrs-client-base": "8.3.
|
|
7
|
-
"@leancodepl/utils": "8.3.
|
|
8
|
-
"@leancodepl/validation": "8.3.
|
|
6
|
+
"@leancodepl/cqrs-client-base": "8.3.2",
|
|
7
|
+
"@leancodepl/utils": "8.3.2",
|
|
8
|
+
"@leancodepl/validation": "8.3.2",
|
|
9
9
|
"@tanstack/react-query": ">=5.0.0",
|
|
10
10
|
"rxjs": ">=7.0.0"
|
|
11
11
|
},
|
|
@@ -38,6 +38,7 @@ export declare function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider,
|
|
|
38
38
|
invalidateQueries?: QueryKey[];
|
|
39
39
|
} & Omit<UseMutationOptions<NullableUncapitalizeDeep<TResult>, unknown, TOperation, TContext>, "mutationFn" | "mutationKey">): UseMutationResult<NullableUncapitalizeDeep<TResult>, unknown, TOperation, TContext>;
|
|
40
40
|
type: string;
|
|
41
|
+
key: string[];
|
|
41
42
|
fetcher(variables: TOperation): Observable<NullableUncapitalizeDeep<TResult>>;
|
|
42
43
|
};
|
|
43
44
|
createCommand<TCommand, TErrorCodes extends {
|
|
@@ -57,6 +58,7 @@ export declare function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider,
|
|
|
57
58
|
optimisticUpdate?: (variables: TCommand) => Promise<() => void>[];
|
|
58
59
|
} & Omit<UseMutationOptions<TResult, TResult, TCommand, TContext>, "mutationFn" | "mutationKey">): UseMutationResult<TResult, TResult, TCommand, TContext>;
|
|
59
60
|
type: string;
|
|
61
|
+
key: string[];
|
|
60
62
|
fetcher(variables: TCommand): Observable<CommandResult<TErrorCodes>>;
|
|
61
63
|
call<TResult>(variables: TCommand, handler: (handler: ValidationErrorsHandler<{
|
|
62
64
|
success: -1;
|