Skip to content

Commit

Permalink
Merge pull request #1179 from Accenture/develop
Browse files Browse the repository at this point in the history
release 6.0.2
  • Loading branch information
JoernBerkefeld committed Jan 18, 2024
2 parents 592dbb7 + b083081 commit 1323b23
Show file tree
Hide file tree
Showing 42 changed files with 1,013 additions and 264 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ body:
label: Version
description: What version of our software are you running? (mcdev --version)
options:
- 6.0.2
- 6.0.1
- 6.0.0
- 5.3.0
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.markdownlint": true
"source.fixAll.eslint": "explicit",
"source.fixAll.markdownlint": "explicit"
},
"editor.formatOnSave": true,
"files.associations": {
Expand Down
34 changes: 11 additions & 23 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,6 @@ MessageSendActivity MetadataType
* [.deleteByKey(customerKey)](#EmailSend.deleteByKey) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.preDeployTasks(metadata)](#EmailSend.preDeployTasks) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItem&gt;</code>
* [.postRetrieveTasks(metadata)](#EmailSend.postRetrieveTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.parseMetadata(metadata)](#EmailSend.parseMetadata) ⇒ <code>TYPE.MetadataTypeItem</code>

<a name="EmailSend.retrieve"></a>

Expand Down Expand Up @@ -2549,18 +2548,6 @@ manages post retrieve steps
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single query |

<a name="EmailSend.parseMetadata"></a>

### EmailSend.parseMetadata(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
parses retrieved Metadata before saving

**Kind**: static method of [<code>EmailSend</code>](#EmailSend)
**Returns**: <code>TYPE.MetadataTypeItem</code> - Array with one metadata object and one sql string

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single query activity definition |

<a name="Event"></a>

## Event ⇐ [<code>MetadataType</code>](#MetadataType)
Expand Down Expand Up @@ -5645,8 +5632,8 @@ TransactionalSMS MetadataType
* [.postDeleteTasks(customerKey)](#TransactionalSMS.postDeleteTasks) ⇒ <code>void</code>
* [.preDeployTasks(metadata, deployDir)](#TransactionalSMS.preDeployTasks) ⇒ <code>Promise.&lt;TYPE.MetadataTypeItem&gt;</code>
* [._mergeCode(metadata, deployDir, [templateName])](#TransactionalSMS._mergeCode) ⇒ <code>Promise.&lt;string&gt;</code>
* [.postRetrieveTasks(metadata)](#TransactionalSMS.postRetrieveTasks) ⇒ <code>TYPE.CodeExtractItem</code>
* [.prepExtractedCode(metadataScript)](#TransactionalSMS.prepExtractedCode) ⇒ <code>Object</code>
* [.postRetrieveTasks(metadata)](#TransactionalSMS.postRetrieveTasks) ⇒ <code>Promise.&lt;TYPE.CodeExtractItem&gt;</code>
* [.prepExtractedCode(metadataScript)](#TransactionalSMS.prepExtractedCode) ⇒ <code>Promise.&lt;{fileExt:string, code:string}&gt;</code>
* [.buildDefinitionForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#TransactionalSMS.buildDefinitionForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
* [.buildTemplateForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#TransactionalSMS.buildTemplateForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
* [._buildForNested(templateDir, targetDir, metadata, templateVariables, templateName, mode)](#TransactionalSMS._buildForNested) ⇒ <code>Promise.&lt;Array.&lt;Array.&lt;string&gt;&gt;&gt;</code>
Expand Down Expand Up @@ -5693,23 +5680,23 @@ helper for [preDeployTasks](#TransactionalSMS.preDeployTasks) that loads extract

<a name="TransactionalSMS.postRetrieveTasks"></a>

### TransactionalSMS.postRetrieveTasks(metadata) ⇒ <code>TYPE.CodeExtractItem</code>
### TransactionalSMS.postRetrieveTasks(metadata) ⇒ <code>Promise.&lt;TYPE.CodeExtractItem&gt;</code>
manages post retrieve steps

**Kind**: static method of [<code>TransactionalSMS</code>](#TransactionalSMS)
**Returns**: <code>TYPE.CodeExtractItem</code> - Array with one metadata object and one ssjs string
**Returns**: <code>Promise.&lt;TYPE.CodeExtractItem&gt;</code> - Array with one metadata object and one ssjs string

| Param | Type | Description |
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single item |

<a name="TransactionalSMS.prepExtractedCode"></a>

### TransactionalSMS.prepExtractedCode(metadataScript) ⇒ <code>Object</code>
### TransactionalSMS.prepExtractedCode(metadataScript) ⇒ <code>Promise.&lt;{fileExt:string, code:string}&gt;</code>
helper for [postRetrieveTasks](#TransactionalSMS.postRetrieveTasks) and [_buildForNested](#TransactionalSMS._buildForNested)

**Kind**: static method of [<code>TransactionalSMS</code>](#TransactionalSMS)
**Returns**: <code>Object</code> - returns found extension and file content
**Returns**: <code>Promise.&lt;{fileExt:string, code:string}&gt;</code> - returns found extension and file content

| Param | Type | Description |
| --- | --- | --- |
Expand Down Expand Up @@ -6637,7 +6624,7 @@ File extends fs-extra. It adds logger and util methods for file handling
* [.normalizePath(denormalizedPath)](#File.normalizePath) ⇒ <code>string</code>
* [.writeJSONToFile(directory, filename, content)](#File.writeJSONToFile) ⇒ <code>Promise</code>
* [.writePrettyToFile(directory, filename, filetype, content, [templateVariables])](#File.writePrettyToFile) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [._beautify_beautyAmp(content)](#File._beautify_beautyAmp) ⇒ <code>string</code>
* [.beautify_beautyAmp(content, formatHTML)](#File.beautify_beautyAmp) ⇒ <code>Promise.&lt;string&gt;</code>
* [._beautify_prettier(directory, filename, filetype, content)](#File._beautify_prettier) ⇒ <code>Promise.&lt;string&gt;</code>
* [.writeToFile(directory, filename, filetype, content, [encoding])](#File.writeToFile) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.readJSONFile(directory, filename, sync, cleanPath)](#File.readJSONFile) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>object</code> \| <code>void</code>
Expand Down Expand Up @@ -6739,17 +6726,18 @@ Saves beautified files in the local file system. Will create the parent director
| content | <code>string</code> | filecontent |
| [templateVariables] | <code>TYPE.TemplateMap</code> | templating variables to be replaced in the metadata |

<a name="File._beautify_beautyAmp"></a>
<a name="File.beautify_beautyAmp"></a>

### File.\_beautify\_beautyAmp(content) ⇒ <code>string</code>
### File.beautify\_beautyAmp(content, formatHTML) ⇒ <code>Promise.&lt;string&gt;</code>
helper for [writePrettyToFile](#File.writePrettyToFile), applying beautyAmp onto given stringified content

**Kind**: static method of [<code>File</code>](#File)
**Returns**: <code>string</code> - original string on error; formatted string on success
**Returns**: <code>Promise.&lt;string&gt;</code> - original string on error; formatted string on success

| Param | Type | Description |
| --- | --- | --- |
| content | <code>string</code> | filecontent |
| formatHTML | <code>boolean</code> | should we format HTML or not via prettier included in beautyAmp |

<a name="File._beautify_prettier"></a>

Expand Down
5 changes: 3 additions & 2 deletions lib/Retriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ class Retriever {
const subTypeArr = deployOrder[type];
// if types were added by getMetadataHierachy() for caching, make sure the key-list is set to [null] for them which will retrieve all
// if we have a subtype, we need to find the correct key-list for it
typeKeyMap[type] = typeKeyMap[type] ||
typeKeyMap[Object.keys(typeKeyMap).find((k) => k.startsWith(type + '-'))] || [null];
typeKeyMap[type] ||= typeKeyMap[
Object.keys(typeKeyMap).find((k) => k.startsWith(type + '-'))
] || [null];

// add client to metadata process class instead of passing every time
MetadataTypeInfo[type].client = auth.getSDK(this.buObject);
Expand Down
27 changes: 9 additions & 18 deletions lib/metadataTypes/DataExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,14 @@ class DataExtension extends MetadataType {
*/
static async upsert(metadataMap) {
// get existing DE-fields for DE-keys in deployment package to properly handle add/update/delete of fields
const fieldOptions = {};
for (const key of Object.keys(metadataMap)) {
fieldOptions.filter = fieldOptions.filter
? {
leftOperand: {
leftOperand: 'DataExtension.CustomerKey',
operator: 'equals',
rightOperand: key,
},
operator: 'OR',
rightOperand: fieldOptions.filter,
}
: {
leftOperand: 'DataExtension.CustomerKey',
operator: 'equals',
rightOperand: key,
};
}
// we need to use IN here because it would fail otherwise if we try to deploy too many DEs at the same time
const fieldOptions = {
filter: {
leftOperand: 'DataExtension.CustomerKey',
operator: 'IN',
rightOperand: Object.keys(metadataMap),
},
};
Util.logger.info(` - Caching dependent Metadata: dataExtensionField`);
await this.#attachFields(metadataMap, fieldOptions);

Expand Down Expand Up @@ -868,6 +858,7 @@ class DataExtension extends MetadataType {
static async #attachFields(metadata, fieldOptions, additionalFields) {
const fieldsObj = await this._retrieveFields(fieldOptions, additionalFields);
const fieldKeys = Object.keys(fieldsObj);

// add fields to corresponding DE
for (const key of fieldKeys) {
const field = fieldsObj[key];
Expand Down
76 changes: 48 additions & 28 deletions lib/metadataTypes/EmailSend.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class EmailSend extends MetadataType {
metadata.IsPlatformObject = false;
// folder
super.setFolderId(metadata);
// email
metadata.Email = {};
// email; in case we still have Email.ID, keep it but warn
metadata.Email ||= {};
if (metadata.r__email_Name) {
// classic
metadata.Email.ID = cache.searchForField('email', metadata.r__email_Name, 'Name', 'ID');
Expand Down Expand Up @@ -131,6 +131,30 @@ class EmailSend extends MetadataType {
delete metadata.r__assetMessage_Key;
delete metadata.r__assetMessage_Name;
}
} else if (metadata.Email.ID) {
Util.logger.warn(
` - ${this.definition.type} ${metadata[this.definition.nameField]} (${
metadata[this.definition.keyField]
}): Email.ID was provided manually in your deployment file. We recommend using r__assetMessage_Key instead.`
);
try {
// content builder - test only
cache.searchForField(
'asset',
metadata.Email.ID,
'legacyData.legacyId',
'customerKey'
);
} catch {
try {
// classic - test only
cache.searchForField('email', metadata.Email.ID, 'ID', 'Name');
} catch {
throw new Error(
` ☇ skipping ${this.definition.type} ${metadata.Name} (${metadata.CustomerKey}): Could not find email with ID ${metadata.Email.ID} in Content Builder or Classic Emails.`
);
}
}
}
// Target Audience DataExtension
// normalize first because this can be an array
Expand Down Expand Up @@ -189,15 +213,6 @@ class EmailSend extends MetadataType {
* @returns {TYPE.MetadataTypeItem} Array with one metadata object and one query string
*/
static postRetrieveTasks(metadata) {
return this.parseMetadata(metadata);
}
/**
* parses retrieved Metadata before saving
*
* @param {TYPE.MetadataTypeItem} metadata a single query activity definition
* @returns {TYPE.MetadataTypeItem} Array with one metadata object and one sql string
*/
static parseMetadata(metadata) {
// remove IsPlatformObject, always has to be 'false'
delete metadata.IsPlatformObject;
// folder
Expand All @@ -206,35 +221,40 @@ class EmailSend extends MetadataType {
// email
if (metadata.Email?.ID) {
try {
// classic
const classicEmail = cache.searchForField('email', metadata.Email.ID, 'ID', 'Name');
metadata.r__email_Name = classicEmail;
// content builder
const contentBuilderEmailName = cache.searchForField(
'asset',
metadata.Email.ID,
'legacyData.legacyId',
'name'
);
metadata.r__assetMessage_Name = contentBuilderEmailName;
const contentBuilderEmailKey = cache.searchForField(
'asset',
metadata.Email.ID,
'legacyData.legacyId',
'customerKey'
);
metadata.r__assetMessage_Key = contentBuilderEmailKey;
delete metadata.Email;
} catch {
try {
// content builder
const contentBuilderEmailName = cache.searchForField(
'asset',
metadata.Email.ID,
'legacyData.legacyId',
'name'
);
metadata.r__assetMessage_Name = contentBuilderEmailName;
const contentBuilderEmailKey = cache.searchForField(
'asset',
// classic
const classicEmail = cache.searchForField(
'email',
metadata.Email.ID,
'legacyData.legacyId',
'customerKey'
'ID',
'Name'
);
metadata.r__assetMessage_Key = contentBuilderEmailKey;
metadata.r__email_Name = classicEmail;
delete metadata.Email;
} catch {
Util.logger.warn(
` - ${this.definition.type} ${metadata[this.definition.nameField]} (${
metadata[this.definition.keyField]
}): Could not find email with ID ${
metadata.Email.ID
} in Classic nor in Content Builder.`
} Content Builder or Classic Emails.`
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ class Journey extends MetadataType {
'mobileKeyword',
activity.configurationArguments.nextKeywordId,
'id',
'keyword'
'c__codeKeyword'
);
delete activity.configurationArguments.nextKeywordId;
}
Expand Down Expand Up @@ -853,7 +853,7 @@ class Journey extends MetadataType {
activity.configurationArguments.nextKeywordId = cache.searchForField(
'mobileKeyword',
activity.configurationArguments.c__next_mobileKeyword,
'keyword',
'c__codeKeyword',
'id'
);
delete activity.configurationArguments.c__next_mobileKeyword;
Expand Down
Loading

0 comments on commit 1323b23

Please sign in to comment.