Skip to content

Commit

Permalink
Merge branch 'release/5.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteenbeek committed Jul 29, 2021
2 parents f908a2c + 978ee36 commit 8e80e60
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hso/d365-cli",
"version": "5.2.2",
"version": "5.3.0",
"author": "HSO Innovation <[email protected]> (http://www.hso.com)",
"description": "HSO D365 Command Line Interface",
"repository": {
Expand Down
15 changes: 14 additions & 1 deletion src/generator/Enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class Enum {
private async writeEnumFile(): Promise<void> {
await this.log(`Generating ${this.entityName}.enum.ts<br/>`);
const enumAttributeNames = await this.getAttributeNamesEnumString();
const navigationPropertyNames = await this.getNavigationPropertyNamesString();
const enumStrings = await this.getEnumStrings();
const enumFilepath = `src/${this.entityName}/${this.entityName}.enum.ts`;
shell.cp('-r', `${__dirname}/Entity/Entity.enum.ts`, `src/${this.entityName}`);
Expand All @@ -31,7 +32,19 @@ export class Enum {
shell.exec(`git add ${enumFilepath}`);
const fileData = String(fs.readFileSync(enumFilepath));
await this.log(`Generated ${this.entityName}.enum.ts<br/>`);
shell.ShellString(fileData + enumAttributeNames + enumStrings).to(enumFilepath);
shell.ShellString(fileData + enumAttributeNames + navigationPropertyNames + enumStrings).to(enumFilepath);
}

private async getNavigationPropertyNamesString(): Promise<string> {
let navigationPropertiesString = '';
const manyToOneMetadatas = await NodeApi.getManyToOneMetadatas(this.entityLogicalName, this.bearer);
navigationPropertiesString += `export enum ${this.entityName}NavigationPropertyNames {\n`;
for (const relation of manyToOneMetadatas) {
const {ReferencingEntityNavigationPropertyName} = relation;
navigationPropertiesString += ` ${Enum.capitalize(ReferencingEntityNavigationPropertyName)} = '${ReferencingEntityNavigationPropertyName}',\n`;
}
navigationPropertiesString += `}\n`;
return navigationPropertiesString;
}

private async getAttributeNamesEnumString(): Promise<string> {
Expand Down

0 comments on commit 8e80e60

Please sign in to comment.