mcdev 5.1.0 → 5.2.0

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 (192) hide show
  1. package/.eslintrc.json +4 -4
  2. package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +2 -2
  4. package/.github/workflows/coverage-develop-branch.yml +0 -2
  5. package/.github/workflows/coverage-main-branch.yml +0 -2
  6. package/.github/workflows/coverage.yml +0 -2
  7. package/.husky/post-checkout +1 -0
  8. package/.husky/post-merge +1 -0
  9. package/.vscode/extensions.json +4 -0
  10. package/docs/dist/documentation.md +633 -286
  11. package/lib/Deployer.js +25 -25
  12. package/lib/MetadataTypeDefinitions.js +1 -1
  13. package/lib/MetadataTypeInfo.js +1 -1
  14. package/lib/Retriever.js +1 -1
  15. package/lib/cli.js +159 -9
  16. package/lib/index.js +395 -95
  17. package/lib/metadataTypes/Asset.js +10 -11
  18. package/lib/metadataTypes/AttributeGroup.js +76 -2
  19. package/lib/metadataTypes/AttributeSet.js +260 -0
  20. package/lib/metadataTypes/Automation.js +413 -96
  21. package/lib/metadataTypes/DataExtension.js +2 -2
  22. package/lib/metadataTypes/DataExtensionField.js +1 -1
  23. package/lib/metadataTypes/Event.js +2 -3
  24. package/lib/metadataTypes/Folder.js +1 -1
  25. package/lib/metadataTypes/Journey.js +5 -6
  26. package/lib/metadataTypes/MetadataType.js +149 -49
  27. package/lib/metadataTypes/MobileKeyword.js +8 -8
  28. package/lib/metadataTypes/MobileMessage.js +5 -5
  29. package/lib/metadataTypes/Query.js +26 -10
  30. package/lib/metadataTypes/Script.js +3 -3
  31. package/lib/metadataTypes/TransactionalSMS.js +5 -5
  32. package/lib/metadataTypes/TriggeredSend.js +25 -50
  33. package/lib/metadataTypes/User.js +7 -4
  34. package/lib/metadataTypes/definitions/AttributeGroup.definition.js +117 -106
  35. package/lib/metadataTypes/definitions/{SetDefinition.definition.js → AttributeSet.definition.js} +54 -27
  36. package/lib/metadataTypes/definitions/Automation.definition.js +22 -15
  37. package/lib/metadataTypes/definitions/ImportFile.definition.js +36 -6
  38. package/lib/metadataTypes/definitions/TriggeredSend.definition.js +1 -0
  39. package/lib/util/cache.js +9 -4
  40. package/lib/util/cli.js +40 -0
  41. package/lib/util/file.js +2 -2
  42. package/lib/util/init.js +84 -0
  43. package/lib/util/util.js +121 -13
  44. package/package.json +11 -11
  45. package/test/mockRoot/.mcdevrc.json +1 -1
  46. package/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json +1 -2
  47. package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json +5 -6
  48. package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testExisting_dataExtract.dataExtract-meta.json +35 -0
  49. package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testNew_dataExtract.dataExtract-meta.json +35 -0
  50. package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testExisting_fileTransfer.fileTransfer-meta.json +17 -0
  51. package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testNew_fileTransfer.fileTransfer-meta.json +17 -0
  52. package/test/mockRoot/deploy/testInstance/testBU/importFile/testExisting_importFile.importFile-meta.json +29 -0
  53. package/test/mockRoot/deploy/testInstance/testBU/importFile/testNew_importFile.importFile-meta.json +29 -0
  54. package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.json +11 -0
  55. package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.sql +6 -0
  56. package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.json +6 -0
  57. package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.ssjs +1 -0
  58. package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.json +6 -0
  59. package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.ssjs +1 -0
  60. package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testExisting_triggeredSend.triggeredSend-meta.json +29 -0
  61. package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testNew_triggeredSend.triggeredSend-meta.json +29 -0
  62. package/test/resourceFactory.js +77 -12
  63. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDCustomerKey=testExisting_userANDEmaillike@-response.xml +27 -0
  64. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDEmaillike@-response.xml +156 -0
  65. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +87 -0
  66. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmaillike@-response.xml +156 -0
  67. package/test/resources/1111111/accountUser/retrieve-CustomerKey=testExisting_userANDActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +27 -0
  68. package/test/resources/1111111/accountUserAccount/retrieve-AccountUser.AccountUserID=700301950-response.xml +60 -0
  69. package/test/resources/1111111/user/retrieve-expected.md +4 -2
  70. package/test/resources/9999999/attributeGroup/retrieve-expected.json +25 -0
  71. package/test/resources/9999999/attributeSet/retrieve-expected.json +748 -0
  72. package/test/resources/9999999/automation/build-expected.json +1 -2
  73. package/test/resources/9999999/automation/create-expected.json +7 -8
  74. package/test/resources/9999999/automation/create-testNew_automation-expected.md +4 -4
  75. package/test/resources/9999999/automation/patch_fixKeys-pause-expected.json +44 -0
  76. package/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json +44 -0
  77. package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
  78. package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml +42 -0
  79. package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +42 -0
  80. package/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
  81. package/test/resources/9999999/automation/retrieve-expected.json +1 -2
  82. package/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +2 -2
  83. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
  84. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-pause-response.xml +38 -0
  85. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml +52 -0
  86. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +52 -0
  87. package/test/resources/9999999/automation/schedule-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
  88. package/test/resources/9999999/automation/template-expected.json +1 -2
  89. package/test/resources/9999999/automation/update-expected.json +1 -2
  90. package/test/resources/9999999/automation/update-testExisting_automation-expected.md +2 -2
  91. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/get-response.json +85 -0
  92. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json +85 -0
  93. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json +85 -0
  94. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json +85 -0
  95. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json +85 -0
  96. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json +85 -0
  97. package/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +1 -1
  98. package/test/resources/9999999/automation/v1/automations/post-response.json +20 -19
  99. package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/patch-response.json +38 -0
  100. package/test/resources/9999999/automation/v1/dataextracts/post-response.json +38 -0
  101. package/test/resources/9999999/automation/v1/dataextracttypes/get-response.json +50 -0
  102. package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/patch-response.json +18 -0
  103. package/test/resources/9999999/automation/v1/filetransfers/post-response.json +18 -0
  104. package/test/resources/9999999/automation/v1/ftplocations/get-response.json +18 -0
  105. package/test/resources/9999999/automation/v1/imports/9d16f42c-2260-ed11-b849-48df37d1de8b/patch-response.json +31 -0
  106. package/test/resources/9999999/automation/v1/imports/get-response.json +1 -1
  107. package/test/resources/9999999/automation/v1/imports/post-response.json +30 -0
  108. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dae/actions/start/post-response.txt +1 -0
  109. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/get-response.json +17 -0
  110. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/patch-response.json +18 -0
  111. package/test/resources/9999999/automation/v1/queries/get-response.json +18 -1
  112. package/test/resources/9999999/automation/v1/scripts/39f6a488-20eb-4ba0-b0b9-023725b574e4/patch-response.json +10 -0
  113. package/test/resources/9999999/automation/v1/scripts/get-response.json +12 -2
  114. package/test/resources/9999999/automation/v1/scripts/post-response.json +10 -0
  115. package/test/resources/9999999/dataExtension/retrieve-Name=testExisting_dataExtension-response.xml +52 -0
  116. package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml +98 -0
  117. package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testNew_dataExtensionORDataExtension.CustomerKey=testExisting_dataExtension-response.xml +99 -0
  118. package/test/resources/9999999/dataExtract/build-expected.json +35 -0
  119. package/test/resources/9999999/dataExtract/get-expected.json +39 -0
  120. package/test/resources/9999999/dataExtract/patch-expected.json +37 -0
  121. package/test/resources/9999999/dataExtract/post-expected.json +37 -0
  122. package/test/resources/9999999/dataExtract/template-expected.json +35 -0
  123. package/test/resources/9999999/dataFolder/retrieve-ContentType=contextual_suppression_listORContentType=publicationORContentType=suppression_listORContentType=mysubsORContentType=list-response.xml +136 -0
  124. package/test/resources/9999999/dataFolder/retrieve-ContentType=ssjsactivity-response.xml +48 -0
  125. package/test/resources/9999999/dataFolder/retrieve-ContentType=triggered_send_journeybuilderORContentType=triggered_sendORContentType=hidden-response.xml +276 -0
  126. package/test/resources/9999999/dataFolder/retrieve-response.xml +23 -0
  127. package/test/resources/9999999/email/retrieve-response.xml +203 -0
  128. package/test/resources/9999999/fileTransfer/build-expected.json +15 -0
  129. package/test/resources/9999999/fileTransfer/get-expected.json +17 -0
  130. package/test/resources/9999999/fileTransfer/patch-expected.json +17 -0
  131. package/test/resources/9999999/fileTransfer/post-expected.json +17 -0
  132. package/test/resources/9999999/fileTransfer/template-expected.json +15 -0
  133. package/test/resources/9999999/hub/v1/contacts/schema/attributeGroups/get-response.json +585 -0
  134. package/test/resources/9999999/hub/v1/contacts/schema/setDefinitions/get-response.json +19807 -0
  135. package/test/resources/9999999/importFile/build-expected.json +27 -0
  136. package/test/resources/9999999/importFile/get-expected.json +29 -0
  137. package/test/resources/9999999/importFile/patch-expected.json +29 -0
  138. package/test/resources/9999999/importFile/post-expected.json +29 -0
  139. package/test/resources/9999999/importFile/template-expected.json +27 -0
  140. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml +32 -0
  141. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml +32 -0
  142. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml +32 -0
  143. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml +32 -0
  144. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_pause-response.xml +30 -0
  145. package/test/resources/9999999/program/retrieve-response.xml +21 -3
  146. package/test/resources/9999999/query/patch_fixKeys-expected.json +11 -0
  147. package/test/resources/9999999/query/patch_fixKeys-expected.sql +6 -0
  148. package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixKeysANDStatus=Active-response.xml +30 -0
  149. package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml +30 -0
  150. package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testNew_queryANDStatus=Active-response.xml +30 -0
  151. package/test/resources/9999999/script/build-expected.json +6 -0
  152. package/test/resources/9999999/script/build-expected.ssjs +1 -0
  153. package/test/resources/9999999/script/get-expected.json +8 -0
  154. package/test/resources/9999999/script/get-expected.ssjs +1 -0
  155. package/test/resources/9999999/script/get_noScriptTag-expected.html +1 -0
  156. package/test/resources/9999999/script/get_noScriptTag-expected.json +8 -0
  157. package/test/resources/9999999/script/patch-expected.json +8 -0
  158. package/test/resources/9999999/script/patch-expected.ssjs +1 -0
  159. package/test/resources/9999999/script/post-expected.json +8 -0
  160. package/test/resources/9999999/script/post-expected.ssjs +1 -0
  161. package/test/resources/9999999/script/template-expected.json +6 -0
  162. package/test/resources/9999999/script/template-expected.ssjs +1 -0
  163. package/test/resources/9999999/triggeredSend/build-expected.json +29 -0
  164. package/test/resources/9999999/triggeredSend/get-expected.json +29 -0
  165. package/test/resources/9999999/triggeredSend/patch-expected.json +29 -0
  166. package/test/resources/9999999/triggeredSend/post-expected.json +29 -0
  167. package/test/resources/9999999/triggeredSend/template-expected.json +29 -0
  168. package/test/resources/9999999/triggeredSendDefinition/create-response.xml +75 -0
  169. package/test/resources/9999999/triggeredSendDefinition/delete-response.xml +36 -0
  170. package/test/resources/9999999/triggeredSendDefinition/{retrieve-response.xml → retrieve-TriggeredSendStatusINNew,Active,Inactive,Moved,Canceled-response.xml} +4 -4
  171. package/test/resources/9999999/triggeredSendDefinition/update-response.xml +74 -0
  172. package/test/type.attributeGroup.test.js +55 -0
  173. package/test/type.attributeSet.test.js +55 -0
  174. package/test/type.automation.test.js +638 -11
  175. package/test/type.dataExtension.test.js +0 -1
  176. package/test/type.dataExtract.test.js +187 -0
  177. package/test/type.fileTransfer.test.js +185 -0
  178. package/test/type.importFile.test.js +186 -0
  179. package/test/type.mobileKeyword.test.js +0 -1
  180. package/test/type.query.test.js +464 -13
  181. package/test/type.script.test.js +367 -0
  182. package/test/type.triggeredSend.test.js +152 -0
  183. package/test/type.user.test.js +22 -10
  184. package/test/utils.js +4 -1
  185. package/lib/metadataTypes/SetDefinition.js +0 -37
  186. /package/test/resources/1111111/accountUser/{retrieve-response.xml → retrieve-ActiveFlag=trueANDCustomerKey=testExisting_userANDEmaillike@-response.xml} +0 -0
  187. /package/test/resources/1111111/accountUserAccount/{retrieve-response.xml → retrieve-AccountUser.AccountUserIDIN700301950,700301951,7471228-response.xml} +0 -0
  188. /package/test/resources/1111111/businessUnit/{retrieve-response.xml → retrieve-ID=1111111-response.xml} +0 -0
  189. /package/test/resources/1111111/list/{retrieve-response.xml → retrieve-CustomerKey=All SubscribersORListName=All Subscribers-response.xml} +0 -0
  190. /package/test/resources/1111111/role/{retrieve-response.xml → retrieve-IsPrivate=false-response.xml} +0 -0
  191. /package/test/resources/9999999/emailSendDefinition/{retrieve-response.xml → retrieve-IsPlatformObject=falseANDDescriptionnotEqualsSFSendDefinition-response.xml} +0 -0
  192. /package/test/resources/9999999/queryDefinition/{retrieve-response.xml → retrieve-CustomerKey=testExisting_queryANDStatus=Active-response.xml} +0 -0
@@ -0,0 +1,367 @@
1
+ const chai = require('chai');
2
+ const chaiFiles = require('chai-files');
3
+ const assert = chai.assert;
4
+ chai.use(chaiFiles);
5
+ const expect = chai.expect;
6
+ const file = chaiFiles.file;
7
+ // const dir = chaiFiles.dir;
8
+ const cache = require('../lib/util/cache');
9
+ const testUtils = require('./utils');
10
+ const handler = require('../lib/index');
11
+
12
+ describe('type: script', () => {
13
+ beforeEach(() => {
14
+ testUtils.mockSetup();
15
+ });
16
+ afterEach(() => {
17
+ testUtils.mockReset();
18
+ });
19
+
20
+ describe('Retrieve ================', () => {
21
+ it('Should retrieve all scripts', async () => {
22
+ // WHEN
23
+ const retrieve = await handler.retrieve('testInstance/testBU', ['script']);
24
+ // THEN
25
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
26
+
27
+ // retrieve result
28
+ assert.equal(
29
+ retrieve['testInstance/testBU'].script
30
+ ? Object.keys(retrieve['testInstance/testBU'].script).length
31
+ : 0,
32
+ 2,
33
+ 'only 2 scripts expected in retrieve response'
34
+ );
35
+
36
+ // get results from cache
37
+ const result = cache.getCache();
38
+ assert.equal(
39
+ result.script ? Object.keys(result.script).length : 0,
40
+ 2,
41
+ 'only 2 scripts expected'
42
+ );
43
+ // normal test
44
+ assert.deepEqual(
45
+ await testUtils.getActualJson('testExisting_script', 'script'),
46
+ await testUtils.getExpectedJson('9999999', 'script', 'get'),
47
+ 'returned metadata with correct key was not equal expected'
48
+ );
49
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not
50
+ .exist;
51
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal(
52
+ file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs'))
53
+ );
54
+
55
+ assert.deepEqual(
56
+ await testUtils.getActualJson('testExisting_script_noScriptTag', 'script'),
57
+ await testUtils.getExpectedJson('9999999', 'script', 'get_noScriptTag'),
58
+ 'returned metadata was not equal expected'
59
+ );
60
+ expect(
61
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html'))
62
+ ).to.equal(
63
+ file(testUtils.getExpectedFile('9999999', 'script', 'get_noScriptTag', 'html'))
64
+ );
65
+ expect(
66
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs'))
67
+ ).to.not.exist;
68
+
69
+ assert.equal(
70
+ testUtils.getAPIHistoryLength(),
71
+ 3,
72
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
73
+ );
74
+ return;
75
+ });
76
+ it('Should retrieve one specific script by key', async () => {
77
+ // WHEN
78
+ await handler.retrieve('testInstance/testBU', ['script'], ['testExisting_script']);
79
+ // THEN
80
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
81
+ // get results from cache
82
+ const result = cache.getCache();
83
+ assert.equal(
84
+ result.script ? Object.keys(result.script).length : 0,
85
+ 1,
86
+ 'only one script expected'
87
+ );
88
+ assert.deepEqual(
89
+ await testUtils.getActualJson('testExisting_script', 'script'),
90
+ await testUtils.getExpectedJson('9999999', 'script', 'get'),
91
+ 'returned metadata was not equal expected'
92
+ );
93
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not
94
+ .exist;
95
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal(
96
+ file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs'))
97
+ );
98
+
99
+ expect(
100
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'json'))
101
+ ).to.not.exist;
102
+ expect(
103
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs'))
104
+ ).to.not.exist;
105
+ expect(
106
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html'))
107
+ ).to.not.exist;
108
+
109
+ assert.equal(
110
+ testUtils.getAPIHistoryLength(),
111
+ 3,
112
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
113
+ );
114
+ return;
115
+ });
116
+ it('Should retrieve one specific script via --like', async () => {
117
+ // WHEN
118
+ handler.setOptions({ like: { key: '%Existing_script' } });
119
+ await handler.retrieve('testInstance/testBU', ['script']);
120
+
121
+ // THEN
122
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
123
+
124
+ // get results from cache
125
+ const result = cache.getCache();
126
+ assert.equal(
127
+ result.script ? Object.keys(result.script).length : 0,
128
+ 2,
129
+ 'two scripts in cache expected'
130
+ );
131
+ assert.deepEqual(
132
+ await testUtils.getActualJson('testExisting_script', 'script'),
133
+ await testUtils.getExpectedJson('9999999', 'script', 'get'),
134
+ 'returned metadata was not equal expected'
135
+ );
136
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal(
137
+ file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs'))
138
+ );
139
+
140
+ expect(
141
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'json'))
142
+ ).to.not.exist;
143
+ expect(
144
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs'))
145
+ ).to.not.exist;
146
+ expect(
147
+ file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'html'))
148
+ ).to.not.exist;
149
+
150
+ assert.equal(
151
+ testUtils.getAPIHistoryLength(),
152
+ 3,
153
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
154
+ );
155
+ return;
156
+ });
157
+ it('Should not retrieve any script via --like and key due to a mismatching filter', async () => {
158
+ // WHEN
159
+ handler.setOptions({ like: { key: 'NotExisting_script' } });
160
+ await handler.retrieve('testInstance/testBU', ['script']);
161
+ // THEN
162
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
163
+
164
+ // get results from cache
165
+ const result = cache.getCache();
166
+ assert.equal(
167
+ result.script ? Object.keys(result.script).length : 0,
168
+ 2,
169
+ 'two scripts in cache expected'
170
+ );
171
+
172
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.not
173
+ .exist;
174
+ assert.equal(
175
+ testUtils.getAPIHistoryLength(),
176
+ 3,
177
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
178
+ );
179
+ return;
180
+ });
181
+ });
182
+ describe('Deploy ================', () => {
183
+ beforeEach(() => {
184
+ testUtils.mockSetup(true);
185
+ });
186
+ it('Should create & upsert a script', async () => {
187
+ // WHEN
188
+ await handler.deploy('testInstance/testBU', ['script']);
189
+ // THEN
190
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
191
+ // get results from cache
192
+ const result = cache.getCache();
193
+ assert.equal(
194
+ result.script ? Object.keys(result.script).length : 0,
195
+ 3,
196
+ 'three scripts expected'
197
+ );
198
+ // confirm created item
199
+ assert.deepEqual(
200
+ await testUtils.getActualJson('testNew_script', 'script'),
201
+ await testUtils.getExpectedJson('9999999', 'script', 'post'),
202
+ 'returned metadata was not equal expected for insert script'
203
+ );
204
+ expect(file(testUtils.getActualFile('testNew_script', 'script', 'ssjs'))).to.equal(
205
+ file(testUtils.getExpectedFile('9999999', 'script', 'post', 'ssjs'))
206
+ );
207
+ // confirm updated item
208
+ assert.deepEqual(
209
+ await testUtils.getActualJson('testExisting_script', 'script'),
210
+ await testUtils.getExpectedJson('9999999', 'script', 'patch'),
211
+ 'returned metadata was not equal expected for insert script'
212
+ );
213
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal(
214
+ file(testUtils.getExpectedFile('9999999', 'script', 'patch', 'ssjs'))
215
+ );
216
+ // check number of API calls
217
+ assert.equal(
218
+ testUtils.getAPIHistoryLength(),
219
+ 5,
220
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
221
+ );
222
+ return;
223
+ });
224
+ });
225
+ describe('Templating ================', () => {
226
+ it('Should create a script template via retrieveAsTemplate and build it', async () => {
227
+ // GIVEN there is a template
228
+ const result = await handler.retrieveAsTemplate(
229
+ 'testInstance/testBU',
230
+ 'script',
231
+ ['testExisting_script'],
232
+ 'testSourceMarket'
233
+ );
234
+ // WHEN
235
+ assert.equal(
236
+ process.exitCode,
237
+ false,
238
+ 'retrieveAsTemplate should not have thrown an error'
239
+ );
240
+ assert.equal(
241
+ result.script ? Object.keys(result.script).length : 0,
242
+ 1,
243
+ 'only one script expected'
244
+ );
245
+ assert.deepEqual(
246
+ await testUtils.getActualTemplateJson('testExisting_script', 'script'),
247
+ await testUtils.getExpectedJson('9999999', 'script', 'template'),
248
+ 'returned template JSON of retrieveAsTemplate was not equal expected'
249
+ );
250
+ expect(
251
+ file(testUtils.getActualTemplateFile('testExisting_script', 'script', 'ssjs'))
252
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'template', 'ssjs')));
253
+ // THEN
254
+ await handler.buildDefinition(
255
+ 'testInstance/testBU',
256
+ 'script',
257
+ 'testExisting_script',
258
+ 'testTargetMarket'
259
+ );
260
+ assert.equal(
261
+ process.exitCode,
262
+ false,
263
+ 'buildDefinition should not have thrown an error'
264
+ );
265
+
266
+ assert.deepEqual(
267
+ await testUtils.getActualDeployJson('testTemplated_script', 'script'),
268
+ await testUtils.getExpectedJson('9999999', 'script', 'build'),
269
+ 'returned deployment JSON was not equal expected'
270
+ );
271
+ expect(
272
+ file(testUtils.getActualDeployFile('testTemplated_script', 'script', 'ssjs'))
273
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'build', 'ssjs')));
274
+
275
+ assert.equal(
276
+ testUtils.getAPIHistoryLength(),
277
+ 3,
278
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
279
+ );
280
+ return;
281
+ });
282
+ it('Should create a script template via buildTemplate and build it', async () => {
283
+ // download first before we test buildTemplate
284
+ await handler.retrieve('testInstance/testBU', ['script']);
285
+ // GIVEN there is a template
286
+ const result = await handler.buildTemplate(
287
+ 'testInstance/testBU',
288
+ 'script',
289
+ ['testExisting_script'],
290
+ 'testSourceMarket'
291
+ );
292
+ // WHEN
293
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
294
+
295
+ assert.equal(
296
+ result.script ? Object.keys(result.script).length : 0,
297
+ 1,
298
+ 'only one script expected'
299
+ );
300
+ assert.deepEqual(
301
+ await testUtils.getActualTemplateJson('testExisting_script', 'script'),
302
+ await testUtils.getExpectedJson('9999999', 'script', 'template'),
303
+ 'returned template JSON of buildTemplate was not equal expected'
304
+ );
305
+ expect(
306
+ file(testUtils.getActualTemplateFile('testExisting_script', 'script', 'ssjs'))
307
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'template', 'ssjs')));
308
+ // THEN
309
+ await handler.buildDefinition(
310
+ 'testInstance/testBU',
311
+ 'script',
312
+ 'testExisting_script',
313
+ 'testTargetMarket'
314
+ );
315
+ assert.equal(
316
+ process.exitCode,
317
+ false,
318
+ 'buildDefinition should not have thrown an error'
319
+ );
320
+
321
+ assert.deepEqual(
322
+ await testUtils.getActualDeployJson('testTemplated_script', 'script'),
323
+ await testUtils.getExpectedJson('9999999', 'script', 'build'),
324
+ 'returned deployment JSON was not equal expected'
325
+ );
326
+ expect(
327
+ file(testUtils.getActualDeployFile('testTemplated_script', 'script', 'ssjs'))
328
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'build', 'ssjs')));
329
+
330
+ assert.equal(
331
+ testUtils.getAPIHistoryLength(),
332
+ 3,
333
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
334
+ );
335
+ return;
336
+ });
337
+ });
338
+ describe('Delete ================', () => {});
339
+ describe('CI/CD ================', () => {
340
+ it('Should return a list of files based on their type and key', async () => {
341
+ // WHEN
342
+ const fileList = await handler.getFilesToCommit('testInstance/testBU', 'script', [
343
+ 'testExisting_script',
344
+ ]);
345
+ // THEN
346
+ assert.equal(
347
+ process.exitCode,
348
+ false,
349
+ 'getFilesToCommit should not have thrown an error'
350
+ );
351
+ assert.equal(fileList.length, 3, 'expected only 3 file paths (html, json, ssjs)');
352
+
353
+ assert.equal(
354
+ fileList[0].split('\\').join('/'),
355
+ 'retrieve/testInstance/testBU/script/testExisting_script.script-meta.json',
356
+ 'wrong JSON path'
357
+ );
358
+ assert.equal(
359
+ fileList[1].split('\\').join('/'),
360
+ 'retrieve/testInstance/testBU/script/testExisting_script.script-meta.ssjs',
361
+ 'wrong JSON path'
362
+ );
363
+ return;
364
+ });
365
+ });
366
+ describe('Execute ================', () => {});
367
+ });
@@ -0,0 +1,152 @@
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('type: triggeredSend', () => {
10
+ beforeEach(() => {
11
+ testUtils.mockSetup();
12
+ });
13
+ afterEach(() => {
14
+ testUtils.mockReset();
15
+ });
16
+
17
+ describe('Retrieve ================', () => {
18
+ it('Should retrieve a triggeredSend', async () => {
19
+ // WHEN
20
+ await handler.retrieve('testInstance/testBU', ['triggeredSend']);
21
+ // THEN
22
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
23
+ // get results from cache
24
+ const result = cache.getCache();
25
+ assert.equal(
26
+ result.triggeredSend ? Object.keys(result.triggeredSend).length : 0,
27
+ 1,
28
+ 'only one triggeredSend expected'
29
+ );
30
+ assert.deepEqual(
31
+ await testUtils.getActualJson('testExisting_triggeredSend', 'triggeredSend'),
32
+ await testUtils.getExpectedJson('9999999', 'triggeredSend', 'get'),
33
+ 'returned JSON was not equal expected'
34
+ );
35
+ assert.equal(
36
+ testUtils.getAPIHistoryLength(),
37
+ 10,
38
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
39
+ );
40
+ return;
41
+ });
42
+ });
43
+ describe('Deploy ================', () => {
44
+ beforeEach(() => {
45
+ testUtils.mockSetup(true);
46
+ });
47
+ it('Should create & upsert a triggeredSend', async () => {
48
+ // WHEN
49
+ await handler.deploy('testInstance/testBU', ['triggeredSend']);
50
+ // THEN
51
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
52
+ // get results from cache
53
+ const result = cache.getCache();
54
+ assert.equal(
55
+ result.triggeredSend ? Object.keys(result.triggeredSend).length : 0,
56
+ 2,
57
+ 'two triggeredSends expected'
58
+ );
59
+ // confirm created item
60
+ assert.deepEqual(
61
+ await testUtils.getActualJson('testNew_triggeredSend', 'triggeredSend'),
62
+ await testUtils.getExpectedJson('9999999', 'triggeredSend', 'post'),
63
+ 'returned JSON was not equal expected for insert triggeredSend'
64
+ );
65
+ // confirm updated item
66
+ assert.deepEqual(
67
+ await testUtils.getActualJson('testExisting_triggeredSend', 'triggeredSend'),
68
+ await testUtils.getExpectedJson('9999999', 'triggeredSend', 'patch'),
69
+ 'returned JSON was not equal expected for update triggeredSend'
70
+ );
71
+ // check number of API calls
72
+ assert.equal(
73
+ testUtils.getAPIHistoryLength(),
74
+ 12,
75
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
76
+ );
77
+ return;
78
+ });
79
+ });
80
+ describe('Templating ================', () => {
81
+ it('Should create a triggeredSend template via buildTemplate and build it', async () => {
82
+ // download first before we test buildTemplate
83
+ await handler.retrieve('testInstance/testBU', ['triggeredSend']);
84
+ // buildTemplate
85
+ const result = await handler.buildTemplate(
86
+ 'testInstance/testBU',
87
+ 'triggeredSend',
88
+ ['testExisting_triggeredSend'],
89
+ 'testSourceMarket'
90
+ );
91
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
92
+ assert.equal(
93
+ result.triggeredSend ? Object.keys(result.triggeredSend).length : 0,
94
+ 1,
95
+ 'only one triggeredSend expected'
96
+ );
97
+ assert.deepEqual(
98
+ await testUtils.getActualTemplateJson(
99
+ 'testExisting_triggeredSend',
100
+ 'triggeredSend'
101
+ ),
102
+ await testUtils.getExpectedJson('9999999', 'triggeredSend', 'template'),
103
+ 'returned template JSON was not equal expected'
104
+ );
105
+ // buildDefinition
106
+ await handler.buildDefinition(
107
+ 'testInstance/testBU',
108
+ 'triggeredSend',
109
+ 'testExisting_triggeredSend',
110
+ 'testTargetMarket'
111
+ );
112
+ assert.equal(
113
+ process.exitCode,
114
+ false,
115
+ 'buildDefinition should not have thrown an error'
116
+ );
117
+ assert.deepEqual(
118
+ await testUtils.getActualDeployJson('testTemplated_triggeredSend', 'triggeredSend'),
119
+ await testUtils.getExpectedJson('9999999', 'triggeredSend', 'build'),
120
+ 'returned deployment JSON was not equal expected'
121
+ );
122
+ assert.equal(
123
+ testUtils.getAPIHistoryLength(),
124
+ 10,
125
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
126
+ );
127
+ return;
128
+ });
129
+ });
130
+ describe('Delete ================', () => {
131
+ it('Should delete the item', async () => {
132
+ // WHEN
133
+ const result = await handler.deleteByKey('testInstance/testBU', 'triggeredSend', [
134
+ 'testExisting_triggeredSend',
135
+ ]);
136
+ // THEN
137
+ assert.equal(process.exitCode, false, 'delete should not have thrown an error');
138
+
139
+ assert.equal(result, true, 'should have deleted the item');
140
+ return;
141
+ });
142
+ });
143
+ describe('Refresh ================', () => {
144
+ it('Should refresh a triggeredSend by key');
145
+ });
146
+ describe('Start (Execute) ================', () => {
147
+ it('Should start a triggeredSend by key');
148
+ });
149
+ describe('Pause ================', () => {
150
+ it('Should pause a triggeredSend by key');
151
+ });
152
+ });
@@ -26,8 +26,8 @@ describe('type: user', () => {
26
26
  const result = cache.getCache();
27
27
  assert.equal(
28
28
  result.user ? Object.keys(result.user).length : 0,
29
- 1,
30
- 'only one user expected'
29
+ 3,
30
+ 'only three users expected'
31
31
  );
32
32
  assert.deepEqual(
33
33
  await testUtils.getActualJson('testExisting_user', 'user', '_ParentBU_'),
@@ -42,7 +42,7 @@ describe('type: user', () => {
42
42
  { encoding: 'utf8' }
43
43
  );
44
44
  const regexFindDaysSinceLogin =
45
- /\| (\d*) (seconds|minutes|days|weeks|months|years){1} \|/gm;
45
+ /\| (\d*) (seconds|minutes|days|weeks|months|years){1} \|/g;
46
46
  // fetch expected time since last login
47
47
  const expectedDaysSinceLogin = expectedFile.match(regexFindDaysSinceLogin);
48
48
  // load actual file and replace days since last login with expected value
@@ -50,7 +50,7 @@ describe('type: user', () => {
50
50
  await File.readFile(`./docs/user/testInstance.users.md`, {
51
51
  encoding: 'utf8',
52
52
  })
53
- ).replaceAll(regexFindDaysSinceLogin, expectedDaysSinceLogin);
53
+ ).replaceAll(regexFindDaysSinceLogin, [expectedDaysSinceLogin[0]]);
54
54
  expect(actualFile).to.equal(expectedFile);
55
55
 
56
56
  assert.equal(
@@ -83,7 +83,12 @@ describe('type: user', () => {
83
83
  });
84
84
  it('Should create & upsert a user', async () => {
85
85
  // WHEN
86
- const expectedCache = ['testNew_user', 'testExisting_user'];
86
+ const expectedCache = [
87
+ 'testExisting_user',
88
+ 'testExisting_user_inactive',
89
+ '45372cbb-06e0-438e-88d8-008981f7a18b',
90
+ 'testNew_user',
91
+ ];
87
92
  await handler.deploy('testInstance/_ParentBU_', ['user'], expectedCache);
88
93
  // THEN
89
94
  assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
@@ -92,8 +97,8 @@ describe('type: user', () => {
92
97
  const result = cache.getCache();
93
98
  assert.equal(
94
99
  result.user ? Object.keys(result.user).length : 0,
95
- 2,
96
- 'two users expected'
100
+ 4,
101
+ 'four users expected'
97
102
  );
98
103
  // confirm if result.user only includes values from expectedCache
99
104
  assert.deepEqual(
@@ -126,14 +131,22 @@ describe('type: user', () => {
126
131
  });
127
132
  it('Should not deploy user with Marketing Cloud role', async () => {
128
133
  // WHEN
129
- const expectedCache = ['testExisting_user'];
134
+ const expectedCache = [
135
+ 'testExisting_user',
136
+ 'testExisting_user_inactive',
137
+ '45372cbb-06e0-438e-88d8-008981f7a18b',
138
+ ];
130
139
  await handler.deploy('testInstance/_ParentBU_', ['user'], ['testBlocked_user']);
131
140
  // THEN
132
141
  assert.equal(process.exitCode, 1, 'Deployment should have thrown an error');
133
142
 
134
143
  // get results from cache
135
144
  const result = cache.getCache();
136
- assert.equal(result.user ? Object.keys(result.user).length : 0, 1, '1 user expected');
145
+ assert.equal(
146
+ result.user ? Object.keys(result.user).length : 0,
147
+ 3,
148
+ 'three users expected'
149
+ );
137
150
  // confirm if result.user only includes values from expectedCache
138
151
  assert.deepEqual(
139
152
  Object.keys(result.user),
@@ -148,7 +161,6 @@ describe('type: user', () => {
148
161
  );
149
162
  return;
150
163
  });
151
- it('Should change the key during update with --changeKeyValue');
152
164
  });
153
165
  describe('Templating ================', () => {
154
166
  // it('Should create a user template via retrieveAsTemplate and build it', async () => {});
package/test/utils.js CHANGED
@@ -112,7 +112,10 @@ exports.getExpectedFile = (mid, type, action, ext) =>
112
112
  */
113
113
 
114
114
  exports.mockSetup = (isDeploy) => {
115
- handler.setOptions({ debug: true, noLogFile: true });
115
+ if (!isDeploy) {
116
+ // no need to execute this again - already done in standard setup
117
+ handler.setOptions({ debug: true, noLogFile: true });
118
+ }
116
119
  apimock = new MockAdapter(axios, { onNoMatch: 'throwException' });
117
120
  // set access_token to mid to allow for autorouting of mock to correct resources
118
121
  apimock.onPost(authResources.success.url).reply((config) => {
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- const TYPE = require('../../types/mcdev.d');
4
- const MetadataType = require('./MetadataType');
5
-
6
- /**
7
- * SetDefinition MetadataType
8
- *
9
- * @augments MetadataType
10
- */
11
- class SetDefinition extends MetadataType {
12
- /**
13
- * Retrieves Metadata of schema set Definitions.
14
- *
15
- * @param {string} retrieveDir Directory where retrieved metadata directory will be saved
16
- * @param {void} [_] unused parameter
17
- * @param {void} [__] unused parameter
18
- * @param {string} [key] customer key of single item to retrieve
19
- * @returns {Promise.<TYPE.MetadataTypeMapObj>} Promise
20
- */
21
- static retrieve(retrieveDir, _, __, key) {
22
- return super.retrieveREST(retrieveDir, '/hub/v1/contacts/schema/setDefinitions', null, key);
23
- }
24
- /**
25
- * Retrieves Metadata of schema set definitions for caching.
26
- *
27
- * @returns {Promise.<TYPE.MetadataTypeMapObj>} Promise
28
- */
29
- static retrieveForCache() {
30
- return super.retrieveREST(null, '/hub/v1/contacts/schema/setDefinitions');
31
- }
32
- }
33
-
34
- // Assign definition to static attributes
35
- SetDefinition.definition = require('../MetadataTypeDefinitions').setDefinition;
36
-
37
- module.exports = SetDefinition;