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

EdmxComplexType

EdmxEntitySet

EdmxEntitySet: EdmxEntitySetBase
deprecated

Since version 1.25.0 due to major generator refactoring.

EdmxEntityType

EdmxEntityType

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

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

complexTypeImportDeclarations

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

complexTypeInterface

  • complexTypeInterface(complexType: VdmComplexType): InterfaceDeclarationStructure

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 | undefined

edmxPaths

  • edmxPaths(input: PathLike): PathLike[]

endWithDot

  • endWithDot(text: string): string

ensureString

  • ensureString(obj: any): string

entityClass

entityDescription

entityNamespace

entitySourceFile

entityTypeForceMandatoryInterface

entityTypeInterface

exportStatement

externalImportDeclaration

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

externalImportDeclarations

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

fieldTypeClass

  • fieldTypeClass(complexType: VdmComplexType): ClassDeclarationStructure

filterUnknownEdmTypes

forceArray

  • forceArray(obj: any): any[]

functionImportDescription

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

functionImportFunction

functionImportParametersInterface

  • functionImportParametersInterface(functionImport: VdmFunctionImport): InterfaceDeclarationStructure

functionImportSourceFile

generate

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

generateComplexTypesV2

generateComplexTypesV4

generateEntitiesV2

generateEntitiesV4

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

getComplexTypeFieldDescription

getComplexTypePropertyDescription

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

getEntityDescription

getFunctionDoc

getGenericParameters

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

getLookupDescription

getNavPropertyDescription

getPropertyDescription

getRequestBuilderDescription

  • getRequestBuilderDescription(entity: VdmEntity): string

getRoot

  • getRoot(edmx: any): any

getServiceEntitiesV2

getServiceEntitiesV4

getServicePath

getStaticNavPropertyDescription

getStaticPropertyDescription

  • getStaticPropertyDescription(property: VdmProperty): string

hasComplexTypeProperty

  • hasComplexTypeProperty(properties: VdmProperty[]): boolean

hasEdmTypeProperty

  • hasEdmTypeProperty(properties: VdmProperty[]): boolean

helpfulLinksSection

  • helpfulLinksSection(): string[]

importBatchDeclarations

importDeclarations

importDeclarations

importDeclarations

importDeclarations

includeFactoryName

indexFile

inputPaths

isCollection

  • isCollection(typeName: string): boolean

isCollectionType

  • isCollectionType(typeName: string): boolean

isComplexType

  • isComplexType(type: string): boolean

isCreatable

  • isCreatable(entity: any): boolean

isDeletable

  • isDeletable(entity: any): 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

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

joinEntityTypes

joinTypeWithBaseType

  • joinTypeWithBaseType<T>(type: T, types: T[], joinTypes: (type: T, baseType: T) => T): T
  • Recursively adds the base type data to the current type

    Type parameters

    Parameters

    • type: T

      An EDMX type that can have a base type (e. g. EntityType or ComplexType)

    • types: T[]

      All parsed EDMX types

    • joinTypes: (type: T, baseType: T) => T

      Function to ultimatively join types

        • (type: T, baseType: T): T
        • Parameters

          • type: T
          • baseType: T

          Returns T

    Returns T

    The enriched type (type + basetype)

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

parseAllServices

parseAssociation

parseAssociationSets

parseBaseMetadata

parseCmdArgs

  • parseCmdArgs(): GeneratorOptions

parseComplexTypes

parseComplexTypes

parseComplexTypes

parseComplexTypesBase

parseEdmxFromPath

  • parseEdmxFromPath(edmxPath: PathLike): EdmxMetadataV2 | EdmxMetadataV4

parseEdmxV2

parseEdmxV4

parseEntitySets

parseEntitySets

parseEntitySetsBase

parseEntityType

parseEntityTypes

parseEntityTypes

parseEntityTypesBase

parseEnumTypes

parseFunctionImports

parseFunctionImports

parseFunctionImportsBase

parseFunctions

parseReturnType

parseReturnTypes

parseService

parseSwaggerFromPath

parseType

  • parseType(type: string): string

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

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

transformComplexTypes

transformComplexTypesBase

transformEntitiesV2

transformEntitiesV4

transformEntity

transformEntityBase

transformFunctionImportBase

transformFunctionImportBase

transformFunctionImportsV2

transformFunctionImportsV4

tsConfig

  • tsConfig(): string

typedocJson

  • typedocJson(): string

writeReqeustType