Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @sap/cloud-sdk-generator

@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 programatically. 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)

Helpful Links

Index

Enumerations

Classes

Interfaces

Variables

Functions

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('-')

Const applySuffixOnConflictUnderscore

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

Functions

batchFunction

  • Parameters

    Returns FunctionDeclarationStructure

batchSourceFile

  • Parameters

    Returns SourceFileStructure

builderFunction

  • builderFunction(complexType: VdmComplexType): FunctionDeclarationStructure
  • Parameters

    Returns FunctionDeclarationStructure

changesetFunction

  • Parameters

    Returns FunctionDeclarationStructure

cloudSdkVdmHack

  • cloudSdkVdmHack(name: string): string
  • Parameters

    • name: string

    Returns string

complexTypeImportDeclarations

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

    Returns ImportDeclarationStructure[]

complexTypeInterface

  • complexTypeInterface(complexType: VdmComplexType): InterfaceDeclarationStructure
  • Parameters

    Returns InterfaceDeclarationStructure

complexTypeNamespace

  • complexTypeNamespace(complexType: VdmComplexType): NamespaceDeclarationStructure
  • Parameters

    Returns NamespaceDeclarationStructure

complexTypeSourceFile

  • complexTypeSourceFile(complexType: VdmComplexType): SourceFileStructure
  • Parameters

    Returns SourceFileStructure

copyFile

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

    • fromPath: string
    • toRelativePath: string
    • toDirectory: Directory
    • overwrite: boolean

    Returns void

coreImportDeclaration

  • coreImportDeclaration(namedImports: string[]): ImportDeclarationStructure
  • Parameters

    • namedImports: string[]

    Returns ImportDeclarationStructure

coreNavPropertyFieldTypeImportNames

  • Parameters

    Returns string[]

corePropertyFieldTypeImportNames

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

    Returns string[]

corePropertyTypeImportNames

  • Parameters

    Returns string[]

csn

  • Parameters

    Returns Promise<string>

edmToComplexPropertyType

  • edmToComplexPropertyType(edmType: string): string
  • Parameters

    • edmType: string

    Returns string

edmToFieldType

  • edmToFieldType(edmType: string): string
  • Parameters

    • edmType: string

    Returns string

edmToTsType

  • edmToTsType(edmType: string): string
  • Parameters

    • edmType: string

    Returns string

edmxPaths

  • edmxPaths(input: PathLike): PathLike[]
  • Parameters

    • input: PathLike

    Returns PathLike[]

endWithDot

  • endWithDot(text: string): string
  • Parameters

    • text: string

    Returns string

ensureString

  • ensureString(obj: any): string
  • Parameters

    • obj: any

    Returns string

entityClass

  • Parameters

    Returns ClassDeclarationStructure

entityNamespace

  • Parameters

    Returns NamespaceDeclarationStructure

entitySourceFile

entityTypeForceMandatoryInterface

  • Parameters

    Returns InterfaceDeclarationStructure

entityTypeInterface

  • Parameters

    Returns InterfaceDeclarationStructure

exportStatement

  • Parameters

    Returns VariableStatementStructure

externalImportDeclaration

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

    Returns ImportDeclarationStructure

externalImportDeclarations

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

    Returns ImportDeclarationStructure[]

fieldTypeClass

  • fieldTypeClass(complexType: VdmComplexType): ClassDeclarationStructure
  • Parameters

    Returns ClassDeclarationStructure

forceArray

  • forceArray(obj: any): any[]
  • Parameters

    • obj: any

    Returns any[]

functionImportFunction

functionImportParametersInterface

  • functionImportParametersInterface(functionImport: VdmFunctionImport): InterfaceDeclarationStructure
  • Parameters

    Returns InterfaceDeclarationStructure

functionImportSourceFile

  • Parameters

    Returns SourceFileStructure

generate

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

    • options: GeneratorOptions

    Returns Promise<void | DirectoryEmitResult[]>

generateProject

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

    • options: GeneratorOptions

    Returns Promise<Project | undefined>

generateSourcesForService

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

    Returns Promise<void>

Const genericDescription

  • genericDescription(packageName: string): string
  • Parameters

    • packageName: string

    Returns string

getComplexTypeFieldDescription

  • Parameters

    Returns string

getComplexTypePropertyDescription

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

    Returns string

getEntityDescription

getFunctionDoc

  • getFunctionDoc(description: string, tags: Partial<object>): string
  • Parameters

    • description: string
    • tags: Partial<object>

    Returns string

getLookupDescription

  • Parameters

    Returns string

getNavPropertyDescription

getPropertyDescription

getRequestBuilderDescription

  • getRequestBuilderDescription(entity: VdmEntity): string
  • Parameters

    Returns string

getRoot

  • getRoot(edmx: any): any
  • Parameters

    • edmx: any

    Returns any

getStaticNavPropertyDescription

getStaticPropertyDescription

  • getStaticPropertyDescription(property: VdmProperty): string
  • Parameters

    Returns string

hasComplexTypeProperty

  • hasComplexTypeProperty(properties: VdmProperty[]): boolean
  • Parameters

    Returns boolean

hasEdmTypeProperty

  • hasEdmTypeProperty(properties: VdmProperty[]): boolean
  • Parameters

    Returns boolean

helpfulLinksSection

  • helpfulLinksSection(): string[]
  • Returns string[]

importBatchDeclarations

  • Parameters

    Returns ImportDeclarationStructure[]

importDeclarations

  • importDeclarations(complexType: VdmComplexType): ImportDeclarationStructure[]
  • Parameters

    Returns ImportDeclarationStructure[]

importDeclarations

  • importDeclarations(entity: VdmEntity): ImportDeclarationStructure[]
  • Parameters

    Returns ImportDeclarationStructure[]

importDeclarations

  • Parameters

    Returns ImportDeclarationStructure[]

importDeclarations

  • importDeclarations(entity: VdmEntity): ImportDeclarationStructure[]
  • Parameters

    Returns ImportDeclarationStructure[]

indexFile

  • Parameters

    Returns SourceFileStructure

inputPaths

  • Parameters

    • input: PathLike
    • useSwagger: boolean

    Returns ServiceDefinitionPaths[]

isCreatable

  • isCreatable(entity: any): boolean
  • Parameters

    • entity: any

    Returns boolean

isDeletable

  • isDeletable(entity: any): boolean
  • Parameters

    • entity: any

    Returns boolean

isFilterable

  • isFilterable(property: any): boolean
  • Parameters

    • property: any

    Returns boolean

isNullableParameter

  • isNullableParameter(parameter: any): boolean
  • Parameters

    • parameter: any

    Returns boolean

isNullableProperty

  • isNullableProperty(property: any): boolean
  • Parameters

    • property: any

    Returns boolean

isSortable

  • isSortable(property: any): boolean
  • Parameters

    • property: any

    Returns boolean

isUpdatable

  • isUpdatable(entity: any): boolean
  • Parameters

    • entity: any

    Returns boolean

linkClass

  • Parameters

    Returns string

mergeImportDeclarations

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

    • importDeclarations: ImportDeclarationStructure[]

    Returns ImportDeclarationStructure[]

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
  • Returns string

otherEntityImports

  • Parameters

    Returns ImportDeclarationStructure[]

otherFile

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

    • directory: Directory
    • relativePath: string
    • content: string
    • overwrite: boolean

    Returns SourceFile

packageJson

  • packageJson(npmPackageName: string, dependencies: string[], version: string): string
  • Parameters

    • npmPackageName: string
    • dependencies: string[]
    • version: string

    Returns string

packgeJson

  • packgeJson(npmPackageName: string, version: string, description: string, sdkAfterVersionScript: boolean): string
  • Parameters

    • npmPackageName: string
    • version: string
    • description: string
    • sdkAfterVersionScript: boolean

    Returns string

parseAllServices

  • Parameters

    • options: GeneratorOptions

    Returns VdmServiceMetadata[]

parseCmdArgs

  • parseCmdArgs(): GeneratorOptions
  • Returns GeneratorOptions

parseEdmxFromPath

  • Parameters

    • edmxPath: PathLike

    Returns EdmxMetadata

parseService

parseSwaggerFromPath

  • Parameters

    • swaggerPath: PathLike

    Returns SwaggerMetadata

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
  • Parameters

    • name: string

    Returns string

readRequestType

  • Parameters

    Returns TypeAliasDeclarationStructure

readServiceMapping

  • readServiceMapping(options: GeneratorOptions): VdmMapping
  • Parameters

    • options: GeneratorOptions

    Returns VdmMapping

readme

  • Parameters

    Returns string

readme

  • Parameters

    Returns string

requestBuilderClass

  • requestBuilderClass(entity: VdmEntity): ClassDeclarationStructure
  • Parameters

    Returns ClassDeclarationStructure

requestBuilderSourceFile

  • requestBuilderSourceFile(entity: VdmEntity): SourceFileStructure
  • Parameters

    Returns SourceFileStructure

responseTransformerFunctionName

  • Parameters

    Returns string

Const s4hanaCloudDescription

  • s4hanaCloudDescription(packageName: string): string
  • Parameters

    • packageName: string

    Returns string

serviceMapping

serviceMappingFile

  • Parameters

    Returns string

sourceFile

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

    • directory: Directory
    • relativePath: string
    • content: SourceFileStructure
    • overwrite: boolean

    Returns SourceFile

stripCollection

  • stripCollection(name: string): string
  • Parameters

    • name: string

    Returns string

stripPrefix

  • stripPrefix(name: string): string
  • Parameters

    • name: string

    Returns string

tsConfig

  • tsConfig(): string
  • Returns string

typedocJson

  • typedocJson(): string
  • Returns string

writeReqeustType

  • Parameters

    Returns TypeAliasDeclarationStructure