mobx-tanstack-query-api 0.0.69 → 0.0.70
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 +5 -0
- package/codegen/index.d.ts.map +1 -1
- package/codegen/index.js +35 -6
- package/codegen/templates/all-exports.tmpl.d.ts +3 -4
- package/codegen/templates/all-exports.tmpl.d.ts.map +1 -1
- package/codegen/templates/all-exports.tmpl.js +2 -10
- package/codegen/templates/endpoint-per-file.tmpl.d.ts +3 -3
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +1 -1
- package/codegen/templates/endpoint-per-file.tmpl.js +7 -3
- package/codegen/templates/meta-info.tmpl.d.ts +11 -0
- package/codegen/templates/meta-info.tmpl.d.ts.map +1 -0
- package/codegen/templates/meta-info.tmpl.js +24 -0
- package/codegen/templates/new-endpoint.tmpl.d.ts +3 -3
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +1 -1
- package/codegen/templates/new-endpoint.tmpl.js +10 -5
- package/package.json +6 -1
package/codegen/index.d.ts
CHANGED
|
@@ -10,6 +10,11 @@ export interface ImportFileParams {
|
|
|
10
10
|
path: string;
|
|
11
11
|
exportName: string;
|
|
12
12
|
}
|
|
13
|
+
export interface MetaInfo {
|
|
14
|
+
namespace: string | null;
|
|
15
|
+
groupNames: string[];
|
|
16
|
+
tags?: string[];
|
|
17
|
+
}
|
|
13
18
|
export interface GenerateQueryApiParams {
|
|
14
19
|
output: string;
|
|
15
20
|
input: string | AnyObject;
|
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,EAAS,MAAM,qBAAqB,CAAC;
|
|
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;AAgBrE,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,QAAQ;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;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;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,qBAAqB,CAAC,EAAE,CACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,gBAAgB,KACpB,MAAM,CAAC;IAEZ;;OAEG;IACH,OAAO,CAAC,EACJ,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC,GAC9B,cAAc,GACd,gBAAgB,MAAM,EAAE,GACxB,KAAK,GACL,OAAO,MAAM,EAAE,CAAC;IAEpB;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC,CAAC;IAEpD;;;;;;;;OAQG;IACH,yBAAyB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE7C,WAAW,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC;IAC3C,QAAQ,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC;IACxC,UAAU,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC;IAE1C,eAAe,CAAC,EAAE,CAChB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,KACb;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,KACb;QACH,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF,cAAc,CAAC,EAAE,SAAS,CAAC;IAE3B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAE/B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;IAE7C,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAE9C,UAAU,CAAC,EAAE;QACX,yBAAyB,CAAC,EAAE,MAAM,CAAC;KACpC,CAAC;CACH;AAED,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,CAqbd,CAAC"}
|
package/codegen/index.js
CHANGED
|
@@ -6,6 +6,7 @@ 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
8
|
import { indexTsForEndpointPerFileTmpl } from './templates/index-ts-for-endpoint-per-file.tmpl.js';
|
|
9
|
+
import { metaInfoTmpl } from './templates/meta-info.tmpl.js';
|
|
9
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
11
|
const __dirname = path.dirname(__filename);
|
|
11
12
|
export const generateApi = async (params) => {
|
|
@@ -138,6 +139,7 @@ export const generateApi = async (params) => {
|
|
|
138
139
|
const reservedDataContractNamesMap = new Map();
|
|
139
140
|
const collectedExportFiles = [];
|
|
140
141
|
const groupsMap = new Map();
|
|
142
|
+
const tagsSet = new Set();
|
|
141
143
|
if (params.groupBy == null) {
|
|
142
144
|
collectedExportFiles.push('endpoints');
|
|
143
145
|
// #region кодогенерация 1 эндпоинт - 1 файл без группировки
|
|
@@ -152,9 +154,15 @@ export const generateApi = async (params) => {
|
|
|
152
154
|
importFileParams,
|
|
153
155
|
utils,
|
|
154
156
|
relativePathDataContracts: '../data-contracts',
|
|
155
|
-
namespace,
|
|
156
157
|
groupName: null,
|
|
158
|
+
metaInfo: {
|
|
159
|
+
groupNames: [],
|
|
160
|
+
namespace,
|
|
161
|
+
},
|
|
157
162
|
});
|
|
163
|
+
if (Array.isArray(route.raw.tags)) {
|
|
164
|
+
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
165
|
+
}
|
|
158
166
|
reservedDataContractNames.forEach((name) => {
|
|
159
167
|
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
160
168
|
});
|
|
@@ -222,9 +230,15 @@ export const generateApi = async (params) => {
|
|
|
222
230
|
importFileParams,
|
|
223
231
|
utils,
|
|
224
232
|
relativePathDataContracts: '../../data-contracts',
|
|
225
|
-
namespace,
|
|
226
233
|
groupName,
|
|
234
|
+
metaInfo: {
|
|
235
|
+
namespace,
|
|
236
|
+
groupNames: [],
|
|
237
|
+
},
|
|
227
238
|
});
|
|
239
|
+
if (Array.isArray(route.raw.tags)) {
|
|
240
|
+
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
241
|
+
}
|
|
228
242
|
reservedDataContractNames.forEach((name) => {
|
|
229
243
|
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
230
244
|
});
|
|
@@ -263,6 +277,13 @@ export * as ${exportGroupName} from './endpoints';
|
|
|
263
277
|
}
|
|
264
278
|
// #endregion
|
|
265
279
|
}
|
|
280
|
+
const metaInfo = (namespace ?? groupsMap.size > 0)
|
|
281
|
+
? {
|
|
282
|
+
namespace,
|
|
283
|
+
groupNames: [...groupsMap.keys()],
|
|
284
|
+
tags: [...tagsSet.values()],
|
|
285
|
+
}
|
|
286
|
+
: null;
|
|
266
287
|
const excludedDataContractNames = Array.from(reservedDataContractNamesMap.entries())
|
|
267
288
|
.filter(([_, count]) => count === 1)
|
|
268
289
|
.map(([name]) => name);
|
|
@@ -278,6 +299,16 @@ export * as ${exportGroupName} from './endpoints';
|
|
|
278
299
|
withPrefix: false,
|
|
279
300
|
content: dataContractsContent,
|
|
280
301
|
});
|
|
302
|
+
codegenFs.createFile({
|
|
303
|
+
path: paths.outputDir,
|
|
304
|
+
fileName: 'meta-info.ts',
|
|
305
|
+
withPrefix: false,
|
|
306
|
+
content: await metaInfoTmpl({
|
|
307
|
+
...generated,
|
|
308
|
+
metaInfo,
|
|
309
|
+
utils,
|
|
310
|
+
}),
|
|
311
|
+
});
|
|
281
312
|
if (namespace) {
|
|
282
313
|
codegenFs.createFile({
|
|
283
314
|
path: paths.outputDir,
|
|
@@ -286,8 +317,7 @@ export * as ${exportGroupName} from './endpoints';
|
|
|
286
317
|
content: await allExportsTmpl({
|
|
287
318
|
...generated,
|
|
288
319
|
collectedExportFiles,
|
|
289
|
-
|
|
290
|
-
groupNames: [...groupsMap.keys()],
|
|
320
|
+
metaInfo,
|
|
291
321
|
utils,
|
|
292
322
|
}),
|
|
293
323
|
});
|
|
@@ -308,8 +338,7 @@ export * as ${namespace} from './__exports';
|
|
|
308
338
|
content: await allExportsTmpl({
|
|
309
339
|
...generated,
|
|
310
340
|
collectedExportFiles,
|
|
311
|
-
|
|
312
|
-
groupNames: [...groupsMap.keys()],
|
|
341
|
+
metaInfo,
|
|
313
342
|
utils,
|
|
314
343
|
}),
|
|
315
344
|
});
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Maybe } from 'yummies';
|
|
2
|
-
import { CodegenDataUtils } from '../index.js';
|
|
2
|
+
import { CodegenDataUtils, MetaInfo } from '../index.js';
|
|
3
3
|
export interface AllExportsTmplParams {
|
|
4
4
|
formatTSContent: (...args: any[]) => Promise<string>;
|
|
5
5
|
collectedExportFiles: string[];
|
|
6
|
-
|
|
7
|
-
namespace?: Maybe<string>;
|
|
6
|
+
metaInfo: Maybe<MetaInfo>;
|
|
8
7
|
utils: CodegenDataUtils;
|
|
9
8
|
}
|
|
10
9
|
export declare const formatGroupNameEnumKey: (groupName: string, { _ }: CodegenDataUtils) => Capitalize<string>;
|
|
11
|
-
export declare const allExportsTmpl: ({ collectedExportFiles,
|
|
10
|
+
export declare const allExportsTmpl: ({ collectedExportFiles, metaInfo, formatTSContent, }: AllExportsTmplParams) => Promise<string>;
|
|
12
11
|
//# 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;
|
|
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,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIzD,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,QAAQ,EAAE,KAAK,CAAC,QAAQ,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,sDAIlC,oBAAoB,oBAMtB,CAAC"}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { LINTERS_IGNORE } from './constants.js';
|
|
2
2
|
export const formatGroupNameEnumKey = (groupName, { _ }) => _.upperFirst(_.camelCase(groupName));
|
|
3
|
-
export const allExportsTmpl = async ({ collectedExportFiles,
|
|
3
|
+
export const allExportsTmpl = async ({ collectedExportFiles, metaInfo, formatTSContent, }) => {
|
|
4
4
|
return await formatTSContent(`${LINTERS_IGNORE}
|
|
5
5
|
export * from './data-contracts';
|
|
6
6
|
${collectedExportFiles.map((fileName) => `export * from './${fileName}';`).join('\n')}
|
|
7
|
-
|
|
8
|
-
${namespace ? `export const namespace = "${namespace}"` : ''}
|
|
9
|
-
${groupNames?.length
|
|
10
|
-
? `
|
|
11
|
-
export const enum Group {
|
|
12
|
-
${groupNames.map((groupName) => `${formatGroupNameEnumKey(groupName, utils)} = "${groupName}"`).join(',\n')}
|
|
13
|
-
}
|
|
14
|
-
`
|
|
15
|
-
: ''}
|
|
7
|
+
${metaInfo ? 'export * from "./meta-info";' : ''}
|
|
16
8
|
`);
|
|
17
9
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams } from '../index.js';
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from '../index.js';
|
|
3
3
|
export interface EndpointPerFileTmplParams extends AnyObject {
|
|
4
4
|
route: AnyObject;
|
|
5
5
|
configuration: AnyObject;
|
|
@@ -9,9 +9,9 @@ export interface EndpointPerFileTmplParams extends AnyObject {
|
|
|
9
9
|
utils: CodegenDataUtils;
|
|
10
10
|
relativePathDataContracts: string;
|
|
11
11
|
groupName: Maybe<string>;
|
|
12
|
-
|
|
12
|
+
metaInfo: Maybe<MetaInfo>;
|
|
13
13
|
}
|
|
14
|
-
export declare const endpointPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName,
|
|
14
|
+
export declare const endpointPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }: EndpointPerFileTmplParams) => Promise<{
|
|
15
15
|
reservedDataContractNames: string[];
|
|
16
16
|
content: any;
|
|
17
17
|
}>;
|
|
@@ -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,
|
|
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,EACtB,QAAQ,EACT,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,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,GAAU,gIAUvC,yBAAyB;;;EA+G3B,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { LINTERS_IGNORE } from './constants.js';
|
|
|
2
2
|
import { dataContractTmpl } from './data-contract.tmpl.js';
|
|
3
3
|
import { endpointJSDocTmpl } from './endpoint-jsdoc.tmpl.js';
|
|
4
4
|
import { newEndpointTmpl } from './new-endpoint.tmpl.js';
|
|
5
|
-
export const endpointPerFileTmpl = async ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName,
|
|
5
|
+
export const endpointPerFileTmpl = async ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }) => {
|
|
6
6
|
const { _ } = utils;
|
|
7
7
|
const { content: requestInfoInstanceContent, reservedDataContractNames, localModelTypes, } = newEndpointTmpl({
|
|
8
8
|
route,
|
|
@@ -11,7 +11,7 @@ export const endpointPerFileTmpl = async ({ route, configuration, apiParams, for
|
|
|
11
11
|
importFileParams,
|
|
12
12
|
utils,
|
|
13
13
|
groupName,
|
|
14
|
-
|
|
14
|
+
metaInfo,
|
|
15
15
|
});
|
|
16
16
|
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
17
17
|
const dataContractNamesInThisFile = [];
|
|
@@ -20,6 +20,10 @@ export const endpointPerFileTmpl = async ({ route, configuration, apiParams, for
|
|
|
20
20
|
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
let metaInfoImport = '';
|
|
24
|
+
if (metaInfo) {
|
|
25
|
+
metaInfoImport = `import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "../${groupName ? '../' : ''}meta-info";`;
|
|
26
|
+
}
|
|
23
27
|
return {
|
|
24
28
|
reservedDataContractNames: dataContractNamesInThisFile,
|
|
25
29
|
content: await formatTSContent(`${LINTERS_IGNORE}
|
|
@@ -31,7 +35,7 @@ export const endpointPerFileTmpl = async ({ route, configuration, apiParams, for
|
|
|
31
35
|
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
32
36
|
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
33
37
|
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
34
|
-
|
|
38
|
+
${metaInfoImport}
|
|
35
39
|
|
|
36
40
|
${configuration.modelTypes.length > 0
|
|
37
41
|
? `
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Maybe } from 'yummies';
|
|
2
|
+
import { CodegenDataUtils, MetaInfo } from '../index.js';
|
|
3
|
+
export interface MetaInfoTmplParams {
|
|
4
|
+
formatTSContent: (...args: any[]) => Promise<string>;
|
|
5
|
+
metaInfo: Maybe<MetaInfo>;
|
|
6
|
+
utils: CodegenDataUtils;
|
|
7
|
+
}
|
|
8
|
+
export declare const formatGroupNameEnumKey: (groupName: string, { _ }: CodegenDataUtils) => Capitalize<string>;
|
|
9
|
+
export declare const formatTagNameEnumKey: (tagName: string, utils: CodegenDataUtils) => Capitalize<string>;
|
|
10
|
+
export declare const metaInfoTmpl: ({ metaInfo, utils, formatTSContent, }: MetaInfoTmplParams) => Promise<string>;
|
|
11
|
+
//# sourceMappingURL=meta-info.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-info.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/meta-info.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIzD,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,OAAO,gBAAgB,uBACgB,CAAC;AAE1C,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,EACf,OAAO,gBAAgB,uBACkB,CAAC;AAE5C,eAAO,MAAM,YAAY,GAAU,uCAIhC,kBAAkB,oBAoBpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LINTERS_IGNORE } from './constants.js';
|
|
2
|
+
export const formatGroupNameEnumKey = (groupName, { _ }) => _.upperFirst(_.camelCase(groupName));
|
|
3
|
+
export const formatTagNameEnumKey = (tagName, utils) => formatGroupNameEnumKey(tagName, utils);
|
|
4
|
+
export const metaInfoTmpl = async ({ metaInfo, utils, formatTSContent, }) => {
|
|
5
|
+
return await formatTSContent(`${LINTERS_IGNORE}
|
|
6
|
+
${[
|
|
7
|
+
metaInfo?.namespace && `export const namespace = "${metaInfo?.namespace}";`,
|
|
8
|
+
metaInfo?.groupNames?.length &&
|
|
9
|
+
`
|
|
10
|
+
export const enum Group {
|
|
11
|
+
${metaInfo?.groupNames.map((groupName) => `${formatGroupNameEnumKey(groupName, utils)} = "${groupName}"`).join(',\n')}
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
metaInfo?.tags?.length &&
|
|
15
|
+
`
|
|
16
|
+
export const enum Tag {
|
|
17
|
+
${metaInfo?.tags.map((tagName) => `${formatTagNameEnumKey(tagName, utils)} = "${tagName}"`).join(',\n')}
|
|
18
|
+
}
|
|
19
|
+
`,
|
|
20
|
+
]
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join('\n')}
|
|
23
|
+
`);
|
|
24
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { AllImportFileParams, CodegenDataUtils, GenerateQueryApiParams } from '../index.js';
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, GenerateQueryApiParams, MetaInfo } from '../index.js';
|
|
3
3
|
export interface NewEndpointTmplParams {
|
|
4
4
|
route: AnyObject;
|
|
5
5
|
configuration: AnyObject;
|
|
@@ -7,9 +7,9 @@ export interface NewEndpointTmplParams {
|
|
|
7
7
|
importFileParams: AllImportFileParams;
|
|
8
8
|
utils: CodegenDataUtils;
|
|
9
9
|
groupName: Maybe<string>;
|
|
10
|
-
|
|
10
|
+
metaInfo: Maybe<MetaInfo>;
|
|
11
11
|
}
|
|
12
|
-
export declare const newEndpointTmpl: ({ route, apiParams, importFileParams, utils, groupName,
|
|
12
|
+
export declare const newEndpointTmpl: ({ route, apiParams, importFileParams, utils, groupName, metaInfo, }: NewEndpointTmplParams) => {
|
|
13
13
|
reservedDataContractNames: string[];
|
|
14
14
|
localModelTypes: {
|
|
15
15
|
typeIdentifier: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,EACT,MAAM,aAAa,CAAC;AAOrB,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,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,qEAO7B,qBAAqB;;;;;;;;CA6MvB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatGroupNameEnumKey } from './
|
|
1
|
+
import { formatGroupNameEnumKey, formatTagNameEnumKey, } from './meta-info.tmpl.js';
|
|
2
2
|
// RequestParams["type"]
|
|
3
3
|
const requestContentKind = {
|
|
4
4
|
URL_ENCODED: '"application/x-www-form-urlencoded"',
|
|
@@ -13,7 +13,7 @@ const responseContentKind = {
|
|
|
13
13
|
FORM_DATA: '"formData"',
|
|
14
14
|
BYTES: '"bytes"',
|
|
15
15
|
};
|
|
16
|
-
export const newEndpointTmpl = ({ route, apiParams, importFileParams, utils, groupName,
|
|
16
|
+
export const newEndpointTmpl = ({ route, apiParams, importFileParams, utils, groupName, metaInfo, }) => {
|
|
17
17
|
const { _ } = utils;
|
|
18
18
|
const positiveResponseTypes = route.raw.responsesTypes?.filter((it) => +it.status >= 200 && +it.status < 300);
|
|
19
19
|
const { requestBodyInfo, responseBodyInfo } = route;
|
|
@@ -152,9 +152,14 @@ new ${importFileParams.endpoint.exportName}<
|
|
|
152
152
|
.split('/')
|
|
153
153
|
.filter(Boolean)
|
|
154
154
|
.map((it) => `"${it}"`)}],
|
|
155
|
-
tags: [${tags.map((tag) =>
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
tags: [${tags.map((tag) => {
|
|
156
|
+
if (metaInfo) {
|
|
157
|
+
return `Tag.${formatTagNameEnumKey(tag, utils)}`;
|
|
158
|
+
}
|
|
159
|
+
return `"${tag}"`;
|
|
160
|
+
})}],
|
|
161
|
+
${groupName ? `group: ${metaInfo ? `Group.${formatGroupNameEnumKey(groupName, utils)}` : `"${groupName}"`},` : ''}
|
|
162
|
+
${metaInfo?.namespace ? `namespace,` : ''}
|
|
158
163
|
meta: ${requestInfoMeta?.tmplData ?? '{} as any'},
|
|
159
164
|
},
|
|
160
165
|
${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.70",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -102,6 +102,11 @@
|
|
|
102
102
|
"default": "./codegen/templates/index-ts-for-endpoint-per-file.tmpl.js",
|
|
103
103
|
"types": "./codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts"
|
|
104
104
|
},
|
|
105
|
+
"./codegen/templates/meta-info.tmpl": {
|
|
106
|
+
"import": "./codegen/templates/meta-info.tmpl.js",
|
|
107
|
+
"default": "./codegen/templates/meta-info.tmpl.js",
|
|
108
|
+
"types": "./codegen/templates/meta-info.tmpl.d.ts"
|
|
109
|
+
},
|
|
105
110
|
"./codegen/templates/new-endpoint.tmpl": {
|
|
106
111
|
"import": "./codegen/templates/new-endpoint.tmpl.js",
|
|
107
112
|
"default": "./codegen/templates/new-endpoint.tmpl.js",
|