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,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: journey', () => {
10
9
  beforeEach(() => {
@@ -141,17 +140,44 @@ describe('type: journey', () => {
141
140
  });
142
141
  });
143
142
  describe('Delete ================', () => {
144
- // TODO: add this test
145
- it('Should delete the item'); // , async () => {
146
- // // WHEN
147
- // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
148
- // 'testExisting_keyword',
149
- // ]);
150
- // // THEN
151
- // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
143
+ it('Should NOT delete the item due to missing version', async () => {
144
+ // WHEN
145
+ const isDeleted = await handler.deleteByKey(
146
+ 'testInstance/testBU',
147
+ 'journey',
148
+ 'testExisting_interaction'
149
+ );
150
+ // THEN
151
+ assert.equal(process.exitCode, true, 'delete should have thrown an error');
152
152
 
153
- // assert.equal(result, true, 'should have deleted the item');
154
- // return;
155
- // });
153
+ assert.equal(isDeleted, false, 'should not have deleted the item');
154
+ return;
155
+ });
156
+ it('Should NOT delete the item due to unknown version', async () => {
157
+ // WHEN
158
+ const isDeleted = await handler.deleteByKey(
159
+ 'testInstance/testBU',
160
+ 'journey',
161
+ 'testExisting_interaction/2'
162
+ );
163
+ // THEN
164
+ assert.equal(process.exitCode, true, 'delete should have thrown an error');
165
+
166
+ assert.equal(isDeleted, false, 'should not have deleted the item');
167
+ return;
168
+ });
169
+ it('Should delete the item with version', async () => {
170
+ // WHEN
171
+ const isDeleted = await handler.deleteByKey(
172
+ 'testInstance/testBU',
173
+ 'journey',
174
+ 'testExisting_interaction/1'
175
+ );
176
+ // THEN
177
+ assert.equal(process.exitCode, false, 'delete should not have thrown an error');
178
+
179
+ assert.equal(isDeleted, true, 'should have deleted the item');
180
+ return;
181
+ });
156
182
  });
157
183
  });
@@ -1,12 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
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
- const expect = chai.expect;
6
7
  const file = chaiFiles.file;
7
- const cache = require('../lib/util/cache');
8
- const testUtils = require('./utils');
9
- const handler = require('../lib/index');
10
8
 
11
9
  describe('type: mobileKeyword', () => {
12
10
  beforeEach(() => {
@@ -245,13 +243,15 @@ describe('type: mobileKeyword', () => {
245
243
  describe('Delete ================', () => {
246
244
  it('Should delete the item', async () => {
247
245
  // WHEN
248
- const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
249
- '4912312345678.TESTEXISTING_KEYWORD',
250
- ]);
246
+ const isDeleted = await handler.deleteByKey(
247
+ 'testInstance/testBU',
248
+ 'mobileKeyword',
249
+ '4912312345678.TESTEXISTING_KEYWORD'
250
+ );
251
251
  // THEN
252
252
  assert.equal(process.exitCode, false, 'delete should not have thrown an error');
253
253
 
254
- assert.equal(result, true, 'should have deleted the item');
254
+ assert.equal(isDeleted, true, 'should have deleted the item');
255
255
  return;
256
256
  });
257
257
  });
@@ -1,12 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
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
- const expect = chai.expect;
6
7
  const file = chaiFiles.file;
7
- const cache = require('../lib/util/cache');
8
- const testUtils = require('./utils');
9
- const handler = require('../lib/index');
10
8
 
11
9
  describe('type: mobileMessage', () => {
12
10
  beforeEach(() => {
@@ -163,13 +161,15 @@ describe('type: mobileMessage', () => {
163
161
  describe('Delete ================', () => {
164
162
  it('Should delete the item', async () => {
165
163
  // WHEN
166
- const result = await handler.deleteByKey('testInstance/testBU', 'mobileMessage', [
167
- 'NTIzOjc4OjA',
168
- ]);
164
+ const isDeleted = await handler.deleteByKey(
165
+ 'testInstance/testBU',
166
+ 'mobileMessage',
167
+ 'NTIzOjc4OjA'
168
+ );
169
169
  // THEN
170
170
  assert.equal(process.exitCode, false, 'delete should not have thrown an error');
171
171
 
172
- assert.equal(result, true, 'should have deleted the item');
172
+ assert.equal(isDeleted, true, 'should have deleted the item');
173
173
  return;
174
174
  });
175
175
  });
@@ -1,13 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
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
- const expect = chai.expect;
6
7
  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
8
 
12
9
  describe('type: query', () => {
13
10
  beforeEach(() => {
@@ -458,7 +455,7 @@ describe('type: query', () => {
458
455
  // check number of API calls
459
456
  assert.equal(
460
457
  testUtils.getAPIHistoryLength(),
461
- 33,
458
+ 34,
462
459
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
463
460
  );
464
461
  return;
@@ -498,7 +495,7 @@ describe('type: query', () => {
498
495
  // check number of API calls
499
496
  assert.equal(
500
497
  testUtils.getAPIHistoryLength(),
501
- 35,
498
+ 36,
502
499
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
503
500
  );
504
501
  return;
@@ -656,13 +653,15 @@ describe('type: query', () => {
656
653
  describe('Delete ================', () => {
657
654
  it('Should delete the item', async () => {
658
655
  // WHEN
659
- const result = await handler.deleteByKey('testInstance/testBU', 'query', [
660
- 'testExisting_query',
661
- ]);
656
+ const isDeleted = await handler.deleteByKey(
657
+ 'testInstance/testBU',
658
+ 'query',
659
+ 'testExisting_query'
660
+ );
662
661
  // THEN
663
662
  assert.equal(process.exitCode, false, 'delete should not have thrown an error');
664
663
 
665
- assert.equal(result, true, 'should have deleted the item');
664
+ assert.equal(isDeleted, true, 'should have deleted the item');
666
665
  return;
667
666
  });
668
667
  });
@@ -1,13 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
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
- const expect = chai.expect;
6
7
  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
8
 
12
9
  describe('type: script', () => {
13
10
  beforeEach(() => {
@@ -358,7 +355,12 @@ describe('type: script', () => {
358
355
  assert.equal(
359
356
  fileList[1].split('\\').join('/'),
360
357
  'retrieve/testInstance/testBU/script/testExisting_script.script-meta.ssjs',
361
- 'wrong JSON path'
358
+ 'wrong SSJS path'
359
+ );
360
+ assert.equal(
361
+ fileList[2].split('\\').join('/'),
362
+ 'retrieve/testInstance/testBU/script/testExisting_script.script-meta.html',
363
+ 'wrong HTML path'
362
364
  );
363
365
  return;
364
366
  });
@@ -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: transactionalEmail', () => {
10
9
  beforeEach(() => {
@@ -142,17 +141,18 @@ describe('type: transactionalEmail', () => {
142
141
  });
143
142
  });
144
143
  describe('Delete ================', () => {
145
- // TODO: add this test
146
- it('Should delete the item'); // , async () => {
147
- // // WHEN
148
- // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
149
- // 'testExisting_keyword',
150
- // ]);
151
- // // THEN
152
- // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
144
+ it('Should delete the item', async () => {
145
+ // WHEN
146
+ const isDeleted = await handler.deleteByKey(
147
+ 'testInstance/testBU',
148
+ 'transactionalEmail',
149
+ 'testExisting_temail'
150
+ );
151
+ // THEN
152
+ assert.equal(process.exitCode, false, 'delete should not have thrown an error');
153
153
 
154
- // assert.equal(result, true, 'should have deleted the item');
155
- // return;
156
- // });
154
+ assert.equal(isDeleted, true, 'should have deleted the item');
155
+ return;
156
+ });
157
157
  });
158
158
  });
@@ -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: transactionalPush', () => {
10
9
  beforeEach(() => {
@@ -146,13 +145,11 @@ describe('type: transactionalPush', () => {
146
145
  // TODO: add this test
147
146
  it('Should delete the item'); // , async () => {
148
147
  // // WHEN
149
- // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
150
- // 'testExisting_keyword',
151
- // ]);
148
+ // const isDeleted = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', 'testExisting_keyword');
152
149
  // // THEN
153
150
  // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
154
151
 
155
- // assert.equal(result, true, 'should have deleted the item');
152
+ // assert.equal(isDeleted, true, 'should have deleted the item');
156
153
  // return;
157
154
  // });
158
155
  });
@@ -1,12 +1,10 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
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
- const expect = chai.expect;
6
7
  const file = chaiFiles.file;
7
- const cache = require('../lib/util/cache');
8
- const testUtils = require('./utils');
9
- const handler = require('../lib/index');
10
8
 
11
9
  describe('type: transactionalSMS', () => {
12
10
  beforeEach(() => {
@@ -176,13 +174,11 @@ describe('type: transactionalSMS', () => {
176
174
  // TODO: add this test
177
175
  it('Should delete the item'); // , async () => {
178
176
  // // WHEN
179
- // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
180
- // 'testExisting_keyword',
181
- // ]);
177
+ // const isDeleted = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', 'testExisting_keyword');
182
178
  // // THEN
183
179
  // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
184
180
 
185
- // assert.equal(result, true, 'should have deleted the item');
181
+ // assert.equal(isDeleted, true, 'should have deleted the item');
186
182
  // return;
187
183
  // });
188
184
  });
@@ -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: triggeredSend', () => {
10
9
  beforeEach(() => {
@@ -130,13 +129,15 @@ describe('type: triggeredSend', () => {
130
129
  describe('Delete ================', () => {
131
130
  it('Should delete the item', async () => {
132
131
  // WHEN
133
- const result = await handler.deleteByKey('testInstance/testBU', 'triggeredSend', [
134
- 'testExisting_triggeredSend',
135
- ]);
132
+ const isDeleted = await handler.deleteByKey(
133
+ 'testInstance/testBU',
134
+ 'triggeredSend',
135
+ 'testExisting_triggeredSend'
136
+ );
136
137
  // THEN
137
138
  assert.equal(process.exitCode, false, 'delete should not have thrown an error');
138
139
 
139
- assert.equal(result, true, 'should have deleted the item');
140
+ assert.equal(isDeleted, true, 'should have deleted the item');
140
141
  return;
141
142
  });
142
143
  });
@@ -1,13 +1,11 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
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
- const expect = chai.expect;
6
7
  const file = chaiFiles.file;
7
- const cache = require('../lib/util/cache');
8
- const testUtils = require('./utils');
9
- const handler = require('../lib/index');
10
- const File = require('../lib/util/file');
8
+ import File from '../lib/util/file.js';
11
9
 
12
10
  describe('type: user', () => {
13
11
  beforeEach(() => {
@@ -0,0 +1,172 @@
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';
6
+ chai.use(chaiFiles);
7
+
8
+ describe('type: verification', () => {
9
+ beforeEach(() => {
10
+ testUtils.mockSetup();
11
+ });
12
+ afterEach(() => {
13
+ testUtils.mockReset();
14
+ });
15
+
16
+ describe('Retrieve ================', () => {
17
+ it('Should retrieve a verification', async () => {
18
+ // WHEN
19
+ const retrieved = await handler.retrieve('testInstance/testBU', ['verification']);
20
+ // THEN
21
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
22
+ // get results from cache
23
+ const result = cache.getCache();
24
+ assert.equal(
25
+ result.verification ? Object.keys(result.verification).length : 0,
26
+ 1,
27
+ 'only one verification expected'
28
+ );
29
+ assert.equal(
30
+ retrieved['testInstance/testBU']?.verification
31
+ ? Object.keys(retrieved['testInstance/testBU']?.verification).length
32
+ : 0,
33
+ 1,
34
+ 'one verifications to be retrieved'
35
+ );
36
+
37
+ assert.deepEqual(
38
+ await testUtils.getActualJson(
39
+ 'testExisting_39f6a488-20eb-4ba0-b0b9',
40
+ 'verification'
41
+ ),
42
+ await testUtils.getExpectedJson('9999999', 'verification', 'get'),
43
+ 'returned JSON was not equal expected'
44
+ );
45
+ assert.equal(
46
+ testUtils.getAPIHistoryLength(),
47
+ 9,
48
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
49
+ );
50
+ return;
51
+ });
52
+ });
53
+ describe('Deploy ================', () => {
54
+ beforeEach(() => {
55
+ testUtils.mockSetup(true);
56
+ });
57
+ it('Should create & upsert a verification', async () => {
58
+ // WHEN
59
+
60
+ const deployed = await handler.deploy('testInstance/testBU', ['verification']);
61
+ // THEN
62
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
63
+ // get results from cache
64
+ const result = cache.getCache();
65
+ assert.equal(
66
+ result.verification ? Object.keys(result.verification).length : 0,
67
+ 2,
68
+ 'two verifications expected'
69
+ );
70
+ assert.equal(
71
+ deployed['testInstance/testBU']?.verification
72
+ ? Object.keys(deployed['testInstance/testBU']?.verification).length
73
+ : 0,
74
+ 2,
75
+ 'two verifications to be deployed'
76
+ );
77
+ // confirm created item
78
+ assert.deepEqual(
79
+ await testUtils.getActualJson('testNew_RANDOM_NEW_GUID', 'verification'),
80
+ await testUtils.getExpectedJson('9999999', 'verification', 'post'),
81
+ 'returned new-JSON was not equal expected for insert verification'
82
+ );
83
+ // confirm updated item
84
+ assert.deepEqual(
85
+ await testUtils.getActualJson(
86
+ 'testExisting_39f6a488-20eb-4ba0-b0b9',
87
+ 'verification'
88
+ ),
89
+ await testUtils.getExpectedJson('9999999', 'verification', 'patch'),
90
+ 'returned existing-JSON was not equal expected for update verification'
91
+ );
92
+ // check number of API calls
93
+ assert.equal(
94
+ testUtils.getAPIHistoryLength(),
95
+ 11,
96
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
97
+ );
98
+ return;
99
+ });
100
+ });
101
+ describe('Templating ================', () => {
102
+ it('Should create a verification template via buildTemplate and build it', async () => {
103
+ // download first before we test buildTemplate
104
+ await handler.retrieve('testInstance/testBU', ['verification']);
105
+ // buildTemplate
106
+ const result = await handler.buildTemplate(
107
+ 'testInstance/testBU',
108
+ 'verification',
109
+ ['testExisting_39f6a488-20eb-4ba0-b0b9'],
110
+ 'testSourceMarket'
111
+ );
112
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
113
+ assert.equal(
114
+ result.verification ? Object.keys(result.verification).length : 0,
115
+ 1,
116
+ 'only one verification expected'
117
+ );
118
+ assert.deepEqual(
119
+ await testUtils.getActualTemplateJson(
120
+ 'testExisting_39f6a488-20eb-4ba0-b0b9',
121
+ 'verification'
122
+ ),
123
+ await testUtils.getExpectedJson('9999999', 'verification', 'template'),
124
+ 'returned template JSON was not equal expected'
125
+ );
126
+ // buildDefinition
127
+ await handler.buildDefinition(
128
+ 'testInstance/testBU',
129
+ 'verification',
130
+ 'testExisting_39f6a488-20eb-4ba0-b0b9',
131
+ 'testTargetMarket'
132
+ );
133
+ assert.equal(
134
+ process.exitCode,
135
+ false,
136
+ 'buildDefinition should not have thrown an error'
137
+ );
138
+ assert.deepEqual(
139
+ await testUtils.getActualDeployJson(
140
+ 'testTemplated_39f6a488-20eb-4ba0-b0b9',
141
+ 'verification'
142
+ ),
143
+ await testUtils.getExpectedJson('9999999', 'verification', 'build'),
144
+ 'returned deployment JSON was not equal expected'
145
+ );
146
+ assert.equal(
147
+ testUtils.getAPIHistoryLength(),
148
+ 9,
149
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
150
+ );
151
+ return;
152
+ });
153
+ });
154
+ describe('Delete ================', () => {
155
+ it('Should delete the item', async () => {
156
+ // WHEN
157
+ const isDeleted = await handler.deleteByKey(
158
+ 'testInstance/testBU',
159
+ 'verification',
160
+ 'testExisting_39f6a488-20eb-4ba0-b0b9'
161
+ );
162
+ // THEN
163
+ assert.equal(
164
+ process.exitCode,
165
+ 0,
166
+ 'deleteByKey should have thrown an error due to lack of support'
167
+ );
168
+ assert.equal(isDeleted, true, 'deleteByKey should have returned true for success');
169
+ return;
170
+ });
171
+ });
172
+ });