Skip to content

Commit

Permalink
#984: move updateNotification logic from custom createOrUpdate into p…
Browse files Browse the repository at this point in the history
…reDeployTasks
  • Loading branch information
JoernBerkefeld committed Oct 9, 2023
1 parent 258c067 commit 63f9784
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 44 deletions.
17 changes: 0 additions & 17 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3105,7 +3105,6 @@ ImportFile MetadataType
* [.preDeployTasks(metadata)](#ImportFile.preDeployTasks) ⇒ <code>Promise</code>
* [.getKeysToSetNotifications(metadataMap)](#ImportFile.getKeysToSetNotifications) ⇒ <code>Array.&lt;string&gt;</code>
* [.parseMetadata(metadata)](#ImportFile.parseMetadata) ⇒ <code>TYPE.MetadataTypeItem</code>
* [.createOrUpdate(metadataMap, metadataKey, hasError, metadataToUpdate, metadataToCreate)](#ImportFile.createOrUpdate) ⇒ <code>&#x27;create&#x27;</code> \| <code>&#x27;update&#x27;</code> \| <code>&#x27;skip&#x27;</code>

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

Expand Down Expand Up @@ -3217,22 +3216,6 @@ parses retrieved Metadata before saving
| --- | --- | --- |
| metadata | <code>TYPE.MetadataTypeItem</code> | a single import definition |

<a name="ImportFile.createOrUpdate"></a>

### ImportFile.createOrUpdate(metadataMap, metadataKey, hasError, metadataToUpdate, metadataToCreate) ⇒ <code>&#x27;create&#x27;</code> \| <code>&#x27;update&#x27;</code> \| <code>&#x27;skip&#x27;</code>
helper for [upsert](#MetadataType.upsert)

**Kind**: static method of [<code>ImportFile</code>](#ImportFile)
**Returns**: <code>&#x27;create&#x27;</code> \| <code>&#x27;update&#x27;</code> \| <code>&#x27;skip&#x27;</code> - action to take

| Param | Type | Description |
| --- | --- | --- |
| metadataMap | <code>TYPE.MetadataTypeMap</code> | list of metadata |
| metadataKey | <code>string</code> | key of item we are looking at |
| hasError | <code>boolean</code> | error flag from previous code |
| metadataToUpdate | <code>Array.&lt;TYPE.MetadataTypeItemDiff&gt;</code> | list of items to update |
| metadataToCreate | <code>Array.&lt;TYPE.MetadataTypeItem&gt;</code> | list of items to create |

<a name="Journey"></a>

## Journey ⇐ [<code>MetadataType</code>](#MetadataType)
Expand Down
37 changes: 10 additions & 27 deletions lib/metadataTypes/ImportFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ class ImportFile extends MetadataType {
metadata.subscriberImportTypeId =
this.definition.subscriberImportTypeMapping[metadata.c__subscriberImportType];
metadata.updateTypeId = this.definition.updateTypeMapping[metadata.c__dataAction];

// logic for mcdev.updateNotifications
if (Util.OPTIONS.clear) {
metadata.sendEmailNotification = false;
metadata.notificationEmailAddress = '';
} else if (Util.OPTIONS.completionEmail) {
metadata.sendEmailNotification = true;
metadata.notificationEmailAddress = Util.OPTIONS.completionEmail;
}

return metadata;
}
/**
Expand Down Expand Up @@ -263,33 +273,6 @@ class ImportFile extends MetadataType {
delete metadata.updateTypeId;
return metadata;
}
/**
* helper for {@link MetadataType.upsert}
*
* @param {TYPE.MetadataTypeMap} metadataMap list of metadata
* @param {string} metadataKey key of item we are looking at
* @param {boolean} hasError error flag from previous code
* @param {TYPE.MetadataTypeItemDiff[]} metadataToUpdate list of items to update
* @param {TYPE.MetadataTypeItem[]} metadataToCreate list of items to create
* @returns {'create' | 'update' | 'skip'} action to take
*/
static createOrUpdate(metadataMap, metadataKey, hasError, metadataToUpdate, metadataToCreate) {
if (Util.OPTIONS.clear) {
metadataMap[metadataKey].sendEmailNotification = false;
metadataMap[metadataKey].notificationEmailAddress = '';
} else if (Util.OPTIONS.completionEmail) {
metadataMap[metadataKey].sendEmailNotification = true;
metadataMap[metadataKey].notificationEmailAddress = Util.OPTIONS.completionEmail;
}
const createOrUpdateAction = super.createOrUpdate(
metadataMap,
metadataKey,
hasError,
metadataToUpdate,
metadataToCreate
);
return createOrUpdateAction;
}
}

// Assign definition to static attributes
Expand Down

0 comments on commit 63f9784

Please sign in to comment.