diff --git a/lib/metadataTypes/MobileMessage.js b/lib/metadataTypes/MobileMessage.js index 58390931d..7f2c56cda 100644 --- a/lib/metadataTypes/MobileMessage.js +++ b/lib/metadataTypes/MobileMessage.js @@ -165,7 +165,13 @@ class MobileMessage extends MetadataType { static postRetrieveTasks(metadata) { // mobileCode try { - cache.searchForField('mobileCode', metadata.code.code, 'code', 'code'); + metadata.r__mobileCode_code = cache.searchForField( + 'mobileCode', + metadata.code.code, + 'code', + 'code' + ); + delete metadata.code; } catch (ex) { Util.logger.warn( ` - ${this.definition.type} ${metadata[this.definition.nameField]} (${ @@ -175,11 +181,12 @@ class MobileMessage extends MetadataType { } // mobileKeyword + try { for (const attr of ['keyword', 'subscriptionKeyword', 'nextKeyword']) { if (metadata[attr]?.id) { metadata[attr] = { - c__codeKeyword: cache.searchForField( + r__mobileKeyword_c__codeKeyword: cache.searchForField( 'mobileKeyword', metadata[attr].id, 'id', @@ -198,7 +205,7 @@ class MobileMessage extends MetadataType { // campaign try { if (Array.isArray(metadata.campaigns)) { - metadata.c__campaignNames = []; + metadata.r__campaign_name = []; for (const campaign of metadata.campaigns) { try { @@ -208,7 +215,7 @@ class MobileMessage extends MetadataType { throw new Error(`campaign ${campaign.name} not found in cache`); } - metadata.c__campaignNames.push(campaign.name); + metadata.r__campaign_name.push(campaign.name); } catch (ex) { Util.logger.warn( ` - ${this.definition.type} ${metadata[this.definition.nameField]}: ${ @@ -267,19 +274,26 @@ class MobileMessage extends MetadataType { */ static async preDeployTasks(metadata, deployDir) { // mobileCode - const code = cache.getByKey('mobileCode', metadata.code.code); - if (!code) { - throw new Error(`mobileCode ${metadata.code.code} not found in cache`); + if (metadata.r__mobileCode_code) { + metadata.code ||= {}; + const code = cache.getByKey('mobileCode', metadata.r__mobileCode_code); + if (!code) { + throw new Error(`mobileCode ${metadata.r__mobileCode_code} not found in cache`); + } + metadata.code = code; + delete metadata.r__mobileCode_code; } - metadata.code = code; // mobileKeyword for (const attr of ['keyword', 'subscriptionKeyword', 'nextKeyword']) { - if (metadata[attr]?.c__codeKeyword) { - const keywordObj = cache.getByKey('mobileKeyword', metadata[attr].c__codeKeyword); + if (metadata[attr]?.r__mobileKeyword_c__codeKeyword) { + const keywordObj = cache.getByKey( + 'mobileKeyword', + metadata[attr].r__mobileKeyword_c__codeKeyword + ); if (!keywordObj) { throw new Error( - `mobileKeyword ${metadata[attr].c__codeKeyword} not found in cache` + `mobileKeyword ${metadata[attr].r__mobileKeyword_c__codeKeyword} not found in cache` ); } metadata[attr] = keywordObj; @@ -287,10 +301,10 @@ class MobileMessage extends MetadataType { } // campaign - if (Array.isArray(metadata.c__campaignNames)) { + if (Array.isArray(metadata.r__campaign_name)) { metadata.campaigns = []; - for (const campaignName of metadata.c__campaignNames) { + for (const campaignName of metadata.r__campaign_name) { const campaign = cache.getByKey('campaign', campaignName); if (!campaign) { throw new Error(`campaign ${campaignName} not found in cache`); @@ -304,7 +318,7 @@ class MobileMessage extends MetadataType { }, }); } - delete metadata.c__campaignNames; + delete metadata.r__campaign_name; } if (metadata.smsTriggeredSendDefinitionId !== '00000000-0000-0000-0000-000000000000') { diff --git a/lib/metadataTypes/definitions/MobileMessage.definition.js b/lib/metadataTypes/definitions/MobileMessage.definition.js index 70f02bbfa..914c3fb33 100644 --- a/lib/metadataTypes/definitions/MobileMessage.definition.js +++ b/lib/metadataTypes/definitions/MobileMessage.definition.js @@ -37,6 +37,12 @@ export default { 'campaigns[]': { skipValidation: true, }, + r__mobileCode_code: { + isCreateable: false, + isUpdateable: false, + retrieving: true, + template: true, + }, 'code.code': { isCreateable: true, isUpdateable: true, @@ -774,12 +780,12 @@ export default { retrieving: true, template: true, }, - c__campaignNames: { + r__campaign_name: { isCreateable: false, isUpdateable: false, retrieving: true, template: true, }, - 'c__campaignNames[]': { skipValidation: true }, + 'r__campaign_name[]': { skipValidation: true }, }, }; diff --git a/test/mockRoot/deploy/testInstance/testBU/mobileMessage/NTIzOjc4OjA.mobileMessage-meta.json b/test/mockRoot/deploy/testInstance/testBU/mobileMessage/NTIzOjc4OjA.mobileMessage-meta.json index 50cbe9cae..2300663ca 100644 --- a/test/mockRoot/deploy/testInstance/testBU/mobileMessage/NTIzOjc4OjA.mobileMessage-meta.json +++ b/test/mockRoot/deploy/testInstance/testBU/mobileMessage/NTIzOjc4OjA.mobileMessage-meta.json @@ -4,10 +4,8 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "testExisting_mobileMessage", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, - "c__campaignNames": ["testExisting_campaign"], + "r__mobileCode_code": "4912312345678", + "r__campaign_name": ["testExisting_campaign"], "mtSendDate": "2020-07-16T22:46:00Z", "template": { diff --git a/test/mockRoot/deploy/testInstance/testBU/mobileMessage/new.mobileMessage-meta.json b/test/mockRoot/deploy/testInstance/testBU/mobileMessage/new.mobileMessage-meta.json index 74c631b83..92dbe5bba 100644 --- a/test/mockRoot/deploy/testInstance/testBU/mobileMessage/new.mobileMessage-meta.json +++ b/test/mockRoot/deploy/testInstance/testBU/mobileMessage/new.mobileMessage-meta.json @@ -4,10 +4,8 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "testNew_mobileMessage", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, - "c__campaignNames": ["testExisting_campaign"], + "r__mobileCode_code": "4912312345678", + "r__campaign_name": ["testExisting_campaign"], "mtSendDate": "2017-07-03T14:03:00Z", "template": { "id": "Mzo4MDow", diff --git a/test/resources/9999999/mobileMessage/build-expected.json b/test/resources/9999999/mobileMessage/build-expected.json index ae0b6bb81..3d990b9dd 100644 --- a/test/resources/9999999/mobileMessage/build-expected.json +++ b/test/resources/9999999/mobileMessage/build-expected.json @@ -3,11 +3,8 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "testTemplated_mobileMessage", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, - "c__campaignNames": ["testTemplated_campaign"], - + "r__mobileCode_code": "4912312345678", + "r__campaign_name": ["testTemplated_campaign"], "mtSendDate": "2020-07-16T22:46:00Z", "template": { "id": "Mzo4MDow", diff --git a/test/resources/9999999/mobileMessage/get-expected.json b/test/resources/9999999/mobileMessage/get-expected.json index 4138eda34..8afb5b87d 100644 --- a/test/resources/9999999/mobileMessage/get-expected.json +++ b/test/resources/9999999/mobileMessage/get-expected.json @@ -4,11 +4,8 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "testExisting_mobileMessage", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, - "c__campaignNames": ["testExisting_campaign"], - + "r__mobileCode_code": "4912312345678", + "r__campaign_name": ["testExisting_campaign"], "mtSendDate": "2020-07-16T22:46:00Z", "template": { "id": "Mzo4MDow", diff --git a/test/resources/9999999/mobileMessage/post-create-expected.json b/test/resources/9999999/mobileMessage/post-create-expected.json index 936c2bd69..6b5a39f7d 100644 --- a/test/resources/9999999/mobileMessage/post-create-expected.json +++ b/test/resources/9999999/mobileMessage/post-create-expected.json @@ -4,9 +4,7 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "jb test 3", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, + "r__mobileCode_code": "4912312345678", "mtSendDate": "2017-07-03T14:03:00Z", "template": { "id": "Mzo4MDow", diff --git a/test/resources/9999999/mobileMessage/post-update-expected.json b/test/resources/9999999/mobileMessage/post-update-expected.json index 50cbe9cae..fa72aa9ee 100644 --- a/test/resources/9999999/mobileMessage/post-update-expected.json +++ b/test/resources/9999999/mobileMessage/post-update-expected.json @@ -4,11 +4,8 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "testExisting_mobileMessage", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, - "c__campaignNames": ["testExisting_campaign"], - + "r__mobileCode_code": "4912312345678", + "r__campaign_name": ["testExisting_campaign"], "mtSendDate": "2020-07-16T22:46:00Z", "template": { "id": "Mzo4MDow", diff --git a/test/resources/9999999/mobileMessage/template-expected.json b/test/resources/9999999/mobileMessage/template-expected.json index dc388db49..26b7e3933 100644 --- a/test/resources/9999999/mobileMessage/template-expected.json +++ b/test/resources/9999999/mobileMessage/template-expected.json @@ -3,11 +3,8 @@ "type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity", "name": "{{{prefix}}}mobileMessage", "origin": "SMS Send", - "code": { - "code": "4912312345678" - }, - "c__campaignNames": ["{{{prefix}}}campaign"], - + "r__mobileCode_code": "4912312345678", + "r__campaign_name": ["{{{prefix}}}campaign"], "mtSendDate": "2020-07-16T22:46:00Z", "template": { "id": "Mzo4MDow",