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
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.endpointPerFileTmpl = 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 endpointPerFileTmpl = async (params) => {
|
|
9
|
-
const { route, configuration, codegenParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, } = params;
|
|
10
|
-
const { _ } = utils;
|
|
11
|
-
const { content: requestInfoInstanceContent, reservedDataContractNames, localModelTypes, } = (0, new_endpoint_tmpl_js_1.newEndpointTmpl)({
|
|
12
|
-
...params,
|
|
13
|
-
route,
|
|
14
|
-
groupName,
|
|
15
|
-
metaInfo,
|
|
16
|
-
});
|
|
17
|
-
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
18
|
-
const dataContractNamesInThisFile = [];
|
|
19
|
-
reservedDataContractNames.forEach((reservedDataContractName) => {
|
|
20
|
-
if (!dataContactNames.has(reservedDataContractName)) {
|
|
21
|
-
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
const extraImportLines = [];
|
|
25
|
-
if (metaInfo) {
|
|
26
|
-
extraImportLines.push(`import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "../${groupName ? '../' : ''}meta-info";`);
|
|
27
|
-
}
|
|
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
|
-
reservedDataContractNames: dataContractNamesInThisFile,
|
|
34
|
-
content: await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
35
|
-
import {
|
|
36
|
-
RequestParams,
|
|
37
|
-
HttpResponse,
|
|
38
|
-
HttpMultistatusResponse,
|
|
39
|
-
} from "${codegenParams.libImports?.['mobx-tanstack-query-api'] ?? 'mobx-tanstack-query-api'}";
|
|
40
|
-
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
41
|
-
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
42
|
-
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
43
|
-
${extraImportLines.join('\n')}
|
|
44
|
-
|
|
45
|
-
${configuration.modelTypes.length > 0
|
|
46
|
-
? `
|
|
47
|
-
import { ${configuration.modelTypes
|
|
48
|
-
.map((it) => it.name)
|
|
49
|
-
.filter((it) => !dataContractNamesInThisFile.includes(it))} } from "${relativePathDataContracts}";
|
|
50
|
-
`
|
|
51
|
-
: ''}
|
|
52
|
-
|
|
53
|
-
${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
|
|
54
|
-
const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
|
|
55
|
-
if (!modelType) {
|
|
56
|
-
return '';
|
|
57
|
-
}
|
|
58
|
-
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
59
|
-
...params,
|
|
60
|
-
contract: modelType,
|
|
61
|
-
addExportKeyword: true,
|
|
62
|
-
});
|
|
63
|
-
return contractType;
|
|
64
|
-
})))
|
|
65
|
-
.filter(Boolean)
|
|
66
|
-
.join('\n\n')}
|
|
67
|
-
|
|
68
|
-
${(await Promise.all(localModelTypes.map(async (modelType) => {
|
|
69
|
-
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
70
|
-
...params,
|
|
71
|
-
contract: modelType,
|
|
72
|
-
addExportKeyword: true,
|
|
73
|
-
});
|
|
74
|
-
return contractType;
|
|
75
|
-
})))
|
|
76
|
-
.filter(Boolean)
|
|
77
|
-
.join('\n\n')}
|
|
78
|
-
|
|
79
|
-
${(0, endpoint_jsdoc_tmpl_js_1.endpointJSDocTmpl)({
|
|
80
|
-
...params,
|
|
81
|
-
route,
|
|
82
|
-
})}
|
|
83
|
-
export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
|
|
84
|
-
`),
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
exports.endpointPerFileTmpl = endpointPerFileTmpl;
|
|
@@ -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 EndpointPerFileTmplParams extends BaseTmplParams {
|
|
5
|
-
route: ParsedRoute;
|
|
6
|
-
relativePathDataContracts: string;
|
|
7
|
-
groupName: Maybe<string>;
|
|
8
|
-
metaInfo: Maybe<MetaInfo>;
|
|
9
|
-
}
|
|
10
|
-
export declare const endpointPerFileTmpl: (params: EndpointPerFileTmplParams) => Promise<{
|
|
11
|
-
reservedDataContractNames: string[];
|
|
12
|
-
content: string;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=endpoint-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-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,yBAA0B,SAAQ,cAAc;IAC/D,KAAK,EAAE,WAAW,CAAC;IACnB,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,GAC9B,QAAQ,yBAAyB;;;EAgIlC,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 EndpointPerFileTmplParams extends BaseTmplParams {
|
|
5
|
-
route: ParsedRoute;
|
|
6
|
-
relativePathDataContracts: string;
|
|
7
|
-
groupName: Maybe<string>;
|
|
8
|
-
metaInfo: Maybe<MetaInfo>;
|
|
9
|
-
}
|
|
10
|
-
export declare const endpointPerFileTmpl: (params: EndpointPerFileTmplParams) => Promise<{
|
|
11
|
-
reservedDataContractNames: string[];
|
|
12
|
-
content: string;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=endpoint-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-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,yBAA0B,SAAQ,cAAc;IAC/D,KAAK,EAAE,WAAW,CAAC;IACnB,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,GAC9B,QAAQ,yBAAyB;;;EAgIlC,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { LINTERS_IGNORE } from "./constants.js";
|
|
2
|
-
import { dataContractTmpl } from "./data-contract.tmpl.js";
|
|
3
|
-
import { endpointJSDocTmpl } from "./endpoint-jsdoc.tmpl.js";
|
|
4
|
-
import { newEndpointTmpl } from "./new-endpoint.tmpl.js";
|
|
5
|
-
export const endpointPerFileTmpl = async (params) => {
|
|
6
|
-
const { route, configuration, codegenParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, } = params;
|
|
7
|
-
const { _ } = utils;
|
|
8
|
-
const { content: requestInfoInstanceContent, reservedDataContractNames, localModelTypes, } = newEndpointTmpl({
|
|
9
|
-
...params,
|
|
10
|
-
route,
|
|
11
|
-
groupName,
|
|
12
|
-
metaInfo,
|
|
13
|
-
});
|
|
14
|
-
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
15
|
-
const dataContractNamesInThisFile = [];
|
|
16
|
-
reservedDataContractNames.forEach((reservedDataContractName) => {
|
|
17
|
-
if (!dataContactNames.has(reservedDataContractName)) {
|
|
18
|
-
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
const extraImportLines = [];
|
|
22
|
-
if (metaInfo) {
|
|
23
|
-
extraImportLines.push(`import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "../${groupName ? '../' : ''}meta-info";`);
|
|
24
|
-
}
|
|
25
|
-
const requestInfoMeta = codegenParams.getEndpointMeta?.(route, utils);
|
|
26
|
-
if (requestInfoMeta?.typeNameImportPath && requestInfoMeta.typeName) {
|
|
27
|
-
extraImportLines.push(`import { ${requestInfoMeta.typeName} } from "${requestInfoMeta.typeNameImportPath}";`);
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
reservedDataContractNames: dataContractNamesInThisFile,
|
|
31
|
-
content: await formatTSContent(`${LINTERS_IGNORE}
|
|
32
|
-
import {
|
|
33
|
-
RequestParams,
|
|
34
|
-
HttpResponse,
|
|
35
|
-
HttpMultistatusResponse,
|
|
36
|
-
} from "${codegenParams.libImports?.['mobx-tanstack-query-api'] ?? 'mobx-tanstack-query-api'}";
|
|
37
|
-
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
38
|
-
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
39
|
-
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
40
|
-
${extraImportLines.join('\n')}
|
|
41
|
-
|
|
42
|
-
${configuration.modelTypes.length > 0
|
|
43
|
-
? `
|
|
44
|
-
import { ${configuration.modelTypes
|
|
45
|
-
.map((it) => it.name)
|
|
46
|
-
.filter((it) => !dataContractNamesInThisFile.includes(it))} } from "${relativePathDataContracts}";
|
|
47
|
-
`
|
|
48
|
-
: ''}
|
|
49
|
-
|
|
50
|
-
${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
|
|
51
|
-
const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
|
|
52
|
-
if (!modelType) {
|
|
53
|
-
return '';
|
|
54
|
-
}
|
|
55
|
-
const contractType = await dataContractTmpl({
|
|
56
|
-
...params,
|
|
57
|
-
contract: modelType,
|
|
58
|
-
addExportKeyword: true,
|
|
59
|
-
});
|
|
60
|
-
return contractType;
|
|
61
|
-
})))
|
|
62
|
-
.filter(Boolean)
|
|
63
|
-
.join('\n\n')}
|
|
64
|
-
|
|
65
|
-
${(await Promise.all(localModelTypes.map(async (modelType) => {
|
|
66
|
-
const contractType = await dataContractTmpl({
|
|
67
|
-
...params,
|
|
68
|
-
contract: modelType,
|
|
69
|
-
addExportKeyword: true,
|
|
70
|
-
});
|
|
71
|
-
return contractType;
|
|
72
|
-
})))
|
|
73
|
-
.filter(Boolean)
|
|
74
|
-
.join('\n\n')}
|
|
75
|
-
|
|
76
|
-
${endpointJSDocTmpl({
|
|
77
|
-
...params,
|
|
78
|
-
route,
|
|
79
|
-
})}
|
|
80
|
-
export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
|
|
81
|
-
`),
|
|
82
|
-
};
|
|
83
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indexTsForEndpointPerFileTmpl = void 0;
|
|
4
|
-
const constants_js_1 = require("./constants.cjs");
|
|
5
|
-
const indexTsForEndpointPerFileTmpl = async ({ generatedRequestFileNames, }) => {
|
|
6
|
-
return `${constants_js_1.LINTERS_IGNORE}
|
|
7
|
-
${generatedRequestFileNames.map((fileName) => `export * from './${fileName.replace('.ts', '')}';`).join('\n')}
|
|
8
|
-
`;
|
|
9
|
-
};
|
|
10
|
-
exports.indexTsForEndpointPerFileTmpl = indexTsForEndpointPerFileTmpl;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BaseTmplParams } from "../types/index.cjs";
|
|
2
|
-
export interface IndexTsForEndpointPerFileTmplParams extends BaseTmplParams {
|
|
3
|
-
generatedRequestFileNames: string[];
|
|
4
|
-
}
|
|
5
|
-
export declare const indexTsForEndpointPerFileTmpl: ({ generatedRequestFileNames, }: IndexTsForEndpointPerFileTmplParams) => Promise<string>;
|
|
6
|
-
//# sourceMappingURL=index-ts-for-endpoint-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-ts-for-endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/index-ts-for-endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,2BAA0B;AAGxD,MAAM,WAAW,mCAAoC,SAAQ,cAAc;IACzE,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,6BAA6B,GAAU,gCAEjD,mCAAmC,oBAIrC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BaseTmplParams } from "../types/index.js";
|
|
2
|
-
export interface IndexTsForEndpointPerFileTmplParams extends BaseTmplParams {
|
|
3
|
-
generatedRequestFileNames: string[];
|
|
4
|
-
}
|
|
5
|
-
export declare const indexTsForEndpointPerFileTmpl: ({ generatedRequestFileNames, }: IndexTsForEndpointPerFileTmplParams) => Promise<string>;
|
|
6
|
-
//# sourceMappingURL=index-ts-for-endpoint-per-file.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-ts-for-endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/index-ts-for-endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,0BAA0B;AAGxD,MAAM,WAAW,mCAAoC,SAAQ,cAAc;IACzE,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,6BAA6B,GAAU,gCAEjD,mCAAmC,oBAIrC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LINTERS_IGNORE } from "./constants.js";
|
|
2
|
-
export const indexTsForEndpointPerFileTmpl = async ({ generatedRequestFileNames, }) => {
|
|
3
|
-
return `${LINTERS_IGNORE}
|
|
4
|
-
${generatedRequestFileNames.map((fileName) => `export * from './${fileName.replace('.ts', '')}';`).join('\n')}
|
|
5
|
-
`;
|
|
6
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.metaInfoTmpl = exports.formatTagNameEnumKey = exports.formatGroupNameEnumKey = void 0;
|
|
4
|
-
const constants_js_1 = require("./constants.cjs");
|
|
5
|
-
const formatGroupNameEnumKey = (groupName, { _ }) => _.upperFirst(_.camelCase(groupName));
|
|
6
|
-
exports.formatGroupNameEnumKey = formatGroupNameEnumKey;
|
|
7
|
-
const formatTagNameEnumKey = (tagName, utils) => (0, exports.formatGroupNameEnumKey)(tagName, utils);
|
|
8
|
-
exports.formatTagNameEnumKey = formatTagNameEnumKey;
|
|
9
|
-
const metaInfoTmpl = async ({ metaInfo, utils, formatTSContent, codegenParams, ...other }) => {
|
|
10
|
-
const tagsMap = new Map(other.configuration?.apiConfig?.tags?.map((it) => [
|
|
11
|
-
it.name,
|
|
12
|
-
it,
|
|
13
|
-
]));
|
|
14
|
-
return await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
15
|
-
${[
|
|
16
|
-
metaInfo?.namespace && `export const namespace = "${metaInfo?.namespace}";`,
|
|
17
|
-
metaInfo?.groupNames?.length &&
|
|
18
|
-
`
|
|
19
|
-
export const enum Group {
|
|
20
|
-
${metaInfo?.groupNames.map((groupName) => `${(0, exports.formatGroupNameEnumKey)(groupName, utils)} = "${codegenParams.transforms?.groupEnumValue?.(groupName) ?? groupName}"`).join(',\n')}
|
|
21
|
-
}
|
|
22
|
-
`,
|
|
23
|
-
metaInfo?.tags?.length &&
|
|
24
|
-
`
|
|
25
|
-
export const enum Tag {
|
|
26
|
-
${metaInfo?.tags
|
|
27
|
-
.map((tagName) => {
|
|
28
|
-
const tagData = tagsMap.get(tagName);
|
|
29
|
-
let description = tagData?.description;
|
|
30
|
-
if (!description) {
|
|
31
|
-
description = utils._.words(tagName).join(' ');
|
|
32
|
-
}
|
|
33
|
-
return [
|
|
34
|
-
description && `/** ${description} */`,
|
|
35
|
-
`${(0, exports.formatTagNameEnumKey)(tagName, utils)} = "${codegenParams.transforms?.tagEnumValue?.(tagName) ?? tagName}"`,
|
|
36
|
-
]
|
|
37
|
-
.filter(Boolean)
|
|
38
|
-
.join('\n');
|
|
39
|
-
})
|
|
40
|
-
.join(',\n')}
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
]
|
|
44
|
-
.filter(Boolean)
|
|
45
|
-
.join('\n')}
|
|
46
|
-
`);
|
|
47
|
-
};
|
|
48
|
-
exports.metaInfoTmpl = metaInfoTmpl;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { BaseTmplParams, CodegenDataUtils, MetaInfo } from "../types/index.cjs";
|
|
3
|
-
export interface MetaInfoTmplParams extends BaseTmplParams {
|
|
4
|
-
metaInfo: Maybe<MetaInfo>;
|
|
5
|
-
}
|
|
6
|
-
export declare const formatGroupNameEnumKey: (groupName: string, { _ }: CodegenDataUtils) => Capitalize<string>;
|
|
7
|
-
export declare const formatTagNameEnumKey: (tagName: string, utils: CodegenDataUtils) => Capitalize<string>;
|
|
8
|
-
export declare const metaInfoTmpl: ({ metaInfo, utils, formatTSContent, codegenParams, ...other }: MetaInfoTmplParams) => Promise<string>;
|
|
9
|
-
//# sourceMappingURL=meta-info.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta-info.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/meta-info.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACT,2BAA0B;AAI3B,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;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,+DAMhC,kBAAkB,oBA4CpB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { BaseTmplParams, CodegenDataUtils, MetaInfo } from "../types/index.js";
|
|
3
|
-
export interface MetaInfoTmplParams extends BaseTmplParams {
|
|
4
|
-
metaInfo: Maybe<MetaInfo>;
|
|
5
|
-
}
|
|
6
|
-
export declare const formatGroupNameEnumKey: (groupName: string, { _ }: CodegenDataUtils) => Capitalize<string>;
|
|
7
|
-
export declare const formatTagNameEnumKey: (tagName: string, utils: CodegenDataUtils) => Capitalize<string>;
|
|
8
|
-
export declare const metaInfoTmpl: ({ metaInfo, utils, formatTSContent, codegenParams, ...other }: MetaInfoTmplParams) => Promise<string>;
|
|
9
|
-
//# sourceMappingURL=meta-info.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta-info.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/meta-info.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACT,0BAA0B;AAI3B,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;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,+DAMhC,kBAAkB,oBA4CpB,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
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, codegenParams, ...other }) => {
|
|
5
|
-
const tagsMap = new Map(other.configuration?.apiConfig?.tags?.map((it) => [
|
|
6
|
-
it.name,
|
|
7
|
-
it,
|
|
8
|
-
]));
|
|
9
|
-
return await formatTSContent(`${LINTERS_IGNORE}
|
|
10
|
-
${[
|
|
11
|
-
metaInfo?.namespace && `export const namespace = "${metaInfo?.namespace}";`,
|
|
12
|
-
metaInfo?.groupNames?.length &&
|
|
13
|
-
`
|
|
14
|
-
export const enum Group {
|
|
15
|
-
${metaInfo?.groupNames.map((groupName) => `${formatGroupNameEnumKey(groupName, utils)} = "${codegenParams.transforms?.groupEnumValue?.(groupName) ?? groupName}"`).join(',\n')}
|
|
16
|
-
}
|
|
17
|
-
`,
|
|
18
|
-
metaInfo?.tags?.length &&
|
|
19
|
-
`
|
|
20
|
-
export const enum Tag {
|
|
21
|
-
${metaInfo?.tags
|
|
22
|
-
.map((tagName) => {
|
|
23
|
-
const tagData = tagsMap.get(tagName);
|
|
24
|
-
let description = tagData?.description;
|
|
25
|
-
if (!description) {
|
|
26
|
-
description = utils._.words(tagName).join(' ');
|
|
27
|
-
}
|
|
28
|
-
return [
|
|
29
|
-
description && `/** ${description} */`,
|
|
30
|
-
`${formatTagNameEnumKey(tagName, utils)} = "${codegenParams.transforms?.tagEnumValue?.(tagName) ?? tagName}"`,
|
|
31
|
-
]
|
|
32
|
-
.filter(Boolean)
|
|
33
|
-
.join('\n');
|
|
34
|
-
})
|
|
35
|
-
.join(',\n')}
|
|
36
|
-
}
|
|
37
|
-
`,
|
|
38
|
-
]
|
|
39
|
-
.filter(Boolean)
|
|
40
|
-
.join('\n')}
|
|
41
|
-
`);
|
|
42
|
-
};
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newEndpointTmpl = void 0;
|
|
4
|
-
const create_short_model_type_js_1 = require("../utils/create-short-model-type.cjs");
|
|
5
|
-
const meta_info_tmpl_js_1 = require("./meta-info.tmpl.cjs");
|
|
6
|
-
// RequestParams["type"]
|
|
7
|
-
const requestContentKind = {
|
|
8
|
-
URL_ENCODED: '"application/x-www-form-urlencoded"',
|
|
9
|
-
FORM_DATA: '"multipart/form-data"',
|
|
10
|
-
TEXT: '"text/plain"',
|
|
11
|
-
BINARY: '"application/octet-stream"',
|
|
12
|
-
};
|
|
13
|
-
// RequestParams["format"]
|
|
14
|
-
const responseContentKind = {
|
|
15
|
-
TEXT: '"text"',
|
|
16
|
-
IMAGE: '"blob"',
|
|
17
|
-
FORM_DATA: '"formData"',
|
|
18
|
-
BYTES: '"bytes"',
|
|
19
|
-
};
|
|
20
|
-
const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, filterTypes, configuration, }) => {
|
|
21
|
-
const { _ } = utils;
|
|
22
|
-
const positiveResponseTypes = route.raw.responsesTypes?.filter((it) => +it.status >= 200 &&
|
|
23
|
-
+it.status < 300 &&
|
|
24
|
-
(!it.typeData || filterTypes(it.typeData)));
|
|
25
|
-
const { requestBodyInfo, responseBodyInfo } = route;
|
|
26
|
-
const routeRequest = route.request;
|
|
27
|
-
const routeResponse = route.response;
|
|
28
|
-
const { parameters, path, method, payload, query, requestParams, security } = routeRequest;
|
|
29
|
-
const { raw } = route;
|
|
30
|
-
const queryName = query?.name || 'query';
|
|
31
|
-
const pathParams = _.values(parameters);
|
|
32
|
-
const pathParamsNames = _.map(pathParams, 'name');
|
|
33
|
-
const requestConfigParam = {
|
|
34
|
-
name: 'requestParams',
|
|
35
|
-
optional: true,
|
|
36
|
-
type: 'RequestParams',
|
|
37
|
-
defaultValue: '{}',
|
|
38
|
-
};
|
|
39
|
-
const inputParams = [
|
|
40
|
-
...pathParams,
|
|
41
|
-
payload,
|
|
42
|
-
query,
|
|
43
|
-
requestConfigParam,
|
|
44
|
-
].filter(Boolean);
|
|
45
|
-
const getArgs = ({ withPayload, withRequestConfigParam, }) => {
|
|
46
|
-
return _.sortBy(_.compact([
|
|
47
|
-
...(requestParams
|
|
48
|
-
? [
|
|
49
|
-
{
|
|
50
|
-
name: pathParams.length > 0
|
|
51
|
-
? `{ ${_.join(pathParamsNames, ', ')}, ...${queryName} }`
|
|
52
|
-
: queryName,
|
|
53
|
-
optional: false,
|
|
54
|
-
type: utils.getInlineParseContent(requestParams),
|
|
55
|
-
},
|
|
56
|
-
]
|
|
57
|
-
: pathParams),
|
|
58
|
-
withPayload && payload,
|
|
59
|
-
withRequestConfigParam && requestConfigParam,
|
|
60
|
-
]), [(o) => o.optional]);
|
|
61
|
-
};
|
|
62
|
-
const tags = (raw.tags || []).filter(Boolean);
|
|
63
|
-
const requestOutputDataTypes = positiveResponseTypes.map((it) => it.type);
|
|
64
|
-
const foundErrorModelType = (routeResponse.errorType &&
|
|
65
|
-
configuration.modelTypes.find((it) => it.name === routeResponse.errorType)) ||
|
|
66
|
-
null;
|
|
67
|
-
const requestOutputErrorType = foundErrorModelType
|
|
68
|
-
? routeResponse.errorType
|
|
69
|
-
: 'any';
|
|
70
|
-
const pathParamsToInline = path.split('/').slice(1);
|
|
71
|
-
let lastDynamicStructPos = 0;
|
|
72
|
-
const queryParamStruct = query == null
|
|
73
|
-
? null
|
|
74
|
-
: {
|
|
75
|
-
type: 'dynamic',
|
|
76
|
-
key: 'params',
|
|
77
|
-
i: pathParamsToInline.length,
|
|
78
|
-
param: lastDynamicStructPos > 0 ? lastDynamicStructPos - 1 : 0,
|
|
79
|
-
};
|
|
80
|
-
if (queryParamStruct && !lastDynamicStructPos) {
|
|
81
|
-
lastDynamicStructPos++;
|
|
82
|
-
}
|
|
83
|
-
const requestInfoMeta = codegenParams.getEndpointMeta?.(route, utils);
|
|
84
|
-
const requestMeta = codegenParams.getRequestMeta?.(route, utils);
|
|
85
|
-
const resultPath = (codegenParams.requestPathPrefix ?? '') +
|
|
86
|
-
path +
|
|
87
|
-
(codegenParams.requestPathSuffix ?? '');
|
|
88
|
-
const bodyContentType = requestContentKind[requestBodyInfo.contentKind] || null;
|
|
89
|
-
const responseFormat = responseContentKind[responseBodyInfo.success?.schema?.contentKind] || null;
|
|
90
|
-
const reservedDataContractNames = _.uniq([
|
|
91
|
-
...requestOutputDataTypes,
|
|
92
|
-
requestOutputErrorType || 'any',
|
|
93
|
-
...getArgs({
|
|
94
|
-
withPayload: true,
|
|
95
|
-
}).map((it) => it.type),
|
|
96
|
-
]);
|
|
97
|
-
const pathDeclaration = resultPath.replaceAll('$', '');
|
|
98
|
-
const getHttpRequestGenerics = () => {
|
|
99
|
-
const defaultOkResponse = positiveResponseTypes?.[0]?.type || 'unknown';
|
|
100
|
-
const defaultBadResponse = requestOutputErrorType;
|
|
101
|
-
const responses = raw.responsesTypes?.filter((it) => it.status !== 'default' &&
|
|
102
|
-
(!it.typeData ||
|
|
103
|
-
filterTypes(it.typeData))) || [];
|
|
104
|
-
if (!responses?.length) {
|
|
105
|
-
return `HttpResponse<unknown, ${requestOutputErrorType}>`;
|
|
106
|
-
}
|
|
107
|
-
if (responses.length === 1 && responses[0].isSuccess) {
|
|
108
|
-
return `HttpResponse<${responses[0].type}, ${requestOutputErrorType}>`;
|
|
109
|
-
}
|
|
110
|
-
return `HttpMultistatusResponse<{
|
|
111
|
-
${responses
|
|
112
|
-
.map((it) => {
|
|
113
|
-
return [
|
|
114
|
-
it.description && `/** ${it.description} */`,
|
|
115
|
-
`${it.status}: ${it.type};`,
|
|
116
|
-
]
|
|
117
|
-
.filter(Boolean)
|
|
118
|
-
.join('\n');
|
|
119
|
-
})
|
|
120
|
-
.join('\n')}
|
|
121
|
-
},
|
|
122
|
-
${defaultOkResponse},
|
|
123
|
-
${defaultBadResponse}
|
|
124
|
-
>`;
|
|
125
|
-
};
|
|
126
|
-
const requestInputTypeDc = (0, create_short_model_type_js_1.createShortModelType)({
|
|
127
|
-
typeIdentifier: 'type',
|
|
128
|
-
name: _.upperFirst(_.camelCase(`${route.routeName.usage}Params`)),
|
|
129
|
-
content: `{
|
|
130
|
-
${inputParams
|
|
131
|
-
.map(({ name, optional, type }) => {
|
|
132
|
-
return `${name}${optional ? '?' : ''}:${type}`;
|
|
133
|
-
})
|
|
134
|
-
.filter(Boolean)
|
|
135
|
-
.join(', ')}
|
|
136
|
-
}`,
|
|
137
|
-
});
|
|
138
|
-
const isAllowedInputType = filterTypes(requestInputTypeDc);
|
|
139
|
-
return {
|
|
140
|
-
reservedDataContractNames,
|
|
141
|
-
localModelTypes: isAllowedInputType ? [requestInputTypeDc] : [],
|
|
142
|
-
content: `
|
|
143
|
-
new ${importFileParams.endpoint.exportName}<
|
|
144
|
-
${getHttpRequestGenerics()},
|
|
145
|
-
${isAllowedInputType ? requestInputTypeDc.name : 'any'},
|
|
146
|
-
${requestInfoMeta?.typeName ?? 'any'}
|
|
147
|
-
>(
|
|
148
|
-
{
|
|
149
|
-
params: ({
|
|
150
|
-
${inputParams.map((it) => it.name)}
|
|
151
|
-
}) => ({
|
|
152
|
-
path: \`${resultPath}\`,
|
|
153
|
-
method: '${_.upperCase(method)}',
|
|
154
|
-
${requestMeta?.tmplData ? `meta: ${requestMeta.tmplData},` : ''}
|
|
155
|
-
${query == null ? '' : `query: ${query.name},`}
|
|
156
|
-
${payload?.name ? `body: ${payload.name},` : ''}
|
|
157
|
-
${security ? 'secure: true,' : ''}
|
|
158
|
-
${bodyContentType ? `contentType: ${bodyContentType},` : ''}
|
|
159
|
-
${responseFormat ? `format: ${responseFormat},` : ''}
|
|
160
|
-
...${requestConfigParam.name},
|
|
161
|
-
}),
|
|
162
|
-
requiredParams: [${inputParams.filter((it) => !it.optional).map((it) => `"${it.name}"`)}],
|
|
163
|
-
operationId: "${raw.operationId || _.camelCase(route.routeName.usage)}",
|
|
164
|
-
path: [${pathDeclaration
|
|
165
|
-
.split('/')
|
|
166
|
-
.filter(Boolean)
|
|
167
|
-
.map((it) => `"${it}"`)}],
|
|
168
|
-
tags: [${tags.map((tag) => {
|
|
169
|
-
if (metaInfo) {
|
|
170
|
-
return `Tag.${(0, meta_info_tmpl_js_1.formatTagNameEnumKey)(tag, utils)}`;
|
|
171
|
-
}
|
|
172
|
-
return `"${tag}"`;
|
|
173
|
-
})}],
|
|
174
|
-
${groupName ? `group: ${metaInfo ? `Group.${(0, meta_info_tmpl_js_1.formatGroupNameEnumKey)(groupName, utils)}` : `"${groupName}"`},` : ''}
|
|
175
|
-
${metaInfo?.namespace ? `namespace,` : ''}
|
|
176
|
-
meta: ${requestInfoMeta?.tmplData ?? '{} as any'},
|
|
177
|
-
},
|
|
178
|
-
${importFileParams.queryClient.exportName},
|
|
179
|
-
${importFileParams.httpClient.exportName},
|
|
180
|
-
)
|
|
181
|
-
`
|
|
182
|
-
.split('\n')
|
|
183
|
-
.map((it) => it.trim())
|
|
184
|
-
.filter(Boolean)
|
|
185
|
-
.join('\n'),
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
exports.newEndpointTmpl = newEndpointTmpl;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ParsedRoute } from 'swagger-typescript-api';
|
|
2
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
3
|
-
import type { BaseTmplParams } from "../types/base-tmpl-params.cjs";
|
|
4
|
-
import type { MetaInfo } from "../types/index.cjs";
|
|
5
|
-
export interface NewEndpointTmplParams extends BaseTmplParams {
|
|
6
|
-
route: ParsedRoute;
|
|
7
|
-
groupName: Maybe<string>;
|
|
8
|
-
metaInfo: Maybe<MetaInfo>;
|
|
9
|
-
}
|
|
10
|
-
export declare const newEndpointTmpl: ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, filterTypes, configuration, }: NewEndpointTmplParams) => {
|
|
11
|
-
reservedDataContractNames: string[];
|
|
12
|
-
localModelTypes: (Omit<import("swagger-typescript-api").ModelType, "rawContent"> & Partial<Pick<import("swagger-typescript-api").ModelType, "rawContent">> & import("swagger-typescript-api").ModelType)[];
|
|
13
|
-
content: string;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=new-endpoint.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.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,sCAAqC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,2BAA0B;AAOlD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,qGAS7B,qBAAqB;;;;CA8NvB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ParsedRoute } from 'swagger-typescript-api';
|
|
2
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
3
|
-
import type { BaseTmplParams } from "../types/base-tmpl-params.js";
|
|
4
|
-
import type { MetaInfo } from "../types/index.js";
|
|
5
|
-
export interface NewEndpointTmplParams extends BaseTmplParams {
|
|
6
|
-
route: ParsedRoute;
|
|
7
|
-
groupName: Maybe<string>;
|
|
8
|
-
metaInfo: Maybe<MetaInfo>;
|
|
9
|
-
}
|
|
10
|
-
export declare const newEndpointTmpl: ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, filterTypes, configuration, }: NewEndpointTmplParams) => {
|
|
11
|
-
reservedDataContractNames: string[];
|
|
12
|
-
localModelTypes: (Omit<import("swagger-typescript-api").ModelType, "rawContent"> & Partial<Pick<import("swagger-typescript-api").ModelType, "rawContent">> & import("swagger-typescript-api").ModelType)[];
|
|
13
|
-
content: string;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=new-endpoint.tmpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.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,qCAAqC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,0BAA0B;AAOlD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,qGAS7B,qBAAqB;;;;CA8NvB,CAAC"}
|