Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @sap-cloud-sdk/generator

SAP Cloud SDK for JavaScript Logo

@sap-cloud-sdk/generator

Generate your own service module using a service specification (.edmx file).

Installation

$ npm install @sap-cloud-sdk/generator

Usage

The generator is primarily meant to be used on the command line:

generate-odata-client --inputDir path/to/your/service-specification(s) --outputDir path/where/the/modules/are/stored

Run generate-odata-client --help for further options.

You can also use the generator programmatically. You will have to provide the options anyways.

import { generateProject } from '@sap-cloud-sdk/generator';

// initialize generator options based on what you want to do
const options: GeneratorOptions = initializeOptions();

// creates a Project datastructure with all sourcefiles based on your options
const project = generateProject(options);

// here you can modify you project if you need to

// save the files at the specified location
project.save();

// alternatively you can generate and save the project in one step with: generate(options)

Documentation

Getting started guide API documentation

Helpful Links

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

EdmTypeMapping

EdmTypeMapping: {}

Type declaration

EdmxAction

EdmxAction: EdmxFunction

EdmxComplexType

EdmxEntitySet

EdmxEntitySet: EdmxEntitySetBase
deprecated

Since version 1.25.0 due to major generator refactoring.

EdmxEntityType

EdmxEntityType

VdmActionFunctionImportReturnType

VdmActionFunctionImportReturnType: VdmActionImportReturnType | VdmFunctionImportReturnType

VdmActionImport

VdmActionImport: VdmFunctionImport

VdmActionImportBase

VdmActionImportBase: VdmFunctionImportBase

VdmActionImportReturnType

VdmActionImportReturnType: VdmFunctionImportReturnType

VdmServiceMetadata

Variables

Const VALUE_IS_UNDEFINED

VALUE_IS_UNDEFINED: "VALUE_IS_UNDEFINED" = "VALUE_IS_UNDEFINED"

Const applyPrefixOnJsConfictFunctionImports

applyPrefixOnJsConfictFunctionImports: (Anonymous function) = applyPrefixOnJsConflictFunctionImports
deprecated

Since v1.25.0. Use applyPrefixOnJsConflictFunctionImports instead.

Const applyPrefixOnJsConfictParam

applyPrefixOnJsConfictParam: (Anonymous function) = applyPrefixOnJsConflictParam
deprecated

Since v1.25.0. Use applyPrefixOnJsConflictParam instead.

Const applyPrefixOnJsConflictFunctionImports

applyPrefixOnJsConflictFunctionImports: (Anonymous function) = applyPrefixOnJSReservedWords('f')

Const applyPrefixOnJsConflictParam

applyPrefixOnJsConflictParam: (Anonymous function) = applyPrefixOnJSReservedWords('p')

Const applySuffixOnConflictDash

applySuffixOnConflictDash: (Anonymous function) = applySuffixOnConflict('-')
deprecated

Since v1.22.0. This method changes the 'previouslyGeneratedNames' passed to it. Use UniqueNameFinder instead.

Const applySuffixOnConflictUnderscore

applySuffixOnConflictUnderscore: (Anonymous function) = applySuffixOnConflict('_')
deprecated

Since v1.22.0. This method changes the 'previouslyGeneratedNames' passed to it. Use UniqueNameFinder instead.

Const collectionRegExp

collectionRegExp: RegExp = /Collection\((?<collectionType>.*)\)/

Const reservedJSKeywords

reservedJSKeywords: Set<string> = new Set<string>(['break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','false','finally','for','function','if','implements','in','instanceof','let','new','null','protected','public','return','static','super','switch','symbol','this','true','try','typeof','var','void','while','with','yield'])

Const reservedObjectPrototypeKeywords

reservedObjectPrototypeKeywords: Set<string> = new Set<string>(Object.getOwnPropertyNames(Object.prototype))

Const reservedServiceKeywords

reservedServiceKeywords: string[] = ['BinaryField','NumberField','Moment','BigNumber','BigNumberField','StringField','DateField','AllFields','CustomField','Entity','EntityBuilderType','Field','Selectable','OneToOneLink','BooleanField','Link','Time','TimeField']

Const reservedVdmKeywords

reservedVdmKeywords: Set<string> = new Set<string>(['builder','entityBuilder','requestBuilder'])

Functions

actionImportDescription

  • actionImportDescription(swaggerDefinition: SwaggerPath | undefined, originalName: string): string

actionImportFunction

actionImportSourceFile

addLeadingNewline

  • addLeadingNewline(documentation: string): string
  • Adds a leading \n to a documentation string so that the ts-morph makes a block comment out of it.

    Parameters

    • documentation: string

      text.

    Returns string

    documentation text with leading \n.

apiBusinessHubMetadata

batchFunction

batchSourceFile

builderFunction

  • builderFunction(complexType: VdmComplexType): FunctionDeclarationStructure

changesetFunction

checkCollectionKind

cloudSdkVdmHack

  • cloudSdkVdmHack(name: string): string

complexTypeFieldType

  • complexTypeFieldType(typeName: string): string

complexTypeForName

  • complexTypeForName(name: string, complexTypes: Omit<VdmComplexType, "factoryName">[]): string

complexTypeImportDeclarations

  • complexTypeImportDeclarations(properties: VdmProperty[]): ImportDeclarationStructure[]

complexTypeInterface

  • complexTypeInterface(complexType: VdmComplexType): InterfaceDeclarationStructure

complexTypeName

  • complexTypeName(type: string): string | undefined

Const complexTypeName

  • complexTypeName(type: string): undefined | string

complexTypeNamespace

  • complexTypeNamespace(complexType: VdmComplexType): NamespaceDeclarationStructure

complexTypeSourceFile

copyFile

  • copyFile(fromPath: string, toRelativePath: string, toDirectory: Directory, overwrite: boolean): void

coreImportDeclaration

  • coreImportDeclaration(namedImports: string[], oDataVersion: ODataVersion): ImportDeclarationStructure

coreNavPropertyFieldTypeImportNames

corePropertyFieldTypeImportNames

  • corePropertyFieldTypeImportNames(properties: VdmProperty[]): string[]

corePropertyTypeImportNames

createEntityClassNames

createEntityClassNames

createPropertyFieldInitializer

  • createPropertyFieldInitializer(property: VdmProperty, entityClassName: string): string

csn

edmToComplexPropertyType

  • edmToComplexPropertyType(edmType: string): string

edmToFieldType

  • edmToFieldType(edmType: string): string

edmToTsType

  • edmToTsType(edmType: string): string

edmxPaths

  • edmxPaths(input: PathLike): PathLike[]

endWithDot

  • endWithDot(text: string): string

ensureString

  • ensureString(obj: any): string

entityClass

entityDescription

entityNamespace

entitySourceFile

entityTypeForceMandatoryInterface

entityTypeInterface

enumTypeClass

  • enumTypeClass(enumType: VdmEnumType): EnumDeclarationStructure

enumTypeForName

  • enumTypeForName(name: string, enumTypes: VdmEnumType[]): string

enumTypeImportDeclarations

  • enumTypeImportDeclarations(properties: VdmProperty[]): ImportDeclarationStructure[]

enumTypeSourceFile

  • enumTypeSourceFile(enumType: VdmEnumType): SourceFileStructure

exportStatement

externalImportDeclaration

  • externalImportDeclaration(properties: VdmMappedEdmType[], moduleSpecifier: string, namedImports: string[]): ImportDeclarationStructure

externalImportDeclarations

  • externalImportDeclarations(properties: VdmMappedEdmType[]): ImportDeclarationStructure[]

fieldTypeClass

  • fieldTypeClass(complexType: VdmComplexType): ClassDeclarationStructure

findActionFunctionByImportName

Const findComplexType

Const findEnumType

forceArray

  • forceArray(obj: any): any[]

functionImportDescription

  • functionImportDescription(swaggerDefinition: SwaggerPath | undefined, originalName: string): string

functionImportFunction

functionImportSourceFile

generate

  • generate(options: GeneratorOptions): Promise<void | EmitResult[]>

generateActionImportsV4

generateComplexTypesV2

generateComplexTypesV4

generateEntitiesV2

generateEntitiesV4

generateEnumTypesV4

generateFunctionImportsV2

generateFunctionImportsV4

generateProject

  • generateProject(options: GeneratorOptions): Promise<Project | undefined>

generateSourcesForService

  • generateSourcesForService(service: VdmServiceMetadata, project: Project, options: GeneratorOptions): Promise<void>

Const genericDescription

  • genericDescription(packageName: string): string

getActionImportParameters

getComplexTypeFieldDescription

getComplexTypePropertyDescription

  • getComplexTypePropertyDescription(property: VdmProperty, complexTypeName: string): string

getEntityDescription

getFallbackEdmTypeIfNeeded

  • getFallbackEdmTypeIfNeeded(edmType: string): EdmTypeShared<any>

getFunctionDoc

getFunctionImportParameters

getGenericParameters

  • getGenericParameters(entityClassName: string, prop: VdmProperty): string

getLookupDescription

getNavPropertyDescription

getPropertyDescription

getRequestBuilderArgumentsBase

getRequestBuilderDescription

  • getRequestBuilderDescription(entity: VdmEntity): string

getRoot

  • getRoot(edmx: any): any

getServiceEntitiesV2

getServiceEntitiesV4

getServicePath

getStaticNavPropertyDescription

getStaticPropertyDescription

  • getStaticPropertyDescription(property: VdmProperty): string

getTypeMappingActionFunction

getTypeMappingComplexProperties

  • getTypeMappingComplexProperties(typeName: string, enumTypes: VdmEnumType[], formattedTypes: MapType<any>, isCollection: boolean, isEnum: boolean, isComplex: boolean): VdmMappedEdmType

hasComplexTypeProperty

  • hasComplexTypeProperty(properties: VdmProperty[]): boolean

hasEdmTypeProperty

  • hasEdmTypeProperty(properties: VdmProperty[]): boolean

helpfulLinksSection

  • helpfulLinksSection(): string[]

importBatchDeclarations

importDeclarations

importDeclarations

importDeclarations

importDeclarationsAction

importDeclarationsFunction

includeFactoryName

indexFile

inputPaths

isCollection

  • isCollection(typeName: string): boolean

isCollectionType

  • isCollectionType(typeName: string): boolean

isComplexType

  • isComplexType(name: string, complexTypes: Omit<VdmComplexType, "factoryName">[]): boolean

isComplexTypeOrEnumType

  • isComplexTypeOrEnumType(typeName: string): boolean

isCreatable

  • isCreatable(entity: any): boolean

isDeletable

  • isDeletable(entity: any): boolean

isEdmType

  • isEdmType(typeName: string): boolean

isEnumType

  • isEnumType(name: string, enumTypes: VdmEnumType[]): boolean

isFilterable

  • isFilterable(property: any): boolean

isNullableParameter

  • isNullableParameter(parameter: any): boolean

isNullableProperty

  • isNullableProperty(property: any): boolean

isSortable

  • isSortable(property: any): boolean

isUpdatable

  • isUpdatable(entity: any): boolean

isV2Metadata

isV2Metadata

isV4Metadata

joinAssociationMetadata

joinAssociationMetadata

joinComplexTypes

joinEntityMetadata

  • joinEntityMetadata<EntitySetT, EntityTypeT>(entitySets: EntitySetT[], entityTypes: EntityTypeT[], namespace: string, swagger?: SwaggerMetadata): JoinedEntityMetadata<EntitySetT, EntityTypeT>[]

joinEntityMetadata

joinEntityTypes

joinTypesWithBaseTypes

  • joinTypesWithBaseTypes<T>(types: T[], joinTypes: (type: T, baseType: T) => T): T[]

linkClass

longDescription

mergeImportDeclarations

  • mergeImportDeclarations(importDeclarations: ImportDeclarationStructure[]): ImportDeclarationStructure[]
  • Parameters

    • importDeclarations: ImportDeclarationStructure[]

    Returns ImportDeclarationStructure[]

navigationPropertyBase

  • navigationPropertyBase(navPropName: string, entitySetName: string, formatter: ServiceNameFormatter): Pick<VdmNavigationProperty, "originalName" | "instancePropertyName" | "staticPropertyName" | "propertyNameAsParam">

navigationPropertyBase

  • navigationPropertyBase(navPropName: string, entitySetName: string, formatter: ServiceNameFormatter): Pick<VdmNavigationProperty, "originalName" | "instancePropertyName" | "staticPropertyName" | "propertyNameAsParam">

npmCompliantName

  • npmCompliantName(name: string): string
  • Takes a name and returns a transformation that is guaranteed to be compliant with npm naming rules.

    Parameters

    • name: string

      The name to be transformed if necessary.

    Returns string

    Name that is guaranteed to be compliant.

npmrc

  • npmrc(): string

otherEntityImports

otherFile

  • otherFile(directory: Directory, relativePath: string, content: string, overwrite: boolean): SourceFile

packageJson

  • packageJson(npmPackageName: string, dependencies: string[], versionInPackageJson: string | undefined, generatorVersion: string): string

packageJson

  • packageJson(npmPackageName: string, versionInPackageJson: string | undefined, generatorVersion: string, description: string, sdkAfterVersionScript: boolean): string
  • Parameters

    • npmPackageName: string
    • versionInPackageJson: string | undefined
    • generatorVersion: string
    • description: string
    • sdkAfterVersionScript: boolean

    Returns string

parameterDescription

parametersInterface

parseActionImport

parseActionImportReturnTypes

parseActions

parseAllServices

parseAssociation

parseAssociationSets

parseBaseMetadata

parseCmdArgs

  • parseCmdArgs(): GeneratorOptions

parseCollectionTypeName

  • parseCollectionTypeName(typeName: string): string

parseComplexTypes

parseComplexTypes

parseComplexTypes

parseComplexTypesBase

parseEdmxFromPath

  • parseEdmxFromPath(edmxPath: PathLike): EdmxMetadataV2 | EdmxMetadataV4

parseEdmxV2

parseEdmxV4

parseEntitySets

parseEntitySets

parseEntitySetsBase

parseEntityType

parseEntityTypes

parseEntityTypes

parseEntityTypesBase

parseEnumTypes

parseFunctionImportReturnTypes

parseFunctionImports

parseFunctionImports

parseFunctionImportsBase

parseFunctions

parseReturnType

parseService

parseSwaggerFromPath

parseType

  • parseType(typeName: string): string
  • deprecated

    since version 1.27.0. Use isEdmType and complexTypeName if you want to extract type names of non Edm types.

    Parameters

    • typeName: string

      Name of the edm type for example "Edm.String" or "Namespace.ComplexType"

    Returns string

    the typename input for Edm types e.g. "Edm.String" or the type without the namesapce.

parseTypeName

  • parseTypeName(typeName: string): string

parseTypeName

  • parseTypeName(typeName: string): string

prefixString

  • prefixString(string: string, prefix?: undefined | string): string
  • Applies a prefix to a string if present.

    Parameters

    • string: string

      The string to be prefixed.

    • Optional prefix: undefined | string

      The optional prefix.

    Returns string

    Prefixed string.

prependPrefix

  • prependPrefix(name: string): string

propertyDescription

Const propertyJsType

  • propertyJsType(type: string): string | undefined

readEdmxFile

readRequestType

readServiceMapping

  • readServiceMapping(options: GeneratorOptions): VdmMapping

readSwaggerFile

readme

readme

requestBuilderClass

  • requestBuilderClass(entity: VdmEntity): ClassDeclarationStructure

requestBuilderSourceFile

responseTransformerFunctionName

Const s4hanaCloudDescription

  • s4hanaCloudDescription(packageName: string): string

serviceMapping

serviceMappingFile

servicePathFromSwagger

shortPropertyDescription

sourceFile

  • sourceFile(directory: Directory, relativePath: string, content: SourceFileStructure, overwrite: boolean): SourceFile

stripCollection

  • stripCollection(name: string): string

stripNamespace

  • stripNamespace(name: string): string

stripNamespace

  • stripNamespace(name: string): string

stripPrefix

  • stripPrefix(name: string): string

swaggerDefinitionForFunctionImport

  • swaggerDefinitionForFunctionImport(originalName: string, httpMethod: string, swaggerMetadata: SwaggerMetadata | undefined): SwaggerPath | undefined

swaggerDefinitionForFunctionImport

transformActionImportBase

transformComplexTypes

transformComplexTypesBase

transformEntitiesV2

transformEntitiesV4

transformEntity

transformEntityBase

transformEnumTypesBase

transformFunctionImportBase

transformFunctionImportBase

transformFunctionImportsV2

transformFunctionImportsV4

tsConfig

  • tsConfig(): string

typedocJson

  • typedocJson(): string

typesForCollection

writeReqeustType