From 2f51c4a30605cf60ff70711ee9993c1af75045f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Thu, 29 Aug 2024 23:21:27 +0200 Subject: [PATCH 1/2] #1434: add resume journey via execute-method --- lib/cli.js | 4 ++-- lib/metadataTypes/Journey.js | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 4dc54671c..248505c71 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -679,8 +679,8 @@ yargs(hideBin(process.argv)) } ) .command( - ['execute [TYPE] [KEY]', 'exec', 'start'], - 'executes the entity (query/journey/automation etc.)', + ['execute [TYPE] [KEY]', 'exec', 'start', 'resume'], + 'executes the entity', (yargs) => yargs .positional('BU', { diff --git a/lib/metadataTypes/Journey.js b/lib/metadataTypes/Journey.js index e7b5ed7c8..3ce5dd296 100644 --- a/lib/metadataTypes/Journey.js +++ b/lib/metadataTypes/Journey.js @@ -1969,6 +1969,50 @@ class Journey extends MetadataType { return stoppedKeyArr; } + /** + * resumes selected journey versions + * + * @param {string[]} keyArr customerkey of the metadata + * @returns {Promise.} Returns list of keys that were paused + */ + static async execute(keyArr) { + let version; + const endpoint = '/interaction/v1/interactions/resume/'; + const resumedKeyArr = []; + const apiLimit = pLimit(20); + const journeyCache = await this.retrieveForCache(); + + await Promise.allSettled( + keyArr.map((key) => + apiLimit(async () => { + [key, version] = key.split('/'); + if (journeyCache.metadata[key]) { + version ||= journeyCache.metadata[key].version; + try { + await this.client.rest.post( + endpoint + + journeyCache.metadata[key].id + + (version === '*' + ? '?allVersions=true' + : `?versionNumber=${version}`), + {} + ); + Util.logger.info( + ` - Resumed ${this.definition.type} ${key}/${version}` + ); + resumedKeyArr.push(key); + } catch (ex) { + Util.logger.error( + ` - Resuming ${this.definition.type} ${key} failed: ${ex.message}` + ); + } + } + }) + ) + ); + + return resumedKeyArr; + } } // Assign definition to static attributes From a29d4af4143604edf3025c5fcbb7622f4a4e1283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Thu, 29 Aug 2024 23:22:25 +0200 Subject: [PATCH 2/2] #0: add option to run mcdev publish via 'activate' alias --- lib/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 248505c71..5e4a2ab37 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -733,7 +733,7 @@ yargs(hideBin(process.argv)) } ) .command( - ['publish [TYPE] [KEY]'], + ['publish [TYPE] [KEY]', 'activate'], 'publishes the entity', (yargs) => yargs