@leancodepl/react-query-cqrs-client 9.6.4 → 9.6.6
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 +5 -5
- package/index.cjs.js +2 -2
- package/index.esm.js +2 -2
- package/package.json +4 -4
- package/src/lib/mkCqrsClient.d.ts +4 -13
package/README.md
CHANGED
|
@@ -46,11 +46,11 @@ import { QueryClient } from "@tanstack/react-query"
|
|
|
46
46
|
const queryClient = new QueryClient()
|
|
47
47
|
|
|
48
48
|
const client = mkCqrsClient({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
cqrsEndpoint: "https://api.example.com",
|
|
50
|
+
queryClient,
|
|
51
|
+
tokenProvider: {
|
|
52
|
+
getToken: () => Promise.resolve(localStorage.getItem("token")),
|
|
53
|
+
},
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
package/index.cjs.js
CHANGED
|
@@ -254,7 +254,7 @@ function uncapitalizedParse() {
|
|
|
254
254
|
isSuccess: true,
|
|
255
255
|
result
|
|
256
256
|
})), rxjs.catchError((e)=>rxjs.of(useApiCommand.mapError(e))), operators.map((response)=>{
|
|
257
|
-
const result = handler ? useApiCommand.handleResponse(handler)(response) : response;
|
|
257
|
+
const result = handler ? useApiCommand.handleResponse(handler, variables)(response) : response;
|
|
258
258
|
if (!response.isSuccess || !response.result.WasSuccessful) {
|
|
259
259
|
throw result;
|
|
260
260
|
}
|
|
@@ -273,7 +273,7 @@ function uncapitalizedParse() {
|
|
|
273
273
|
error: e
|
|
274
274
|
};
|
|
275
275
|
};
|
|
276
|
-
useApiCommand.handleResponse = (handler)=>(response)=>handler(validation.handleResponse(response, errorCodes));
|
|
276
|
+
useApiCommand.handleResponse = (handler, variables)=>(response)=>handler(validation.handleResponse(response, errorCodes), variables);
|
|
277
277
|
return useApiCommand;
|
|
278
278
|
}
|
|
279
279
|
};
|
package/index.esm.js
CHANGED
|
@@ -252,7 +252,7 @@ function uncapitalizedParse() {
|
|
|
252
252
|
isSuccess: true,
|
|
253
253
|
result
|
|
254
254
|
})), catchError((e)=>of(useApiCommand.mapError(e))), map((response)=>{
|
|
255
|
-
const result = handler ? useApiCommand.handleResponse(handler)(response) : response;
|
|
255
|
+
const result = handler ? useApiCommand.handleResponse(handler, variables)(response) : response;
|
|
256
256
|
if (!response.isSuccess || !response.result.WasSuccessful) {
|
|
257
257
|
throw result;
|
|
258
258
|
}
|
|
@@ -271,7 +271,7 @@ function uncapitalizedParse() {
|
|
|
271
271
|
error: e
|
|
272
272
|
};
|
|
273
273
|
};
|
|
274
|
-
useApiCommand.handleResponse = (handler)=>(response)=>handler(handleResponse(response, errorCodes));
|
|
274
|
+
useApiCommand.handleResponse = (handler, variables)=>(response)=>handler(handleResponse(response, errorCodes), variables);
|
|
275
275
|
return useApiCommand;
|
|
276
276
|
}
|
|
277
277
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/react-query-cqrs-client",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/cqrs-client-base": "9.6.
|
|
7
|
-
"@leancodepl/utils": "9.6.
|
|
8
|
-
"@leancodepl/validation": "9.6.
|
|
6
|
+
"@leancodepl/cqrs-client-base": "9.6.6",
|
|
7
|
+
"@leancodepl/utils": "9.6.6",
|
|
8
|
+
"@leancodepl/validation": "9.6.6",
|
|
9
9
|
"@tanstack/react-query": ">=5.0.0",
|
|
10
10
|
"rxjs": ">=7.0.0"
|
|
11
11
|
},
|
|
@@ -2,7 +2,7 @@ import { DefaultError, FetchQueryOptions, InfiniteData, QueryClient, QueryFuncti
|
|
|
2
2
|
import { Observable, OperatorFunction } from "rxjs";
|
|
3
3
|
import { AjaxConfig } from "rxjs/ajax";
|
|
4
4
|
import { ApiResponse, ApiSuccess, CommandResult, FailedCommandResult, SuccessfulCommandResult, TokenProvider } from "@leancodepl/cqrs-client-base";
|
|
5
|
-
import { ValidationErrorsHandler } from "@leancodepl/validation";
|
|
5
|
+
import { SuccessOrFailureMarker, ValidationErrorsHandler } from "@leancodepl/validation";
|
|
6
6
|
import { NullableUncapitalizeDeep } from "./types";
|
|
7
7
|
export declare function uncapitalizedParse<TResult>(): OperatorFunction<string, NullableUncapitalizeDeep<TResult>>;
|
|
8
8
|
/**
|
|
@@ -71,23 +71,14 @@ export declare function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider,
|
|
|
71
71
|
}): UseMutationResult<ApiSuccess<SuccessfulCommandResult>, ApiResponse<FailedCommandResult<TErrorCodes>>, TCommand, TOnMutateResult>;
|
|
72
72
|
<TResult, TOnMutateResult extends Record<string, unknown> = {}>(options?: Omit<UseMutationOptions<TResult, TResult, TCommand, TOnMutateResult>, "mutationFn" | "mutationKey"> & {
|
|
73
73
|
invalidateQueries?: QueryKey[];
|
|
74
|
-
handler: (handler: ValidationErrorsHandler<
|
|
75
|
-
success: -1;
|
|
76
|
-
failure: -2;
|
|
77
|
-
}, never>) => TResult;
|
|
74
|
+
handler: (handler: ValidationErrorsHandler<SuccessOrFailureMarker & TErrorCodes, never>, variables: TCommand) => TResult;
|
|
78
75
|
optimisticUpdate?: (variables: TCommand) => Promise<() => void>[];
|
|
79
76
|
}): UseMutationResult<TResult, TResult, TCommand, TOnMutateResult>;
|
|
80
77
|
type: string;
|
|
81
78
|
key: readonly [string];
|
|
82
79
|
fetcher: (data: TCommand) => Observable<SuccessfulCommandResult>;
|
|
83
|
-
call<TResult>(variables: TCommand, handler?: (handler: ValidationErrorsHandler<
|
|
84
|
-
success: -1;
|
|
85
|
-
failure: -2;
|
|
86
|
-
}, never>) => TResult): Observable<ApiSuccess<SuccessfulCommandResult> | TResult>;
|
|
80
|
+
call<TResult>(variables: TCommand, handler?: (handler: ValidationErrorsHandler<SuccessOrFailureMarker & TErrorCodes, never>, variables: TCommand) => TResult): Observable<ApiSuccess<SuccessfulCommandResult> | TResult>;
|
|
87
81
|
mapError(e: unknown): ApiResponse<CommandResult<TErrorCodes>>;
|
|
88
|
-
handleResponse<TResult>(handler: (handler: ValidationErrorsHandler<
|
|
89
|
-
success: -1;
|
|
90
|
-
failure: -2;
|
|
91
|
-
}, never>) => TResult): (response: ApiResponse<CommandResult<TErrorCodes>>) => TResult;
|
|
82
|
+
handleResponse<TResult>(handler: (handler: ValidationErrorsHandler<SuccessOrFailureMarker & TErrorCodes, never>, variables: TCommand) => TResult, variables: TCommand): (response: ApiResponse<CommandResult<TErrorCodes>>) => TResult;
|
|
92
83
|
};
|
|
93
84
|
};
|