mcdev 9.0.2 → 9.0.4
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.
- package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
- package/.github/copilot-instructions.md +85 -0
- package/.github/pr-labeler.yml +3 -3
- package/.github/workflows/code-test.yml +3 -3
- package/.github/workflows/coverage-base-update.yml +2 -2
- package/.github/workflows/coverage.yml +1 -1
- package/.github/workflows/npm-publish.yml +71 -3
- package/.github/workflows/sync-milestone.yml +55 -0
- package/.husky/post-checkout +1 -1
- package/@types/lib/Retriever.d.ts.map +1 -1
- package/@types/lib/metadataTypes/Asset.d.ts +0 -21
- package/@types/lib/metadataTypes/Asset.d.ts.map +1 -1
- package/@types/lib/metadataTypes/Automation.d.ts +11 -2
- package/@types/lib/metadataTypes/Automation.d.ts.map +1 -1
- package/@types/lib/metadataTypes/DataExtension.d.ts +4 -2
- package/@types/lib/metadataTypes/DataExtension.d.ts.map +1 -1
- package/@types/lib/metadataTypes/DataExtensionField.d.ts +25 -0
- package/@types/lib/metadataTypes/DataExtensionField.d.ts.map +1 -1
- package/@types/lib/metadataTypes/Event.d.ts +6 -6
- package/@types/lib/metadataTypes/Event.d.ts.map +1 -1
- package/@types/lib/metadataTypes/Filter.d.ts +1 -1
- package/@types/lib/metadataTypes/Folder.d.ts +12 -4
- package/@types/lib/metadataTypes/Folder.d.ts.map +1 -1
- package/@types/lib/metadataTypes/ImportFile.d.ts +2 -2
- package/@types/lib/metadataTypes/ImportFile.d.ts.map +1 -1
- package/@types/lib/metadataTypes/Journey.d.ts.map +1 -1
- package/@types/lib/metadataTypes/MetadataType.d.ts +16 -6
- package/@types/lib/metadataTypes/MetadataType.d.ts.map +1 -1
- package/@types/lib/metadataTypes/SenderProfile.d.ts +7 -2
- package/@types/lib/metadataTypes/SenderProfile.d.ts.map +1 -1
- package/@types/lib/metadataTypes/definitions/Filter.definition.d.ts +1 -1
- package/@types/lib/util/cache.d.ts.map +1 -1
- package/@types/lib/util/cli.d.ts.map +1 -1
- package/@types/lib/util/util.d.ts +44 -26
- package/@types/lib/util/util.d.ts.map +1 -1
- package/@types/lib/util/validations.d.ts +6 -3
- package/@types/lib/util/validations.d.ts.map +1 -1
- package/@types/types/mcdev.d.d.ts +12 -12
- package/@types/types/mcdev.d.d.ts.map +1 -1
- package/README.md +6 -2
- package/lib/Retriever.js +2 -1
- package/lib/index.js +2 -2
- package/lib/metadataTypes/Automation.js +2 -2
- package/lib/metadataTypes/DataExtension.js +60 -1
- package/lib/metadataTypes/DataExtensionField.js +114 -0
- package/lib/metadataTypes/Event.js +3 -3
- package/lib/metadataTypes/Folder.js +2 -2
- package/lib/metadataTypes/ImportFile.js +1 -1
- package/lib/metadataTypes/Journey.js +82 -39
- package/lib/metadataTypes/MetadataType.js +27 -11
- package/lib/metadataTypes/SenderProfile.js +1 -1
- package/lib/metadataTypes/definitions/Filter.definition.js +2 -3
- package/lib/util/auth.js +7 -2
- package/lib/util/cache.js +5 -3
- package/lib/util/cli.js +3 -0
- package/lib/util/util.js +17 -15
- package/lib/util/validations.js +2 -2
- package/package.json +12 -12
- package/test/general.test.js +11 -11
- package/test/mock-fs-windows.test.js +54 -0
- package/test/mockRoot/.mcdev-validations.js +3 -3
- package/test/mockRoot/.mcdevrc.json +1 -1
- package/test/mockRoot/deploy/testInstance/testBU/journey/testExisting_journey_updatecontact_sharedDE.journey-meta.json +108 -0
- package/test/release-hotfix.test.js +97 -0
- package/test/resources/1111111/dataExtension/template_sharedDE-expected.json +53 -0
- package/test/resources/9999999/automation/v1/queries/get-response.json +17 -0
- package/test/resources/9999999/interaction/v1/interactions/get-response.json +40 -2
- package/test/resources/9999999/interaction/v1/interactions/key_testExisting_journey_updatecontact/get-response.json +4 -4
- package/test/resources/9999999/interaction/v1/interactions/key_testExisting_journey_updatecontact_sharedDE/get-response.json +119 -0
- package/test/resources/9999999/interaction/v1/interactions/key_testExisting_journey_updatecontact_sharedDE/put-response.json +110 -0
- package/test/resources/9999999/journey/get-updatecontact-sharedDE-expected.json +108 -0
- package/test/resources/9999999/journey/put-updatecontact-sharedDE-expected.json +108 -0
- package/test/resources/9999999/query/get_sharedDE-expected.json +11 -0
- package/test/resources/9999999/query/get_sharedDE-expected.sql +7 -0
- package/test/resources/9999999/query/template_sharedDE-expected.json +8 -0
- package/test/resources/9999999/query/template_sharedDE-expected.sql +7 -0
- package/test/type.attributeSet.test.js +41 -0
- package/test/type.automation.test.js +1 -1
- package/test/type.journey.test.js +108 -6
- package/test/type.query.test.js +105 -8
- package/test/utils.js +4 -1
- package/types/mcdev.d.js +13 -7
package/lib/util/util.js
CHANGED
|
@@ -57,9 +57,10 @@ export const Util = {
|
|
|
57
57
|
/**
|
|
58
58
|
* helper that allows filtering an object by its keys
|
|
59
59
|
*
|
|
60
|
-
* @
|
|
60
|
+
* @template T
|
|
61
|
+
* @param {Object.<string, T>} originalObj object that you want to filter
|
|
61
62
|
* @param {string[]} [whitelistArr] positive filter. if not provided, returns originalObj without filter
|
|
62
|
-
* @returns {Object.<string
|
|
63
|
+
* @returns {Object.<string, T>} filtered object that only contains keys you provided
|
|
63
64
|
*/
|
|
64
65
|
filterObjByKeys(originalObj, whitelistArr) {
|
|
65
66
|
if (!whitelistArr || !Array.isArray(whitelistArr)) {
|
|
@@ -222,7 +223,7 @@ export const Util = {
|
|
|
222
223
|
* SFMC accepts multiple true values for Boolean attributes for which we are checking here.
|
|
223
224
|
* The same problem occurs when evaluating boolean CLI flags
|
|
224
225
|
*
|
|
225
|
-
* @param {
|
|
226
|
+
* @param {string | number | boolean} attrValue value
|
|
226
227
|
* @returns {boolean} attribute value == true ? true : false
|
|
227
228
|
*/
|
|
228
229
|
isTrue(attrValue) {
|
|
@@ -233,7 +234,7 @@ export const Util = {
|
|
|
233
234
|
* SFMC accepts multiple false values for Boolean attributes for which we are checking here.
|
|
234
235
|
* The same problem occurs when evaluating boolean CLI flags
|
|
235
236
|
*
|
|
236
|
-
* @param {
|
|
237
|
+
* @param {string | number | boolean} attrValue value
|
|
237
238
|
* @returns {boolean} attribute value == false ? true : false
|
|
238
239
|
*/
|
|
239
240
|
isFalse(attrValue) {
|
|
@@ -607,7 +608,7 @@ export const Util = {
|
|
|
607
608
|
* @param {string} level of log (error, info, warn)
|
|
608
609
|
* @param {string} type of metadata being referenced
|
|
609
610
|
* @param {string} method name which log was called from
|
|
610
|
-
* @param {
|
|
611
|
+
* @param {unknown} payload generic object which details the error
|
|
611
612
|
* @param {string} [source] key/id of metadata which relates to error
|
|
612
613
|
* @returns {void}
|
|
613
614
|
*/
|
|
@@ -800,8 +801,8 @@ export const Util = {
|
|
|
800
801
|
* let's you dynamically walk down an object and get a value
|
|
801
802
|
*
|
|
802
803
|
* @param {string} path 'fieldA.fieldB.fieldC'
|
|
803
|
-
* @param {
|
|
804
|
-
* @returns {
|
|
804
|
+
* @param {MetadataTypeItem} obj some parent object
|
|
805
|
+
* @returns {unknown} value of obj.path
|
|
805
806
|
*/
|
|
806
807
|
resolveObjPath(path, obj) {
|
|
807
808
|
return path.split('.').reduce((prev, curr) => (prev ? prev[curr] : null), obj);
|
|
@@ -922,7 +923,7 @@ export const Util = {
|
|
|
922
923
|
/**
|
|
923
924
|
* helper for MetadataType class to issue a similar error message for unsupported methods
|
|
924
925
|
*
|
|
925
|
-
* @param {
|
|
926
|
+
* @param {{type: string, keyField: string, nameField: string}} definition type definition object
|
|
926
927
|
* @param {string} method name of the method thats not supported
|
|
927
928
|
* @param {MetadataTypeItem} [item] metadata item
|
|
928
929
|
*/
|
|
@@ -976,7 +977,7 @@ export const Util = {
|
|
|
976
977
|
/**
|
|
977
978
|
* helper that returns the prefix of item specific log messages
|
|
978
979
|
*
|
|
979
|
-
* @param {
|
|
980
|
+
* @param {{type: string, keyField: string, nameField: string}} definition metadata definition
|
|
980
981
|
* @param {MetadataTypeItem} metadataItem metadata item
|
|
981
982
|
* @returns {string} msg prefix
|
|
982
983
|
*/
|
|
@@ -987,7 +988,7 @@ export const Util = {
|
|
|
987
988
|
/**
|
|
988
989
|
* helper that returns the prefix of item specific log messages
|
|
989
990
|
*
|
|
990
|
-
* @param {
|
|
991
|
+
* @param {{type: string, keyField: string, nameField: string}} definition metadata definition
|
|
991
992
|
* @param {MetadataTypeItem} metadataItem metadata item
|
|
992
993
|
* @returns {string} key or key/name combo
|
|
993
994
|
*/
|
|
@@ -998,7 +999,7 @@ export const Util = {
|
|
|
998
999
|
/**
|
|
999
1000
|
* helper that returns the prefix of item specific log messages
|
|
1000
1001
|
*
|
|
1001
|
-
* @param {
|
|
1002
|
+
* @param {{type: string, keyField: string, nameField: string}} definition metadata definition
|
|
1002
1003
|
* @param {MetadataTypeItem} metadataItem metadata item
|
|
1003
1004
|
* @returns {string} key or key/name combo
|
|
1004
1005
|
*/
|
|
@@ -1302,9 +1303,10 @@ export const Util = {
|
|
|
1302
1303
|
* async version of Array.find()
|
|
1303
1304
|
* returns the first element in the provided array that satisfies the provided testin function
|
|
1304
1305
|
*
|
|
1305
|
-
* @
|
|
1306
|
-
* @param {
|
|
1307
|
-
* @
|
|
1306
|
+
* @template T
|
|
1307
|
+
* @param {T[]} arr your test array
|
|
1308
|
+
* @param {(element: T) => boolean | Promise.<boolean>} asyncCallback callback
|
|
1309
|
+
* @returns {Promise.<T | undefined>} first element that passed the test
|
|
1308
1310
|
*/
|
|
1309
1311
|
async findAsync(arr, asyncCallback) {
|
|
1310
1312
|
for (const element of arr) {
|
|
@@ -1328,7 +1330,7 @@ export const Util = {
|
|
|
1328
1330
|
/**
|
|
1329
1331
|
* recursively find all values of the given key in the object
|
|
1330
1332
|
*
|
|
1331
|
-
* @param {
|
|
1333
|
+
* @param {object} object data to search in
|
|
1332
1334
|
* @param {string} key attribute to find
|
|
1333
1335
|
* @returns {Array} all values of the given key
|
|
1334
1336
|
*/
|
package/lib/util/validations.js
CHANGED
|
@@ -37,8 +37,8 @@ async function loadCustomRules() {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
*
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
40
|
+
* @param {{type: string, keyField: string}} definition type definition
|
|
41
|
+
* @param {import('../../types/mcdev.d.js').MetadataTypeItem} item MetadataItem
|
|
42
42
|
* @param {string} targetDir folder in which the MetadataItem is deployed from (deploy/cred/bu)
|
|
43
43
|
* @param {CodeExtract[]} [codeExtractItemArr] array of code snippets
|
|
44
44
|
* @returns {Promise.<validationRuleList>} MetadataItem
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcdev",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.4",
|
|
4
4
|
"description": "Accenture Salesforce Marketing Cloud DevTools",
|
|
5
5
|
"author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"mcdev": "./lib/cli.js"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": "^
|
|
48
|
+
"node": "^22.22.2 || >=24.15.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"start": "node lib/cli.js",
|
|
52
52
|
"mcdev": "node lib/cli.js",
|
|
53
|
-
"build": "run-s lint:fix
|
|
53
|
+
"build": "run-s lint:fix test",
|
|
54
54
|
"debug": "node --nolazy --inspect-brk=9229 lib/cli.js",
|
|
55
55
|
"lint:fix": "eslint --fix lib/**/*.js types/*.js test/**/*.js",
|
|
56
56
|
"lint": "eslint lib/**/*.js types/*.js test/**/*.js",
|
|
@@ -74,15 +74,15 @@
|
|
|
74
74
|
"console.table": "0.10.0",
|
|
75
75
|
"deep-equal": "2.2.3",
|
|
76
76
|
"fs-extra": "11.3.4",
|
|
77
|
-
"inquirer": "13.3.
|
|
77
|
+
"inquirer": "13.3.2",
|
|
78
78
|
"json-to-table": "4.2.1",
|
|
79
79
|
"mustache": "4.2.0",
|
|
80
80
|
"p-limit": "7.3.0",
|
|
81
81
|
"prettier": "3.8.1",
|
|
82
|
-
"prettier-plugin-sql": "0.
|
|
82
|
+
"prettier-plugin-sql": "0.20.0",
|
|
83
83
|
"semver": "7.7.4",
|
|
84
|
-
"sfmc-sdk": "
|
|
85
|
-
"simple-git": "3.
|
|
84
|
+
"sfmc-sdk": "4.0.2",
|
|
85
|
+
"simple-git": "3.33.0",
|
|
86
86
|
"toposort": "2.0.2",
|
|
87
87
|
"update-notifier": "7.3.1",
|
|
88
88
|
"winston": "3.19.0",
|
|
@@ -94,23 +94,23 @@
|
|
|
94
94
|
"@types/fs-extra": "11.0.4",
|
|
95
95
|
"@types/inquirer": "9.0.9",
|
|
96
96
|
"@types/mocha": "10.0.8",
|
|
97
|
-
"@types/node": "25.
|
|
97
|
+
"@types/node": "25.5.0",
|
|
98
98
|
"@types/yargs": "17.0.35",
|
|
99
99
|
"assert": "2.1.0",
|
|
100
100
|
"axios-mock-adapter": "2.0.0",
|
|
101
101
|
"c8": "11.0.0",
|
|
102
102
|
"chai": "6.2.2",
|
|
103
103
|
"chai-files": "1.4.0",
|
|
104
|
-
"eslint": "10.0
|
|
104
|
+
"eslint": "10.1.0",
|
|
105
105
|
"eslint-config-ssjs": "2.0.0",
|
|
106
|
-
"eslint-plugin-jsdoc": "62.
|
|
106
|
+
"eslint-plugin-jsdoc": "62.8.0",
|
|
107
107
|
"eslint-plugin-mocha": "11.2.0",
|
|
108
108
|
"eslint-plugin-prettier": "5.5.5",
|
|
109
109
|
"eslint-plugin-unicorn": "63.0.0",
|
|
110
|
-
"fast-xml-parser": "5.
|
|
110
|
+
"fast-xml-parser": "5.5.9",
|
|
111
111
|
"globals": "17.4.0",
|
|
112
112
|
"husky": "9.1.7",
|
|
113
|
-
"lint-staged": "16.
|
|
113
|
+
"lint-staged": "16.4.0",
|
|
114
114
|
"mocha": "11.7.5",
|
|
115
115
|
"mock-fs": "5.3.0",
|
|
116
116
|
"npm-run-all": "4.1.5",
|
package/test/general.test.js
CHANGED
|
@@ -60,7 +60,7 @@ describe('GENERAL', () => {
|
|
|
60
60
|
);
|
|
61
61
|
assert.equal(
|
|
62
62
|
testUtils.getAPIHistoryLength(),
|
|
63
|
-
|
|
63
|
+
48,
|
|
64
64
|
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
65
65
|
);
|
|
66
66
|
return;
|
|
@@ -108,7 +108,7 @@ describe('GENERAL', () => {
|
|
|
108
108
|
);
|
|
109
109
|
assert.equal(
|
|
110
110
|
testUtils.getAPIHistoryLength(),
|
|
111
|
-
|
|
111
|
+
48,
|
|
112
112
|
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
113
113
|
);
|
|
114
114
|
return;
|
|
@@ -157,7 +157,7 @@ describe('GENERAL', () => {
|
|
|
157
157
|
|
|
158
158
|
assert.equal(
|
|
159
159
|
testUtils.getAPIHistoryLength(),
|
|
160
|
-
|
|
160
|
+
48,
|
|
161
161
|
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
162
162
|
);
|
|
163
163
|
return;
|
|
@@ -224,7 +224,7 @@ describe('GENERAL', () => {
|
|
|
224
224
|
|
|
225
225
|
assert.equal(
|
|
226
226
|
testUtils.getAPIHistoryLength(),
|
|
227
|
-
|
|
227
|
+
84,
|
|
228
228
|
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
229
229
|
);
|
|
230
230
|
return;
|
|
@@ -284,7 +284,7 @@ describe('GENERAL', () => {
|
|
|
284
284
|
|
|
285
285
|
assert.equal(
|
|
286
286
|
testUtils.getAPIHistoryLength(),
|
|
287
|
-
|
|
287
|
+
84,
|
|
288
288
|
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
289
289
|
);
|
|
290
290
|
return;
|
|
@@ -344,7 +344,7 @@ describe('GENERAL', () => {
|
|
|
344
344
|
|
|
345
345
|
assert.equal(
|
|
346
346
|
testUtils.getAPIHistoryLength(),
|
|
347
|
-
|
|
347
|
+
84,
|
|
348
348
|
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
349
349
|
);
|
|
350
350
|
return;
|
|
@@ -985,7 +985,7 @@ describe('GENERAL', () => {
|
|
|
985
985
|
// download first before we test buildTemplate
|
|
986
986
|
await handler.retrieve('testInstance/testBU');
|
|
987
987
|
|
|
988
|
-
const expectedApiCallsRetrieve =
|
|
988
|
+
const expectedApiCallsRetrieve = 111;
|
|
989
989
|
assert.equal(
|
|
990
990
|
testUtils.getAPIHistoryLength(),
|
|
991
991
|
expectedApiCallsRetrieve,
|
|
@@ -1227,7 +1227,7 @@ describe('GENERAL', () => {
|
|
|
1227
1227
|
await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')
|
|
1228
1228
|
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'));
|
|
1229
1229
|
|
|
1230
|
-
const expectedApiCallsRetrieve =
|
|
1230
|
+
const expectedApiCallsRetrieve = 115;
|
|
1231
1231
|
assert.equal(
|
|
1232
1232
|
testUtils.getAPIHistoryLength(),
|
|
1233
1233
|
expectedApiCallsRetrieve,
|
|
@@ -1601,7 +1601,7 @@ describe('GENERAL', () => {
|
|
|
1601
1601
|
// download everything before we test buildTemplate
|
|
1602
1602
|
await handler.retrieve('testInstance/testBU');
|
|
1603
1603
|
|
|
1604
|
-
const expectedApiCallsRetrieve =
|
|
1604
|
+
const expectedApiCallsRetrieve = 111;
|
|
1605
1605
|
assert.equal(
|
|
1606
1606
|
testUtils.getAPIHistoryLength(),
|
|
1607
1607
|
expectedApiCallsRetrieve,
|
|
@@ -1812,7 +1812,7 @@ describe('GENERAL', () => {
|
|
|
1812
1812
|
await testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql')
|
|
1813
1813
|
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'build', 'sql'));
|
|
1814
1814
|
|
|
1815
|
-
const expectedApiCallsRetrieve =
|
|
1815
|
+
const expectedApiCallsRetrieve = 115;
|
|
1816
1816
|
assert.equal(
|
|
1817
1817
|
testUtils.getAPIHistoryLength(),
|
|
1818
1818
|
expectedApiCallsRetrieve,
|
|
@@ -2003,7 +2003,7 @@ describe('GENERAL', () => {
|
|
|
2003
2003
|
// download first before we test buildTemplate
|
|
2004
2004
|
await handler.retrieve('testInstance/testBU');
|
|
2005
2005
|
|
|
2006
|
-
const expectedApiCallsRetrieve =
|
|
2006
|
+
const expectedApiCallsRetrieve = 111;
|
|
2007
2007
|
assert.equal(
|
|
2008
2008
|
testUtils.getAPIHistoryLength(),
|
|
2009
2009
|
expectedApiCallsRetrieve,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import Conf from 'conf';
|
|
6
|
+
import fsmock from 'mock-fs';
|
|
7
|
+
|
|
8
|
+
const packagePath = path.resolve('package.json');
|
|
9
|
+
const packageContents = fs.readFileSync(packagePath, 'utf8');
|
|
10
|
+
const configRoot = path.parse(process.env.APPDATA || os.homedir()).root;
|
|
11
|
+
const sessionDirectory = path.join(configRoot, 'mcdev-mock-fs-regression', 'Config');
|
|
12
|
+
|
|
13
|
+
// Disable default roots so the Windows regression also runs when cwd and home share a drive.
|
|
14
|
+
describe('mock-fs Windows session directories', () => {
|
|
15
|
+
it('reproduces recursive mkdir overflow when the session drive is absent', () => {
|
|
16
|
+
if (process.platform !== 'win32') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
fsmock({}, { createCwd: false, createTmp: false });
|
|
20
|
+
try {
|
|
21
|
+
assert.equal(fs.existsSync(configRoot), false);
|
|
22
|
+
assert.equal(path.dirname(configRoot), configRoot);
|
|
23
|
+
assert.throws(
|
|
24
|
+
() => new Conf({ cwd: sessionDirectory, configName: 'sessions' }),
|
|
25
|
+
RangeError
|
|
26
|
+
);
|
|
27
|
+
} finally {
|
|
28
|
+
fsmock.restore();
|
|
29
|
+
}
|
|
30
|
+
assert.equal(fs.readFileSync(packagePath, 'utf8'), packageContents);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('writes and clears sessions when the session drive root is seeded', () => {
|
|
34
|
+
// Seed the root before relative fixtures, retaining both when they share a drive.
|
|
35
|
+
fsmock(
|
|
36
|
+
{ [configRoot]: {}, 'mock-fs-regression-marker.txt': 'mock fixture' },
|
|
37
|
+
{ createCwd: false, createTmp: false }
|
|
38
|
+
);
|
|
39
|
+
try {
|
|
40
|
+
const sessions = new Conf({ cwd: sessionDirectory, configName: 'sessions' });
|
|
41
|
+
sessions.set('test-session', { access_token: 'mock-token' });
|
|
42
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(sessions.path, 'utf8')), {
|
|
43
|
+
'test-session': { access_token: 'mock-token' },
|
|
44
|
+
});
|
|
45
|
+
sessions.clear();
|
|
46
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(sessions.path, 'utf8')), {});
|
|
47
|
+
assert.equal(fs.readFileSync('mock-fs-regression-marker.txt', 'utf8'), 'mock fixture');
|
|
48
|
+
} finally {
|
|
49
|
+
fsmock.restore();
|
|
50
|
+
}
|
|
51
|
+
assert.equal(fs.readFileSync(packagePath, 'utf8'), packageContents);
|
|
52
|
+
assert.equal(fs.existsSync('mock-fs-regression-marker.txt'), false);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
'use strict';
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {
|
|
4
|
+
* @typedef {object} MetadataTypeItem generic metadata item
|
|
5
5
|
*
|
|
6
6
|
* @typedef {object} CodeExtract
|
|
7
7
|
* @property {string[]} subFolder mostly set to null, otherwise subfolders path split into elements
|
|
@@ -32,11 +32,11 @@ const buPrefixBlacklistMap = {
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
*
|
|
35
|
-
* @param {
|
|
35
|
+
* @param {{keyField: string, nameField: string}} definition type definition
|
|
36
36
|
* @param {MetadataTypeItem} item MetadataItem
|
|
37
37
|
* @param {string} targetDir folder in which the MetadataItem is deployed from (deploy/cred/bu)
|
|
38
38
|
* @param {CodeExtract[]} codeExtractItemArr array of code snippets
|
|
39
|
-
* @param {
|
|
39
|
+
* @param {typeof import('../../lib/util/util.js').Util} Util utility functions
|
|
40
40
|
* @returns {validationRuleList} MetadataItem
|
|
41
41
|
*/
|
|
42
42
|
export function validation(definition, item, targetDir, codeExtractItemArr, Util) {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "testExisting_journey_updatecontact_sharedDE",
|
|
3
|
+
"name": "testExisting_journey_updatecontact_sharedDE",
|
|
4
|
+
"lastPublishedDate": "0001-01-01T00:00:00",
|
|
5
|
+
"description": "",
|
|
6
|
+
"version": 1,
|
|
7
|
+
"workflowApiVersion": 1,
|
|
8
|
+
"createdDate": "2024-05-04T05:54:48.027",
|
|
9
|
+
"modifiedDate": "2024-05-04T17:25:57.9",
|
|
10
|
+
"activities": [
|
|
11
|
+
{
|
|
12
|
+
"key": "UPDATECONTACTDATAV2-1",
|
|
13
|
+
"name": "Update Contact - TEST",
|
|
14
|
+
"description": "",
|
|
15
|
+
"type": "UPDATECONTACTDATA",
|
|
16
|
+
"outcomes": [
|
|
17
|
+
{
|
|
18
|
+
"key": "9f21d42b-4679-4561-911a-4bccf84672ba",
|
|
19
|
+
"arguments": {},
|
|
20
|
+
"metaData": {
|
|
21
|
+
"invalid": false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"arguments": {
|
|
26
|
+
"activityData": {
|
|
27
|
+
"updateContactFields": [
|
|
28
|
+
{
|
|
29
|
+
"r__dataExtension_key": "testExisting_dataExtensionShared",
|
|
30
|
+
"r__dataExtensionField_name": "LastName",
|
|
31
|
+
"value": "TEST"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"configurationArguments": {},
|
|
37
|
+
"metaData": {
|
|
38
|
+
"isConfigured": true
|
|
39
|
+
},
|
|
40
|
+
"schema": {
|
|
41
|
+
"arguments": {
|
|
42
|
+
"activityData": {
|
|
43
|
+
"dataType": "Text",
|
|
44
|
+
"isNullable": false,
|
|
45
|
+
"direction": "In",
|
|
46
|
+
"readOnly": false,
|
|
47
|
+
"access": "Hidden"
|
|
48
|
+
},
|
|
49
|
+
"contactKey": {
|
|
50
|
+
"dataType": "Text",
|
|
51
|
+
"isNullable": false,
|
|
52
|
+
"direction": "In",
|
|
53
|
+
"readOnly": false,
|
|
54
|
+
"access": "Hidden"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"triggers": [
|
|
61
|
+
{
|
|
62
|
+
"key": "TRIGGER",
|
|
63
|
+
"name": "TRIGGER",
|
|
64
|
+
"description": "",
|
|
65
|
+
"type": "EmailAudience",
|
|
66
|
+
"outcomes": [],
|
|
67
|
+
"arguments": {},
|
|
68
|
+
"configurationArguments": {},
|
|
69
|
+
"metaData": {
|
|
70
|
+
"r__event_key": "DEAudience-2e3c73b6-48cc-2ec0-5522-48636e1a236e",
|
|
71
|
+
"chainType": "None",
|
|
72
|
+
"configurationRequired": false,
|
|
73
|
+
"iconUrl": "/images/icon-data-extension.svg",
|
|
74
|
+
"title": "Data Extension",
|
|
75
|
+
"entrySourceGroupConfigUrl": "jb:///data/entry/audience/entrysourcegroupconfig.json",
|
|
76
|
+
"sourceInteractionId": "00000000-0000-0000-0000-000000000000"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"goals": [],
|
|
81
|
+
"exits": [],
|
|
82
|
+
"notifiers": [],
|
|
83
|
+
"entryMode": "NotSet",
|
|
84
|
+
"definitionType": "Multistep",
|
|
85
|
+
"channel": "",
|
|
86
|
+
"defaults": {
|
|
87
|
+
"email": [
|
|
88
|
+
"{{Event.DEAudience-2e3c73b6-48cc-2ec0-5522-48636e1a236e.\"Email\"}}"
|
|
89
|
+
],
|
|
90
|
+
"properties": {
|
|
91
|
+
"analyticsTracking": {
|
|
92
|
+
"enabled": true,
|
|
93
|
+
"analyticsType": "google",
|
|
94
|
+
"urlDomainsToTrack": []
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"metaData": {
|
|
99
|
+
"dataSource": "ContactsModel",
|
|
100
|
+
"highThroughputSending": {
|
|
101
|
+
"email": false
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"executionMode": "Production",
|
|
105
|
+
"status": "Draft",
|
|
106
|
+
"scheduledStatus": "Draft",
|
|
107
|
+
"r__folder_Path": "my journeys"
|
|
108
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { assert } from 'chai';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import SDK from 'sfmc-sdk';
|
|
5
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
6
|
+
import semver from 'semver';
|
|
7
|
+
import { axiosInstance } from '../node_modules/sfmc-sdk/lib/util.js';
|
|
8
|
+
|
|
9
|
+
const workflow = fs.readFileSync('.github/workflows/npm-publish.yml', 'utf8');
|
|
10
|
+
const releaseScript = workflow
|
|
11
|
+
.split("node --input-type=module <<'NODE'\n")[1]
|
|
12
|
+
.split('\n NODE')[0];
|
|
13
|
+
|
|
14
|
+
// Evaluate the workflow guard without publishing or writing to GitHub.
|
|
15
|
+
describe('V9 HOTFIX RELEASE', () => {
|
|
16
|
+
it('Checks out the release tag in both jobs and only publishes to literal legacy-v9', () => {
|
|
17
|
+
assert.equal(workflow.split('ref: ${{ github.event.release.tag_name }}').length - 1, 2);
|
|
18
|
+
const commands = workflow.split('\n').filter((line) => line.includes('npm publish'));
|
|
19
|
+
assert.deepEqual(
|
|
20
|
+
commands.map((line) => line.trim()),
|
|
21
|
+
['- run: npm publish --tag legacy-v9']
|
|
22
|
+
);
|
|
23
|
+
const channel = commands[0].trim().split('--tag ')[1];
|
|
24
|
+
assert.isNull(semver.validRange(channel), 'npm channels must not be valid semver ranges');
|
|
25
|
+
assert.isNotNull(semver.validRange('v9'), 'the previous channel was a semver range');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const releases = [
|
|
29
|
+
['9.0.4', 'v9.0.4', null],
|
|
30
|
+
['10.1.0', 'v10.1.0', 'only publishes v9'],
|
|
31
|
+
['8.4.0', 'v8.4.0', 'only publishes v9'],
|
|
32
|
+
['9.0.4', 'v9.0.3', 'Release tag must match'],
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
it('Accepts only matching v9 releases and rejects other majors or mismatches', () => {
|
|
36
|
+
for (const [version, tag, error] of releases) {
|
|
37
|
+
const script = releaseScript.replace(
|
|
38
|
+
"JSON.parse(fs.readFileSync('package.json', 'utf8'))",
|
|
39
|
+
JSON.stringify({ version })
|
|
40
|
+
);
|
|
41
|
+
const result = spawnSync(process.execPath, ['--input-type=module', '-e', script], {
|
|
42
|
+
env: { ...process.env, RELEASE_TAG: tag },
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
});
|
|
45
|
+
if (error) {
|
|
46
|
+
assert.notEqual(result.status, 0);
|
|
47
|
+
assert.include(result.stderr, error);
|
|
48
|
+
} else {
|
|
49
|
+
assert.equal(result.status, 0, result.stderr);
|
|
50
|
+
assert.equal(result.stdout, '');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Exercise the SDK's scope fix with a cold refresh and an array-scoped cached session.
|
|
56
|
+
it('Refreshes and reuses sessions containing newly introduced scopes', async () => {
|
|
57
|
+
const credentials = {
|
|
58
|
+
access_token: '',
|
|
59
|
+
client_id: 'hotfix-test-client',
|
|
60
|
+
client_secret: 'hotfix-test-secret',
|
|
61
|
+
account_id: 1234567,
|
|
62
|
+
auth_url: 'https://mct0l7nxfq2r988t1kxfy8sc4xxx.auth.marketingcloudapis.com/',
|
|
63
|
+
};
|
|
64
|
+
const scopes = ['data_extensions_read', 'future_scope_unknown_to_sdk'];
|
|
65
|
+
const mock = new MockAdapter(axiosInstance);
|
|
66
|
+
try {
|
|
67
|
+
mock.onPost('/v2/token').reply(200, {
|
|
68
|
+
access_token: 'hotfix-test-token',
|
|
69
|
+
expires_in: 1080,
|
|
70
|
+
scope: scopes.join(' '),
|
|
71
|
+
rest_instance_url: credentials.auth_url.replace('.auth.', '.rest.'),
|
|
72
|
+
soap_instance_url: credentials.auth_url.replace('.auth.', '.soap.'),
|
|
73
|
+
});
|
|
74
|
+
const sdk = new SDK(
|
|
75
|
+
/** @type {ConstructorParameters<typeof SDK>[0]} */ (
|
|
76
|
+
/** @type {unknown} */ (credentials)
|
|
77
|
+
),
|
|
78
|
+
{
|
|
79
|
+
eventHandlers: {
|
|
80
|
+
onRefresh: (session) => {
|
|
81
|
+
session.scope = session.scope.split(' ');
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
const session = await sdk.auth.getAccessToken();
|
|
87
|
+
assert.deepEqual(session.scope, scopes);
|
|
88
|
+
const cached = new SDK(session);
|
|
89
|
+
const reused = await cached.auth.getAccessToken();
|
|
90
|
+
assert.deepEqual(reused.scope, scopes);
|
|
91
|
+
assert.equal(reused.access_token, 'hotfix-test-token');
|
|
92
|
+
assert.equal(mock.history.post.length, 1);
|
|
93
|
+
} finally {
|
|
94
|
+
mock.restore();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"CustomerKey": "{{{prefix}}}dataExtensionShared",
|
|
3
|
+
"DataRetentionPeriodLength": 6,
|
|
4
|
+
"Description": "{{{description}}}",
|
|
5
|
+
"Fields": [
|
|
6
|
+
{
|
|
7
|
+
"DefaultValue": "",
|
|
8
|
+
"FieldType": "Text",
|
|
9
|
+
"IsPrimaryKey": false,
|
|
10
|
+
"IsRequired": false,
|
|
11
|
+
"MaxLength": 50,
|
|
12
|
+
"Name": "FirstName"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"DefaultValue": "",
|
|
16
|
+
"FieldType": "Text",
|
|
17
|
+
"IsPrimaryKey": false,
|
|
18
|
+
"IsRequired": false,
|
|
19
|
+
"MaxLength": 50,
|
|
20
|
+
"Name": "LastName"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"DefaultValue": "",
|
|
24
|
+
"FieldType": "EmailAddress",
|
|
25
|
+
"IsPrimaryKey": false,
|
|
26
|
+
"IsRequired": true,
|
|
27
|
+
"MaxLength": 254,
|
|
28
|
+
"Name": "EmailAddress"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"DefaultValue": "",
|
|
32
|
+
"FieldType": "Text",
|
|
33
|
+
"IsPrimaryKey": true,
|
|
34
|
+
"IsRequired": true,
|
|
35
|
+
"MaxLength": 50,
|
|
36
|
+
"Name": "ContactKey"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"IsSendable": true,
|
|
40
|
+
"IsTestable": true,
|
|
41
|
+
"Name": "{{{prefix}}}dataExtensionShared",
|
|
42
|
+
"ResetRetentionPeriodOnImport": false,
|
|
43
|
+
"SendableDataExtensionField": {
|
|
44
|
+
"Name": "ContactKey"
|
|
45
|
+
},
|
|
46
|
+
"SendableSubscriberField": {
|
|
47
|
+
"Name": "Subscriber Key"
|
|
48
|
+
},
|
|
49
|
+
"c__dataRetentionPeriodUnitOfMeasure": "Months",
|
|
50
|
+
"c__retentionPolicy": "individialRecords",
|
|
51
|
+
"r__folder_ContentType": "shared_dataextension",
|
|
52
|
+
"r__folder_Path": "Shared Items/Shared Data Extensions"
|
|
53
|
+
}
|
|
@@ -70,6 +70,23 @@
|
|
|
70
70
|
"targetUpdateTypeName": "Overwrite",
|
|
71
71
|
"categoryId": 999,
|
|
72
72
|
"isFrozen": false
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"queryDefinitionId": "shared-607c-4940-afef-437965094dat",
|
|
76
|
+
"name": "testExisting_query_SharedDE",
|
|
77
|
+
"key": "testExisting_query_SharedDE",
|
|
78
|
+
"description": "bla bla",
|
|
79
|
+
"queryText": "Select\n SubscriberKey as testField, Trim(last_name) AS name\nFrom\n testExisting_dataExtensionShared\nwhere\n country in ('test')\n",
|
|
80
|
+
"targetName": "testExisting_dataExtensionShared",
|
|
81
|
+
"targetKey": "testExisting_dataExtensionShared",
|
|
82
|
+
"targetId": "21711373-72c1-ec11-b83b-shared",
|
|
83
|
+
"targetDescription": "",
|
|
84
|
+
"createdDate": "2022-04-26T15:21:16.453",
|
|
85
|
+
"modifiedDate": "2022-04-26T16:02:44.01",
|
|
86
|
+
"targetUpdateTypeId": 0,
|
|
87
|
+
"targetUpdateTypeName": "Overwrite",
|
|
88
|
+
"categoryId": 999,
|
|
89
|
+
"isFrozen": false
|
|
73
90
|
}
|
|
74
91
|
]
|
|
75
92
|
}
|