diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 876c1779c..cdfed5fcd 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json index ad0290c42..3abf1f935 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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": { diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md index c9d9205d9..c46eccb64 100644 --- a/docs/dist/documentation.md +++ b/docs/dist/documentation.md @@ -2472,7 +2472,6 @@ MessageSendActivity MetadataType * [.deleteByKey(customerKey)](#EmailSend.deleteByKey) ⇒ Promise.<boolean> * [.preDeployTasks(metadata)](#EmailSend.preDeployTasks) ⇒ Promise.<TYPE.MetadataTypeItem> * [.postRetrieveTasks(metadata)](#EmailSend.postRetrieveTasks) ⇒ TYPE.MetadataTypeItem - * [.parseMetadata(metadata)](#EmailSend.parseMetadata) ⇒ TYPE.MetadataTypeItem @@ -2549,18 +2548,6 @@ manages post retrieve steps | --- | --- | --- | | metadata | TYPE.MetadataTypeItem | a single query | - - -### EmailSend.parseMetadata(metadata) ⇒ TYPE.MetadataTypeItem -parses retrieved Metadata before saving - -**Kind**: static method of [EmailSend](#EmailSend) -**Returns**: TYPE.MetadataTypeItem - Array with one metadata object and one sql string - -| Param | Type | Description | -| --- | --- | --- | -| metadata | TYPE.MetadataTypeItem | a single query activity definition | - ## Event ⇐ [MetadataType](#MetadataType) @@ -5645,8 +5632,8 @@ TransactionalSMS MetadataType * [.postDeleteTasks(customerKey)](#TransactionalSMS.postDeleteTasks) ⇒ void * [.preDeployTasks(metadata, deployDir)](#TransactionalSMS.preDeployTasks) ⇒ Promise.<TYPE.MetadataTypeItem> * [._mergeCode(metadata, deployDir, [templateName])](#TransactionalSMS._mergeCode) ⇒ Promise.<string> - * [.postRetrieveTasks(metadata)](#TransactionalSMS.postRetrieveTasks) ⇒ TYPE.CodeExtractItem - * [.prepExtractedCode(metadataScript)](#TransactionalSMS.prepExtractedCode) ⇒ Object + * [.postRetrieveTasks(metadata)](#TransactionalSMS.postRetrieveTasks) ⇒ Promise.<TYPE.CodeExtractItem> + * [.prepExtractedCode(metadataScript)](#TransactionalSMS.prepExtractedCode) ⇒ Promise.<{fileExt:string, code:string}> * [.buildDefinitionForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#TransactionalSMS.buildDefinitionForNested) ⇒ Promise.<Array.<Array.<string>>> * [.buildTemplateForNested(templateDir, targetDir, metadata, templateVariables, templateName)](#TransactionalSMS.buildTemplateForNested) ⇒ Promise.<Array.<Array.<string>>> * [._buildForNested(templateDir, targetDir, metadata, templateVariables, templateName, mode)](#TransactionalSMS._buildForNested) ⇒ Promise.<Array.<Array.<string>>> @@ -5693,11 +5680,11 @@ helper for [preDeployTasks](#TransactionalSMS.preDeployTasks) that loads extract -### TransactionalSMS.postRetrieveTasks(metadata) ⇒ TYPE.CodeExtractItem +### TransactionalSMS.postRetrieveTasks(metadata) ⇒ Promise.<TYPE.CodeExtractItem> manages post retrieve steps **Kind**: static method of [TransactionalSMS](#TransactionalSMS) -**Returns**: TYPE.CodeExtractItem - Array with one metadata object and one ssjs string +**Returns**: Promise.<TYPE.CodeExtractItem> - Array with one metadata object and one ssjs string | Param | Type | Description | | --- | --- | --- | @@ -5705,11 +5692,11 @@ manages post retrieve steps -### TransactionalSMS.prepExtractedCode(metadataScript) ⇒ Object +### TransactionalSMS.prepExtractedCode(metadataScript) ⇒ Promise.<{fileExt:string, code:string}> helper for [postRetrieveTasks](#TransactionalSMS.postRetrieveTasks) and [_buildForNested](#TransactionalSMS._buildForNested) **Kind**: static method of [TransactionalSMS](#TransactionalSMS) -**Returns**: Object - returns found extension and file content +**Returns**: Promise.<{fileExt:string, code:string}> - returns found extension and file content | Param | Type | Description | | --- | --- | --- | @@ -6637,7 +6624,7 @@ File extends fs-extra. It adds logger and util methods for file handling * [.normalizePath(denormalizedPath)](#File.normalizePath) ⇒ string * [.writeJSONToFile(directory, filename, content)](#File.writeJSONToFile) ⇒ Promise * [.writePrettyToFile(directory, filename, filetype, content, [templateVariables])](#File.writePrettyToFile) ⇒ Promise.<boolean> - * [._beautify_beautyAmp(content)](#File._beautify_beautyAmp) ⇒ string + * [.beautify_beautyAmp(content, formatHTML)](#File.beautify_beautyAmp) ⇒ Promise.<string> * [._beautify_prettier(directory, filename, filetype, content)](#File._beautify_prettier) ⇒ Promise.<string> * [.writeToFile(directory, filename, filetype, content, [encoding])](#File.writeToFile) ⇒ Promise.<boolean> * [.readJSONFile(directory, filename, sync, cleanPath)](#File.readJSONFile) ⇒ Promise.<object> \| object \| void @@ -6739,17 +6726,18 @@ Saves beautified files in the local file system. Will create the parent director | content | string | filecontent | | [templateVariables] | TYPE.TemplateMap | templating variables to be replaced in the metadata | - + -### File.\_beautify\_beautyAmp(content) ⇒ string +### File.beautify\_beautyAmp(content, formatHTML) ⇒ Promise.<string> helper for [writePrettyToFile](#File.writePrettyToFile), applying beautyAmp onto given stringified content **Kind**: static method of [File](#File) -**Returns**: string - original string on error; formatted string on success +**Returns**: Promise.<string> - original string on error; formatted string on success | Param | Type | Description | | --- | --- | --- | | content | string | filecontent | +| formatHTML | boolean | should we format HTML or not via prettier included in beautyAmp | diff --git a/lib/Retriever.js b/lib/Retriever.js index bbfb0c0d6..11e54ceae 100644 --- a/lib/Retriever.js +++ b/lib/Retriever.js @@ -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); diff --git a/lib/metadataTypes/DataExtension.js b/lib/metadataTypes/DataExtension.js index 5e4a8cad5..95e2771af 100644 --- a/lib/metadataTypes/DataExtension.js +++ b/lib/metadataTypes/DataExtension.js @@ -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); @@ -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]; diff --git a/lib/metadataTypes/EmailSend.js b/lib/metadataTypes/EmailSend.js index 38474bd56..e3c4a5cb2 100644 --- a/lib/metadataTypes/EmailSend.js +++ b/lib/metadataTypes/EmailSend.js @@ -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'); @@ -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 @@ -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 @@ -206,27 +221,32 @@ 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( @@ -234,7 +254,7 @@ class EmailSend extends MetadataType { metadata[this.definition.keyField] }): Could not find email with ID ${ metadata.Email.ID - } in Classic nor in Content Builder.` + } Content Builder or Classic Emails.` ); } } diff --git a/lib/metadataTypes/Journey.js b/lib/metadataTypes/Journey.js index 599b4cd58..1c7b2ba3c 100644 --- a/lib/metadataTypes/Journey.js +++ b/lib/metadataTypes/Journey.js @@ -571,7 +571,7 @@ class Journey extends MetadataType { 'mobileKeyword', activity.configurationArguments.nextKeywordId, 'id', - 'keyword' + 'c__codeKeyword' ); delete activity.configurationArguments.nextKeywordId; } @@ -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; diff --git a/lib/metadataTypes/TransactionalSMS.js b/lib/metadataTypes/TransactionalSMS.js index 8aff9a02d..a7cb1adff 100644 --- a/lib/metadataTypes/TransactionalSMS.js +++ b/lib/metadataTypes/TransactionalSMS.js @@ -4,7 +4,6 @@ import TYPE from '../../types/mcdev.d.js'; import TransactionalMessage from './TransactionalMessage.js'; import { Util } from '../util/util.js'; import File from '../util/file.js'; -import beautifier from 'beauty-amp-core'; import cache from '../util/cache.js'; /** @@ -52,16 +51,16 @@ class TransactionalSMS extends TransactionalMessage { if (metadata.subscriptions?.shortCode) { // we merely want to be able to show an error if it does not exist cache.searchForField('mobileCode', metadata.subscriptions.shortCode, 'code', 'code'); - } - // subscriptions: mobileKeyword - if (metadata.subscriptions?.keyword) { - // we merely want to be able to show an error if it does not exist - cache.searchForField( - 'mobileKeyword', - metadata.subscriptions.shortCode + '.' + metadata.subscriptions.keyword, - 'c__codeKeyword', - 'id' - ); + // subscriptions: mobileKeyword + if (metadata.subscriptions?.keyword) { + // we merely want to be able to show an error if it does not exist + cache.searchForField( + 'mobileKeyword', + metadata.subscriptions.shortCode + '.' + metadata.subscriptions.keyword, + 'c__codeKeyword', + 'id' + ); + } } return metadata; } @@ -95,13 +94,13 @@ class TransactionalSMS extends TransactionalMessage { * manages post retrieve steps * * @param {TYPE.MetadataTypeItem} metadata a single item - * @returns {TYPE.CodeExtractItem} Array with one metadata object and one ssjs string + * @returns {Promise.} Array with one metadata object and one ssjs string */ - static postRetrieveTasks(metadata) { + static async postRetrieveTasks(metadata) { // extract message body const codeArr = []; // keep between tags - const { fileExt, code } = this.prepExtractedCode(metadata.content?.message); + const { fileExt, code } = await this.prepExtractedCode(metadata.content?.message); delete metadata.content; codeArr.push({ subFolder: null, @@ -143,7 +142,7 @@ class TransactionalSMS extends TransactionalMessage { cache.searchForField( 'mobileKeyword', metadata.subscriptions.shortCode + '.' + metadata.subscriptions.keyword, - 'keyword', + 'c__codeKeyword', 'id' ); } catch { @@ -161,29 +160,10 @@ class TransactionalSMS extends TransactionalMessage { * helper for {@link TransactionalSMS.postRetrieveTasks} and {@link TransactionalSMS._buildForNested} * * @param {string} metadataScript the code of the file - * @returns {{fileExt:string,code:string}} returns found extension and file content + * @returns {Promise.<{fileExt:string,code:string}>} returns found extension and file content */ - static prepExtractedCode(metadataScript) { - // immutable at the moment: - const ampscript = { - capitalizeAndOrNot: true, - capitalizeIfFor: true, - capitalizeSet: true, - capitalizeVar: true, - maxParametersPerLine: 4, - }; - // immutable at the moment: - const editor = { - insertSpaces: true, - tabSize: 4, - }; - // logs trough console only for the moment. - const logs = { - loggerOn: false, // <= disable logging - }; - - beautifier.setup(ampscript, editor, logs); - const code = beautifier.beautify(metadataScript); + static async prepExtractedCode(metadataScript) { + const code = await File.beautify_beautyAmp(metadataScript, false); const fileExt = 'amp'; return { fileExt, code }; @@ -266,7 +246,7 @@ class TransactionalSMS extends TransactionalMessage { ) { // get code from filesystem let code = await this._mergeCode(metadata, templateDir, templateName); - const file = this.prepExtractedCode(code, metadata.name); + const file = await this.prepExtractedCode(code, metadata.name); const fileExt = file.fileExt; code = file.code; // apply templating diff --git a/lib/metadataTypes/definitions/MobileKeyword.definition.js b/lib/metadataTypes/definitions/MobileKeyword.definition.js index a5850b1e6..39d375643 100644 --- a/lib/metadataTypes/definitions/MobileKeyword.definition.js +++ b/lib/metadataTypes/definitions/MobileKeyword.definition.js @@ -5,7 +5,7 @@ export default { idField: 'id', keyIsFixed: false, // custom field but mapped to normal fields keyField: 'c__codeKeyword', - nameField: 'keyword', + nameField: 'c__codeKeyword', createdDateField: 'createdDate', createdNameField: 'createdBy.name', lastmodDateField: 'lastUpdated', diff --git a/lib/util/file.js b/lib/util/file.js index 682f897ae..a3010350f 100644 --- a/lib/util/file.js +++ b/lib/util/file.js @@ -6,7 +6,7 @@ import fs from 'fs-extra'; import path from 'node:path'; import prettier from 'prettier'; -import beautyAmp from 'beauty-amp-core'; +import beautyAmp from 'beauty-amp-core2'; import { Util } from './util.js'; import updateNotifier from 'update-notifier'; @@ -171,7 +171,7 @@ const File = { writePrettyToFile: async function (directory, filename, filetype, content, templateVariables) { let formatted = filetype === 'amp' - ? this._beautify_beautyAmp(content) + ? await this.beautify_beautyAmp(content, false) : await this._beautify_prettier(directory, filename, filetype, content); if (templateVariables) { formatted = Util.replaceByObject(formatted, templateVariables); @@ -182,10 +182,10 @@ const File = { * helper for {@link File.writePrettyToFile}, applying beautyAmp onto given stringified content * * @param {string} content filecontent - * @returns {string} original string on error; formatted string on success + * @param {boolean} formatHTML should we format HTML or not via prettier included in beautyAmp + * @returns {Promise.} original string on error; formatted string on success */ - _beautify_beautyAmp: function (content) { - // immutable at the moment: + beautify_beautyAmp: async function (content, formatHTML = true) { const ampscript = { capitalizeAndOrNot: true, capitalizeIfFor: true, @@ -193,7 +193,6 @@ const File = { capitalizeVar: true, maxParametersPerLine: 4, }; - // immutable at the moment: const editor = { insertSpaces: true, tabSize: 4, @@ -204,9 +203,10 @@ const File = { }; try { beautyAmp.setup(ampscript, editor, logs); - return beautyAmp.beautify(content); + // Note: we need to trim the result as beautyAmp adds a leading new line; but we also want to ensure there is a single new line at the end to comply with standard linting rules + return (await beautyAmp.beautify(content, formatHTML)).trim() + '\n'; } catch (ex) { - Util.logger.debug('File._beautify_beautyAmp:: error | ' + ex.message); + Util.logger.debug('File.beautify_beautyAmp:: error | ' + ex.message); return content; } }, @@ -229,7 +229,7 @@ const File = { } else if (content.includes('%%[') || content.includes('%%=')) { // in case we find AMPScript we need to abort beautifying as prettier // will throw an error falsely assuming bad syntax - return this._beautify_beautyAmp(content); + return await this.beautify_beautyAmp(content, true); } // load the right prettier config relative to our file switch (filetype) { diff --git a/package-lock.json b/package-lock.json index c0f52d3ef..6f615aa76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,26 +1,26 @@ { "name": "mcdev", - "version": "6.0.1", + "version": "6.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mcdev", - "version": "6.0.1", + "version": "6.0.2", "license": "MIT", "dependencies": { - "beauty-amp-core": "0.3.7", + "beauty-amp-core2": "0.4.5", "cli-progress": "3.12.0", "command-exists": "1.2.9", - "conf": "11.0.1", + "conf": "12.0.0", "console.table": "0.10.0", - "deep-equal": "2.2.2", + "deep-equal": "2.2.3", "fs-extra": "11.1.1", "inquirer": "9.2.6", "json-to-table": "4.2.1", "mustache": "4.2.0", "p-limit": "4.0.0", - "prettier": "3.1.1", + "prettier": "3.2.4", "prettier-plugin-sql": "0.15.1", "semver": "7.5.4", "sfmc-sdk": "2.0.1", @@ -36,11 +36,11 @@ "devDependencies": { "assert": "2.1.0", "axios-mock-adapter": "1.22.0", - "c8": "8.0.1", + "c8": "9.1.0", "chai": "4.3.10", "chai-files": "1.4.0", "eslint": "8.56.0", - "eslint-config-prettier": "9.0.0", + "eslint-config-prettier": "9.1.0", "eslint-config-ssjs": "1.1.11", "eslint-plugin-jsdoc": "48.0.2", "eslint-plugin-mocha": "10.2.0", @@ -1000,11 +1000,11 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "node_modules/atomically": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/atomically/-/atomically-2.0.1.tgz", - "integrity": "sha512-sxBhVZUFBFhqSAsYMM3X2oaUi2NVDJ8U026FsIusM8gYXls9AYs/eXzgGrufs1Qjpkxi9zunds+75QUFz+m7UQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/atomically/-/atomically-2.0.2.tgz", + "integrity": "sha512-Xfmb4q5QV7uqTlVdMSTtO5eF4DCHfNOdaPyKlbFShkzeNP+3lj3yjjcbdjSmEY4+pDBKJ9g26aP+ImTe88UHoQ==", "dependencies": { - "stubborn-fs": "^1.2.4", + "stubborn-fs": "^1.2.5", "when-exit": "^2.0.0" } }, @@ -1067,10 +1067,28 @@ } ] }, - "node_modules/beauty-amp-core": { - "version": "0.3.7", - "resolved": "https://registry.npmjs.org/beauty-amp-core/-/beauty-amp-core-0.3.7.tgz", - "integrity": "sha512-/a3jRMN0IZ4SaV8PoVLqprk0sSEXvTOOVs4jdSQhgNBJYRkHau0PhUwju6PzfNvQpleZXWdechrPQAVAxIKnHA==" + "node_modules/beauty-amp-core2": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/beauty-amp-core2/-/beauty-amp-core2-0.4.5.tgz", + "integrity": "sha512-mhmHf8/6qf1yCdqkL66j9T3C5Z0Q+jP+XWK6ajnA+L/cG3bEjnN6ywRy97eSzij5JVSRNxs8w2857whB6+o5jw==", + "dependencies": { + "lodash": "^4.17.21", + "prettier": "^2.8.8" + } + }, + "node_modules/beauty-amp-core2/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } }, "node_modules/big-integer": { "version": "1.6.51", @@ -1317,19 +1335,18 @@ } }, "node_modules/c8": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/c8/-/c8-8.0.1.tgz", - "integrity": "sha512-EINpopxZNH1mETuI0DzRA4MZpAUH+IFiRhnmFD3vFr3vdrgxqi3VfE3KL0AIL+zDq8rC9bZqwM/VDmmoe04y7w==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-9.1.0.tgz", + "integrity": "sha512-mBWcT5iqNir1zIkzSPyI3NCR9EZCVI3WUD+AVO17MVWTSFNyUueXE82qTeampNtTr+ilN/5Ua3j24LgbCKjDVg==", "dev": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@istanbuljs/schema": "^0.1.3", "find-up": "^5.0.0", - "foreground-child": "^2.0.0", + "foreground-child": "^3.1.1", "istanbul-lib-coverage": "^3.2.0", "istanbul-lib-report": "^3.0.1", "istanbul-reports": "^3.1.6", - "rimraf": "^3.0.2", "test-exclude": "^6.0.0", "v8-to-istanbul": "^9.0.0", "yargs": "^17.7.2", @@ -1339,7 +1356,7 @@ "c8": "bin/c8.js" }, "engines": { - "node": ">=12" + "node": ">=14.14.0" } }, "node_modules/cache-point": { @@ -1374,12 +1391,13 @@ } }, "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -1911,21 +1929,22 @@ "dev": true }, "node_modules/conf": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/conf/-/conf-11.0.1.tgz", - "integrity": "sha512-WlLiQboEjKx0bYx2IIRGedBgNjLAxtwPaCSnsjWPST5xR0DB4q8lcsO/bEH9ZRYNcj63Y9vj/JG/5Fg6uWzI0Q==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/conf/-/conf-12.0.0.tgz", + "integrity": "sha512-fIWyWUXrJ45cHCIQX+Ck1hrZDIf/9DR0P0Zewn3uNht28hbt5OfGUq8rRWsxi96pZWPyBEd0eY9ama01JTaknA==", "dependencies": { "ajv": "^8.12.0", "ajv-formats": "^2.1.1", - "atomically": "^2.0.0", + "atomically": "^2.0.2", "debounce-fn": "^5.1.2", - "dot-prop": "^7.2.0", + "dot-prop": "^8.0.2", "env-paths": "^3.0.0", "json-schema-typed": "^8.0.1", - "semver": "^7.3.8" + "semver": "^7.5.4", + "uint8array-extras": "^0.3.0" }, "engines": { - "node": ">=14.16" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -2102,14 +2121,14 @@ } }, "node_modules/deep-equal": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.2.tgz", - "integrity": "sha512-xjVyBf0w5vH0I42jdAZzOKVldmPgSulmiyPRywoyq7HXC9qdgo17kxJE+rdnif5Tz6+pIrpJI8dCpMNLIGkUiA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz", + "integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==", "dependencies": { "array-buffer-byte-length": "^1.0.0", - "call-bind": "^1.0.2", + "call-bind": "^1.0.5", "es-get-iterator": "^1.1.3", - "get-intrinsic": "^1.2.1", + "get-intrinsic": "^1.2.2", "is-arguments": "^1.1.1", "is-array-buffer": "^3.0.2", "is-date-object": "^1.0.5", @@ -2119,11 +2138,14 @@ "object-is": "^1.1.5", "object-keys": "^1.1.1", "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.0", + "regexp.prototype.flags": "^1.5.1", "side-channel": "^1.0.4", "which-boxed-primitive": "^1.0.2", "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2151,6 +2173,19 @@ "clone": "^1.0.2" } }, + "node_modules/define-data-property": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", + "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/define-properties": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz", @@ -2251,25 +2286,25 @@ } }, "node_modules/dot-prop": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-7.2.0.tgz", - "integrity": "sha512-Ol/IPXUARn9CSbkrdV4VJo7uCy1I3VuSiWCaFSg+8BdUOzF9n3jefIpcgAydvUZbTdEBZs2vEiTiS9m61ssiDA==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-8.0.2.tgz", + "integrity": "sha512-xaBe6ZT4DHPkg0k4Ytbvn5xoxgpG0jOS1dYxSOwAHPuNLjP3/OzN0gH55SrLqpx8cBfSaVt91lXYkApjb+nYdQ==", "dependencies": { - "type-fest": "^2.11.2" + "type-fest": "^3.8.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/dot-prop/node_modules/type-fest": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", - "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", + "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==", "engines": { - "node": ">=12.20" + "node": ">=14.16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -2490,9 +2525,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz", - "integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" @@ -3157,16 +3192,31 @@ } }, "node_modules/foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", "dev": true, "dependencies": { "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" + "signal-exit": "^4.0.1" }, "engines": { - "node": ">=8.0.0" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/form-data": { @@ -3232,9 +3282,12 @@ } }, "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/functions-have-names": { "version": "1.2.3", @@ -3274,14 +3327,14 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", - "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", + "function-bind": "^1.1.2", "has-proto": "^1.0.1", - "has-symbols": "^1.0.3" + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3506,11 +3559,11 @@ } }, "node_modules/has-property-descriptors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", - "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", "dependencies": { - "get-intrinsic": "^1.1.1" + "get-intrinsic": "^1.2.2" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3563,6 +3616,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -6267,9 +6331,9 @@ } }, "node_modules/prettier": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", - "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.4.tgz", + "integrity": "sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==", "bin": { "prettier": "bin/prettier.cjs" }, @@ -6694,13 +6758,13 @@ } }, "node_modules/regexp.prototype.flags": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", - "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz", + "integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", - "functions-have-names": "^1.2.3" + "set-function-name": "^2.0.0" }, "engines": { "node": ">= 0.4" @@ -6929,6 +6993,34 @@ "randombytes": "^2.1.0" } }, + "node_modules/set-function-length": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", + "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "dependencies": { + "define-data-property": "^1.1.1", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.2", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz", + "integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==", + "dependencies": { + "define-data-property": "^1.0.1", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/sfmc-sdk": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/sfmc-sdk/-/sfmc-sdk-2.0.1.tgz", @@ -7361,9 +7453,9 @@ "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" }, "node_modules/stubborn-fs": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/stubborn-fs/-/stubborn-fs-1.2.4.tgz", - "integrity": "sha512-KRa4nIRJ8q6uApQbPwYZVhOof8979fw4xbajBWa5kPJFa4nyY3aFaMWVyIVCDnkNCCG/3HLipUZ4QaNlYsmX1w==" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/stubborn-fs/-/stubborn-fs-1.2.5.tgz", + "integrity": "sha512-H2N9c26eXjzL/S/K+i/RHHcFanE74dptvvjM8iwzwbVcWY/zjBbgRqF3K0DY4+OD+uTTASTBvDoxPDaPN02D7g==" }, "node_modules/supports-color": { "version": "7.2.0", @@ -7627,6 +7719,17 @@ "node": ">=0.8.0" } }, + "node_modules/uint8array-extras": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-0.3.0.tgz", + "integrity": "sha512-erJsJwQ0tKdwuqI0359U8ijkFmfiTcq25JvvzRVc1VP+2son1NJRXhxcAKJmAW3ajM8JSGAfsAXye8g4s+znxA==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -7869,9 +7972,9 @@ } }, "node_modules/when-exit": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/when-exit/-/when-exit-2.1.0.tgz", - "integrity": "sha512-H85ulNwUBU1e6PGxkWUDgxnbohSXD++ah6Xw1VHAN7CtypcbZaC4aYjQ+C2PMVaDkURDuOinNAT+Lnz3utWXxQ==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/when-exit/-/when-exit-2.1.2.tgz", + "integrity": "sha512-u9J+toaf3CCxCAzM/484qNAxQE75rFdVgiFEEV8Xps2gzYhf0tx73s1WXDQhkwV17E3MxRMz40m7Ekd2/121Lg==" }, "node_modules/which": { "version": "2.0.2", @@ -7918,16 +8021,15 @@ } }, "node_modules/which-typed-array": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", - "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.13.tgz", + "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", "dependencies": { "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", + "call-bind": "^1.0.4", "for-each": "^0.3.3", "gopd": "^1.0.1", - "has-tostringtag": "^1.0.0", - "is-typed-array": "^1.1.10" + "has-tostringtag": "^1.0.0" }, "engines": { "node": ">= 0.4" diff --git a/package.json b/package.json index 8c52c9695..a8321efb5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcdev", - "version": "6.0.1", + "version": "6.0.2", "description": "Accenture Salesforce Marketing Cloud DevTools", "author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas", "license": "MIT", @@ -63,18 +63,18 @@ "version:patch": "npm version --no-commit-hooks patch" }, "dependencies": { - "beauty-amp-core": "0.3.7", + "beauty-amp-core2": "0.4.5", "cli-progress": "3.12.0", "command-exists": "1.2.9", - "conf": "11.0.1", + "conf": "12.0.0", "console.table": "0.10.0", - "deep-equal": "2.2.2", + "deep-equal": "2.2.3", "fs-extra": "11.1.1", "inquirer": "9.2.6", "json-to-table": "4.2.1", "mustache": "4.2.0", "p-limit": "4.0.0", - "prettier": "3.1.1", + "prettier": "3.2.4", "prettier-plugin-sql": "0.15.1", "semver": "7.5.4", "sfmc-sdk": "2.0.1", @@ -87,11 +87,11 @@ "devDependencies": { "assert": "2.1.0", "axios-mock-adapter": "1.22.0", - "c8": "8.0.1", + "c8": "9.1.0", "chai": "4.3.10", "chai-files": "1.4.0", "eslint": "8.56.0", - "eslint-config-prettier": "9.0.0", + "eslint-config-prettier": "9.1.0", "eslint-config-ssjs": "1.1.11", "eslint-plugin-jsdoc": "48.0.2", "eslint-plugin-mocha": "10.2.0", diff --git a/test/mockRoot/.mcdevrc.json b/test/mockRoot/.mcdevrc.json index 2106df40c..d7811fb20 100644 --- a/test/mockRoot/.mcdevrc.json +++ b/test/mockRoot/.mcdevrc.json @@ -78,5 +78,5 @@ "triggeredSend" ] }, - "version": "6.0.1" + "version": "6.0.2" } diff --git a/test/resources/9999999/asset/block-1157-retrieve-expected.html b/test/resources/9999999/asset/block-1157-retrieve-expected.html index eec6813cd..a4023930f 100644 --- a/test/resources/9999999/asset/block-1157-retrieve-expected.html +++ b/test/resources/9999999/asset/block-1157-retrieve-expected.html @@ -1,13 +1,22 @@ - + + diff --git a/test/resources/9999999/automation/v1/scripts/get-response.json b/test/resources/9999999/automation/v1/scripts/get-response.json index d928b6361..b19640196 100644 --- a/test/resources/9999999/automation/v1/scripts/get-response.json +++ b/test/resources/9999999/automation/v1/scripts/get-response.json @@ -1,5 +1,5 @@ { - "count": 1, + "count": 5, "page": 1, "pageSize": 500, "items": [ @@ -8,7 +8,7 @@ "name": "testExisting_script", "key": "testExisting_script", "description": "", - "script": "", + "script": " ", "categoryId": 304, "createdDate": "2022-10-20T00:41:26.163", "modifiedDate": "2022-10-20T00:41:26.163" @@ -22,6 +22,36 @@ "categoryId": 304, "createdDate": "2022-10-20T00:41:26.163", "modifiedDate": "2022-10-20T00:41:26.163" + }, + { + "ssjsActivityId": "39f6a488-20eb-4ba0-b0b9-ampscript", + "name": "testExisting_script_ampscript", + "key": "testExisting_script_ampscript", + "description": "", + "script": "line1 %%[ SET @test='bla bla' ]%% line2 %%= v(@test) =%% still line2\nline3", + "categoryId": 304, + "createdDate": "2022-10-20T00:41:26.163", + "modifiedDate": "2022-10-20T00:41:26.163" + }, + { + "ssjsActivityId": "39f6a488-20eb-4ba0-b0b9-ampincluded", + "name": "testExisting_script_ampincluded", + "key": "testExisting_script_ampincluded", + "description": "", + "script": " ", + "categoryId": 304, + "createdDate": "2022-10-20T00:41:26.163", + "modifiedDate": "2022-10-20T00:41:26.163" + }, + { + "ssjsActivityId": "39f6a488-20eb-4ba0-b0b9-mixed", + "name": "testExisting_script_mixed", + "key": "testExisting_script_mixed", + "description": "", + "script": " line1 %%[ SET @test='bla bla' ]%% line2 %%= v(@test) =%% still line2;\n collapsed to line2 because it's assumed HTML\n", + "categoryId": 304, + "createdDate": "2022-10-20T00:41:26.163", + "modifiedDate": "2022-10-20T00:41:26.163" } ] } diff --git a/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json b/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json index b256ebe20..8b716a497 100644 --- a/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json +++ b/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json @@ -39,7 +39,7 @@ "createdBy": { "id": "abcabcabc", "name": "xyz app user" }, "restriction": "NONE", "keywordType": "NORMAL", - "responseMessage": "line1\nline2", + "responseMessage": "line1 %%[ SET @test='bla bla' ]%% line2 %%= v(@test) =%% still line2\nline3", "isInherited": false, "decodedId": "9e2192ab-f611-4039-86a8-7ce0ccf3a453" } diff --git a/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json b/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json index 8cf078833..ff19924a8 100644 --- a/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json +++ b/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json @@ -8,7 +8,7 @@ "lastUpdated": "2023-03-08T16:30:00Z", "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "testExisting_mobileMessage", - "text": "test message jb secret", + "text": "line1 %%[ SET @test='bla bla' ]%% line2 %%= v(@test) =%% still line2\nline3", "origin": "SMS Send", "code": { "id": "RXBwc0JoNk9jVTY0YWJNWFZDaGxvdzo4MTow", diff --git a/test/resources/9999999/messaging/v1/sms/definitions/post-response.json b/test/resources/9999999/messaging/v1/sms/definitions/post-response.json index d78803aa8..6067d13eb 100644 --- a/test/resources/9999999/messaging/v1/sms/definitions/post-response.json +++ b/test/resources/9999999/messaging/v1/sms/definitions/post-response.json @@ -6,7 +6,9 @@ "status": "Active", "createdDate": "2022-11-07T02:24:00", "modifiedDate": "2022-11-07T02:25:00", - "content": { "message": "\n%%[\n SET @key = 'new secret'\n]%%\n" }, + "content": { + "message": "\n%%[\n SET @key = 'new secret'\n]%%\n%%[\n\nSET @unsubMessages = 'UnsubscribeSMSMessages_DEV'\nSET @unsubEvents = 'UnsubscribeSMS_DEV'\n\nSET @num = concat('+',[MOBILE_NUMBER])\nSET @rs= RetrieveSalesforceObjects('Contact','Id,et4ae5__HasOptedOutOfMobile__c', 'MobilePhone', '=',@num) \nSET @count = rowCount(@rs)\nVAR @response\nSET @rx = '^\\+((?:9[679]\\d8[035789]\\d|6[789]\\d|5[90]\\d|42\\d|3[578]\\d|2[1-689]\\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)'\nSET @prefix = concat('+',RegExMatch(@num, @rx, 1))\nIF @count>0 THEN\n\tFOR @i = 1 TO @count DO\n\t\tSET @sk = Field(Row(@rs,@i),'Id')\n\t\tIF Field(Row(@rs,1),'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN\n\t\t\tSET @result = UpdateSingleSalesforceObject('Contact',@sk,'et4ae5__HasOptedOutOfMobile__c','true')\n\t\t\tIF @result == 0 THEN \n\t\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Error Updating')\n\t\t\tELSE \n\t\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Successfully Unsubscribed')\n\t\t\tENDIF\n\t\tELSE \n\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Already Unsubscribed')\n\t\tENDIF\n\n\tNEXT @i\n\n\tSET @msg = Lookup(@unsubMessages,'Message','Prefix',@prefix,'Type', 'Found')\n\tIF Length(@msg) == 0 THEN\n\t\tSET @response ='You have unsubscribed and will no longer receive any messages.|'\n\tELSE \n\t\tSET @response = @msg\n\tENDIF\nELSE \n\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'Status', 'Not Found') \n\tSET @msg = Lookup(@unsubMessages,'Message','Prefix',@prefix,'Type', 'NotFound')\n\tIF Length(@msg) == 0 THEN\n\t\tSET @response ='Sorry, we could not find you'\n\tELSE \n\t\tSET @response = @msg\n\tENDIF\nENDIF\n]%%\n%%=v(@response)=%%" + }, "subscriptions": { "shortCode": "4912312345678", "countryCode": "", diff --git a/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json b/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json index e42c625ff..4a154f3d0 100644 --- a/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json +++ b/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json @@ -7,7 +7,9 @@ "status": "Active", "createdDate": "2022-11-07T02:24:00", "modifiedDate": "2022-11-07T02:25:00", - "content": { "message": "%%[ SET @key = 'secret' ]%%" }, + "content": { + "message": "line1 %%[ SET @test='bla bla' ]%% line2 %%= v(@test) =%% still line2\nline3 %%[ SET @key = 'secret' ]%%\n%%[\n\nSET @unsubMessages = 'UnsubscribeSMSMessages_DEV'\nSET @unsubEvents = 'UnsubscribeSMS_DEV'\n\nSET @num = concat('+',[MOBILE_NUMBER])\nSET @rs= RetrieveSalesforceObjects('Contact','Id,et4ae5__HasOptedOutOfMobile__c', 'MobilePhone', '=',@num) \nSET @count = rowCount(@rs)\nVAR @response\nSET @rx = '^\\+((?:9[679]\\d8[035789]\\d|6[789]\\d|5[90]\\d|42\\d|3[578]\\d|2[1-689]\\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)'\nSET @prefix = concat('+',RegExMatch(@num, @rx, 1))\nIF @count>0 THEN\n\tFOR @i = 1 TO @count DO\n\t\tSET @sk = Field(Row(@rs,@i),'Id')\n\t\tIF Field(Row(@rs,1),'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN\n\t\t\tSET @result = UpdateSingleSalesforceObject('Contact',@sk,'et4ae5__HasOptedOutOfMobile__c','true')\n\t\t\tIF @result == 0 THEN \n\t\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Error Updating')\n\t\t\tELSE \n\t\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Successfully Unsubscribed')\n\t\t\tENDIF\n\t\tELSE \n\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Already Unsubscribed')\n\t\tENDIF\n\n\tNEXT @i\n\n\tSET @msg = Lookup(@unsubMessages,'Message','Prefix',@prefix,'Type', 'Found')\n\tIF Length(@msg) == 0 THEN\n\t\tSET @response ='You have unsubscribed and will no longer receive any messages.|'\n\tELSE \n\t\tSET @response = @msg\n\tENDIF\nELSE \n\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'Status', 'Not Found') \n\tSET @msg = Lookup(@unsubMessages,'Message','Prefix',@prefix,'Type', 'NotFound')\n\tIF Length(@msg) == 0 THEN\n\t\tSET @response ='Sorry, we could not find you'\n\tELSE \n\t\tSET @response = @msg\n\tENDIF\nENDIF\n]%%\n%%=v(@response)=%%" + }, "subscriptions": { "shortCode": "4912312345678", "countryCode": "", diff --git a/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json b/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json index e42c625ff..75fb1c122 100644 --- a/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json +++ b/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json @@ -7,7 +7,9 @@ "status": "Active", "createdDate": "2022-11-07T02:24:00", "modifiedDate": "2022-11-07T02:25:00", - "content": { "message": "%%[ SET @key = 'secret' ]%%" }, + "content": { + "message": "%%[ SET @key = 'secret' ]%%\n%%[\n\nSET @unsubMessages = 'UnsubscribeSMSMessages_DEV'\nSET @unsubEvents = 'UnsubscribeSMS_DEV'\n\nSET @num = concat('+',[MOBILE_NUMBER])\nSET @rs= RetrieveSalesforceObjects('Contact','Id,et4ae5__HasOptedOutOfMobile__c', 'MobilePhone', '=',@num) \nSET @count = rowCount(@rs)\nVAR @response\nSET @rx = '^\\+((?:9[679]\\d8[035789]\\d|6[789]\\d|5[90]\\d|42\\d|3[578]\\d|2[1-689]\\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)'\nSET @prefix = concat('+',RegExMatch(@num, @rx, 1))\nIF @count>0 THEN\n\tFOR @i = 1 TO @count DO\n\t\tSET @sk = Field(Row(@rs,@i),'Id')\n\t\tIF Field(Row(@rs,1),'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN\n\t\t\tSET @result = UpdateSingleSalesforceObject('Contact',@sk,'et4ae5__HasOptedOutOfMobile__c','true')\n\t\t\tIF @result == 0 THEN \n\t\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Error Updating')\n\t\t\tELSE \n\t\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Successfully Unsubscribed')\n\t\t\tENDIF\n\t\tELSE \n\t\t\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'ContactId',@sk,'Status', 'Already Unsubscribed')\n\t\tENDIF\n\n\tNEXT @i\n\n\tSET @msg = Lookup(@unsubMessages,'Message','Prefix',@prefix,'Type', 'Found')\n\tIF Length(@msg) == 0 THEN\n\t\tSET @response ='You have unsubscribed and will no longer receive any messages.|'\n\tELSE \n\t\tSET @response = @msg\n\tENDIF\nELSE \n\tInsertData(@unsubEvents,'MobileNumber',@num,'Message',[MSG(0).NOUNS],'Status', 'Not Found') \n\tSET @msg = Lookup(@unsubMessages,'Message','Prefix',@prefix,'Type', 'NotFound')\n\tIF Length(@msg) == 0 THEN\n\t\tSET @response ='Sorry, we could not find you'\n\tELSE \n\t\tSET @response = @msg\n\tENDIF\nENDIF\n]%%\n%%=v(@response)=%%" + }, "subscriptions": { "shortCode": "4912312345678", "countryCode": "", diff --git a/test/resources/9999999/mobileKeyword/build-expected.amp b/test/resources/9999999/mobileKeyword/build-expected.amp index f8be7bb82..d5ac0a44d 100644 --- a/test/resources/9999999/mobileKeyword/build-expected.amp +++ b/test/resources/9999999/mobileKeyword/build-expected.amp @@ -1,2 +1,6 @@ line1 -line2 \ No newline at end of file +%%[ + SET @test = 'foobar' +]%% +line2 %%= v(@test) =%% still line2 +line3 diff --git a/test/resources/9999999/mobileKeyword/get-expected.amp b/test/resources/9999999/mobileKeyword/get-expected.amp index f8be7bb82..f525314af 100644 --- a/test/resources/9999999/mobileKeyword/get-expected.amp +++ b/test/resources/9999999/mobileKeyword/get-expected.amp @@ -1,2 +1,6 @@ line1 -line2 \ No newline at end of file +%%[ + SET @test = 'bla bla' +]%% +line2 %%= v(@test) =%% still line2 +line3 diff --git a/test/resources/9999999/mobileKeyword/post-create-expected.amp b/test/resources/9999999/mobileKeyword/post-create-expected.amp index f8be7bb82..c0d0fb45c 100644 --- a/test/resources/9999999/mobileKeyword/post-create-expected.amp +++ b/test/resources/9999999/mobileKeyword/post-create-expected.amp @@ -1,2 +1,2 @@ line1 -line2 \ No newline at end of file +line2 diff --git a/test/resources/9999999/mobileKeyword/template-expected.amp b/test/resources/9999999/mobileKeyword/template-expected.amp index f8be7bb82..936f8c5c5 100644 --- a/test/resources/9999999/mobileKeyword/template-expected.amp +++ b/test/resources/9999999/mobileKeyword/template-expected.amp @@ -1,2 +1,6 @@ line1 -line2 \ No newline at end of file +%%[ + SET @test = '{{{description}}}' +]%% +line2 %%= v(@test) =%% still line2 +line3 diff --git a/test/resources/9999999/mobileMessage/build-expected.amp b/test/resources/9999999/mobileMessage/build-expected.amp index 2717f2fb5..d5ac0a44d 100644 --- a/test/resources/9999999/mobileMessage/build-expected.amp +++ b/test/resources/9999999/mobileMessage/build-expected.amp @@ -1 +1,6 @@ -test message jb target secret \ No newline at end of file +line1 +%%[ + SET @test = 'foobar' +]%% +line2 %%= v(@test) =%% still line2 +line3 diff --git a/test/resources/9999999/mobileMessage/get-expected.amp b/test/resources/9999999/mobileMessage/get-expected.amp index 9e2605fbc..f525314af 100644 --- a/test/resources/9999999/mobileMessage/get-expected.amp +++ b/test/resources/9999999/mobileMessage/get-expected.amp @@ -1 +1,6 @@ -test message jb secret \ No newline at end of file +line1 +%%[ + SET @test = 'bla bla' +]%% +line2 %%= v(@test) =%% still line2 +line3 diff --git a/test/resources/9999999/mobileMessage/post-create-expected.amp b/test/resources/9999999/mobileMessage/post-create-expected.amp index 5cd044454..3e5727b71 100644 --- a/test/resources/9999999/mobileMessage/post-create-expected.amp +++ b/test/resources/9999999/mobileMessage/post-create-expected.amp @@ -1 +1 @@ -New Task Available \ No newline at end of file +New Task Available diff --git a/test/resources/9999999/mobileMessage/post-update-expected.amp b/test/resources/9999999/mobileMessage/post-update-expected.amp index 0639ff611..d389984de 100644 --- a/test/resources/9999999/mobileMessage/post-update-expected.amp +++ b/test/resources/9999999/mobileMessage/post-update-expected.amp @@ -1 +1 @@ -test message jb new \ No newline at end of file +test message jb new diff --git a/test/resources/9999999/mobileMessage/template-expected.amp b/test/resources/9999999/mobileMessage/template-expected.amp index bb1bc863d..936f8c5c5 100644 --- a/test/resources/9999999/mobileMessage/template-expected.amp +++ b/test/resources/9999999/mobileMessage/template-expected.amp @@ -1 +1,6 @@ -test message jb {{{secret}}} \ No newline at end of file +line1 +%%[ + SET @test = '{{{description}}}' +]%% +line2 %%= v(@test) =%% still line2 +line3 diff --git a/test/resources/9999999/script/get_ampincluded-expected.json b/test/resources/9999999/script/get_ampincluded-expected.json new file mode 100644 index 000000000..b801f5140 --- /dev/null +++ b/test/resources/9999999/script/get_ampincluded-expected.json @@ -0,0 +1,8 @@ +{ + "createdDate": "2022-10-20T00:41:26.163", + "description": "", + "key": "testExisting_script_ampincluded", + "modifiedDate": "2022-10-20T00:41:26.163", + "name": "testExisting_script_ampincluded", + "r__folder_Path": "Scripts" +} diff --git a/test/resources/9999999/script/get_ampincluded-expected.ssjs b/test/resources/9999999/script/get_ampincluded-expected.ssjs new file mode 100644 index 000000000..8c5acec4b --- /dev/null +++ b/test/resources/9999999/script/get_ampincluded-expected.ssjs @@ -0,0 +1,5 @@ +line1 +%%[ + SET @test = 'bla bla' +]%% +line2 %%= v(@test) =%% still line2 line3 diff --git a/test/resources/9999999/script/get_ampscript-expected.html b/test/resources/9999999/script/get_ampscript-expected.html new file mode 100644 index 000000000..8c5acec4b --- /dev/null +++ b/test/resources/9999999/script/get_ampscript-expected.html @@ -0,0 +1,5 @@ +line1 +%%[ + SET @test = 'bla bla' +]%% +line2 %%= v(@test) =%% still line2 line3 diff --git a/test/resources/9999999/script/get_ampscript-expected.json b/test/resources/9999999/script/get_ampscript-expected.json new file mode 100644 index 000000000..949cbc253 --- /dev/null +++ b/test/resources/9999999/script/get_ampscript-expected.json @@ -0,0 +1,8 @@ +{ + "createdDate": "2022-10-20T00:41:26.163", + "description": "", + "key": "testExisting_script_ampscript", + "modifiedDate": "2022-10-20T00:41:26.163", + "name": "testExisting_script_ampscript", + "r__folder_Path": "Scripts" +} diff --git a/test/resources/9999999/script/get_mixed-expected.html b/test/resources/9999999/script/get_mixed-expected.html new file mode 100644 index 000000000..87ae1266f --- /dev/null +++ b/test/resources/9999999/script/get_mixed-expected.html @@ -0,0 +1,9 @@ + +line1 +%%[ + SET @test = 'bla bla' +]%% +line2 %%= v(@test) =%% still line2; collapsed to line2 because +it's assumed HTML diff --git a/test/resources/9999999/script/get_mixed-expected.json b/test/resources/9999999/script/get_mixed-expected.json new file mode 100644 index 000000000..c217d3cb1 --- /dev/null +++ b/test/resources/9999999/script/get_mixed-expected.json @@ -0,0 +1,8 @@ +{ + "createdDate": "2022-10-20T00:41:26.163", + "description": "", + "key": "testExisting_script_mixed", + "modifiedDate": "2022-10-20T00:41:26.163", + "name": "testExisting_script_mixed", + "r__folder_Path": "Scripts" +} diff --git a/test/resources/9999999/transactionalSMS/build-expected.amp b/test/resources/9999999/transactionalSMS/build-expected.amp index 006734caf..90327ec0e 100644 --- a/test/resources/9999999/transactionalSMS/build-expected.amp +++ b/test/resources/9999999/transactionalSMS/build-expected.amp @@ -1,4 +1,108 @@ - +line1 +%%[ + SET @test = 'foobar' +]%% +line2 %%= v(@test) =%% still line2 +line3 %%[ SET @key = 'target secret' ]%% + +%%[ + SET @unsubMessages = 'UnsubscribeSMSMessages_DEV' + SET @unsubEvents = 'UnsubscribeSMS_DEV' + SET @num = concat('+', [MOBILE_NUMBER]) + SET @rs = RetrieveSalesforceObjects( + 'Contact', + 'Id,et4ae5__HasOptedOutOfMobile__c', + 'MobilePhone', + '=', + @num + ) + SET @count = rowCount(@rs) + VAR @response + SET @rx = '^\+((?:9[679]\d8[035789]\d|6[789]\d|5[90]\d|42\d|3[578]\d|2[1-689]\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)' + SET @prefix = concat('+', RegExMatch(@num, @rx, 1)) + IF @count>0 THEN + FOR @I = 1 TO @COUNT DO + SET @sk = Field(Row(@rs, @i), 'Id') + IF Field(Row(@rs, 1), 'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN + SET @result = UpdateSingleSalesforceObject('Contact', @sk, 'et4ae5__HasOptedOutOfMobile__c', 'true') + IF @result == 0 THEN + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Error Updating' + ) + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Successfully Unsubscribed' + ) + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Already Unsubscribed' + ) + ENDIF + NEXT @i + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'Found' + ) + IF Length(@msg) == 0 THEN + SET @response = 'You have unsubscribed and will no longer receive any messages.|' + ELSE + SET @response = @msg + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'Status', + 'Not Found' + ) + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'NotFound' + ) + IF Length(@msg) == 0 THEN + SET @response = 'Sorry, we could not find you' + ELSE + SET @response = @msg + ENDIF + ENDIF +]%% +%%=v(@response)=%% diff --git a/test/resources/9999999/transactionalSMS/get-expected.amp b/test/resources/9999999/transactionalSMS/get-expected.amp index e4c5aff95..550ecfdd8 100644 --- a/test/resources/9999999/transactionalSMS/get-expected.amp +++ b/test/resources/9999999/transactionalSMS/get-expected.amp @@ -1,4 +1,108 @@ - +line1 +%%[ + SET @test = 'bla bla' +]%% +line2 %%= v(@test) =%% still line2 +line3 %%[ SET @key = 'secret' ]%% + +%%[ + SET @unsubMessages = 'UnsubscribeSMSMessages_DEV' + SET @unsubEvents = 'UnsubscribeSMS_DEV' + SET @num = concat('+', [MOBILE_NUMBER]) + SET @rs = RetrieveSalesforceObjects( + 'Contact', + 'Id,et4ae5__HasOptedOutOfMobile__c', + 'MobilePhone', + '=', + @num + ) + SET @count = rowCount(@rs) + VAR @response + SET @rx = '^\+((?:9[679]\d8[035789]\d|6[789]\d|5[90]\d|42\d|3[578]\d|2[1-689]\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)' + SET @prefix = concat('+', RegExMatch(@num, @rx, 1)) + IF @count>0 THEN + FOR @I = 1 TO @COUNT DO + SET @sk = Field(Row(@rs, @i), 'Id') + IF Field(Row(@rs, 1), 'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN + SET @result = UpdateSingleSalesforceObject('Contact', @sk, 'et4ae5__HasOptedOutOfMobile__c', 'true') + IF @result == 0 THEN + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Error Updating' + ) + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Successfully Unsubscribed' + ) + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Already Unsubscribed' + ) + ENDIF + NEXT @i + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'Found' + ) + IF Length(@msg) == 0 THEN + SET @response = 'You have unsubscribed and will no longer receive any messages.|' + ELSE + SET @response = @msg + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'Status', + 'Not Found' + ) + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'NotFound' + ) + IF Length(@msg) == 0 THEN + SET @response = 'Sorry, we could not find you' + ELSE + SET @response = @msg + ENDIF + ENDIF +]%% +%%=v(@response)=%% diff --git a/test/resources/9999999/transactionalSMS/patch-expected.amp b/test/resources/9999999/transactionalSMS/patch-expected.amp index e4c5aff95..e1ef91076 100644 --- a/test/resources/9999999/transactionalSMS/patch-expected.amp +++ b/test/resources/9999999/transactionalSMS/patch-expected.amp @@ -1,4 +1,102 @@ - %%[ SET @key = 'secret' ]%% + +%%[ + SET @unsubMessages = 'UnsubscribeSMSMessages_DEV' + SET @unsubEvents = 'UnsubscribeSMS_DEV' + SET @num = concat('+', [MOBILE_NUMBER]) + SET @rs = RetrieveSalesforceObjects( + 'Contact', + 'Id,et4ae5__HasOptedOutOfMobile__c', + 'MobilePhone', + '=', + @num + ) + SET @count = rowCount(@rs) + VAR @response + SET @rx = '^\+((?:9[679]\d8[035789]\d|6[789]\d|5[90]\d|42\d|3[578]\d|2[1-689]\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)' + SET @prefix = concat('+', RegExMatch(@num, @rx, 1)) + IF @count>0 THEN + FOR @I = 1 TO @COUNT DO + SET @sk = Field(Row(@rs, @i), 'Id') + IF Field(Row(@rs, 1), 'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN + SET @result = UpdateSingleSalesforceObject('Contact', @sk, 'et4ae5__HasOptedOutOfMobile__c', 'true') + IF @result == 0 THEN + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Error Updating' + ) + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Successfully Unsubscribed' + ) + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Already Unsubscribed' + ) + ENDIF + NEXT @i + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'Found' + ) + IF Length(@msg) == 0 THEN + SET @response = 'You have unsubscribed and will no longer receive any messages.|' + ELSE + SET @response = @msg + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'Status', + 'Not Found' + ) + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'NotFound' + ) + IF Length(@msg) == 0 THEN + SET @response = 'Sorry, we could not find you' + ELSE + SET @response = @msg + ENDIF + ENDIF +]%% +%%=v(@response)=%% diff --git a/test/resources/9999999/transactionalSMS/post-expected.amp b/test/resources/9999999/transactionalSMS/post-expected.amp index a1f4bd04f..b11a84731 100644 --- a/test/resources/9999999/transactionalSMS/post-expected.amp +++ b/test/resources/9999999/transactionalSMS/post-expected.amp @@ -1,4 +1,102 @@ - %%[ SET @key = 'new secret' ]%% + +%%[ + SET @unsubMessages = 'UnsubscribeSMSMessages_DEV' + SET @unsubEvents = 'UnsubscribeSMS_DEV' + SET @num = concat('+', [MOBILE_NUMBER]) + SET @rs = RetrieveSalesforceObjects( + 'Contact', + 'Id,et4ae5__HasOptedOutOfMobile__c', + 'MobilePhone', + '=', + @num + ) + SET @count = rowCount(@rs) + VAR @response + SET @rx = '^\+((?:9[679]\d8[035789]\d|6[789]\d|5[90]\d|42\d|3[578]\d|2[1-689]\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)' + SET @prefix = concat('+', RegExMatch(@num, @rx, 1)) + IF @count>0 THEN + FOR @I = 1 TO @COUNT DO + SET @sk = Field(Row(@rs, @i), 'Id') + IF Field(Row(@rs, 1), 'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN + SET @result = UpdateSingleSalesforceObject('Contact', @sk, 'et4ae5__HasOptedOutOfMobile__c', 'true') + IF @result == 0 THEN + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Error Updating' + ) + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Successfully Unsubscribed' + ) + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Already Unsubscribed' + ) + ENDIF + NEXT @i + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'Found' + ) + IF Length(@msg) == 0 THEN + SET @response = 'You have unsubscribed and will no longer receive any messages.|' + ELSE + SET @response = @msg + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'Status', + 'Not Found' + ) + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'NotFound' + ) + IF Length(@msg) == 0 THEN + SET @response = 'Sorry, we could not find you' + ELSE + SET @response = @msg + ENDIF + ENDIF +]%% +%%=v(@response)=%% diff --git a/test/resources/9999999/transactionalSMS/template-expected.amp b/test/resources/9999999/transactionalSMS/template-expected.amp index 29e5fcafe..26bc6dc2f 100644 --- a/test/resources/9999999/transactionalSMS/template-expected.amp +++ b/test/resources/9999999/transactionalSMS/template-expected.amp @@ -1,4 +1,108 @@ - +line1 +%%[ + SET @test = '{{{description}}}' +]%% +line2 %%= v(@test) =%% still line2 +line3 %%[ SET @key = '{{{secret}}}' ]%% + +%%[ + SET @unsubMessages = 'UnsubscribeSMSMessages_DEV' + SET @unsubEvents = 'UnsubscribeSMS_DEV' + SET @num = concat('+', [MOBILE_NUMBER]) + SET @rs = RetrieveSalesforceObjects( + 'Contact', + 'Id,et4ae5__HasOptedOutOfMobile__c', + 'MobilePhone', + '=', + @num + ) + SET @count = rowCount(@rs) + VAR @response + SET @rx = '^\+((?:9[679]\d8[035789]\d|6[789]\d|5[90]\d|42\d|3[578]\d|2[1-689]\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)' + SET @prefix = concat('+', RegExMatch(@num, @rx, 1)) + IF @count>0 THEN + FOR @I = 1 TO @COUNT DO + SET @sk = Field(Row(@rs, @i), 'Id') + IF Field(Row(@rs, 1), 'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN + SET @result = UpdateSingleSalesforceObject('Contact', @sk, 'et4ae5__HasOptedOutOfMobile__c', 'true') + IF @result == 0 THEN + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Error Updating' + ) + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Successfully Unsubscribed' + ) + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'ContactId', + @sk, + 'Status', + 'Already Unsubscribed' + ) + ENDIF + NEXT @i + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'Found' + ) + IF Length(@msg) == 0 THEN + SET @response = 'You have unsubscribed and will no longer receive any messages.|' + ELSE + SET @response = @msg + ENDIF + ELSE + InsertData( + @unsubEvents, + 'MobileNumber', + @num, + 'Message', + [MSG(0).NOUNS], + 'Status', + 'Not Found' + ) + SET @msg = Lookup( + @unsubMessages, + 'Message', + 'Prefix', + @prefix, + 'Type', + 'NotFound' + ) + IF Length(@msg) == 0 THEN + SET @response = 'Sorry, we could not find you' + ELSE + SET @response = @msg + ENDIF + ENDIF +]%% +%%=v(@response)=%% diff --git a/test/type.script.test.js b/test/type.script.test.js index d50fda9a1..215136ab5 100644 --- a/test/type.script.test.js +++ b/test/type.script.test.js @@ -20,22 +20,21 @@ describe('type: script', () => { const retrieve = await handler.retrieve('testInstance/testBU', ['script']); // THEN assert.equal(process.exitCode, false, 'retrieve should not have thrown an error'); - // retrieve result assert.equal( retrieve['testInstance/testBU'].script ? Object.keys(retrieve['testInstance/testBU'].script).length : 0, - 2, - 'only 2 scripts expected in retrieve response' + 5, + 'only 5 scripts expected in retrieve response' ); // get results from cache const result = cache.getCache(); assert.equal( result.script ? Object.keys(result.script).length : 0, - 2, - 'only 2 scripts expected' + 5, + 'only 5 scripts expected' ); // normal test assert.deepEqual( @@ -49,6 +48,7 @@ describe('type: script', () => { file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs')) ); + // test with no script tag assert.deepEqual( await testUtils.getActualJson('testExisting_script_noScriptTag', 'script'), await testUtils.getExpectedJson('9999999', 'script', 'get_noScriptTag'), @@ -63,6 +63,47 @@ describe('type: script', () => { file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs')) ).to.not.exist; + // test with ampscript + assert.deepEqual( + await testUtils.getActualJson('testExisting_script_ampscript', 'script'), + await testUtils.getExpectedJson('9999999', 'script', 'get_ampscript'), + 'returned metadata was not equal expected' + ); + expect( + file(testUtils.getActualFile('testExisting_script_ampscript', 'script', 'html')) + ).to.equal( + file(testUtils.getExpectedFile('9999999', 'script', 'get_ampscript', 'html')) + ); + expect(file(testUtils.getActualFile('testExisting_script_ampscript', 'script', 'ssjs'))) + .to.not.exist; + + // test with mixed code (ampscript inside of ssjs) + assert.deepEqual( + await testUtils.getActualJson('testExisting_script_ampincluded', 'script'), + await testUtils.getExpectedJson('9999999', 'script', 'get_ampincluded'), + 'returned metadata was not equal expected' + ); + expect( + file(testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'html')) + ).to.not.exist; + expect( + file(testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'ssjs')) + ).to.equal( + file(testUtils.getExpectedFile('9999999', 'script', 'get_ampincluded', 'ssjs')) + ); + + // test with mixed code (ssjs and ampscript side-by-side) + assert.deepEqual( + await testUtils.getActualJson('testExisting_script_mixed', 'script'), + await testUtils.getExpectedJson('9999999', 'script', 'get_mixed'), + 'returned metadata was not equal expected' + ); + expect( + file(testUtils.getActualFile('testExisting_script_mixed', 'script', 'html')) + ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'get_mixed', 'html'))); + expect(file(testUtils.getActualFile('testExisting_script_mixed', 'script', 'ssjs'))).to + .not.exist; + assert.equal( testUtils.getAPIHistoryLength(), 3, @@ -122,8 +163,8 @@ describe('type: script', () => { const result = cache.getCache(); assert.equal( result.script ? Object.keys(result.script).length : 0, - 2, - 'two scripts in cache expected' + 5, + '5 scripts in cache expected' ); assert.deepEqual( await testUtils.getActualJson('testExisting_script', 'script'), @@ -162,8 +203,8 @@ describe('type: script', () => { const result = cache.getCache(); assert.equal( result.script ? Object.keys(result.script).length : 0, - 2, - 'two scripts in cache expected' + 5, + '5 scripts in cache expected' ); expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.not @@ -189,8 +230,8 @@ describe('type: script', () => { const result = cache.getCache(); assert.equal( result.script ? Object.keys(result.script).length : 0, - 3, - 'three scripts expected' + 6, + '6 scripts expected' ); // confirm created item assert.deepEqual( @@ -198,15 +239,14 @@ describe('type: script', () => { await testUtils.getExpectedJson('9999999', 'script', 'post'), 'returned metadata was not equal expected for insert script' ); - expect(file(testUtils.getActualFile('testNew_script', 'script', 'ssjs'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'script', 'post', 'ssjs')) - ); // confirm updated item assert.deepEqual( await testUtils.getActualJson('testExisting_script', 'script'), await testUtils.getExpectedJson('9999999', 'script', 'patch'), 'returned metadata was not equal expected for insert script' ); + expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not + .exist; expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal( file(testUtils.getExpectedFile('9999999', 'script', 'patch', 'ssjs')) ); diff --git a/test/utils.js b/test/utils.js index f6404ee8c..98021ae80 100644 --- a/test/utils.js +++ b/test/utils.js @@ -156,6 +156,9 @@ export function mockSetup(isDeploy) { 'node_modules/prettier-plugin-sql': fsmock.load( path.resolve(__dirname, '../node_modules/prettier-plugin-sql') ), + 'node_modules/beauty-amp-core2': fsmock.load( + path.resolve(__dirname, '../node_modules/beauty-amp-core2') + ), 'node_modules/node-sql-parser': fsmock.load( path.resolve(__dirname, '../node_modules/node-sql-parser') ),