Skip to content

Commit

Permalink
#1763: correctly cache transactionalEmail during journey deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Oct 1, 2024
1 parent 7542295 commit b636ecd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Journey.d.ts.map

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

2 changes: 1 addition & 1 deletion lib/metadataTypes/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ class Event extends MetadataType {
if (this.sfObjects.objectFields[objectAPIName] || objectAPIName === 'Common') {
return;
}
Util.logger.info(
Util.logger.verbose(
Util.getGrayMsg(' - Caching Fields for Salesforce Object ' + objectAPIName)
);

Expand Down
23 changes: 20 additions & 3 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,31 @@ class Journey extends MetadataType {
/**
* Deploys metadata - merely kept here to be able to print {@link Util.logBeta} once per deploy
*
* @param {MetadataTypeMap} metadata metadata mapped by their keyField
* @param {MetadataTypeMap} metadataMap metadata mapped by their keyField
* @param {string} deployDir directory where deploy metadata are saved
* @param {string} retrieveDir directory where metadata after deploy should be saved
* @returns {Promise.<MetadataTypeMap>} Promise of keyField => metadata map
*/
static async deploy(metadata, deployDir, retrieveDir) {
static async deploy(metadataMap, deployDir, retrieveDir) {
Util.logBeta(this.definition.type);
return super.deploy(metadata, deployDir, retrieveDir);

let needTransactionalEmail = false;
for (const key in metadataMap) {
if (metadataMap[key].definitionType == 'Transactional') {
needTransactionalEmail = true;
break;
}
}
if (needTransactionalEmail && !cache.getCache()?.transactionalEmail) {
// ! interaction and transactionalEmail both link to each other. caching transactionalEmail here "manually", assuming that it's quicker than the other way round
Util.logger.info(' - Caching dependent Metadata: transactionalEmail');
TransactionalEmail.buObject = this.buObject;
TransactionalEmail.client = this.client;
TransactionalEmail.properties = this.properties;
const result = await TransactionalEmail.retrieveForCache();
cache.setMetadata('transactionalEmail', result.metadata);
}
return super.deploy(metadataMap, deployDir, retrieveDir);
}

/**
Expand Down

0 comments on commit b636ecd

Please sign in to comment.