Skip to content

Commit

Permalink
Merge pull request #719 from Accenture/develop
Browse files Browse the repository at this point in the history
4.3.2
  • Loading branch information
JoernBerkefeld authored Feb 7, 2023
2 parents 2b27b07 + c021c19 commit 4f5bfe1
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 144 deletions.
14 changes: 14 additions & 0 deletions .fork/custom-commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"name": "Create PR to develop branch",
"target": "ref",
"refTargets": [
"localbranch",
"remotebranch"
],
"action": {
"type": "url",
"url": "https://github.com/Accenture/sfmc-devtools/compare/develop...$shortname?expand=1"
}
}
]
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:
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.1
Expand Down
1 change: 1 addition & 0 deletions boilerplate/gitignore-template
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules/
/template/
**/QueryStudioResults at*
.mcdev-auth.json
*.error.log
37 changes: 0 additions & 37 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,7 @@ MessageSendActivity MetadataType
* [AccountUser](#AccountUser)[<code>MetadataType</code>](#MetadataType)
* [.retrieve(retrieveDir, _, [__], [key])](#AccountUser.retrieve) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.retrieveChangelog()](#AccountUser.retrieveChangelog) ⇒ <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code>
* [.timeSinceDate(date)](#AccountUser.timeSinceDate) ⇒ <code>number</code>
* [.getBuName(id)](#AccountUser.getBuName) ⇒ <code>string</code>
* [.document([metadata])](#AccountUser.document) ⇒ <code>Promise.&lt;void&gt;</code>
* [._generateDocMd(users, type, columnsToPrint)](#AccountUser._generateDocMd) ⇒ <code>string</code>
* [.postRetrieveTasks(metadata)](#AccountUser.postRetrieveTasks) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.parseMetadata(metadata)](#AccountUser.parseMetadata) ⇒ <code>TYPE.MetadataTypeItem</code>

Expand All @@ -765,28 +762,6 @@ Retrieves SOAP based metadata of metadata type into local filesystem. executes c

**Kind**: static method of [<code>AccountUser</code>](#AccountUser)
**Returns**: <code>Promise.&lt;TYPE.MetadataTypeMapObj&gt;</code> - Promise of metadata
<a name="AccountUser.timeSinceDate"></a>

### AccountUser.timeSinceDate(date) ⇒ <code>number</code>
**Kind**: static method of [<code>AccountUser</code>](#AccountUser)
**Returns**: <code>number</code> - time difference

| Param | Type | Description |
| --- | --- | --- |
| date | <code>string</code> | first date |

<a name="AccountUser.getBuName"></a>

### AccountUser.getBuName(id) ⇒ <code>string</code>
helper to print bu names

**Kind**: static method of [<code>AccountUser</code>](#AccountUser)
**Returns**: <code>string</code> - "bu name (bu id)""

| Param | Type | Description |
| --- | --- | --- |
| id | <code>number</code> | bu id |

<a name="AccountUser.document"></a>

### AccountUser.document([metadata]) ⇒ <code>Promise.&lt;void&gt;</code>
Expand All @@ -799,18 +774,6 @@ Creates markdown documentation of all roles
| --- | --- | --- |
| [metadata] | <code>TYPE.MetadataTypeMap</code> | user list |

<a name="AccountUser._generateDocMd"></a>

### AccountUser.\_generateDocMd(users, type, columnsToPrint) ⇒ <code>string</code>
**Kind**: static method of [<code>AccountUser</code>](#AccountUser)
**Returns**: <code>string</code> - markdown

| Param | Type | Description |
| --- | --- | --- |
| users | <code>Array.&lt;object&gt;</code> | list of users and installed package |
| type | <code>&#x27;Installed Package&#x27;</code> \| <code>&#x27;User&#x27;</code> | choose what sub type to print |
| columnsToPrint | <code>Array.&lt;Array&gt;</code> | helper array |

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

### AccountUser.postRetrieveTasks(metadata) ⇒ <code>TYPE.MetadataTypeItem</code>
Expand Down
55 changes: 42 additions & 13 deletions lib/metadataTypes/AccountUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ class AccountUser extends MetadataType {
for (const item of resultsBatch) {
this.userIdBuMap[item.AccountUser.AccountUserID] =
this.userIdBuMap[item.AccountUser.AccountUserID] || [];
this.userIdBuMap[item.AccountUser.AccountUserID].push({
ID: item.Account.ID,
Name: item.Account.Name,
});
// push to array if not already in array
if (
!this.userIdBuMap[item.AccountUser.AccountUserID].some(
(bu) => bu.ID === item.Account.ID
)
) {
this.userIdBuMap[item.AccountUser.AccountUserID].push({
ID: item.Account.ID,
Name: item.Account.Name,
});
}
}
// get actual user details
/** @type {TYPE.SoapRequestParams} */
Expand Down Expand Up @@ -114,10 +121,11 @@ class AccountUser extends MetadataType {
}
/**
*
* @private
* @param {string} date first date
* @returns {number} time difference
*/
static timeSinceDate(date) {
static _timeSinceDate(date) {
const interval = 'days';
const second = 1000,
minute = second * 60,
Expand Down Expand Up @@ -172,13 +180,28 @@ class AccountUser extends MetadataType {
/**
* helper to print bu names
*
* @private
* @param {number} id bu id
* @returns {string} "bu name (bu id)""
*/
static getBuName(id) {
static _getBuName(id) {
const name = this.buObject.eid == id ? '_ParentBU_' : this.buIdName[id];
return `<nobr>${name} (${id})</nobr>`;
}

/**
* helper that gets BU names from config
*
* @private
*/
static _getBuNames() {
this.buIdName = {};
for (const cred in this.properties.credentials) {
for (const buName in this.properties.credentials[cred].businessUnits) {
this.buIdName[this.properties.credentials[cred].businessUnits[buName]] = buName;
}
}
}
/**
* Creates markdown documentation of all roles
*
Expand Down Expand Up @@ -209,7 +232,7 @@ class AccountUser extends MetadataType {
}
}
// init map of BU Ids > BU Name
this.buIdName = {};
this._getBuNames();

// initialize permission object
this.allPermissions = {};
Expand Down Expand Up @@ -244,14 +267,19 @@ class AccountUser extends MetadataType {
}
let associatedBus = '';
if (user.AssociatedBusinessUnits__c) {
associatedBus = user.AssociatedBusinessUnits__c.map((item) => {
this.buIdName[item.ID] = item.Name;
return this.getBuName(item.ID);
})
user.AssociatedBusinessUnits__c.push({
ID: user.DefaultBusinessUnit,
});
// ensure associatedBus have no duplicates
associatedBus = [
...new Set(
user.AssociatedBusinessUnits__c.map((item) => this._getBuName(item.ID))
),
]
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
.join(',<br> ');
}
const defaultBUName = this.getBuName(user.DefaultBusinessUnit);
const defaultBUName = this._getBuName(user.DefaultBusinessUnit);
users.push({
TYPE: user.type__c,
UserID: user.UserID,
Expand All @@ -267,7 +295,7 @@ class AccountUser extends MetadataType {
AssociatedBusinessUnits__c: associatedBus,
Roles: roles,
UserPermissions: userPermissions,
LastSuccessfulLogin: this.timeSinceDate(user.LastSuccessfulLogin),
LastSuccessfulLogin: this._timeSinceDate(user.LastSuccessfulLogin),
CreatedDate: user.CreatedDate.split('T').join(' '),
ModifiedDate: user.ModifiedDate.split('T').join(' '),
});
Expand Down Expand Up @@ -325,6 +353,7 @@ class AccountUser extends MetadataType {
}
/**
*
* @private
* @param {object[]} users list of users and installed package
* @param {'Installed Package'|'User'} type choose what sub type to print
* @param {Array[]} columnsToPrint helper array
Expand Down
44 changes: 29 additions & 15 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,22 +317,30 @@ class Asset extends MetadataType {
} catch (ex) {
failed.push({ item: item, error: ex });
}
// even if the extended file failed, still save the metadata
metadata[item.customerKey] = item;
}
// this is a complex type which stores data in the asset itself
else if (!completed.includes(item.id)) {
const extendedItem = await this.client.rest.get(
'asset/v1/content/assets/' + item.id
);
metadata[item.customerKey] = extendedItem;
try {
const extendedItem = await this.client.rest.get(
'asset/v1/content/assets/' + item.id
);
// only save the metadata if we have extended content
metadata[item.customerKey] = extendedItem;
} catch (ex) {
failed.push({ item: item, error: ex });
}
}
completed.push(item.id);
await this.saveResults(
metadata,
retrieveDir,
'asset-' + subType,
templateVariables
);
if (metadata[item.customerKey]) {
await this.saveResults(
metadata,
retrieveDir,
'asset-' + subType,
templateVariables
);
}
// update the current value in your application..
extendedBar.increment();
})
Expand All @@ -346,7 +354,7 @@ class Asset extends MetadataType {
} catch (ex) {
extendedBar.stop();
Asset._resetLogLevel(loggerLevelBak, failed);
// timeouts should be retried, others can be retried
// timeouts should be retried, others can be exited
if (ex.code !== 'ETIMEDOUT') {
throw ex;
}
Expand Down Expand Up @@ -394,11 +402,17 @@ class Asset extends MetadataType {
);
for (const fail of failed) {
Util.logger.warn(
` - "${fail.item.name}" (${fail.item.customerKey}) in ${fail.item.r__folder_Path}: ${fail.error.message}`
` - "${fail.item.name}" (${fail.item.customerKey}): ${fail.error.message} (${
fail.error.code
})${
fail.error.endpoint
? Util.getGrayMsg(
' - ' +
fail.error.endpoint.split('rest.marketingcloudapis.com')[1]
)
: ''
}`
);
Util.logger.debug(`-- Error: ${fail.error.message}`);
Util.logger.debug(`-- AssetType: ${fail.item.assetType.name}`);
Util.logger.debug(`-- fileProperties: ${JSON.stringify(fail.item.fileProperties)}`);
}
Util.logger.info(
' - You will still find a JSON file for each of these in the download directory.'
Expand Down
8 changes: 5 additions & 3 deletions lib/metadataTypes/DataExtensionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ class DataExtensionField extends MetadataType {
}

Util.logger.info(
` - Found ${deployColumns.length} added/updated Fields for ${deKey}${
deployColumns.length ? ': ' : ''
}` + deployColumns.map((item) => item.Name).join(', ')
Util.getGrayMsg(
` - Found ${deployColumns.length} added/updated Fields for ${deKey}${
deployColumns.length ? ': ' : ''
}` + deployColumns.map((item) => item.Name).join(', ')
)
);
return existingFieldByName;
}
Expand Down
Loading

0 comments on commit 4f5bfe1

Please sign in to comment.