@leancodepl/axios-cqrs-client 8.3.3 → 8.3.5

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 CHANGED
@@ -85,7 +85,14 @@ function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader =
85
85
  });
86
86
  return {
87
87
  createQuery (type) {
88
- return (dto)=>apiAxios.post("query/" + type, dto).then((r)=>r.data);
88
+ return (dto)=>{
89
+ const abortController = new AbortController();
90
+ const promise = apiAxios.post("query/" + type, dto, {
91
+ signal: abortController.signal
92
+ }).then((r)=>r.data);
93
+ promise.abort = abortController.abort.bind(abortController);
94
+ return promise;
95
+ };
89
96
  },
90
97
  createOperation (type) {
91
98
  return (dto)=>apiAxios.post("operation/" + type, dto).then((r)=>r.data);
package/index.esm.js CHANGED
@@ -83,7 +83,14 @@ function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader =
83
83
  });
84
84
  return {
85
85
  createQuery (type) {
86
- return (dto)=>apiAxios.post("query/" + type, dto).then((r)=>r.data);
86
+ return (dto)=>{
87
+ const abortController = new AbortController();
88
+ const promise = apiAxios.post("query/" + type, dto, {
89
+ signal: abortController.signal
90
+ }).then((r)=>r.data);
91
+ promise.abort = abortController.abort.bind(abortController);
92
+ return promise;
93
+ };
87
94
  },
88
95
  createOperation (type) {
89
96
  return (dto)=>apiAxios.post("operation/" + type, dto).then((r)=>r.data);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@leancodepl/axios-cqrs-client",
3
- "version": "8.3.3",
3
+ "version": "8.3.5",
4
4
  "license": "Apache-2.0",
5
5
  "dependencies": {
6
- "@leancodepl/cqrs-client-base": "8.3.3",
7
- "@leancodepl/validation": "8.3.3",
6
+ "@leancodepl/cqrs-client-base": "8.3.5",
7
+ "@leancodepl/validation": "8.3.5",
8
8
  "axios": ">=1.6.0"
9
9
  },
10
10
  "exports": {
@@ -7,7 +7,7 @@ export type MkCqrsClientParameters = {
7
7
  tokenHeader?: string;
8
8
  };
9
9
  export declare function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader, }: MkCqrsClientParameters): {
10
- createQuery<TQuery, TResult>(type: string): (dto: TQuery) => Promise<ApiError | ApiSuccess<TResult>>;
10
+ createQuery<TQuery, TResult>(type: string): (dto: TQuery) => QueryPromise<TResult>;
11
11
  createOperation<TOperation, TResult>(type: string): (dto: TOperation) => Promise<ApiError | ApiSuccess<TResult>>;
12
12
  createCommand<TCommand, TErrorCodes extends {
13
13
  [name: string]: number;
@@ -19,3 +19,7 @@ export declare function mkCqrsClient({ cqrsEndpoint, tokenProvider, axiosOptions
19
19
  }, never>>;
20
20
  };
21
21
  };
22
+ export type QueryAbort = {
23
+ abort: AbortController["abort"];
24
+ };
25
+ export type QueryPromise<TResult> = Promise<ApiResponse<TResult>> & QueryAbort;