@devrev/typescript-sdk 1.0.2
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/.eslintignore +2 -0
- package/.github/workflows/npm-publish.yml +27 -0
- package/.prettierignore +4 -0
- package/.prettierrc +15 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/launch.json +17 -0
- package/.vscode/settings.json +31 -0
- package/README.md +69 -0
- package/USER_README.md +16 -0
- package/nodemon.json +5 -0
- package/package.json +61 -0
- package/src/auto-generated/beta/beta-devrev-sdk.ts +1826 -0
- package/src/auto-generated/internal/private-internal-devrev-sdk.ts +54739 -0
- package/src/auto-generated/public-devrev-sdk.ts +4009 -0
- package/src/beta-data-contracts.json +3271 -0
- package/src/client_setup.ts +64 -0
- package/src/private-internal-data-contracts.json +98025 -0
- package/src/public-data-contracts.json +6922 -0
- package/src/workflow/workflow.test.ts +26 -0
- package/src/workflow/workflow.ts +54 -0
- package/templates/README.md +17 -0
- package/templates/base/README.md +8 -0
- package/templates/base/data-contract-jsdoc.ejs +37 -0
- package/templates/base/data-contracts.ejs +28 -0
- package/templates/base/enum-data-contract.ejs +12 -0
- package/templates/base/http-client.ejs +3 -0
- package/templates/base/http-clients/axios-http-client.ejs +138 -0
- package/templates/base/http-clients/fetch-http-client.ejs +224 -0
- package/templates/base/interface-data-contract.ejs +10 -0
- package/templates/base/object-field-jsdoc.ejs +28 -0
- package/templates/base/route-docs.ejs +30 -0
- package/templates/base/route-name.ejs +43 -0
- package/templates/base/route-type.ejs +22 -0
- package/templates/base/type-data-contract.ejs +15 -0
- package/templates/default/README.md +7 -0
- package/templates/default/api.ejs +64 -0
- package/templates/default/procedure-call.ejs +100 -0
- package/templates/default/route-types.ejs +26 -0
- package/templates/modular/README.md +7 -0
- package/templates/modular/api.ejs +28 -0
- package/templates/modular/procedure-call.ejs +100 -0
- package/templates/modular/route-types.ejs +18 -0
- package/tsconfig.eslint.json +4 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { route, utils, config } = it;
|
|
3
|
+
const { _, pascalCase, require } = utils;
|
|
4
|
+
const { query, payload, pathParams, headers } = route.request;
|
|
5
|
+
|
|
6
|
+
const routeDocs = includeFile("@base/route-docs", { config, route, utils });
|
|
7
|
+
const routeNamespace = pascalCase(route.routeName.usage);
|
|
8
|
+
|
|
9
|
+
%>
|
|
10
|
+
/**
|
|
11
|
+
<%~ routeDocs.description %>
|
|
12
|
+
|
|
13
|
+
<%~ routeDocs.lines %>
|
|
14
|
+
|
|
15
|
+
*/
|
|
16
|
+
export namespace <%~ routeNamespace %> {
|
|
17
|
+
export type RequestParams = <%~ (pathParams && pathParams.type) || '{}' %>;
|
|
18
|
+
export type RequestQuery = <%~ (query && query.type) || '{}' %>;
|
|
19
|
+
export type RequestBody = <%~ (payload && payload.type) || 'never' %>;
|
|
20
|
+
export type RequestHeaders = <%~ (headers && headers.type) || '{}' %>;
|
|
21
|
+
export type ResponseBody = <%~ route.response.type %>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { contract, utils } = it;
|
|
3
|
+
const { formatDescription, require, _ } = utils;
|
|
4
|
+
|
|
5
|
+
%>
|
|
6
|
+
<% if (contract.$content.length) { %>
|
|
7
|
+
export type <%~ contract.name %> = {
|
|
8
|
+
<% _.forEach(contract.$content, (field) => { %>
|
|
9
|
+
<%~ includeFile('@base/object-field-jsdoc.ejs', { ...it, field }) %>
|
|
10
|
+
<%~ field.field %>;
|
|
11
|
+
<% }) %>
|
|
12
|
+
}<%~ utils.isNeedToAddNull(contract) ? ' | null' : ''%>
|
|
13
|
+
<% } else { %>
|
|
14
|
+
export type <%~ contract.name %> = Record<string, any>;
|
|
15
|
+
<% } %>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { apiConfig, routes, utils, config } = it;
|
|
3
|
+
const { info, servers, externalDocs } = apiConfig;
|
|
4
|
+
const { _, require, formatDescription } = utils;
|
|
5
|
+
|
|
6
|
+
const server = (servers && servers[0]) || { url: "" };
|
|
7
|
+
|
|
8
|
+
const descriptionLines = _.compact([
|
|
9
|
+
`@title ${info.title || "No title"}`,
|
|
10
|
+
info.version && `@version ${info.version}`,
|
|
11
|
+
info.license && `@license ${_.compact([
|
|
12
|
+
info.license.name,
|
|
13
|
+
info.license.url && `(${info.license.url})`,
|
|
14
|
+
]).join(" ")}`,
|
|
15
|
+
info.termsOfService && `@termsOfService ${info.termsOfService}`,
|
|
16
|
+
server.url && `@baseUrl ${server.url}`,
|
|
17
|
+
externalDocs.url && `@externalDocs ${externalDocs.url}`,
|
|
18
|
+
info.contact && `@contact ${_.compact([
|
|
19
|
+
info.contact.name,
|
|
20
|
+
info.contact.email && `<${info.contact.email}>`,
|
|
21
|
+
info.contact.url && `(${info.contact.url})`,
|
|
22
|
+
]).join(" ")}`,
|
|
23
|
+
info.description && " ",
|
|
24
|
+
info.description && _.replace(formatDescription(info.description), /\n/g, "\n * "),
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
%>
|
|
28
|
+
|
|
29
|
+
<% if (config.httpClientType === config.constants.HTTP_CLIENT.AXIOS) { %> import { AxiosRequestConfig, AxiosResponse } from "axios"; <% } %>
|
|
30
|
+
|
|
31
|
+
<% if (descriptionLines.length) { %>
|
|
32
|
+
/**
|
|
33
|
+
<% descriptionLines.forEach((descriptionLine) => { %>
|
|
34
|
+
* <%~ descriptionLine %>
|
|
35
|
+
|
|
36
|
+
<% }) %>
|
|
37
|
+
*/
|
|
38
|
+
<% } %>
|
|
39
|
+
export class <%~ config.apiClassName %><SecurityDataType extends unknown><% if (!config.singleHttpClient) { %> extends HttpClient<SecurityDataType> <% } %> {
|
|
40
|
+
|
|
41
|
+
<% if(config.singleHttpClient) { %>
|
|
42
|
+
http: HttpClient<SecurityDataType>;
|
|
43
|
+
|
|
44
|
+
constructor (http: HttpClient<SecurityDataType>) {
|
|
45
|
+
this.http = http;
|
|
46
|
+
}
|
|
47
|
+
<% } %>
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
<% routes.outOfModule && routes.outOfModule.forEach((route) => { %>
|
|
51
|
+
<% console.log("The value of it.num is: " + it.num) %>
|
|
52
|
+
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
|
|
53
|
+
|
|
54
|
+
<% }) %>
|
|
55
|
+
|
|
56
|
+
<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %>
|
|
57
|
+
|
|
58
|
+
<% routes.forEach((route) => { %>
|
|
59
|
+
|
|
60
|
+
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
|
|
61
|
+
|
|
62
|
+
<% }) %>
|
|
63
|
+
<% }) %>
|
|
64
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { utils, route, config } = it;
|
|
3
|
+
const { requestBodyInfo, responseBodyInfo, specificArgNameResolver } = route;
|
|
4
|
+
const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRef, require } = utils;
|
|
5
|
+
const { parameters, path, method, payload, query, formData, security, requestParams } = route.request;
|
|
6
|
+
const { type, errorType, contentTypes } = route.response;
|
|
7
|
+
const { HTTP_CLIENT, RESERVED_REQ_PARAMS_ARG_NAMES } = config.constants;
|
|
8
|
+
const routeDocs = includeFile("@base/route-docs", { config, route, utils });
|
|
9
|
+
const queryName = (query && query.name) || "query";
|
|
10
|
+
const pathParams = _.values(parameters);
|
|
11
|
+
const pathParamsNames = _.map(pathParams, "name");
|
|
12
|
+
|
|
13
|
+
const isFetchTemplate = config.httpClientType === HTTP_CLIENT.FETCH;
|
|
14
|
+
|
|
15
|
+
const requestConfigParam = {
|
|
16
|
+
name: specificArgNameResolver.resolve(RESERVED_REQ_PARAMS_ARG_NAMES),
|
|
17
|
+
optional: true,
|
|
18
|
+
type: "RequestParams",
|
|
19
|
+
defaultValue: "{}",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const argToTmpl = ({ name, optional, type, defaultValue }) => `${name}${!defaultValue && optional ? '?' : ''}: ${type}${defaultValue ? ` = ${defaultValue}` : ''}`;
|
|
23
|
+
|
|
24
|
+
const rawWrapperArgs = config.extractRequestParams ?
|
|
25
|
+
_.compact([
|
|
26
|
+
requestParams && {
|
|
27
|
+
name: pathParams.length ? `{ ${_.join(pathParamsNames, ", ")}, ...${queryName} }` : queryName,
|
|
28
|
+
optional: false,
|
|
29
|
+
type: getInlineParseContent(requestParams),
|
|
30
|
+
},
|
|
31
|
+
...(!requestParams ? pathParams : []),
|
|
32
|
+
payload,
|
|
33
|
+
requestConfigParam,
|
|
34
|
+
]) :
|
|
35
|
+
_.compact([
|
|
36
|
+
...pathParams,
|
|
37
|
+
query,
|
|
38
|
+
payload,
|
|
39
|
+
requestConfigParam,
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
const wrapperArgs = _
|
|
43
|
+
// Sort by optionality
|
|
44
|
+
.sortBy(rawWrapperArgs, [o => o.optional])
|
|
45
|
+
.map(argToTmpl)
|
|
46
|
+
.join(', ')
|
|
47
|
+
|
|
48
|
+
// RequestParams["type"]
|
|
49
|
+
const requestContentKind = {
|
|
50
|
+
"JSON": "ContentType.Json",
|
|
51
|
+
"URL_ENCODED": "ContentType.UrlEncoded",
|
|
52
|
+
"FORM_DATA": "ContentType.FormData",
|
|
53
|
+
"TEXT": "ContentType.Text",
|
|
54
|
+
}
|
|
55
|
+
// RequestParams["format"]
|
|
56
|
+
const responseContentKind = {
|
|
57
|
+
"JSON": '"json"',
|
|
58
|
+
"IMAGE": '"blob"',
|
|
59
|
+
"FORM_DATA": isFetchTemplate ? '"formData"' : '"document"'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const bodyTmpl = _.get(payload, "name") || null;
|
|
63
|
+
const queryTmpl = (query != null && queryName) || null;
|
|
64
|
+
const bodyContentKindTmpl = requestContentKind[requestBodyInfo.contentKind] || null;
|
|
65
|
+
const responseFormatTmpl = responseContentKind[responseBodyInfo.success && responseBodyInfo.success.schema && responseBodyInfo.success.schema.contentKind] || null;
|
|
66
|
+
const securityTmpl = security ? 'true' : null;
|
|
67
|
+
|
|
68
|
+
const describeReturnType = () => {
|
|
69
|
+
if (!config.toJS) return "";
|
|
70
|
+
|
|
71
|
+
switch(config.httpClientType) {
|
|
72
|
+
case HTTP_CLIENT.AXIOS: {
|
|
73
|
+
return `Promise<AxiosResponse<${type}>>`
|
|
74
|
+
}
|
|
75
|
+
default: {
|
|
76
|
+
return `Promise<HttpResponse<${type}, ${errorType}>`
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
%>
|
|
82
|
+
/**
|
|
83
|
+
<%~ routeDocs.description %>
|
|
84
|
+
|
|
85
|
+
*<% /* Here you can add some other JSDoc tags */ %>
|
|
86
|
+
|
|
87
|
+
<%~ routeDocs.lines %>
|
|
88
|
+
|
|
89
|
+
*/
|
|
90
|
+
<%~ route.routeName.usage %><%~ route.namespace ? '= ' : ' = ' %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
|
|
91
|
+
<%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
|
|
92
|
+
path: `<%~ path %>`,
|
|
93
|
+
method: '<%~ _.upperCase(method) %>',
|
|
94
|
+
<%~ queryTmpl ? `query: ${queryTmpl},` : '' %>
|
|
95
|
+
<%~ bodyTmpl ? `body: ${bodyTmpl},` : '' %>
|
|
96
|
+
<%~ securityTmpl ? `secure: ${securityTmpl},` : '' %>
|
|
97
|
+
<%~ bodyContentKindTmpl ? `type: ${bodyContentKindTmpl},` : '' %>
|
|
98
|
+
<%~ responseFormatTmpl ? `format: ${responseFormatTmpl},` : '' %>
|
|
99
|
+
...<%~ _.get(requestConfigParam, "name") %>,
|
|
100
|
+
})<%~ route.namespace ? '' : '' %>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { utils, config, routes, modelTypes } = it;
|
|
3
|
+
const { _, pascalCase } = utils;
|
|
4
|
+
const dataContracts = config.modular ? _.map(modelTypes, "name") : [];
|
|
5
|
+
%>
|
|
6
|
+
|
|
7
|
+
<% if (dataContracts.length) { %>
|
|
8
|
+
import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
|
|
9
|
+
<% } %>
|
|
10
|
+
|
|
11
|
+
<%
|
|
12
|
+
/* TODO: outOfModule, combined should be attributes of route, which will allow to avoid duplication of code */
|
|
13
|
+
%>
|
|
14
|
+
|
|
15
|
+
<% routes.outOfModule && routes.outOfModule.forEach(({ routes = [] }) => { %>
|
|
16
|
+
<% routes.forEach((route) => { %>
|
|
17
|
+
<%~ includeFile('@base/route-type.ejs', { ...it, route }) %>
|
|
18
|
+
<% }) %>
|
|
19
|
+
<% }) %>
|
|
20
|
+
|
|
21
|
+
<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %>
|
|
22
|
+
<% routes.forEach((route) => { %>
|
|
23
|
+
<%~ includeFile('@base/route-type.ejs', { ...it, route }) %>
|
|
24
|
+
<% }) %>
|
|
25
|
+
|
|
26
|
+
<% }) %>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { utils, route, config, modelTypes } = it;
|
|
3
|
+
const { _, pascalCase, require } = utils;
|
|
4
|
+
const apiClassName = pascalCase(route.moduleName);
|
|
5
|
+
const routes = route.routes;
|
|
6
|
+
const dataContracts = _.map(modelTypes, "name");
|
|
7
|
+
%>
|
|
8
|
+
|
|
9
|
+
<% if (config.httpClientType === config.constants.HTTP_CLIENT.AXIOS) { %> import { AxiosRequestConfig, AxiosResponse } from "axios"; <% } %>
|
|
10
|
+
|
|
11
|
+
import { HttpClient, RequestParams, ContentType, HttpResponse } from "./<%~ config.fileNames.httpClient %>";
|
|
12
|
+
<% if (dataContracts.length) { %>
|
|
13
|
+
import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
|
|
14
|
+
<% } %>
|
|
15
|
+
|
|
16
|
+
export class <%= apiClassName %><SecurityDataType = unknown><% if (!config.singleHttpClient) { %> extends HttpClient<SecurityDataType> <% } %> {
|
|
17
|
+
<% if(config.singleHttpClient) { %>
|
|
18
|
+
http: HttpClient<SecurityDataType>;
|
|
19
|
+
|
|
20
|
+
constructor (http: HttpClient<SecurityDataType>) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
<% } %>
|
|
24
|
+
|
|
25
|
+
<% routes.forEach((route) => { %>
|
|
26
|
+
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
|
|
27
|
+
<% }) %>
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { utils, route, config } = it;
|
|
3
|
+
const { requestBodyInfo, responseBodyInfo, specificArgNameResolver } = route;
|
|
4
|
+
const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRef, require } = utils;
|
|
5
|
+
const { parameters, path, method, payload, query, formData, security, requestParams } = route.request;
|
|
6
|
+
const { type, errorType, contentTypes } = route.response;
|
|
7
|
+
const { HTTP_CLIENT, RESERVED_REQ_PARAMS_ARG_NAMES } = config.constants;
|
|
8
|
+
const routeDocs = includeFile("@base/route-docs", { config, route, utils });
|
|
9
|
+
const queryName = (query && query.name) || "query";
|
|
10
|
+
const pathParams = _.values(parameters);
|
|
11
|
+
const pathParamsNames = _.map(pathParams, "name");
|
|
12
|
+
|
|
13
|
+
const isFetchTemplate = config.httpClientType === HTTP_CLIENT.FETCH;
|
|
14
|
+
|
|
15
|
+
const requestConfigParam = {
|
|
16
|
+
name: specificArgNameResolver.resolve(RESERVED_REQ_PARAMS_ARG_NAMES),
|
|
17
|
+
optional: true,
|
|
18
|
+
type: "RequestParams",
|
|
19
|
+
defaultValue: "{}",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const argToTmpl = ({ name, optional, type, defaultValue }) => `${name}${!defaultValue && optional ? '?' : ''}: ${type}${defaultValue ? ` = ${defaultValue}` : ''}`;
|
|
23
|
+
|
|
24
|
+
const rawWrapperArgs = config.extractRequestParams ?
|
|
25
|
+
_.compact([
|
|
26
|
+
requestParams && {
|
|
27
|
+
name: pathParams.length ? `{ ${_.join(pathParamsNames, ", ")}, ...${queryName} }` : queryName,
|
|
28
|
+
optional: false,
|
|
29
|
+
type: getInlineParseContent(requestParams),
|
|
30
|
+
},
|
|
31
|
+
...(!requestParams ? pathParams : []),
|
|
32
|
+
payload,
|
|
33
|
+
requestConfigParam,
|
|
34
|
+
]) :
|
|
35
|
+
_.compact([
|
|
36
|
+
...pathParams,
|
|
37
|
+
query,
|
|
38
|
+
payload,
|
|
39
|
+
requestConfigParam,
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
const wrapperArgs = _
|
|
43
|
+
// Sort by optionality
|
|
44
|
+
.sortBy(rawWrapperArgs, [o => o.optional])
|
|
45
|
+
.map(argToTmpl)
|
|
46
|
+
.join(', ')
|
|
47
|
+
|
|
48
|
+
// RequestParams["type"]
|
|
49
|
+
const requestContentKind = {
|
|
50
|
+
"JSON": "ContentType.Json",
|
|
51
|
+
"URL_ENCODED": "ContentType.UrlEncoded",
|
|
52
|
+
"FORM_DATA": "ContentType.FormData",
|
|
53
|
+
"TEXT": "ContentType.Text",
|
|
54
|
+
}
|
|
55
|
+
// RequestParams["format"]
|
|
56
|
+
const responseContentKind = {
|
|
57
|
+
"JSON": '"json"',
|
|
58
|
+
"IMAGE": '"blob"',
|
|
59
|
+
"FORM_DATA": isFetchTemplate ? '"formData"' : '"document"'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const bodyTmpl = _.get(payload, "name") || null;
|
|
63
|
+
const queryTmpl = (query != null && queryName) || null;
|
|
64
|
+
const bodyContentKindTmpl = requestContentKind[requestBodyInfo.contentKind] || null;
|
|
65
|
+
const responseFormatTmpl = responseContentKind[responseBodyInfo.success && responseBodyInfo.success.schema && responseBodyInfo.success.schema.contentKind] || null;
|
|
66
|
+
const securityTmpl = security ? 'true' : null;
|
|
67
|
+
|
|
68
|
+
const describeReturnType = () => {
|
|
69
|
+
if (!config.toJS) return "";
|
|
70
|
+
|
|
71
|
+
switch(config.httpClientType) {
|
|
72
|
+
case HTTP_CLIENT.AXIOS: {
|
|
73
|
+
return `Promise<AxiosResponse<${type}>>`
|
|
74
|
+
}
|
|
75
|
+
default: {
|
|
76
|
+
return `Promise<HttpResponse<${type}, ${errorType}>`
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
%>
|
|
82
|
+
/**
|
|
83
|
+
<%~ routeDocs.description %>
|
|
84
|
+
|
|
85
|
+
*<% /* Here you can add some other JSDoc tags */ %>
|
|
86
|
+
|
|
87
|
+
<%~ routeDocs.lines %>
|
|
88
|
+
|
|
89
|
+
*/
|
|
90
|
+
<%~ route.routeName.usage %> = (<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
|
|
91
|
+
<%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
|
|
92
|
+
path: `<%~ path %>`,
|
|
93
|
+
method: '<%~ _.upperCase(method) %>',
|
|
94
|
+
<%~ queryTmpl ? `query: ${queryTmpl},` : '' %>
|
|
95
|
+
<%~ bodyTmpl ? `body: ${bodyTmpl},` : '' %>
|
|
96
|
+
<%~ securityTmpl ? `secure: ${securityTmpl},` : '' %>
|
|
97
|
+
<%~ bodyContentKindTmpl ? `type: ${bodyContentKindTmpl},` : '' %>
|
|
98
|
+
<%~ responseFormatTmpl ? `format: ${responseFormatTmpl},` : '' %>
|
|
99
|
+
...<%~ _.get(requestConfigParam, "name") %>,
|
|
100
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const { utils, config, route, modelTypes } = it;
|
|
3
|
+
const { _, pascalCase } = utils;
|
|
4
|
+
const { routes, moduleName } = route;
|
|
5
|
+
const dataContracts = config.modular ? _.map(modelTypes, "name") : [];
|
|
6
|
+
|
|
7
|
+
%>
|
|
8
|
+
<% if (dataContracts.length) { %>
|
|
9
|
+
import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
|
|
10
|
+
<% } %>
|
|
11
|
+
|
|
12
|
+
export namespace <%~ pascalCase(moduleName) %> {
|
|
13
|
+
<% _.forEach(routes, (route) => { %>
|
|
14
|
+
|
|
15
|
+
<%~ includeFile('@base/route-type.ejs', { ...it, route }) %>
|
|
16
|
+
|
|
17
|
+
<% }) %>
|
|
18
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2016",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"baseUrl": "./",
|
|
6
|
+
"paths": {
|
|
7
|
+
"*": [
|
|
8
|
+
"./src/*"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"declaration": true
|
|
17
|
+
},
|
|
18
|
+
"include": [
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"exclude": [
|
|
22
|
+
"node_modules",
|
|
23
|
+
"dist"
|
|
24
|
+
]
|
|
25
|
+
}
|