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/api/

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

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

  • complexTypeSourceFile(complexType: VdmComplexType): SourceFileStructure

copyFile

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

coreImportDeclaration

  • coreImportDeclaration(namedImports: string[]): ImportDeclarationStructure

coreNavPropertyFieldTypeImportNames

corePropertyFieldTypeImportNames

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

corePropertyTypeImportNames

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 | DirectoryEmitResult[]>

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(complexType: VdmComplexType): ImportDeclarationStructure[]

importDeclarations

  • importDeclarations(entity: VdmEntity): ImportDeclarationStructure[]

importDeclarations

importDeclarations

  • importDeclarations(entity: VdmEntity): ImportDeclarationStructure[]

indexFile

inputPaths

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

linkClass

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

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

parseCmdArgs

  • parseCmdArgs(): GeneratorOptions

parseEdmxFromPath

parseService

parseSwaggerFromPath

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

  • requestBuilderSourceFile(entity: VdmEntity): SourceFileStructure

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

stripPrefix

  • stripPrefix(name: string): string

tsConfig

  • tsConfig(): string

typedocJson

  • typedocJson(): string

writeReqeustType