mobx-tanstack-query-api 0.0.45 → 0.0.47
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/codegen/index.d.ts +1 -0
- package/codegen/index.d.ts.map +1 -1
- package/codegen/index.js +3 -0
- package/package.json +2 -2
- package/runtime/endpoint-query.d.ts +2 -2
- package/runtime/endpoint-query.d.ts.map +1 -1
- package/runtime/endpoint-query.js +22 -12
- package/runtime/endpoint-query.types.d.ts +9 -5
- package/runtime/endpoint-query.types.d.ts.map +1 -1
- package/runtime/endpoint.d.ts +3 -3
- package/runtime/endpoint.d.ts.map +1 -1
- package/runtime/endpoint.js +7 -1
package/codegen/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export interface GenerateQueryApiParams {
|
|
|
62
62
|
requestOptions?: AnyObject;
|
|
63
63
|
otherCodegenParams?: AnyObject;
|
|
64
64
|
filterRoutes?: (route: AnyObject) => boolean;
|
|
65
|
+
filterGroups?: (groupName: string) => boolean;
|
|
65
66
|
libImports?: {
|
|
66
67
|
'mobx-tanstack-query-api'?: string;
|
|
67
68
|
};
|
package/codegen/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAc9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,EAAE,YAAY,CAAC;IAChB,qBAAqB,EAAE,CAAC,aAAa,EAAE,SAAS,KAAK,MAAM,CAAC;IAC5D,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM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AAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KACxD,OAAO,CAAC,IAAI,CA0Xd,CAAC"}
|
package/codegen/index.js
CHANGED
|
@@ -189,6 +189,9 @@ export const generateApi = async (params) => {
|
|
|
189
189
|
});
|
|
190
190
|
// #endregion
|
|
191
191
|
for await (const [groupName, routes] of groupsMap) {
|
|
192
|
+
if (params.filterGroups && !params.filterGroups(groupName)) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
192
195
|
const fileNamesWithRequestInfo = [];
|
|
193
196
|
codegenFs.createDir(path.resolve(params.output, _.kebabCase(groupName)));
|
|
194
197
|
codegenFs.createDir(path.resolve(params.output, _.kebabCase(groupName), 'endpoints'));
|
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.47",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,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": "^
|
|
26
|
+
"mobx-tanstack-query": "^5.0.0",
|
|
27
27
|
"swagger-typescript-api": "13.1.3",
|
|
28
28
|
"yummies": "^3.0.37"
|
|
29
29
|
},
|
|
@@ -5,10 +5,10 @@ import { EndpointQueryClient } from './endpoint-query-client.js';
|
|
|
5
5
|
import { EndpointQueryOptions } from './endpoint-query.types.js';
|
|
6
6
|
import { AnyEndpoint } from './endpoint.types.js';
|
|
7
7
|
import { AnyHttpResponse } from './http-client.js';
|
|
8
|
-
export declare class EndpointQuery<
|
|
8
|
+
export declare class EndpointQuery<TResponse extends AnyHttpResponse, TInput extends AnyObject, TOutput = TResponse> extends MobxQuery<TResponse, TResponse['error'], TOutput, TResponse, any[]> {
|
|
9
9
|
private endpoint;
|
|
10
10
|
response: TResponse | null;
|
|
11
|
-
constructor(endpoint: AnyEndpoint, queryClient: EndpointQueryClient, { input: getInput,
|
|
11
|
+
constructor(endpoint: AnyEndpoint, queryClient: EndpointQueryClient, { input: getInput, options: getDynamicOptions, uniqKey, ...queryOptions }: EndpointQueryOptions<TResponse, TInput, TOutput>);
|
|
12
12
|
setInput(input: MaybeFalsy<TInput>): Promise<TResponse>;
|
|
13
13
|
protected getInputFromContext(ctx: QueryFunctionContext<any, any>): TInput;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAS,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAEL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"endpoint-query.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAS,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAEL,oBAAoB,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AAuBlE,qBAAa,aAAa,CACxB,SAAS,SAAS,eAAe,EACjC,MAAM,SAAS,SAAS,EACxB,OAAO,GAAG,SAAS,CACnB,SAAQ,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;IAIzE,OAAO,CAAC,QAAQ;IAHlB,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAQ;gBAGxB,QAAQ,EAAE,WAAW,EAC7B,WAAW,EAAE,mBAAmB,EAChC,EACE,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EACP,GAAG,YAAY,EAChB,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;IA8E/C,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAO7D,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,GACzB,MAAM;CAE/C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { makeObservable, observable, runInAction, when } from 'mobx';
|
|
2
2
|
import { MobxQuery } from 'mobx-tanstack-query';
|
|
3
|
-
const buildOptionsFromInput = (endpoint, input) => {
|
|
3
|
+
const buildOptionsFromInput = (endpoint, input, uniqKey) => {
|
|
4
4
|
const { requiredParams } = endpoint.configuration;
|
|
5
5
|
let hasRequiredParams = false;
|
|
6
6
|
if (requiredParams.length > 0) {
|
|
@@ -12,13 +12,13 @@ const buildOptionsFromInput = (endpoint, input) => {
|
|
|
12
12
|
}
|
|
13
13
|
return {
|
|
14
14
|
enabled: hasRequiredParams,
|
|
15
|
-
queryKey: endpoint.getQueryKey(input || {}),
|
|
15
|
+
queryKey: endpoint.getQueryKey(input || {}, uniqKey),
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
export class EndpointQuery extends MobxQuery {
|
|
19
19
|
endpoint;
|
|
20
20
|
response = null;
|
|
21
|
-
constructor(endpoint, queryClient, { input: getInput,
|
|
21
|
+
constructor(endpoint, queryClient, { input: getInput, options: getDynamicOptions, uniqKey, ...queryOptions }) {
|
|
22
22
|
super({
|
|
23
23
|
...queryOptions,
|
|
24
24
|
queryClient,
|
|
@@ -30,14 +30,27 @@ export class EndpointQuery extends MobxQuery {
|
|
|
30
30
|
pathDeclaration: endpoint.path.join('/'),
|
|
31
31
|
endpointQuery: true,
|
|
32
32
|
},
|
|
33
|
-
options: (
|
|
34
|
-
const willEnableManually = options?.enabled === false;
|
|
33
|
+
options: (query) => {
|
|
34
|
+
const willEnableManually = query.options?.enabled === false;
|
|
35
35
|
const input = (getInput?.() || {});
|
|
36
|
-
const builtOptions = buildOptionsFromInput(endpoint, input);
|
|
36
|
+
const builtOptions = buildOptionsFromInput(endpoint, input, uniqKey);
|
|
37
|
+
const dynamicOuterOptions = getDynamicOptions?.(query);
|
|
38
|
+
let isEnabled = false;
|
|
39
|
+
if (willEnableManually) {
|
|
40
|
+
if (dynamicOuterOptions?.enabled != null) {
|
|
41
|
+
isEnabled = dynamicOuterOptions.enabled;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const outerDynamicEnabled = dynamicOuterOptions?.enabled != null &&
|
|
46
|
+
!!dynamicOuterOptions.enabled;
|
|
47
|
+
isEnabled = builtOptions.enabled && outerDynamicEnabled;
|
|
48
|
+
}
|
|
37
49
|
return {
|
|
38
|
-
...options,
|
|
50
|
+
...query.options,
|
|
39
51
|
...builtOptions,
|
|
40
|
-
|
|
52
|
+
...dynamicOuterOptions,
|
|
53
|
+
enabled: isEnabled,
|
|
41
54
|
};
|
|
42
55
|
},
|
|
43
56
|
queryFn: async (ctx) => {
|
|
@@ -62,10 +75,7 @@ export class EndpointQuery extends MobxQuery {
|
|
|
62
75
|
runInAction(() => {
|
|
63
76
|
this.response = response;
|
|
64
77
|
});
|
|
65
|
-
|
|
66
|
-
if (transformResponse) {
|
|
67
|
-
output = await transformResponse(response);
|
|
68
|
-
}
|
|
78
|
+
const output = response.data;
|
|
69
79
|
return output;
|
|
70
80
|
},
|
|
71
81
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { MobxQueryConfig } from 'mobx-tanstack-query';
|
|
2
|
-
import {
|
|
1
|
+
import { MobxQuery, MobxQueryConfig, MobxQueryDynamicOptions } from 'mobx-tanstack-query';
|
|
2
|
+
import { FnValue } from 'yummies/common';
|
|
3
|
+
import { AnyObject, Maybe, MaybeFalsy } from 'yummies/utils/types';
|
|
3
4
|
import { AnyHttpResponse } from './http-client.js';
|
|
4
5
|
export interface EndpointQueryMeta {
|
|
5
6
|
endpointQuery: true;
|
|
@@ -8,8 +9,11 @@ export interface EndpointQueryMeta {
|
|
|
8
9
|
path: string[];
|
|
9
10
|
pathDeclaration: string;
|
|
10
11
|
}
|
|
11
|
-
export type
|
|
12
|
+
export type EndpointQueryUnitKey = Maybe<FnValue<string | number | AnyObject | boolean>>;
|
|
13
|
+
export type EndpointQueryOptions<TResponse extends AnyHttpResponse, TInput extends AnyObject, TOutput = TResponse> = {
|
|
12
14
|
input?: () => MaybeFalsy<TInput>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
} & Omit<MobxQueryConfig<TResponse, TResponse['error'], TOutput, TResponse, any[]>, 'options' | 'queryFn' | 'queryClient' | 'queryKey'> & {
|
|
16
|
+
uniqKey?: EndpointQueryUnitKey;
|
|
17
|
+
options?: (query: NoInfer<MobxQuery<NoInfer<TResponse>, NoInfer<TResponse['error']>, NoInfer<TOutput>, NoInfer<TResponse>, NoInfer<any[]>>>) => Omit<MobxQueryDynamicOptions<TResponse, TResponse['error'], TOutput, TResponse, any[]>, 'queryKey' | 'queryFn' | 'queryHash' | '_defaulted' | 'experimental_prefetchInRender' | '_optimisticResults'>;
|
|
18
|
+
};
|
|
15
19
|
//# sourceMappingURL=endpoint-query.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"endpoint-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,oBAAoB,GAAG,KAAK,CACtC,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,CAC/C,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAC9B,SAAS,SAAS,eAAe,EACjC,MAAM,SAAS,SAAS,EACxB,OAAO,GAAG,SAAS,IACjB;IACF,KAAK,CAAC,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;CAClC,GAAG,IAAI,CACN,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EACzE,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CACnD,GAAG;IACA,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,OAAO,CAAC,EAAE,CACR,KAAK,EAAE,OAAO,CACZ,SAAS,CACP,OAAO,CAAC,SAAS,CAAC,EAClB,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAC3B,OAAO,CAAC,OAAO,CAAC,EAChB,OAAO,CAAC,SAAS,CAAC,EAClB,OAAO,CAAC,GAAG,EAAE,CAAC,CACf,CACF,KACE,IAAI,CACP,uBAAuB,CACrB,SAAS,EACT,SAAS,CAAC,OAAO,CAAC,EAClB,OAAO,EACP,SAAS,EACT,GAAG,EAAE,CACN,EACC,UAAU,GACV,SAAS,GACT,WAAW,GACX,YAAY,GACZ,+BAA+B,GAC/B,oBAAoB,CACvB,CAAC;CACH,CAAC"}
|
package/runtime/endpoint.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AllPropertiesOptional, AnyObject } from 'yummies/utils/types';
|
|
|
3
3
|
import { EndpointMutation, EndpointMutationOptions } from './endpoint-mutation.js';
|
|
4
4
|
import { EndpointQueryClient } from './endpoint-query-client.js';
|
|
5
5
|
import { EndpointQuery } from './endpoint-query.js';
|
|
6
|
-
import { EndpointQueryOptions } from './endpoint-query.types.js';
|
|
6
|
+
import { EndpointQueryOptions, EndpointQueryUnitKey } from './endpoint-query.types.js';
|
|
7
7
|
import { EndpointConfiguration } from './endpoint.types.js';
|
|
8
8
|
import type { HttpClient, HttpResponse } from './http-client.js';
|
|
9
9
|
export interface Endpoint<TResponse extends HttpResponse<any, any>, TInput extends AnyObject, TMetaData extends AnyObject = AnyObject> {
|
|
@@ -21,7 +21,7 @@ export declare class Endpoint<TResponse extends HttpResponse<any, any>, TInput e
|
|
|
21
21
|
get path(): string[];
|
|
22
22
|
get operationId(): string;
|
|
23
23
|
request(...args: AllPropertiesOptional<TInput> extends true ? [input?: TInput] : [input: TInput]): Promise<TResponse>;
|
|
24
|
-
getQueryKey(...args: AllPropertiesOptional<TInput> extends true ? [input?: TInput] : [input: TInput]): any[];
|
|
24
|
+
getQueryKey(...args: AllPropertiesOptional<TInput> extends true ? [input?: TInput, uniqKey?: EndpointQueryUnitKey] : [input: TInput, uniqKey?: EndpointQueryUnitKey]): any[];
|
|
25
25
|
/**
|
|
26
26
|
* segment - last segment number in path which need to crop for invalidate
|
|
27
27
|
* @example
|
|
@@ -37,6 +37,6 @@ export declare class Endpoint<TResponse extends HttpResponse<any, any>, TInput e
|
|
|
37
37
|
queryKeyIndex?: number;
|
|
38
38
|
}, options?: InvalidateOptions): Promise<void>;
|
|
39
39
|
toMutation<TOutput = TResponse, TMutationMeta extends AnyObject | void = void>(options: EndpointMutationOptions<TOutput, TInput, TResponse, TMutationMeta>): EndpointMutation<TOutput, TInput, TResponse, TMutationMeta>;
|
|
40
|
-
toQuery<TOutput = TResponse>(options: EndpointQueryOptions<
|
|
40
|
+
toQuery<TOutput = TResponse['data']>(options: EndpointQueryOptions<TResponse, TInput, TOutput>): EndpointQuery<TResponse, TInput, TOutput>;
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=endpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,K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I,GAAG,IAAI,EAE7C,OAAO,EAAE,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC;IAK7E,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,EACjC,OAAO,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC;CAQ5D"}
|
package/runtime/endpoint.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveFnValue } from 'yummies/common';
|
|
1
2
|
import { EndpointMutation, } from './endpoint-mutation.js';
|
|
2
3
|
import { EndpointQuery } from './endpoint-query.js';
|
|
3
4
|
export class Endpoint {
|
|
@@ -53,7 +54,12 @@ export class Endpoint {
|
|
|
53
54
|
}
|
|
54
55
|
getQueryKey(...args) {
|
|
55
56
|
const input = args[0] ?? {};
|
|
56
|
-
return [
|
|
57
|
+
return [
|
|
58
|
+
...this.configuration.path,
|
|
59
|
+
this.configuration.operationId,
|
|
60
|
+
input,
|
|
61
|
+
resolveFnValue(args[1]),
|
|
62
|
+
];
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
65
|
* segment - last segment number in path which need to crop for invalidate
|