mobx-tanstack-query-api 0.16.0 → 0.17.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/dist/builtin/index.cjs +26 -0
- package/dist/builtin/index.d.cts +5 -0
- package/dist/builtin/index.d.cts.map +1 -0
- package/dist/builtin/index.d.ts +5 -0
- package/dist/builtin/index.d.ts.map +1 -0
- package/{builtin → dist/builtin}/index.js +2 -2
- package/dist/cli/bin.cjs +17 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/{cli → dist/cli}/bin.js +4 -4
- package/dist/cli/index.cjs +18 -0
- package/dist/cli/index.d.cts +3 -0
- package/dist/cli/index.d.cts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/utils/define-config.cjs +9 -0
- package/dist/cli/utils/define-config.d.cts +4 -0
- package/dist/cli/utils/define-config.d.cts.map +1 -0
- package/{cli → dist/cli}/utils/define-config.d.ts +1 -1
- package/{cli → dist/cli}/utils/define-config.d.ts.map +1 -1
- package/dist/cli/utils/exec-config-path.cjs +16 -0
- package/dist/cli/utils/exec-config-path.d.ts +2 -0
- package/dist/cli/utils/exec-config-path.d.ts.map +1 -0
- package/dist/cli/utils/resolve-config-path.cjs +65 -0
- package/dist/cli/utils/resolve-config-path.d.ts +3 -0
- package/dist/cli/utils/resolve-config-path.d.ts.map +1 -0
- package/dist/codegen/index.cjs +488 -0
- package/dist/codegen/index.d.cts +167 -0
- package/dist/codegen/index.d.cts.map +1 -0
- package/{codegen → dist/codegen}/index.d.ts +1 -1
- package/dist/codegen/index.d.ts.map +1 -0
- package/{codegen → dist/codegen}/index.js +9 -9
- package/dist/codegen/templates/all-endpoints-per-file.tmpl.cjs +99 -0
- package/dist/codegen/templates/all-endpoints-per-file.tmpl.d.cts +18 -0
- package/dist/codegen/templates/all-endpoints-per-file.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/all-endpoints-per-file.tmpl.d.ts +1 -1
- package/dist/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +1 -0
- package/{codegen → dist/codegen}/templates/all-endpoints-per-file.tmpl.js +4 -4
- package/dist/codegen/templates/all-exports.tmpl.cjs +14 -0
- package/dist/codegen/templates/all-exports.tmpl.d.cts +11 -0
- package/dist/codegen/templates/all-exports.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/all-exports.tmpl.d.ts +1 -1
- package/dist/codegen/templates/all-exports.tmpl.d.ts.map +1 -0
- package/{codegen → dist/codegen}/templates/all-exports.tmpl.js +1 -1
- package/dist/codegen/templates/constants.cjs +5 -0
- package/dist/codegen/templates/constants.d.ts +2 -0
- package/dist/codegen/templates/constants.d.ts.map +1 -0
- package/dist/codegen/templates/data-contract.tmpl.cjs +49 -0
- package/dist/codegen/templates/data-contract.tmpl.d.ts +8 -0
- package/dist/codegen/templates/data-contract.tmpl.d.ts.map +1 -0
- package/dist/codegen/templates/data-contracts-file.tmpl.cjs +27 -0
- package/dist/codegen/templates/data-contracts-file.tmpl.d.cts +10 -0
- package/dist/codegen/templates/data-contracts-file.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/data-contracts-file.tmpl.d.ts +1 -1
- package/dist/codegen/templates/data-contracts-file.tmpl.d.ts.map +1 -0
- package/{codegen → dist/codegen}/templates/data-contracts-file.tmpl.js +2 -2
- package/dist/codegen/templates/endpoint-jsdoc.tmpl.cjs +110 -0
- package/dist/codegen/templates/endpoint-jsdoc.tmpl.d.cts +10 -0
- package/dist/codegen/templates/endpoint-jsdoc.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/endpoint-jsdoc.tmpl.d.ts +1 -1
- package/dist/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +1 -0
- package/dist/codegen/templates/endpoint-per-file.tmpl.cjs +90 -0
- package/dist/codegen/templates/endpoint-per-file.tmpl.d.cts +18 -0
- package/dist/codegen/templates/endpoint-per-file.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/endpoint-per-file.tmpl.d.ts +1 -1
- package/dist/codegen/templates/endpoint-per-file.tmpl.d.ts.map +1 -0
- package/{codegen → dist/codegen}/templates/endpoint-per-file.tmpl.js +4 -4
- package/dist/codegen/templates/index-ts-for-endpoint-per-file.tmpl.cjs +10 -0
- package/dist/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts +10 -0
- package/dist/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +1 -1
- package/{codegen → dist/codegen}/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +1 -1
- package/{codegen → dist/codegen}/templates/index-ts-for-endpoint-per-file.tmpl.js +1 -1
- package/dist/codegen/templates/meta-info.tmpl.cjs +48 -0
- package/dist/codegen/templates/meta-info.tmpl.d.cts +12 -0
- package/dist/codegen/templates/meta-info.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/meta-info.tmpl.d.ts +1 -1
- package/dist/codegen/templates/meta-info.tmpl.d.ts.map +1 -0
- package/{codegen → dist/codegen}/templates/meta-info.tmpl.js +1 -1
- package/dist/codegen/templates/new-endpoint.tmpl.cjs +178 -0
- package/dist/codegen/templates/new-endpoint.tmpl.d.cts +21 -0
- package/dist/codegen/templates/new-endpoint.tmpl.d.cts.map +1 -0
- package/{codegen → dist/codegen}/templates/new-endpoint.tmpl.d.ts +1 -1
- package/dist/codegen/templates/new-endpoint.tmpl.d.ts.map +1 -0
- package/{codegen → dist/codegen}/templates/new-endpoint.tmpl.js +1 -1
- package/dist/codegen/utils/remove-unused-types.cjs +117 -0
- package/dist/codegen/utils/remove-unused-types.d.cts +7 -0
- package/dist/codegen/utils/remove-unused-types.d.cts.map +1 -0
- package/{codegen → dist/codegen}/utils/remove-unused-types.d.ts +1 -1
- package/dist/codegen/utils/remove-unused-types.d.ts.map +1 -0
- package/{codegen → dist/codegen}/utils/remove-unused-types.js +1 -1
- package/dist/codegen/utils/unpack-filter-option.cjs +20 -0
- package/dist/codegen/utils/unpack-filter-option.d.cts +4 -0
- package/dist/codegen/utils/unpack-filter-option.d.cts.map +1 -0
- package/{codegen → dist/codegen}/utils/unpack-filter-option.d.ts +1 -1
- package/dist/codegen/utils/unpack-filter-option.d.ts.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/{index.d.ts.map → dist/index.d.ts.map} +1 -1
- package/{index.js → dist/index.js} +1 -1
- package/dist/runtime/endpoint-infinite-query.cjs +101 -0
- package/dist/runtime/endpoint-infinite-query.d.cts +17 -0
- package/dist/runtime/endpoint-infinite-query.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-infinite-query.d.ts +3 -3
- package/dist/runtime/endpoint-infinite-query.d.ts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-infinite-query.js +1 -1
- package/dist/runtime/endpoint-infinite-query.types.cjs +2 -0
- package/dist/runtime/endpoint-infinite-query.types.d.cts +30 -0
- package/dist/runtime/endpoint-infinite-query.types.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-infinite-query.types.d.ts +2 -2
- package/dist/runtime/endpoint-infinite-query.types.d.ts.map +1 -0
- package/dist/runtime/endpoint-mutation.cjs +73 -0
- package/dist/runtime/endpoint-mutation.d.cts +13 -0
- package/dist/runtime/endpoint-mutation.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-mutation.d.ts +3 -3
- package/dist/runtime/endpoint-mutation.d.ts.map +1 -0
- package/dist/runtime/endpoint-mutation.types.cjs +2 -0
- package/dist/runtime/endpoint-mutation.types.d.cts +30 -0
- package/dist/runtime/endpoint-mutation.types.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-mutation.types.d.ts +2 -2
- package/dist/runtime/endpoint-mutation.types.d.ts.map +1 -0
- package/dist/runtime/endpoint-query-client.cjs +79 -0
- package/dist/runtime/endpoint-query-client.d.cts +13 -0
- package/dist/runtime/endpoint-query-client.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-query-client.d.ts +1 -1
- package/dist/runtime/endpoint-query-client.d.ts.map +1 -0
- package/dist/runtime/endpoint-query-client.types.cjs +2 -0
- package/dist/runtime/endpoint-query-client.types.d.cts +16 -0
- package/dist/runtime/endpoint-query-client.types.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-query-client.types.d.ts +2 -2
- package/dist/runtime/endpoint-query-client.types.d.ts.map +1 -0
- package/dist/runtime/endpoint-query.cjs +213 -0
- package/dist/runtime/endpoint-query.d.cts +29 -0
- package/dist/runtime/endpoint-query.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-query.d.ts +3 -3
- package/dist/runtime/endpoint-query.d.ts.map +1 -0
- package/dist/runtime/endpoint-query.types.cjs +2 -0
- package/dist/runtime/endpoint-query.types.d.cts +37 -0
- package/dist/runtime/endpoint-query.types.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint-query.types.d.ts +1 -1
- package/dist/runtime/endpoint-query.types.d.ts.map +1 -0
- package/dist/runtime/endpoint.cjs +128 -0
- package/dist/runtime/endpoint.d.cts +69 -0
- package/dist/runtime/endpoint.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint.d.ts +9 -9
- package/dist/runtime/endpoint.d.ts.map +1 -0
- package/{runtime → dist/runtime}/endpoint.js +3 -3
- package/dist/runtime/endpoint.types.cjs +2 -0
- package/dist/runtime/endpoint.types.d.cts +23 -0
- package/dist/runtime/endpoint.types.d.cts.map +1 -0
- package/{runtime → dist/runtime}/endpoint.types.d.ts +3 -3
- package/dist/runtime/endpoint.types.d.ts.map +1 -0
- package/dist/runtime/http-client.cjs +208 -0
- package/dist/runtime/http-client.d.ts +85 -0
- package/dist/runtime/http-client.d.ts.map +1 -0
- package/dist/runtime/index.cjs +25 -0
- package/dist/runtime/index.d.cts +10 -0
- package/dist/runtime/index.d.cts.map +1 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +9 -0
- package/package.json +40 -149
- package/assets/gh-repo-template.pxz +0 -0
- package/assets/logo.png +0 -0
- package/assets/logo.pxz +0 -0
- package/builtin/index.d.ts +0 -5
- package/builtin/index.d.ts.map +0 -1
- package/cli/bin.mjs +0 -15
- package/cli/index.d.ts +0 -2
- package/cli/index.d.ts.map +0 -1
- package/cli/index.js +0 -1
- package/codegen/index.d.ts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-exports.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/meta-info.tmpl.d.ts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +0 -1
- package/codegen/utils/remove-unused-types.d.ts.map +0 -1
- package/codegen/utils/unpack-filter-option.d.ts.map +0 -1
- package/index.d.ts +0 -3
- package/runtime/endpoint-infinite-query.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.types.d.ts.map +0 -1
- package/runtime/endpoint-mutation.d.ts.map +0 -1
- package/runtime/endpoint-mutation.types.d.ts.map +0 -1
- package/runtime/endpoint-query-client.d.ts.map +0 -1
- package/runtime/endpoint-query-client.types.d.ts.map +0 -1
- package/runtime/endpoint-query.d.ts.map +0 -1
- package/runtime/endpoint-query.types.d.ts.map +0 -1
- package/runtime/endpoint.d.ts.map +0 -1
- package/runtime/endpoint.types.d.ts.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/{cli/bin.d.ts → dist/cli/bin.d.cts} +0 -0
- /package/{cli/bin.d.ts.map → dist/cli/bin.d.cts.map} +0 -0
- /package/{cli → dist/cli}/utils/define-config.js +0 -0
- /package/{cli/utils/exec-config-path.d.ts → dist/cli/utils/exec-config-path.d.cts} +0 -0
- /package/{cli/utils/exec-config-path.d.ts.map → dist/cli/utils/exec-config-path.d.cts.map} +0 -0
- /package/{cli → dist/cli}/utils/exec-config-path.js +0 -0
- /package/{cli/utils/resolve-config-path.d.ts → dist/cli/utils/resolve-config-path.d.cts} +0 -0
- /package/{cli/utils/resolve-config-path.d.ts.map → dist/cli/utils/resolve-config-path.d.cts.map} +0 -0
- /package/{cli → dist/cli}/utils/resolve-config-path.js +0 -0
- /package/{codegen/templates/constants.d.ts → dist/codegen/templates/constants.d.cts} +0 -0
- /package/{codegen/templates/constants.d.ts.map → dist/codegen/templates/constants.d.cts.map} +0 -0
- /package/{codegen → dist/codegen}/templates/constants.js +0 -0
- /package/{codegen/templates/data-contract.tmpl.d.ts → dist/codegen/templates/data-contract.tmpl.d.cts} +0 -0
- /package/{codegen/templates/data-contract.tmpl.d.ts.map → dist/codegen/templates/data-contract.tmpl.d.cts.map} +0 -0
- /package/{codegen → dist/codegen}/templates/data-contract.tmpl.js +0 -0
- /package/{codegen → dist/codegen}/templates/endpoint-jsdoc.tmpl.js +0 -0
- /package/{codegen → dist/codegen}/utils/unpack-filter-option.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-infinite-query.types.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-mutation.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-mutation.types.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-query-client.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-query-client.types.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-query.js +0 -0
- /package/{runtime → dist/runtime}/endpoint-query.types.js +0 -0
- /package/{runtime → dist/runtime}/endpoint.types.js +0 -0
- /package/{runtime/http-client.d.ts → dist/runtime/http-client.d.cts} +0 -0
- /package/{runtime/http-client.d.ts.map → dist/runtime/http-client.d.cts.map} +0 -0
- /package/{runtime → dist/runtime}/http-client.js +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { generateApi as generateApiFromSwagger, } from 'swagger-typescript-api';
|
|
4
|
-
import { allEndpointPerFileTmpl } from
|
|
5
|
-
import { allExportsTmpl } from
|
|
6
|
-
import { LINTERS_IGNORE } from
|
|
7
|
-
import { dataContractsFileTmpl } from
|
|
8
|
-
import { endpointPerFileTmpl } from
|
|
9
|
-
import { indexTsForEndpointPerFileTmpl } from
|
|
10
|
-
import { metaInfoTmpl } from
|
|
11
|
-
import { removeUnusedTypes, } from
|
|
12
|
-
import { unpackFilterOption } from
|
|
4
|
+
import { allEndpointPerFileTmpl } from "./templates/all-endpoints-per-file.tmpl.js";
|
|
5
|
+
import { allExportsTmpl } from "./templates/all-exports.tmpl.js";
|
|
6
|
+
import { LINTERS_IGNORE } from "./templates/constants.js";
|
|
7
|
+
import { dataContractsFileTmpl } from "./templates/data-contracts-file.tmpl.js";
|
|
8
|
+
import { endpointPerFileTmpl } from "./templates/endpoint-per-file.tmpl.js";
|
|
9
|
+
import { indexTsForEndpointPerFileTmpl } from "./templates/index-ts-for-endpoint-per-file.tmpl.js";
|
|
10
|
+
import { metaInfoTmpl } from "./templates/meta-info.tmpl.js";
|
|
11
|
+
import { removeUnusedTypes, } from "./utils/remove-unused-types.js";
|
|
12
|
+
import { unpackFilterOption } from "./utils/unpack-filter-option.js";
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
14
|
const __dirname = path.dirname(__filename);
|
|
15
15
|
const __execdirname = process.cwd();
|
|
@@ -0,0 +1,99 @@
|
|
|
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 ({ routes, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }) => {
|
|
9
|
+
const { _ } = utils;
|
|
10
|
+
const dataContractNamesInThisFile = [];
|
|
11
|
+
const newEndpointTemplates = routes.map((route) => {
|
|
12
|
+
const newEndpointTemplateData = (0, new_endpoint_tmpl_js_1.newEndpointTmpl)({
|
|
13
|
+
route,
|
|
14
|
+
configuration,
|
|
15
|
+
apiParams,
|
|
16
|
+
importFileParams,
|
|
17
|
+
utils,
|
|
18
|
+
groupName,
|
|
19
|
+
metaInfo,
|
|
20
|
+
});
|
|
21
|
+
const { reservedDataContractNames } = newEndpointTemplateData;
|
|
22
|
+
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
23
|
+
reservedDataContractNames.forEach((reservedDataContractName) => {
|
|
24
|
+
if (!dataContactNames.has(reservedDataContractName)) {
|
|
25
|
+
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return { ...newEndpointTemplateData, route };
|
|
29
|
+
});
|
|
30
|
+
const extraImportLines = [];
|
|
31
|
+
const endpointTemplates = await Promise.all(newEndpointTemplates.map(async ({ content: requestInfoInstanceContent, localModelTypes, route, }) => {
|
|
32
|
+
const requestInfoMeta = apiParams.getEndpointMeta?.(route, utils);
|
|
33
|
+
if (requestInfoMeta?.typeNameImportPath && requestInfoMeta.typeName) {
|
|
34
|
+
extraImportLines.push(`import { ${requestInfoMeta.typeName} } from "${requestInfoMeta.typeNameImportPath}";`);
|
|
35
|
+
}
|
|
36
|
+
return `
|
|
37
|
+
${(await Promise.all(localModelTypes.map(async (modelType) => {
|
|
38
|
+
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
39
|
+
configuration,
|
|
40
|
+
contract: modelType,
|
|
41
|
+
addExportKeyword: true,
|
|
42
|
+
});
|
|
43
|
+
return contractType;
|
|
44
|
+
})))
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join('\n\n')}
|
|
47
|
+
|
|
48
|
+
${(0, endpoint_jsdoc_tmpl_js_1.endpointJSDocTmpl)({
|
|
49
|
+
route,
|
|
50
|
+
configuration,
|
|
51
|
+
apiParams,
|
|
52
|
+
})}
|
|
53
|
+
export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
|
|
54
|
+
`;
|
|
55
|
+
}));
|
|
56
|
+
if (metaInfo) {
|
|
57
|
+
extraImportLines.push(`import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "${groupName ? '../' : './'}meta-info";`);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
reservedDataContractNames: dataContractNamesInThisFile,
|
|
61
|
+
content: await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
62
|
+
import {
|
|
63
|
+
RequestParams,
|
|
64
|
+
HttpResponse,
|
|
65
|
+
HttpMultistatusResponse,
|
|
66
|
+
} from "${apiParams.libImports?.['mobx-tanstack-query-api'] ?? 'mobx-tanstack-query-api'}";
|
|
67
|
+
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
68
|
+
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
69
|
+
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
70
|
+
${extraImportLines.join('\n')}
|
|
71
|
+
|
|
72
|
+
${configuration.modelTypes.length > 0
|
|
73
|
+
? `
|
|
74
|
+
import { ${configuration.modelTypes
|
|
75
|
+
.map((it) => it.name)
|
|
76
|
+
.filter((it) => !dataContractNamesInThisFile.includes(it))} } from "${relativePathDataContracts}";
|
|
77
|
+
`
|
|
78
|
+
: ''}
|
|
79
|
+
|
|
80
|
+
${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
|
|
81
|
+
const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
|
|
82
|
+
if (!modelType) {
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
86
|
+
configuration,
|
|
87
|
+
contract: modelType,
|
|
88
|
+
addExportKeyword: true,
|
|
89
|
+
});
|
|
90
|
+
return contractType;
|
|
91
|
+
})))
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join('\n\n')}
|
|
94
|
+
|
|
95
|
+
${endpointTemplates.filter(Boolean).join('\n\n')}
|
|
96
|
+
`),
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.allEndpointPerFileTmpl = allEndpointPerFileTmpl;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from "../index.cjs";
|
|
3
|
+
export interface AllEndpointPerFileTmplParams extends AnyObject {
|
|
4
|
+
routes: AnyObject[];
|
|
5
|
+
configuration: AnyObject;
|
|
6
|
+
apiParams: GenerateQueryApiParams;
|
|
7
|
+
codegenProcess: CodegenProcess;
|
|
8
|
+
importFileParams: AllImportFileParams;
|
|
9
|
+
utils: CodegenDataUtils;
|
|
10
|
+
relativePathDataContracts: string;
|
|
11
|
+
groupName: Maybe<string>;
|
|
12
|
+
metaInfo: Maybe<MetaInfo>;
|
|
13
|
+
}
|
|
14
|
+
export declare const allEndpointPerFileTmpl: ({ routes, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }: AllEndpointPerFileTmplParams) => Promise<{
|
|
15
|
+
reservedDataContractNames: string[];
|
|
16
|
+
content: any;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=all-endpoints-per-file.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACT,qBAAoB;AAOrB,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC7D,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,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,sBAAsB,GAAU,iIAU1C,4BAA4B;;;EAuI9B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from "../index.js";
|
|
3
3
|
export interface AllEndpointPerFileTmplParams extends AnyObject {
|
|
4
4
|
routes: AnyObject[];
|
|
5
5
|
configuration: AnyObject;
|
|
@@ -0,0 +1 @@
|
|
|
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,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACT,oBAAoB;AAOrB,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC7D,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,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,sBAAsB,GAAU,iIAU1C,4BAA4B;;;EAuI9B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LINTERS_IGNORE } from
|
|
2
|
-
import { dataContractTmpl } from
|
|
3
|
-
import { endpointJSDocTmpl } from
|
|
4
|
-
import { newEndpointTmpl } from
|
|
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
5
|
export const allEndpointPerFileTmpl = async ({ routes, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }) => {
|
|
6
6
|
const { _ } = utils;
|
|
7
7
|
const dataContractNamesInThisFile = [];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allExportsTmpl = 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 allExportsTmpl = async ({ collectedExportFiles, metaInfo, formatTSContent, }) => {
|
|
8
|
+
return await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
9
|
+
export * from './data-contracts';
|
|
10
|
+
${collectedExportFiles.map((fileName) => `export * from './${fileName}';`).join('\n')}
|
|
11
|
+
${metaInfo ? 'export * from "./meta-info";' : ''}
|
|
12
|
+
`);
|
|
13
|
+
};
|
|
14
|
+
exports.allExportsTmpl = allExportsTmpl;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Maybe } from 'yummies/utils/types';
|
|
2
|
+
import type { CodegenDataUtils, MetaInfo } from "../index.cjs";
|
|
3
|
+
export interface AllExportsTmplParams {
|
|
4
|
+
formatTSContent: (...args: any[]) => Promise<string>;
|
|
5
|
+
collectedExportFiles: string[];
|
|
6
|
+
metaInfo: Maybe<MetaInfo>;
|
|
7
|
+
utils: CodegenDataUtils;
|
|
8
|
+
}
|
|
9
|
+
export declare const formatGroupNameEnumKey: (groupName: string, { _ }: CodegenDataUtils) => Capitalize<string>;
|
|
10
|
+
export declare const allExportsTmpl: ({ collectedExportFiles, metaInfo, formatTSContent, }: AllExportsTmplParams) => Promise<string>;
|
|
11
|
+
//# sourceMappingURL=all-exports.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-exports.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-exports.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,qBAAoB;AAI9D,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,5 +1,5 @@
|
|
|
1
1
|
import type { Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { CodegenDataUtils, MetaInfo } from
|
|
2
|
+
import type { CodegenDataUtils, MetaInfo } from "../index.js";
|
|
3
3
|
export interface AllExportsTmplParams {
|
|
4
4
|
formatTSContent: (...args: any[]) => Promise<string>;
|
|
5
5
|
collectedExportFiles: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-exports.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-exports.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB;AAI9D,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,4 +1,4 @@
|
|
|
1
|
-
import { LINTERS_IGNORE } from
|
|
1
|
+
import { LINTERS_IGNORE } from "./constants.js";
|
|
2
2
|
export const formatGroupNameEnumKey = (groupName, { _ }) => _.upperFirst(_.camelCase(groupName));
|
|
3
3
|
export const allExportsTmpl = async ({ collectedExportFiles, metaInfo, formatTSContent, }) => {
|
|
4
4
|
return await formatTSContent(`${LINTERS_IGNORE}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,+CACN,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataContractTmpl = void 0;
|
|
4
|
+
const buildGenerics = (contract) => {
|
|
5
|
+
if (!contract.genericArgs?.length)
|
|
6
|
+
return '';
|
|
7
|
+
return ('<' +
|
|
8
|
+
contract.genericArgs
|
|
9
|
+
.map((arg) => {
|
|
10
|
+
const { name, default: defaultType, extends: extendsType } = arg;
|
|
11
|
+
return [
|
|
12
|
+
name,
|
|
13
|
+
extendsType && `extends ${extendsType}`,
|
|
14
|
+
defaultType && `= ${defaultType}`,
|
|
15
|
+
]
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.join(' ');
|
|
18
|
+
})
|
|
19
|
+
.join(', ') +
|
|
20
|
+
'>');
|
|
21
|
+
};
|
|
22
|
+
const dataContractTmpl = async ({ contract, configuration, addExportKeyword, }) => {
|
|
23
|
+
const { utils } = configuration;
|
|
24
|
+
const { formatDescription } = utils;
|
|
25
|
+
const dataContractTemplates = {
|
|
26
|
+
enum: (contract) => {
|
|
27
|
+
return `enum ${contract.name} {\r\n${contract.content}\r\n}`;
|
|
28
|
+
},
|
|
29
|
+
interface: (contract) => {
|
|
30
|
+
return `interface ${contract.name}${buildGenerics(contract)} {\r\n${contract.content}}`;
|
|
31
|
+
},
|
|
32
|
+
type: (contract) => {
|
|
33
|
+
return `type ${contract.name}${buildGenerics(contract)} = ${contract.content === contract.name ? 'any' : contract.content}`;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
let result = '';
|
|
37
|
+
let jsdoc = '';
|
|
38
|
+
if (contract.description) {
|
|
39
|
+
jsdoc = `/**\n * ${formatDescription(contract.description, true)}\n */\n`;
|
|
40
|
+
}
|
|
41
|
+
if (jsdoc) {
|
|
42
|
+
result += jsdoc;
|
|
43
|
+
}
|
|
44
|
+
const templateFn = dataContractTemplates[contract.typeIdentifier] ||
|
|
45
|
+
dataContractTemplates.type;
|
|
46
|
+
const contractType = `${addExportKeyword ? 'export ' : ''}${templateFn(contract)}`;
|
|
47
|
+
return result + contractType;
|
|
48
|
+
};
|
|
49
|
+
exports.dataContractTmpl = dataContractTmpl;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnyObject } from 'yummies/utils/types';
|
|
2
|
+
export interface DataContractTmplParams {
|
|
3
|
+
configuration: AnyObject;
|
|
4
|
+
contract: AnyObject;
|
|
5
|
+
addExportKeyword?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const dataContractTmpl: ({ contract, configuration, addExportKeyword, }: DataContractTmplParams) => Promise<string>;
|
|
8
|
+
//# sourceMappingURL=data-contract.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-contract.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contract.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,SAAS,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAuBD,eAAO,MAAM,gBAAgB,GAAU,gDAIpC,sBAAsB,oBAmCxB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataContractsFileTmpl = void 0;
|
|
4
|
+
const constants_js_1 = require("./constants.cjs");
|
|
5
|
+
const data_contract_tmpl_js_1 = require("./data-contract.tmpl.cjs");
|
|
6
|
+
const dataContractsFileTmpl = async ({ configuration, formatTSContent, excludedDataContractNames, }) => {
|
|
7
|
+
const { config, modelTypes } = configuration;
|
|
8
|
+
const contractDefinitions = [];
|
|
9
|
+
if (config.internalTemplateOptions?.addUtilRequiredKeysType) {
|
|
10
|
+
contractDefinitions.push(`type UtilRequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>`);
|
|
11
|
+
}
|
|
12
|
+
for await (const contract of modelTypes) {
|
|
13
|
+
if (excludedDataContractNames?.includes(contract.name)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
contractDefinitions.push(await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
17
|
+
configuration,
|
|
18
|
+
contract,
|
|
19
|
+
addExportKeyword: true,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
return await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
23
|
+
|
|
24
|
+
${contractDefinitions.length > 0 ? contractDefinitions.join('\n\n') : `export {}`}
|
|
25
|
+
`);
|
|
26
|
+
};
|
|
27
|
+
exports.dataContractsFileTmpl = dataContractsFileTmpl;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyObject } from 'yummies/utils/types';
|
|
2
|
+
import type { CodegenProcess, GenerateQueryApiParams } from "../index.cjs";
|
|
3
|
+
export interface DataContractsTmplParams extends AnyObject {
|
|
4
|
+
configuration: AnyObject;
|
|
5
|
+
apiParams: GenerateQueryApiParams;
|
|
6
|
+
codegenProcess: CodegenProcess;
|
|
7
|
+
excludedDataContractNames?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const dataContractsFileTmpl: ({ configuration, formatTSContent, excludedDataContractNames, }: DataContractsTmplParams) => Promise<any>;
|
|
10
|
+
//# sourceMappingURL=data-contracts-file.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-contracts-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contracts-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,qBAAoB;AAK1E,MAAM,WAAW,uBAAwB,SAAQ,SAAS;IACxD,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,eAAO,MAAM,qBAAqB,GAAU,gEAIzC,uBAAuB,iBA6BzB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObject } from 'yummies/utils/types';
|
|
2
|
-
import type { CodegenProcess, GenerateQueryApiParams } from
|
|
2
|
+
import type { CodegenProcess, GenerateQueryApiParams } from "../index.js";
|
|
3
3
|
export interface DataContractsTmplParams extends AnyObject {
|
|
4
4
|
configuration: AnyObject;
|
|
5
5
|
apiParams: GenerateQueryApiParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-contracts-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contracts-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB;AAK1E,MAAM,WAAW,uBAAwB,SAAQ,SAAS;IACxD,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,eAAO,MAAM,qBAAqB,GAAU,gEAIzC,uBAAuB,iBA6BzB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LINTERS_IGNORE } from
|
|
2
|
-
import { dataContractTmpl } from
|
|
1
|
+
import { LINTERS_IGNORE } from "./constants.js";
|
|
2
|
+
import { dataContractTmpl } from "./data-contract.tmpl.js";
|
|
3
3
|
export const dataContractsFileTmpl = async ({ configuration, formatTSContent, excludedDataContractNames, }) => {
|
|
4
4
|
const { config, modelTypes } = configuration;
|
|
5
5
|
const contractDefinitions = [];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.endpointJSDocTmpl = void 0;
|
|
4
|
+
const text_1 = require("yummies/text");
|
|
5
|
+
const endpointJSDocTmpl = ({ route, configuration, offset = 0, }) => {
|
|
6
|
+
const { routeName } = route;
|
|
7
|
+
const rawRoute = route.raw;
|
|
8
|
+
const routeRequest = route.request;
|
|
9
|
+
const { utils } = configuration;
|
|
10
|
+
const { _, formatDescription } = utils;
|
|
11
|
+
const jsDocLines = [];
|
|
12
|
+
if (rawRoute.summary) {
|
|
13
|
+
const summaryLines = (0, text_1.splitTextByLines)(rawRoute.summary, 60)
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.map((line) => ({
|
|
16
|
+
content: `**${formatDescription(line, true)}**`,
|
|
17
|
+
}));
|
|
18
|
+
if (summaryLines.length > 0) {
|
|
19
|
+
jsDocLines.push(...summaryLines, { content: '' });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (rawRoute.description) {
|
|
23
|
+
const descriptionLines = (0, text_1.splitTextByLines)(rawRoute.description, 60)
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.map((line) => ({
|
|
26
|
+
content: formatDescription(line, true),
|
|
27
|
+
}));
|
|
28
|
+
if (descriptionLines.length > 0) {
|
|
29
|
+
jsDocLines.push(...descriptionLines, { content: '' });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
jsDocLines.push({
|
|
33
|
+
content: 'No description',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
jsDocLines.push({
|
|
39
|
+
content: 'No description',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (rawRoute.operationId) {
|
|
43
|
+
jsDocLines.push({
|
|
44
|
+
name: 'operationId',
|
|
45
|
+
content: rawRoute.operationId,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (_.size(rawRoute.tags)) {
|
|
49
|
+
jsDocLines.push({
|
|
50
|
+
name: 'tags',
|
|
51
|
+
content: rawRoute.tags.join(', '),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
jsDocLines.push({
|
|
55
|
+
name: 'request',
|
|
56
|
+
content: `**${_.upperCase(routeRequest.method)}:${rawRoute.route}**`,
|
|
57
|
+
});
|
|
58
|
+
if (rawRoute.deprecated) {
|
|
59
|
+
jsDocLines.push({
|
|
60
|
+
name: 'deprecated',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (routeName.duplicate) {
|
|
64
|
+
jsDocLines.push({
|
|
65
|
+
name: 'duplicate',
|
|
66
|
+
}, {
|
|
67
|
+
name: 'originalName',
|
|
68
|
+
content: routeName.original,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (routeRequest.security) {
|
|
72
|
+
jsDocLines.push({
|
|
73
|
+
name: 'secure',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (rawRoute.responsesTypes.length > 0) {
|
|
77
|
+
jsDocLines.push({
|
|
78
|
+
name: 'responses',
|
|
79
|
+
});
|
|
80
|
+
rawRoute.responsesTypes.forEach((response) => {
|
|
81
|
+
jsDocLines.push({
|
|
82
|
+
name: `**${response.status}**`,
|
|
83
|
+
content: `${_.replace(_.replace(response.type, /\/\*/g, String.raw `\*`), /\*\//g, '*\\')} ${response.description}`,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const jsdocContent = jsDocLines.map((it) => {
|
|
88
|
+
let line = ' * ';
|
|
89
|
+
if (it.name) {
|
|
90
|
+
line += `@${it.name} `;
|
|
91
|
+
}
|
|
92
|
+
const content = (it.content ?? '').trimEnd();
|
|
93
|
+
if (content) {
|
|
94
|
+
line += content;
|
|
95
|
+
}
|
|
96
|
+
return line;
|
|
97
|
+
});
|
|
98
|
+
const result = `
|
|
99
|
+
/**
|
|
100
|
+
${jsdocContent.join('\n')}
|
|
101
|
+
*/`;
|
|
102
|
+
if (offset > 0) {
|
|
103
|
+
return result
|
|
104
|
+
.split('\n')
|
|
105
|
+
.map((line) => line.padStart(offset))
|
|
106
|
+
.join('\n');
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
exports.endpointJSDocTmpl = endpointJSDocTmpl;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyObject } from 'yummies/utils/types';
|
|
2
|
+
import type { GenerateQueryApiParams } from "../index.cjs";
|
|
3
|
+
export interface EndpointJSDocTmplParams {
|
|
4
|
+
route: AnyObject;
|
|
5
|
+
configuration: AnyObject;
|
|
6
|
+
apiParams: GenerateQueryApiParams;
|
|
7
|
+
offset?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const endpointJSDocTmpl: ({ route, configuration, offset, }: EndpointJSDocTmplParams) => string;
|
|
10
|
+
//# sourceMappingURL=endpoint-jsdoc.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-jsdoc.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-jsdoc.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAoB;AAE1D,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iBAAiB,GAAI,mCAI/B,uBAAuB,WAgIzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-jsdoc.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-jsdoc.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB;AAE1D,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,iBAAiB,GAAI,mCAI/B,uBAAuB,WAgIzB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }) => {
|
|
9
|
+
const { _ } = utils;
|
|
10
|
+
const { content: requestInfoInstanceContent, reservedDataContractNames, localModelTypes, } = (0, new_endpoint_tmpl_js_1.newEndpointTmpl)({
|
|
11
|
+
route,
|
|
12
|
+
configuration,
|
|
13
|
+
apiParams,
|
|
14
|
+
importFileParams,
|
|
15
|
+
utils,
|
|
16
|
+
groupName,
|
|
17
|
+
metaInfo,
|
|
18
|
+
});
|
|
19
|
+
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
20
|
+
const dataContractNamesInThisFile = [];
|
|
21
|
+
reservedDataContractNames.forEach((reservedDataContractName) => {
|
|
22
|
+
if (!dataContactNames.has(reservedDataContractName)) {
|
|
23
|
+
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const extraImportLines = [];
|
|
27
|
+
if (metaInfo) {
|
|
28
|
+
extraImportLines.push(`import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "../${groupName ? '../' : ''}meta-info";`);
|
|
29
|
+
}
|
|
30
|
+
const requestInfoMeta = apiParams.getEndpointMeta?.(route, utils);
|
|
31
|
+
if (requestInfoMeta?.typeNameImportPath && requestInfoMeta.typeName) {
|
|
32
|
+
extraImportLines.push(`import { ${requestInfoMeta.typeName} } from "${requestInfoMeta.typeNameImportPath}";`);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
reservedDataContractNames: dataContractNamesInThisFile,
|
|
36
|
+
content: await formatTSContent(`${constants_js_1.LINTERS_IGNORE}
|
|
37
|
+
import {
|
|
38
|
+
RequestParams,
|
|
39
|
+
HttpResponse,
|
|
40
|
+
HttpMultistatusResponse,
|
|
41
|
+
} from "${apiParams.libImports?.['mobx-tanstack-query-api'] ?? 'mobx-tanstack-query-api'}";
|
|
42
|
+
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
43
|
+
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
44
|
+
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
45
|
+
${extraImportLines.join('\n')}
|
|
46
|
+
|
|
47
|
+
${configuration.modelTypes.length > 0
|
|
48
|
+
? `
|
|
49
|
+
import { ${configuration.modelTypes
|
|
50
|
+
.map((it) => it.name)
|
|
51
|
+
.filter((it) => !dataContractNamesInThisFile.includes(it))} } from "${relativePathDataContracts}";
|
|
52
|
+
`
|
|
53
|
+
: ''}
|
|
54
|
+
|
|
55
|
+
${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
|
|
56
|
+
const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
|
|
57
|
+
if (!modelType) {
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
61
|
+
configuration,
|
|
62
|
+
contract: modelType,
|
|
63
|
+
addExportKeyword: true,
|
|
64
|
+
});
|
|
65
|
+
return contractType;
|
|
66
|
+
})))
|
|
67
|
+
.filter(Boolean)
|
|
68
|
+
.join('\n\n')}
|
|
69
|
+
|
|
70
|
+
${(await Promise.all(localModelTypes.map(async (modelType) => {
|
|
71
|
+
const contractType = await (0, data_contract_tmpl_js_1.dataContractTmpl)({
|
|
72
|
+
configuration,
|
|
73
|
+
contract: modelType,
|
|
74
|
+
addExportKeyword: true,
|
|
75
|
+
});
|
|
76
|
+
return contractType;
|
|
77
|
+
})))
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.join('\n\n')}
|
|
80
|
+
|
|
81
|
+
${(0, endpoint_jsdoc_tmpl_js_1.endpointJSDocTmpl)({
|
|
82
|
+
route,
|
|
83
|
+
configuration,
|
|
84
|
+
apiParams,
|
|
85
|
+
})}
|
|
86
|
+
export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
|
|
87
|
+
`),
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.endpointPerFileTmpl = endpointPerFileTmpl;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from "../index.cjs";
|
|
3
|
+
export interface EndpointPerFileTmplParams extends AnyObject {
|
|
4
|
+
route: AnyObject;
|
|
5
|
+
configuration: AnyObject;
|
|
6
|
+
apiParams: GenerateQueryApiParams;
|
|
7
|
+
codegenProcess: CodegenProcess;
|
|
8
|
+
importFileParams: AllImportFileParams;
|
|
9
|
+
utils: CodegenDataUtils;
|
|
10
|
+
relativePathDataContracts: string;
|
|
11
|
+
groupName: Maybe<string>;
|
|
12
|
+
metaInfo: Maybe<MetaInfo>;
|
|
13
|
+
}
|
|
14
|
+
export declare const endpointPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }: EndpointPerFileTmplParams) => Promise<{
|
|
15
|
+
reservedDataContractNames: string[];
|
|
16
|
+
content: any;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=endpoint-per-file.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACT,qBAAoB;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;;;EAwH3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACT,oBAAoB;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;;;EAwH3B,CAAC"}
|