mobx-tanstack-query-api 0.0.64 → 0.0.66
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.js +3 -3
- package/codegen/templates/all-exports.tmpl.d.ts +2 -1
- package/codegen/templates/all-exports.tmpl.d.ts.map +1 -1
- package/codegen/templates/all-exports.tmpl.js +3 -2
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +1 -1
- package/codegen/templates/endpoint-per-file.tmpl.js +2 -0
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +10 -0
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +1 -0
- package/codegen/templates/{index-ts-for-request-per-file.tmpl.js → index-ts-for-endpoint-per-file.tmpl.js} +1 -1
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +1 -1
- package/codegen/templates/new-endpoint.tmpl.js +3 -2
- package/package.json +5 -5
- package/runtime/endpoint-query-client.d.ts +1 -1
- package/runtime/endpoint-query-client.d.ts.map +1 -1
- package/runtime/endpoint-query-client.js +9 -1
- package/codegen/templates/index-ts-for-request-per-file.tmpl.d.ts +0 -10
- package/codegen/templates/index-ts-for-request-per-file.tmpl.d.ts.map +0 -1
package/codegen/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { allExportsTmpl } from './templates/all-exports.tmpl.js';
|
|
|
5
5
|
import { LINTERS_IGNORE } from './templates/constants.js';
|
|
6
6
|
import { dataContractsFileTmpl } from './templates/data-contracts-file.tmpl.js';
|
|
7
7
|
import { endpointPerFileTmpl } from './templates/endpoint-per-file.tmpl.js';
|
|
8
|
-
import {
|
|
8
|
+
import { indexTsForEndpointPerFileTmpl } from './templates/index-ts-for-endpoint-per-file.tmpl.js';
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
export const generateApi = async (params) => {
|
|
@@ -171,7 +171,7 @@ export const generateApi = async (params) => {
|
|
|
171
171
|
path: path.resolve(params.output, 'endpoints'),
|
|
172
172
|
fileName: 'index.ts',
|
|
173
173
|
withPrefix: false,
|
|
174
|
-
content: await
|
|
174
|
+
content: await indexTsForEndpointPerFileTmpl({
|
|
175
175
|
...generated,
|
|
176
176
|
apiParams: params,
|
|
177
177
|
codegenProcess,
|
|
@@ -252,7 +252,7 @@ export * as ${exportGroupName} from './endpoints';
|
|
|
252
252
|
path: path.resolve(params.output, _.kebabCase(groupName), 'endpoints'),
|
|
253
253
|
fileName: 'index.ts',
|
|
254
254
|
withPrefix: false,
|
|
255
|
-
content: await
|
|
255
|
+
content: await indexTsForEndpointPerFileTmpl({
|
|
256
256
|
...generated,
|
|
257
257
|
apiParams: params,
|
|
258
258
|
codegenProcess,
|
|
@@ -7,5 +7,6 @@ export interface AllExportsTmplParams {
|
|
|
7
7
|
namespace?: Maybe<string>;
|
|
8
8
|
utils: CodegenDataUtils;
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const formatGroupNameEnumKey: (groupName: string, { _ }: CodegenDataUtils) => Capitalize<string>;
|
|
11
|
+
export declare const allExportsTmpl: ({ collectedExportFiles, groupNames, namespace, utils, formatTSContent, }: AllExportsTmplParams) => Promise<string>;
|
|
11
12
|
//# sourceMappingURL=all-exports.tmpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-exports.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-exports.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,eAAO,MAAM,cAAc,GAAU,
|
|
1
|
+
{"version":3,"file":"all-exports.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-exports.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,OAAO,gBAAgB,uBACgB,CAAC;AAE1C,eAAO,MAAM,cAAc,GAAU,0EAMlC,oBAAoB,oBAgBtB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LINTERS_IGNORE } from './constants.js';
|
|
2
|
-
export const
|
|
2
|
+
export const formatGroupNameEnumKey = (groupName, { _ }) => _.upperFirst(_.camelCase(groupName));
|
|
3
|
+
export const allExportsTmpl = async ({ collectedExportFiles, groupNames, namespace, utils, formatTSContent, }) => {
|
|
3
4
|
return await formatTSContent(`${LINTERS_IGNORE}
|
|
4
5
|
export * from './data-contracts';
|
|
5
6
|
${collectedExportFiles.map((fileName) => `export * from './${fileName}';`).join('\n')}
|
|
@@ -8,7 +9,7 @@ export const allExportsTmpl = async ({ collectedExportFiles, groupNames, namespa
|
|
|
8
9
|
${groupNames?.length
|
|
9
10
|
? `
|
|
10
11
|
export const enum Group {
|
|
11
|
-
${groupNames.map((groupName) => `${
|
|
12
|
+
${groupNames.map((groupName) => `${formatGroupNameEnumKey(groupName, utils)} = "${groupName}"`).join(',\n')}
|
|
12
13
|
}
|
|
13
14
|
`
|
|
14
15
|
: ''}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,yBAA0B,SAAQ,SAAS;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,KAAK,EAAE,gBAAgB,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,eAAO,MAAM,mBAAmB,GAAU,iIAUvC,yBAAyB;;;
|
|
1
|
+
{"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,yBAA0B,SAAQ,SAAS;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,KAAK,EAAE,gBAAgB,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B;AAED,eAAO,MAAM,mBAAmB,GAAU,iIAUvC,yBAAyB;;;EAyG3B,CAAC"}
|
|
@@ -31,6 +31,8 @@ export const endpointPerFileTmpl = async ({ route, configuration, apiParams, for
|
|
|
31
31
|
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
32
32
|
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
33
33
|
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
34
|
+
import { ${[groupName && 'Group', namespace && 'namespace'].filter(Boolean).join(',')} } from "../../__exports";
|
|
35
|
+
|
|
34
36
|
${configuration.modelTypes.length > 0
|
|
35
37
|
? `
|
|
36
38
|
import { ${configuration.modelTypes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnyObject } from 'yummies/utils/types';
|
|
2
|
+
import { CodegenProcess, GenerateQueryApiParams } from '../index.js';
|
|
3
|
+
export interface IndexTsForEndpointPerFileTmplParams extends AnyObject {
|
|
4
|
+
configuration: AnyObject;
|
|
5
|
+
apiParams: GenerateQueryApiParams;
|
|
6
|
+
codegenProcess: CodegenProcess;
|
|
7
|
+
generatedRequestFileNames: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const indexTsForEndpointPerFileTmpl: ({ generatedRequestFileNames, }: IndexTsForEndpointPerFileTmplParams) => Promise<string>;
|
|
10
|
+
//# sourceMappingURL=index-ts-for-endpoint-per-file.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-ts-for-endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/index-ts-for-endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIrE,MAAM,WAAW,mCAAoC,SAAQ,SAAS;IACpE,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,6BAA6B,GAAU,gCAEjD,mCAAmC,oBAIrC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LINTERS_IGNORE } from './constants.js';
|
|
2
|
-
export const
|
|
2
|
+
export const indexTsForEndpointPerFileTmpl = async ({ generatedRequestFileNames, }) => {
|
|
3
3
|
return `${LINTERS_IGNORE}
|
|
4
4
|
${generatedRequestFileNames.map((fileName) => `export * from './${fileName.replace('.ts', '')}';`).join('\n')}
|
|
5
5
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,sEAO7B,qBAAqB;;;;;;;;CAwMvB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatGroupNameEnumKey } from './all-exports.tmpl.js';
|
|
1
2
|
// RequestParams["type"]
|
|
2
3
|
const requestContentKind = {
|
|
3
4
|
URL_ENCODED: '"application/x-www-form-urlencoded"',
|
|
@@ -152,8 +153,8 @@ new ${importFileParams.endpoint.exportName}<
|
|
|
152
153
|
.filter(Boolean)
|
|
153
154
|
.map((it) => `"${it}"`)}],
|
|
154
155
|
tags: [${tags.map((tag) => `"${tag}"`)}],
|
|
155
|
-
${groupName ? `group:
|
|
156
|
-
${namespace ? `namespace
|
|
156
|
+
${groupName ? `group: Group.${formatGroupNameEnumKey(groupName, utils)},` : ''}
|
|
157
|
+
${namespace ? `namespace,` : ''}
|
|
157
158
|
meta: ${requestInfoMeta?.tmplData ?? '{} as any'},
|
|
158
159
|
},
|
|
159
160
|
${importFileParams.queryClient.exportName},
|
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.66",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
"default": "./codegen/templates/endpoint-per-file.tmpl.js",
|
|
98
98
|
"types": "./codegen/templates/endpoint-per-file.tmpl.d.ts"
|
|
99
99
|
},
|
|
100
|
-
"./codegen/templates/index-ts-for-
|
|
101
|
-
"import": "./codegen/templates/index-ts-for-
|
|
102
|
-
"default": "./codegen/templates/index-ts-for-
|
|
103
|
-
"types": "./codegen/templates/index-ts-for-
|
|
100
|
+
"./codegen/templates/index-ts-for-endpoint-per-file.tmpl": {
|
|
101
|
+
"import": "./codegen/templates/index-ts-for-endpoint-per-file.tmpl.js",
|
|
102
|
+
"default": "./codegen/templates/index-ts-for-endpoint-per-file.tmpl.js",
|
|
103
|
+
"types": "./codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts"
|
|
104
104
|
},
|
|
105
105
|
"./codegen/templates/new-endpoint.tmpl": {
|
|
106
106
|
"import": "./codegen/templates/new-endpoint.tmpl.js",
|
|
@@ -2,6 +2,6 @@ import { InvalidateOptions } from '@tanstack/query-core';
|
|
|
2
2
|
import { QueryClient } from 'mobx-tanstack-query';
|
|
3
3
|
import { InvalidateEndpointsFilters } from './endpoint-query-client.types.js';
|
|
4
4
|
export declare class EndpointQueryClient extends QueryClient {
|
|
5
|
-
invalidateEndpoints({ group, namespace, operationId, tag, predicate, ...queryFilters }: InvalidateEndpointsFilters, options?: InvalidateOptions): Promise<void>;
|
|
5
|
+
invalidateEndpoints({ group, namespace, operationId, tag, predicate, endpoint, ...queryFilters }: InvalidateEndpointsFilters, options?: InvalidateOptions): Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=endpoint-query-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query-client.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAEL,0BAA0B,EAC3B,MAAM,kCAAkC,CAAC;AAG1C,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,mBAAmB,CACjB,EACE,KAAK,EACL,SAAS,EACT,WAAW,EACX,GAAG,EACH,SAAS,EACT,GAAG,YAAY,EAChB,EAAE,0BAA0B,EAC7B,OAAO,CAAC,EAAE,iBAAiB;
|
|
1
|
+
{"version":3,"file":"endpoint-query-client.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAEL,0BAA0B,EAC3B,MAAM,kCAAkC,CAAC;AAG1C,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,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,6 +1,6 @@
|
|
|
1
1
|
import { QueryClient } from 'mobx-tanstack-query';
|
|
2
2
|
export class EndpointQueryClient extends QueryClient {
|
|
3
|
-
invalidateEndpoints({ group, namespace, operationId, tag, predicate, ...queryFilters }, options) {
|
|
3
|
+
invalidateEndpoints({ group, namespace, operationId, tag, predicate, endpoint, ...queryFilters }, options) {
|
|
4
4
|
return this.invalidateQueries({
|
|
5
5
|
...queryFilters,
|
|
6
6
|
// eslint-disable-next-line sonarjs/no-invariant-returns
|
|
@@ -9,6 +9,14 @@ export class EndpointQueryClient extends QueryClient {
|
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
const meta = query.meta;
|
|
12
|
+
if (endpoint) {
|
|
13
|
+
const endpointsToFilter = Array.isArray(endpoint)
|
|
14
|
+
? endpoint
|
|
15
|
+
: [endpoint];
|
|
16
|
+
if (endpointsToFilter.every((endpoint) => meta.endpointId !== endpoint.endpointId)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
12
20
|
if (namespace &&
|
|
13
21
|
meta.namespace &&
|
|
14
22
|
!applyStringFilter(namespace, meta.namespace)) {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AnyObject } from 'yummies/utils/types';
|
|
2
|
-
import { CodegenProcess, GenerateQueryApiParams } from '../index.js';
|
|
3
|
-
export interface IndexTsForRequestPerFileTmplParams extends AnyObject {
|
|
4
|
-
configuration: AnyObject;
|
|
5
|
-
apiParams: GenerateQueryApiParams;
|
|
6
|
-
codegenProcess: CodegenProcess;
|
|
7
|
-
generatedRequestFileNames: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare const indexTsForRequestPerFileTmpl: ({ generatedRequestFileNames, }: IndexTsForRequestPerFileTmplParams) => Promise<string>;
|
|
10
|
-
//# sourceMappingURL=index-ts-for-request-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-ts-for-request-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/index-ts-for-request-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIrE,MAAM,WAAW,kCAAmC,SAAQ,SAAS;IACnE,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,4BAA4B,GAAU,gCAEhD,kCAAkC,oBAIpC,CAAC"}
|