mcdev 9.0.3 → 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/workflows/code-test.yml +3 -3
- package/.github/workflows/npm-publish.yml +20 -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 +2 -2
- package/@types/lib/metadataTypes/DataExtension.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/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/MetadataType.d.ts +6 -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/util/cache.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/metadataTypes/Automation.js +2 -2
- package/lib/metadataTypes/DataExtension.js +1 -1
- package/lib/metadataTypes/Event.js +3 -3
- package/lib/metadataTypes/Folder.js +2 -2
- package/lib/metadataTypes/ImportFile.js +1 -1
- package/lib/metadataTypes/MetadataType.js +3 -3
- package/lib/metadataTypes/SenderProfile.js +1 -1
- package/lib/util/auth.js +7 -2
- package/lib/util/cache.js +5 -3
- package/lib/util/util.js +17 -15
- package/lib/util/validations.js +2 -2
- package/package.json +4 -4
- package/test/mock-fs-windows.test.js +54 -0
- package/test/mockRoot/.mcdev-validations.js +3 -3
- package/test/release-hotfix.test.js +97 -0
- package/test/utils.js +4 -1
- package/types/mcdev.d.js +13 -7
|
@@ -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
|
+
});
|
package/test/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import File from '../lib/util/file.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
3
4
|
import MockAdapter from 'axios-mock-adapter';
|
|
4
5
|
import { axiosInstance } from '../node_modules/sfmc-sdk/lib/util.js';
|
|
5
6
|
import handler from '../lib/index.js';
|
|
@@ -226,6 +227,8 @@ export function mockSetup(isDeploy) {
|
|
|
226
227
|
.onAny(new RegExp(`^${escapeRegExp(restUrl)}`))
|
|
227
228
|
.reply((config) => handleRESTRequest(config));
|
|
228
229
|
const fsMockConf = {
|
|
230
|
+
// Conf sessions may live on a different drive than cwd and the temp directory.
|
|
231
|
+
[path.parse(process.env.APPDATA || os.homedir()).root]: {},
|
|
229
232
|
'.beautyamp.json': fsmock.load(
|
|
230
233
|
path.resolve(__dirname, '../boilerplate/files/.beautyamp.json')
|
|
231
234
|
),
|
|
@@ -336,7 +339,7 @@ export function getRestCallout(method, url, returnAll = false) {
|
|
|
336
339
|
/**
|
|
337
340
|
* helper for filter/find
|
|
338
341
|
*
|
|
339
|
-
* @param {
|
|
342
|
+
* @param {import('axios').AxiosRequestConfig} item history item
|
|
340
343
|
* @returns {boolean} if item matches
|
|
341
344
|
*/
|
|
342
345
|
function findCallout(item) {
|
package/types/mcdev.d.js
CHANGED
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @typedef {
|
|
19
|
+
* @typedef {Record<string, unknown> | object} MetadataTypeItem generic metadata item
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
20
23
|
* @typedef {Object.<string, MetadataTypeItem>} MetadataTypeMap key=customer key
|
|
21
24
|
* @typedef {Object.<string, MetadataTypeMap>} MultiMetadataTypeMap key=Supported MetadataType
|
|
22
25
|
* @typedef {Object.<string, MetadataTypeItem[]>} MultiMetadataTypeList key=Supported MetadataType
|
|
@@ -77,7 +80,10 @@
|
|
|
77
80
|
*/
|
|
78
81
|
|
|
79
82
|
/**
|
|
80
|
-
* @typedef {
|
|
83
|
+
* @typedef {MetadataTypeItem} AssetItem
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
81
87
|
* @typedef {Object.<string, AssetItem>} AssetMap
|
|
82
88
|
* @typedef {'archive'|'asset'|'audio'|'block'|'code'|'document'|'image'|'message'|'other'|'rawimage'|'template'|'textfile'|'video'} AssetSubType
|
|
83
89
|
*/
|
|
@@ -250,8 +256,8 @@
|
|
|
250
256
|
* @property {number} [timezoneId] see this.definition.timeZoneMapping
|
|
251
257
|
* @property {number} [timeZoneId] same as timezoneId but returned by legacy-API; see this.definition.timeZoneMapping
|
|
252
258
|
* @property {number} [rangeTypeId] ?
|
|
253
|
-
* @property {
|
|
254
|
-
* @property {
|
|
259
|
+
* @property {unknown} [pattern] ?
|
|
260
|
+
* @property {unknown} [scheduledTime] ?
|
|
255
261
|
* @property {string} [scheduledStatus] ?
|
|
256
262
|
*/
|
|
257
263
|
|
|
@@ -294,7 +300,7 @@
|
|
|
294
300
|
* @property {string} [CustomerKey] key (SOAP API)
|
|
295
301
|
* @property {string} [name] name (Rest API)
|
|
296
302
|
* @property {string} [Name] name (SOAP API)
|
|
297
|
-
* @property {
|
|
303
|
+
* @property {{type: string, email: string | string[], message?: string}[]} [notifications] notifications
|
|
298
304
|
* @property {string} [description] -
|
|
299
305
|
* @property {'scheduled'|'triggered'|'automationtriggered'} [type] Starting Source = Schedule / File Drop
|
|
300
306
|
* @property {'scheduled'|'triggered'|'automationtriggered'} [automationType] Starting Source = Schedule / File Drop; from legacy api
|
|
@@ -487,7 +493,7 @@
|
|
|
487
493
|
* @typedef {object} SoapRequestParams
|
|
488
494
|
* @property {string} [continueRequest] request id
|
|
489
495
|
* @property {object} [options] additional options (CallsInConversation, Client, ConversationID, Priority, RequestType, SaveOptions, ScheduledTime, SendResponseTo, SequenceCode)
|
|
490
|
-
* @property {
|
|
496
|
+
* @property {unknown} [clientIDs] ?
|
|
491
497
|
* @property {SoapSDKFilter} [filter] simple or complex
|
|
492
498
|
complex
|
|
493
499
|
* @property {boolean} [QueryAllAccounts] all BUs or just one
|
|
@@ -529,7 +535,7 @@ complex
|
|
|
529
535
|
* @typedef {object} AssetRequestParams
|
|
530
536
|
* @property {string} [continueRequest] request id
|
|
531
537
|
* @property {object} [options] additional options (CallsInConversation, Client, ConversationID, Priority, RequestType, SaveOptions, ScheduledTime, SendResponseTo, SequenceCode)
|
|
532
|
-
* @property {
|
|
538
|
+
* @property {unknown} [clientIDs] ?
|
|
533
539
|
complex
|
|
534
540
|
* @property {object} [page] pagination
|
|
535
541
|
* @property {string[]} [fields] list of fields we want returned
|