mobx-tanstack-query-api 0.24.0 → 0.26.0
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/builtin.cjs +27 -0
- package/builtin.cjs.map +1 -0
- package/builtin.d.ts +6 -0
- package/builtin.js +27 -0
- package/builtin.js.map +1 -0
- package/cli.cjs +1279 -0
- package/cli.cjs.map +1 -0
- package/{codegen/types/generate-query-api-params.d.cts → cli.d.ts} +55 -10
- package/cli.js +1278 -0
- package/cli.js.map +1 -0
- package/index.cjs +771 -16
- package/index.cjs.map +1 -0
- package/index.d.ts +322 -2
- package/index.js +768 -2
- package/index.js.map +1 -0
- package/package.json +21 -64
- package/builtin/index.cjs +0 -25
- package/builtin/index.d.cts +0 -4
- package/builtin/index.d.cts.map +0 -1
- package/builtin/index.d.ts +0 -4
- package/builtin/index.d.ts.map +0 -1
- package/builtin/index.js +0 -22
- package/cli/bin.cjs +0 -17
- package/cli/bin.d.cts +0 -2
- package/cli/bin.d.cts.map +0 -1
- package/cli/bin.d.ts +0 -2
- package/cli/bin.d.ts.map +0 -1
- package/cli/bin.js +0 -15
- package/cli/index.cjs +0 -18
- package/cli/index.d.cts +0 -3
- package/cli/index.d.cts.map +0 -1
- package/cli/index.d.ts +0 -3
- package/cli/index.d.ts.map +0 -1
- package/cli/index.js +0 -2
- package/cli/utils/define-config.cjs +0 -9
- package/cli/utils/define-config.d.cts +0 -4
- package/cli/utils/define-config.d.cts.map +0 -1
- package/cli/utils/define-config.d.ts +0 -4
- package/cli/utils/define-config.d.ts.map +0 -1
- package/cli/utils/define-config.js +0 -5
- package/cli/utils/exec-config-path.cjs +0 -16
- package/cli/utils/exec-config-path.d.cts +0 -2
- package/cli/utils/exec-config-path.d.cts.map +0 -1
- package/cli/utils/exec-config-path.d.ts +0 -2
- package/cli/utils/exec-config-path.d.ts.map +0 -1
- package/cli/utils/exec-config-path.js +0 -12
- package/cli/utils/resolve-config-path.cjs +0 -65
- package/cli/utils/resolve-config-path.d.cts +0 -3
- package/cli/utils/resolve-config-path.d.cts.map +0 -1
- package/cli/utils/resolve-config-path.d.ts +0 -3
- package/cli/utils/resolve-config-path.d.ts.map +0 -1
- package/cli/utils/resolve-config-path.js +0 -25
- package/codegen/index.cjs +0 -545
- package/codegen/index.d.cts +0 -4
- package/codegen/index.d.cts.map +0 -1
- package/codegen/index.d.ts +0 -4
- package/codegen/index.d.ts.map +0 -1
- package/codegen/index.js +0 -524
- package/codegen/templates/all-endpoints-per-file.tmpl.cjs +0 -94
- package/codegen/templates/all-endpoints-per-file.tmpl.d.cts +0 -14
- package/codegen/templates/all-endpoints-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +0 -14
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.js +0 -90
- package/codegen/templates/all-exports.tmpl.cjs +0 -14
- package/codegen/templates/all-exports.tmpl.d.cts +0 -9
- package/codegen/templates/all-exports.tmpl.d.cts.map +0 -1
- package/codegen/templates/all-exports.tmpl.d.ts +0 -9
- package/codegen/templates/all-exports.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-exports.tmpl.js +0 -9
- package/codegen/templates/constants.cjs +0 -5
- package/codegen/templates/constants.d.cts +0 -2
- package/codegen/templates/constants.d.cts.map +0 -1
- package/codegen/templates/constants.d.ts +0 -2
- package/codegen/templates/constants.d.ts.map +0 -1
- package/codegen/templates/constants.js +0 -2
- package/codegen/templates/data-contract.tmpl.cjs +0 -49
- package/codegen/templates/data-contract.tmpl.d.cts +0 -8
- package/codegen/templates/data-contract.tmpl.d.cts.map +0 -1
- package/codegen/templates/data-contract.tmpl.d.ts +0 -8
- package/codegen/templates/data-contract.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contract.tmpl.js +0 -45
- package/codegen/templates/data-contracts-file.tmpl.cjs +0 -27
- package/codegen/templates/data-contracts-file.tmpl.d.cts +0 -6
- package/codegen/templates/data-contracts-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.d.ts +0 -6
- package/codegen/templates/data-contracts-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.js +0 -23
- package/codegen/templates/endpoint-jsdoc.tmpl.cjs +0 -111
- package/codegen/templates/endpoint-jsdoc.tmpl.d.cts +0 -8
- package/codegen/templates/endpoint-jsdoc.tmpl.d.cts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts +0 -8
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.js +0 -107
- package/codegen/templates/endpoint-per-file.tmpl.cjs +0 -87
- package/codegen/templates/endpoint-per-file.tmpl.d.cts +0 -14
- package/codegen/templates/endpoint-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.d.ts +0 -14
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.js +0 -83
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.cjs +0 -10
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts +0 -6
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +0 -6
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.js +0 -6
- package/codegen/templates/meta-info.tmpl.cjs +0 -48
- package/codegen/templates/meta-info.tmpl.d.cts +0 -9
- package/codegen/templates/meta-info.tmpl.d.cts.map +0 -1
- package/codegen/templates/meta-info.tmpl.d.ts +0 -9
- package/codegen/templates/meta-info.tmpl.d.ts.map +0 -1
- package/codegen/templates/meta-info.tmpl.js +0 -42
- package/codegen/templates/new-endpoint.tmpl.cjs +0 -188
- package/codegen/templates/new-endpoint.tmpl.d.cts +0 -15
- package/codegen/templates/new-endpoint.tmpl.d.cts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.d.ts +0 -15
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.js +0 -184
- package/codegen/types/all-import-file-params.cjs +0 -2
- package/codegen/types/all-import-file-params.d.cts +0 -5
- package/codegen/types/all-import-file-params.d.cts.map +0 -1
- package/codegen/types/all-import-file-params.d.ts +0 -5
- package/codegen/types/all-import-file-params.d.ts.map +0 -1
- package/codegen/types/all-import-file-params.js +0 -1
- package/codegen/types/base-tmpl-params.cjs +0 -2
- package/codegen/types/base-tmpl-params.d.cts +0 -16
- package/codegen/types/base-tmpl-params.d.cts.map +0 -1
- package/codegen/types/base-tmpl-params.d.ts +0 -16
- package/codegen/types/base-tmpl-params.d.ts.map +0 -1
- package/codegen/types/base-tmpl-params.js +0 -1
- package/codegen/types/codegen-data-utils.cjs +0 -2
- package/codegen/types/codegen-data-utils.d.cts +0 -8
- package/codegen/types/codegen-data-utils.d.cts.map +0 -1
- package/codegen/types/codegen-data-utils.d.ts +0 -8
- package/codegen/types/codegen-data-utils.d.ts.map +0 -1
- package/codegen/types/codegen-data-utils.js +0 -1
- package/codegen/types/endpoint-data.cjs +0 -2
- package/codegen/types/endpoint-data.d.cts +0 -3
- package/codegen/types/endpoint-data.d.cts.map +0 -1
- package/codegen/types/endpoint-data.d.ts +0 -3
- package/codegen/types/endpoint-data.d.ts.map +0 -1
- package/codegen/types/endpoint-data.js +0 -1
- package/codegen/types/generate-query-api-params.cjs +0 -2
- package/codegen/types/generate-query-api-params.d.cts.map +0 -1
- package/codegen/types/generate-query-api-params.d.ts +0 -162
- package/codegen/types/generate-query-api-params.d.ts.map +0 -1
- package/codegen/types/generate-query-api-params.js +0 -1
- package/codegen/types/import-file-params.cjs +0 -2
- package/codegen/types/import-file-params.d.cts +0 -5
- package/codegen/types/import-file-params.d.cts.map +0 -1
- package/codegen/types/import-file-params.d.ts +0 -5
- package/codegen/types/import-file-params.d.ts.map +0 -1
- package/codegen/types/import-file-params.js +0 -1
- package/codegen/types/index.cjs +0 -23
- package/codegen/types/index.d.cts +0 -8
- package/codegen/types/index.d.cts.map +0 -1
- package/codegen/types/index.d.ts +0 -8
- package/codegen/types/index.d.ts.map +0 -1
- package/codegen/types/index.js +0 -7
- package/codegen/types/meta-info.cjs +0 -2
- package/codegen/types/meta-info.d.cts +0 -6
- package/codegen/types/meta-info.d.cts.map +0 -1
- package/codegen/types/meta-info.d.ts +0 -6
- package/codegen/types/meta-info.d.ts.map +0 -1
- package/codegen/types/meta-info.js +0 -1
- package/codegen/types/type-info.cjs +0 -2
- package/codegen/types/type-info.d.cts +0 -4
- package/codegen/types/type-info.d.cts.map +0 -1
- package/codegen/types/type-info.d.ts +0 -4
- package/codegen/types/type-info.d.ts.map +0 -1
- package/codegen/types/type-info.js +0 -1
- package/codegen/utils/create-short-model-type.cjs +0 -12
- package/codegen/utils/create-short-model-type.d.cts +0 -5
- package/codegen/utils/create-short-model-type.d.cts.map +0 -1
- package/codegen/utils/create-short-model-type.d.ts +0 -5
- package/codegen/utils/create-short-model-type.d.ts.map +0 -1
- package/codegen/utils/create-short-model-type.js +0 -8
- package/codegen/utils/remove-unused-types.cjs +0 -117
- package/codegen/utils/remove-unused-types.d.cts +0 -7
- package/codegen/utils/remove-unused-types.d.cts.map +0 -1
- package/codegen/utils/remove-unused-types.d.ts +0 -7
- package/codegen/utils/remove-unused-types.d.ts.map +0 -1
- package/codegen/utils/remove-unused-types.js +0 -110
- package/codegen/utils/unpack-filter-option.cjs +0 -23
- package/codegen/utils/unpack-filter-option.d.cts +0 -7
- package/codegen/utils/unpack-filter-option.d.cts.map +0 -1
- package/codegen/utils/unpack-filter-option.d.ts +0 -7
- package/codegen/utils/unpack-filter-option.d.ts.map +0 -1
- package/codegen/utils/unpack-filter-option.js +0 -19
- package/index.d.cts +0 -3
- package/index.d.cts.map +0 -1
- package/index.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.cjs +0 -101
- package/runtime/endpoint-infinite-query.d.cts +0 -17
- package/runtime/endpoint-infinite-query.d.cts.map +0 -1
- package/runtime/endpoint-infinite-query.d.ts +0 -17
- package/runtime/endpoint-infinite-query.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.js +0 -97
- package/runtime/endpoint-infinite-query.types.cjs +0 -2
- package/runtime/endpoint-infinite-query.types.d.cts +0 -30
- package/runtime/endpoint-infinite-query.types.d.cts.map +0 -1
- package/runtime/endpoint-infinite-query.types.d.ts +0 -30
- package/runtime/endpoint-infinite-query.types.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.types.js +0 -1
- package/runtime/endpoint-mutation.cjs +0 -74
- package/runtime/endpoint-mutation.d.cts +0 -13
- package/runtime/endpoint-mutation.d.cts.map +0 -1
- package/runtime/endpoint-mutation.d.ts +0 -13
- package/runtime/endpoint-mutation.d.ts.map +0 -1
- package/runtime/endpoint-mutation.js +0 -70
- package/runtime/endpoint-mutation.types.cjs +0 -2
- package/runtime/endpoint-mutation.types.d.cts +0 -36
- package/runtime/endpoint-mutation.types.d.cts.map +0 -1
- package/runtime/endpoint-mutation.types.d.ts +0 -36
- package/runtime/endpoint-mutation.types.d.ts.map +0 -1
- package/runtime/endpoint-mutation.types.js +0 -1
- package/runtime/endpoint-query-client.cjs +0 -79
- package/runtime/endpoint-query-client.d.cts +0 -13
- package/runtime/endpoint-query-client.d.cts.map +0 -1
- package/runtime/endpoint-query-client.d.ts +0 -13
- package/runtime/endpoint-query-client.d.ts.map +0 -1
- package/runtime/endpoint-query-client.js +0 -75
- package/runtime/endpoint-query-client.types.cjs +0 -2
- package/runtime/endpoint-query-client.types.d.cts +0 -16
- package/runtime/endpoint-query-client.types.d.cts.map +0 -1
- package/runtime/endpoint-query-client.types.d.ts +0 -16
- package/runtime/endpoint-query-client.types.d.ts.map +0 -1
- package/runtime/endpoint-query-client.types.js +0 -1
- package/runtime/endpoint-query.cjs +0 -214
- package/runtime/endpoint-query.d.cts +0 -29
- package/runtime/endpoint-query.d.cts.map +0 -1
- package/runtime/endpoint-query.d.ts +0 -29
- package/runtime/endpoint-query.d.ts.map +0 -1
- package/runtime/endpoint-query.js +0 -208
- package/runtime/endpoint-query.types.cjs +0 -2
- package/runtime/endpoint-query.types.d.cts +0 -42
- package/runtime/endpoint-query.types.d.cts.map +0 -1
- package/runtime/endpoint-query.types.d.ts +0 -42
- package/runtime/endpoint-query.types.d.ts.map +0 -1
- package/runtime/endpoint-query.types.js +0 -1
- package/runtime/endpoint.cjs +0 -131
- package/runtime/endpoint.d.cts +0 -73
- package/runtime/endpoint.d.cts.map +0 -1
- package/runtime/endpoint.d.ts +0 -73
- package/runtime/endpoint.d.ts.map +0 -1
- package/runtime/endpoint.js +0 -127
- package/runtime/endpoint.types.cjs +0 -2
- package/runtime/endpoint.types.d.cts +0 -24
- package/runtime/endpoint.types.d.cts.map +0 -1
- package/runtime/endpoint.types.d.ts +0 -24
- package/runtime/endpoint.types.d.ts.map +0 -1
- package/runtime/endpoint.types.js +0 -1
- package/runtime/http-client.cjs +0 -190
- package/runtime/http-client.d.cts +0 -85
- package/runtime/http-client.d.cts.map +0 -1
- package/runtime/http-client.d.ts +0 -85
- package/runtime/http-client.d.ts.map +0 -1
- package/runtime/http-client.js +0 -184
- package/runtime/index.cjs +0 -25
- package/runtime/index.d.cts +0 -10
- package/runtime/index.d.cts.map +0 -1
- package/runtime/index.d.ts +0 -10
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -9
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { makeObservable, observable, runInAction } from 'mobx';
|
|
2
|
-
import { InfiniteQuery } from 'mobx-tanstack-query';
|
|
3
|
-
import { buildOptionsFromParams } from "./endpoint-query.js";
|
|
4
|
-
export class EndpointInfiniteQuery extends InfiniteQuery {
|
|
5
|
-
endpoint;
|
|
6
|
-
response = null;
|
|
7
|
-
params = null;
|
|
8
|
-
uniqKey;
|
|
9
|
-
paramsFn;
|
|
10
|
-
constructor(endpoint, queryClient, queryOptionsInput) {
|
|
11
|
-
const { uniqKey, transform: transformResponse, params: paramsFn, ...queryOptions } = typeof queryOptionsInput === 'function'
|
|
12
|
-
? queryOptionsInput()
|
|
13
|
-
: queryOptionsInput;
|
|
14
|
-
super({
|
|
15
|
-
...queryOptions,
|
|
16
|
-
queryClient,
|
|
17
|
-
meta: endpoint.toQueryMeta(queryOptions.meta),
|
|
18
|
-
options: (query) => {
|
|
19
|
-
const extraOptions = {};
|
|
20
|
-
let willEnableManually;
|
|
21
|
-
let params;
|
|
22
|
-
const pageParam = query.options.initialPageParam;
|
|
23
|
-
if (typeof queryOptionsInput === 'function') {
|
|
24
|
-
Object.assign(extraOptions, queryOptionsInput());
|
|
25
|
-
params = paramsFn(pageParam);
|
|
26
|
-
willEnableManually = false;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
willEnableManually = queryOptionsInput.enabled === false;
|
|
30
|
-
params = paramsFn(pageParam);
|
|
31
|
-
}
|
|
32
|
-
const builtOptions = buildOptionsFromParams(endpoint, params, uniqKey);
|
|
33
|
-
// const dynamicOuterOptions = getDynamicOptions?.(query);
|
|
34
|
-
let isEnabled = false;
|
|
35
|
-
if (willEnableManually) {
|
|
36
|
-
// if (dynamicOuterOptions?.enabled != null) {
|
|
37
|
-
// isEnabled = dynamicOuterOptions.enabled;
|
|
38
|
-
// }
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// const outerDynamicEnabled =
|
|
42
|
-
// dynamicOuterOptions?.enabled == null ||
|
|
43
|
-
// !!dynamicOuterOptions.enabled;
|
|
44
|
-
// isEnabled = builtOptions.enabled && outerDynamicEnabled;
|
|
45
|
-
isEnabled = builtOptions.enabled;
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
...query.options,
|
|
49
|
-
...builtOptions,
|
|
50
|
-
// ...dynamicOuterOptions,
|
|
51
|
-
enabled: isEnabled,
|
|
52
|
-
...extraOptions,
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
queryFn: async (ctx) => {
|
|
56
|
-
const params = paramsFn(ctx.pageParam ?? queryOptions.initialPageParam);
|
|
57
|
-
runInAction(() => {
|
|
58
|
-
this.response = null;
|
|
59
|
-
this.params = params;
|
|
60
|
-
});
|
|
61
|
-
let requestParams = params.request;
|
|
62
|
-
if (requestParams) {
|
|
63
|
-
if (!requestParams.signal) {
|
|
64
|
-
requestParams.signal = ctx.signal;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
requestParams = { signal: ctx.signal };
|
|
69
|
-
}
|
|
70
|
-
const fixedInput = {
|
|
71
|
-
...params,
|
|
72
|
-
request: requestParams,
|
|
73
|
-
};
|
|
74
|
-
const response = await endpoint.request(fixedInput);
|
|
75
|
-
runInAction(() => {
|
|
76
|
-
this.response = response;
|
|
77
|
-
});
|
|
78
|
-
return (await transformResponse?.(response)) ?? response.data;
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
this.endpoint = endpoint;
|
|
82
|
-
this.paramsFn = paramsFn;
|
|
83
|
-
this.uniqKey = uniqKey;
|
|
84
|
-
observable.ref(this, 'response');
|
|
85
|
-
observable.ref(this, 'params');
|
|
86
|
-
makeObservable(this);
|
|
87
|
-
}
|
|
88
|
-
update({ params, ...options }) {
|
|
89
|
-
return super.update({
|
|
90
|
-
...buildOptionsFromParams(this.endpoint, params, this.uniqKey),
|
|
91
|
-
...options,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
async start(params) {
|
|
95
|
-
return await super.start(buildOptionsFromParams(this.endpoint, params, this.uniqKey));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { DefaultError, InfiniteData } from '@tanstack/query-core';
|
|
2
|
-
import type { InfiniteQueryConfig, InfiniteQueryDynamicOptions, InfiniteQueryOptions, InfiniteQueryUpdateOptions } from 'mobx-tanstack-query';
|
|
3
|
-
import type { AnyObject, MaybeFalsy } from 'yummies/utils/types';
|
|
4
|
-
import type { AnyEndpoint } from "./endpoint.types.cjs";
|
|
5
|
-
import type { EndpointQueryUniqKey, ExcludedQueryKeys } from "./endpoint-query.types.cjs";
|
|
6
|
-
type ShortInfiniteQueryConfig<TQueryFnData, TError = DefaultError, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = Omit<InfiniteQueryConfig<TQueryFnData, TError, TPageParam, TData, any[]>, ExcludedQueryKeys> & {
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type EndpointInfiniteQueryFlattenOptions<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = ShortInfiniteQueryConfig<NoInfer<TQueryFnData>, TError, TPageParam, TData> & {
|
|
10
|
-
uniqKey?: EndpointQueryUniqKey;
|
|
11
|
-
params: (pageParam: NoInfer<TPageParam>) => 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, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = ShortInfiniteQueryConfig<NoInfer<TQueryFnData>, TError, TPageParam, TData> & {
|
|
18
|
-
uniqKey?: EndpointQueryUniqKey;
|
|
19
|
-
params: (pageParam: NoInfer<TPageParam>) => MaybeFalsy<TEndpoint['__params']>;
|
|
20
|
-
/**
|
|
21
|
-
* Transform response to QueryFnData
|
|
22
|
-
*/
|
|
23
|
-
transform?: (response: TEndpoint['__response']) => TQueryFnData | Promise<TQueryFnData>;
|
|
24
|
-
};
|
|
25
|
-
type EnhanceUpdatOptionVariant<TEndpoint extends AnyEndpoint, TVariant extends AnyObject> = Omit<TVariant, ExcludedQueryKeys> & {
|
|
26
|
-
params?: MaybeFalsy<TEndpoint['__params']>;
|
|
27
|
-
};
|
|
28
|
-
export type EndpointInfiniteQueryUpdateOptionsAllVariants<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = EnhanceUpdatOptionVariant<TEndpoint, Partial<InfiniteQueryOptions<TQueryFnData, TError, TPageParam, TData, any[]>>> | EnhanceUpdatOptionVariant<TEndpoint, InfiniteQueryUpdateOptions<TQueryFnData, TError, TPageParam, TData, any[]>> | EnhanceUpdatOptionVariant<TEndpoint, InfiniteQueryDynamicOptions<TQueryFnData, TError, TPageParam, TData, any[]>>;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=endpoint-infinite-query.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-infinite-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-infinite-query.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { DefaultError, InfiniteData } from '@tanstack/query-core';
|
|
2
|
-
import type { InfiniteQueryConfig, InfiniteQueryDynamicOptions, InfiniteQueryOptions, InfiniteQueryUpdateOptions } from 'mobx-tanstack-query';
|
|
3
|
-
import type { AnyObject, MaybeFalsy } from 'yummies/utils/types';
|
|
4
|
-
import type { AnyEndpoint } from "./endpoint.types.js";
|
|
5
|
-
import type { EndpointQueryUniqKey, ExcludedQueryKeys } from "./endpoint-query.types.js";
|
|
6
|
-
type ShortInfiniteQueryConfig<TQueryFnData, TError = DefaultError, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = Omit<InfiniteQueryConfig<TQueryFnData, TError, TPageParam, TData, any[]>, ExcludedQueryKeys> & {
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type EndpointInfiniteQueryFlattenOptions<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = ShortInfiniteQueryConfig<NoInfer<TQueryFnData>, TError, TPageParam, TData> & {
|
|
10
|
-
uniqKey?: EndpointQueryUniqKey;
|
|
11
|
-
params: (pageParam: NoInfer<TPageParam>) => 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, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = ShortInfiniteQueryConfig<NoInfer<TQueryFnData>, TError, TPageParam, TData> & {
|
|
18
|
-
uniqKey?: EndpointQueryUniqKey;
|
|
19
|
-
params: (pageParam: NoInfer<TPageParam>) => MaybeFalsy<TEndpoint['__params']>;
|
|
20
|
-
/**
|
|
21
|
-
* Transform response to QueryFnData
|
|
22
|
-
*/
|
|
23
|
-
transform?: (response: TEndpoint['__response']) => TQueryFnData | Promise<TQueryFnData>;
|
|
24
|
-
};
|
|
25
|
-
type EnhanceUpdatOptionVariant<TEndpoint extends AnyEndpoint, TVariant extends AnyObject> = Omit<TVariant, ExcludedQueryKeys> & {
|
|
26
|
-
params?: MaybeFalsy<TEndpoint['__params']>;
|
|
27
|
-
};
|
|
28
|
-
export type EndpointInfiniteQueryUpdateOptionsAllVariants<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TPageParam = unknown, TData = InfiniteData<TQueryFnData, TPageParam>> = EnhanceUpdatOptionVariant<TEndpoint, Partial<InfiniteQueryOptions<TQueryFnData, TError, TPageParam, TData, any[]>>> | EnhanceUpdatOptionVariant<TEndpoint, InfiniteQueryUpdateOptions<TQueryFnData, TError, TPageParam, TData, any[]>> | EnhanceUpdatOptionVariant<TEndpoint, InfiniteQueryDynamicOptions<TQueryFnData, TError, TPageParam, TData, any[]>>;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=endpoint-infinite-query.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-infinite-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-infinite-query.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EndpointMutation = void 0;
|
|
4
|
-
const mobx_tanstack_query_1 = require("mobx-tanstack-query");
|
|
5
|
-
/**
|
|
6
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-mutations/)
|
|
7
|
-
*/
|
|
8
|
-
class EndpointMutation extends mobx_tanstack_query_1.Mutation {
|
|
9
|
-
endpoint;
|
|
10
|
-
constructor(endpoint, inputQueryClient, { transform: transformResponse, invalidateEndpoints, queryClient: overridedQueryClient, ...mutationOptions }) {
|
|
11
|
-
const queryClient = overridedQueryClient ?? inputQueryClient;
|
|
12
|
-
super({
|
|
13
|
-
...mutationOptions,
|
|
14
|
-
queryClient,
|
|
15
|
-
onSuccess: (data, variables, onMutateResult, context) => {
|
|
16
|
-
mutationOptions.onSuccess?.(data, variables, onMutateResult, context);
|
|
17
|
-
if (invalidateEndpoints) {
|
|
18
|
-
if (typeof invalidateEndpoints === 'object') {
|
|
19
|
-
queryClient.invalidateEndpoints(invalidateEndpoints);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
let filters;
|
|
23
|
-
switch (`${invalidateEndpoints}`) {
|
|
24
|
-
case 'true': {
|
|
25
|
-
filters = endpoint.group
|
|
26
|
-
? {
|
|
27
|
-
group: endpoint.group,
|
|
28
|
-
}
|
|
29
|
-
: {
|
|
30
|
-
tag: endpoint.tags,
|
|
31
|
-
};
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case 'by-group': {
|
|
35
|
-
filters = {
|
|
36
|
-
group: endpoint.group,
|
|
37
|
-
};
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
case 'by-tag': {
|
|
41
|
-
filters = {
|
|
42
|
-
tag: endpoint.tags,
|
|
43
|
-
};
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (filters) {
|
|
48
|
-
queryClient.invalidateEndpoints(filters);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
mutationFn: async (input, context) => {
|
|
54
|
-
let requestParams = input?.requestParams;
|
|
55
|
-
if (requestParams) {
|
|
56
|
-
if (!requestParams.signal) {
|
|
57
|
-
requestParams.signal = context.signal;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
requestParams = { signal: context.signal };
|
|
62
|
-
}
|
|
63
|
-
const fixedInput = {
|
|
64
|
-
...input,
|
|
65
|
-
requestParams,
|
|
66
|
-
};
|
|
67
|
-
const response = await endpoint.request(fixedInput);
|
|
68
|
-
return (await transformResponse?.(response)) ?? response.data;
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
this.endpoint = endpoint;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.EndpointMutation = EndpointMutation;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Mutation } from 'mobx-tanstack-query';
|
|
2
|
-
import type { AnyObject } from 'yummies/utils/types';
|
|
3
|
-
import type { AnyEndpoint } from "./endpoint.types.cjs";
|
|
4
|
-
import type { EndpointMutationOptions, EndpointMutationParams } from "./endpoint-mutation.types.cjs";
|
|
5
|
-
import type { EndpointQueryClient } from "./endpoint-query-client.cjs";
|
|
6
|
-
/**
|
|
7
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-mutations/)
|
|
8
|
-
*/
|
|
9
|
-
export declare class EndpointMutation<TEndpoint extends AnyEndpoint, TData = unknown, TParams extends AnyObject = AnyObject, TMutationMeta extends AnyObject | void = void, TOnMutateResult = unknown> extends Mutation<TData, EndpointMutationParams<TParams, TMutationMeta>, TEndpoint['__response']['error'], TOnMutateResult> {
|
|
10
|
-
private endpoint;
|
|
11
|
-
constructor(endpoint: AnyEndpoint, inputQueryClient: EndpointQueryClient, { transform: transformResponse, invalidateEndpoints, queryClient: overridedQueryClient, ...mutationOptions }: EndpointMutationOptions<TEndpoint, TData, TParams, TMutationMeta, TOnMutateResult>);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=endpoint-mutation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-mutation.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,6BAA4B;AACvD,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACvB,sCAAqC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAmC;AAItE;;GAEG;AACH,qBAAa,gBAAgB,CAC3B,SAAS,SAAS,WAAW,EAC7B,KAAK,GAAG,OAAO,EACf,OAAO,SAAS,SAAS,GAAG,SAAS,EACrC,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,eAAe,GAAG,OAAO,CACzB,SAAQ,QAAQ,CAChB,KAAK,EACL,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,EAC9C,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,EAChC,eAAe,CAChB;IAEG,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,WAAW,EAC7B,gBAAgB,EAAE,mBAAmB,EACrC,EACE,SAAS,EAAE,iBAAiB,EAC5B,mBAAmB,EACnB,WAAW,EAAE,oBAAoB,EACjC,GAAG,eAAe,EACnB,EAAE,uBAAuB,CACxB,SAAS,EACT,KAAK,EACL,OAAO,EACP,aAAa,EACb,eAAe,CAChB;CAoEJ"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Mutation } from 'mobx-tanstack-query';
|
|
2
|
-
import type { AnyObject } from 'yummies/utils/types';
|
|
3
|
-
import type { AnyEndpoint } from "./endpoint.types.js";
|
|
4
|
-
import type { EndpointMutationOptions, EndpointMutationParams } from "./endpoint-mutation.types.js";
|
|
5
|
-
import type { EndpointQueryClient } from "./endpoint-query-client.js";
|
|
6
|
-
/**
|
|
7
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-mutations/)
|
|
8
|
-
*/
|
|
9
|
-
export declare class EndpointMutation<TEndpoint extends AnyEndpoint, TData = unknown, TParams extends AnyObject = AnyObject, TMutationMeta extends AnyObject | void = void, TOnMutateResult = unknown> extends Mutation<TData, EndpointMutationParams<TParams, TMutationMeta>, TEndpoint['__response']['error'], TOnMutateResult> {
|
|
10
|
-
private endpoint;
|
|
11
|
-
constructor(endpoint: AnyEndpoint, inputQueryClient: EndpointQueryClient, { transform: transformResponse, invalidateEndpoints, queryClient: overridedQueryClient, ...mutationOptions }: EndpointMutationOptions<TEndpoint, TData, TParams, TMutationMeta, TOnMutateResult>);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=endpoint-mutation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-mutation.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,4BAA4B;AACvD,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACvB,qCAAqC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,mCAAmC;AAItE;;GAEG;AACH,qBAAa,gBAAgB,CAC3B,SAAS,SAAS,WAAW,EAC7B,KAAK,GAAG,OAAO,EACf,OAAO,SAAS,SAAS,GAAG,SAAS,EACrC,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,eAAe,GAAG,OAAO,CACzB,SAAQ,QAAQ,CAChB,KAAK,EACL,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,EAC9C,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,EAChC,eAAe,CAChB;IAEG,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,WAAW,EAC7B,gBAAgB,EAAE,mBAAmB,EACrC,EACE,SAAS,EAAE,iBAAiB,EAC5B,mBAAmB,EACnB,WAAW,EAAE,oBAAoB,EACjC,GAAG,eAAe,EACnB,EAAE,uBAAuB,CACxB,SAAS,EACT,KAAK,EACL,OAAO,EACP,aAAa,EACb,eAAe,CAChB;CAoEJ"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Mutation } from 'mobx-tanstack-query';
|
|
2
|
-
/**
|
|
3
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-mutations/)
|
|
4
|
-
*/
|
|
5
|
-
export class EndpointMutation extends Mutation {
|
|
6
|
-
endpoint;
|
|
7
|
-
constructor(endpoint, inputQueryClient, { transform: transformResponse, invalidateEndpoints, queryClient: overridedQueryClient, ...mutationOptions }) {
|
|
8
|
-
const queryClient = overridedQueryClient ?? inputQueryClient;
|
|
9
|
-
super({
|
|
10
|
-
...mutationOptions,
|
|
11
|
-
queryClient,
|
|
12
|
-
onSuccess: (data, variables, onMutateResult, context) => {
|
|
13
|
-
mutationOptions.onSuccess?.(data, variables, onMutateResult, context);
|
|
14
|
-
if (invalidateEndpoints) {
|
|
15
|
-
if (typeof invalidateEndpoints === 'object') {
|
|
16
|
-
queryClient.invalidateEndpoints(invalidateEndpoints);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
let filters;
|
|
20
|
-
switch (`${invalidateEndpoints}`) {
|
|
21
|
-
case 'true': {
|
|
22
|
-
filters = endpoint.group
|
|
23
|
-
? {
|
|
24
|
-
group: endpoint.group,
|
|
25
|
-
}
|
|
26
|
-
: {
|
|
27
|
-
tag: endpoint.tags,
|
|
28
|
-
};
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case 'by-group': {
|
|
32
|
-
filters = {
|
|
33
|
-
group: endpoint.group,
|
|
34
|
-
};
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
case 'by-tag': {
|
|
38
|
-
filters = {
|
|
39
|
-
tag: endpoint.tags,
|
|
40
|
-
};
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (filters) {
|
|
45
|
-
queryClient.invalidateEndpoints(filters);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
mutationFn: async (input, context) => {
|
|
51
|
-
let requestParams = input?.requestParams;
|
|
52
|
-
if (requestParams) {
|
|
53
|
-
if (!requestParams.signal) {
|
|
54
|
-
requestParams.signal = context.signal;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
requestParams = { signal: context.signal };
|
|
59
|
-
}
|
|
60
|
-
const fixedInput = {
|
|
61
|
-
...input,
|
|
62
|
-
requestParams,
|
|
63
|
-
};
|
|
64
|
-
const response = await endpoint.request(fixedInput);
|
|
65
|
-
return (await transformResponse?.(response)) ?? response.data;
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
this.endpoint = endpoint;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { MutationConfig, MutationInvalidateQueriesOptions } from 'mobx-tanstack-query';
|
|
2
|
-
import type { AnyObject, IsPartial, Maybe } from 'yummies/utils/types';
|
|
3
|
-
import type { Endpoint } from "./endpoint.cjs";
|
|
4
|
-
import type { AnyEndpoint } from "./endpoint.types.cjs";
|
|
5
|
-
import type { EndpointMutation } from "./endpoint-mutation.cjs";
|
|
6
|
-
import type { EndpointQueryClient } from "./endpoint-query-client.cjs";
|
|
7
|
-
import type { InvalidateEndpointsFilters } from "./endpoint-query-client.types.cjs";
|
|
8
|
-
export interface EndpointMutationInvalidateQueriesOptions extends MutationInvalidateQueriesOptions {
|
|
9
|
-
}
|
|
10
|
-
export type EndpointMutationParams<TParams extends AnyObject, TMutationMeta extends AnyObject | void = void> = TParams & (TMutationMeta extends void ? {} : IsPartial<TMutationMeta> extends true ? {
|
|
11
|
-
meta?: Maybe<TMutationMeta>;
|
|
12
|
-
} : {
|
|
13
|
-
meta: TMutationMeta;
|
|
14
|
-
});
|
|
15
|
-
export type EndpointMutationOptions<TEndpoint extends AnyEndpoint, TData = unknown, TParams extends AnyObject = AnyObject, TMutationMeta extends AnyObject | void = void, TOnMutateResult = unknown> = {
|
|
16
|
-
/**
|
|
17
|
-
* Invalidates query endpoints using various filters based on data from the OpenAPI schema
|
|
18
|
-
*
|
|
19
|
-
* The value `by-group` will invalidate query endpoints that belong to the exact same group as the mutation
|
|
20
|
-
*
|
|
21
|
-
* The value `by-tag` will invalidate query endpoints that contain at least one tag described in the endpoint with the mutation
|
|
22
|
-
*
|
|
23
|
-
* The value `true` will use dynamic definition of `by-group` | `by-tag` values.
|
|
24
|
-
* If there is a group, it will use `by-group` invalidation, if there is a tag then `by-tag`
|
|
25
|
-
*/
|
|
26
|
-
invalidateEndpoints?: true | 'by-group' | 'by-tag' | InvalidateEndpointsFilters;
|
|
27
|
-
/**
|
|
28
|
-
* Transform response to TData
|
|
29
|
-
*/
|
|
30
|
-
transform?: (response: TEndpoint['__response']) => TData | Promise<TData>;
|
|
31
|
-
invalidateQueries?: EndpointMutationInvalidateQueriesOptions | ((data: NoInfer<TData>, payload: EndpointMutationParams<NoInfer<TParams>, NoInfer<TMutationMeta>>) => EndpointMutationInvalidateQueriesOptions | null | undefined);
|
|
32
|
-
} & Omit<MutationConfig<NoInfer<TData>, EndpointMutationParams<NoInfer<TParams>, NoInfer<TMutationMeta>>, TEndpoint['__response']['error'], TOnMutateResult>, 'queryClient' | 'mutationFn' | 'invalidateQueries'> & {
|
|
33
|
-
queryClient?: EndpointQueryClient;
|
|
34
|
-
};
|
|
35
|
-
export type ToEndpointMutation<T, TMutationMeta extends AnyObject | void = void, TOnMutateResult = unknown> = T extends Endpoint<infer TResponse, infer TParams, any> ? EndpointMutation<T, TResponse['data'], TParams, TMutationMeta, TOnMutateResult> : ToEndpointMutation<AnyEndpoint>;
|
|
36
|
-
//# sourceMappingURL=endpoint-mutation.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-mutation.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAsB;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,6BAA4B;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA+B;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAmC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,0CAAyC;AAEnF,MAAM,WAAW,wCACf,SAAQ,gCAAgC;CAAG;AAE7C,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,SAAS,EACzB,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,IAC3C,OAAO,GACT,CAAC,aAAa,SAAS,IAAI,GACvB,EAAE,GACF,SAAS,CAAC,aAAa,CAAC,SAAS,IAAI,GACnC;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AAEjC,MAAM,MAAM,uBAAuB,CACjC,SAAS,SAAS,WAAW,EAC7B,KAAK,GAAG,OAAO,EACf,OAAO,SAAS,SAAS,GAAG,SAAS,EACrC,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,eAAe,GAAG,OAAO,IACvB;IACF;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAChB,IAAI,GACJ,UAAU,GACV,QAAQ,GACR,0BAA0B,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1E,iBAAiB,CAAC,EACd,wCAAwC,GACxC,CAAC,CACC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EACpB,OAAO,EAAE,sBAAsB,CAC7B,OAAO,CAAC,OAAO,CAAC,EAChB,OAAO,CAAC,aAAa,CAAC,CACvB,KACE,wCAAwC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACvE,GAAG,IAAI,CACN,cAAc,CACZ,OAAO,CAAC,KAAK,CAAC,EACd,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,EAChE,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,EAChC,eAAe,CAChB,EACD,aAAa,GAAG,YAAY,GAAG,mBAAmB,CACnD,GAAG;IACA,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAEJ,MAAM,MAAM,kBAAkB,CAC5B,CAAC,EACD,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,eAAe,GAAG,OAAO,IACvB,CAAC,SAAS,QAAQ,CAAC,MAAM,SAAS,EAAE,MAAM,OAAO,EAAE,GAAG,CAAC,GACvD,gBAAgB,CACd,CAAC,EACD,SAAS,CAAC,MAAM,CAAC,EACjB,OAAO,EACP,aAAa,EACb,eAAe,CAChB,GACD,kBAAkB,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { MutationConfig, MutationInvalidateQueriesOptions } from 'mobx-tanstack-query';
|
|
2
|
-
import type { AnyObject, IsPartial, Maybe } from 'yummies/utils/types';
|
|
3
|
-
import type { Endpoint } from "./endpoint.js";
|
|
4
|
-
import type { AnyEndpoint } from "./endpoint.types.js";
|
|
5
|
-
import type { EndpointMutation } from "./endpoint-mutation.js";
|
|
6
|
-
import type { EndpointQueryClient } from "./endpoint-query-client.js";
|
|
7
|
-
import type { InvalidateEndpointsFilters } from "./endpoint-query-client.types.js";
|
|
8
|
-
export interface EndpointMutationInvalidateQueriesOptions extends MutationInvalidateQueriesOptions {
|
|
9
|
-
}
|
|
10
|
-
export type EndpointMutationParams<TParams extends AnyObject, TMutationMeta extends AnyObject | void = void> = TParams & (TMutationMeta extends void ? {} : IsPartial<TMutationMeta> extends true ? {
|
|
11
|
-
meta?: Maybe<TMutationMeta>;
|
|
12
|
-
} : {
|
|
13
|
-
meta: TMutationMeta;
|
|
14
|
-
});
|
|
15
|
-
export type EndpointMutationOptions<TEndpoint extends AnyEndpoint, TData = unknown, TParams extends AnyObject = AnyObject, TMutationMeta extends AnyObject | void = void, TOnMutateResult = unknown> = {
|
|
16
|
-
/**
|
|
17
|
-
* Invalidates query endpoints using various filters based on data from the OpenAPI schema
|
|
18
|
-
*
|
|
19
|
-
* The value `by-group` will invalidate query endpoints that belong to the exact same group as the mutation
|
|
20
|
-
*
|
|
21
|
-
* The value `by-tag` will invalidate query endpoints that contain at least one tag described in the endpoint with the mutation
|
|
22
|
-
*
|
|
23
|
-
* The value `true` will use dynamic definition of `by-group` | `by-tag` values.
|
|
24
|
-
* If there is a group, it will use `by-group` invalidation, if there is a tag then `by-tag`
|
|
25
|
-
*/
|
|
26
|
-
invalidateEndpoints?: true | 'by-group' | 'by-tag' | InvalidateEndpointsFilters;
|
|
27
|
-
/**
|
|
28
|
-
* Transform response to TData
|
|
29
|
-
*/
|
|
30
|
-
transform?: (response: TEndpoint['__response']) => TData | Promise<TData>;
|
|
31
|
-
invalidateQueries?: EndpointMutationInvalidateQueriesOptions | ((data: NoInfer<TData>, payload: EndpointMutationParams<NoInfer<TParams>, NoInfer<TMutationMeta>>) => EndpointMutationInvalidateQueriesOptions | null | undefined);
|
|
32
|
-
} & Omit<MutationConfig<NoInfer<TData>, EndpointMutationParams<NoInfer<TParams>, NoInfer<TMutationMeta>>, TEndpoint['__response']['error'], TOnMutateResult>, 'queryClient' | 'mutationFn' | 'invalidateQueries'> & {
|
|
33
|
-
queryClient?: EndpointQueryClient;
|
|
34
|
-
};
|
|
35
|
-
export type ToEndpointMutation<T, TMutationMeta extends AnyObject | void = void, TOnMutateResult = unknown> = T extends Endpoint<infer TResponse, infer TParams, any> ? EndpointMutation<T, TResponse['data'], TParams, TMutationMeta, TOnMutateResult> : ToEndpointMutation<AnyEndpoint>;
|
|
36
|
-
//# sourceMappingURL=endpoint-mutation.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-mutation.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,4BAA4B;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA+B;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,mCAAmC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,yCAAyC;AAEnF,MAAM,WAAW,wCACf,SAAQ,gCAAgC;CAAG;AAE7C,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,SAAS,EACzB,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,IAC3C,OAAO,GACT,CAAC,aAAa,SAAS,IAAI,GACvB,EAAE,GACF,SAAS,CAAC,aAAa,CAAC,SAAS,IAAI,GACnC;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AAEjC,MAAM,MAAM,uBAAuB,CACjC,SAAS,SAAS,WAAW,EAC7B,KAAK,GAAG,OAAO,EACf,OAAO,SAAS,SAAS,GAAG,SAAS,EACrC,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,eAAe,GAAG,OAAO,IACvB;IACF;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAChB,IAAI,GACJ,UAAU,GACV,QAAQ,GACR,0BAA0B,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1E,iBAAiB,CAAC,EACd,wCAAwC,GACxC,CAAC,CACC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EACpB,OAAO,EAAE,sBAAsB,CAC7B,OAAO,CAAC,OAAO,CAAC,EAChB,OAAO,CAAC,aAAa,CAAC,CACvB,KACE,wCAAwC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACvE,GAAG,IAAI,CACN,cAAc,CACZ,OAAO,CAAC,KAAK,CAAC,EACd,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,EAChE,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,EAChC,eAAe,CAChB,EACD,aAAa,GAAG,YAAY,GAAG,mBAAmB,CACnD,GAAG;IACA,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAEJ,MAAM,MAAM,kBAAkB,CAC5B,CAAC,EACD,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,eAAe,GAAG,OAAO,IACvB,CAAC,SAAS,QAAQ,CAAC,MAAM,SAAS,EAAE,MAAM,OAAO,EAAE,GAAG,CAAC,GACvD,gBAAgB,CACd,CAAC,EACD,SAAS,CAAC,MAAM,CAAC,EACjB,OAAO,EACP,aAAa,EACb,eAAe,CAChB,GACD,kBAAkB,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EndpointQueryClient = void 0;
|
|
4
|
-
const query_core_1 = require("@tanstack/query-core");
|
|
5
|
-
const mobx_tanstack_query_1 = require("mobx-tanstack-query");
|
|
6
|
-
/**
|
|
7
|
-
* Class that extends `QueryClient` and gives a bit more control over endpoint queries and mutations.
|
|
8
|
-
*
|
|
9
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-query-client/)
|
|
10
|
-
*/
|
|
11
|
-
class EndpointQueryClient extends mobx_tanstack_query_1.QueryClient {
|
|
12
|
-
constructor(config) {
|
|
13
|
-
super({
|
|
14
|
-
...config,
|
|
15
|
-
defaultOptions: {
|
|
16
|
-
...config?.defaultOptions,
|
|
17
|
-
queries: {
|
|
18
|
-
...config?.defaultOptions?.queries,
|
|
19
|
-
queryKeyHashFn: config?.defaultOptions?.queries?.queryKeyHashFn ?? query_core_1.hashKey,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
invalidateEndpoints({ group, namespace, operationId, tag, predicate, endpoint, ...queryFilters }, options) {
|
|
25
|
-
let endpointIdsToFilter;
|
|
26
|
-
if (Array.isArray(endpoint)) {
|
|
27
|
-
endpointIdsToFilter = new Set(endpoint.map((it) => it.endpointId));
|
|
28
|
-
}
|
|
29
|
-
else if (endpoint) {
|
|
30
|
-
endpointIdsToFilter = new Set([endpoint.endpointId]);
|
|
31
|
-
}
|
|
32
|
-
return this.invalidateQueries({
|
|
33
|
-
...queryFilters,
|
|
34
|
-
predicate: (query) => {
|
|
35
|
-
if (!query.meta?.endpointQuery) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const meta = query.meta;
|
|
39
|
-
if (endpointIdsToFilter &&
|
|
40
|
-
!endpointIdsToFilter.has(meta.endpointId)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (namespace &&
|
|
44
|
-
meta.namespace &&
|
|
45
|
-
!applyStringFilter(namespace, meta.namespace)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (group && meta.group && !applyStringFilter(group, meta.group)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (tag && meta.tags && !applyStringFilter(tag, meta.tags)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if (tag && meta.tags && !applyStringFilter(tag, meta.tags)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (operationId &&
|
|
58
|
-
!applyStringFilter(operationId, meta.operationId)) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
if (predicate && !predicate(meta, query)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
},
|
|
66
|
-
}, options);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.EndpointQueryClient = EndpointQueryClient;
|
|
70
|
-
const applyStringFilter = (filter, value) => {
|
|
71
|
-
const values = Array.isArray(value) ? value : [value];
|
|
72
|
-
if (filter instanceof RegExp) {
|
|
73
|
-
return values.some((value) => filter.test(value));
|
|
74
|
-
}
|
|
75
|
-
if (Array.isArray(filter)) {
|
|
76
|
-
return filter.some((filter) => values.includes(filter));
|
|
77
|
-
}
|
|
78
|
-
return values.includes(filter);
|
|
79
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type InvalidateOptions } from '@tanstack/query-core';
|
|
2
|
-
import { QueryClient, type QueryClientConfig } from 'mobx-tanstack-query';
|
|
3
|
-
import type { InvalidateEndpointsFilters } from "./endpoint-query-client.types.cjs";
|
|
4
|
-
/**
|
|
5
|
-
* Class that extends `QueryClient` and gives a bit more control over endpoint queries and mutations.
|
|
6
|
-
*
|
|
7
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-query-client/)
|
|
8
|
-
*/
|
|
9
|
-
export declare class EndpointQueryClient extends QueryClient {
|
|
10
|
-
constructor(config?: QueryClientConfig);
|
|
11
|
-
invalidateEndpoints({ group, namespace, operationId, tag, predicate, endpoint, ...queryFilters }: InvalidateEndpointsFilters, options?: InvalidateOptions): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=endpoint-query-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query-client.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG1E,OAAO,KAAK,EAEV,0BAA0B,EAC3B,0CAAyC;AAE1C;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,MAAM,CAAC,EAAE,iBAAiB;IActC,mBAAmB,CACjB,EACE,KAAK,EACL,SAAS,EACT,WAAW,EACX,GAAG,EACH,SAAS,EACT,QAAQ,EACR,GAAG,YAAY,EAChB,EAAE,0BAA0B,EAC7B,OAAO,CAAC,EAAE,iBAAiB;CAgE9B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type InvalidateOptions } from '@tanstack/query-core';
|
|
2
|
-
import { QueryClient, type QueryClientConfig } from 'mobx-tanstack-query';
|
|
3
|
-
import type { InvalidateEndpointsFilters } from "./endpoint-query-client.types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Class that extends `QueryClient` and gives a bit more control over endpoint queries and mutations.
|
|
6
|
-
*
|
|
7
|
-
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-query-client/)
|
|
8
|
-
*/
|
|
9
|
-
export declare class EndpointQueryClient extends QueryClient {
|
|
10
|
-
constructor(config?: QueryClientConfig);
|
|
11
|
-
invalidateEndpoints({ group, namespace, operationId, tag, predicate, endpoint, ...queryFilters }: InvalidateEndpointsFilters, options?: InvalidateOptions): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=endpoint-query-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query-client.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG1E,OAAO,KAAK,EAEV,0BAA0B,EAC3B,yCAAyC;AAE1C;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,MAAM,CAAC,EAAE,iBAAiB;IActC,mBAAmB,CACjB,EACE,KAAK,EACL,SAAS,EACT,WAAW,EACX,GAAG,EACH,SAAS,EACT,QAAQ,EACR,GAAG,YAAY,EAChB,EAAE,0BAA0B,EAC7B,OAAO,CAAC,EAAE,iBAAiB;CAgE9B"}
|