mobx-tanstack-query-api 0.0.102 → 0.0.104
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/package.json +8 -3
- package/runtime/endpoint-infinite-query.d.ts +19 -0
- package/runtime/endpoint-infinite-query.d.ts.map +1 -0
- package/runtime/endpoint-infinite-query.js +95 -0
- package/runtime/endpoint-infinite-query.types.d.ts +26 -0
- package/runtime/endpoint-infinite-query.types.d.ts.map +1 -0
- package/runtime/endpoint-infinite-query.types.js +1 -0
- package/runtime/endpoint-query.d.ts +8 -3
- package/runtime/endpoint-query.d.ts.map +1 -1
- package/runtime/endpoint-query.js +4 -13
- package/runtime/endpoint.d.ts +9 -1
- package/runtime/endpoint.d.ts.map +1 -1
- package/runtime/endpoint.js +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-tanstack-query-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.104",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"mobx": "^6.13.6"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tanstack/query-core": "^5.80.
|
|
22
|
+
"@tanstack/query-core": "^5.80.7",
|
|
23
23
|
"@types/lodash": "^4.17.16",
|
|
24
24
|
"@types/lodash-es": "^4.17.12",
|
|
25
25
|
"http-status-code-types": "^0.0.2",
|
|
26
|
-
"mobx-tanstack-query": "^5.3.
|
|
26
|
+
"mobx-tanstack-query": "^5.3.5",
|
|
27
27
|
"swagger-typescript-api": "13.2.7",
|
|
28
28
|
"ts-morph": "^26.0.0",
|
|
29
29
|
"yummies": "^4.0.0"
|
|
@@ -123,6 +123,11 @@
|
|
|
123
123
|
"default": "./index.js",
|
|
124
124
|
"types": "./index.d.ts"
|
|
125
125
|
},
|
|
126
|
+
"./runtime/endpoint-infinite-query": {
|
|
127
|
+
"import": "./runtime/endpoint-infinite-query.js",
|
|
128
|
+
"default": "./runtime/endpoint-infinite-query.js",
|
|
129
|
+
"types": "./runtime/endpoint-infinite-query.d.ts"
|
|
130
|
+
},
|
|
126
131
|
"./runtime/endpoint-mutation": {
|
|
127
132
|
"import": "./runtime/endpoint-mutation.js",
|
|
128
133
|
"default": "./runtime/endpoint-mutation.js",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DefaultError, InfiniteData, QueryKey, QueryObserverResult } from '@tanstack/query-core';
|
|
2
|
+
import { InfiniteQuery, InfiniteQueryUpdateOptionsAllVariants } from 'mobx-tanstack-query';
|
|
3
|
+
import { MaybeFalsy } from 'yummies/utils/types';
|
|
4
|
+
import { EndpointInfiniteQueryFlattenOptions, EndpointInfiniteQueryOptions } from './endpoint-infinite-query.types.js';
|
|
5
|
+
import { EndpointQueryClient } from './endpoint-query-client.js';
|
|
6
|
+
import { ExcludedQueryKeys } from './endpoint-query.types.js';
|
|
7
|
+
import { AnyEndpoint } from './endpoint.types.js';
|
|
8
|
+
export declare class EndpointInfiniteQuery<TEndpoint extends AnyEndpoint, TData, TError = DefaultError, TQueryKey extends QueryKey = any, TPageParam = unknown> extends InfiniteQuery<TData, TError, TQueryKey, TPageParam> {
|
|
9
|
+
private endpoint;
|
|
10
|
+
response: TEndpoint['__response'] | null;
|
|
11
|
+
params: TEndpoint['__params'] | null;
|
|
12
|
+
private uniqKey?;
|
|
13
|
+
constructor(endpoint: AnyEndpoint, queryClient: EndpointQueryClient, queryOptionsInput: EndpointInfiniteQueryOptions<TEndpoint, TData, TError, TQueryKey, TPageParam> | (() => EndpointInfiniteQueryFlattenOptions<TEndpoint, TData, TError, TQueryKey, TPageParam>));
|
|
14
|
+
update({ params, ...options }: Omit<InfiniteQueryUpdateOptionsAllVariants<TData, TError, TQueryKey, TPageParam>, ExcludedQueryKeys> & {
|
|
15
|
+
params?: MaybeFalsy<TEndpoint['__params']>;
|
|
16
|
+
}): void;
|
|
17
|
+
start(params: MaybeFalsy<TEndpoint['__params']>): Promise<QueryObserverResult<InfiniteData<TData, TPageParam>, TError>>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=endpoint-infinite-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-infinite-query.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-infinite-query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,EACb,qCAAqC,EACtC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAS,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,OAAO,EAEL,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,qBAAa,qBAAqB,CAChC,SAAS,SAAS,WAAW,EAC7B,KAAK,EACL,MAAM,GAAG,YAAY,EACrB,SAAS,SAAS,QAAQ,GAAG,GAAG,EAChC,UAAU,GAAG,OAAO,CACpB,SAAQ,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;IAOzD,OAAO,CAAC,QAAQ;IANlB,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,GAAG,IAAI,CAAQ;IAChD,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,IAAI,CAAQ;IAE5C,OAAO,CAAC,OAAO,CAAC,CAAuB;gBAG7B,QAAQ,EAAE,WAAW,EAC7B,WAAW,EAAE,mBAAmB,EAEhC,iBAAiB,EACb,4BAA4B,CAC1B,SAAS,EACT,KAAK,EACL,MAAM,EACN,SAAS,EACT,UAAU,CACX,GACD,CAAC,MAAM,mCAAmC,CACxC,SAAS,EACT,KAAK,EACL,MAAM,EACN,SAAS,EACT,UAAU,CACX,CAAC;IAgGR,MAAM,CAAC,EACL,MAAM,EACN,GAAG,OAAO,EACX,EAAE,IAAI,CACL,qCAAqC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,EAC3E,iBAAiB,CAClB,GAAG;QACF,MAAM,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;KAC5C;IAOK,KAAK,CACT,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,GACxC,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;CAKzE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { makeObservable, observable, runInAction } from 'mobx';
|
|
2
|
+
import { InfiniteQuery, } from 'mobx-tanstack-query';
|
|
3
|
+
import { buildOptionsFromParams, getParamsFromContext, } from './endpoint-query.js';
|
|
4
|
+
export class EndpointInfiniteQuery extends InfiniteQuery {
|
|
5
|
+
endpoint;
|
|
6
|
+
response = null;
|
|
7
|
+
params = null;
|
|
8
|
+
uniqKey;
|
|
9
|
+
constructor(endpoint, queryClient, queryOptionsInput) {
|
|
10
|
+
const { uniqKey, transform: transformResponse, ...queryOptions } = typeof queryOptionsInput === 'function'
|
|
11
|
+
? queryOptionsInput()
|
|
12
|
+
: queryOptionsInput;
|
|
13
|
+
super({
|
|
14
|
+
...queryOptions,
|
|
15
|
+
queryClient,
|
|
16
|
+
meta: endpoint.toQueryMeta(queryOptions.meta),
|
|
17
|
+
options: (query) => {
|
|
18
|
+
const extraOptions = {};
|
|
19
|
+
let willEnableManually;
|
|
20
|
+
let params;
|
|
21
|
+
if (typeof queryOptionsInput === 'function') {
|
|
22
|
+
const { params: dynamicParams, ...dynamicOptions } = queryOptionsInput();
|
|
23
|
+
Object.assign(extraOptions, dynamicOptions);
|
|
24
|
+
params = dynamicParams;
|
|
25
|
+
willEnableManually = false;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
willEnableManually = queryOptions.enabled === false;
|
|
29
|
+
params = (queryOptionsInput.params?.() || {});
|
|
30
|
+
}
|
|
31
|
+
const builtOptions = buildOptionsFromParams(endpoint, params, uniqKey);
|
|
32
|
+
// const dynamicOuterOptions = getDynamicOptions?.(query);
|
|
33
|
+
let isEnabled = false;
|
|
34
|
+
if (willEnableManually) {
|
|
35
|
+
// if (dynamicOuterOptions?.enabled != null) {
|
|
36
|
+
// isEnabled = dynamicOuterOptions.enabled;
|
|
37
|
+
// }
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// const outerDynamicEnabled =
|
|
41
|
+
// dynamicOuterOptions?.enabled == null ||
|
|
42
|
+
// !!dynamicOuterOptions.enabled;
|
|
43
|
+
// isEnabled = builtOptions.enabled && outerDynamicEnabled;
|
|
44
|
+
isEnabled = builtOptions.enabled;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
...query.options,
|
|
48
|
+
...builtOptions,
|
|
49
|
+
// ...dynamicOuterOptions,
|
|
50
|
+
enabled: isEnabled,
|
|
51
|
+
...extraOptions,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
queryFn: async (ctx) => {
|
|
55
|
+
const params = getParamsFromContext(ctx);
|
|
56
|
+
runInAction(() => {
|
|
57
|
+
this.response = null;
|
|
58
|
+
this.params = params;
|
|
59
|
+
});
|
|
60
|
+
let requestParams = params.request;
|
|
61
|
+
if (requestParams) {
|
|
62
|
+
if (!requestParams.signal) {
|
|
63
|
+
requestParams.signal = ctx.signal;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
requestParams = { signal: ctx.signal };
|
|
68
|
+
}
|
|
69
|
+
const fixedInput = {
|
|
70
|
+
...params,
|
|
71
|
+
request: requestParams,
|
|
72
|
+
};
|
|
73
|
+
const response = await endpoint.request(fixedInput);
|
|
74
|
+
runInAction(() => {
|
|
75
|
+
this.response = response;
|
|
76
|
+
});
|
|
77
|
+
return (await transformResponse?.(response)) ?? response.data;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
this.endpoint = endpoint;
|
|
81
|
+
this.uniqKey = uniqKey;
|
|
82
|
+
observable.ref(this, 'response');
|
|
83
|
+
observable.ref(this, 'params');
|
|
84
|
+
makeObservable(this);
|
|
85
|
+
}
|
|
86
|
+
update({ params, ...options }) {
|
|
87
|
+
return super.update({
|
|
88
|
+
...buildOptionsFromParams(this.endpoint, params, this.uniqKey),
|
|
89
|
+
...options,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async start(params) {
|
|
93
|
+
return await super.start(buildOptionsFromParams(this.endpoint, params, this.uniqKey));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DefaultError, QueryKey } from '@tanstack/query-core';
|
|
2
|
+
import { InfiniteQueryConfig } from 'mobx-tanstack-query';
|
|
3
|
+
import { MaybeFalsy, RequiredKeys } from 'yummies/utils/types';
|
|
4
|
+
import { EndpointQueryUniqKey, ExcludedQueryKeys } from './endpoint-query.types.js';
|
|
5
|
+
import { AnyEndpoint } from './endpoint.types.js';
|
|
6
|
+
type ShortInfiniteQueryConfig<TQueryFnData, TError = DefaultError, TQueryKey extends QueryKey = any, TPageParam = unknown> = Omit<RequiredKeys<InfiniteQueryConfig<TQueryFnData, TError, TQueryKey, TPageParam>, 'getNextPageParam'>, ExcludedQueryKeys> & {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type EndpointInfiniteQueryFlattenOptions<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TQueryKey extends QueryKey = any, TPageParam = unknown> = ShortInfiniteQueryConfig<NoInfer<TQueryFnData>, TError, TQueryKey, TPageParam> & {
|
|
10
|
+
uniqKey?: EndpointQueryUniqKey;
|
|
11
|
+
params?: MaybeFalsy<TEndpoint['__params']>;
|
|
12
|
+
/**
|
|
13
|
+
* Transform response to QueryFnData
|
|
14
|
+
*/
|
|
15
|
+
transform?: (response: TEndpoint['__response']) => TQueryFnData | Promise<TQueryFnData>;
|
|
16
|
+
};
|
|
17
|
+
export type EndpointInfiniteQueryOptions<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TQueryKey extends QueryKey = any, TPageParam = unknown> = ShortInfiniteQueryConfig<NoInfer<TQueryFnData>, TError, TQueryKey, TPageParam> & {
|
|
18
|
+
uniqKey?: EndpointQueryUniqKey;
|
|
19
|
+
params?: () => MaybeFalsy<TEndpoint['__params']>;
|
|
20
|
+
/**
|
|
21
|
+
* Transform response to QueryFnData
|
|
22
|
+
*/
|
|
23
|
+
transform?: (response: TEndpoint['__response']) => TQueryFnData | Promise<TQueryFnData>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=endpoint-infinite-query.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-infinite-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-infinite-query.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,KAAK,wBAAwB,CAC3B,YAAY,EACZ,MAAM,GAAG,YAAY,EACrB,SAAS,SAAS,QAAQ,GAAG,G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CAAC,KAC9B,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DefaultError, QueryObserverResult } from '@tanstack/query-core';
|
|
1
|
+
import { DefaultError, QueryFunctionContext, QueryObserverResult } from '@tanstack/query-core';
|
|
2
2
|
import { Query, QueryUpdateOptionsAllVariants } from 'mobx-tanstack-query';
|
|
3
|
-
import { MaybeFalsy } from 'yummies/utils/types';
|
|
3
|
+
import { AnyObject, Maybe, MaybeFalsy } from 'yummies/utils/types';
|
|
4
4
|
import { EndpointQueryClient } from './endpoint-query-client.js';
|
|
5
|
-
import { EndpointQueryFlattenOptions, EndpointQueryOptions, ExcludedQueryKeys } from './endpoint-query.types.js';
|
|
5
|
+
import { EndpointQueryFlattenOptions, EndpointQueryOptions, EndpointQueryUniqKey, ExcludedQueryKeys } from './endpoint-query.types.js';
|
|
6
6
|
import { AnyEndpoint } from './endpoint.types.js';
|
|
7
7
|
export declare class EndpointQuery<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData> extends Query<TQueryFnData, TError, TData, TQueryData> {
|
|
8
8
|
private endpoint;
|
|
@@ -15,4 +15,9 @@ export declare class EndpointQuery<TEndpoint extends AnyEndpoint, TQueryFnData =
|
|
|
15
15
|
}): void;
|
|
16
16
|
start(params: MaybeFalsy<TEndpoint['__params']>): Promise<QueryObserverResult<TData, TError>>;
|
|
17
17
|
}
|
|
18
|
+
export declare const getParamsFromContext: (ctx: QueryFunctionContext<any, any>) => AnyEndpoint["__params"];
|
|
19
|
+
export declare const buildOptionsFromParams: (endpoint: AnyEndpoint, params: MaybeFalsy<AnyObject>, uniqKey: Maybe<EndpointQueryUniqKey>) => {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
queryKey: any;
|
|
22
|
+
};
|
|
18
23
|
//# sourceMappingURL=endpoint-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"endpoint-query.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,qBAAa,aAAa,CACxB,SAAS,SAAS,WAAW,EAC7B,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAC9C,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,UAAU,GAAG,YAAY,CACzB,SAAQ,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC;IAOpD,OAAO,CAAC,QAAQ;IANlB,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,GAAG,IAAI,CAAQ;IAChD,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,IAAI,CAAQ;IAE5C,OAAO,CAAC,OAAO,CAAC,CAAuB;gBAG7B,QAAQ,EAAE,WAAW,EAC7B,WAAW,EAAE,mBAAmB,EAChC,iBAAiB,EACb,oBAAoB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,GACxE,CAAC,MAAM,2BAA2B,CAChC,SAAS,EACT,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,CACX,CAAC;IAgGR,MAAM,CAAC,EACL,MAAM,EACN,GAAG,OAAO,EACX,EAAE,IAAI,CACL,6BAA6B,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,EACtE,iBAAiB,CAClB,GAAG;QACF,MAAM,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;KAC5C;IAOK,KAAK,CACT,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,GACxC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAK/C;AAED,eAAO,MAAM,oBAAoB,GAAI,KAAK,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,KAChC,WAAW,CAAC,UAAU,CAC7D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,UAAU,WAAW,EACrB,QAAQ,UAAU,CAAC,SAAS,CAAC,EAC7B,SAAS,KAAK,CAAC,oBAAoB,CAAC;;;CAgBrC,CAAC"}
|
|
@@ -12,7 +12,7 @@ export class EndpointQuery extends Query {
|
|
|
12
12
|
super({
|
|
13
13
|
...queryOptions,
|
|
14
14
|
queryClient,
|
|
15
|
-
meta:
|
|
15
|
+
meta: endpoint.toQueryMeta(queryOptions.meta),
|
|
16
16
|
options: (query) => {
|
|
17
17
|
const extraOptions = {};
|
|
18
18
|
let willEnableManually;
|
|
@@ -92,19 +92,10 @@ export class EndpointQuery extends Query {
|
|
|
92
92
|
return await super.start(buildOptionsFromParams(this.endpoint, params, this.uniqKey));
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
const
|
|
96
|
-
...meta,
|
|
97
|
-
tags: endpoint.tags,
|
|
98
|
-
operationId: endpoint.operationId,
|
|
99
|
-
path: endpoint.path,
|
|
100
|
-
pathDeclaration: endpoint.path.join('/'),
|
|
101
|
-
endpointId: endpoint.endpointId,
|
|
102
|
-
endpointQuery: true,
|
|
103
|
-
});
|
|
104
|
-
const getParamsFromContext = (ctx) => {
|
|
95
|
+
export const getParamsFromContext = (ctx) => {
|
|
105
96
|
return (ctx.queryKey.at(-2) || {});
|
|
106
97
|
};
|
|
107
|
-
const buildOptionsFromParams = (endpoint, params, uniqKey) => {
|
|
98
|
+
export const buildOptionsFromParams = (endpoint, params, uniqKey) => {
|
|
108
99
|
const { requiredParams } = endpoint.configuration;
|
|
109
100
|
let hasRequiredParams = false;
|
|
110
101
|
if (requiredParams.length > 0) {
|
|
@@ -116,6 +107,6 @@ const buildOptionsFromParams = (endpoint, params, uniqKey) => {
|
|
|
116
107
|
}
|
|
117
108
|
return {
|
|
118
109
|
enabled: hasRequiredParams,
|
|
119
|
-
queryKey: endpoint.
|
|
110
|
+
queryKey: endpoint.toQueryKey(params || {}, uniqKey),
|
|
120
111
|
};
|
|
121
112
|
};
|
package/runtime/endpoint.d.ts
CHANGED
|
@@ -30,7 +30,15 @@ export declare class Endpoint<TResponse extends HttpResponse<any, any>, TParams
|
|
|
30
30
|
get group(): string | undefined;
|
|
31
31
|
get namespace(): string | undefined;
|
|
32
32
|
request(...args: AllPropertiesOptional<TParams> extends true ? [input?: TParams] : [input: TParams]): Promise<TResponse>;
|
|
33
|
-
|
|
33
|
+
toQueryMeta: (meta?: AnyObject) => {
|
|
34
|
+
tags: string[];
|
|
35
|
+
operationId: string;
|
|
36
|
+
path: string[];
|
|
37
|
+
pathDeclaration: string;
|
|
38
|
+
endpointId: string;
|
|
39
|
+
endpointQuery: true;
|
|
40
|
+
};
|
|
41
|
+
toQueryKey(...args: AllPropertiesOptional<TParams> extends true ? [input?: TParams, uniqKey?: EndpointQueryUniqKey] : [input: TParams, uniqKey?: EndpointQueryUniqKey]): any;
|
|
34
42
|
invalidateQuery(...args: AllPropertiesOptional<TParams> extends true ? [
|
|
35
43
|
input?: TParams,
|
|
36
44
|
filters?: InvalidateQueryFilters & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,2BAA2B,
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,2BAA2B,EAE3B,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjE,MAAM,WAAW,QAAQ,CACvB,SAAS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MAAM,CAAC,EAChC,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,UAAU,GAAG,YAAY,EAEzB,OAAO,EACH,oBAAoB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,GACnE,CAAC,MAAM,2BAA2B,CAChC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,CACX,CAAC;CAQT"}
|
package/runtime/endpoint.js
CHANGED
|
@@ -65,7 +65,16 @@ export class Endpoint {
|
|
|
65
65
|
request(...args) {
|
|
66
66
|
return this.http.request(this.configuration.params(args[0] ?? {}));
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
toQueryMeta = (meta) => ({
|
|
69
|
+
...meta,
|
|
70
|
+
tags: this.tags,
|
|
71
|
+
operationId: this.operationId,
|
|
72
|
+
path: this.path,
|
|
73
|
+
pathDeclaration: this.path.join('/'),
|
|
74
|
+
endpointId: this.endpointId,
|
|
75
|
+
endpointQuery: true,
|
|
76
|
+
});
|
|
77
|
+
toQueryKey(...args) {
|
|
69
78
|
const params = args[0] ?? {};
|
|
70
79
|
return [
|
|
71
80
|
...this.configuration.path,
|
|
@@ -77,7 +86,7 @@ export class Endpoint {
|
|
|
77
86
|
invalidateQuery(...args) {
|
|
78
87
|
this.queryClient.invalidateQueries({
|
|
79
88
|
// @ts-ignore
|
|
80
|
-
queryKey: this.
|
|
89
|
+
queryKey: this.toQueryKey(args[0], args[1]?.uniqKey),
|
|
81
90
|
exact: true,
|
|
82
91
|
...args[1],
|
|
83
92
|
}, args[2]);
|