mcdev 5.3.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 (127) hide show
  1. package/.eslintrc.json +1 -1
  2. package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
  3. package/.github/workflows/code-test.yml +1 -1
  4. package/.github/workflows/coverage-base-update.yml +1 -1
  5. package/.github/workflows/coverage-develop-branch.yml +2 -2
  6. package/.github/workflows/coverage-main-branch.yml +2 -2
  7. package/.github/workflows/coverage.yml +2 -2
  8. package/.github/workflows/npm-publish.yml +2 -2
  9. package/.prettierrc +7 -0
  10. package/docs/dist/documentation.md +9 -494
  11. package/jsconfig.json +5 -1
  12. package/lib/Builder.js +8 -8
  13. package/lib/Deployer.js +10 -10
  14. package/lib/MetadataTypeDefinitions.js +73 -39
  15. package/lib/MetadataTypeInfo.js +72 -38
  16. package/lib/Retriever.js +8 -8
  17. package/lib/cli.js +6 -6
  18. package/lib/index.js +24 -17
  19. package/lib/metadataTypes/Asset.js +12 -10
  20. package/lib/metadataTypes/AttributeGroup.js +7 -6
  21. package/lib/metadataTypes/AttributeSet.js +8 -7
  22. package/lib/metadataTypes/Automation.js +8 -8
  23. package/lib/metadataTypes/Campaign.js +7 -6
  24. package/lib/metadataTypes/ContentArea.js +7 -6
  25. package/lib/metadataTypes/DataExtension.js +16 -16
  26. package/lib/metadataTypes/DataExtensionField.js +6 -5
  27. package/lib/metadataTypes/DataExtensionTemplate.js +5 -4
  28. package/lib/metadataTypes/DataExtract.js +8 -7
  29. package/lib/metadataTypes/DataExtractType.js +5 -4
  30. package/lib/metadataTypes/Discovery.js +6 -5
  31. package/lib/metadataTypes/Email.js +6 -5
  32. package/lib/metadataTypes/EmailSend.js +7 -6
  33. package/lib/metadataTypes/Event.js +8 -7
  34. package/lib/metadataTypes/FileLocation.js +5 -4
  35. package/lib/metadataTypes/FileTransfer.js +8 -7
  36. package/lib/metadataTypes/Filter.js +5 -4
  37. package/lib/metadataTypes/Folder.js +9 -8
  38. package/lib/metadataTypes/ImportFile.js +8 -7
  39. package/lib/metadataTypes/Journey.js +9 -8
  40. package/lib/metadataTypes/List.js +9 -8
  41. package/lib/metadataTypes/MetadataType.js +37 -29
  42. package/lib/metadataTypes/MobileCode.js +5 -4
  43. package/lib/metadataTypes/MobileKeyword.js +8 -7
  44. package/lib/metadataTypes/MobileMessage.js +8 -7
  45. package/lib/metadataTypes/Query.js +9 -8
  46. package/lib/metadataTypes/Role.js +8 -7
  47. package/lib/metadataTypes/Script.js +7 -6
  48. package/lib/metadataTypes/SendClassification.js +5 -4
  49. package/lib/metadataTypes/TransactionalEmail.js +8 -7
  50. package/lib/metadataTypes/TransactionalMessage.js +6 -5
  51. package/lib/metadataTypes/TransactionalPush.js +7 -6
  52. package/lib/metadataTypes/TransactionalSMS.js +9 -8
  53. package/lib/metadataTypes/TriggeredSend.js +15 -12
  54. package/lib/metadataTypes/User.js +8 -7
  55. package/lib/metadataTypes/Verification.js +8 -8
  56. package/lib/metadataTypes/definitions/Asset.definition.js +1 -1
  57. package/lib/metadataTypes/definitions/AttributeGroup.definition.js +1 -1
  58. package/lib/metadataTypes/definitions/AttributeSet.definition.js +1 -1
  59. package/lib/metadataTypes/definitions/Automation.definition.js +1 -1
  60. package/lib/metadataTypes/definitions/Campaign.definition.js +1 -1
  61. package/lib/metadataTypes/definitions/ContentArea.definition.js +1 -1
  62. package/lib/metadataTypes/definitions/DataExtension.definition.js +1 -1
  63. package/lib/metadataTypes/definitions/DataExtensionField.definition.js +1 -1
  64. package/lib/metadataTypes/definitions/DataExtensionTemplate.definition.js +1 -1
  65. package/lib/metadataTypes/definitions/DataExtract.definition.js +1 -1
  66. package/lib/metadataTypes/definitions/DataExtractType.definition.js +1 -1
  67. package/lib/metadataTypes/definitions/Discovery.definition.js +1 -1
  68. package/lib/metadataTypes/definitions/Email.definition.js +1 -1
  69. package/lib/metadataTypes/definitions/EmailSend.definition.js +1 -1
  70. package/lib/metadataTypes/definitions/Event.definition.js +1 -1
  71. package/lib/metadataTypes/definitions/FileLocation.definition.js +1 -1
  72. package/lib/metadataTypes/definitions/FileTransfer.definition.js +1 -1
  73. package/lib/metadataTypes/definitions/Filter.definition.js +1 -1
  74. package/lib/metadataTypes/definitions/Folder.definition.js +1 -1
  75. package/lib/metadataTypes/definitions/ImportFile.definition.js +1 -1
  76. package/lib/metadataTypes/definitions/Journey.definition.js +1 -1
  77. package/lib/metadataTypes/definitions/List.definition.js +1 -1
  78. package/lib/metadataTypes/definitions/MobileCode.definition.js +1 -1
  79. package/lib/metadataTypes/definitions/MobileKeyword.definition.js +1 -1
  80. package/lib/metadataTypes/definitions/MobileMessage.definition.js +1 -1
  81. package/lib/metadataTypes/definitions/Query.definition.js +1 -1
  82. package/lib/metadataTypes/definitions/Role.definition.js +1 -1
  83. package/lib/metadataTypes/definitions/Script.definition.js +1 -1
  84. package/lib/metadataTypes/definitions/SendClassification.definition.js +1 -1
  85. package/lib/metadataTypes/definitions/TransactionalEmail.definition.js +1 -1
  86. package/lib/metadataTypes/definitions/TransactionalPush.definition.js +1 -1
  87. package/lib/metadataTypes/definitions/TransactionalSMS.definition.js +1 -1
  88. package/lib/metadataTypes/definitions/TriggeredSend.definition.js +1 -1
  89. package/lib/metadataTypes/definitions/User.definition.js +1 -1
  90. package/lib/metadataTypes/definitions/Verification.definition.js +1 -1
  91. package/lib/retrieveChangelog.js +4 -3
  92. package/lib/util/auth.js +11 -8
  93. package/lib/util/businessUnit.js +5 -5
  94. package/lib/util/cache.js +3 -3
  95. package/lib/util/cli.js +15 -13
  96. package/lib/util/config.js +10 -7
  97. package/lib/util/devops.js +12 -11
  98. package/lib/util/file.js +15 -14
  99. package/lib/util/init.config.js +11 -9
  100. package/lib/util/init.git.js +8 -7
  101. package/lib/util/init.js +12 -12
  102. package/lib/util/init.npm.js +7 -5
  103. package/lib/util/util.js +14 -12
  104. package/package.json +31 -26
  105. package/test/general.test.js +4 -6
  106. package/test/mockRoot/.mcdevrc.json +1 -1
  107. package/test/resourceFactory.js +52 -26
  108. package/test/type.attributeGroup.test.js +5 -8
  109. package/test/type.attributeSet.test.js +5 -8
  110. package/test/type.automation.test.js +5 -9
  111. package/test/type.dataExtension.test.js +5 -9
  112. package/test/type.dataExtract.test.js +5 -6
  113. package/test/type.fileTransfer.test.js +5 -6
  114. package/test/type.importFile.test.js +5 -6
  115. package/test/type.journey.test.js +5 -6
  116. package/test/type.mobileKeyword.test.js +5 -7
  117. package/test/type.mobileMessage.test.js +5 -7
  118. package/test/type.query.test.js +5 -8
  119. package/test/type.script.test.js +5 -8
  120. package/test/type.transactionalEmail.test.js +5 -6
  121. package/test/type.transactionalPush.test.js +5 -6
  122. package/test/type.transactionalSMS.test.js +5 -7
  123. package/test/type.triggeredSend.test.js +5 -6
  124. package/test/type.user.test.js +6 -8
  125. package/test/type.verification.test.js +5 -6
  126. package/test/utils.js +61 -47
  127. package/types/mcdev.d.js +2 -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: dataExtract', () => {
10
9
  beforeEach(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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(() => {
@@ -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: verification', () => {
10
9
  beforeEach(() => {
package/test/utils.js CHANGED
@@ -1,17 +1,20 @@
1
- const File = require('../lib/util/file');
2
- const path = require('node:path');
3
- const axios = require('axios');
4
- const MockAdapter = require('axios-mock-adapter');
5
- const auth = require('../lib/util/auth');
6
- const Util = require('../lib/util/util');
7
- const handler = require('../lib/index');
1
+ import File from '../lib/util/file.js';
2
+ import path from 'node:path';
3
+ import MockAdapter from 'axios-mock-adapter';
4
+ import { axiosInstance } from '../node_modules/sfmc-sdk/lib/util.js';
5
+ import handler from '../lib/index.js';
6
+ import auth from '../lib/util/auth.js';
7
+ import { Util } from '../lib/util/util.js';
8
+ import { fileURLToPath } from 'node:url';
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
10
 
9
11
  // for some reason doesnt realize below reference
10
12
  // eslint-disable-next-line no-unused-vars
11
- const fsmock = require('mock-fs');
13
+ import fsmock from 'mock-fs';
14
+
12
15
  let apimock;
13
- const authResources = require('./resources/auth.json');
14
- const resourceFactory = require('./resourceFactory');
16
+ import { handleSOAPRequest, handleRESTRequest, soapUrl, restUrl } from './resourceFactory.js';
17
+ const authResources = File.readJsonSync(path.join(__dirname, './resources/auth.json'));
15
18
 
16
19
  /**
17
20
  * gets file from Retrieve folder
@@ -21,8 +24,12 @@ const resourceFactory = require('./resourceFactory');
21
24
  * @param {string} [buName] used when we need to test on ParentBU
22
25
  * @returns {Promise.<string>} file in string form
23
26
  */
24
- exports.getActualJson = (customerKey, type, buName = 'testBU') =>
25
- File.readJSON(`./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-meta.json`);
27
+ export function getActualJson(customerKey, type, buName = 'testBU') {
28
+ return File.readJSON(
29
+ `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-meta.json`
30
+ );
31
+ }
32
+
26
33
  /**
27
34
  * gets file from Retrieve folder
28
35
  *
@@ -31,8 +38,9 @@ exports.getActualJson = (customerKey, type, buName = 'testBU') =>
31
38
  * @param {string} [buName] used when we need to test on ParentBU
32
39
  * @returns {string} file path
33
40
  */
34
- exports.getActualDoc = (customerKey, type, buName = 'testBU') =>
35
- `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-doc.md`;
41
+ export function getActualDoc(customerKey, type, buName = 'testBU') {
42
+ return `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-doc.md`;
43
+ }
36
44
  /**
37
45
  * gets file from Retrieve folder
38
46
  *
@@ -41,8 +49,9 @@ exports.getActualDoc = (customerKey, type, buName = 'testBU') =>
41
49
  * @param {string} ext file extension
42
50
  * @returns {string} file path
43
51
  */
44
- exports.getActualFile = (customerKey, type, ext) =>
45
- `./retrieve/testInstance/testBU/${type}/${customerKey}.${type}-meta.${ext}`;
52
+ export function getActualFile(customerKey, type, ext) {
53
+ return `./retrieve/testInstance/testBU/${type}/${customerKey}.${type}-meta.${ext}`;
54
+ }
46
55
  /**
47
56
  * gets file from Deploy folder
48
57
  *
@@ -51,8 +60,11 @@ exports.getActualFile = (customerKey, type, ext) =>
51
60
  * @param {string} [buName] used when we need to test on ParentBU
52
61
  * @returns {Promise.<string>} file in string form
53
62
  */
54
- exports.getActualDeployJson = (customerKey, type, buName = 'testBU') =>
55
- File.readJSON(`./deploy/testInstance/${buName}/${type}/${customerKey}.${type}-meta.json`);
63
+ export function getActualDeployJson(customerKey, type, buName = 'testBU') {
64
+ return File.readJSON(
65
+ `./deploy/testInstance/${buName}/${type}/${customerKey}.${type}-meta.json`
66
+ );
67
+ }
56
68
  /**
57
69
  * gets file from Deploy folder
58
70
  *
@@ -61,8 +73,9 @@ exports.getActualDeployJson = (customerKey, type, buName = 'testBU') =>
61
73
  * @param {string} ext file extension
62
74
  * @returns {string} file path
63
75
  */
64
- exports.getActualDeployFile = (customerKey, type, ext) =>
65
- `./deploy/testInstance/testBU/${type}/${customerKey}.${type}-meta.${ext}`;
76
+ export function getActualDeployFile(customerKey, type, ext) {
77
+ return `./deploy/testInstance/testBU/${type}/${customerKey}.${type}-meta.${ext}`;
78
+ }
66
79
  /**
67
80
  * gets file from Template folder
68
81
  *
@@ -70,8 +83,9 @@ exports.getActualDeployFile = (customerKey, type, ext) =>
70
83
  * @param {string} type of metadata
71
84
  * @returns {Promise.<string>} file in string form
72
85
  */
73
- exports.getActualTemplateJson = (customerKey, type) =>
74
- File.readJSON(`./template/${type}/${customerKey}.${type}-meta.json`);
86
+ export function getActualTemplateJson(customerKey, type) {
87
+ return File.readJSON(`./template/${type}/${customerKey}.${type}-meta.json`);
88
+ }
75
89
  /**
76
90
  * gets file from Template folder
77
91
  *
@@ -80,9 +94,9 @@ exports.getActualTemplateJson = (customerKey, type) =>
80
94
  * @param {string} ext file extension
81
95
  * @returns {string} file path
82
96
  */
83
- exports.getActualTemplateFile = (customerKey, type, ext) =>
84
- `./template/${type}/${customerKey}.${type}-meta.${ext}`;
85
-
97
+ export function getActualTemplateFile(customerKey, type, ext) {
98
+ return `./template/${type}/${customerKey}.${type}-meta.${ext}`;
99
+ }
86
100
  /**
87
101
  * gets file from resources folder which should be used for comparison
88
102
  *
@@ -91,8 +105,9 @@ exports.getActualTemplateFile = (customerKey, type, ext) =>
91
105
  * @param {string} action of SOAP request
92
106
  * @returns {Promise.<string>} file in string form
93
107
  */
94
- exports.getExpectedJson = (mid, type, action) =>
95
- File.readJSON(path.join('test', 'resources', mid, type, action + '-expected.json'));
108
+ export function getExpectedJson(mid, type, action) {
109
+ return File.readJSON(path.join('test', 'resources', mid, type, action + '-expected.json'));
110
+ }
96
111
  /**
97
112
  * gets file from resources folder which should be used for comparison
98
113
  *
@@ -102,32 +117,30 @@ exports.getExpectedJson = (mid, type, action) =>
102
117
  * @param {string} ext file extension
103
118
  * @returns {string} file path
104
119
  */
105
- exports.getExpectedFile = (mid, type, action, ext) =>
106
- path.join('test', 'resources', mid, type, action + '-expected.' + ext);
120
+ export function getExpectedFile(mid, type, action, ext) {
121
+ return path.join('test', 'resources', mid, type, action + '-expected.' + ext);
122
+ }
107
123
  /**
108
124
  * setup mocks for API and FS
109
125
  *
110
126
  * @param {boolean} [isDeploy] if true, will mock deploy folder
111
127
  * @returns {void}
112
128
  */
113
-
114
- exports.mockSetup = (isDeploy) => {
129
+ export function mockSetup(isDeploy) {
115
130
  if (!isDeploy) {
116
131
  // no need to execute this again - already done in standard setup
117
132
  handler.setOptions({ debug: true, noLogFile: true });
118
133
  }
119
- apimock = new MockAdapter(axios, { onNoMatch: 'throwException' });
134
+ apimock = new MockAdapter(axiosInstance, { onNoMatch: 'throwException' });
120
135
  // set access_token to mid to allow for autorouting of mock to correct resources
121
136
  apimock.onPost(authResources.success.url).reply((config) => {
122
137
  authResources.success.response.access_token = JSON.parse(config.data).account_id;
123
138
  return [authResources.success.status, authResources.success.response];
124
139
  });
140
+ apimock.onPost(soapUrl).reply((config) => handleSOAPRequest(config));
125
141
  apimock
126
- .onPost(resourceFactory.soapUrl)
127
- .reply((config) => resourceFactory.handleSOAPRequest(config));
128
- apimock
129
- .onAny(new RegExp(`^${escapeRegExp(resourceFactory.restUrl)}`))
130
- .reply((config) => resourceFactory.handleRESTRequest(config));
142
+ .onAny(new RegExp(`^${escapeRegExp(restUrl)}`))
143
+ .reply((config) => handleRESTRequest(config));
131
144
  const fsMockConf = {
132
145
  '.prettierrc': fsmock.load(path.resolve(__dirname, '../boilerplate/files/.prettierrc')),
133
146
  '.eslintrc': fsmock.load(path.resolve(__dirname, '../boilerplate/files/.eslintrc')),
@@ -162,14 +175,14 @@ exports.mockSetup = (isDeploy) => {
162
175
 
163
176
  // ! reset exitCode or else tests could influence each other; do this in mockSetup to to ensure correct starting value
164
177
  process.exitCode = 0;
165
- };
178
+ }
166
179
 
167
180
  /**
168
181
  * resets mocks for API and FS
169
182
  *
170
183
  * @returns {void}
171
184
  */
172
- exports.mockReset = () => {
185
+ export function mockReset() {
173
186
  // remove all options that might have been set by previous tests
174
187
  for (const key in Util.OPTIONS) {
175
188
  if (Object.prototype.hasOwnProperty.call(Util.OPTIONS, key)) {
@@ -180,32 +193,34 @@ exports.mockReset = () => {
180
193
  auth.clearSessions();
181
194
  fsmock.restore();
182
195
  apimock.restore();
183
- };
196
+ }
184
197
  /**
185
198
  * helper to return amount of api callouts
186
199
  *
187
200
  * @param {boolean} [includeToken] if true, will include token calls in count
188
201
  * @returns {object} of API history
189
202
  */
190
- exports.getAPIHistoryLength = (includeToken) => {
203
+ export function getAPIHistoryLength(includeToken) {
191
204
  const historyArr = Object.values(apimock.history).flat();
192
205
  if (includeToken) {
193
206
  return historyArr.length;
194
207
  }
195
208
  return historyArr.filter((item) => item.url !== '/v2/token').length;
196
- };
209
+ }
197
210
  /**
198
211
  * helper to return api history
199
212
  *
200
213
  * @returns {object} of API history
201
214
  */
202
- exports.getAPIHistory = () => apimock.history;
215
+ export function getAPIHistory() {
216
+ return apimock.history;
217
+ }
203
218
  /**
204
219
  * helper to return most important fields for each api call
205
220
  *
206
221
  * @returns {object} of API history
207
222
  */
208
- function getAPIHistoryDebug() {
223
+ export function getAPIHistoryDebug() {
209
224
  const historyArr = Object.values(apimock.history)
210
225
  .flat()
211
226
  .map((item) => {
@@ -217,15 +232,14 @@ function getAPIHistoryDebug() {
217
232
  });
218
233
  return historyArr;
219
234
  }
220
- exports.getAPIHistoryDebug = getAPIHistoryDebug;
221
235
  /**
222
236
  * helper to return most important fields for each api call
223
237
  *
224
238
  * @returns {void} of API history
225
239
  */
226
- exports.logAPIHistoryDebug = () => {
240
+ export function logAPIHistoryDebug() {
227
241
  console.log(getAPIHistoryDebug()); // eslint-disable-line no-console
228
- };
242
+ }
229
243
 
230
244
  /**
231
245
  * escapes string for regex
package/types/mcdev.d.js CHANGED
@@ -1,4 +1,4 @@
1
- const SDK = require('sfmc-sdk');
1
+ import SDK from 'sfmc-sdk';
2
2
  /**
3
3
  * @ignore
4
4
  * @typedef {object} BuObject
@@ -347,4 +347,4 @@ complex
347
347
  * @property {Function} errorStack (ex, msg) print error with trace message
348
348
  */
349
349
 
350
- module.exports = {};
350
+ export default {};