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)

Api documentation

https://sap.github.io/cloud-sdk/docs/js/api-reference-js-ts

Helpful Links

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

EdmxEntitySet

EdmxEntitySet: EdmxEntitySetBase

Variables

Const VALUE_IS_UNDEFINED

VALUE_IS_UNDEFINED: "VALUE_IS_UNDEFINED" = "VALUE_IS_UNDEFINED"

Const applyPrefixOnJsConfictFunctionImports

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

Const applyPrefixOnJsConfictParam

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

Const applySuffixOnConflictDash

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

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

Const applySuffixOnConflictUnderscore

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

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

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.

batchFunction

batchSourceFile

builderFunction

  • builderFunction(complexType: VdmComplexType): FunctionDeclarationStructure

changesetFunction

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

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

entityNamespace

entitySourceFile

entityTypeForceMandatoryInterface

entityTypeInterface

exportStatement

externalImportDeclaration

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

externalImportDeclarations

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

fieldTypeClass

  • fieldTypeClass(complexType: VdmComplexType): ClassDeclarationStructure

forceArray

  • forceArray(obj: any): any[]

functionImportFunction

functionImportParametersInterface

  • functionImportParametersInterface(functionImport: VdmFunctionImport): InterfaceDeclarationStructure

functionImportSourceFile

generate

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

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

getLookupDescription

getNavPropertyDescription

getPropertyDescription

getRequestBuilderDescription

  • getRequestBuilderDescription(entity: VdmEntity): string

getRoot

  • getRoot(edmx: any): any

getStaticNavPropertyDescription

getStaticPropertyDescription

  • getStaticPropertyDescription(property: VdmProperty): string

hasComplexTypeProperty

  • hasComplexTypeProperty(properties: VdmProperty[]): boolean

hasEdmTypeProperty

  • hasEdmTypeProperty(properties: VdmProperty[]): boolean

helpfulLinksSection

  • helpfulLinksSection(): string[]

importBatchDeclarations

importDeclarations

importDeclarations

importDeclarations

importDeclarations

indexFile

inputPaths

isCollection

  • isCollection(typeName: 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

isV4Metadata

joinAssociationMetadata

joinEntityMetadata

linkClass

mergeImportDeclarations

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

    • importDeclarations: ImportDeclarationStructure[]

    Returns ImportDeclarationStructure[]

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

parseAllServices

parseBaseMetadata

parseCmdArgs

  • parseCmdArgs(): GeneratorOptions

parseComplexTypes

parseEdmxFromPath

  • parseEdmxFromPath(edmxPath: PathLike): EdmxMetadataV2 | EdmxMetadataV4

parseEdmxV2

parseEdmxV4

parseEntityTypes

parseFunctionImportsBase

parseReturnType

parseService

parseSwaggerFromPath

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

readRequestType

readServiceMapping

  • readServiceMapping(options: GeneratorOptions): VdmMapping

readme

readme

requestBuilderClass

  • requestBuilderClass(entity: VdmEntity): ClassDeclarationStructure

requestBuilderSourceFile

responseTransformerFunctionName

Const s4hanaCloudDescription

  • s4hanaCloudDescription(packageName: string): string

serviceMapping

serviceMappingFile

sourceFile

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

stripCollection

  • stripCollection(name: string): string

stripNamespace

  • stripNamespace(name: string): string

stripPrefix

  • stripPrefix(name: string): string

swaggerDefinitionForFunctionImport

transformComplexTypes

transformEntitiesV2

transformEntitiesV4

transformEntity

transformFunctionImportBase

transformFunctionImportsV2

transformFunctionImportsV4

tsConfig

  • tsConfig(): string

typedocJson

  • typedocJson(): string

writeReqeustType