Skip to content

Commit

Permalink
#1522: allow specifying multiple markets at once in buildTemplate, bu…
Browse files Browse the repository at this point in the history
…ildDefinition and build
  • Loading branch information
JoernBerkefeld committed Aug 28, 2024
1 parent 0591d17 commit 66091a1
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 52 deletions.
8 changes: 4 additions & 4 deletions @types/lib/Builder.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/Builder.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions @types/lib/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 26 additions & 10 deletions lib/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ saved
* @param {string} businessUnit references credentials from properties.json
* @param {string} selectedType supported metadata type
* @param {string[]} keyArr customerkey of the metadata
* @param {string} market market localizations
* @param {string[]} marketArr market localizations
* @returns {Promise.<MultiMetadataTypeList>} -
*/
static async buildTemplate(businessUnit, selectedType, keyArr, market) {
static async buildTemplate(businessUnit, selectedType, keyArr, marketArr) {
const properties = await config.getProperties();
if (!(await config.checkProperties(properties))) {
return null;
Expand All @@ -119,12 +119,20 @@ saved
);
return;
}
/** @type {TemplateMap} */
const templateVariables = {};
for (const market of marketArr) {
if (Util.checkMarket(market, properties)) {
Object.assign(templateVariables, properties.markets[market]);
} else {
// do not execute the rest of this method if a market was invalid
return;
}
}
const buObject = await Cli.getCredentialObject(properties, businessUnit);
if (buObject !== null) {
const builder = new Builder(properties, buObject);
if (Util.checkMarket(market, properties)) {
return builder._buildTemplate(selectedType, keyArr, properties.markets[market]);
}
return builder._buildTemplate(selectedType, keyArr, templateVariables);
}
}

Expand Down Expand Up @@ -175,10 +183,10 @@ saved
* @param {string} businessUnit references credentials from properties.json
* @param {string} selectedType supported metadata type
* @param {string[]} nameArr name of the metadata
* @param {string} market market localizations
* @param {string[]} marketArr market localizations
* @returns {Promise.<MultiMetadataTypeList>} -
*/
static async buildDefinition(businessUnit, selectedType, nameArr, market) {
static async buildDefinition(businessUnit, selectedType, nameArr, marketArr) {
const properties = await config.getProperties();
if (!(await config.checkProperties(properties))) {
return null;
Expand All @@ -192,12 +200,20 @@ saved
);
return;
}
/** @type {TemplateMap} */
const templateVariables = {};
for (const market of marketArr) {
if (Util.checkMarket(market, properties)) {
Object.assign(templateVariables, properties.markets[market]);
} else {
// do not execute the rest of this method if a market was invalid
return;
}
}
const buObject = await Cli.getCredentialObject(properties, businessUnit);
if (buObject !== null) {
const builder = new Builder(properties, buObject);
if (Util.checkMarket(market, properties)) {
return builder._buildDefinition(selectedType, nameArr, properties.markets[market]);
}
return builder._buildDefinition(selectedType, nameArr, templateVariables);
}
}

Expand Down
Loading

0 comments on commit 66091a1

Please sign in to comment.