/
index-file.ts
34 lines (31 loc) · 1023 Bytes
/
index-file.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
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import {
ExportDeclarationStructure,
SourceFileStructure,
StructureKind
} from 'ts-morph';
import { VdmServiceMetadata } from '../vdm-types';
export function indexFile(service: VdmServiceMetadata): SourceFileStructure {
return {
kind: StructureKind.SourceFile,
statements: [
...service.entities.map(entity => exportStatement(entity.className)),
...service.entities.map(entity =>
exportStatement(`${entity.className}RequestBuilder`)
),
...service.complexTypes.map(complexType =>
exportStatement(complexType.typeName)
),
...(service.functionImports && service.functionImports.length
? [exportStatement('function-imports')]
: []),
exportStatement('BatchRequest')
]
};
}
function exportStatement(moduleName: string): ExportDeclarationStructure {
return {
kind: StructureKind.ExportDeclaration,
moduleSpecifier: `./${moduleName}`
};
}