-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathfunction-import.ts
45 lines (41 loc) · 1.51 KB
/
function-import.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { toTypeNameFormat } from '@sap-cloud-sdk/core';
import { createLogger } from '@sap-cloud-sdk/util';
import { ServiceNameFormatter } from '../../service-name-formatter';
import { VdmFunctionImportBase } from '../../vdm-types';
import { SwaggerPath } from '../../swagger-parser/swagger-types';
import { functionImportDescription } from '../description-util';
import { EdmxParameter } from '../../edmx-parser/common';
import { EdmxFunctionImport as EdmxFunctionImportV2 } from '../../edmx-parser/v2';
import { EdmxFunctionImport as EdmxFunctionImportV4 } from '../../edmx-parser/v4';
import { getFunctionImportParameters } from './action-function-parameters';
const logger = createLogger({
package: 'generator',
messageContext: 'function-import'
});
export function transformFunctionImportBase(
edmxFunctionImport: EdmxFunctionImportV2 | EdmxFunctionImportV4,
edmxParameters: EdmxParameter[],
swaggerDefinition: SwaggerPath | undefined,
formatter: ServiceNameFormatter
): VdmFunctionImportBase {
const name = formatter.originalToFunctionImportName(edmxFunctionImport.Name);
const functionImport = {
originalName: edmxFunctionImport.Name,
name,
parametersTypeName: toTypeNameFormat(`${name}Parameters`)
};
const parameters = getFunctionImportParameters(
edmxFunctionImport,
edmxParameters,
swaggerDefinition,
formatter
);
return {
...functionImport,
parameters,
description: functionImportDescription(
swaggerDefinition,
functionImport.originalName
)
};
}