mcdev 5.2.0 → 6.0.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 (191) hide show
  1. package/.eslintrc.json +1 -1
  2. package/.fork/custom-commands.json +12 -0
  3. package/.github/ISSUE_TEMPLATE/bug.yml +2 -0
  4. package/.github/PULL_REQUEST_TEMPLATE/pr_template_release.md +19 -0
  5. package/.github/workflows/code-test.yml +1 -1
  6. package/.github/workflows/coverage-base-update.yml +1 -1
  7. package/.github/workflows/coverage-develop-branch.yml +2 -2
  8. package/.github/workflows/coverage-main-branch.yml +2 -2
  9. package/.github/workflows/coverage.yml +2 -2
  10. package/.github/workflows/npm-publish.yml +2 -2
  11. package/.prettierrc +7 -0
  12. package/docs/dist/documentation.md +388 -482
  13. package/jsconfig.json +5 -1
  14. package/lib/Builder.js +8 -8
  15. package/lib/Deployer.js +10 -10
  16. package/lib/MetadataTypeDefinitions.js +73 -38
  17. package/lib/MetadataTypeInfo.js +72 -37
  18. package/lib/Retriever.js +8 -8
  19. package/lib/cli.js +12 -7
  20. package/lib/index.js +28 -18
  21. package/lib/metadataTypes/Asset.js +12 -10
  22. package/lib/metadataTypes/AttributeGroup.js +7 -6
  23. package/lib/metadataTypes/AttributeSet.js +126 -18
  24. package/lib/metadataTypes/Automation.js +107 -78
  25. package/lib/metadataTypes/Campaign.js +7 -6
  26. package/lib/metadataTypes/ContentArea.js +7 -6
  27. package/lib/metadataTypes/DataExtension.js +475 -78
  28. package/lib/metadataTypes/DataExtensionField.js +36 -18
  29. package/lib/metadataTypes/DataExtensionTemplate.js +5 -4
  30. package/lib/metadataTypes/DataExtract.js +8 -7
  31. package/lib/metadataTypes/DataExtractType.js +5 -4
  32. package/lib/metadataTypes/Discovery.js +6 -5
  33. package/lib/metadataTypes/Email.js +6 -5
  34. package/lib/metadataTypes/EmailSend.js +7 -6
  35. package/lib/metadataTypes/Event.js +8 -7
  36. package/lib/metadataTypes/FileLocation.js +5 -4
  37. package/lib/metadataTypes/FileTransfer.js +8 -7
  38. package/lib/metadataTypes/Filter.js +5 -4
  39. package/lib/metadataTypes/Folder.js +9 -8
  40. package/lib/metadataTypes/ImportFile.js +8 -7
  41. package/lib/metadataTypes/Journey.js +17 -9
  42. package/lib/metadataTypes/List.js +9 -8
  43. package/lib/metadataTypes/MetadataType.js +100 -34
  44. package/lib/metadataTypes/MobileCode.js +5 -4
  45. package/lib/metadataTypes/MobileKeyword.js +9 -8
  46. package/lib/metadataTypes/MobileMessage.js +8 -7
  47. package/lib/metadataTypes/Query.js +9 -8
  48. package/lib/metadataTypes/Role.js +8 -7
  49. package/lib/metadataTypes/Script.js +7 -6
  50. package/lib/metadataTypes/SendClassification.js +5 -4
  51. package/lib/metadataTypes/TransactionalEmail.js +101 -23
  52. package/lib/metadataTypes/TransactionalMessage.js +9 -7
  53. package/lib/metadataTypes/TransactionalPush.js +7 -6
  54. package/lib/metadataTypes/TransactionalSMS.js +9 -8
  55. package/lib/metadataTypes/TriggeredSend.js +15 -12
  56. package/lib/metadataTypes/User.js +8 -7
  57. package/lib/metadataTypes/Verification.js +230 -0
  58. package/lib/metadataTypes/definitions/Asset.definition.js +1 -1
  59. package/lib/metadataTypes/definitions/AttributeGroup.definition.js +3 -3
  60. package/lib/metadataTypes/definitions/AttributeSet.definition.js +75 -22
  61. package/lib/metadataTypes/definitions/Automation.definition.js +2 -1
  62. package/lib/metadataTypes/definitions/Campaign.definition.js +1 -1
  63. package/lib/metadataTypes/definitions/ContentArea.definition.js +1 -1
  64. package/lib/metadataTypes/definitions/DataExtension.definition.js +1 -1
  65. package/lib/metadataTypes/definitions/DataExtensionField.definition.js +1 -1
  66. package/lib/metadataTypes/definitions/DataExtensionTemplate.definition.js +1 -1
  67. package/lib/metadataTypes/definitions/DataExtract.definition.js +1 -1
  68. package/lib/metadataTypes/definitions/DataExtractType.definition.js +1 -1
  69. package/lib/metadataTypes/definitions/Discovery.definition.js +1 -1
  70. package/lib/metadataTypes/definitions/Email.definition.js +1 -1
  71. package/lib/metadataTypes/definitions/EmailSend.definition.js +1 -1
  72. package/lib/metadataTypes/definitions/Event.definition.js +1 -1
  73. package/lib/metadataTypes/definitions/FileLocation.definition.js +1 -1
  74. package/lib/metadataTypes/definitions/FileTransfer.definition.js +1 -1
  75. package/lib/metadataTypes/definitions/Filter.definition.js +1 -1
  76. package/lib/metadataTypes/definitions/Folder.definition.js +1 -1
  77. package/lib/metadataTypes/definitions/ImportFile.definition.js +1 -1
  78. package/lib/metadataTypes/definitions/Journey.definition.js +1 -1
  79. package/lib/metadataTypes/definitions/List.definition.js +1 -1
  80. package/lib/metadataTypes/definitions/MobileCode.definition.js +1 -1
  81. package/lib/metadataTypes/definitions/MobileKeyword.definition.js +1 -1
  82. package/lib/metadataTypes/definitions/MobileMessage.definition.js +1 -1
  83. package/lib/metadataTypes/definitions/Query.definition.js +1 -1
  84. package/lib/metadataTypes/definitions/Role.definition.js +1 -1
  85. package/lib/metadataTypes/definitions/Script.definition.js +1 -1
  86. package/lib/metadataTypes/definitions/SendClassification.definition.js +1 -1
  87. package/lib/metadataTypes/definitions/TransactionalEmail.definition.js +20 -2
  88. package/lib/metadataTypes/definitions/TransactionalPush.definition.js +1 -1
  89. package/lib/metadataTypes/definitions/TransactionalSMS.definition.js +1 -1
  90. package/lib/metadataTypes/definitions/TriggeredSend.definition.js +1 -1
  91. package/lib/metadataTypes/definitions/User.definition.js +1 -1
  92. package/lib/metadataTypes/definitions/Verification.definition.js +88 -0
  93. package/lib/retrieveChangelog.js +4 -3
  94. package/lib/util/auth.js +11 -8
  95. package/lib/util/businessUnit.js +5 -5
  96. package/lib/util/cache.js +3 -3
  97. package/lib/util/cli.js +15 -13
  98. package/lib/util/config.js +10 -7
  99. package/lib/util/devops.js +12 -11
  100. package/lib/util/file.js +15 -14
  101. package/lib/util/init.config.js +11 -9
  102. package/lib/util/init.git.js +8 -7
  103. package/lib/util/init.js +12 -12
  104. package/lib/util/init.npm.js +7 -5
  105. package/lib/util/util.js +14 -12
  106. package/package.json +32 -27
  107. package/test/general.test.js +4 -6
  108. package/test/mockRoot/.mcdevrc.json +1 -1
  109. package/test/mockRoot/deploy/testInstance/_ParentBU_/dataExtension/testExisting_dataExtensionShared.dataExtension-meta.json +59 -0
  110. package/test/mockRoot/deploy/testInstance/_ParentBU_/dataExtension/testNew_dataExtensionShared.dataExtension-meta.json +23 -0
  111. package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json +4 -0
  112. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/testExisting_dataExtension.dataExtension-meta.json +1 -0
  113. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testExisting_temail.transactionalEmail-meta.json +3 -4
  114. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testNew_temail.transactionalEmail-meta.json +1 -6
  115. package/test/mockRoot/deploy/testInstance/testBU/verification/testExisting_39f6a488-20eb-4ba0-b0b9.verification-meta.json +11 -0
  116. package/test/mockRoot/deploy/testInstance/testBU/verification/testNew_39f6a488-20eb-4ba0-b0b9.verification-meta.json +11 -0
  117. package/test/resourceFactory.js +52 -26
  118. package/test/resources/1111111/data/v1/customobjectdata/key/testExisting_dataExtensionShared/rowset/get-response.json +13 -0
  119. package/test/resources/1111111/dataExtension/create-expected.json +23 -0
  120. package/test/resources/1111111/dataExtension/create-response.xml +59 -0
  121. package/test/resources/1111111/dataExtension/retrieve-expected.json +55 -0
  122. package/test/resources/1111111/dataExtension/retrieve-expected.md +18 -0
  123. package/test/resources/1111111/dataExtension/retrieve-response.xml +27 -1
  124. package/test/resources/1111111/dataExtension/update-expected.json +55 -0
  125. package/test/resources/1111111/dataExtension/update-response.xml +57 -0
  126. package/test/resources/1111111/dataExtensionField/retrieve-CustomerKey=[testExisting_dataExtensionShared].[TriggerUpdate_randomNumber_]-response.xml +45 -0
  127. package/test/resources/1111111/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtensionShared-response.xml +98 -0
  128. package/test/resources/1111111/dataExtensionField/retrieve-DataExtension.CustomerKey=testNew_dataExtensionSharedORDataExtension.CustomerKey=testExisting_dataExtensionShared-response.xml +98 -0
  129. package/test/resources/1111111/dataExtensionField/retrieve-response.xml +98 -0
  130. package/test/resources/1111111/dataExtensionTemplate/retrieve-response.xml +303 -0
  131. package/test/resources/1111111/dataFolder/retrieve-ContentType=synchronizeddataextensionORContentType=shared_salesforcedataextensionORContentType=shared_dataextensionORContentType=shared_dataORContentType=salesforcedataextensionORContentType=dataextensionORContentType=hidden-response.xml +387 -0
  132. package/test/resources/1111111/dataFolder/retrieve-response.xml +353 -9
  133. package/test/resources/9999999/attributeSet/retrieve-expected.json +89 -694
  134. package/test/resources/9999999/automation/build-expected.json +4 -0
  135. package/test/resources/9999999/automation/create-expected.json +4 -0
  136. package/test/resources/9999999/automation/create-testNew_automation-expected.md +1 -0
  137. package/test/resources/9999999/automation/retrieve-expected.json +4 -0
  138. package/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +1 -0
  139. package/test/resources/9999999/automation/template-expected.json +4 -0
  140. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +7 -0
  141. package/test/resources/9999999/automation/v1/automations/post-response.json +7 -0
  142. package/test/resources/9999999/automation/v1/dataverifications/post-response.json +12 -0
  143. package/test/resources/9999999/automation/v1/dataverifications/testExisting_39f6a488-20eb-4ba0-b0b9/delete-response.json +0 -0
  144. package/test/resources/9999999/automation/v1/dataverifications/testExisting_39f6a488-20eb-4ba0-b0b9/get-response.json +12 -0
  145. package/test/resources/9999999/automation/v1/dataverifications/testExisting_39f6a488-20eb-4ba0-b0b9/patch-response.json +12 -0
  146. package/test/resources/9999999/dataExtension/build-expected.json +16 -0
  147. package/test/resources/9999999/dataExtension/delete-response.xml +42 -0
  148. package/test/resources/9999999/dataExtension/retrieve-expected.json +16 -0
  149. package/test/resources/9999999/dataExtension/retrieve-expected.md +3 -1
  150. package/test/resources/9999999/dataExtension/template-expected.json +16 -0
  151. package/test/resources/9999999/dataExtension/update-expected.json +17 -1
  152. package/test/resources/9999999/dataExtensionField/retrieve-CustomerKey=[testExisting_dataExtension].[LastName]-response.xml +44 -0
  153. package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml +36 -1
  154. package/test/resources/9999999/dataExtensionField/retrieve-response.xml +36 -1
  155. package/test/resources/9999999/dataFolder/retrieve-ContentType=synchronizeddataextensionORContentType=shared_salesforcedataextensionORContentType=shared_dataextensionORContentType=shared_dataORContentType=salesforcedataextensionORContentType=dataextensionORContentType=hidden-response.xml +117 -0
  156. package/test/resources/9999999/hub/v1/contacts/schema/attributeGroups/get-response.json +43 -0
  157. package/test/resources/9999999/hub/v1/contacts/schema/setDefinitions/get-response.json +387 -0
  158. package/test/resources/9999999/interaction/v1/interactions/233d4413-922c-4568-85a5-e5cc77efc3be/delete-response.json +1 -0
  159. package/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json +1 -1
  160. package/test/resources/9999999/messaging/v1/email/definitions/post-response.json +1 -1
  161. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/delete-response.json +6 -0
  162. package/test/resources/9999999/transactionalEmail/build-expected.json +3 -7
  163. package/test/resources/9999999/transactionalEmail/get-expected.json +3 -7
  164. package/test/resources/9999999/transactionalEmail/patch-expected.json +3 -7
  165. package/test/resources/9999999/transactionalEmail/post-expected.json +3 -7
  166. package/test/resources/9999999/transactionalEmail/template-expected.json +3 -7
  167. package/test/resources/9999999/verification/build-expected.json +11 -0
  168. package/test/resources/9999999/verification/get-expected.json +11 -0
  169. package/test/resources/9999999/verification/patch-expected.json +11 -0
  170. package/test/resources/9999999/verification/post-expected.json +11 -0
  171. package/test/resources/9999999/verification/template-expected.json +11 -0
  172. package/test/type.attributeGroup.test.js +9 -12
  173. package/test/type.attributeSet.test.js +10 -13
  174. package/test/type.automation.test.js +34 -32
  175. package/test/type.dataExtension.test.js +210 -54
  176. package/test/type.dataExtract.test.js +15 -9
  177. package/test/type.fileTransfer.test.js +15 -9
  178. package/test/type.importFile.test.js +15 -9
  179. package/test/type.journey.test.js +43 -17
  180. package/test/type.mobileKeyword.test.js +11 -11
  181. package/test/type.mobileMessage.test.js +11 -11
  182. package/test/type.query.test.js +13 -14
  183. package/test/type.script.test.js +11 -9
  184. package/test/type.transactionalEmail.test.js +17 -17
  185. package/test/type.transactionalPush.test.js +7 -10
  186. package/test/type.transactionalSMS.test.js +7 -11
  187. package/test/type.triggeredSend.test.js +11 -10
  188. package/test/type.user.test.js +6 -8
  189. package/test/type.verification.test.js +172 -0
  190. package/test/utils.js +68 -48
  191. package/types/mcdev.d.js +16 -2
@@ -1,13 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
-
1
+ import chai, { assert } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import cache from '../lib/util/cache.js';
4
+ import * as testUtils from './utils.js';
5
+ import handler from '../lib/index.js';
4
6
  chai.use(chaiFiles);
5
7
 
6
- const assert = chai.assert;
7
- const cache = require('../lib/util/cache');
8
- const testUtils = require('./utils');
9
- const handler = require('../lib/index');
10
-
11
8
  describe('type: attributeSet', () => {
12
9
  beforeEach(() => {
13
10
  testUtils.mockSetup();
@@ -26,19 +23,19 @@ describe('type: attributeSet', () => {
26
23
  retrieve['testInstance/testBU'].attributeSet
27
24
  ? Object.keys(retrieve['testInstance/testBU'].attributeSet).length
28
25
  : 0,
29
- 27,
30
- 'only 27 attributeSets expected in retrieve response'
26
+ 28,
27
+ 'only 28 attributeSets expected in retrieve response'
31
28
  );
32
29
  // get results from cache
33
30
  const result = cache.getCache();
34
31
  assert.equal(
35
32
  result.attributeSet ? Object.keys(result.attributeSet).length : 0,
36
- 27,
37
- 'only 27 attributeSets expected in cache'
33
+ 28,
34
+ 'only 28 attributeSets expected in cache'
38
35
  );
39
36
 
40
37
  assert.deepEqual(
41
- await testUtils.getActualJson('MobileSubscriptions', 'attributeSet'),
38
+ await testUtils.getActualJson('testExisting_dataExtensionShared', 'attributeSet'),
42
39
  await testUtils.getExpectedJson('9999999', 'attributeSet', 'retrieve'),
43
40
 
44
41
  'returned metadata was not equal expected'
@@ -1,14 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
-
1
+ import chai, { assert, expect } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import cache from '../lib/util/cache.js';
4
+ import * as testUtils from './utils.js';
5
+ import handler from '../lib/index.js';
4
6
  chai.use(chaiFiles);
5
-
6
- const assert = chai.assert;
7
- const expect = chai.expect;
8
7
  const file = chaiFiles.file;
9
- const cache = require('../lib/util/cache');
10
- const testUtils = require('./utils');
11
- const handler = require('../lib/index');
12
8
 
13
9
  describe('type: automation', () => {
14
10
  beforeEach(() => {
@@ -47,10 +43,9 @@ describe('type: automation', () => {
47
43
  )
48
44
  )
49
45
  );
50
-
51
46
  assert.equal(
52
47
  testUtils.getAPIHistoryLength(),
53
- 17,
48
+ 18,
54
49
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
55
50
  );
56
51
  return;
@@ -62,7 +57,11 @@ describe('type: automation', () => {
62
57
  });
63
58
  it('Should create & update a automation', async () => {
64
59
  // WHEN
65
- const deployResult = await handler.deploy('testInstance/testBU', ['automation']);
60
+ const deployResult = await handler.deploy(
61
+ 'testInstance/testBU',
62
+ ['automation', 'verification'],
63
+ ['testExisting_automation', 'testNew_automation', 'testNew_39f6a488-20eb-4ba0-b0b9']
64
+ );
66
65
  // THEN
67
66
  assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
68
67
 
@@ -120,7 +119,7 @@ describe('type: automation', () => {
120
119
 
121
120
  assert.equal(
122
121
  testUtils.getAPIHistoryLength(),
123
- 16,
122
+ 25,
124
123
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
125
124
  );
126
125
  return;
@@ -130,8 +129,8 @@ describe('type: automation', () => {
130
129
  handler.setOptions({ schedule: true });
131
130
  const deployed = await handler.deploy(
132
131
  'testInstance/testBU',
133
- ['automation'],
134
- ['testExisting_automation', 'testNew_automation']
132
+ ['automation', 'verification'],
133
+ ['testExisting_automation', 'testNew_automation', 'testNew_39f6a488-20eb-4ba0-b0b9']
135
134
  );
136
135
  // THEN
137
136
  assert.equal(
@@ -189,7 +188,7 @@ describe('type: automation', () => {
189
188
 
190
189
  assert.equal(
191
190
  testUtils.getAPIHistoryLength(),
192
- 24,
191
+ 33,
193
192
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
194
193
  );
195
194
  return;
@@ -199,8 +198,8 @@ describe('type: automation', () => {
199
198
  handler.setOptions({ execute: true });
200
199
  const deployed = await handler.deploy(
201
200
  'testInstance/testBU',
202
- ['automation'],
203
- ['testExisting_automation', 'testNew_automation']
201
+ ['automation', 'verification'],
202
+ ['testExisting_automation', 'testNew_automation', 'testNew_39f6a488-20eb-4ba0-b0b9']
204
203
  );
205
204
  // THEN
206
205
  assert.equal(
@@ -257,7 +256,7 @@ describe('type: automation', () => {
257
256
 
258
257
  assert.equal(
259
258
  testUtils.getAPIHistoryLength(),
260
- 20,
259
+ 29,
261
260
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
262
261
  );
263
262
  return;
@@ -289,10 +288,11 @@ describe('type: automation', () => {
289
288
  1,
290
289
  'one automation expected'
291
290
  );
291
+ testUtils.logAPIHistoryDebug();
292
292
  // check number of API calls
293
293
  assert.equal(
294
294
  testUtils.getAPIHistoryLength(),
295
- 14,
295
+ 18,
296
296
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
297
297
  );
298
298
  return;
@@ -336,7 +336,7 @@ describe('type: automation', () => {
336
336
  // check number of API calls
337
337
  assert.equal(
338
338
  testUtils.getAPIHistoryLength(),
339
- 29,
339
+ 40,
340
340
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
341
341
  );
342
342
  return;
@@ -380,7 +380,7 @@ describe('type: automation', () => {
380
380
  // check number of API calls
381
381
  assert.equal(
382
382
  testUtils.getAPIHistoryLength(),
383
- 31,
383
+ 42,
384
384
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
385
385
  );
386
386
  return;
@@ -424,7 +424,7 @@ describe('type: automation', () => {
424
424
  // check number of API calls
425
425
  assert.equal(
426
426
  testUtils.getAPIHistoryLength(),
427
- 32,
427
+ 43,
428
428
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
429
429
  );
430
430
  return;
@@ -464,7 +464,7 @@ describe('type: automation', () => {
464
464
  // check number of API calls
465
465
  assert.equal(
466
466
  testUtils.getAPIHistoryLength(),
467
- 26,
467
+ 35,
468
468
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
469
469
  );
470
470
  return;
@@ -505,7 +505,7 @@ describe('type: automation', () => {
505
505
  // check number of API calls
506
506
  assert.equal(
507
507
  testUtils.getAPIHistoryLength(),
508
- 30,
508
+ 41,
509
509
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
510
510
  );
511
511
  return;
@@ -546,7 +546,7 @@ describe('type: automation', () => {
546
546
  // check number of API calls
547
547
  assert.equal(
548
548
  testUtils.getAPIHistoryLength(),
549
- 32,
549
+ 43,
550
550
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
551
551
  );
552
552
  return;
@@ -597,7 +597,7 @@ describe('type: automation', () => {
597
597
  );
598
598
  assert.equal(
599
599
  testUtils.getAPIHistoryLength(),
600
- 14,
600
+ 20,
601
601
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
602
602
  );
603
603
  return;
@@ -644,7 +644,7 @@ describe('type: automation', () => {
644
644
  );
645
645
  assert.equal(
646
646
  testUtils.getAPIHistoryLength(),
647
- 17,
647
+ 18,
648
648
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
649
649
  );
650
650
  return;
@@ -653,13 +653,15 @@ describe('type: automation', () => {
653
653
  describe('Delete ================', () => {
654
654
  it('Should delete the item', async () => {
655
655
  // WHEN
656
- const result = await handler.deleteByKey('testInstance/testBU', 'automation', [
657
- 'testExisting_automation',
658
- ]);
656
+ const isDeleted = await handler.deleteByKey(
657
+ 'testInstance/testBU',
658
+ 'automation',
659
+ 'testExisting_automation'
660
+ );
659
661
  // THEN
660
662
  assert.equal(process.exitCode, false, 'delete should not have thrown an error');
661
663
 
662
- assert.equal(result, true, 'should have deleted the item');
664
+ assert.equal(isDeleted, true, 'should have deleted the item');
663
665
  return;
664
666
  });
665
667
  });
@@ -1,14 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
-
1
+ import chai, { assert, expect } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import cache from '../lib/util/cache.js';
4
+ import * as testUtils from './utils.js';
5
+ import handler from '../lib/index.js';
4
6
  chai.use(chaiFiles);
5
-
6
- const assert = chai.assert;
7
- const expect = chai.expect;
8
7
  const file = chaiFiles.file;
9
- const cache = require('../lib/util/cache');
10
- const testUtils = require('./utils');
11
- const handler = require('../lib/index');
12
8
 
13
9
  describe('type: dataExtension', () => {
14
10
  beforeEach(() => {
@@ -50,23 +46,73 @@ describe('type: dataExtension', () => {
50
46
  );
51
47
  return;
52
48
  });
49
+ it('Should retrieve a shared dataExtension', async () => {
50
+ // WHEN
51
+ await handler.retrieve('testInstance/_ParentBU_', ['dataExtension']);
52
+ // THEN
53
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
54
+ // get results from cache
55
+ const result = cache.getCache();
56
+ assert.equal(
57
+ result.dataExtension ? Object.keys(result.dataExtension).length : 0,
58
+ 1,
59
+ 'only one dataExtension expected'
60
+ );
61
+ assert.deepEqual(
62
+ await testUtils.getActualJson(
63
+ 'testExisting_dataExtensionShared',
64
+ 'dataExtension',
65
+ '_ParentBU_'
66
+ ),
67
+ await testUtils.getExpectedJson('1111111', 'dataExtension', 'retrieve'),
68
+
69
+ 'returned metadata was not equal expected'
70
+ );
71
+ // check if MD file was created and equals expectations
72
+ expect(
73
+ file(
74
+ testUtils.getActualDoc(
75
+ 'testExisting_dataExtensionShared',
76
+ 'dataExtension',
77
+ '_ParentBU_'
78
+ )
79
+ )
80
+ ).to.equal(
81
+ file(testUtils.getExpectedFile('1111111', 'dataExtension', 'retrieve', 'md'))
82
+ );
83
+
84
+ assert.equal(
85
+ testUtils.getAPIHistoryLength(),
86
+ 4,
87
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
88
+ );
89
+ return;
90
+ });
53
91
  });
54
92
  describe('Deploy ================', () => {
55
93
  beforeEach(() => {
56
94
  testUtils.mockSetup(true);
57
95
  });
58
- it('Should create & update a dataExtension', async () => {
96
+ it('Should create & update a dataExtension including a field rename', async () => {
59
97
  // WHEN
60
- await handler.deploy('testInstance/testBU', ['dataExtension']);
98
+ const deployResult = await handler.deploy('testInstance/testBU', ['dataExtension']);
61
99
  // THEN
62
100
  assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
63
101
 
102
+ assert.equal(
103
+ deployResult['testInstance/testBU']?.dataExtension
104
+ ? Object.keys(deployResult['testInstance/testBU']?.dataExtension).length
105
+ : 0,
106
+ 2,
107
+ 'two dataExtensions to be deployed'
108
+ );
109
+
64
110
  // get results from cache
65
111
  const result = cache.getCache();
66
112
  assert.equal(
67
113
  result.dataExtension ? Object.keys(result.dataExtension).length : 0,
68
- 2,
69
- 'two dataExtensions expected'
114
+ 3,
115
+ 'three dataExtensions expected'
70
116
  );
71
117
  // insert
72
118
  assert.deepEqual(
@@ -87,7 +133,104 @@ describe('type: dataExtension', () => {
87
133
  );
88
134
  return;
89
135
  });
90
- it('Should rename fields');
136
+ it('Should create & update a shared dataExtension', async () => {
137
+ // WHEN
138
+ const deployResult = await handler.deploy('testInstance/_ParentBU_', ['dataExtension']);
139
+ // THEN
140
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
141
+
142
+ assert.equal(
143
+ deployResult['testInstance/_ParentBU_']?.dataExtension
144
+ ? Object.keys(deployResult['testInstance/_ParentBU_']?.dataExtension).length
145
+ : 0,
146
+ 2,
147
+ 'two dataExtensions to be deployed'
148
+ );
149
+
150
+ // get results from cache
151
+ const result = cache.getCache();
152
+ assert.equal(
153
+ result.dataExtension ? Object.keys(result.dataExtension).length : 0,
154
+ 2,
155
+ 'two dataExtensions expected'
156
+ );
157
+ // insert
158
+ assert.deepEqual(
159
+ await testUtils.getActualJson(
160
+ 'testNew_dataExtensionShared',
161
+ 'dataExtension',
162
+ '_ParentBU_'
163
+ ),
164
+ await testUtils.getExpectedJson('1111111', 'dataExtension', 'create'),
165
+ 'returned metadata was not equal expected for create'
166
+ );
167
+ // update
168
+ assert.deepEqual(
169
+ await testUtils.getActualJson(
170
+ 'testExisting_dataExtensionShared',
171
+ 'dataExtension',
172
+ '_ParentBU_'
173
+ ),
174
+ await testUtils.getExpectedJson('1111111', 'dataExtension', 'update'),
175
+ 'returned metadata was not equal expected for update'
176
+ );
177
+ assert.equal(
178
+ testUtils.getAPIHistoryLength(),
179
+ 8,
180
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
181
+ );
182
+ return;
183
+ });
184
+ it('Should create & update a shared dataExtension with --fixShared & --skipInteraction', async () => {
185
+ // WHEN
186
+ handler.setOptions({ fixShared: 'testBU', skipInteraction: true, _runningTest: true });
187
+
188
+ const deployResult = await handler.deploy('testInstance/_ParentBU_', ['dataExtension']);
189
+ // THEN
190
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
191
+
192
+ assert.equal(
193
+ deployResult['testInstance/_ParentBU_']?.dataExtension
194
+ ? Object.keys(deployResult['testInstance/_ParentBU_']?.dataExtension).length
195
+ : 0,
196
+ 2,
197
+ 'two dataExtensions to be deployed'
198
+ );
199
+
200
+ // get results from cache
201
+ const result = cache.getCache();
202
+ assert.equal(
203
+ result.dataExtension ? Object.keys(result.dataExtension).length : 0,
204
+ 2,
205
+ 'two dataExtensions expected'
206
+ );
207
+ // insert
208
+ assert.deepEqual(
209
+ await testUtils.getActualJson(
210
+ 'testNew_dataExtensionShared',
211
+ 'dataExtension',
212
+ '_ParentBU_'
213
+ ),
214
+ await testUtils.getExpectedJson('1111111', 'dataExtension', 'create'),
215
+ 'returned metadata was not equal expected for create'
216
+ );
217
+ // update
218
+ assert.deepEqual(
219
+ await testUtils.getActualJson(
220
+ 'testExisting_dataExtensionShared',
221
+ 'dataExtension',
222
+ '_ParentBU_'
223
+ ),
224
+ await testUtils.getExpectedJson('1111111', 'dataExtension', 'update'),
225
+ 'returned metadata was not equal expected for update'
226
+ );
227
+ assert.equal(
228
+ testUtils.getAPIHistoryLength(),
229
+ 12,
230
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
231
+ );
232
+ return;
233
+ });
91
234
  });
92
235
  describe('Templating ================', () => {
93
236
  it('Should create a dataExtension template via retrieveAsTemplate and build it', async () => {
@@ -194,47 +337,60 @@ describe('type: dataExtension', () => {
194
337
  });
195
338
  });
196
339
  describe('Delete ================', () => {
197
- // TODO: add this test
198
- it('Should delete the item'); // , async () => {
199
- // // WHEN
200
- // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
201
- // 'testExisting_keyword',
202
- // ]);
203
- // // THEN
204
- // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
205
-
206
- // assert.equal(result, true, 'should have deleted the item');
207
- // return;
208
- // });
340
+ it('Should delete the dataExtension', async () => {
341
+ // WHEN
342
+ const isDeleted = await handler.deleteByKey(
343
+ 'testInstance/testBU',
344
+ 'dataExtension',
345
+ 'testExisting_dataExtension'
346
+ );
347
+ // THEN
348
+ assert.equal(process.exitCode, false, 'delete should not have thrown an error');
349
+
350
+ assert.equal(isDeleted, true, 'should have deleted the item');
351
+ return;
352
+ });
353
+ it('Should delete the dataExtensionField', async () => {
354
+ // WHEN
355
+ const isDeleted = await handler.deleteByKey(
356
+ 'testInstance/testBU',
357
+ 'dataExtensionField',
358
+ 'testExisting_dataExtension.LastName'
359
+ );
360
+ // THEN
361
+ assert.equal(process.exitCode, false, 'delete should not have thrown an error');
362
+
363
+ assert.equal(isDeleted, true, 'should have deleted the item');
364
+ return;
365
+ });
209
366
  });
210
367
  describe('CI/CD ================', () => {
211
- // TODO: add this test
212
- it('Should return a list of files based on their type and key'); // , async () => {
213
- // // WHEN
214
- // const fileList = await handler.getFilesToCommit(
215
- // 'testInstance/testBU',
216
- // 'mobileKeyword',
217
- // ['testExisting_keyword']
218
- // );
219
- // // THEN
220
- // assert.equal(
221
- // process.exitCode,
222
- // false,
223
- // 'getFilesToCommit should not have thrown an error'
224
- // );
225
- // assert.equal(fileList.length, 2, 'expected only 2 file paths');
226
-
227
- // assert.equal(
228
- // fileList[0].split('\\').join('/'),
229
- // 'retrieve/testInstance/testBU/mobileKeyword/testExisting_keyword.mobileKeyword-meta.json',
230
- // 'wrong JSON path'
231
- // );
232
- // assert.equal(
233
- // fileList[1].split('\\').join('/'),
234
- // 'retrieve/testInstance/testBU/mobileKeyword/testExisting_keyword.mobileKeyword-meta.amp',
235
- // 'wrong AMP path'
236
- // );
237
- // return;
238
- // });
368
+ it('Should return a list of files based on their type and key', async () => {
369
+ // WHEN
370
+ const fileList = await handler.getFilesToCommit(
371
+ 'testInstance/testBU',
372
+ 'dataExtension',
373
+ ['testExisting_dataExtension']
374
+ );
375
+ // THEN
376
+ assert.equal(
377
+ process.exitCode,
378
+ false,
379
+ 'getFilesToCommit should not have thrown an error'
380
+ );
381
+ assert.equal(fileList.length, 2, 'expected only 2 file paths (json, md)');
382
+
383
+ assert.equal(
384
+ fileList[0].split('\\').join('/'),
385
+ 'retrieve/testInstance/testBU/dataExtension/testExisting_dataExtension.dataExtension-meta.json',
386
+ 'wrong JSON path'
387
+ );
388
+ assert.equal(
389
+ fileList[1].split('\\').join('/'),
390
+ 'retrieve/testInstance/testBU/dataExtension/testExisting_dataExtension.dataExtension-doc.md',
391
+ 'wrong MD path'
392
+ );
393
+ return;
394
+ });
239
395
  });
240
396
  });
@@ -1,10 +1,9 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
1
+ import chai, { assert } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import cache from '../lib/util/cache.js';
4
+ import * as testUtils from './utils.js';
5
+ import handler from '../lib/index.js';
4
6
  chai.use(chaiFiles);
5
- const cache = require('../lib/util/cache');
6
- const testUtils = require('./utils');
7
- const handler = require('../lib/index');
8
7
 
9
8
  describe('type: dataExtract', () => {
10
9
  beforeEach(() => {
@@ -172,15 +171,22 @@ describe('type: dataExtract', () => {
172
171
  describe('Delete ================', () => {
173
172
  it('Should NOT delete the item', async () => {
174
173
  // WHEN
175
- await handler.deleteByKey('testInstance/testBU', 'dataExtract', [
176
- 'testExisting_fileTranfer',
177
- ]);
174
+ const isDeleted = await handler.deleteByKey(
175
+ 'testInstance/testBU',
176
+ 'dataExtract',
177
+ 'testExisting_fileTranfer'
178
+ );
178
179
  // THEN
179
180
  assert.equal(
180
181
  process.exitCode,
181
182
  1,
182
183
  'deleteByKey should have thrown an error due to lack of support'
183
184
  );
185
+ assert.equal(
186
+ isDeleted,
187
+ false,
188
+ 'deleteByKey should have returned false due to lack of support'
189
+ );
184
190
  return;
185
191
  });
186
192
  });
@@ -1,10 +1,9 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
1
+ import chai, { assert } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import cache from '../lib/util/cache.js';
4
+ import * as testUtils from './utils.js';
5
+ import handler from '../lib/index.js';
4
6
  chai.use(chaiFiles);
5
- const cache = require('../lib/util/cache');
6
- const testUtils = require('./utils');
7
- const handler = require('../lib/index');
8
7
 
9
8
  describe('type: fileTransfer', () => {
10
9
  beforeEach(() => {
@@ -170,15 +169,22 @@ describe('type: fileTransfer', () => {
170
169
  describe('Delete ================', () => {
171
170
  it('Should NOT delete the item', async () => {
172
171
  // WHEN
173
- await handler.deleteByKey('testInstance/testBU', 'fileTransfer', [
174
- 'testExisting_fileTranfer',
175
- ]);
172
+ const isDeleted = await handler.deleteByKey(
173
+ 'testInstance/testBU',
174
+ 'fileTransfer',
175
+ 'testExisting_fileTranfer'
176
+ );
176
177
  // THEN
177
178
  assert.equal(
178
179
  process.exitCode,
179
180
  1,
180
181
  'deleteByKey should have thrown an error due to lack of support'
181
182
  );
183
+ assert.equal(
184
+ isDeleted,
185
+ false,
186
+ 'deleteByKey should have returned false due to lack of support'
187
+ );
182
188
  return;
183
189
  });
184
190
  });
@@ -1,10 +1,9 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
1
+ import chai, { assert } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import cache from '../lib/util/cache.js';
4
+ import * as testUtils from './utils.js';
5
+ import handler from '../lib/index.js';
4
6
  chai.use(chaiFiles);
5
- const cache = require('../lib/util/cache');
6
- const testUtils = require('./utils');
7
- const handler = require('../lib/index');
8
7
 
9
8
  describe('type: importFile', () => {
10
9
  beforeEach(() => {
@@ -171,15 +170,22 @@ describe('type: importFile', () => {
171
170
  describe('Delete ================', () => {
172
171
  it('Should NOT delete the item', async () => {
173
172
  // WHEN
174
- await handler.deleteByKey('testInstance/testBU', 'importFile', [
175
- 'testExisting_fileTranfer',
176
- ]);
173
+ const isDeleted = await handler.deleteByKey(
174
+ 'testInstance/testBU',
175
+ 'importFile',
176
+ 'testExisting_fileTranfer'
177
+ );
177
178
  // THEN
178
179
  assert.equal(
179
180
  process.exitCode,
180
181
  1,
181
182
  'deleteByKey should have thrown an error due to lack of support'
182
183
  );
184
+ assert.equal(
185
+ isDeleted,
186
+ false,
187
+ 'deleteByKey should have returned false due to lack of support'
188
+ );
183
189
  return;
184
190
  });
185
191
  });