mobx-tanstack-query-api 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin.cjs +27 -0
- package/builtin.cjs.map +1 -0
- package/builtin.d.ts +6 -0
- package/builtin.js +27 -0
- package/builtin.js.map +1 -0
- package/cli.cjs +1279 -0
- package/cli.cjs.map +1 -0
- package/{codegen/types/generate-query-api-params.d.cts → cli.d.ts} +55 -10
- package/cli.js +1278 -0
- package/cli.js.map +1 -0
- package/index.cjs +771 -16
- package/index.cjs.map +1 -0
- package/index.d.ts +322 -2
- package/index.js +768 -2
- package/index.js.map +1 -0
- package/package.json +21 -64
- package/builtin/index.cjs +0 -25
- package/builtin/index.d.cts +0 -4
- package/builtin/index.d.cts.map +0 -1
- package/builtin/index.d.ts +0 -4
- package/builtin/index.d.ts.map +0 -1
- package/builtin/index.js +0 -22
- package/cli/bin.cjs +0 -17
- package/cli/bin.d.cts +0 -2
- package/cli/bin.d.cts.map +0 -1
- package/cli/bin.d.ts +0 -2
- package/cli/bin.d.ts.map +0 -1
- package/cli/bin.js +0 -15
- package/cli/index.cjs +0 -18
- package/cli/index.d.cts +0 -3
- package/cli/index.d.cts.map +0 -1
- package/cli/index.d.ts +0 -3
- package/cli/index.d.ts.map +0 -1
- package/cli/index.js +0 -2
- package/cli/utils/define-config.cjs +0 -9
- package/cli/utils/define-config.d.cts +0 -4
- package/cli/utils/define-config.d.cts.map +0 -1
- package/cli/utils/define-config.d.ts +0 -4
- package/cli/utils/define-config.d.ts.map +0 -1
- package/cli/utils/define-config.js +0 -5
- package/cli/utils/exec-config-path.cjs +0 -16
- package/cli/utils/exec-config-path.d.cts +0 -2
- package/cli/utils/exec-config-path.d.cts.map +0 -1
- package/cli/utils/exec-config-path.d.ts +0 -2
- package/cli/utils/exec-config-path.d.ts.map +0 -1
- package/cli/utils/exec-config-path.js +0 -12
- package/cli/utils/resolve-config-path.cjs +0 -65
- package/cli/utils/resolve-config-path.d.cts +0 -3
- package/cli/utils/resolve-config-path.d.cts.map +0 -1
- package/cli/utils/resolve-config-path.d.ts +0 -3
- package/cli/utils/resolve-config-path.d.ts.map +0 -1
- package/cli/utils/resolve-config-path.js +0 -25
- package/codegen/index.cjs +0 -545
- package/codegen/index.d.cts +0 -4
- package/codegen/index.d.cts.map +0 -1
- package/codegen/index.d.ts +0 -4
- package/codegen/index.d.ts.map +0 -1
- package/codegen/index.js +0 -524
- package/codegen/templates/all-endpoints-per-file.tmpl.cjs +0 -94
- package/codegen/templates/all-endpoints-per-file.tmpl.d.cts +0 -14
- package/codegen/templates/all-endpoints-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +0 -14
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.js +0 -90
- package/codegen/templates/all-exports.tmpl.cjs +0 -14
- package/codegen/templates/all-exports.tmpl.d.cts +0 -9
- package/codegen/templates/all-exports.tmpl.d.cts.map +0 -1
- package/codegen/templates/all-exports.tmpl.d.ts +0 -9
- package/codegen/templates/all-exports.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-exports.tmpl.js +0 -9
- package/codegen/templates/constants.cjs +0 -5
- package/codegen/templates/constants.d.cts +0 -2
- package/codegen/templates/constants.d.cts.map +0 -1
- package/codegen/templates/constants.d.ts +0 -2
- package/codegen/templates/constants.d.ts.map +0 -1
- package/codegen/templates/constants.js +0 -2
- package/codegen/templates/data-contract.tmpl.cjs +0 -49
- package/codegen/templates/data-contract.tmpl.d.cts +0 -8
- package/codegen/templates/data-contract.tmpl.d.cts.map +0 -1
- package/codegen/templates/data-contract.tmpl.d.ts +0 -8
- package/codegen/templates/data-contract.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contract.tmpl.js +0 -45
- package/codegen/templates/data-contracts-file.tmpl.cjs +0 -27
- package/codegen/templates/data-contracts-file.tmpl.d.cts +0 -6
- package/codegen/templates/data-contracts-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.d.ts +0 -6
- package/codegen/templates/data-contracts-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.js +0 -23
- package/codegen/templates/endpoint-jsdoc.tmpl.cjs +0 -111
- package/codegen/templates/endpoint-jsdoc.tmpl.d.cts +0 -8
- package/codegen/templates/endpoint-jsdoc.tmpl.d.cts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts +0 -8
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.js +0 -107
- package/codegen/templates/endpoint-per-file.tmpl.cjs +0 -87
- package/codegen/templates/endpoint-per-file.tmpl.d.cts +0 -14
- package/codegen/templates/endpoint-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.d.ts +0 -14
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.js +0 -83
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.cjs +0 -10
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts +0 -6
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +0 -6
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.js +0 -6
- package/codegen/templates/meta-info.tmpl.cjs +0 -48
- package/codegen/templates/meta-info.tmpl.d.cts +0 -9
- package/codegen/templates/meta-info.tmpl.d.cts.map +0 -1
- package/codegen/templates/meta-info.tmpl.d.ts +0 -9
- package/codegen/templates/meta-info.tmpl.d.ts.map +0 -1
- package/codegen/templates/meta-info.tmpl.js +0 -42
- package/codegen/templates/new-endpoint.tmpl.cjs +0 -188
- package/codegen/templates/new-endpoint.tmpl.d.cts +0 -15
- package/codegen/templates/new-endpoint.tmpl.d.cts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.d.ts +0 -15
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.js +0 -184
- package/codegen/types/all-import-file-params.cjs +0 -2
- package/codegen/types/all-import-file-params.d.cts +0 -5
- package/codegen/types/all-import-file-params.d.cts.map +0 -1
- package/codegen/types/all-import-file-params.d.ts +0 -5
- package/codegen/types/all-import-file-params.d.ts.map +0 -1
- package/codegen/types/all-import-file-params.js +0 -1
- package/codegen/types/base-tmpl-params.cjs +0 -2
- package/codegen/types/base-tmpl-params.d.cts +0 -16
- package/codegen/types/base-tmpl-params.d.cts.map +0 -1
- package/codegen/types/base-tmpl-params.d.ts +0 -16
- package/codegen/types/base-tmpl-params.d.ts.map +0 -1
- package/codegen/types/base-tmpl-params.js +0 -1
- package/codegen/types/codegen-data-utils.cjs +0 -2
- package/codegen/types/codegen-data-utils.d.cts +0 -8
- package/codegen/types/codegen-data-utils.d.cts.map +0 -1
- package/codegen/types/codegen-data-utils.d.ts +0 -8
- package/codegen/types/codegen-data-utils.d.ts.map +0 -1
- package/codegen/types/codegen-data-utils.js +0 -1
- package/codegen/types/endpoint-data.cjs +0 -2
- package/codegen/types/endpoint-data.d.cts +0 -3
- package/codegen/types/endpoint-data.d.cts.map +0 -1
- package/codegen/types/endpoint-data.d.ts +0 -3
- package/codegen/types/endpoint-data.d.ts.map +0 -1
- package/codegen/types/endpoint-data.js +0 -1
- package/codegen/types/generate-query-api-params.cjs +0 -2
- package/codegen/types/generate-query-api-params.d.cts.map +0 -1
- package/codegen/types/generate-query-api-params.d.ts +0 -162
- package/codegen/types/generate-query-api-params.d.ts.map +0 -1
- package/codegen/types/generate-query-api-params.js +0 -1
- package/codegen/types/import-file-params.cjs +0 -2
- package/codegen/types/import-file-params.d.cts +0 -5
- package/codegen/types/import-file-params.d.cts.map +0 -1
- package/codegen/types/import-file-params.d.ts +0 -5
- package/codegen/types/import-file-params.d.ts.map +0 -1
- package/codegen/types/import-file-params.js +0 -1
- package/codegen/types/index.cjs +0 -23
- package/codegen/types/index.d.cts +0 -8
- package/codegen/types/index.d.cts.map +0 -1
- package/codegen/types/index.d.ts +0 -8
- package/codegen/types/index.d.ts.map +0 -1
- package/codegen/types/index.js +0 -7
- package/codegen/types/meta-info.cjs +0 -2
- package/codegen/types/meta-info.d.cts +0 -6
- package/codegen/types/meta-info.d.cts.map +0 -1
- package/codegen/types/meta-info.d.ts +0 -6
- package/codegen/types/meta-info.d.ts.map +0 -1
- package/codegen/types/meta-info.js +0 -1
- package/codegen/types/type-info.cjs +0 -2
- package/codegen/types/type-info.d.cts +0 -4
- package/codegen/types/type-info.d.cts.map +0 -1
- package/codegen/types/type-info.d.ts +0 -4
- package/codegen/types/type-info.d.ts.map +0 -1
- package/codegen/types/type-info.js +0 -1
- package/codegen/utils/create-short-model-type.cjs +0 -12
- package/codegen/utils/create-short-model-type.d.cts +0 -5
- package/codegen/utils/create-short-model-type.d.cts.map +0 -1
- package/codegen/utils/create-short-model-type.d.ts +0 -5
- package/codegen/utils/create-short-model-type.d.ts.map +0 -1
- package/codegen/utils/create-short-model-type.js +0 -8
- package/codegen/utils/remove-unused-types.cjs +0 -117
- package/codegen/utils/remove-unused-types.d.cts +0 -7
- package/codegen/utils/remove-unused-types.d.cts.map +0 -1
- package/codegen/utils/remove-unused-types.d.ts +0 -7
- package/codegen/utils/remove-unused-types.d.ts.map +0 -1
- package/codegen/utils/remove-unused-types.js +0 -110
- package/codegen/utils/unpack-filter-option.cjs +0 -23
- package/codegen/utils/unpack-filter-option.d.cts +0 -7
- package/codegen/utils/unpack-filter-option.d.cts.map +0 -1
- package/codegen/utils/unpack-filter-option.d.ts +0 -7
- package/codegen/utils/unpack-filter-option.d.ts.map +0 -1
- package/codegen/utils/unpack-filter-option.js +0 -19
- package/index.d.cts +0 -3
- package/index.d.cts.map +0 -1
- package/index.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.cjs +0 -101
- package/runtime/endpoint-infinite-query.d.cts +0 -17
- package/runtime/endpoint-infinite-query.d.cts.map +0 -1
- package/runtime/endpoint-infinite-query.d.ts +0 -17
- package/runtime/endpoint-infinite-query.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.js +0 -97
- package/runtime/endpoint-infinite-query.types.cjs +0 -2
- package/runtime/endpoint-infinite-query.types.d.cts +0 -30
- package/runtime/endpoint-infinite-query.types.d.cts.map +0 -1
- package/runtime/endpoint-infinite-query.types.d.ts +0 -30
- package/runtime/endpoint-infinite-query.types.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.types.js +0 -1
- package/runtime/endpoint-mutation.cjs +0 -74
- package/runtime/endpoint-mutation.d.cts +0 -13
- package/runtime/endpoint-mutation.d.cts.map +0 -1
- package/runtime/endpoint-mutation.d.ts +0 -13
- package/runtime/endpoint-mutation.d.ts.map +0 -1
- package/runtime/endpoint-mutation.js +0 -70
- package/runtime/endpoint-mutation.types.cjs +0 -2
- package/runtime/endpoint-mutation.types.d.cts +0 -36
- package/runtime/endpoint-mutation.types.d.cts.map +0 -1
- package/runtime/endpoint-mutation.types.d.ts +0 -36
- package/runtime/endpoint-mutation.types.d.ts.map +0 -1
- package/runtime/endpoint-mutation.types.js +0 -1
- package/runtime/endpoint-query-client.cjs +0 -79
- package/runtime/endpoint-query-client.d.cts +0 -13
- package/runtime/endpoint-query-client.d.cts.map +0 -1
- package/runtime/endpoint-query-client.d.ts +0 -13
- package/runtime/endpoint-query-client.d.ts.map +0 -1
- package/runtime/endpoint-query-client.js +0 -75
- package/runtime/endpoint-query-client.types.cjs +0 -2
- package/runtime/endpoint-query-client.types.d.cts +0 -16
- package/runtime/endpoint-query-client.types.d.cts.map +0 -1
- package/runtime/endpoint-query-client.types.d.ts +0 -16
- package/runtime/endpoint-query-client.types.d.ts.map +0 -1
- package/runtime/endpoint-query-client.types.js +0 -1
- package/runtime/endpoint-query.cjs +0 -214
- package/runtime/endpoint-query.d.cts +0 -29
- package/runtime/endpoint-query.d.cts.map +0 -1
- package/runtime/endpoint-query.d.ts +0 -29
- package/runtime/endpoint-query.d.ts.map +0 -1
- package/runtime/endpoint-query.js +0 -208
- package/runtime/endpoint-query.types.cjs +0 -2
- package/runtime/endpoint-query.types.d.cts +0 -42
- package/runtime/endpoint-query.types.d.cts.map +0 -1
- package/runtime/endpoint-query.types.d.ts +0 -42
- package/runtime/endpoint-query.types.d.ts.map +0 -1
- package/runtime/endpoint-query.types.js +0 -1
- package/runtime/endpoint.cjs +0 -131
- package/runtime/endpoint.d.cts +0 -73
- package/runtime/endpoint.d.cts.map +0 -1
- package/runtime/endpoint.d.ts +0 -73
- package/runtime/endpoint.d.ts.map +0 -1
- package/runtime/endpoint.js +0 -127
- package/runtime/endpoint.types.cjs +0 -2
- package/runtime/endpoint.types.d.cts +0 -24
- package/runtime/endpoint.types.d.cts.map +0 -1
- package/runtime/endpoint.types.d.ts +0 -24
- package/runtime/endpoint.types.d.ts.map +0 -1
- package/runtime/endpoint.types.js +0 -1
- package/runtime/http-client.cjs +0 -190
- package/runtime/http-client.d.cts +0 -85
- package/runtime/http-client.d.cts.map +0 -1
- package/runtime/http-client.d.ts +0 -85
- package/runtime/http-client.d.ts.map +0 -1
- package/runtime/http-client.js +0 -184
- package/runtime/index.cjs +0 -25
- package/runtime/index.d.cts +0 -10
- package/runtime/index.d.cts.map +0 -1
- package/runtime/index.d.ts +0 -10
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -9
package/codegen/index.js
DELETED
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { cloneDeep } from 'lodash-es';
|
|
4
|
-
import { generateApi as generateApiFromSwagger, } from 'swagger-typescript-api';
|
|
5
|
-
import { allEndpointPerFileTmpl } from "./templates/all-endpoints-per-file.tmpl.js";
|
|
6
|
-
import { allExportsTmpl } from "./templates/all-exports.tmpl.js";
|
|
7
|
-
import { LINTERS_IGNORE } from "./templates/constants.js";
|
|
8
|
-
import { dataContractsFileTmpl } from "./templates/data-contracts-file.tmpl.js";
|
|
9
|
-
import { endpointPerFileTmpl } from "./templates/endpoint-per-file.tmpl.js";
|
|
10
|
-
import { indexTsForEndpointPerFileTmpl } from "./templates/index-ts-for-endpoint-per-file.tmpl.js";
|
|
11
|
-
import { metaInfoTmpl } from "./templates/meta-info.tmpl.js";
|
|
12
|
-
import { removeUnusedTypes } from "./utils/remove-unused-types.js";
|
|
13
|
-
import { unpackFilterOption } from "./utils/unpack-filter-option.js";
|
|
14
|
-
export * from "./types/index.js";
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
const __dirname = path.dirname(__filename);
|
|
17
|
-
const __execdirname = process.cwd();
|
|
18
|
-
export const generateApi = async (params) => {
|
|
19
|
-
if (Array.isArray(params)) {
|
|
20
|
-
for await (const param of params) {
|
|
21
|
-
await generateApi(param);
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const tsconfigPath = params.tsconfigPath
|
|
26
|
-
? path.resolve(__execdirname, params.tsconfigPath)
|
|
27
|
-
: path.resolve(__execdirname, './tsconfig.json');
|
|
28
|
-
console.info('using tsconfig', tsconfigPath);
|
|
29
|
-
const importFileParams = {
|
|
30
|
-
queryClient: !params.queryClient || typeof params.queryClient === 'string'
|
|
31
|
-
? {
|
|
32
|
-
exportName: 'queryClient',
|
|
33
|
-
path: 'mobx-tanstack-query-api/builtin',
|
|
34
|
-
}
|
|
35
|
-
: params.queryClient,
|
|
36
|
-
endpoint: !params.endpoint || typeof params.endpoint === 'string'
|
|
37
|
-
? {
|
|
38
|
-
exportName: 'Endpoint',
|
|
39
|
-
path: 'mobx-tanstack-query-api',
|
|
40
|
-
}
|
|
41
|
-
: params.endpoint,
|
|
42
|
-
httpClient: !params.httpClient || typeof params.httpClient === 'string'
|
|
43
|
-
? {
|
|
44
|
-
exportName: 'http',
|
|
45
|
-
path: 'mobx-tanstack-query-api/builtin',
|
|
46
|
-
}
|
|
47
|
-
: params.httpClient,
|
|
48
|
-
};
|
|
49
|
-
const paths = {
|
|
50
|
-
templates: path.resolve(__dirname, 'templates'),
|
|
51
|
-
requestInfoClass: path.resolve(__dirname, 'templates/request-info-class.ejs'),
|
|
52
|
-
httpClient: path.resolve(__dirname, 'templates/http-client.ejs'),
|
|
53
|
-
createRequestInfoInstance: path.resolve(__dirname, 'templates/create-request-info-instance.ejs'),
|
|
54
|
-
outputDir: path.resolve(process.cwd(), params.output),
|
|
55
|
-
};
|
|
56
|
-
//#region swagger-typescript-api
|
|
57
|
-
const swaggerTypescriptApiCodegenBaseParams = {
|
|
58
|
-
httpClientType: 'fetch',
|
|
59
|
-
cleanOutput: params.cleanOutput ?? true,
|
|
60
|
-
modular: true,
|
|
61
|
-
patch: true,
|
|
62
|
-
typeSuffix: 'DC',
|
|
63
|
-
disableStrictSSL: false,
|
|
64
|
-
singleHttpClient: true,
|
|
65
|
-
extractRequestBody: true,
|
|
66
|
-
extractRequestParams: false,
|
|
67
|
-
extractResponseBody: true,
|
|
68
|
-
extractResponseError: true,
|
|
69
|
-
generateResponses: true,
|
|
70
|
-
generateClient: false,
|
|
71
|
-
addReadonly: true,
|
|
72
|
-
moduleNameFirstTag: true,
|
|
73
|
-
sortTypes: true,
|
|
74
|
-
templates: paths.templates.toString(),
|
|
75
|
-
primitiveTypeConstructs: (constructs) => {
|
|
76
|
-
return {
|
|
77
|
-
...constructs,
|
|
78
|
-
object: () => `Record<string, any>`,
|
|
79
|
-
float: () => `number`,
|
|
80
|
-
...params.otherCodegenParams?.primitiveTypeConstructs?.(constructs),
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
requestOptions: params.fetchSchemaRequestOptions,
|
|
84
|
-
...params.otherCodegenParams,
|
|
85
|
-
};
|
|
86
|
-
let codegenProcess;
|
|
87
|
-
if (!params.input) {
|
|
88
|
-
console.warn('[mobx-tanstack-query-api/codegen]', 'input is not specified', '\nprocess will be skipped');
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const inputToCodegenInput = (input) => {
|
|
92
|
-
const inputData = {};
|
|
93
|
-
if (typeof input === 'string') {
|
|
94
|
-
inputData.input = input;
|
|
95
|
-
inputData.url = input;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
inputData.spec = input;
|
|
99
|
-
}
|
|
100
|
-
return inputData;
|
|
101
|
-
};
|
|
102
|
-
let mixinSwaggerSchema = null;
|
|
103
|
-
if (params.mixinInput) {
|
|
104
|
-
await generateApiFromSwagger({
|
|
105
|
-
...swaggerTypescriptApiCodegenBaseParams,
|
|
106
|
-
...inputToCodegenInput(params.mixinInput),
|
|
107
|
-
hooks: {
|
|
108
|
-
onInit: (configuration) => {
|
|
109
|
-
mixinSwaggerSchema = cloneDeep(configuration.swaggerSchema);
|
|
110
|
-
},
|
|
111
|
-
onPrepareConfig: (config) => {
|
|
112
|
-
config.routes.combined?.forEach((routeInfo) => {
|
|
113
|
-
routeInfo.routes.sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
onFormatRouteName: (routeInfo, usageRouteName) => {
|
|
117
|
-
let formattedRouteName = usageRouteName;
|
|
118
|
-
if (params.addPathSegmentToRouteName === true ||
|
|
119
|
-
typeof params.addPathSegmentToRouteName === 'number') {
|
|
120
|
-
const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === 'number'
|
|
121
|
-
? params.addPathSegmentToRouteName
|
|
122
|
-
: 0;
|
|
123
|
-
const pathSegments = routeInfo.route.split('/').filter(Boolean);
|
|
124
|
-
const { _ } = codegenProcess.getRenderTemplateData()
|
|
125
|
-
.utils;
|
|
126
|
-
formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
|
|
127
|
-
}
|
|
128
|
-
const endpointName = formattedRouteName;
|
|
129
|
-
return (params?.formatEndpointName?.(endpointName, routeInfo) ??
|
|
130
|
-
swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(routeInfo, endpointName) ??
|
|
131
|
-
endpointName);
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
const generated = await generateApiFromSwagger({
|
|
137
|
-
...swaggerTypescriptApiCodegenBaseParams,
|
|
138
|
-
...inputToCodegenInput(params.input),
|
|
139
|
-
hooks: {
|
|
140
|
-
onInit: (configuration, codeGenProcessFromInit) => {
|
|
141
|
-
codegenProcess = codeGenProcessFromInit;
|
|
142
|
-
const resultSwaggerSchema = configuration.swaggerSchema;
|
|
143
|
-
resultSwaggerSchema.components = resultSwaggerSchema.components || {};
|
|
144
|
-
resultSwaggerSchema.components.schemas =
|
|
145
|
-
resultSwaggerSchema.components.schemas || {};
|
|
146
|
-
resultSwaggerSchema.paths = {
|
|
147
|
-
...resultSwaggerSchema.paths,
|
|
148
|
-
...mixinSwaggerSchema?.paths,
|
|
149
|
-
};
|
|
150
|
-
resultSwaggerSchema.components.schemas = {
|
|
151
|
-
...resultSwaggerSchema.components.schemas,
|
|
152
|
-
...mixinSwaggerSchema?.components?.schemas,
|
|
153
|
-
};
|
|
154
|
-
return swaggerTypescriptApiCodegenBaseParams?.hooks?.onInit?.(configuration, codeGenProcessFromInit);
|
|
155
|
-
},
|
|
156
|
-
onPrepareConfig: (config) => {
|
|
157
|
-
config.routes.combined?.forEach((routeInfo) => {
|
|
158
|
-
routeInfo.routes.sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
|
|
159
|
-
});
|
|
160
|
-
return swaggerTypescriptApiCodegenBaseParams?.hooks?.onPrepareConfig?.(config);
|
|
161
|
-
},
|
|
162
|
-
onFormatRouteName: (routeInfo, usageRouteName) => {
|
|
163
|
-
let formattedRouteName = usageRouteName;
|
|
164
|
-
if (params.addPathSegmentToRouteName === true ||
|
|
165
|
-
typeof params.addPathSegmentToRouteName === 'number') {
|
|
166
|
-
const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === 'number'
|
|
167
|
-
? params.addPathSegmentToRouteName
|
|
168
|
-
: 0;
|
|
169
|
-
const pathSegments = routeInfo.route.split('/').filter(Boolean);
|
|
170
|
-
const { _ } = codegenProcess.getRenderTemplateData()
|
|
171
|
-
.utils;
|
|
172
|
-
formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
|
|
173
|
-
}
|
|
174
|
-
const endpointName = formattedRouteName;
|
|
175
|
-
return (params?.formatEndpointName?.(endpointName, routeInfo) ??
|
|
176
|
-
swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(routeInfo, endpointName) ??
|
|
177
|
-
endpointName);
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
//#endregion
|
|
182
|
-
const utils = codegenProcess.getRenderTemplateData()
|
|
183
|
-
.utils;
|
|
184
|
-
const { _ } = utils;
|
|
185
|
-
let namespace = null;
|
|
186
|
-
if (params.namespace) {
|
|
187
|
-
if (typeof params.namespace === 'function') {
|
|
188
|
-
namespace = params.namespace(utils);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
namespace = utils._.camelCase(params.namespace);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
const codegenFs = codegenProcess.fileSystem;
|
|
195
|
-
codegenFs.cleanDir(params.output);
|
|
196
|
-
codegenFs.createDir(params.output);
|
|
197
|
-
const filterTypes = unpackFilterOption(params.filterTypes, (modelType) => modelType.name);
|
|
198
|
-
generated.configuration.modelTypes =
|
|
199
|
-
generated.configuration.modelTypes.filter((modelType) => filterTypes(modelType));
|
|
200
|
-
const allRoutes = Object.values(generated.configuration.routes)
|
|
201
|
-
.flat()
|
|
202
|
-
.flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
|
|
203
|
-
const filterEndpoint = unpackFilterOption(params.filterEndpoints, (route) => route.raw?.operationId || '');
|
|
204
|
-
const baseTmplParams = {
|
|
205
|
-
...generated,
|
|
206
|
-
codegenParams: params,
|
|
207
|
-
configuration: generated.configuration,
|
|
208
|
-
formatTSContent: generated.formatTSContent,
|
|
209
|
-
codegenProcess,
|
|
210
|
-
importFileParams,
|
|
211
|
-
utils,
|
|
212
|
-
filterTypes,
|
|
213
|
-
};
|
|
214
|
-
const reservedDataContractNamesMap = new Map();
|
|
215
|
-
const collectedExportFilesFromIndexFile = [];
|
|
216
|
-
const groupsMap = new Map();
|
|
217
|
-
const nonEmptyGroups = new Set();
|
|
218
|
-
const tagsSet = new Set();
|
|
219
|
-
if (params.groupBy == null) {
|
|
220
|
-
collectedExportFilesFromIndexFile.push('endpoints');
|
|
221
|
-
if (params.outputType === 'one-endpoint-per-file') {
|
|
222
|
-
// #region кодогенерация 1 эндпоинт - 1 файл без группировки
|
|
223
|
-
codegenFs.createDir(path.resolve(params.output, 'endpoints'));
|
|
224
|
-
const fileNamesWithRequestInfo = [];
|
|
225
|
-
for await (const route of allRoutes) {
|
|
226
|
-
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await endpointPerFileTmpl({
|
|
227
|
-
...baseTmplParams,
|
|
228
|
-
route,
|
|
229
|
-
relativePathDataContracts: '../data-contracts',
|
|
230
|
-
groupName: null,
|
|
231
|
-
metaInfo: params.noMetaInfo
|
|
232
|
-
? null
|
|
233
|
-
: {
|
|
234
|
-
groupNames: [],
|
|
235
|
-
namespace,
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
if (Array.isArray(route.raw.tags)) {
|
|
239
|
-
route.raw.tags.forEach((tag) => {
|
|
240
|
-
tagsSet.add(tag);
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
reservedDataContractNames.forEach((name) => {
|
|
244
|
-
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
245
|
-
});
|
|
246
|
-
if (!filterEndpoint(route)) {
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
|
|
250
|
-
fileNamesWithRequestInfo.push(fileName);
|
|
251
|
-
codegenFs.createFile({
|
|
252
|
-
path: path.resolve(params.output, 'endpoints'),
|
|
253
|
-
fileName,
|
|
254
|
-
withPrefix: false,
|
|
255
|
-
content: requestInfoPerFileContent,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
codegenFs.createFile({
|
|
259
|
-
path: path.resolve(params.output, 'endpoints'),
|
|
260
|
-
fileName: 'index.ts',
|
|
261
|
-
withPrefix: false,
|
|
262
|
-
content: await indexTsForEndpointPerFileTmpl({
|
|
263
|
-
...baseTmplParams,
|
|
264
|
-
generatedRequestFileNames: fileNamesWithRequestInfo,
|
|
265
|
-
}),
|
|
266
|
-
});
|
|
267
|
-
// #endregion
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
// #region кодогенерация несколько эндпоинтов в 1 файле без группировки
|
|
271
|
-
const { content: requestInfoPerFileContent, reservedDataContractNames } = await allEndpointPerFileTmpl({
|
|
272
|
-
...baseTmplParams,
|
|
273
|
-
routes: allRoutes,
|
|
274
|
-
relativePathDataContracts: './data-contracts',
|
|
275
|
-
groupName: null,
|
|
276
|
-
metaInfo: params.noMetaInfo
|
|
277
|
-
? null
|
|
278
|
-
: {
|
|
279
|
-
namespace,
|
|
280
|
-
groupNames: [],
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
reservedDataContractNames.forEach((name) => {
|
|
284
|
-
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
285
|
-
});
|
|
286
|
-
const filteredRoutes = allRoutes.filter(filterEndpoint);
|
|
287
|
-
const hasFilteredRoutes = filteredRoutes.length > 0;
|
|
288
|
-
if (hasFilteredRoutes) {
|
|
289
|
-
filteredRoutes.forEach((route) => {
|
|
290
|
-
if (Array.isArray(route.raw.tags)) {
|
|
291
|
-
route.raw.tags.forEach((tag) => {
|
|
292
|
-
tagsSet.add(tag);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
const fileName = 'endpoints.ts';
|
|
297
|
-
collectedExportFilesFromIndexFile.push('endpoints');
|
|
298
|
-
codegenFs.createFile({
|
|
299
|
-
path: params.output,
|
|
300
|
-
fileName,
|
|
301
|
-
withPrefix: false,
|
|
302
|
-
content: requestInfoPerFileContent,
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
// #endregion
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
// #region кодогенерация с группировкой
|
|
310
|
-
// #region разбиение роутов по группам
|
|
311
|
-
allRoutes.forEach((route) => {
|
|
312
|
-
let group;
|
|
313
|
-
if (typeof params.groupBy === 'function') {
|
|
314
|
-
group = params.groupBy(route);
|
|
315
|
-
}
|
|
316
|
-
else if (params.groupBy?.includes('path-segment')) {
|
|
317
|
-
const segmentIndex = +params.groupBy.replaceAll(/path-segment-?/g, '') || 0;
|
|
318
|
-
group =
|
|
319
|
-
route.request.path?.split('/')?.filter(Boolean)?.[segmentIndex] || undefined;
|
|
320
|
-
}
|
|
321
|
-
else if (params.groupBy?.includes('tag')) {
|
|
322
|
-
const tagIndex = +params.groupBy.replaceAll(/tag-?/g, '') || 0;
|
|
323
|
-
group = route.raw?.tags?.[tagIndex] ?? undefined;
|
|
324
|
-
}
|
|
325
|
-
if (group == null) {
|
|
326
|
-
group = 'other';
|
|
327
|
-
}
|
|
328
|
-
if (!groupsMap.has(group)) {
|
|
329
|
-
groupsMap.set(group, []);
|
|
330
|
-
}
|
|
331
|
-
groupsMap.get(group)?.push(route);
|
|
332
|
-
});
|
|
333
|
-
// #endregion
|
|
334
|
-
const filterGroups = unpackFilterOption(params.filterGroups, (groupName) => groupName);
|
|
335
|
-
for await (const [groupName, routes] of groupsMap) {
|
|
336
|
-
if (!filterGroups(groupName)) {
|
|
337
|
-
continue;
|
|
338
|
-
}
|
|
339
|
-
const fileNamesWithRequestInfo = [];
|
|
340
|
-
const groupDirectory = path.resolve(params.output, _.kebabCase(groupName));
|
|
341
|
-
codegenFs.createDir(groupDirectory);
|
|
342
|
-
let hasFilteredRoutes = false;
|
|
343
|
-
if (params.outputType === 'one-endpoint-per-file') {
|
|
344
|
-
// #region Генерация одного эндпоинта на 1 файл
|
|
345
|
-
codegenFs.createDir(path.resolve(groupDirectory, 'endpoints'));
|
|
346
|
-
for await (const route of routes) {
|
|
347
|
-
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await endpointPerFileTmpl({
|
|
348
|
-
...baseTmplParams,
|
|
349
|
-
route,
|
|
350
|
-
relativePathDataContracts: '../../data-contracts',
|
|
351
|
-
groupName,
|
|
352
|
-
metaInfo: params.noMetaInfo
|
|
353
|
-
? null
|
|
354
|
-
: {
|
|
355
|
-
namespace,
|
|
356
|
-
groupNames: [],
|
|
357
|
-
},
|
|
358
|
-
});
|
|
359
|
-
reservedDataContractNames.forEach((name) => {
|
|
360
|
-
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
361
|
-
});
|
|
362
|
-
if (!filterEndpoint(route)) {
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
hasFilteredRoutes = true;
|
|
366
|
-
if (Array.isArray(route.raw.tags)) {
|
|
367
|
-
route.raw.tags.forEach((tag) => {
|
|
368
|
-
tagsSet.add(tag);
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
|
|
372
|
-
fileNamesWithRequestInfo.push(fileName);
|
|
373
|
-
codegenFs.createFile({
|
|
374
|
-
path: path.resolve(params.output, _.kebabCase(groupName), 'endpoints'),
|
|
375
|
-
fileName,
|
|
376
|
-
withPrefix: false,
|
|
377
|
-
content: requestInfoPerFileContent,
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
// #endregion
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
// #region Генерация нескольких эндпоинтов на 1 файл
|
|
384
|
-
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await allEndpointPerFileTmpl({
|
|
385
|
-
...baseTmplParams,
|
|
386
|
-
routes,
|
|
387
|
-
relativePathDataContracts: '../data-contracts',
|
|
388
|
-
groupName,
|
|
389
|
-
metaInfo: params.noMetaInfo
|
|
390
|
-
? null
|
|
391
|
-
: {
|
|
392
|
-
namespace,
|
|
393
|
-
groupNames: [],
|
|
394
|
-
},
|
|
395
|
-
});
|
|
396
|
-
reservedDataContractNames.forEach((name) => {
|
|
397
|
-
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
398
|
-
});
|
|
399
|
-
const filteredRoutes = routes.filter(filterEndpoint);
|
|
400
|
-
hasFilteredRoutes = filteredRoutes.length > 0;
|
|
401
|
-
if (hasFilteredRoutes) {
|
|
402
|
-
filteredRoutes.forEach((route) => {
|
|
403
|
-
if (Array.isArray(route.raw.tags)) {
|
|
404
|
-
route.raw.tags.forEach((tag) => {
|
|
405
|
-
tagsSet.add(tag);
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
const fileName = 'endpoints.ts';
|
|
410
|
-
fileNamesWithRequestInfo.push(fileName);
|
|
411
|
-
codegenFs.createFile({
|
|
412
|
-
path: groupDirectory,
|
|
413
|
-
fileName,
|
|
414
|
-
withPrefix: false,
|
|
415
|
-
content: requestInfoPerFileContent,
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
// #endregion
|
|
419
|
-
}
|
|
420
|
-
if (hasFilteredRoutes) {
|
|
421
|
-
nonEmptyGroups.add(groupName);
|
|
422
|
-
const exportGroupName = params.formatExportGroupName
|
|
423
|
-
? params.formatExportGroupName(_.camelCase(groupName), utils)
|
|
424
|
-
: _.camelCase(groupName);
|
|
425
|
-
codegenFs.createFile({
|
|
426
|
-
path: groupDirectory,
|
|
427
|
-
fileName: 'index.ts',
|
|
428
|
-
withPrefix: false,
|
|
429
|
-
content: `${LINTERS_IGNORE}
|
|
430
|
-
export * as ${exportGroupName} from './endpoints';
|
|
431
|
-
`,
|
|
432
|
-
});
|
|
433
|
-
if (params.outputType === 'one-endpoint-per-file') {
|
|
434
|
-
codegenFs.createFile({
|
|
435
|
-
path: path.resolve(groupDirectory, 'endpoints'),
|
|
436
|
-
fileName: 'index.ts',
|
|
437
|
-
withPrefix: false,
|
|
438
|
-
content: await indexTsForEndpointPerFileTmpl({
|
|
439
|
-
...baseTmplParams,
|
|
440
|
-
generatedRequestFileNames: fileNamesWithRequestInfo,
|
|
441
|
-
}),
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
collectedExportFilesFromIndexFile.push(_.kebabCase(groupName));
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
codegenFs.removeDir(path.resolve(params.output, _.kebabCase(groupName)));
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
// #endregion
|
|
451
|
-
}
|
|
452
|
-
const metaInfo = !params.noMetaInfo &&
|
|
453
|
-
(namespace ?? (nonEmptyGroups.size > 0 || tagsSet.size > 0))
|
|
454
|
-
? {
|
|
455
|
-
namespace,
|
|
456
|
-
groupNames: [...nonEmptyGroups.values()],
|
|
457
|
-
tags: [...tagsSet.values()],
|
|
458
|
-
}
|
|
459
|
-
: null;
|
|
460
|
-
const excludedDataContractNames = Array.from(reservedDataContractNamesMap.entries())
|
|
461
|
-
.filter(([_, count]) => count === 1)
|
|
462
|
-
.map(([name]) => name);
|
|
463
|
-
const dataContractsContent = await dataContractsFileTmpl({
|
|
464
|
-
...baseTmplParams,
|
|
465
|
-
excludedDataContractNames,
|
|
466
|
-
});
|
|
467
|
-
codegenFs.createFile({
|
|
468
|
-
path: paths.outputDir,
|
|
469
|
-
fileName: 'data-contracts.ts',
|
|
470
|
-
withPrefix: false,
|
|
471
|
-
content: dataContractsContent,
|
|
472
|
-
});
|
|
473
|
-
if (metaInfo) {
|
|
474
|
-
codegenFs.createFile({
|
|
475
|
-
path: paths.outputDir,
|
|
476
|
-
fileName: 'meta-info.ts',
|
|
477
|
-
withPrefix: false,
|
|
478
|
-
content: await metaInfoTmpl({
|
|
479
|
-
...baseTmplParams,
|
|
480
|
-
metaInfo,
|
|
481
|
-
}),
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
if (namespace) {
|
|
485
|
-
codegenFs.createFile({
|
|
486
|
-
path: paths.outputDir,
|
|
487
|
-
fileName: '__exports.ts',
|
|
488
|
-
withPrefix: false,
|
|
489
|
-
content: await allExportsTmpl({
|
|
490
|
-
...baseTmplParams,
|
|
491
|
-
collectedExportFiles: collectedExportFilesFromIndexFile,
|
|
492
|
-
metaInfo,
|
|
493
|
-
}),
|
|
494
|
-
});
|
|
495
|
-
codegenFs.createFile({
|
|
496
|
-
path: paths.outputDir,
|
|
497
|
-
fileName: 'index.ts',
|
|
498
|
-
withPrefix: false,
|
|
499
|
-
content: `${LINTERS_IGNORE}
|
|
500
|
-
export * as ${namespace} from './__exports';
|
|
501
|
-
`,
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
else {
|
|
505
|
-
codegenFs.createFile({
|
|
506
|
-
path: paths.outputDir,
|
|
507
|
-
fileName: 'index.ts',
|
|
508
|
-
withPrefix: false,
|
|
509
|
-
content: await allExportsTmpl({
|
|
510
|
-
...baseTmplParams,
|
|
511
|
-
collectedExportFiles: collectedExportFilesFromIndexFile,
|
|
512
|
-
metaInfo,
|
|
513
|
-
}),
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
if (params.removeUnusedTypes) {
|
|
517
|
-
removeUnusedTypes({
|
|
518
|
-
directory: params.output,
|
|
519
|
-
keepTypes: params.removeUnusedTypes === true
|
|
520
|
-
? undefined
|
|
521
|
-
: params.removeUnusedTypes.keepTypes,
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allEndpointPerFileTmpl = void 0;
|
|
4
|
-
const constants_js_1 = require("./constants.cjs");
|
|
5
|
-
const data_contract_tmpl_js_1 = require("./data-contract.tmpl.cjs");
|
|
6
|
-
const endpoint_jsdoc_tmpl_js_1 = require("./endpoint-jsdoc.tmpl.cjs");
|
|
7
|
-
const new_endpoint_tmpl_js_1 = require("./new-endpoint.tmpl.cjs");
|
|
8
|
-
const allEndpointPerFileTmpl = async (params) => {
|
|
9
|
-
const { routes, configuration, codegenParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, } = params;
|
|
10
|
-
const { _ } = utils;
|
|
11
|
-
const dataContractNamesInThisFile = [];
|
|
12
|
-
const newEndpointTemplates = routes.map((route) => {
|
|
13
|
-
const newEndpointTemplateData = (0, new_endpoint_tmpl_js_1.newEndpointTmpl)({
|
|
14
|
-
...params,
|
|
15
|
-
route,
|
|
16
|
-
});
|
|
17
|
-
const { reservedDataContractNames } = newEndpointTemplateData;
|
|
18
|
-
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
19
|
-
reservedDataContractNames.forEach((reservedDataContractName) => {
|
|
20
|
-
if (!dataContactNames.has(reservedDataContractName)) {
|
|
21
|
-
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return { ...newEndpointTemplateData, route };
|
|
25
|
-
});
|
|
26
|
-
const extraImportLines = [];
|
|
27
|
-
const endpointTemplates = await Promise.all(newEndpointTemplates.map(async ({ content: requestInfoInstanceContent, localModelTypes, route, }) => {
|
|
28
|
-
const requestInfoMeta = codegenParams.getEndpointMeta?.(route, utils);
|
|
29
|
-
if (requestInfoMeta?.typeNameImportPath && requestInfoMeta.typeName) {
|
|
30
|
-
extraImportLines.push(`import { ${requestInfoMeta.typeName} } from "${requestInfoMeta.typeNameImportPath}";`);
|
|
31
|
-
}
|
|
32
|
-
return `
|
|
33
|
-
${(await Promise.all(localModelTypes.map(async (modelType) => {
|
|
34
|
-
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
35
|
-
...params,
|
|
36
|
-
contract: modelType,
|
|
37
|
-
addExportKeyword: true,
|
|
38
|
-
});
|
|
39
|
-
return contractType;
|
|
40
|
-
})))
|
|
41
|
-
.filter(Boolean)
|
|
42
|
-
.join('\n\n')}
|
|
43
|
-
|
|
44
|
-
${(0, endpoint_jsdoc_tmpl_js_1.endpointJSDocTmpl)({
|
|
45
|
-
...params,
|
|
46
|
-
route,
|
|
47
|
-
})}
|
|
48
|
-
export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
|
|
49
|
-
`;
|
|
50
|
-
}));
|
|
51
|
-
if (metaInfo) {
|
|
52
|
-
extraImportLines.push(`import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "${groupName ? '../' : './'}meta-info";`);
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
reservedDataContractNames: dataContractNamesInThisFile,
|
|
56
|
-
content: await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
57
|
-
import {
|
|
58
|
-
RequestParams,
|
|
59
|
-
HttpResponse,
|
|
60
|
-
HttpMultistatusResponse,
|
|
61
|
-
} from "${codegenParams.libImports?.['mobx-tanstack-query-api'] ?? 'mobx-tanstack-query-api'}";
|
|
62
|
-
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
63
|
-
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
64
|
-
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
65
|
-
${extraImportLines.join('\n')}
|
|
66
|
-
|
|
67
|
-
${configuration.modelTypes.length > 0
|
|
68
|
-
? `
|
|
69
|
-
import { ${configuration.modelTypes
|
|
70
|
-
.map((it) => it.name)
|
|
71
|
-
.filter((it) => !dataContractNamesInThisFile.includes(it))} } from "${relativePathDataContracts}";
|
|
72
|
-
`
|
|
73
|
-
: ''}
|
|
74
|
-
|
|
75
|
-
${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
|
|
76
|
-
const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
|
|
77
|
-
if (!modelType) {
|
|
78
|
-
return '';
|
|
79
|
-
}
|
|
80
|
-
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
81
|
-
...params,
|
|
82
|
-
contract: modelType,
|
|
83
|
-
addExportKeyword: true,
|
|
84
|
-
});
|
|
85
|
-
return contractType;
|
|
86
|
-
})))
|
|
87
|
-
.filter(Boolean)
|
|
88
|
-
.join('\n\n')}
|
|
89
|
-
|
|
90
|
-
${endpointTemplates.filter(Boolean).join('\n\n')}
|
|
91
|
-
`),
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
exports.allEndpointPerFileTmpl = allEndpointPerFileTmpl;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ParsedRoute } from 'swagger-typescript-api';
|
|
2
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
3
|
-
import type { BaseTmplParams, MetaInfo } from "../types/index.cjs";
|
|
4
|
-
export interface AllEndpointPerFileTmplParams extends BaseTmplParams {
|
|
5
|
-
routes: ParsedRoute[];
|
|
6
|
-
groupName: Maybe<string>;
|
|
7
|
-
metaInfo: Maybe<MetaInfo>;
|
|
8
|
-
relativePathDataContracts: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const allEndpointPerFileTmpl: (params: AllEndpointPerFileTmplParams) => Promise<{
|
|
11
|
-
reservedDataContractNames: string[];
|
|
12
|
-
content: string;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=all-endpoints-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"all-endpoints-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-endpoints-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,2BAA0B;AAMlE,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B;;;EA8IrC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ParsedRoute } from 'swagger-typescript-api';
|
|
2
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
3
|
-
import type { BaseTmplParams, MetaInfo } from "../types/index.js";
|
|
4
|
-
export interface AllEndpointPerFileTmplParams extends BaseTmplParams {
|
|
5
|
-
routes: ParsedRoute[];
|
|
6
|
-
groupName: Maybe<string>;
|
|
7
|
-
metaInfo: Maybe<MetaInfo>;
|
|
8
|
-
relativePathDataContracts: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const allEndpointPerFileTmpl: (params: AllEndpointPerFileTmplParams) => Promise<{
|
|
11
|
-
reservedDataContractNames: string[];
|
|
12
|
-
content: string;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=all-endpoints-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"all-endpoints-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-endpoints-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,0BAA0B;AAMlE,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B;;;EA8IrC,CAAC"}
|