mobx-tanstack-query-api 0.0.61 → 0.0.62
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.map +1 -1
- package/codegen/index.js +35 -16
- package/codegen/templates/all-exports.tmpl.d.ts +11 -0
- package/codegen/templates/all-exports.tmpl.d.ts.map +1 -0
- package/codegen/templates/all-exports.tmpl.js +16 -0
- package/codegen/templates/{request-info-jsdoc.tmpl.d.ts → endpoint-jsdoc.tmpl.d.ts} +3 -3
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +1 -0
- package/codegen/templates/{request-info-jsdoc.tmpl.js → endpoint-jsdoc.tmpl.js} +1 -1
- package/codegen/templates/endpoint-per-file.tmpl.d.ts +18 -0
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +1 -0
- package/codegen/templates/{request-info-per-file.tmpl.js → endpoint-per-file.tmpl.js} +7 -5
- package/codegen/templates/{new-request-info.tmpl.d.ts → new-endpoint.tmpl.d.ts} +6 -4
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +1 -0
- package/codegen/templates/{new-request-info.tmpl.js → new-endpoint.tmpl.js} +3 -1
- package/package.json +20 -15
- package/runtime/endpoint-mutation.d.ts +1 -1
- package/runtime/endpoint-mutation.d.ts.map +1 -1
- package/runtime/endpoint-mutation.js +5 -23
- package/runtime/endpoint-mutation.types.d.ts +2 -1
- package/runtime/endpoint-mutation.types.d.ts.map +1 -1
- package/runtime/endpoint-query-client.d.ts +3 -9
- package/runtime/endpoint-query-client.d.ts.map +1 -1
- package/runtime/endpoint-query-client.js +36 -48
- package/runtime/endpoint-query-client.types.d.ts +16 -0
- package/runtime/endpoint-query-client.types.d.ts.map +1 -0
- package/runtime/endpoint-query-client.types.js +1 -0
- package/runtime/endpoint-query.types.d.ts +2 -0
- package/runtime/endpoint-query.types.d.ts.map +1 -1
- package/runtime/endpoint.d.ts +7 -16
- package/runtime/endpoint.d.ts.map +1 -1
- package/runtime/endpoint.js +14 -23
- package/runtime/endpoint.types.d.ts +6 -0
- package/runtime/endpoint.types.d.ts.map +1 -1
- package/runtime/index.d.ts +1 -0
- package/runtime/index.d.ts.map +1 -1
- package/runtime/index.js +1 -0
- package/codegen/templates/new-request-info.tmpl.d.ts.map +0 -1
- package/codegen/templates/request-info-jsdoc.tmpl.d.ts.map +0 -1
- package/codegen/templates/request-info-per-file.tmpl.d.ts +0 -16
- package/codegen/templates/request-info-per-file.tmpl.d.ts.map +0 -1
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,
|
|
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,EAAS,MAAM,qBAAqB,CAAC;AAerE,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,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC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AED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC,EAC5E,gBAAgB,CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KACxD,OAAO,CAAC,IAAI,CAoZd,CAAC"}
|
package/codegen/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { generateApi as generateApiFromSwagger } from 'swagger-typescript-api';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { allExportsTmpl } from './templates/all-exports.tmpl.js';
|
|
4
5
|
import { LINTERS_IGNORE } from './templates/constants.js';
|
|
5
6
|
import { dataContractsFileTmpl } from './templates/data-contracts-file.tmpl.js';
|
|
7
|
+
import { endpointPerFileTmpl } from './templates/endpoint-per-file.tmpl.js';
|
|
6
8
|
import { indexTsForRequestPerFileTmpl } from './templates/index-ts-for-request-per-file.tmpl.js';
|
|
7
|
-
import { requestInfoPerFileTmpl } from './templates/request-info-per-file.tmpl.js';
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = path.dirname(__filename);
|
|
10
11
|
export const generateApi = async (params) => {
|
|
@@ -39,6 +40,7 @@ export const generateApi = async (params) => {
|
|
|
39
40
|
createRequestInfoInstance: path.resolve(__dirname, 'templates/create-request-info-instance.ejs'),
|
|
40
41
|
outputDir: path.resolve(process.cwd(), params.output),
|
|
41
42
|
};
|
|
43
|
+
//#region swagger-typescript-api
|
|
42
44
|
const codegenParams = {
|
|
43
45
|
httpClientType: 'fetch',
|
|
44
46
|
cleanOutput: true,
|
|
@@ -111,9 +113,19 @@ export const generateApi = async (params) => {
|
|
|
111
113
|
},
|
|
112
114
|
},
|
|
113
115
|
});
|
|
116
|
+
//#endregion
|
|
114
117
|
const utils = codegenProcess.getRenderTemplateData()
|
|
115
118
|
.utils;
|
|
116
119
|
const { _ } = utils;
|
|
120
|
+
let namespace = null;
|
|
121
|
+
if (params.namespace) {
|
|
122
|
+
if (typeof params.namespace === 'function') {
|
|
123
|
+
namespace = params.namespace(utils);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
namespace = utils._.camelCase(params.namespace);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
117
129
|
const codegenFs = codegenProcess.fileSystem;
|
|
118
130
|
codegenFs.cleanDir(params.output);
|
|
119
131
|
codegenFs.createDir(params.output);
|
|
@@ -125,13 +137,14 @@ export const generateApi = async (params) => {
|
|
|
125
137
|
: allRoutes;
|
|
126
138
|
const reservedDataContractNamesMap = new Map();
|
|
127
139
|
const collectedExportFiles = [];
|
|
140
|
+
const groupsMap = new Map();
|
|
128
141
|
if (params.groupBy == null) {
|
|
129
142
|
collectedExportFiles.push('endpoints');
|
|
130
143
|
// #region кодогенерация 1 эндпоинт - 1 файл без группировки
|
|
131
144
|
codegenFs.createDir(path.resolve(params.output, 'endpoints'));
|
|
132
145
|
const fileNamesWithRequestInfo = [];
|
|
133
146
|
for await (const route of allRoutes) {
|
|
134
|
-
const { content: requestInfoPerFileContent, reservedDataContractNames } = await
|
|
147
|
+
const { content: requestInfoPerFileContent, reservedDataContractNames } = await endpointPerFileTmpl({
|
|
135
148
|
...generated,
|
|
136
149
|
route,
|
|
137
150
|
apiParams: params,
|
|
@@ -139,6 +152,8 @@ export const generateApi = async (params) => {
|
|
|
139
152
|
importFileParams,
|
|
140
153
|
utils,
|
|
141
154
|
relativePathDataContracts: '../data-contracts',
|
|
155
|
+
namespace,
|
|
156
|
+
groupName: null,
|
|
142
157
|
});
|
|
143
158
|
reservedDataContractNames.forEach((name) => {
|
|
144
159
|
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
@@ -168,7 +183,6 @@ export const generateApi = async (params) => {
|
|
|
168
183
|
else {
|
|
169
184
|
// #region кодогенерация с группировкой
|
|
170
185
|
// #region разбиение роутов по группам
|
|
171
|
-
const groupsMap = new Map();
|
|
172
186
|
allRoutes.forEach((route) => {
|
|
173
187
|
let group;
|
|
174
188
|
if (typeof params.groupBy === 'function') {
|
|
@@ -200,7 +214,7 @@ export const generateApi = async (params) => {
|
|
|
200
214
|
codegenFs.createDir(path.resolve(params.output, _.kebabCase(groupName)));
|
|
201
215
|
codegenFs.createDir(path.resolve(params.output, _.kebabCase(groupName), 'endpoints'));
|
|
202
216
|
for await (const route of routes) {
|
|
203
|
-
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await
|
|
217
|
+
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await endpointPerFileTmpl({
|
|
204
218
|
...generated,
|
|
205
219
|
route,
|
|
206
220
|
apiParams: params,
|
|
@@ -208,6 +222,8 @@ export const generateApi = async (params) => {
|
|
|
208
222
|
importFileParams,
|
|
209
223
|
utils,
|
|
210
224
|
relativePathDataContracts: '../../data-contracts',
|
|
225
|
+
namespace,
|
|
226
|
+
groupName,
|
|
211
227
|
});
|
|
212
228
|
reservedDataContractNames.forEach((name) => {
|
|
213
229
|
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
@@ -262,18 +278,18 @@ export * as ${exportGroupName} from './endpoints';
|
|
|
262
278
|
withPrefix: false,
|
|
263
279
|
content: dataContractsContent,
|
|
264
280
|
});
|
|
265
|
-
if (
|
|
266
|
-
const namespace = typeof params.namespace === 'function'
|
|
267
|
-
? params.namespace(utils)
|
|
268
|
-
: utils._.camelCase(params.namespace);
|
|
281
|
+
if (namespace) {
|
|
269
282
|
codegenFs.createFile({
|
|
270
283
|
path: paths.outputDir,
|
|
271
284
|
fileName: '__exports.ts',
|
|
272
285
|
withPrefix: false,
|
|
273
|
-
content:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
content: await allExportsTmpl({
|
|
287
|
+
...generated,
|
|
288
|
+
collectedExportFiles,
|
|
289
|
+
namespace,
|
|
290
|
+
groupNames: [...groupsMap.keys()],
|
|
291
|
+
utils,
|
|
292
|
+
}),
|
|
277
293
|
});
|
|
278
294
|
codegenFs.createFile({
|
|
279
295
|
path: paths.outputDir,
|
|
@@ -289,10 +305,13 @@ export * as ${namespace} from './__exports';
|
|
|
289
305
|
path: paths.outputDir,
|
|
290
306
|
fileName: 'index.ts',
|
|
291
307
|
withPrefix: false,
|
|
292
|
-
content:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
308
|
+
content: await allExportsTmpl({
|
|
309
|
+
...generated,
|
|
310
|
+
collectedExportFiles,
|
|
311
|
+
namespace,
|
|
312
|
+
groupNames: [...groupsMap.keys()],
|
|
313
|
+
utils,
|
|
314
|
+
}),
|
|
296
315
|
});
|
|
297
316
|
}
|
|
298
317
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Maybe } from 'yummies';
|
|
2
|
+
import { CodegenDataUtils } from '../index.js';
|
|
3
|
+
export interface AllExportsTmplParams {
|
|
4
|
+
formatTSContent: (...args: any[]) => Promise<string>;
|
|
5
|
+
collectedExportFiles: string[];
|
|
6
|
+
groupNames?: string[];
|
|
7
|
+
namespace?: Maybe<string>;
|
|
8
|
+
utils: CodegenDataUtils;
|
|
9
|
+
}
|
|
10
|
+
export declare const allExportsTmpl: ({ collectedExportFiles, groupNames, namespace, utils: { _ }, formatTSContent, }: AllExportsTmplParams) => Promise<string>;
|
|
11
|
+
//# sourceMappingURL=all-exports.tmpl.d.ts.map
|
|
@@ -0,0 +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,iFAMlC,oBAAoB,oBAgBtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LINTERS_IGNORE } from './constants.js';
|
|
2
|
+
export const allExportsTmpl = async ({ collectedExportFiles, groupNames, namespace, utils: { _ }, formatTSContent, }) => {
|
|
3
|
+
return await formatTSContent(`${LINTERS_IGNORE}
|
|
4
|
+
export * from './data-contracts';
|
|
5
|
+
${collectedExportFiles.map((fileName) => `export * from './${fileName}';`).join('\n')}
|
|
6
|
+
|
|
7
|
+
${namespace ? `export const namespace = "${namespace}"` : ''}
|
|
8
|
+
${groupNames?.length
|
|
9
|
+
? `
|
|
10
|
+
export const enum Group {
|
|
11
|
+
${groupNames.map((groupName) => `${_.upperFirst(_.camelCase(groupName))} = "${groupName}"`).join(',\n')}
|
|
12
|
+
}
|
|
13
|
+
`
|
|
14
|
+
: ''}
|
|
15
|
+
`);
|
|
16
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AnyObject } from 'yummies/utils/types';
|
|
2
2
|
import { GenerateQueryApiParams } from '../index.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface EndpointJSDocTmplParams {
|
|
4
4
|
route: AnyObject;
|
|
5
5
|
configuration: AnyObject;
|
|
6
6
|
apiParams: GenerateQueryApiParams;
|
|
7
7
|
offset?: number;
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
10
|
-
//# sourceMappingURL=
|
|
9
|
+
export declare const endpointJSDocTmpl: ({ route, configuration, offset, }: EndpointJSDocTmplParams) => string;
|
|
10
|
+
//# sourceMappingURL=endpoint-jsdoc.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-jsdoc.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-jsdoc.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iBAAiB,GAAI,mCAI/B,uBAAuB,WAkHzB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams } from '../index.js';
|
|
3
|
+
export interface EndpointPerFileTmplParams extends AnyObject {
|
|
4
|
+
route: AnyObject;
|
|
5
|
+
configuration: AnyObject;
|
|
6
|
+
apiParams: GenerateQueryApiParams;
|
|
7
|
+
codegenProcess: CodegenProcess;
|
|
8
|
+
importFileParams: AllImportFileParams;
|
|
9
|
+
utils: CodegenDataUtils;
|
|
10
|
+
relativePathDataContracts: string;
|
|
11
|
+
groupName: Maybe<string>;
|
|
12
|
+
namespace: Maybe<string>;
|
|
13
|
+
}
|
|
14
|
+
export declare const endpointPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, namespace, }: EndpointPerFileTmplParams) => Promise<{
|
|
15
|
+
reservedDataContractNames: string[];
|
|
16
|
+
content: any;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=endpoint-per-file.tmpl.d.ts.map
|
|
@@ -0,0 +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;;;EAuG3B,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { LINTERS_IGNORE } from './constants.js';
|
|
2
2
|
import { dataContractTmpl } from './data-contract.tmpl.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export const
|
|
3
|
+
import { endpointJSDocTmpl } from './endpoint-jsdoc.tmpl.js';
|
|
4
|
+
import { newEndpointTmpl } from './new-endpoint.tmpl.js';
|
|
5
|
+
export const endpointPerFileTmpl = async ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, namespace, }) => {
|
|
6
6
|
const { _ } = utils;
|
|
7
|
-
const { content: requestInfoInstanceContent, reservedDataContractNames, localModelTypes, } =
|
|
7
|
+
const { content: requestInfoInstanceContent, reservedDataContractNames, localModelTypes, } = newEndpointTmpl({
|
|
8
8
|
route,
|
|
9
9
|
configuration,
|
|
10
10
|
apiParams,
|
|
11
11
|
importFileParams,
|
|
12
12
|
utils,
|
|
13
|
+
groupName,
|
|
14
|
+
namespace,
|
|
13
15
|
});
|
|
14
16
|
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
15
17
|
const dataContractNamesInThisFile = [];
|
|
@@ -63,7 +65,7 @@ export const requestInfoPerFileTmpl = async ({ route, configuration, apiParams,
|
|
|
63
65
|
.filter(Boolean)
|
|
64
66
|
.join('\n\n')}
|
|
65
67
|
|
|
66
|
-
${
|
|
68
|
+
${endpointJSDocTmpl({
|
|
67
69
|
route,
|
|
68
70
|
configuration,
|
|
69
71
|
apiParams,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { AnyObject } from 'yummies/utils/types';
|
|
1
|
+
import { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
2
|
import type { AllImportFileParams, CodegenDataUtils, GenerateQueryApiParams } from '../index.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface NewEndpointTmplParams {
|
|
4
4
|
route: AnyObject;
|
|
5
5
|
configuration: AnyObject;
|
|
6
6
|
apiParams: GenerateQueryApiParams;
|
|
7
7
|
importFileParams: AllImportFileParams;
|
|
8
8
|
utils: CodegenDataUtils;
|
|
9
|
+
groupName: Maybe<string>;
|
|
10
|
+
namespace?: Maybe<string>;
|
|
9
11
|
}
|
|
10
|
-
export declare const
|
|
12
|
+
export declare const newEndpointTmpl: ({ route, apiParams, importFileParams, utils, groupName, namespace, }: NewEndpointTmplParams) => {
|
|
11
13
|
reservedDataContractNames: string[];
|
|
12
14
|
localModelTypes: {
|
|
13
15
|
typeIdentifier: string;
|
|
@@ -16,4 +18,4 @@ export declare const newRequestInfoTmpl: ({ route, apiParams, importFileParams,
|
|
|
16
18
|
}[];
|
|
17
19
|
content: string;
|
|
18
20
|
};
|
|
19
|
-
//# sourceMappingURL=new-
|
|
21
|
+
//# sourceMappingURL=new-endpoint.tmpl.d.ts.map
|
|
@@ -0,0 +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;AAErB,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"}
|
|
@@ -12,7 +12,7 @@ const responseContentKind = {
|
|
|
12
12
|
FORM_DATA: '"formData"',
|
|
13
13
|
BYTES: '"bytes"',
|
|
14
14
|
};
|
|
15
|
-
export const
|
|
15
|
+
export const newEndpointTmpl = ({ route, apiParams, importFileParams, utils, groupName, namespace, }) => {
|
|
16
16
|
const { _ } = utils;
|
|
17
17
|
const positiveResponseTypes = route.raw.responsesTypes?.filter((it) => +it.status >= 200 && +it.status < 300);
|
|
18
18
|
const { requestBodyInfo, responseBodyInfo } = route;
|
|
@@ -152,6 +152,8 @@ new ${importFileParams.endpoint.exportName}<
|
|
|
152
152
|
.filter(Boolean)
|
|
153
153
|
.map((it) => `"${it}"`)}],
|
|
154
154
|
tags: [${tags.map((tag) => `"${tag}"`)}],
|
|
155
|
+
${groupName ? `group: "${groupName}",` : ''}
|
|
156
|
+
${namespace ? `namespace: "${namespace}",` : ''}
|
|
155
157
|
meta: ${requestInfoMeta?.tmplData ?? '{} as any'},
|
|
156
158
|
},
|
|
157
159
|
${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.62",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,6 +67,11 @@
|
|
|
67
67
|
"default": "./codegen/index.js",
|
|
68
68
|
"types": "./codegen/index.d.ts"
|
|
69
69
|
},
|
|
70
|
+
"./codegen/templates/all-exports.tmpl": {
|
|
71
|
+
"import": "./codegen/templates/all-exports.tmpl.js",
|
|
72
|
+
"default": "./codegen/templates/all-exports.tmpl.js",
|
|
73
|
+
"types": "./codegen/templates/all-exports.tmpl.d.ts"
|
|
74
|
+
},
|
|
70
75
|
"./codegen/templates/constants": {
|
|
71
76
|
"import": "./codegen/templates/constants.js",
|
|
72
77
|
"default": "./codegen/templates/constants.js",
|
|
@@ -82,25 +87,25 @@
|
|
|
82
87
|
"default": "./codegen/templates/data-contracts-file.tmpl.js",
|
|
83
88
|
"types": "./codegen/templates/data-contracts-file.tmpl.d.ts"
|
|
84
89
|
},
|
|
90
|
+
"./codegen/templates/endpoint-jsdoc.tmpl": {
|
|
91
|
+
"import": "./codegen/templates/endpoint-jsdoc.tmpl.js",
|
|
92
|
+
"default": "./codegen/templates/endpoint-jsdoc.tmpl.js",
|
|
93
|
+
"types": "./codegen/templates/endpoint-jsdoc.tmpl.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./codegen/templates/endpoint-per-file.tmpl": {
|
|
96
|
+
"import": "./codegen/templates/endpoint-per-file.tmpl.js",
|
|
97
|
+
"default": "./codegen/templates/endpoint-per-file.tmpl.js",
|
|
98
|
+
"types": "./codegen/templates/endpoint-per-file.tmpl.d.ts"
|
|
99
|
+
},
|
|
85
100
|
"./codegen/templates/index-ts-for-request-per-file.tmpl": {
|
|
86
101
|
"import": "./codegen/templates/index-ts-for-request-per-file.tmpl.js",
|
|
87
102
|
"default": "./codegen/templates/index-ts-for-request-per-file.tmpl.js",
|
|
88
103
|
"types": "./codegen/templates/index-ts-for-request-per-file.tmpl.d.ts"
|
|
89
104
|
},
|
|
90
|
-
"./codegen/templates/new-
|
|
91
|
-
"import": "./codegen/templates/new-
|
|
92
|
-
"default": "./codegen/templates/new-
|
|
93
|
-
"types": "./codegen/templates/new-
|
|
94
|
-
},
|
|
95
|
-
"./codegen/templates/request-info-jsdoc.tmpl": {
|
|
96
|
-
"import": "./codegen/templates/request-info-jsdoc.tmpl.js",
|
|
97
|
-
"default": "./codegen/templates/request-info-jsdoc.tmpl.js",
|
|
98
|
-
"types": "./codegen/templates/request-info-jsdoc.tmpl.d.ts"
|
|
99
|
-
},
|
|
100
|
-
"./codegen/templates/request-info-per-file.tmpl": {
|
|
101
|
-
"import": "./codegen/templates/request-info-per-file.tmpl.js",
|
|
102
|
-
"default": "./codegen/templates/request-info-per-file.tmpl.js",
|
|
103
|
-
"types": "./codegen/templates/request-info-per-file.tmpl.d.ts"
|
|
105
|
+
"./codegen/templates/new-endpoint.tmpl": {
|
|
106
|
+
"import": "./codegen/templates/new-endpoint.tmpl.js",
|
|
107
|
+
"default": "./codegen/templates/new-endpoint.tmpl.js",
|
|
108
|
+
"types": "./codegen/templates/new-endpoint.tmpl.d.ts"
|
|
104
109
|
},
|
|
105
110
|
".": {
|
|
106
111
|
"import": "./index.js",
|
|
@@ -5,6 +5,6 @@ import { EndpointQueryClient } from './endpoint-query-client.js';
|
|
|
5
5
|
import { AnyEndpoint } from './endpoint.types.js';
|
|
6
6
|
export declare class EndpointMutation<TEndpoint extends AnyEndpoint, TData = unknown, TParams extends AnyObject = AnyObject, TMutationMeta extends AnyObject | void = void, TContext = unknown> extends Mutation<TData, EndpointMutationParams<TParams, TMutationMeta>, TEndpoint['__response']['error'], TContext> {
|
|
7
7
|
private endpoint;
|
|
8
|
-
constructor(endpoint: AnyEndpoint, queryClient: EndpointQueryClient, { transform: transformResponse,
|
|
8
|
+
constructor(endpoint: AnyEndpoint, queryClient: EndpointQueryClient, { transform: transformResponse, invalidateEndpoints, ...mutationOptions }: EndpointMutationOptions<TEndpoint, TData, TParams, TMutationMeta, TContext>);
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=endpoint-mutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,SAAS,
|
|
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,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,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,QAAQ,GAAG,OAAO,CAClB,SAAQ,QAAQ,CAChB,KAAK,EACL,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,EAC9C,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,EAChC,QAAQ,CACT;IAEG,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,WAAW,EAC7B,WAAW,EAAE,mBAAmB,EAChC,EACE,SAAS,EAAE,iBAAiB,EAC5B,mBAAmB,EACnB,GAAG,eAAe,EACnB,EAAE,uBAAuB,CACxB,SAAS,EACT,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,CACT;CAiBJ"}
|
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import { Mutation } from 'mobx-tanstack-query';
|
|
2
2
|
export class EndpointMutation extends Mutation {
|
|
3
3
|
endpoint;
|
|
4
|
-
constructor(endpoint, queryClient, { transform: transformResponse,
|
|
4
|
+
constructor(endpoint, queryClient, { transform: transformResponse, invalidateEndpoints, ...mutationOptions }) {
|
|
5
5
|
super({
|
|
6
6
|
...mutationOptions,
|
|
7
7
|
queryClient,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
onSuccess: (data, variables, context) => {
|
|
9
|
+
mutationOptions.onSuccess?.(data, variables, context);
|
|
10
|
+
if (invalidateEndpoints) {
|
|
11
|
+
queryClient.invalidateEndpoints(invalidateEndpoints);
|
|
11
12
|
}
|
|
12
|
-
let options;
|
|
13
|
-
if (typeof invalidateQueries === 'function') {
|
|
14
|
-
options = invalidateQueries(data, payload);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
options = invalidateQueries;
|
|
18
|
-
}
|
|
19
|
-
if (!options) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
let skipInvalidate = false;
|
|
23
|
-
if (options.invalidateTags?.length) {
|
|
24
|
-
queryClient.invalidateByTags(options.invalidateTags, options);
|
|
25
|
-
skipInvalidate = true;
|
|
26
|
-
}
|
|
27
|
-
if (skipInvalidate) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
return options;
|
|
31
13
|
},
|
|
32
14
|
mutationFn: async (input) => {
|
|
33
15
|
const response = await endpoint.request(input);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MutationConfig, MutationInvalidateQueriesOptions } from 'mobx-tanstack-query';
|
|
2
2
|
import { AllPropertiesOptional, AnyObject } from 'yummies/utils/types';
|
|
3
|
+
import { InvalidateEndpointsFilters } from './endpoint-query-client.types.js';
|
|
3
4
|
import { AnyEndpoint } from './endpoint.types.js';
|
|
4
5
|
export interface EndpointMutationInvalidateQueriesOptions extends MutationInvalidateQueriesOptions {
|
|
5
|
-
invalidateTags?: string[];
|
|
6
6
|
}
|
|
7
7
|
export type EndpointMutationParams<TParams extends AnyObject, TMutationMeta extends AnyObject | void = void> = TParams & (TMutationMeta extends void ? {} : AllPropertiesOptional<TMutationMeta> extends true ? {
|
|
8
8
|
meta?: TMutationMeta;
|
|
@@ -10,6 +10,7 @@ export type EndpointMutationParams<TParams extends AnyObject, TMutationMeta exte
|
|
|
10
10
|
meta: TMutationMeta;
|
|
11
11
|
});
|
|
12
12
|
export type EndpointMutationOptions<TEndpoint extends AnyEndpoint, TData = unknown, TParams extends AnyObject = AnyObject, TMutationMeta extends AnyObject | void = void, TContext = unknown> = {
|
|
13
|
+
invalidateEndpoints?: InvalidateEndpointsFilters;
|
|
13
14
|
/**
|
|
14
15
|
* Transform response to TData
|
|
15
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-mutation.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,wCACf,SAAQ,gCAAgC;
|
|
1
|
+
{"version":3,"file":"endpoint-mutation.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MA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AAC,OAAO,CAAC,EAChC,QAAQ,CACT,EACD,aAAa,GAAG,YAAY,GAAG,mBAAmB,CACnD,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { InvalidateOptions
|
|
1
|
+
import { InvalidateOptions } from '@tanstack/query-core';
|
|
2
2
|
import { QueryClient } from 'mobx-tanstack-query';
|
|
3
|
-
import {
|
|
3
|
+
import { InvalidateEndpointsFilters } from './endpoint-query-client.types.js';
|
|
4
4
|
export declare class EndpointQueryClient extends QueryClient {
|
|
5
|
-
|
|
6
|
-
invalidateByEndpoint(endpoint: AnyEndpoint | AnyEndpoint[], filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'>, options?: InvalidateOptions): Promise<void>;
|
|
7
|
-
invalidateByOperationId(operationId: string | RegExp, filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'>, options?: InvalidateOptions): Promise<void>;
|
|
8
|
-
invalidateByPath(path: string[] | string | RegExp, filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'> & {
|
|
9
|
-
segment?: number;
|
|
10
|
-
}, options?: InvalidateOptions): Promise<void>;
|
|
11
|
-
invalidateByTags(tags: any[], filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'>, options?: InvalidateOptions): Promise<void>;
|
|
5
|
+
invalidateEndpoints({ group, namespace, operationId, tag, predicate, ...queryFilters }: InvalidateEndpointsFilters, options?: InvalidateOptions): Promise<void>;
|
|
12
6
|
}
|
|
13
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":"
|
|
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;CAkD9B"}
|
|
@@ -1,59 +1,47 @@
|
|
|
1
1
|
import { QueryClient } from 'mobx-tanstack-query';
|
|
2
2
|
export class EndpointQueryClient extends QueryClient {
|
|
3
|
-
|
|
3
|
+
invalidateEndpoints({ group, namespace, operationId, tag, predicate, ...queryFilters }, options) {
|
|
4
4
|
return this.invalidateQueries({
|
|
5
|
-
...
|
|
5
|
+
...queryFilters,
|
|
6
|
+
// eslint-disable-next-line sonarjs/no-invariant-returns
|
|
6
7
|
predicate: (query) => {
|
|
7
|
-
if (query.meta
|
|
8
|
-
return
|
|
8
|
+
if (!query.meta?.endpointQuery) {
|
|
9
|
+
return false;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (filters?.segment === undefined) {
|
|
32
|
-
pathDeclarationOrRegExp = path.slice(0, filters?.segment).join('/');
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
pathDeclarationOrRegExp = path.join('/');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
pathDeclarationOrRegExp = path;
|
|
40
|
-
}
|
|
41
|
-
return this.invalidateByEndpointMeta((meta) => {
|
|
42
|
-
if (typeof pathDeclarationOrRegExp === 'string') {
|
|
43
|
-
return meta.pathDeclaration.startsWith(pathDeclarationOrRegExp);
|
|
44
|
-
}
|
|
45
|
-
return pathDeclarationOrRegExp.test(meta.pathDeclaration);
|
|
46
|
-
}, filters, options);
|
|
47
|
-
}
|
|
48
|
-
invalidateByTags(tags, filters, options) {
|
|
49
|
-
return this.invalidateQueries({
|
|
50
|
-
...filters,
|
|
51
|
-
predicate: (query) => {
|
|
52
|
-
if (Array.isArray(query.meta?.tags)) {
|
|
53
|
-
return query.meta.tags.some((tag) => tags.includes(tag));
|
|
11
|
+
const meta = query.meta;
|
|
12
|
+
if (namespace &&
|
|
13
|
+
meta.namespace &&
|
|
14
|
+
!applyStringFilter(namespace, meta.namespace)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (group && meta.group && !applyStringFilter(group, meta.group)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (tag && meta.tags && !applyStringFilter(tag, meta.tags)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (tag && meta.tags && !applyStringFilter(tag, meta.tags)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (operationId &&
|
|
27
|
+
!applyStringFilter(operationId, meta.operationId)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (predicate && !predicate(meta, query)) {
|
|
31
|
+
return false;
|
|
54
32
|
}
|
|
55
33
|
return false;
|
|
56
34
|
},
|
|
57
35
|
}, options);
|
|
58
36
|
}
|
|
59
37
|
}
|
|
38
|
+
const applyStringFilter = (filter, value) => {
|
|
39
|
+
const values = Array.isArray(value) ? value : [value];
|
|
40
|
+
if (filter instanceof RegExp) {
|
|
41
|
+
return values.some((value) => filter.test(value));
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(filter)) {
|
|
44
|
+
return filter.some((filter) => values.includes(filter));
|
|
45
|
+
}
|
|
46
|
+
return values.includes(filter);
|
|
47
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InvalidateQueryFilters } from '@tanstack/query-core';
|
|
2
|
+
import { EndpointQueryMeta } from './endpoint-query.types.js';
|
|
3
|
+
import { AnyEndpoint } from './endpoint.types.js';
|
|
4
|
+
interface InvalidateEndpointQueryFilters extends Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'> {
|
|
5
|
+
}
|
|
6
|
+
export type EndpointStringFilter = string[] | string | RegExp;
|
|
7
|
+
export interface InvalidateEndpointsFilters extends InvalidateEndpointQueryFilters {
|
|
8
|
+
predicate?: (meta: EndpointQueryMeta, query: Parameters<Required<InvalidateQueryFilters>['predicate']>[0]) => boolean;
|
|
9
|
+
endpoint?: AnyEndpoint | AnyEndpoint[];
|
|
10
|
+
namespace?: EndpointStringFilter;
|
|
11
|
+
group?: EndpointStringFilter;
|
|
12
|
+
operationId?: EndpointStringFilter;
|
|
13
|
+
tag?: EndpointStringFilter;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=endpoint-query-client.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-query-client.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query-client.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,UAAU,8BACR,SAAQ,IAAI,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CAAG;AAE1E,MAAM,MAAM,oBAAoB,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,0BACf,SAAQ,8BAA8B;IACtC,SAAS,CAAC,EAAE,CACV,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,KAChE,OAAO,CAAC;IACb,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IACvC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,GAAG,CAAC,EAAE,oBAAoB,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,6 +10,8 @@ export interface EndpointQueryMeta {
|
|
|
10
10
|
operationId: string;
|
|
11
11
|
path: string[];
|
|
12
12
|
pathDeclaration: string;
|
|
13
|
+
group?: string;
|
|
14
|
+
namespace?: string;
|
|
13
15
|
}
|
|
14
16
|
export type EndpointQueryUnitKey = Maybe<FnValue<string | number | AnyObject | boolean>>;
|
|
15
17
|
export type EndpointQueryOptions<TEndpoint extends AnyEndpoint, TQueryFnData = TEndpoint['__response']['data'], TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,IAAI,CAA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,EAAE,SAAS,CAAC,YAAY,CAAC,KAC9B,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC3C,GAAG,IAAI,CACN,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,EAC3D,SAAS,GACT,SAAS,GACT,aAAa,GACb,UAAU,GACV,YAAY,GACZ,oBAAoB,GACpB,+BAA+B,GAC/B,SAAS,GACT,WAAW,GACX,gBAAgB,CACnB,GAAG;IACA,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
package/runtime/endpoint.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DefaultError
|
|
1
|
+
import { DefaultError } from '@tanstack/query-core';
|
|
2
2
|
import { AllPropertiesOptional, AnyObject } from 'yummies/utils/types';
|
|
3
3
|
import { EndpointMutation } from './endpoint-mutation.js';
|
|
4
4
|
import { EndpointMutationOptions } from './endpoint-mutation.types.js';
|
|
5
5
|
import { EndpointQueryClient } from './endpoint-query-client.js';
|
|
6
6
|
import { EndpointQuery } from './endpoint-query.js';
|
|
7
7
|
import { EndpointQueryOptions, EndpointQueryUnitKey } from './endpoint-query.types.js';
|
|
8
|
-
import { EndpointConfiguration } from './endpoint.types.js';
|
|
8
|
+
import { EndpointConfiguration, EndpointMutationPresets } from './endpoint.types.js';
|
|
9
9
|
import type { HttpClient, HttpResponse } from './http-client.js';
|
|
10
10
|
export interface Endpoint<TResponse extends HttpResponse<any, any>, TParams extends AnyObject, TMetaData extends AnyObject = AnyObject> {
|
|
11
11
|
(...args: AllPropertiesOptional<TParams> extends true ? [params?: TParams] : [params: TParams]): ReturnType<Endpoint<TResponse, TParams, TMetaData>['request']>;
|
|
@@ -15,6 +15,9 @@ export declare class Endpoint<TResponse extends HttpResponse<any, any>, TParams
|
|
|
15
15
|
protected queryClient: EndpointQueryClient;
|
|
16
16
|
protected http: HttpClient;
|
|
17
17
|
endpointId: string;
|
|
18
|
+
presets: {
|
|
19
|
+
mutations: EndpointMutationPresets;
|
|
20
|
+
};
|
|
18
21
|
__params: TParams;
|
|
19
22
|
__response: TResponse;
|
|
20
23
|
meta: TMetaData;
|
|
@@ -24,21 +27,9 @@ export declare class Endpoint<TResponse extends HttpResponse<any, any>, TParams
|
|
|
24
27
|
get tags(): string[];
|
|
25
28
|
get path(): string[];
|
|
26
29
|
get operationId(): string;
|
|
30
|
+
get group(): string | undefined;
|
|
31
|
+
get namespace(): string | undefined;
|
|
27
32
|
request(...args: AllPropertiesOptional<TParams> extends true ? [input?: TParams] : [input: TParams]): Promise<TResponse>;
|
|
28
|
-
/**
|
|
29
|
-
* segment - last segment number in path which need to crop for invalidate
|
|
30
|
-
* @example
|
|
31
|
-
* // endpoint path ["v1", "api", "kek"]
|
|
32
|
-
* endpoint.invalidateByPath({ segment: 1 }) // "v1/api*"
|
|
33
|
-
*/
|
|
34
|
-
invalidateByPath(filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'> & {
|
|
35
|
-
segment?: number;
|
|
36
|
-
}, options?: InvalidateOptions): Promise<void>;
|
|
37
|
-
invalidateByOperationId(filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'>, options?: InvalidateOptions): Promise<void>;
|
|
38
|
-
invalidateByTags(filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'>, options?: InvalidateOptions): Promise<void>;
|
|
39
|
-
invalidate(input: TParams, filters?: Omit<InvalidateQueryFilters<any[]>, 'queryKey' | 'predicate'> & {
|
|
40
|
-
queryKeyIndex?: number;
|
|
41
|
-
}, options?: InvalidateOptions): Promise<void>;
|
|
42
33
|
getQueryKey(...args: AllPropertiesOptional<TParams> extends true ? [input?: TParams, uniqKey?: EndpointQueryUnitKey] : [input: TParams, uniqKey?: EndpointQueryUnitKey]): any[];
|
|
43
34
|
toMutation<TData = TResponse['data'], TMutationMeta extends AnyObject | void = void, TContext = unknown>(options: EndpointMutationOptions<this, TData, TParams, TMutationMeta, TContext>): EndpointMutation<this, TData, TParams, TMutationMeta, TContext>;
|
|
44
35
|
toQuery<TQueryFnData = TResponse['data'], TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData>(options: EndpointQueryOptions<this, TQueryFnData, TError, TData, TQueryData>): EndpointQuery<this, TQueryFnData, TError, TData, TQueryData>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,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,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,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACxC,OAAO,SAAS,SAAS,EACzB,SAAS,SAAS,SAAS,GAAG,SAAS;IAEvC,CACE,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,SAAS,IAAI,GAChD,CAAC,MAAM,CAAC,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I,EAAE,qBAAqB,CAAC,OAAO,CAAC,SAAS,IAAI,GAChD,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,GACjB,CAAC,KAAK,EAAE,OAAO,CAAC;IAOtB,WAAW,CACT,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,SAAS,IAAI,GAChD,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,oBAAoB,CAAC,GACjD,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,oBAAoB,CAAC,GACnD,GAAG,EAAE;IAWR,UAAU,CACR,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,EACzB,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,EAC7C,QAAQ,GAAG,OAAO,EAElB,OAAO,EAAE,uBAAuB,CAC9B,IAAI,EACJ,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,CACT;IAcH,OAAO,CACL,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,EAChC,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,UAAU,GAAG,YAAY,EAEzB,OAAO,EAAE,oBAAoB,CAC3B,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,CACX;CAQJ"}
|
package/runtime/endpoint.js
CHANGED
|
@@ -6,6 +6,9 @@ export class Endpoint {
|
|
|
6
6
|
queryClient;
|
|
7
7
|
http;
|
|
8
8
|
endpointId;
|
|
9
|
+
presets = {
|
|
10
|
+
mutations: {},
|
|
11
|
+
};
|
|
9
12
|
__params;
|
|
10
13
|
__response;
|
|
11
14
|
meta;
|
|
@@ -53,30 +56,14 @@ export class Endpoint {
|
|
|
53
56
|
get operationId() {
|
|
54
57
|
return this.configuration.operationId;
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
return this.
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* segment - last segment number in path which need to crop for invalidate
|
|
61
|
-
* @example
|
|
62
|
-
* // endpoint path ["v1", "api", "kek"]
|
|
63
|
-
* endpoint.invalidateByPath({ segment: 1 }) // "v1/api*"
|
|
64
|
-
*/
|
|
65
|
-
invalidateByPath(filters, options) {
|
|
66
|
-
return this.queryClient.invalidateByPath(this.configuration.path, filters, options);
|
|
67
|
-
}
|
|
68
|
-
invalidateByOperationId(filters, options) {
|
|
69
|
-
return this.queryClient.invalidateByOperationId(this.operationId, filters, options);
|
|
59
|
+
get group() {
|
|
60
|
+
return this.configuration.group;
|
|
70
61
|
}
|
|
71
|
-
|
|
72
|
-
return this.
|
|
62
|
+
get namespace() {
|
|
63
|
+
return this.configuration.namespace;
|
|
73
64
|
}
|
|
74
|
-
|
|
75
|
-
return this.
|
|
76
|
-
...filters,
|
|
77
|
-
queryKey: this.getQueryKey(input).slice(0, filters?.queryKeyIndex),
|
|
78
|
-
exact: filters?.exact ?? false,
|
|
79
|
-
}, options);
|
|
65
|
+
request(...args) {
|
|
66
|
+
return this.http.request(this.configuration.params(args[0] ?? {}));
|
|
80
67
|
}
|
|
81
68
|
getQueryKey(...args) {
|
|
82
69
|
const params = args[0] ?? {};
|
|
@@ -88,7 +75,11 @@ export class Endpoint {
|
|
|
88
75
|
];
|
|
89
76
|
}
|
|
90
77
|
toMutation(options) {
|
|
91
|
-
return new EndpointMutation(this, this.queryClient,
|
|
78
|
+
return new EndpointMutation(this, this.queryClient, {
|
|
79
|
+
...options,
|
|
80
|
+
invalidateEndpoints: options.invalidateEndpoints ??
|
|
81
|
+
this.presets.mutations?.invalidateQueries,
|
|
82
|
+
});
|
|
92
83
|
}
|
|
93
84
|
toQuery(options) {
|
|
94
85
|
return new EndpointQuery(this, this.queryClient, options);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { AnyObject } from 'yummies/utils/types';
|
|
2
|
+
import { InvalidateEndpointsFilters } from './endpoint-query-client.types.js';
|
|
2
3
|
import type { Endpoint } from './endpoint.js';
|
|
3
4
|
import { FullRequestParams } from './http-client.js';
|
|
4
5
|
export interface EndpointConfiguration<TInput extends AnyObject, TMetaData extends AnyObject = AnyObject> {
|
|
6
|
+
group?: string;
|
|
7
|
+
namespace?: string;
|
|
5
8
|
operationId: string;
|
|
6
9
|
path: string[];
|
|
7
10
|
meta?: TMetaData;
|
|
@@ -14,4 +17,7 @@ export type InferEndpointData<TEndpoint extends AnyEndpoint> = TEndpoint extends
|
|
|
14
17
|
export type InferEndpointResponse<TEndpoint extends AnyEndpoint> = TEndpoint extends Endpoint<infer T, any, any> ? T : never;
|
|
15
18
|
export type InferEndpointInput<TEndpoint extends AnyEndpoint> = TEndpoint extends Endpoint<any, infer T, any> ? T : never;
|
|
16
19
|
export type InferEndpointMetaData<TEndpoint extends AnyEndpoint> = TEndpoint extends Endpoint<any, any, infer T> ? T : never;
|
|
20
|
+
export interface EndpointMutationPresets {
|
|
21
|
+
invalidateQueries?: InvalidateEndpointsFilters;
|
|
22
|
+
}
|
|
17
23
|
//# sourceMappingURL=endpoint.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.types.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,qBAAqB,CACpC,MAAM,SAAS,SAAS,EACxB,SAAS,SAAS,SAAS,GAAG,SAAS;IAEvC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,iBAAiB,CAAC;IACtD,IAAI,EAAE,MAAM,EAAE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AE,MAAM,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,iBAAiB,CAAC;IACtD,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAElD,MAAM,MAAM,iBAAiB,CAAC,SAAS,SAAS,WAAW,IACzD,SAAS,SAAS,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE5D,MAAM,MAAM,qBAAqB,CAAC,SAAS,SAAS,WAAW,IAC7D,SAAS,SAAS,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE5D,MAAM,MAAM,kBAAkB,CAAC,SAAS,SAAS,WAAW,IAC1D,SAAS,SAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE5D,MAAM,MAAM,qBAAqB,CAAC,SAAS,SAAS,WAAW,IAC7D,SAAS,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE5D,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,EAAE,0BAA0B,CAAC;CAChD"}
|
package/runtime/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './endpoint.js';
|
|
|
2
2
|
export * from './endpoint.types.js';
|
|
3
3
|
export * from './http-client.js';
|
|
4
4
|
export * from './endpoint-query-client.js';
|
|
5
|
+
export * from './endpoint-query-client.types.js';
|
|
5
6
|
export * from './endpoint-query.js';
|
|
6
7
|
export * from './endpoint-query.types.js';
|
|
7
8
|
export * from './endpoint-mutation.js';
|
package/runtime/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC"}
|
package/runtime/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './endpoint.js';
|
|
|
2
2
|
export * from './endpoint.types.js';
|
|
3
3
|
export * from './http-client.js';
|
|
4
4
|
export * from './endpoint-query-client.js';
|
|
5
|
+
export * from './endpoint-query-client.types.js';
|
|
5
6
|
export * from './endpoint-query.js';
|
|
6
7
|
export * from './endpoint-query.types.js';
|
|
7
8
|
export * from './endpoint-mutation.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-request-info.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-request-info.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAiBD,eAAO,MAAM,kBAAkB,GAAI,gDAKhC,wBAAwB;;;;;;;;CAsM1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-info-jsdoc.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/request-info-jsdoc.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,GAAI,mCAIlC,0BAA0B,WAkH5B,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AnyObject } from 'yummies/utils/types';
|
|
2
|
-
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams } from '../index.js';
|
|
3
|
-
export interface RequestInfoPerFileTmplParams extends AnyObject {
|
|
4
|
-
route: AnyObject;
|
|
5
|
-
configuration: AnyObject;
|
|
6
|
-
apiParams: GenerateQueryApiParams;
|
|
7
|
-
codegenProcess: CodegenProcess;
|
|
8
|
-
importFileParams: AllImportFileParams;
|
|
9
|
-
utils: CodegenDataUtils;
|
|
10
|
-
relativePathDataContracts: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const requestInfoPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, }: RequestInfoPerFileTmplParams) => Promise<{
|
|
13
|
-
reservedDataContractNames: string[];
|
|
14
|
-
content: any;
|
|
15
|
-
}>;
|
|
16
|
-
//# sourceMappingURL=request-info-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-info-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/request-info-per-file.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC7D,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;CACnC;AAED,eAAO,MAAM,sBAAsB,GAAU,2GAQ1C,4BAA4B;;;EAqG9B,CAAC"}
|