@leancodepl/react-query-cqrs-client 7.1.7 → 7.2.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 +16 -9
- package/index.esm.js +16 -9
- package/package.json +4 -4
- package/src/lib/mkCqrsClient.d.ts +6 -7
package/index.cjs.js
CHANGED
|
@@ -90,7 +90,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
90
90
|
return reactQuery.useQuery(_extends({
|
|
91
91
|
queryKey: useApiQuery.key(data),
|
|
92
92
|
queryFn: (context)=>rxjs.firstValueFrom(useApiQuery.fetcher(data, context))
|
|
93
|
-
}, options));
|
|
93
|
+
}, options), queryClient);
|
|
94
94
|
}
|
|
95
95
|
useApiQuery.fetcher = (data, context)=>{
|
|
96
96
|
var _context;
|
|
@@ -107,9 +107,12 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
107
107
|
}, options));
|
|
108
108
|
useApiQuery.lazy = function(options = {}) {
|
|
109
109
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
110
|
-
return reactQuery.useMutation(
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
return reactQuery.useMutation(_extends({
|
|
111
|
+
mutationKey: [
|
|
112
|
+
type
|
|
113
|
+
],
|
|
114
|
+
mutationFn: (variables)=>rxjs.firstValueFrom(useApiQuery.fetcher(variables))
|
|
115
|
+
}, options), queryClient);
|
|
113
116
|
};
|
|
114
117
|
useApiQuery.infinite = function(data, options) {
|
|
115
118
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -121,7 +124,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
121
124
|
[options.pageParamKey]: context.pageParam
|
|
122
125
|
}) : data, context));
|
|
123
126
|
}
|
|
124
|
-
}, options));
|
|
127
|
+
}, options), queryClient);
|
|
125
128
|
};
|
|
126
129
|
useApiQuery.key = (query)=>[
|
|
127
130
|
type,
|
|
@@ -163,10 +166,12 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
163
166
|
async onSuccess (data, variables, context) {
|
|
164
167
|
var _onSuccessBase;
|
|
165
168
|
const result = await ((_onSuccessBase = onSuccessBase) == null ? void 0 : _onSuccessBase(data, variables, context));
|
|
166
|
-
invalidateQueries && await Promise.allSettled(invalidateQueries.map((
|
|
169
|
+
invalidateQueries && await Promise.allSettled(invalidateQueries.map((queryKey)=>queryClient.invalidateQueries({
|
|
170
|
+
queryKey
|
|
171
|
+
})));
|
|
167
172
|
return result;
|
|
168
173
|
}
|
|
169
|
-
}));
|
|
174
|
+
}), queryClient);
|
|
170
175
|
}
|
|
171
176
|
useApiOperation.fetcher = (variables)=>fetcher(variables).pipe(uncapitalizedParse());
|
|
172
177
|
return useApiOperation;
|
|
@@ -192,11 +197,13 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
192
197
|
}, options, {
|
|
193
198
|
async onSuccess (data, variables, context) {
|
|
194
199
|
var _onSuccess;
|
|
195
|
-
invalidateQueries && await Promise.allSettled(invalidateQueries.map((queryKey)=>queryClient.invalidateQueries(
|
|
200
|
+
invalidateQueries && await Promise.allSettled(invalidateQueries.map((queryKey)=>queryClient.invalidateQueries({
|
|
201
|
+
queryKey
|
|
202
|
+
})));
|
|
196
203
|
const result = await ((_onSuccess = onSuccess) == null ? void 0 : _onSuccess(data, variables, context));
|
|
197
204
|
return result;
|
|
198
205
|
}
|
|
199
|
-
}));
|
|
206
|
+
}), queryClient);
|
|
200
207
|
}
|
|
201
208
|
useApiCommand.fetcher = (variables)=>fetcher(variables);
|
|
202
209
|
useApiCommand.call = (variables, handler)=>{
|
package/index.esm.js
CHANGED
|
@@ -86,7 +86,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
86
86
|
return useQuery(_extends({
|
|
87
87
|
queryKey: useApiQuery.key(data),
|
|
88
88
|
queryFn: (context)=>firstValueFrom(useApiQuery.fetcher(data, context))
|
|
89
|
-
}, options));
|
|
89
|
+
}, options), queryClient);
|
|
90
90
|
}
|
|
91
91
|
useApiQuery.fetcher = (data, context)=>{
|
|
92
92
|
var _context;
|
|
@@ -103,9 +103,12 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
103
103
|
}, options));
|
|
104
104
|
useApiQuery.lazy = function(options = {}) {
|
|
105
105
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
106
|
-
return useMutation(
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
return useMutation(_extends({
|
|
107
|
+
mutationKey: [
|
|
108
|
+
type
|
|
109
|
+
],
|
|
110
|
+
mutationFn: (variables)=>firstValueFrom(useApiQuery.fetcher(variables))
|
|
111
|
+
}, options), queryClient);
|
|
109
112
|
};
|
|
110
113
|
useApiQuery.infinite = function(data, options) {
|
|
111
114
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -117,7 +120,7 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
117
120
|
[options.pageParamKey]: context.pageParam
|
|
118
121
|
}) : data, context));
|
|
119
122
|
}
|
|
120
|
-
}, options));
|
|
123
|
+
}, options), queryClient);
|
|
121
124
|
};
|
|
122
125
|
useApiQuery.key = (query)=>[
|
|
123
126
|
type,
|
|
@@ -159,10 +162,12 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
159
162
|
async onSuccess (data, variables, context) {
|
|
160
163
|
var _onSuccessBase;
|
|
161
164
|
const result = await ((_onSuccessBase = onSuccessBase) == null ? void 0 : _onSuccessBase(data, variables, context));
|
|
162
|
-
invalidateQueries && await Promise.allSettled(invalidateQueries.map((
|
|
165
|
+
invalidateQueries && await Promise.allSettled(invalidateQueries.map((queryKey)=>queryClient.invalidateQueries({
|
|
166
|
+
queryKey
|
|
167
|
+
})));
|
|
163
168
|
return result;
|
|
164
169
|
}
|
|
165
|
-
}));
|
|
170
|
+
}), queryClient);
|
|
166
171
|
}
|
|
167
172
|
useApiOperation.fetcher = (variables)=>fetcher(variables).pipe(uncapitalizedParse());
|
|
168
173
|
return useApiOperation;
|
|
@@ -188,11 +193,13 @@ function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider, ajaxOptions })
|
|
|
188
193
|
}, options, {
|
|
189
194
|
async onSuccess (data, variables, context) {
|
|
190
195
|
var _onSuccess;
|
|
191
|
-
invalidateQueries && await Promise.allSettled(invalidateQueries.map((queryKey)=>queryClient.invalidateQueries(
|
|
196
|
+
invalidateQueries && await Promise.allSettled(invalidateQueries.map((queryKey)=>queryClient.invalidateQueries({
|
|
197
|
+
queryKey
|
|
198
|
+
})));
|
|
192
199
|
const result = await ((_onSuccess = onSuccess) == null ? void 0 : _onSuccess(data, variables, context));
|
|
193
200
|
return result;
|
|
194
201
|
}
|
|
195
|
-
}));
|
|
202
|
+
}), queryClient);
|
|
196
203
|
}
|
|
197
204
|
useApiCommand.fetcher = (variables)=>fetcher(variables);
|
|
198
205
|
useApiCommand.call = (variables, handler)=>{
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/react-query-cqrs-client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/utils": "7.
|
|
7
|
-
"@leancodepl/validation": "7.
|
|
8
|
-
"@tanstack/react-query": ">=
|
|
6
|
+
"@leancodepl/utils": "7.2.2",
|
|
7
|
+
"@leancodepl/validation": "7.2.2",
|
|
8
|
+
"@tanstack/react-query": ">=5.0.0",
|
|
9
9
|
"rxjs": ">=7.0.0"
|
|
10
10
|
},
|
|
11
11
|
"type": "commonjs",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ApiResponse, CommandResult, TokenProvider } from "@leancodepl/cqrs-client-base";
|
|
2
2
|
import { ValidationErrorsHandler } from "@leancodepl/validation";
|
|
3
|
-
import
|
|
4
|
-
import { FetchQueryOptions, QueryClient, QueryFunctionContext, QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseMutationResult, UseQueryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { FetchQueryOptions, QueryClient, QueryFunctionContext, QueryKey, UseMutationOptions, UseMutationResult, Updater, UndefinedInitialDataInfiniteOptions, UndefinedInitialDataOptions } from "@tanstack/react-query";
|
|
5
4
|
import { Observable, OperatorFunction } from "rxjs";
|
|
6
5
|
import { AjaxConfig } from "rxjs/ajax";
|
|
7
6
|
import { NullableUncapitalizeDeep } from "./types";
|
|
@@ -13,13 +12,13 @@ export declare function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider,
|
|
|
13
12
|
ajaxOptions?: Omit<AjaxConfig, "headers" | "url" | "method" | "responseType" | "body" | "withCredentials">;
|
|
14
13
|
}): {
|
|
15
14
|
createQuery<TQuery, TResult>(type: string): {
|
|
16
|
-
(data: TQuery, options?: Omit<
|
|
15
|
+
(data: TQuery, options?: Omit<UndefinedInitialDataOptions<NullableUncapitalizeDeep<TResult>, unknown>, "queryKey" | "queryFn"> | undefined): import("@tanstack/react-query/build/legacy/types").UseQueryResult<NullableUncapitalizeDeep<TResult>, unknown>;
|
|
17
16
|
fetcher(data: TQuery, context?: QueryFunctionContext<QueryKey>): Observable<NullableUncapitalizeDeep<TResult>>;
|
|
18
|
-
fetch(data: TQuery, options?: Omit<FetchQueryOptions<NullableUncapitalizeDeep<TResult>, unknown, NullableUncapitalizeDeep<TResult>, QueryKey>, "queryKey" | "queryFn"> | undefined): Promise<NullableUncapitalizeDeep<TResult>>;
|
|
17
|
+
fetch(data: TQuery, options?: Omit<FetchQueryOptions<NullableUncapitalizeDeep<TResult>, unknown, NullableUncapitalizeDeep<TResult>, QueryKey, never>, "queryKey" | "queryFn"> | undefined): Promise<NullableUncapitalizeDeep<TResult>>;
|
|
19
18
|
lazy<TContext = unknown>(options?: Omit<UseMutationOptions<NullableUncapitalizeDeep<TResult>, unknown, TQuery, TContext>, "mutationFn" | "mutationKey">): UseMutationResult<NullableUncapitalizeDeep<TResult>, unknown, TQuery, TContext>;
|
|
20
|
-
infinite(data: TQuery, options
|
|
19
|
+
infinite(data: TQuery, options: Omit<UndefinedInitialDataInfiniteOptions<NullableUncapitalizeDeep<TResult>, unknown>, "queryKey" | "queryFn"> & {
|
|
21
20
|
pageParamKey?: keyof TQuery | undefined;
|
|
22
|
-
})
|
|
21
|
+
}): import("@tanstack/react-query/build/legacy/types").UseInfiniteQueryResult<import("@tanstack/query-core/build/legacy/queryClient-b7fce2ff").z<NullableUncapitalizeDeep<TResult>, unknown>, unknown>;
|
|
23
22
|
key(query: Partial<TQuery>): readonly [string, Partial<TQuery>];
|
|
24
23
|
setQueryData: {
|
|
25
24
|
(query: TQuery, updater: Updater<NullableUncapitalizeDeep<TResult> | undefined, NullableUncapitalizeDeep<TResult> | undefined>): NullableUncapitalizeDeep<TResult> | undefined;
|
|
@@ -27,7 +26,7 @@ export declare function mkCqrsClient({ cqrsEndpoint, queryClient, tokenProvider,
|
|
|
27
26
|
};
|
|
28
27
|
getQueryData(query: TQuery): NullableUncapitalizeDeep<TResult> | undefined;
|
|
29
28
|
getQueriesData(query: Partial<TQuery>): [QueryKey, NullableUncapitalizeDeep<TResult> | undefined][];
|
|
30
|
-
prefetch(data: TQuery, options?: Omit<FetchQueryOptions<NullableUncapitalizeDeep<TResult>, unknown, NullableUncapitalizeDeep<TResult>, QueryKey>, "queryKey" | "queryFn" | "initialData"> | undefined): Promise<void>;
|
|
29
|
+
prefetch(data: TQuery, options?: Omit<FetchQueryOptions<NullableUncapitalizeDeep<TResult>, unknown, NullableUncapitalizeDeep<TResult>, QueryKey, never>, "queryKey" | "queryFn" | "initialData"> | undefined): Promise<void>;
|
|
31
30
|
invalidate(query: Partial<TQuery>): Promise<void>;
|
|
32
31
|
};
|
|
33
32
|
createOperation<TOperation, TResult_1>(type: string): {
|