mcdev 4.1.12 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.eslintrc.json +1 -1
  2. package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +2 -3
  4. package/.nycrc.json +5 -0
  5. package/README.md +34 -1528
  6. package/boilerplate/config.json +2 -6
  7. package/boilerplate/files/.vscode/extensions.json +1 -0
  8. package/boilerplate/files/.vscode/settings.json +3 -0
  9. package/docs/dist/documentation.md +437 -31
  10. package/lib/Deployer.js +10 -8
  11. package/lib/MetadataTypeDefinitions.js +3 -0
  12. package/lib/MetadataTypeInfo.js +3 -0
  13. package/lib/Retriever.js +14 -7
  14. package/lib/cli.js +1 -0
  15. package/lib/index.js +6 -6
  16. package/lib/metadataTypes/AccountUser.js +2 -2
  17. package/lib/metadataTypes/Asset.js +45 -35
  18. package/lib/metadataTypes/Automation.js +4 -4
  19. package/lib/metadataTypes/DataExtension.js +14 -8
  20. package/lib/metadataTypes/DataExtensionField.js +44 -9
  21. package/lib/metadataTypes/Discovery.js +5 -5
  22. package/lib/metadataTypes/Folder.js +30 -6
  23. package/lib/metadataTypes/List.js +115 -17
  24. package/lib/metadataTypes/MetadataType.js +73 -40
  25. package/lib/metadataTypes/Query.js +2 -2
  26. package/lib/metadataTypes/Script.js +2 -2
  27. package/lib/metadataTypes/TransactionalEmail.js +163 -0
  28. package/lib/metadataTypes/TransactionalMessage.js +127 -0
  29. package/lib/metadataTypes/TransactionalPush.js +77 -0
  30. package/lib/metadataTypes/TransactionalSMS.js +354 -0
  31. package/lib/metadataTypes/TriggeredSendDefinition.js +11 -9
  32. package/lib/metadataTypes/definitions/TransactionalEmail.definition.js +145 -0
  33. package/lib/metadataTypes/definitions/TransactionalPush.definition.js +109 -0
  34. package/lib/metadataTypes/definitions/TransactionalSMS.definition.js +103 -0
  35. package/lib/metadataTypes/definitions/TriggeredSendDefinition.definition.js +36 -36
  36. package/lib/util/auth.js +2 -2
  37. package/lib/util/businessUnit.js +1 -1
  38. package/lib/util/cli.js +19 -20
  39. package/lib/util/config.js +13 -12
  40. package/lib/util/devops.js +4 -4
  41. package/lib/util/init.config.js +7 -7
  42. package/lib/util/init.git.js +11 -23
  43. package/lib/util/init.js +67 -3
  44. package/lib/util/util.js +20 -12
  45. package/package.json +19 -12
  46. package/test/dataExtension.test.js +36 -19
  47. package/test/mockRoot/.mcdevrc.json +13 -2
  48. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/childBU_dataextension_test.dataExtension-meta.json +27 -7
  49. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.json +1 -1
  50. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.sql +3 -1
  51. package/test/mockRoot/deploy/testInstance/testBU/query/{testQuery.query-meta.json → testNewQuery.query-meta.json} +3 -3
  52. package/test/mockRoot/deploy/testInstance/testBU/query/{testQuery.query-meta.sql → testNewQuery.query-meta.sql} +0 -0
  53. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testExisting_temail.transactionalEmail-meta.json +24 -0
  54. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testNew_temail.transactionalEmail-meta.json +24 -0
  55. package/test/mockRoot/deploy/testInstance/testBU/transactionalPush/testExisting_tpush.transactionalPush-meta.json +18 -0
  56. package/test/mockRoot/deploy/testInstance/testBU/transactionalPush/testNew_tpush.transactionalPush-meta.json +18 -0
  57. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testExisting_tsms.transactionalSMS-meta.amp +4 -0
  58. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testExisting_tsms.transactionalSMS-meta.json +15 -0
  59. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testNew_tsms.transactionalSMS-meta.amp +4 -0
  60. package/test/mockRoot/deploy/testInstance/testBU/transactionalSMS/testNew_tsms.transactionalSMS-meta.json +15 -0
  61. package/test/query.test.js +57 -23
  62. package/test/resources/1111111/businessUnit/retrieve-response.xml +33 -0
  63. package/test/resources/1111111/list/retrieve-response.xml +39 -0
  64. package/test/resources/9999999/asset/v1/content/assets/query/post-response.json +72 -0
  65. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +2 -2
  66. package/test/resources/9999999/automation/v1/queries/get-response.json +2 -2
  67. package/test/resources/9999999/automation/v1/queries/post-response.json +3 -3
  68. package/test/resources/9999999/dataExtension/build-expected.json +2 -2
  69. package/test/resources/9999999/dataFolder/retrieve-response.xml +95 -2
  70. package/test/resources/9999999/interaction/v1/interactions/get-response.json +296 -0
  71. package/test/resources/9999999/legacy/v1/beta/mobile/code/get-response.json +32 -0
  72. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json +46 -0
  73. package/test/resources/9999999/list/retrieve-response.xml +78 -0
  74. package/test/resources/9999999/messaging/v1/email/definitions/get-response.json +15 -0
  75. package/test/resources/9999999/messaging/v1/email/definitions/post-response.json +19 -0
  76. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/get-response.json +26 -0
  77. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/patch-response.json +26 -0
  78. package/test/resources/9999999/messaging/v1/push/definitions/get-response.json +15 -0
  79. package/test/resources/9999999/messaging/v1/push/definitions/post-response.json +13 -0
  80. package/test/resources/9999999/messaging/v1/push/definitions/testExisting_tpush/get-response.json +13 -0
  81. package/test/resources/9999999/messaging/v1/push/definitions/testExisting_tpush/patch-response.json +13 -0
  82. package/test/resources/9999999/messaging/v1/sms/definitions/get-response.json +15 -0
  83. package/test/resources/9999999/messaging/v1/sms/definitions/post-response.json +17 -0
  84. package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json +18 -0
  85. package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json +18 -0
  86. package/test/resources/9999999/query/build-expected.json +2 -2
  87. package/test/resources/9999999/query/build-expected.sql +6 -0
  88. package/test/resources/9999999/query/get-expected.json +1 -1
  89. package/test/resources/9999999/query/get-expected.sql +6 -0
  90. package/test/resources/9999999/query/patch-expected.json +1 -1
  91. package/test/resources/9999999/query/patch-expected.sql +6 -0
  92. package/test/resources/9999999/query/post-expected.json +3 -3
  93. package/test/resources/9999999/query/post-expected.sql +4 -0
  94. package/test/resources/9999999/query/template-expected.json +1 -1
  95. package/test/resources/9999999/query/template-expected.sql +6 -0
  96. package/test/resources/9999999/transactionalEmail/build-expected.json +22 -0
  97. package/test/resources/9999999/transactionalEmail/get-expected.json +24 -0
  98. package/test/resources/9999999/transactionalEmail/patch-expected.json +24 -0
  99. package/test/resources/9999999/transactionalEmail/post-expected.json +24 -0
  100. package/test/resources/9999999/transactionalEmail/template-expected.json +22 -0
  101. package/test/resources/9999999/transactionalPush/build-expected.json +8 -0
  102. package/test/resources/9999999/transactionalPush/get-expected.json +11 -0
  103. package/test/resources/9999999/transactionalPush/patch-expected.json +16 -0
  104. package/test/resources/9999999/transactionalPush/post-expected.json +16 -0
  105. package/test/resources/9999999/transactionalPush/template-expected.json +8 -0
  106. package/test/resources/9999999/transactionalSMS/build-expected.amp +4 -0
  107. package/test/resources/9999999/transactionalSMS/build-expected.json +13 -0
  108. package/test/resources/9999999/transactionalSMS/get-expected.amp +4 -0
  109. package/test/resources/9999999/transactionalSMS/get-expected.json +15 -0
  110. package/test/resources/9999999/transactionalSMS/patch-expected.amp +4 -0
  111. package/test/resources/9999999/transactionalSMS/patch-expected.json +15 -0
  112. package/test/resources/9999999/transactionalSMS/post-expected.amp +4 -0
  113. package/test/resources/9999999/transactionalSMS/post-expected.json +15 -0
  114. package/test/resources/9999999/transactionalSMS/template-expected.amp +4 -0
  115. package/test/resources/9999999/transactionalSMS/template-expected.json +13 -0
  116. package/test/transactionalEmail.test.js +120 -0
  117. package/test/transactionalPush.test.js +120 -0
  118. package/test/transactionalSMS.test.js +149 -0
  119. package/test/utils.js +57 -8
@@ -0,0 +1,15 @@
1
+ {
2
+ "requestId": "4a89b42d-9e71-4ddd-9b4e-a3b00edbfdfb",
3
+ "definitions": [
4
+ {
5
+ "name": "testExisting_tpush",
6
+ "definitionKey": "testExisting_tpush",
7
+ "status": "Active",
8
+ "createdDate": "2022-12-07T02:56:00",
9
+ "modifiedDate": "2022-12-07T02:56:00"
10
+ }
11
+ ],
12
+ "count": 1,
13
+ "page": 1,
14
+ "pageSize": 50
15
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "requestId": "ee81df03-ab61-454d-a54a-025675cf2b41",
3
+ "name": "testNew_tpush",
4
+ "definitionKey": "testNew_tpush",
5
+ "definitionId": "2106d3f9-0c76-ed11-b849-48df37d1de8b",
6
+ "description": "created on deploy; note that applicationId can only be manually set up in Setup - Mobile Push",
7
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
8
+ "status": "Active",
9
+ "createdDate": "2022-12-07T02:56:00",
10
+ "modifiedDate": "2022-12-07T03:26:00",
11
+ "content": { "customerKey": "mobileMessage_test" },
12
+ "options": { "sound": "temp.wmv", "badge": "1" }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "requestId": "64dac58f-f6d0-4bea-9489-eb058c491a87",
3
+ "name": "testExisting_tpush",
4
+ "definitionKey": "testExisting_tpush",
5
+ "definitionId": "2106d3f9-0c76-ed11-b849-48df37d1de8b",
6
+ "description": "bla bla. note that applicationId can only be manually set up in Setup - Mobile Push",
7
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
8
+ "status": "Active",
9
+ "createdDate": "2022-12-07T02:56:00",
10
+ "modifiedDate": "2022-12-07T02:56:00",
11
+ "content": { "customerKey": "mobileMessage_test" },
12
+ "options": { "sound": "temp.wmv", "badge": "1" }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "requestId": "6d796b32-dff3-4564-ae36-f51edb0e5ec6",
3
+ "name": "testExisting_tpush",
4
+ "definitionKey": "testExisting_tpush",
5
+ "definitionId": "2106d3f9-0c76-ed11-b849-48df37d1de8b",
6
+ "description": "updated via deploy; note that applicationId can only be manually set up in Setup - Mobile Push",
7
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
8
+ "status": "Active",
9
+ "createdDate": "2022-12-07T02:56:00",
10
+ "modifiedDate": "2022-12-07T03:26:00",
11
+ "content": { "customerKey": "mobileMessage_test" },
12
+ "options": { "sound": "temp.wmv", "badge": "1" }
13
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "requestId": "60c26a29-e1b0-4952-a566-476a937e4a5d",
3
+ "definitions": [
4
+ {
5
+ "name": "testExisting_tsms",
6
+ "definitionKey": "testExisting_tsms",
7
+ "status": "Active",
8
+ "createdDate": "2022-11-23T02:50:00",
9
+ "modifiedDate": "2022-11-25T08:01:00"
10
+ }
11
+ ],
12
+ "count": 1,
13
+ "page": 1,
14
+ "pageSize": 50
15
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "requestId": "582bec09-6d04-4222-bbba-cea616495596",
3
+ "name": "testNew_tsms",
4
+ "definitionKey": "testNew_tsms",
5
+ "description": "created on deploy",
6
+ "status": "Active",
7
+ "createdDate": "2022-11-07T02:24:00",
8
+ "modifiedDate": "2022-11-07T02:25:00",
9
+ "content": { "message": "\n%%[\n SET @key = 'new secret'\n]%%\n" },
10
+ "subscriptions": {
11
+ "shortCode": "4912312345678",
12
+ "countryCode": "",
13
+ "autoAddSubscriber": true,
14
+ "updateSubscriber": true,
15
+ "keyword": "testExisting_keyword"
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "requestId": "ae8511d0-9bf0-42d0-af4f-bd9c1218c812",
3
+ "name": "testExisting_tsms",
4
+ "definitionKey": "testExisting_tsms",
5
+ "definitionId": "0a650d90-755e-ed11-b852-48df37d1df5b",
6
+ "description": "bla bla",
7
+ "status": "Active",
8
+ "createdDate": "2022-11-07T02:24:00",
9
+ "modifiedDate": "2022-11-07T02:25:00",
10
+ "content": { "message": "%%[ SET @key = 'secret' ]%%" },
11
+ "subscriptions": {
12
+ "shortCode": "4912312345678",
13
+ "countryCode": "",
14
+ "autoAddSubscriber": true,
15
+ "updateSubscriber": true,
16
+ "keyword": "testExisting_keyword"
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "requestId": "ae8511d0-9bf0-42d0-af4f-bd9c1218c812",
3
+ "name": "testExisting_tsms",
4
+ "definitionKey": "testExisting_tsms",
5
+ "definitionId": "0a650d90-755e-ed11-b852-48df37d1df5b",
6
+ "description": "bla bla",
7
+ "status": "Active",
8
+ "createdDate": "2022-11-07T02:24:00",
9
+ "modifiedDate": "2022-11-07T02:25:00",
10
+ "content": { "message": "%%[ SET @key = 'secret' ]%%" },
11
+ "subscriptions": {
12
+ "shortCode": "4912312345678",
13
+ "countryCode": "",
14
+ "autoAddSubscriber": true,
15
+ "updateSubscriber": true,
16
+ "keyword": "testExisting_keyword"
17
+ }
18
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "testExistingQuery",
3
3
  "key": "testExistingQuery",
4
- "description": "",
5
- "targetKey": "childBU_dataextension_test",
4
+ "description": "foobar",
5
+ "targetKey": "childBU_dataextension_testTarget",
6
6
  "targetUpdateTypeName": "Overwrite",
7
7
  "r__folder_Path": "Query"
8
8
  }
@@ -0,0 +1,6 @@
1
+ SELECT
2
+ SubscriberKey as testField
3
+ FROM
4
+ _Subscribers
5
+ WHERE
6
+ country IN ('testTarget')
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testExistingQuery",
3
3
  "key": "testExistingQuery",
4
- "description": "",
4
+ "description": "bla bla",
5
5
  "targetKey": "childBU_dataextension_test",
6
6
  "createdDate": "2022-04-26T15:21:16.453",
7
7
  "modifiedDate": "2022-04-26T16:02:44.01",
@@ -0,0 +1,6 @@
1
+ SELECT
2
+ SubscriberKey as testField
3
+ FROM
4
+ _Subscribers
5
+ WHERE
6
+ country IN ('test')
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testExistingQuery",
3
3
  "key": "testExistingQuery",
4
- "description": "updated",
4
+ "description": "updated on deploy",
5
5
  "targetKey": "childBU_dataextension_test",
6
6
  "createdDate": "2022-04-26T15:21:16.453",
7
7
  "modifiedDate": "2022-04-26T16:04:15.88",
@@ -0,0 +1,6 @@
1
+ SELECT
2
+ SubscriberKey as testField
3
+ FROM
4
+ _Subscribers
5
+ WHERE
6
+ country IN ('test')
@@ -1,7 +1,7 @@
1
1
  {
2
- "name": "testQuery",
3
- "key": "testQuery",
4
- "description": "",
2
+ "name": "testNewQuery",
3
+ "key": "testNewQuery",
4
+ "description": "created on deploy",
5
5
  "targetKey": "childBU_dataextension_test",
6
6
  "createdDate": "2022-04-26T15:21:16.453",
7
7
  "modifiedDate": "2022-04-26T16:04:15.88",
@@ -0,0 +1,4 @@
1
+ SELECT
2
+ SubscriberKey as testField
3
+ FROM
4
+ _Subscribers
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testExistingQuery",
3
3
  "key": "testExistingQuery",
4
- "description": "",
4
+ "description": "{{{description}}}",
5
5
  "targetKey": "childBU_dataextension{{{suffix}}}",
6
6
  "targetUpdateTypeName": "Overwrite",
7
7
  "r__folder_Path": "Query"
@@ -0,0 +1,6 @@
1
+ SELECT
2
+ SubscriberKey as testField
3
+ FROM
4
+ _Subscribers
5
+ WHERE
6
+ country IN ({{{countryCodeIn}}})
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "testExisting_temail",
3
+ "definitionKey": "testExisting_temail",
4
+ "description": "foobar",
5
+ "classification": "Default Transactional",
6
+ "status": "Active",
7
+ "content": {
8
+ "customerKey": "testExisting_asset_message"
9
+ },
10
+ "subscriptions": {
11
+ "dataExtension": "childBU_dataextension_testTarget",
12
+ "autoAddSubscriber": true,
13
+ "updateSubscriber": true,
14
+ "r__list_PathName": "my subscribers/All Subscribers"
15
+ },
16
+ "options": {
17
+ "trackLinks": true
18
+ },
19
+ "journey": {
20
+ "interactionKey": "testExisting_interaction"
21
+ }
22
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "testExisting_temail",
3
+ "definitionKey": "testExisting_temail",
4
+ "description": "bla bla",
5
+ "classification": "Default Transactional",
6
+ "status": "Active",
7
+ "createdDate": "2020-09-10T03:29:00",
8
+ "modifiedDate": "2020-09-10T03:29:00",
9
+ "content": {
10
+ "customerKey": "testExisting_asset_message"
11
+ },
12
+ "subscriptions": {
13
+ "dataExtension": "childBU_dataextension_test",
14
+ "autoAddSubscriber": true,
15
+ "updateSubscriber": true,
16
+ "r__list_PathName": "my subscribers/All Subscribers"
17
+ },
18
+ "options": {
19
+ "trackLinks": true
20
+ },
21
+ "journey": {
22
+ "interactionKey": "testExisting_interaction"
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "testExisting_temail",
3
+ "definitionKey": "testExisting_temail",
4
+ "description": "updated via deploy",
5
+ "classification": "Default Transactional",
6
+ "status": "Active",
7
+ "createdDate": "2020-09-10T03:29:00",
8
+ "modifiedDate": "2020-09-10T03:29:00",
9
+ "content": {
10
+ "customerKey": "testExisting_asset_message"
11
+ },
12
+ "subscriptions": {
13
+ "dataExtension": "childBU_dataextension_test",
14
+ "autoAddSubscriber": true,
15
+ "updateSubscriber": true,
16
+ "r__list_PathName": "my subscribers/All Subscribers"
17
+ },
18
+ "options": {
19
+ "trackLinks": true
20
+ },
21
+ "journey": {
22
+ "interactionKey": "testExisting_interaction"
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "testNew_temail",
3
+ "definitionKey": "testNew_temail",
4
+ "description": "created on deploy",
5
+ "classification": "Default Transactional",
6
+ "status": "Active",
7
+ "createdDate": "2022-12-06T06:08:00",
8
+ "modifiedDate": "2022-12-06T06:08:00",
9
+ "content": {
10
+ "customerKey": "testExisting_asset_message"
11
+ },
12
+ "subscriptions": {
13
+ "dataExtension": "childBU_dataextension_test",
14
+ "autoAddSubscriber": true,
15
+ "updateSubscriber": true,
16
+ "r__list_PathName": "my subscribers/All Subscribers"
17
+ },
18
+ "options": {
19
+ "trackLinks": true
20
+ },
21
+ "journey": {
22
+ "interactionKey": "1f936b41-cf1b-4207-aa33-715b3bf9eab7"
23
+ }
24
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "testExisting_temail",
3
+ "definitionKey": "testExisting_temail",
4
+ "description": "{{{description}}}",
5
+ "classification": "Default Transactional",
6
+ "status": "Active",
7
+ "content": {
8
+ "customerKey": "testExisting_asset_message"
9
+ },
10
+ "subscriptions": {
11
+ "dataExtension": "childBU_dataextension{{{suffix}}}",
12
+ "autoAddSubscriber": true,
13
+ "updateSubscriber": true,
14
+ "r__list_PathName": "my subscribers/All Subscribers"
15
+ },
16
+ "options": {
17
+ "trackLinks": true
18
+ },
19
+ "journey": {
20
+ "interactionKey": "testExisting_interaction"
21
+ }
22
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "testExisting_tpush",
3
+ "definitionKey": "testExisting_tpush",
4
+ "description": "foobar. note that applicationId can only be manually set up in Setup - Mobile Push",
5
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
6
+ "content": { "customerKey": "mobileMessage_testTarget" },
7
+ "options": { "sound": "temp.wmv", "badge": "1" }
8
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "testExisting_tpush",
3
+ "definitionKey": "testExisting_tpush",
4
+ "description": "bla bla. note that applicationId can only be manually set up in Setup - Mobile Push",
5
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
6
+ "status": "Active",
7
+ "createdDate": "2022-12-07T02:56:00",
8
+ "modifiedDate": "2022-12-07T02:56:00",
9
+ "content": { "customerKey": "mobileMessage_test" },
10
+ "options": { "sound": "temp.wmv", "badge": "1" }
11
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "definitionKey": "testExisting_tpush",
3
+ "name": "testExisting_tpush",
4
+ "status": "Active",
5
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
6
+ "description": "updated via deploy; note that applicationId can only be manually set up in Setup - Mobile Push",
7
+ "createdDate": "2022-12-07T02:56:00",
8
+ "modifiedDate": "2022-12-07T03:26:00",
9
+ "content": {
10
+ "customerKey": "mobileMessage_test"
11
+ },
12
+ "options": {
13
+ "sound": "temp.wmv",
14
+ "badge": "1"
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "definitionKey": "testNew_tpush",
3
+ "name": "testNew_tpush",
4
+ "status": "Active",
5
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
6
+ "description": "created on deploy; note that applicationId can only be manually set up in Setup - Mobile Push",
7
+ "createdDate": "2022-12-07T02:56:00",
8
+ "modifiedDate": "2022-12-07T03:26:00",
9
+ "content": {
10
+ "customerKey": "mobileMessage_test"
11
+ },
12
+ "options": {
13
+ "sound": "temp.wmv",
14
+ "badge": "1"
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "testExisting_tpush",
3
+ "definitionKey": "testExisting_tpush",
4
+ "description": "{{{description}}}. note that applicationId can only be manually set up in Setup - Mobile Push",
5
+ "applicationId": "ffbab4c9-fbf6-4b87-9c9a-10c6ce86e81d",
6
+ "content": { "customerKey": "mobileMessage{{{suffix}}}" },
7
+ "options": { "sound": "temp.wmv", "badge": "1" }
8
+ }
@@ -0,0 +1,4 @@
1
+
2
+ %%[
3
+ SET @key = 'target secret'
4
+ ]%%
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "testExisting_tsms",
3
+ "definitionKey": "testExisting_tsms",
4
+ "description": "foobar",
5
+ "status": "Active",
6
+ "subscriptions": {
7
+ "shortCode": "4912312345678",
8
+ "countryCode": "",
9
+ "autoAddSubscriber": true,
10
+ "updateSubscriber": true,
11
+ "keyword": "testExisting_keyword"
12
+ }
13
+ }
@@ -0,0 +1,4 @@
1
+
2
+ %%[
3
+ SET @key = 'secret'
4
+ ]%%
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "testExisting_tsms",
3
+ "definitionKey": "testExisting_tsms",
4
+ "description": "bla bla",
5
+ "status": "Active",
6
+ "createdDate": "2022-11-07T02:24:00",
7
+ "modifiedDate": "2022-11-07T02:25:00",
8
+ "subscriptions": {
9
+ "shortCode": "4912312345678",
10
+ "countryCode": "",
11
+ "autoAddSubscriber": true,
12
+ "updateSubscriber": true,
13
+ "keyword": "testExisting_keyword"
14
+ }
15
+ }
@@ -0,0 +1,4 @@
1
+
2
+ %%[
3
+ SET @key = 'secret'
4
+ ]%%
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "testExisting_tsms",
3
+ "definitionKey": "testExisting_tsms",
4
+ "description": "bla bla",
5
+ "status": "Active",
6
+ "createdDate": "2022-11-07T02:24:00",
7
+ "modifiedDate": "2022-11-07T02:25:00",
8
+ "subscriptions": {
9
+ "shortCode": "4912312345678",
10
+ "countryCode": "",
11
+ "autoAddSubscriber": true,
12
+ "updateSubscriber": true,
13
+ "keyword": "testExisting_keyword"
14
+ }
15
+ }
@@ -0,0 +1,4 @@
1
+
2
+ %%[
3
+ SET @key = 'new secret'
4
+ ]%%
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "testNew_tsms",
3
+ "definitionKey": "testNew_tsms",
4
+ "description": "created on deploy",
5
+ "status": "Active",
6
+ "createdDate": "2022-11-07T02:24:00",
7
+ "modifiedDate": "2022-11-07T02:25:00",
8
+ "subscriptions": {
9
+ "shortCode": "4912312345678",
10
+ "countryCode": "",
11
+ "autoAddSubscriber": true,
12
+ "updateSubscriber": true,
13
+ "keyword": "testExisting_keyword"
14
+ }
15
+ }
@@ -0,0 +1,4 @@
1
+
2
+ %%[
3
+ SET @key = '{{{secret}}}'
4
+ ]%%
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "testExisting_tsms",
3
+ "definitionKey": "testExisting_tsms",
4
+ "description": "{{{description}}}",
5
+ "status": "Active",
6
+ "subscriptions": {
7
+ "shortCode": "4912312345678",
8
+ "countryCode": "",
9
+ "autoAddSubscriber": true,
10
+ "updateSubscriber": true,
11
+ "keyword": "testExisting_keyword"
12
+ }
13
+ }
@@ -0,0 +1,120 @@
1
+ const chai = require('chai');
2
+ const chaiFiles = require('chai-files');
3
+ const assert = chai.assert;
4
+ chai.use(chaiFiles);
5
+ const cache = require('../lib/util/cache');
6
+ const testUtils = require('./utils');
7
+ const handler = require('../lib/index');
8
+
9
+ describe('transactionalEmail', () => {
10
+ beforeEach(() => {
11
+ testUtils.mockSetup();
12
+ });
13
+ afterEach(() => {
14
+ testUtils.mockReset();
15
+ });
16
+
17
+ describe('Retrieve ================', () => {
18
+ it('Should retrieve a transactionalEmail', async () => {
19
+ // WHEN
20
+ await handler.retrieve('testInstance/testBU', ['transactionalEmail']);
21
+ // THEN
22
+ // get results from cache
23
+ const result = cache.getCache();
24
+ assert.equal(
25
+ result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
26
+ 1,
27
+ 'only one transactionalEmail expected'
28
+ );
29
+ assert.deepEqual(
30
+ await testUtils.getActualJson('testExisting_temail', 'transactionalEmail'),
31
+ await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get'),
32
+ 'returned JSON was not equal expected'
33
+ );
34
+ assert.equal(
35
+ Object.values(testUtils.getAPIHistory()).flat().length,
36
+ 12,
37
+ 'Unexpected number of requests made'
38
+ );
39
+ return;
40
+ });
41
+ });
42
+ describe('Deploy ================', () => {
43
+ beforeEach(() => {
44
+ testUtils.mockSetup(true);
45
+ });
46
+ it('Should create & upsert a transactionalEmail', async () => {
47
+ // WHEN
48
+ await handler.deploy('testInstance/testBU', ['transactionalEmail']);
49
+ // THEN
50
+ // get results from cache
51
+ const result = cache.getCache();
52
+ assert.equal(
53
+ result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
54
+ 2,
55
+ 'two transactionalEmails expected'
56
+ );
57
+ // confirm created item
58
+ assert.deepEqual(
59
+ await testUtils.getActualJson('testNew_temail', 'transactionalEmail'),
60
+ await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'post'),
61
+ 'returned JSON was not equal expected for insert transactionalEmail'
62
+ );
63
+ // confirm updated item
64
+ assert.deepEqual(
65
+ await testUtils.getActualJson('testExisting_temail', 'transactionalEmail'),
66
+ await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'patch'),
67
+ 'returned JSON was not equal expected for update transactionalEmail'
68
+ );
69
+ // check number of API calls
70
+ assert.equal(
71
+ Object.values(testUtils.getAPIHistory()).flat().length,
72
+ 13,
73
+ 'Unexpected number of requests made'
74
+ );
75
+ return;
76
+ });
77
+ });
78
+ describe('Templating ================', () => {
79
+ // it.skip('Should create a transactionalEmail template via retrieveAsTemplate and build it');
80
+ it('Should create a transactionalEmail template via buildTemplate and build it', async () => {
81
+ // download first before we test buildTemplate
82
+ await handler.retrieve('testInstance/testBU', ['transactionalEmail']);
83
+ // buildTemplate
84
+ const result = await handler.buildTemplate(
85
+ 'testInstance/testBU',
86
+ 'transactionalEmail',
87
+ ['testExisting_temail'],
88
+ 'testSourceMarket'
89
+ );
90
+ assert.equal(
91
+ result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
92
+ 1,
93
+ 'only one transactionalEmail expected'
94
+ );
95
+ assert.deepEqual(
96
+ await testUtils.getActualTemplateJson('testExisting_temail', 'transactionalEmail'),
97
+ await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'template'),
98
+ 'returned template JSON was not equal expected'
99
+ );
100
+ // buildDefinition
101
+ await handler.buildDefinition(
102
+ 'testInstance/testBU',
103
+ 'transactionalEmail',
104
+ 'testExisting_temail',
105
+ 'testTargetMarket'
106
+ );
107
+ assert.deepEqual(
108
+ await testUtils.getActualDeployJson('testExisting_temail', 'transactionalEmail'),
109
+ await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'build'),
110
+ 'returned deployment JSON was not equal expected'
111
+ );
112
+ assert.equal(
113
+ Object.values(testUtils.getAPIHistory()).flat().length,
114
+ 12,
115
+ 'Unexpected number of requests made'
116
+ );
117
+ return;
118
+ });
119
+ });
120
+ });