-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathaction-import.ts
45 lines (41 loc) · 1.43 KB
/
action-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
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import { toTypeNameFormat } from '@sap-cloud-sdk/core';
import { createLogger } from '@sap-cloud-sdk/util';
import { ServiceNameFormatter } from '../../service-name-formatter';
import { VdmActionImportBase } from '../../vdm-types';
import { SwaggerPath } from '../../swagger-parser/swagger-types';
import { actionImportDescription } from '../description-util';
import { EdmxParameter } from '../../edmx-parser/common';
import { EdmxActionImport } from '../../edmx-parser/v4';
import { getActionImportParameters } from './action-function-parameters';
const logger = createLogger({
package: 'generator',
messageContext: 'function-import'
});
export function transformActionImportBase(
edmxActionImport: EdmxActionImport,
edmxParameters: EdmxParameter[],
swaggerDefinition: SwaggerPath | undefined,
formatter: ServiceNameFormatter
): VdmActionImportBase {
const name = formatter.originalToActionImportName(edmxActionImport.Name);
const actiononImport = {
originalName: edmxActionImport.Name,
name,
parametersTypeName: toTypeNameFormat(`${name}Parameters`)
};
const parameters = getActionImportParameters(
edmxActionImport,
edmxParameters,
swaggerDefinition,
formatter
);
return {
...actiononImport,
parameters,
description: actionImportDescription(
swaggerDefinition,
actiononImport.originalName
)
};
}