-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f8571a
commit 6692329
Showing
3 changed files
with
35 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,3 @@ export interface AbapAnnotation { | |
}; | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import { DataElement, DataElementInput, Domain, DomainInput } from "@abapify/components"; | ||
import { dset } from "dset"; | ||
import { | ||
DataElement, | ||
DataElementInput, | ||
Domain, | ||
DomainInput, | ||
} from '@abapify/components'; | ||
import { dset } from 'dset'; | ||
|
||
export class DdicFactory { | ||
static dataElement(input: DataElementInput): DataElement | Array<DataElement | Domain> { | ||
static dataElement( | ||
input: DataElementInput | ||
): DataElement | Array<DataElement | Domain> { | ||
const result: Array<DataElement | Domain> = [new DataElement(input)]; | ||
|
||
const result: Array<DataElement | Domain> = [new DataElement(input)]; | ||
|
||
if ( | ||
'domain' in input && | ||
typeof input.domain === 'object' | ||
) { | ||
// inherit name from data element if not specified | ||
if (!input.domain.name) { | ||
input.domain.name = input.name; | ||
} | ||
//inherit description from data element if not specified | ||
if (!input.domain.header?.description) { | ||
dset(input.domain, 'header.description', input.description); | ||
} | ||
result.push(DdicFactory.domain(input.domain)); | ||
} | ||
|
||
return result; | ||
} | ||
static domain(input: DomainInput): Domain { | ||
return new Domain(input); | ||
if ('domain' in input && typeof input.domain === 'object') { | ||
// inherit name from data element if not specified | ||
if (!input.domain.name) { | ||
input.domain.name = input.name; | ||
} | ||
//inherit description from data element if not specified | ||
if (!input.domain.header?.description) { | ||
dset(input.domain, 'header.description', input.description); | ||
} | ||
result.push(DdicFactory.domain(input.domain)); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
static domain(input: DomainInput): Domain { | ||
return new Domain(input); | ||
} | ||
} |