diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md index 8027e7538..3e78b1ad0 100644 --- a/docs/dist/documentation.md +++ b/docs/dist/documentation.md @@ -371,7 +371,7 @@ Source and target business units are also compared before the deployment to appl * [new Deployer(properties, buObject)](#new_Deployer_new) * _instance_ * [.metadata](#Deployer+metadata) : TYPE.MultiMetadataTypeMap - * [._deploy([typeArr], [keyArr], [fromRetrieve], [isRefresh])](#Deployer+_deploy) ⇒ Promise.<TYPE.MultiMetadataTypeMap> + * [._deploy([typeArr], [keyArr], [fromRetrieve])](#Deployer+_deploy) ⇒ Promise.<TYPE.MultiMetadataTypeMap> * _static_ * [.deploy(businessUnit, [selectedTypesArr], [keyArr], [fromRetrieve])](#Deployer.deploy) ⇒ Promise.<Object.<string, TYPE.MultiMetadataTypeMap>> * [._deployBU(cred, bu, properties, [typeArr], [keyArr], [fromRetrieve])](#Deployer._deployBU) ⇒ Promise.<TYPE.MultiMetadataTypeMap> @@ -395,7 +395,7 @@ Creates a Deployer, uses v2 auth if v2AuthOptions are passed. **Kind**: instance property of [Deployer](#Deployer) -### deployer.\_deploy([typeArr], [keyArr], [fromRetrieve], [isRefresh]) ⇒ Promise.<TYPE.MultiMetadataTypeMap> +### deployer.\_deploy([typeArr], [keyArr], [fromRetrieve]) ⇒ Promise.<TYPE.MultiMetadataTypeMap> Deploy all metadata that is located in the deployDir **Kind**: instance method of [Deployer](#Deployer) @@ -406,7 +406,6 @@ Deploy all metadata that is located in the deployDir | [typeArr] | Array.<TYPE.SupportedMetadataTypes> | limit deployment to given metadata type (can include subtype) | | [keyArr] | Array.<string> | limit deployment to given metadata keys | | [fromRetrieve] | boolean | if true, no folders will be updated/created | -| [isRefresh] | boolean | optional flag to indicate that triggeredSend should be refreshed after deployment of assets | @@ -798,7 +797,7 @@ FileTransfer MetadataType * [._retrieveExtendedFile(metadata, subType, retrieveDir)](#Asset._retrieveExtendedFile) ⇒ Promise.<void> * [._readExtendedFileFromFS(metadata, subType, deployDir, [pathOnly])](#Asset._readExtendedFileFromFS) ⇒ Promise.<string> * [.postRetrieveTasks(metadata)](#Asset.postRetrieveTasks) ⇒ TYPE.CodeExtractItem - * [.postDeployTasks(metadata, _, createdUpdated, [isRefresh])](#Asset.postDeployTasks) ⇒ Promise.<void> + * [.postDeployTasks(metadata, _, createdUpdated)](#Asset.postDeployTasks) ⇒ Promise.<void> * [.preDeployTasks(metadata, deployDir)](#Asset.preDeployTasks) ⇒ Promise.<TYPE.AssetItem> * [._getMainSubtype(extendedSubType)](#Asset._getMainSubtype) ⇒ string * [.buildDefinitionForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#Asset.buildDefinitionForNested) ⇒ Promise.<void> @@ -959,7 +958,7 @@ manages post retrieve steps -### Asset.postDeployTasks(metadata, _, createdUpdated, [isRefresh]) ⇒ Promise.<void> +### Asset.postDeployTasks(metadata, _, createdUpdated) ⇒ Promise.<void> Gets executed after deployment of metadata type **Kind**: static method of [Asset](#Asset) @@ -970,7 +969,6 @@ Gets executed after deployment of metadata type | metadata | TYPE.MetadataTypeMap | metadata mapped by their keyField | | _ | TYPE.MetadataTypeMap | originalMetadata to be updated (contains additioanl fields) | | createdUpdated | Object | counter representing successful creates/updates | -| [isRefresh] | boolean | optional flag to indicate that triggeredSend should be refreshed after deployment of assets | @@ -1238,7 +1236,7 @@ Automation MetadataType * [.retrieveForCache()](#Automation.retrieveForCache) ⇒ Promise.<TYPE.AutomationMapObj> * [.retrieveAsTemplate(templateDir, name, templateVariables)](#Automation.retrieveAsTemplate) ⇒ Promise.<TYPE.AutomationItemObj> * [.postRetrieveTasks(metadata)](#Automation.postRetrieveTasks) ⇒ TYPE.AutomationItem \| void - * [.deploy(metadata, targetBU, retrieveDir, [isRefresh])](#Automation.deploy) ⇒ Promise.<TYPE.AutomationMap> + * [.deploy(metadata, targetBU, retrieveDir)](#Automation.deploy) ⇒ Promise.<TYPE.AutomationMap> * [.create(metadata)](#Automation.create) ⇒ Promise * [.update(metadata, metadataBefore)](#Automation.update) ⇒ Promise * [.preDeployTasks(metadata)](#Automation.preDeployTasks) ⇒ Promise.<TYPE.AutomationItem> @@ -1310,7 +1308,7 @@ manages post retrieve steps -### Automation.deploy(metadata, targetBU, retrieveDir, [isRefresh]) ⇒ Promise.<TYPE.AutomationMap> +### Automation.deploy(metadata, targetBU, retrieveDir) ⇒ Promise.<TYPE.AutomationMap> Deploys automation - the saved file is the original one due to large differences required for deployment **Kind**: static method of [Automation](#Automation) @@ -1321,7 +1319,6 @@ Deploys automation - the saved file is the original one due to large differences | metadata | TYPE.AutomationMap | metadata mapped by their keyField | | targetBU | string | name/shorthand of target businessUnit for mapping | | retrieveDir | string | directory where metadata after deploy should be saved | -| [isRefresh] | boolean | optional flag - so far not used by automation | @@ -2335,7 +2332,7 @@ Event MetadataType * [.retrieveAsTemplate(templateDir, name, templateVariables)](#Event.retrieveAsTemplate) ⇒ Promise.<TYPE.MetadataTypeItemObj> * [.postRetrieveTasks(eventDef)](#Event.postRetrieveTasks) ⇒ TYPE.MetadataTypeItem * [.deleteByKey(key)](#Event.deleteByKey) ⇒ Promise.<boolean> - * [.deploy(metadata, deployDir, retrieveDir, [isRefresh])](#Event.deploy) ⇒ Promise.<TYPE.MetadataTypeMap> + * [.deploy(metadata, deployDir, retrieveDir)](#Event.deploy) ⇒ Promise.<TYPE.MetadataTypeMap> * [.create(metadata)](#Event.create) ⇒ Promise * [.update(metadataEntry)](#Event.update) ⇒ Promise * [.preDeployTasks(metadata)](#Event.preDeployTasks) ⇒ TYPE.MetadataTypeItem @@ -2405,7 +2402,7 @@ Delete a metadata item from the specified business unit -### Event.deploy(metadata, deployDir, retrieveDir, [isRefresh]) ⇒ Promise.<TYPE.MetadataTypeMap> +### Event.deploy(metadata, deployDir, retrieveDir) ⇒ Promise.<TYPE.MetadataTypeMap> Deploys metadata - merely kept here to be able to print [logBeta](#Util.logBeta) once per deploy **Kind**: static method of [Event](#Event) @@ -2416,7 +2413,6 @@ Deploys metadata - merely kept here to be able to print [logBeta](#Util.logBeta) | metadata | TYPE.MetadataTypeMap | metadata mapped by their keyField | | deployDir | string | directory where deploy metadata are saved | | retrieveDir | string | directory where metadata after deploy should be saved | -| [isRefresh] | boolean | optional flag - so far not used by eventDefinition | @@ -2923,7 +2919,7 @@ definitionId: A unique UUID provided by Salesforce Marketing Cloud. Each version * [Journey](#Journey) ⇐ [MetadataType](#MetadataType) * [.retrieve(retrieveDir, [_], [__], [key])](#Journey.retrieve) ⇒ Promise.<TYPE.MetadataTypeMapObj> * [.deleteByKey(key)](#Journey.deleteByKey) ⇒ Promise.<boolean> - * [.deploy(metadata, deployDir, retrieveDir, [isRefresh])](#Journey.deploy) ⇒ Promise.<TYPE.MetadataTypeMap> + * [.deploy(metadata, deployDir, retrieveDir)](#Journey.deploy) ⇒ Promise.<TYPE.MetadataTypeMap> * [.update(metadata)](#Journey.update) ⇒ Promise * [.create(metadata)](#Journey.create) ⇒ Promise * [.saveResults(results, retrieveDir, [overrideType], [templateVariables])](#Journey.saveResults) ⇒ Promise.<TYPE.MetadataTypeMap> @@ -2961,7 +2957,7 @@ Delete a metadata item from the specified business unit -### Journey.deploy(metadata, deployDir, retrieveDir, [isRefresh]) ⇒ Promise.<TYPE.MetadataTypeMap> +### Journey.deploy(metadata, deployDir, retrieveDir) ⇒ Promise.<TYPE.MetadataTypeMap> Deploys metadata - merely kept here to be able to print [logBeta](#Util.logBeta) once per deploy **Kind**: static method of [Journey](#Journey) @@ -2972,7 +2968,6 @@ Deploys metadata - merely kept here to be able to print [logBeta](#Util.logBeta) | metadata | TYPE.MetadataTypeMap | metadata mapped by their keyField | | deployDir | string | directory where deploy metadata are saved | | retrieveDir | string | directory where metadata after deploy should be saved | -| [isRefresh] | boolean | optional flag - so far not used by interaction | @@ -3155,8 +3150,8 @@ Provides default functionality that can be overwritten by child metadata type cl * [.buObject](#MetadataType.buObject) : TYPE.BuObject * [.getJsonFromFS(dir, [listBadKeys])](#MetadataType.getJsonFromFS) ⇒ TYPE.MetadataTypeMap * [.getFieldNamesToRetrieve([additionalFields], [isCaching])](#MetadataType.getFieldNamesToRetrieve) ⇒ Array.<string> - * [.deploy(metadata, deployDir, retrieveDir, [isRefresh])](#MetadataType.deploy) ⇒ Promise.<TYPE.MetadataTypeMap> - * [.postDeployTasks(upsertResults, originalMetadata, createdUpdated, [isRefresh])](#MetadataType.postDeployTasks) ⇒ void + * [.deploy(metadata, deployDir, retrieveDir)](#MetadataType.deploy) ⇒ Promise.<TYPE.MetadataTypeMap> + * [.postDeployTasks(upsertResults, originalMetadata, createdUpdated)](#MetadataType.postDeployTasks) ⇒ void * [.postCreateTasks(metadataEntry, apiResponse)](#MetadataType.postCreateTasks) ⇒ void * [.postUpdateTasks(metadataEntry, apiResponse)](#MetadataType.postUpdateTasks) ⇒ void * [.postDeployTasks_legacyApi(metadataEntry, apiResponse)](#MetadataType.postDeployTasks_legacyApi) ⇒ Promise.<void> @@ -3176,7 +3171,7 @@ Provides default functionality that can be overwritten by child metadata type cl * [.execute()](#MetadataType.execute) ⇒ void * [.hasChanged(cachedVersion, metadata, [fieldName])](#MetadataType.hasChanged) ⇒ boolean * [.hasChangedGeneric(cachedVersion, metadata, [fieldName], [silent])](#MetadataType.hasChangedGeneric) ⇒ boolean - * [.upsert(metadataMap, deployDir, [isRefresh])](#MetadataType.upsert) ⇒ Promise.<TYPE.MetadataTypeMap> + * [.upsert(metadataMap, deployDir)](#MetadataType.upsert) ⇒ Promise.<TYPE.MetadataTypeMap> * [.createOrUpdate(metadataMap, metadataKey, hasError, metadataToUpdate, metadataToCreate)](#MetadataType.createOrUpdate) ⇒ 'create' \| 'update' \| 'skip' * [.createREST(metadataEntry, uri)](#MetadataType.createREST) ⇒ Promise.<object> \| null * [.createSOAP(metadataEntry, [handleOutside])](#MetadataType.createSOAP) ⇒ Promise.<object> \| null @@ -3257,7 +3252,7 @@ Returns fieldnames of Metadata Type. 'this.definition.fields' variable only set -### MetadataType.deploy(metadata, deployDir, retrieveDir, [isRefresh]) ⇒ Promise.<TYPE.MetadataTypeMap> +### MetadataType.deploy(metadata, deployDir, retrieveDir) ⇒ Promise.<TYPE.MetadataTypeMap> Deploys metadata **Kind**: static method of [MetadataType](#MetadataType) @@ -3268,11 +3263,10 @@ Deploys metadata | metadata | TYPE.MetadataTypeMap | metadata mapped by their keyField | | deployDir | string | directory where deploy metadata are saved | | retrieveDir | string | directory where metadata after deploy should be saved | -| [isRefresh] | boolean | optional flag to indicate that triggeredSend should be refreshed after deployment of assets | -### MetadataType.postDeployTasks(upsertResults, originalMetadata, createdUpdated, [isRefresh]) ⇒ void +### MetadataType.postDeployTasks(upsertResults, originalMetadata, createdUpdated) ⇒ void Gets executed after deployment of metadata type **Kind**: static method of [MetadataType](#MetadataType) @@ -3282,7 +3276,6 @@ Gets executed after deployment of metadata type | upsertResults | TYPE.MetadataTypeMap | metadata mapped by their keyField as returned by update/create | | originalMetadata | TYPE.MetadataTypeMap | metadata to be updated (contains additioanl fields) | | createdUpdated | Object | counter representing successful creates/updates | -| [isRefresh] | boolean | optional flag to indicate that triggeredSend should be refreshed after deployment of assets | @@ -3524,7 +3517,7 @@ test if metadata was actually changed or not to potentially skip it during deplo -### MetadataType.upsert(metadataMap, deployDir, [isRefresh]) ⇒ Promise.<TYPE.MetadataTypeMap> +### MetadataType.upsert(metadataMap, deployDir) ⇒ Promise.<TYPE.MetadataTypeMap> MetadataType upsert, after retrieving from target and comparing to check if create or update operation is needed. **Kind**: static method of [MetadataType](#MetadataType) @@ -3534,7 +3527,6 @@ MetadataType upsert, after retrieving from target and comparing to check if crea | --- | --- | --- | | metadataMap | TYPE.MetadataTypeMap | metadata mapped by their keyField | | deployDir | string | directory where deploy metadata are saved | -| [isRefresh] | boolean | optional flag to indicate that triggeredSend should be refreshed after deployment of assets | @@ -5500,13 +5492,11 @@ MessageSendActivity MetadataType * [.create(metadata)](#TriggeredSend.create) ⇒ Promise * [.update(metadata)](#TriggeredSend.update) ⇒ Promise * [.deleteByKey(customerKey)](#TriggeredSend.deleteByKey) ⇒ Promise.<boolean> - * [.postRetrieveTasks(metadata)](#TriggeredSend.postRetrieveTasks) ⇒ TYPE.MetadataTypeItem - * [.setFolderPath(metadata)](#TriggeredSend.setFolderPath) - * [.parseMetadata(metadata)](#TriggeredSend.parseMetadata) ⇒ TYPE.MetadataTypeItem \| void + * [.postRetrieveTasks(metadata)](#TriggeredSend.postRetrieveTasks) ⇒ TYPE.MetadataTypeItem \| void * [.preDeployTasks(metadata)](#TriggeredSend.preDeployTasks) ⇒ TYPE.MetadataTypeItem * [.refresh([keyArr], [checkKey])](#TriggeredSend.refresh) ⇒ Promise.<void> * [.getKeysForValidTSDs(metadata)](#TriggeredSend.getKeysForValidTSDs) ⇒ Promise.<Array.<string>> - * [.findRefreshableItems()](#TriggeredSend.findRefreshableItems) ⇒ Promise.<TYPE.MetadataTypeMapObj> + * [.findRefreshableItems([assetLoaded])](#TriggeredSend.findRefreshableItems) ⇒ Promise.<TYPE.MetadataTypeMapObj> * [._refreshItem(key, checkKey)](#TriggeredSend._refreshItem) ⇒ Promise.<boolean> @@ -5562,30 +5552,7 @@ Delete a metadata item from the specified business unit -### TriggeredSend.postRetrieveTasks(metadata) ⇒ TYPE.MetadataTypeItem -manages post retrieve steps - -**Kind**: static method of [TriggeredSend](#TriggeredSend) -**Returns**: TYPE.MetadataTypeItem - Array with one metadata object and one query string - -| Param | Type | Description | -| --- | --- | --- | -| metadata | TYPE.MetadataTypeItem | a single query | - - - -### TriggeredSend.setFolderPath(metadata) -generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve - -**Kind**: static method of [TriggeredSend](#TriggeredSend) - -| Param | Type | Description | -| --- | --- | --- | -| metadata | TYPE.MetadataTypeItem | a single script activity definition | - - - -### TriggeredSend.parseMetadata(metadata) ⇒ TYPE.MetadataTypeItem \| void +### TriggeredSend.postRetrieveTasks(metadata) ⇒ TYPE.MetadataTypeItem \| void parses retrieved Metadata before saving **Kind**: static method of [TriggeredSend](#TriggeredSend) @@ -5593,7 +5560,7 @@ parses retrieved Metadata before saving | Param | Type | Description | | --- | --- | --- | -| metadata | TYPE.MetadataTypeItem | a single query activity definition | +| metadata | TYPE.MetadataTypeItem | a single item | @@ -5634,11 +5601,16 @@ helper for [refresh](refresh) that extracts the keys from the TSD item map and e -### TriggeredSend.findRefreshableItems() ⇒ Promise.<TYPE.MetadataTypeMapObj> +### TriggeredSend.findRefreshableItems([assetLoaded]) ⇒ Promise.<TYPE.MetadataTypeMapObj> helper for [refresh](refresh) that finds active TSDs on the server and filters it by the same rules that [retrieve](retrieve) is using to avoid refreshing TSDs with broken dependencies **Kind**: static method of [TriggeredSend](#TriggeredSend) **Returns**: Promise.<TYPE.MetadataTypeMapObj> - Promise of TSD item map + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| [assetLoaded] | boolean | false | if run after Asset.deploy via --refresh option this will skip caching assets | + ### TriggeredSend.\_refreshItem(key, checkKey) ⇒ Promise.<boolean> diff --git a/lib/Deployer.js b/lib/Deployer.js index 3d064049a..49485d2f8 100644 --- a/lib/Deployer.js +++ b/lib/Deployer.js @@ -215,10 +215,9 @@ class Deployer { * @param {TYPE.SupportedMetadataTypes[]} [typeArr] limit deployment to given metadata type (can include subtype) * @param {string[]} [keyArr] limit deployment to given metadata keys * @param {boolean} [fromRetrieve] if true, no folders will be updated/created - * @param {boolean} [isRefresh] optional flag to indicate that triggeredSend should be refreshed after deployment of assets * @returns {Promise.} Promise of all deployed metadata */ - async _deploy(typeArr, keyArr, fromRetrieve, isRefresh) { + async _deploy(typeArr, keyArr, fromRetrieve) { if (await File.pathExists(this.deployDir)) { /** @type {TYPE.MultiMetadataTypeMap} */ this.metadata = Deployer.readBUMetadata(this.deployDir, typeArr); @@ -297,8 +296,7 @@ class Deployer { const result = await MetadataTypeInfo[type].deploy( this.metadata[type], this.deployDir, - this.retrieveDir, - isRefresh + this.retrieveDir ); multiMetadataTypeMap[type] = result; cache.mergeMetadata(type, result); diff --git a/lib/metadataTypes/Asset.js b/lib/metadataTypes/Asset.js index 3ff861cce..2fd5c2c91 100644 --- a/lib/metadataTypes/Asset.js +++ b/lib/metadataTypes/Asset.js @@ -455,7 +455,7 @@ class Asset extends MetadataType { * @param {TYPE.AssetItem} metadata a single asset * @param {TYPE.AssetSubType} subType group of similar assets to put in a folder (ie. images) * @param {string} deployDir directory of deploy files - * @param {boolean} [pathOnly=false] used by getFilesToCommit which does not need the binary file to be actually read + * @param {boolean} [pathOnly] used by getFilesToCommit which does not need the binary file to be actually read * @returns {Promise.} if found will return the path of the binary file */ static async _readExtendedFileFromFS(metadata, subType, deployDir, pathOnly = false) { @@ -504,11 +504,10 @@ class Asset extends MetadataType { * @param {TYPE.MetadataTypeMap} metadata metadata mapped by their keyField * @param {TYPE.MetadataTypeMap} _ originalMetadata to be updated (contains additioanl fields) * @param {{created: number, updated: number}} createdUpdated counter representing successful creates/updates - * @param {boolean} [isRefresh] optional flag to indicate that triggeredSend should be refreshed after deployment of assets * @returns {Promise.} - */ - static async postDeployTasks(metadata, _, createdUpdated, isRefresh) { - if (isRefresh) { + static async postDeployTasks(metadata, _, createdUpdated) { + if (Util.OPTIONS.refresh) { if (createdUpdated.updated) { // only run this if assets were updated. for created assets we do not expect this._refreshTriggeredSend(metadata); @@ -521,7 +520,7 @@ class Asset extends MetadataType { } /** - * helper for {@link postDeployTasks}. triggers a refresh of active triggerredSendDefinitions associated with the updated asset-message items. Gets executed if isRefresh is true. + * helper for {@link postDeployTasks}. triggers a refresh of active triggerredSendDefinitions associated with the updated asset-message items. Gets executed if refresh option has been set. * * @private * @param {TYPE.MetadataTypeMap} metadata metadata mapped by their keyField @@ -546,7 +545,7 @@ class Asset extends MetadataType { TriggeredSend.client = this.client; try { // find refreshable TSDs - const tsdObj = (await TriggeredSend.findRefreshableItems()).metadata; + const tsdObj = (await TriggeredSend.findRefreshableItems(true)).metadata; const tsdCountInitial = Object.keys(tsdObj).length; const emailCount = legacyIdArr.length; diff --git a/lib/metadataTypes/Automation.js b/lib/metadataTypes/Automation.js index 560ed94e3..b2aaefa01 100644 --- a/lib/metadataTypes/Automation.js +++ b/lib/metadataTypes/Automation.js @@ -452,11 +452,10 @@ class Automation extends MetadataType { * @param {TYPE.AutomationMap} metadata metadata mapped by their keyField * @param {string} targetBU name/shorthand of target businessUnit for mapping * @param {string} retrieveDir directory where metadata after deploy should be saved - * @param {boolean} [isRefresh] optional flag - so far not used by automation * @returns {Promise.} Promise */ - static async deploy(metadata, targetBU, retrieveDir, isRefresh) { - const upsertResults = await this.upsert(metadata, targetBU, isRefresh); + static async deploy(metadata, targetBU, retrieveDir) { + const upsertResults = await this.upsert(metadata, targetBU); const savedMetadata = await this.saveResults(upsertResults, retrieveDir, null); if ( this.properties.metaDataTypes.documentOnRetrieve.includes(this.definition.type) && diff --git a/lib/metadataTypes/Event.js b/lib/metadataTypes/Event.js index 3062acfd4..864cd925c 100644 --- a/lib/metadataTypes/Event.js +++ b/lib/metadataTypes/Event.js @@ -136,12 +136,11 @@ class Event extends MetadataType { * @param {TYPE.MetadataTypeMap} metadata 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 - * @param {boolean} [isRefresh] optional flag - so far not used by eventDefinition * @returns {Promise.} Promise of keyField => metadata map */ - static async deploy(metadata, deployDir, retrieveDir, isRefresh) { + static async deploy(metadata, deployDir, retrieveDir) { Util.logBeta(this.definition.type); - return super.deploy(metadata, deployDir, retrieveDir, isRefresh); + return super.deploy(metadata, deployDir, retrieveDir); } /** diff --git a/lib/metadataTypes/Journey.js b/lib/metadataTypes/Journey.js index 7c20b2ee3..87e03e2b5 100644 --- a/lib/metadataTypes/Journey.js +++ b/lib/metadataTypes/Journey.js @@ -216,12 +216,11 @@ class Journey extends MetadataType { * @param {TYPE.MetadataTypeMap} metadata 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 - * @param {boolean} [isRefresh] optional flag - so far not used by interaction * @returns {Promise.} Promise of keyField => metadata map */ - static async deploy(metadata, deployDir, retrieveDir, isRefresh) { + static async deploy(metadata, deployDir, retrieveDir) { Util.logBeta(this.definition.type); - return super.deploy(metadata, deployDir, retrieveDir, isRefresh); + return super.deploy(metadata, deployDir, retrieveDir); } /** diff --git a/lib/metadataTypes/MetadataType.js b/lib/metadataTypes/MetadataType.js index 92b1686de..dd8f99c1e 100644 --- a/lib/metadataTypes/MetadataType.js +++ b/lib/metadataTypes/MetadataType.js @@ -108,11 +108,10 @@ class MetadataType { * @param {TYPE.MetadataTypeMap} metadata 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 - * @param {boolean} [isRefresh] optional flag to indicate that triggeredSend should be refreshed after deployment of assets * @returns {Promise.} Promise of keyField => metadata map */ - static async deploy(metadata, deployDir, retrieveDir, isRefresh) { - const upsertResults = await this.upsert(metadata, deployDir, isRefresh); + static async deploy(metadata, deployDir, retrieveDir) { + const upsertResults = await this.upsert(metadata, deployDir); const savedMetadata = await this.saveResults(upsertResults, retrieveDir, null); if ( this.properties.metaDataTypes.documentOnRetrieve.includes(this.definition.type) && @@ -131,10 +130,9 @@ class MetadataType { * @param {TYPE.MetadataTypeMap} upsertResults metadata mapped by their keyField as returned by update/create * @param {TYPE.MetadataTypeMap} originalMetadata metadata to be updated (contains additioanl fields) * @param {{created: number, updated: number}} createdUpdated counter representing successful creates/updates - * @param {boolean} [isRefresh] optional flag to indicate that triggeredSend should be refreshed after deployment of assets * @returns {void} */ - static postDeployTasks(upsertResults, originalMetadata, createdUpdated, isRefresh) {} + static postDeployTasks(upsertResults, originalMetadata, createdUpdated) {} /** * helper for {@link createREST} @@ -537,10 +535,9 @@ class MetadataType { * * @param {TYPE.MetadataTypeMap} metadataMap metadata mapped by their keyField * @param {string} deployDir directory where deploy metadata are saved - * @param {boolean} [isRefresh] optional flag to indicate that triggeredSend should be refreshed after deployment of assets * @returns {Promise.} keyField => metadata map */ - static async upsert(metadataMap, deployDir, isRefresh) { + static async upsert(metadataMap, deployDir) { const orignalMetadataMap = JSON.parse(JSON.stringify(metadataMap)); const metadataToUpdate = []; const metadataToCreate = []; @@ -632,12 +629,10 @@ class MetadataType { const metadataResults = createResults.concat(updateResults).filter(Boolean); upsertResults = this.parseResponseBody(metadataResults); } - await this.postDeployTasks( - upsertResults, - orignalMetadataMap, - { created: createResults.length, updated: updateResults.length }, - isRefresh - ); + await this.postDeployTasks(upsertResults, orignalMetadataMap, { + created: createResults.length, + updated: updateResults.length, + }); return upsertResults; } diff --git a/lib/metadataTypes/TriggeredSend.js b/lib/metadataTypes/TriggeredSend.js index 26b3ca33d..71d8bd35a 100644 --- a/lib/metadataTypes/TriggeredSend.js +++ b/lib/metadataTypes/TriggeredSend.js @@ -85,51 +85,19 @@ class TriggeredSend extends MetadataType { return super.deleteByKeySOAP(customerKey); } - /** - * manages post retrieve steps - * - * @param {TYPE.MetadataTypeItem} metadata a single query - * @returns {TYPE.MetadataTypeItem} Array with one metadata object and one query string - */ - static postRetrieveTasks(metadata) { - return this.parseMetadata(metadata); - } - /** - * generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve - * - * @param {TYPE.MetadataTypeItem} metadata a single script activity definition - */ - static setFolderPath(metadata) { - try { - metadata.r__folder_Path = cache.searchForField( - 'folder', - metadata[this.definition.folderIdField], - 'ID', - 'Path' - ); - delete metadata[this.definition.folderIdField]; - } catch (ex) { - Util.logger.verbose( - ` - skipping ${this.definition.type} '${metadata[this.definition.nameField]}' (${ - metadata[this.definition.keyField] - }): Could not find folder (${ex.message})` - ); - throw ex; - } - } /** * parses retrieved Metadata before saving * - * @param {TYPE.MetadataTypeItem} metadata a single query activity definition + * @param {TYPE.MetadataTypeItem} metadata a single item * @returns {TYPE.MetadataTypeItem | void} Array with one metadata object and one sql string */ - static parseMetadata(metadata) { + static postRetrieveTasks(metadata) { // remove IsPlatformObject, always has to be 'false' delete metadata.IsPlatformObject; + // folder - try { - this.setFolderPath(metadata); - } catch { + this.setFolderPath(metadata); + if (!metadata.r__folder_Path) { Util.logger.verbose( ` ☇ skipping ${this.definition.typeName} '${metadata.Name}'/'${metadata.CustomerKey}': Could not find folder.` ); @@ -246,7 +214,7 @@ class TriggeredSend extends MetadataType { * TSD-specific refresh method that finds active TSDs and refreshes them * * @param {string[]} [keyArr] metadata keys - * @param {boolean} [checkKey=true] whether to check if the key is valid + * @param {boolean} [checkKey] whether to check if the key is valid * @returns {Promise.} - */ static async refresh(keyArr, checkKey = true) { @@ -284,9 +252,10 @@ class TriggeredSend extends MetadataType { /** * helper for {@link refresh} that finds active TSDs on the server and filters it by the same rules that {@link retrieve} is using to avoid refreshing TSDs with broken dependencies * + * @param {boolean} [assetLoaded] if run after Asset.deploy via --refresh option this will skip caching assets * @returns {Promise.} Promise of TSD item map */ - static async findRefreshableItems() { + static async findRefreshableItems(assetLoaded = false) { Util.logger.info('Finding refreshable items...'); // cache dependencies to test for broken links // skip deprecated classic emails here, assuming they cannot be updated and hence are not relevant for {@link refresh} @@ -305,14 +274,20 @@ class TriggeredSend extends MetadataType { list: null, }; for (const [type, subTypeArr] of Object.entries(requiredCache)) { - if (!cache.getCache()?.[type]) { - Util.logger.info(` - Caching dependent Metadata: ${type}`); - Util.logSubtypes(subTypeArr); - cacheTypes[type].client = this.client; - cacheTypes[type].buObject = this.buObject; - cacheTypes[type].properties = this.properties; + if (type === 'asset' && assetLoaded) { + continue; + } + Util.logger.info(` - Caching dependent Metadata: ${type}`); + Util.logSubtypes(subTypeArr); + cacheTypes[type].client = this.client; + cacheTypes[type].buObject = this.buObject; + cacheTypes[type].properties = this.properties; - const result = await cacheTypes[type].retrieveForCache(null, subTypeArr); + const result = await cacheTypes[type].retrieveForCache(null, subTypeArr); + if (cache.getCache()?.[type]) { + // re-run caching to merge with existing cache, assuming we might have missed subtypes + cache.mergeMetadata(type, result.metadata); + } else { cache.setMetadata(type, result.metadata); } }