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,9 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const File = require('./file');
4
- const path = require('node:path');
5
- const Util = require('./util');
6
- const semver = require('semver');
3
+ import File from './file.js';
4
+ import path from 'node:path';
5
+ import { Util } from './util.js';
6
+ import semver from 'semver';
7
+ import { fileURLToPath } from 'node:url';
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
9
 
8
10
  /**
9
11
  * CLI helper class
@@ -154,4 +156,4 @@ const Init = {
154
156
  },
155
157
  };
156
158
 
157
- module.exports = Init;
159
+ export default Init;
package/lib/util/util.js CHANGED
@@ -1,17 +1,21 @@
1
1
  'use strict';
2
2
 
3
- const TYPE = require('../../types/mcdev.d');
4
- const MetadataDefinitions = require('./../MetadataTypeDefinitions');
5
- const packageJsonMcdev = require('../../package.json');
6
- const child_process = require('node:child_process');
7
- const process = require('node:process');
8
- const toposort = require('toposort');
9
- const winston = require('winston');
3
+ import TYPE from '../../types/mcdev.d.js';
4
+ import MetadataDefinitions from './../MetadataTypeDefinitions.js';
5
+ import process from 'node:process';
6
+ import toposort from 'toposort';
7
+ import winston from 'winston';
8
+ import child_process from 'node:child_process';
9
+ import path from 'node:path';
10
+ // import just to resolve cyclical - TO DO consider if could move to file or context
11
+ import { readJsonSync } from 'fs-extra/esm';
12
+ import { fileURLToPath } from 'node:url';
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
14
 
11
15
  /**
12
16
  * Util that contains logger and simple util methods
13
17
  */
14
- const Util = {
18
+ export const Util = {
15
19
  authFileName: '.mcdev-auth.json',
16
20
  boilerplateDirectory: '../../boilerplate',
17
21
  configFileName: '.mcdevrc.json',
@@ -19,7 +23,7 @@ const Util = {
19
23
  standardizedSplitChar: '/',
20
24
  /** @type {TYPE.skipInteraction} */
21
25
  skipInteraction: false,
22
- packageJsonMcdev: packageJsonMcdev,
26
+ packageJsonMcdev: readJsonSync(path.join(__dirname, '../../package.json')),
23
27
  OPTIONS: {},
24
28
  changedKeysMap: {},
25
29
  /**
@@ -390,7 +394,7 @@ const Util = {
390
394
 
391
395
  const processArgv = process.argv.slice(2);
392
396
  Util.logger.debug(
393
- `:: mcdev ${packageJsonMcdev.version} :: ⚡ mcdev ${processArgv.join(' ')}`
397
+ `:: mcdev ${Util.packageJsonMcdev.version} :: ⚡ mcdev ${processArgv.join(' ')}`
394
398
  );
395
399
  },
396
400
  /**
@@ -891,5 +895,3 @@ const Util = {
891
895
  };
892
896
 
893
897
  Util.startLogger(false, true);
894
-
895
- module.exports = Util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcdev",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "Accenture Salesforce Marketing Cloud DevTools",
5
5
  "author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/Accenture/sfmc-devtools.git"
10
10
  },
11
- "homepage": "https://github.com/Accenture/sfmc-devtools#readme",
11
+ "homepage": "https://github.com/Accenture/sfmc-devtools/wiki",
12
12
  "bugs": {
13
13
  "url": "https://github.com/Accenture/sfmc-devtools/issues",
14
14
  "email": "joern.berkefeld@accenture.com"
@@ -31,11 +31,17 @@
31
31
  "rest"
32
32
  ],
33
33
  "main": "./lib/index.js",
34
+ "exports": {
35
+ ".": {
36
+ "default": "./lib/index.js"
37
+ },
38
+ "./*": "./*.js"
39
+ },
34
40
  "bin": {
35
41
  "mcdev": "./lib/cli.js"
36
42
  },
37
43
  "engines": {
38
- "node": ">=15.0.0"
44
+ "node": ">=18.16.0"
39
45
  },
40
46
  "scripts": {
41
47
  "start": "node lib/cli.js",
@@ -48,58 +54,56 @@
48
54
  "lint-lib": "eslint lib/**/*.js",
49
55
  "lint-type": "eslint types/*.js",
50
56
  "lint-test": "eslint test/**/*.js",
51
- "upgrade": "npm-check --update",
52
57
  "manual-prepare": "husky install",
53
58
  "lint-and-test": "run-s lint test",
54
59
  "test": "mocha --reporter-option maxDiffSize=25000",
55
- "coverage": "nyc npm run test",
60
+ "coverage": "c8 npm run test",
56
61
  "version:major": "npm version --no-commit-hooks major",
57
62
  "version:minor": "npm version --no-commit-hooks minor",
58
63
  "version:patch": "npm version --no-commit-hooks patch"
59
64
  },
60
65
  "dependencies": {
61
66
  "beauty-amp-core": "0.3.7",
62
- "cli-progress": "3.11.2",
67
+ "cli-progress": "3.12.0",
63
68
  "command-exists": "1.2.9",
64
- "conf": "10.2.0",
69
+ "conf": "11.0.1",
65
70
  "console.table": "0.10.0",
66
71
  "deep-equal": "2.2.2",
67
- "fs-extra": "11.1.0",
68
- "inquirer": "8.2.5",
72
+ "fs-extra": "11.1.1",
73
+ "inquirer": "9.2.6",
69
74
  "json-to-table": "4.2.1",
70
75
  "mustache": "4.2.0",
71
- "p-limit": "3.1.0",
72
- "prettier": "2.8.8",
73
- "prettier-plugin-sql": "0.14.0",
76
+ "p-limit": "4.0.0",
77
+ "prettier": "3.0.3",
78
+ "prettier-plugin-sql": "0.15.1",
74
79
  "semver": "7.5.4",
75
- "sfmc-sdk": "1.0.1",
76
- "simple-git": "3.18.0",
80
+ "sfmc-sdk": "2.0.1",
81
+ "simple-git": "3.20.0",
77
82
  "toposort": "2.0.2",
78
- "update-notifier": "5.1.0",
83
+ "update-notifier": "6.0.2",
79
84
  "winston": "3.10.0",
80
85
  "yargs": "17.7.2"
81
86
  },
82
87
  "devDependencies": {
83
- "assert": "2.0.0",
84
- "axios-mock-adapter": "1.21.5",
85
- "chai": "4.3.7",
88
+ "assert": "2.1.0",
89
+ "axios-mock-adapter": "1.22.0",
90
+ "c8": "8.0.1",
91
+ "chai": "4.3.10",
86
92
  "chai-files": "1.4.0",
87
- "eslint": "8.46.0",
93
+ "eslint": "8.50.0",
88
94
  "eslint-config-prettier": "9.0.0",
89
95
  "eslint-config-ssjs": "1.1.11",
90
- "eslint-plugin-jsdoc": "46.4.6",
91
- "eslint-plugin-mocha": "10.1.0",
92
- "eslint-plugin-prettier": "4.2.1",
96
+ "eslint-plugin-jsdoc": "46.8.2",
97
+ "eslint-plugin-mocha": "10.2.0",
98
+ "eslint-plugin-prettier": "5.0.0",
93
99
  "eslint-plugin-unicorn": "48.0.0",
94
- "fast-xml-parser": "4.2.7",
100
+ "fast-xml-parser": "4.3.2",
95
101
  "husky": "8.0.3",
96
102
  "jsdoc-to-markdown": "8.0.0",
97
- "lint-staged": "13.2.3",
103
+ "lint-staged": "14.0.1",
98
104
  "mocha": "10.2.0",
99
105
  "mock-fs": "5.2.0",
100
- "npm-check": "6.0.1",
101
106
  "npm-run-all": "4.1.5",
102
- "nyc": "15.1.0",
103
107
  "prettier-eslint": "15.0.1"
104
108
  },
105
109
  "optionalDependencies": {
@@ -109,5 +113,6 @@
109
113
  "*.{js,jsx,ts,tsx}": [
110
114
  "eslint --fix"
111
115
  ]
112
- }
116
+ },
117
+ "type": "module"
113
118
  }
@@ -1,10 +1,8 @@
1
- const chai = require('chai');
2
- const chaiFiles = require('chai-files');
3
- const assert = chai.assert;
4
- const expect = chai.expect;
1
+ import chai, { assert, expect } from 'chai';
2
+ import chaiFiles from 'chai-files';
3
+ import * as testUtils from './utils.js';
4
+ import handler from '../lib/index.js';
5
5
  chai.use(chaiFiles);
6
- const testUtils = require('./utils');
7
- const handler = require('../lib/index');
8
6
 
9
7
  describe('GENERAL', () => {
10
8
  beforeEach(() => {
@@ -78,5 +78,5 @@
78
78
  "triggeredSend"
79
79
  ]
80
80
  },
81
- "version": "5.2.0"
81
+ "version": "6.0.0"
82
82
  }
@@ -0,0 +1,59 @@
1
+ {
2
+ "CustomerKey": "testExisting_dataExtensionShared",
3
+ "Name": "testExisting_dataExtensionShared",
4
+ "Description": "Container for my test emails",
5
+ "IsSendable": true,
6
+ "IsTestable": true,
7
+ "SendableDataExtensionField": { "Name": "ContactKey" },
8
+ "SendableSubscriberField": { "Name": "Subscriber Key" },
9
+ "DataRetentionPeriodLength": 6,
10
+ "DataRetentionPeriodUnitOfMeasure": 5,
11
+ "RowBasedRetention": true,
12
+ "ResetRetentionPeriodOnImport": false,
13
+ "DeleteAtEndOfRetentionPeriod": false,
14
+ "RetainUntil": "",
15
+ "Fields": [
16
+ {
17
+ "Name": "FirstName",
18
+ "DefaultValue": "",
19
+ "MaxLength": 50,
20
+ "IsRequired": false,
21
+ "IsPrimaryKey": false,
22
+ "FieldType": "Text"
23
+ },
24
+ {
25
+ "Name": "LastName",
26
+ "DefaultValue": "",
27
+ "MaxLength": 55,
28
+ "IsRequired": false,
29
+ "IsPrimaryKey": false,
30
+ "FieldType": "Text"
31
+ },
32
+ {
33
+ "Name": "EmailAddress",
34
+ "DefaultValue": "",
35
+ "MaxLength": 254,
36
+ "IsRequired": true,
37
+ "IsPrimaryKey": false,
38
+ "FieldType": "EmailAddress"
39
+ },
40
+ {
41
+ "Name": "newField",
42
+ "DefaultValue": "",
43
+ "MaxLength": 254,
44
+ "IsRequired": false,
45
+ "IsPrimaryKey": false,
46
+ "FieldType": "Text"
47
+ },
48
+ {
49
+ "Name": "ContactKey",
50
+ "DefaultValue": "",
51
+ "MaxLength": 50,
52
+ "IsRequired": true,
53
+ "IsPrimaryKey": true,
54
+ "FieldType": "Text"
55
+ }
56
+ ],
57
+ "r__folder_ContentType": "shared_dataextension",
58
+ "r__folder_Path": "Shared Items/Shared Data Extensions"
59
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "CustomerKey": "testNew_dataExtensionShared",
3
+ "Name": "testNew_dataExtensionShared",
4
+ "Description": "",
5
+ "IsSendable": false,
6
+ "IsTestable": false,
7
+ "RowBasedRetention": false,
8
+ "ResetRetentionPeriodOnImport": false,
9
+ "DeleteAtEndOfRetentionPeriod": false,
10
+ "RetainUntil": "",
11
+ "Fields": [
12
+ {
13
+ "Name": "testField",
14
+ "DefaultValue": "",
15
+ "MaxLength": 254,
16
+ "IsRequired": true,
17
+ "IsPrimaryKey": false,
18
+ "FieldType": "Text"
19
+ }
20
+ ],
21
+ "r__folder_ContentType": "shared_dataextension",
22
+ "r__folder_Path": "Shared Items/Shared Data Extensions"
23
+ }
@@ -36,6 +36,10 @@
36
36
  {
37
37
  "name": "testExisting_script",
38
38
  "r__type": "script"
39
+ },
40
+ {
41
+ "name": "testNew_39f6a488-20eb-4ba0-b0b9",
42
+ "r__type": "verification"
39
43
  }
40
44
  ],
41
45
  "name": ""
@@ -31,6 +31,7 @@
31
31
  },
32
32
  {
33
33
  "Name": "EmailAddress",
34
+ "Name_new": "Email",
34
35
  "DefaultValue": "",
35
36
  "MaxLength": 254,
36
37
  "IsRequired": true,
@@ -6,9 +6,6 @@
6
6
  "status": "Active",
7
7
  "createdDate": "2020-09-10T03:29:00",
8
8
  "modifiedDate": "2020-09-10T03:29:00",
9
- "content": {
10
- "customerKey": "testExisting_asset_message"
11
- },
12
9
  "subscriptions": {
13
10
  "dataExtension": "testExisting_dataExtension",
14
11
  "autoAddSubscriber": true,
@@ -17,5 +14,7 @@
17
14
  },
18
15
  "options": {
19
16
  "trackLinks": true
20
- }
17
+ },
18
+ "r__journey_key": "testExisting_interaction",
19
+ "r__asset_customerKey": "testExisting_asset_message"
21
20
  }
@@ -6,9 +6,6 @@
6
6
  "status": "Active",
7
7
  "createdDate": "2020-09-10T03:29:00",
8
8
  "modifiedDate": "2020-09-10T03:29:00",
9
- "content": {
10
- "customerKey": "testExisting_asset_message"
11
- },
12
9
  "subscriptions": {
13
10
  "dataExtension": "testExisting_dataExtension",
14
11
  "autoAddSubscriber": true,
@@ -18,7 +15,5 @@
18
15
  "options": {
19
16
  "trackLinks": true
20
17
  },
21
- "journey": {
22
- "interactionKey": "testExisting_interaction"
23
- }
18
+ "r__asset_customerKey": "testExisting_asset_message"
24
19
  }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dataVerificationDefinitionId": "testExisting_39f6a488-20eb-4ba0-b0b9",
3
+ "notificationEmailAddress": "test@accenture.com",
4
+ "notificationEmailMessage": "",
5
+ "r__dataExtension_CustomerKey": "testExisting_dataExtension",
6
+ "shouldEmailOnFailure": true,
7
+ "shouldStopOnFailure": true,
8
+ "value1": 1,
9
+ "value2": 0,
10
+ "verificationType": "IsEqualTo"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dataVerificationDefinitionId": "testNew_39f6a488-20eb-4ba0-b0b9",
3
+ "notificationEmailAddress": "",
4
+ "notificationEmailMessage": "",
5
+ "r__dataExtension_CustomerKey": "testExisting_dataExtension",
6
+ "shouldEmailOnFailure": false,
7
+ "shouldStopOnFailure": false,
8
+ "value1": 2,
9
+ "value2": 0,
10
+ "verificationType": "IsEqualTo"
11
+ }
@@ -1,7 +1,7 @@
1
- const fs = require('fs-extra');
2
- const path = require('node:path');
3
- const { XMLParser } = require('fast-xml-parser');
4
- const Util = require('../lib/util/util');
1
+ import fs from 'fs-extra';
2
+ import path from 'node:path';
3
+ import { XMLParser } from 'fast-xml-parser';
4
+ import { Util } from '../lib/util/util.js';
5
5
  const parser = new XMLParser();
6
6
  const attributeParser = new XMLParser({ ignoreAttributes: false });
7
7
  let color;
@@ -40,11 +40,10 @@ if (
40
40
  * @param {object|string} filter likely for customer key
41
41
  * @returns {string} relevant metadata stringified
42
42
  */
43
- exports.loadSOAPRecords = async (mcdevAction, type, mid, filter) => {
43
+ async function loadSOAPRecords(mcdevAction, type, mid, filter) {
44
44
  type = type[0].toLowerCase() + type.slice(1);
45
45
  const testPath = path.join('test', 'resources', mid.toString(), type, mcdevAction);
46
- const filterPath =
47
- typeof filter === 'string' && filter ? '-' + filter : this.filterToPath(filter);
46
+ const filterPath = typeof filter === 'string' && filter ? '-' + filter : filterToPath(filter);
48
47
  if (await fs.pathExists(testPath + filterPath + '-response.xml')) {
49
48
  return fs.readFile(testPath + filterPath + '-response.xml', {
50
49
  encoding: 'utf8',
@@ -80,42 +79,66 @@ exports.loadSOAPRecords = async (mcdevAction, type, mid, filter) => {
80
79
  return fs.readFile(path.join('test', 'resources', mcdevAction + '-response.xml'), {
81
80
  encoding: 'utf8',
82
81
  });
83
- };
84
- exports.filterToPath = (filter) => {
82
+ }
83
+ /**
84
+ * main filter to path function
85
+ *
86
+ * @param {object} filter main filter object
87
+ * @param {string} filter.Property field name
88
+ * @param {string} filter.SimpleOperator string representation of the comparison method
89
+ * @param {string} filter.Value field value to check for
90
+ * @param {object} filter.LeftOperand contains a filter object itself
91
+ * @param {'AND'|'OR'} filter.LogicalOperator string representation of the comparison method
92
+ * @param {object} filter.RightOperand field value to check for
93
+ * @returns {string} string represenation of the entire filter
94
+ */
95
+ export function filterToPath(filter) {
85
96
  if (filter) {
86
- return '-' + this._filterToPath(filter);
97
+ return '-' + _filterToPath(filter);
87
98
  }
88
99
  return '';
89
- };
90
- exports._filterToPath = (filter) => {
100
+ }
101
+ /**
102
+ * helper for filterToPath
103
+ *
104
+ * @param {object} filter main filter object
105
+ * @param {string} filter.Property field name
106
+ * @param {string} filter.SimpleOperator string representation of the comparison method
107
+ * @param {string} filter.Value field value to check for
108
+ * @param {object} filter.LeftOperand contains a filter object itself
109
+ * @param {'AND'|'OR'} filter.LogicalOperator string representation of the comparison method
110
+ * @param {object} filter.RightOperand field value to check for
111
+ * @returns {string} string represenation of the entire filter
112
+ */
113
+ function _filterToPath(filter) {
91
114
  if (filter.Property && filter.SimpleOperator) {
92
115
  return `${filter.Property}${filter.SimpleOperator.replace('equals', '=')}${
93
116
  filter.Value === undefined ? '' : filter.Value
94
117
  }`;
95
118
  } else if (filter.LeftOperand && filter.LogicalOperator && filter.RightOperand) {
96
119
  return (
97
- this._filterToPath(filter.LeftOperand) +
120
+ _filterToPath(filter.LeftOperand) +
98
121
  filter.LogicalOperator +
99
- this._filterToPath(filter.RightOperand)
122
+ _filterToPath(filter.RightOperand)
100
123
  );
101
124
  } else {
102
125
  throw new Error('unknown filter type');
103
126
  }
104
- };
127
+ }
105
128
  /**
106
129
  * based on request, respond with different soap data
107
130
  *
108
131
  * @param {object} config mock api request object
109
132
  * @returns {Promise.<Array>} status code plus response in string form
110
133
  */
111
- exports.handleSOAPRequest = async (config) => {
134
+ export const handleSOAPRequest = async (config) => {
112
135
  const jObj = parser.parse(config.data);
113
136
  const fullObj = attributeParser.parse(config.data);
114
137
  let responseXML;
115
138
 
116
139
  switch (config.headers.SOAPAction) {
117
140
  case 'Retrieve': {
118
- responseXML = await this.loadSOAPRecords(
141
+ responseXML = await loadSOAPRecords(
119
142
  config.headers.SOAPAction.toLocaleLowerCase(),
120
143
  jObj.Envelope.Body.RetrieveRequestMsg.RetrieveRequest.ObjectType,
121
144
  jObj.Envelope.Header.fueloauth,
@@ -125,7 +148,7 @@ exports.handleSOAPRequest = async (config) => {
125
148
  break;
126
149
  }
127
150
  case 'Create': {
128
- responseXML = await this.loadSOAPRecords(
151
+ responseXML = await loadSOAPRecords(
129
152
  config.headers.SOAPAction.toLocaleLowerCase(),
130
153
  fullObj.Envelope.Body.CreateRequest.Objects['@_xsi:type'],
131
154
  jObj.Envelope.Header.fueloauth,
@@ -135,7 +158,7 @@ exports.handleSOAPRequest = async (config) => {
135
158
  break;
136
159
  }
137
160
  case 'Update': {
138
- responseXML = await this.loadSOAPRecords(
161
+ responseXML = await loadSOAPRecords(
139
162
  config.headers.SOAPAction.toLocaleLowerCase(),
140
163
  fullObj.Envelope.Body.UpdateRequest.Objects['@_xsi:type'],
141
164
  jObj.Envelope.Header.fueloauth,
@@ -145,7 +168,7 @@ exports.handleSOAPRequest = async (config) => {
145
168
  break;
146
169
  }
147
170
  case 'Configure': {
148
- responseXML = await this.loadSOAPRecords(
171
+ responseXML = await loadSOAPRecords(
149
172
  config.headers.SOAPAction.toLocaleLowerCase(),
150
173
  fullObj.Envelope.Body.ConfigureRequestMsg.Configurations.Configuration[0][
151
174
  '@_xsi:type'
@@ -157,7 +180,7 @@ exports.handleSOAPRequest = async (config) => {
157
180
  break;
158
181
  }
159
182
  case 'Delete': {
160
- responseXML = await this.loadSOAPRecords(
183
+ responseXML = await loadSOAPRecords(
161
184
  config.headers.SOAPAction.toLocaleLowerCase(),
162
185
  fullObj.Envelope.Body.DeleteRequest.Objects['@_xsi:type'],
163
186
  jObj.Envelope.Header.fueloauth,
@@ -167,7 +190,7 @@ exports.handleSOAPRequest = async (config) => {
167
190
  break;
168
191
  }
169
192
  case 'Schedule': {
170
- responseXML = await this.loadSOAPRecords(
193
+ responseXML = await loadSOAPRecords(
171
194
  config.headers.SOAPAction.toLocaleLowerCase(),
172
195
  fullObj.Envelope.Body.ScheduleRequestMsg.Interactions.Interaction['@_xsi:type'],
173
196
  jObj.Envelope.Header.fueloauth,
@@ -177,7 +200,7 @@ exports.handleSOAPRequest = async (config) => {
177
200
  break;
178
201
  }
179
202
  case 'Perform': {
180
- responseXML = await this.loadSOAPRecords(
203
+ responseXML = await loadSOAPRecords(
181
204
  config.headers.SOAPAction.toLocaleLowerCase(),
182
205
  fullObj.Envelope.Body.PerformRequestMsg.Definitions.Definition['@_xsi:type'],
183
206
  jObj.Envelope.Header.fueloauth,
@@ -195,12 +218,14 @@ exports.handleSOAPRequest = async (config) => {
195
218
 
196
219
  return [200, responseXML];
197
220
  };
221
+
198
222
  /**
199
223
  * helper to return soap base URL
200
224
  *
201
225
  * @returns {string} soap URL
202
226
  */
203
- exports.soapUrl = 'https://mct0l7nxfq2r988t1kxfy8sc4xxx.soap.marketingcloudapis.com/Service.asmx';
227
+ export const soapUrl =
228
+ 'https://mct0l7nxfq2r988t1kxfy8sc4xxx.soap.marketingcloudapis.com/Service.asmx';
204
229
 
205
230
  /**
206
231
  * based on request, respond with different soap data
@@ -208,7 +233,7 @@ exports.soapUrl = 'https://mct0l7nxfq2r988t1kxfy8sc4xxx.soap.marketingcloudapis.
208
233
  * @param {object} config mock api request object
209
234
  * @returns {Promise.<Array>} status code plus response in string form
210
235
  */
211
- exports.handleRESTRequest = async (config) => {
236
+ export const handleRESTRequest = async (config) => {
212
237
  try {
213
238
  // check if filtered
214
239
  const urlObj = new URL(config.baseURL + config.url.slice(1));
@@ -271,9 +296,10 @@ exports.handleRESTRequest = async (config) => {
271
296
  return [500, {}];
272
297
  }
273
298
  };
299
+
274
300
  /**
275
301
  * helper to return rest base URL
276
302
  *
277
303
  * @returns {string} test URL
278
304
  */
279
- exports.restUrl = 'https://mct0l7nxfq2r988t1kxfy8sc4xxx.rest.marketingcloudapis.com/';
305
+ export const restUrl = 'https://mct0l7nxfq2r988t1kxfy8sc4xxx.rest.marketingcloudapis.com/';
@@ -0,0 +1,13 @@
1
+ {
2
+ "links": {
3
+ "self": "/v1/customobjectdata/token/ea0a44dc-b679-4d7d-8b77-e5d3f106e854/rowset?$page=1"
4
+ },
5
+ "requestToken": "ea0a44dc-b679-4d7d-8b77-e5d3f106e854",
6
+ "tokenExpireDateUtc": "2023-01-26T13:54:59.883",
7
+ "customObjectId": "30400c03-0ec4-ec11-b83c-48df37d1de8b",
8
+ "customObjectKey": "testExisting_dataExtensionShared",
9
+ "pageSize": 1,
10
+ "page": 1,
11
+ "count": 0,
12
+ "top": 0
13
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "CustomerKey": "testNew_dataExtensionShared",
3
+ "DeleteAtEndOfRetentionPeriod": false,
4
+ "Description": "",
5
+ "Fields": [
6
+ {
7
+ "DefaultValue": "",
8
+ "FieldType": "Text",
9
+ "IsPrimaryKey": false,
10
+ "IsRequired": true,
11
+ "MaxLength": 254,
12
+ "Name": "testField"
13
+ }
14
+ ],
15
+ "IsSendable": false,
16
+ "IsTestable": false,
17
+ "Name": "testNew_dataExtensionShared",
18
+ "ResetRetentionPeriodOnImport": false,
19
+ "RetainUntil": "",
20
+ "RowBasedRetention": false,
21
+ "r__folder_ContentType": "shared_dataextension",
22
+ "r__folder_Path": "Shared Items/Shared Data Extensions"
23
+ }