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.
Files changed (82) hide show
  1. package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
  2. package/.github/copilot-instructions.md +85 -0
  3. package/.github/pr-labeler.yml +3 -3
  4. package/.github/workflows/code-test.yml +3 -3
  5. package/.github/workflows/coverage-base-update.yml +2 -2
  6. package/.github/workflows/coverage.yml +1 -1
  7. package/.github/workflows/npm-publish.yml +71 -3
  8. package/.github/workflows/sync-milestone.yml +55 -0
  9. package/.husky/post-checkout +1 -1
  10. package/@types/lib/Retriever.d.ts.map +1 -1
  11. package/@types/lib/metadataTypes/Asset.d.ts +0 -21
  12. package/@types/lib/metadataTypes/Asset.d.ts.map +1 -1
  13. package/@types/lib/metadataTypes/Automation.d.ts +11 -2
  14. package/@types/lib/metadataTypes/Automation.d.ts.map +1 -1
  15. package/@types/lib/metadataTypes/DataExtension.d.ts +4 -2
  16. package/@types/lib/metadataTypes/DataExtension.d.ts.map +1 -1
  17. package/@types/lib/metadataTypes/DataExtensionField.d.ts +25 -0
  18. package/@types/lib/metadataTypes/DataExtensionField.d.ts.map +1 -1
  19. package/@types/lib/metadataTypes/Event.d.ts +6 -6
  20. package/@types/lib/metadataTypes/Event.d.ts.map +1 -1
  21. package/@types/lib/metadataTypes/Filter.d.ts +1 -1
  22. package/@types/lib/metadataTypes/Folder.d.ts +12 -4
  23. package/@types/lib/metadataTypes/Folder.d.ts.map +1 -1
  24. package/@types/lib/metadataTypes/ImportFile.d.ts +2 -2
  25. package/@types/lib/metadataTypes/ImportFile.d.ts.map +1 -1
  26. package/@types/lib/metadataTypes/Journey.d.ts.map +1 -1
  27. package/@types/lib/metadataTypes/MetadataType.d.ts +16 -6
  28. package/@types/lib/metadataTypes/MetadataType.d.ts.map +1 -1
  29. package/@types/lib/metadataTypes/SenderProfile.d.ts +7 -2
  30. package/@types/lib/metadataTypes/SenderProfile.d.ts.map +1 -1
  31. package/@types/lib/metadataTypes/definitions/Filter.definition.d.ts +1 -1
  32. package/@types/lib/util/cache.d.ts.map +1 -1
  33. package/@types/lib/util/cli.d.ts.map +1 -1
  34. package/@types/lib/util/util.d.ts +44 -26
  35. package/@types/lib/util/util.d.ts.map +1 -1
  36. package/@types/lib/util/validations.d.ts +6 -3
  37. package/@types/lib/util/validations.d.ts.map +1 -1
  38. package/@types/types/mcdev.d.d.ts +12 -12
  39. package/@types/types/mcdev.d.d.ts.map +1 -1
  40. package/README.md +6 -2
  41. package/lib/Retriever.js +2 -1
  42. package/lib/index.js +2 -2
  43. package/lib/metadataTypes/Automation.js +2 -2
  44. package/lib/metadataTypes/DataExtension.js +60 -1
  45. package/lib/metadataTypes/DataExtensionField.js +114 -0
  46. package/lib/metadataTypes/Event.js +3 -3
  47. package/lib/metadataTypes/Folder.js +2 -2
  48. package/lib/metadataTypes/ImportFile.js +1 -1
  49. package/lib/metadataTypes/Journey.js +82 -39
  50. package/lib/metadataTypes/MetadataType.js +27 -11
  51. package/lib/metadataTypes/SenderProfile.js +1 -1
  52. package/lib/metadataTypes/definitions/Filter.definition.js +2 -3
  53. package/lib/util/auth.js +7 -2
  54. package/lib/util/cache.js +5 -3
  55. package/lib/util/cli.js +3 -0
  56. package/lib/util/util.js +17 -15
  57. package/lib/util/validations.js +2 -2
  58. package/package.json +12 -12
  59. package/test/general.test.js +11 -11
  60. package/test/mock-fs-windows.test.js +54 -0
  61. package/test/mockRoot/.mcdev-validations.js +3 -3
  62. package/test/mockRoot/.mcdevrc.json +1 -1
  63. package/test/mockRoot/deploy/testInstance/testBU/journey/testExisting_journey_updatecontact_sharedDE.journey-meta.json +108 -0
  64. package/test/release-hotfix.test.js +97 -0
  65. package/test/resources/1111111/dataExtension/template_sharedDE-expected.json +53 -0
  66. package/test/resources/9999999/automation/v1/queries/get-response.json +17 -0
  67. package/test/resources/9999999/interaction/v1/interactions/get-response.json +40 -2
  68. package/test/resources/9999999/interaction/v1/interactions/key_testExisting_journey_updatecontact/get-response.json +4 -4
  69. package/test/resources/9999999/interaction/v1/interactions/key_testExisting_journey_updatecontact_sharedDE/get-response.json +119 -0
  70. package/test/resources/9999999/interaction/v1/interactions/key_testExisting_journey_updatecontact_sharedDE/put-response.json +110 -0
  71. package/test/resources/9999999/journey/get-updatecontact-sharedDE-expected.json +108 -0
  72. package/test/resources/9999999/journey/put-updatecontact-sharedDE-expected.json +108 -0
  73. package/test/resources/9999999/query/get_sharedDE-expected.json +11 -0
  74. package/test/resources/9999999/query/get_sharedDE-expected.sql +7 -0
  75. package/test/resources/9999999/query/template_sharedDE-expected.json +8 -0
  76. package/test/resources/9999999/query/template_sharedDE-expected.sql +7 -0
  77. package/test/type.attributeSet.test.js +41 -0
  78. package/test/type.automation.test.js +1 -1
  79. package/test/type.journey.test.js +108 -6
  80. package/test/type.query.test.js +105 -8
  81. package/test/utils.js +4 -1
  82. package/types/mcdev.d.js +13 -7
@@ -19,6 +19,7 @@ import { checkbox } from '@inquirer/prompts';
19
19
  * @typedef {import('../../types/mcdev.d.js').MetadataTypeMap} MetadataTypeMap
20
20
  * @typedef {import('../../types/mcdev.d.js').SoapRequestParams} SoapRequestParams
21
21
  * @typedef {import('../../types/mcdev.d.js').TemplateMap} TemplateMap
22
+ * @typedef {import('../../types/mcdev.d.js').TypeKeyCombo} TypeKeyCombo
22
23
  */
23
24
 
24
25
  /**
@@ -176,6 +177,7 @@ class DataExtension extends MetadataType {
176
177
  // Modify columns for update call
177
178
  DataExtensionField.client = this.client;
178
179
  DataExtensionField.properties = this.properties;
180
+ DataExtensionField.buObject = this.buObject;
179
181
  DataExtension.oldFields ||= {};
180
182
  DataExtension.oldFields[metadataMap[metadataKey][this.definition.keyField]] =
181
183
  await DataExtensionField.prepareDeployColumnsOnUpdate(
@@ -1384,7 +1386,7 @@ class DataExtension extends MetadataType {
1384
1386
  * Parses metadata into a readable Markdown/HTML format then saves it
1385
1387
  *
1386
1388
  * @param {DataExtensionMap} [metadataMap] a list of dataExtension definitions
1387
- * @returns {Promise.<any>} -
1389
+ * @returns {Promise.<void[] | void>} -
1388
1390
  */
1389
1391
  static async document(metadataMap) {
1390
1392
  try {
@@ -1663,6 +1665,63 @@ class DataExtension extends MetadataType {
1663
1665
  return super.getFilesToCommit(keyArr);
1664
1666
  }
1665
1667
  }
1668
+ /**
1669
+ * Hook called when dependency keys were not found in the child BU retrieve folder.
1670
+ * Checks the `_ParentBU_` folder for shared or synchronized dataExtensions and emits
1671
+ * readable warnings. Does NOT add the found items to the deployment package.
1672
+ * Only active when running on a child BU (eid !== mid).
1673
+ * Used by {@link MetadataType.getDependentFiles}.
1674
+ *
1675
+ * @param {string[]} notFound keys that were not found in the child BU retrieve folder
1676
+ * @returns {Promise.<string[]>} keys that should still trigger the default "not found" warning
1677
+ */
1678
+ static async handleNotFoundDependencies(notFound) {
1679
+ // on parent BU, shared DE check is not applicable
1680
+ if (this.buObject.eid === this.buObject.mid) {
1681
+ return notFound;
1682
+ }
1683
+ const parentBUPath = File.normalizePath([
1684
+ this.properties.directories.retrieve,
1685
+ this.buObject.credential,
1686
+ Util.parentBuName,
1687
+ this.definition.type,
1688
+ ]);
1689
+ const stillNotFound = [];
1690
+ for (const key of notFound) {
1691
+ const filePath = File.normalizePath([
1692
+ parentBUPath,
1693
+ File.filterIllegalFilenames(key) + '.' + this.definition.type + '-meta.json',
1694
+ ]);
1695
+ let metadataItem;
1696
+ try {
1697
+ metadataItem = await File.readJson(filePath);
1698
+ } catch {
1699
+ stillNotFound.push(key);
1700
+ continue;
1701
+ }
1702
+ const contentType = metadataItem.r__folder_ContentType;
1703
+ if (contentType === 'shared_dataextension') {
1704
+ Util.logger.warn(
1705
+ `dataExtension '${key}' is a shared dataExtension stored in _ParentBU_. It cannot be included in the child BU deployment package.`
1706
+ );
1707
+ Util.logger.warn(
1708
+ `References to it may need to be changed during deployment via mcdev templating or manually. To update the shared dataExtension itself, run build for the parent BU and deploy it separately.`
1709
+ );
1710
+ } else if (contentType === 'synchronizeddataextension') {
1711
+ Util.logger.warn(
1712
+ `dataExtension '${key}' is a synchronized dataExtension stored in _ParentBU_. It cannot be included in the child BU deployment package.`
1713
+ );
1714
+ Util.logger.warn(
1715
+ `The reference to it likely needs to be changed during deployment via mcdev templating or manually.`
1716
+ );
1717
+ } else {
1718
+ // regular dataExtension found on parent BU cannot be used from a child BU; treat as not found
1719
+ stillNotFound.push(key);
1720
+ }
1721
+ }
1722
+ return stillNotFound;
1723
+ }
1724
+
1666
1725
  /**
1667
1726
  * helper for {@link MetadataType.createOrUpdate}
1668
1727
  *
@@ -4,6 +4,7 @@ import MetadataType from './MetadataType.js';
4
4
  import { Util } from '../util/util.js';
5
5
  import DataExtension from './DataExtension.js';
6
6
  import { confirm } from '@inquirer/prompts';
7
+ import auth from '../util/auth.js';
7
8
 
8
9
  /**
9
10
  * @typedef {import('../../types/mcdev.d.js').BuObject} BuObject
@@ -75,6 +76,95 @@ class DataExtensionField extends MetadataType {
75
76
  }, {});
76
77
  }
77
78
 
79
+ /**
80
+ * determines if a dataExtension is shared (from parent BU) by checking its folder's ContentType in the parent BU folder cache
81
+ *
82
+ * @param {string} customerKey external key of single DE
83
+ * @returns {boolean} true if the DE is shared (stored on parent BU)
84
+ */
85
+ static isSharedDe(customerKey) {
86
+ if (this.buObject.eid === this.buObject.mid) {
87
+ // already on parent BU, no shared DEs possible
88
+ return false;
89
+ }
90
+ const categoryId = cache.getCache().dataExtension?.[customerKey]?.CategoryID;
91
+ if (!categoryId) {
92
+ return false;
93
+ }
94
+ try {
95
+ const contentType = cache.searchForField(
96
+ 'folder',
97
+ categoryId,
98
+ 'ID',
99
+ 'ContentType',
100
+ this.buObject.eid
101
+ );
102
+ return MetadataTypeDefinitions.folder.folderTypesFromParent.includes(contentType);
103
+ } catch {
104
+ // folder not found in parent BU cache → local DE
105
+ return false;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * helps retrieving fields for a single DE from parent BU.
111
+ * Use when the DE is shared (stored on parent BU) and its fields are not in the current BU's cache.
112
+ *
113
+ * @param {string} customerKey external key of single DE
114
+ * @returns {Promise.<object>} Promise of items
115
+ */
116
+ static async retrieveFieldsForSingleSharedDe(customerKey) {
117
+ if (this.buObject.eid === this.buObject.mid) {
118
+ // already on parent BU, shared retrieval is not needed - all DEs are local here
119
+ Util.logger.debug(
120
+ `DataExtensionField.retrieveFieldsForSingleSharedDe: already on parent BU, skipping for ${customerKey}`
121
+ );
122
+ return {};
123
+ }
124
+ if (!this.properties.credentials[this.buObject.credential]) {
125
+ Util.logger.error(
126
+ `DataExtensionField.retrieveFieldsForSingleSharedDe: credential '${this.buObject.credential}' not found in properties`
127
+ );
128
+ return {};
129
+ }
130
+ const buObjectBak = this.buObject;
131
+ const clientBak = this.client;
132
+ /** @type {BuObject} */
133
+ const buObjectParentBu = {
134
+ eid: this.properties.credentials[this.buObject.credential].eid,
135
+ mid: this.properties.credentials[this.buObject.credential].eid,
136
+ businessUnit: Util.parentBuName,
137
+ credential: this.buObject.credential,
138
+ };
139
+ try {
140
+ this.buObject = buObjectParentBu;
141
+ this.client = auth.getSDK(buObjectParentBu);
142
+ } catch (ex) {
143
+ Util.logger.error(ex.message);
144
+ this.buObject = buObjectBak;
145
+ this.client = clientBak;
146
+ return {};
147
+ }
148
+ const fields = await this.retrieveFieldsForSingleDe(customerKey);
149
+ // revert client to current default
150
+ this.buObject = buObjectBak;
151
+ this.client = clientBak;
152
+ return fields;
153
+ }
154
+
155
+ /**
156
+ * Routes field retrieval to the correct method depending on whether the DE is local or shared.
157
+ * Use this instead of duplicating the isSharedDe() check at each call site.
158
+ *
159
+ * @param {string} customerKey external key of single DE
160
+ * @returns {Promise.<object>} Promise of items
161
+ */
162
+ static async retrieveFieldsForSingleDeAuto(customerKey) {
163
+ return this.isSharedDe(customerKey)
164
+ ? this.retrieveFieldsForSingleSharedDe(customerKey)
165
+ : this.retrieveFieldsForSingleDe(customerKey);
166
+ }
167
+
78
168
  /**
79
169
  * Retrieves all records for caching
80
170
  *
@@ -187,6 +277,10 @@ class DataExtensionField extends MetadataType {
187
277
  // make sure we stringify the name in case it looked numeric and then lowercase it for easy comparison as the server is comparing field names case-insensitive
188
278
  existingFieldByName[(fieldsObj[key].Name + '').toLowerCase()] = fieldsObj[key];
189
279
  }
280
+ // capture field names from deploy payload before the loop modifies them (for renamed fields, the original name is used)
281
+ const deployColumnNames = new Set(
282
+ deployColumns.map((item) => (item.Name + '').toLowerCase())
283
+ );
190
284
  for (let i = deployColumns.length - 1; i >= 0; i--) {
191
285
  const item = deployColumns[i];
192
286
  // make sure we stringify the name in case it looked numeric and then lowercase it for easy comparison as the server is comparing field names case-insensitive
@@ -304,6 +398,26 @@ class DataExtensionField extends MetadataType {
304
398
  )
305
399
  );
306
400
 
401
+ // warn about fields that exist on the server but are not in the deploy payload
402
+ // these fields are NOT auto-deleted to prevent unintended data loss
403
+ const removedFieldNames = Object.values(existingFieldByName)
404
+ .filter((field) => !deployColumnNames.has((field.Name + '').toLowerCase()))
405
+ .map((field) => field.Name)
406
+ .toSorted();
407
+ if (removedFieldNames.length > 0) {
408
+ Util.logger.warn(
409
+ ` - dataExtension ${deKey}: found ${removedFieldNames.length} field${removedFieldNames.length > 1 ? 's' : ''} on the server but not in the deploy payload. Fields cannot be auto-deleted due to potential data loss. To delete them, please run:`
410
+ );
411
+ Util.logger.info(
412
+ Util.getGrayMsg(
413
+ `mcdev delete ${this.buObject.credential}/${this.buObject.businessUnit} -m ` +
414
+ removedFieldNames
415
+ .map((name) => `dataExtensionField:"${deKey}.${name}"`)
416
+ .join(' ')
417
+ )
418
+ );
419
+ }
420
+
307
421
  return existingFieldByName;
308
422
  }
309
423
 
@@ -652,11 +652,11 @@ class Event extends MetadataType {
652
652
  referencedObjects: {},
653
653
  /** @type {Object.<string, Object.<string, SfObjectField>>} object-name > field-name > field data */
654
654
  objectFields: {},
655
- /** @type {Object.<string, Promise.<any>>} */
655
+ /** @type {Object.<string, Promise.<void>>} */
656
656
  loadingFields: {},
657
- /** @type {Object.<string, Promise.<any>>} */
657
+ /** @type {Object.<string, Promise.<void>>} */
658
658
  loadingRelatedObjects: {},
659
- /** @type {Promise.<any>} */
659
+ /** @type {Promise.<void>} */
660
660
  loadingWorkflowObjects: null,
661
661
  };
662
662
 
@@ -364,7 +364,7 @@ class Folder extends MetadataType {
364
364
  * creates a folder based on metatadata
365
365
  *
366
366
  * @param {ListItem} metadataEntry metadata of the folder
367
- * @returns {Promise.<any>} Promise of api response
367
+ * @returns {Promise.<{Results?: {Object: MetadataTypeItem}[]} | undefined>} Promise of api response
368
368
  */
369
369
  static async create(metadataEntry) {
370
370
  if (metadataEntry?.ParentFolder?.ID === 0) {
@@ -486,7 +486,7 @@ class Folder extends MetadataType {
486
486
  * Updates a single Folder.
487
487
  *
488
488
  * @param {MetadataTypeItem} metadataEntry single metadata entry
489
- * @returns {Promise.<any>} Promise of api response
489
+ * @returns {Promise.<{Results?: {Object: MetadataTypeItem}[]} | undefined>} Promise of api response
490
490
  */
491
491
  static async update(metadataEntry) {
492
492
  if (metadataEntry?.ParentFolder?.ID === 0) {
@@ -102,7 +102,7 @@ class ImportFile extends MetadataType {
102
102
  * @param {SDKError} ex exception
103
103
  * @param {string} key id or key of item
104
104
  * @param {string} url url to call for retry
105
- * @returns {Promise.<any>} can return retry-result
105
+ * @returns {Promise.<MetadataTypeItem | null>} can return retry-result
106
106
  */
107
107
  static async handleRESTErrors(ex, key, url) {
108
108
  try {
@@ -1286,25 +1286,53 @@ class Journey extends MetadataType {
1286
1286
  metadata[this.definition.keyField]
1287
1287
  }) activity-key=${activity.key}: ${ex.message}`
1288
1288
  );
1289
+ continue;
1289
1290
  }
1290
1291
  // Don't replace the field Id with the name if DE CustomerKey was not found
1291
1292
  try {
1293
+ DataExtensionField.buObject = this.buObject;
1294
+ DataExtensionField.client = this.client;
1295
+ DataExtensionField.properties = this.properties;
1296
+ let alreadyFetchedDe = false;
1292
1297
  if (!cache.getCache().dataExtensionField) {
1298
+ // no dataExtensionField cache yet: retrieve fields for this specific DE
1293
1299
  tempCachedFields = true;
1294
- DataExtensionField.buObject = this.buObject;
1295
- DataExtensionField.client = this.client;
1296
- DataExtensionField.properties = this.properties;
1297
- const fields = await DataExtensionField.retrieveFieldsForSingleDe(
1298
- contactField.r__dataExtension_key
1299
- );
1300
+ alreadyFetchedDe = true;
1301
+ const fields =
1302
+ await DataExtensionField.retrieveFieldsForSingleDeAuto(
1303
+ contactField.r__dataExtension_key
1304
+ );
1300
1305
  cache.setMetadata('dataExtensionField', fields);
1301
1306
  }
1302
- contactField.r__dataExtensionField_name = cache.searchForField(
1303
- 'dataExtensionField',
1304
- contactField.field,
1305
- 'ObjectID',
1306
- 'Name'
1307
- );
1307
+ let fieldName;
1308
+ try {
1309
+ fieldName = cache.searchForField(
1310
+ 'dataExtensionField',
1311
+ contactField.field,
1312
+ 'ObjectID',
1313
+ 'Name'
1314
+ );
1315
+ } catch (ex) {
1316
+ if (alreadyFetchedDe) {
1317
+ throw ex;
1318
+ }
1319
+ // field not in existing cache - retrieve fields for this specific DE
1320
+ const fields =
1321
+ await DataExtensionField.retrieveFieldsForSingleDeAuto(
1322
+ contactField.r__dataExtension_key
1323
+ );
1324
+ if (Object.keys(fields).length > 0) {
1325
+ cache.mergeMetadata('dataExtensionField', fields);
1326
+ }
1327
+ // throws if still not found, handled by outer catch
1328
+ fieldName = cache.searchForField(
1329
+ 'dataExtensionField',
1330
+ contactField.field,
1331
+ 'ObjectID',
1332
+ 'Name'
1333
+ );
1334
+ }
1335
+ contactField.r__dataExtensionField_name = fieldName;
1308
1336
  delete contactField.field;
1309
1337
  } catch (ex) {
1310
1338
  Util.logger.warn(
@@ -1751,46 +1779,61 @@ class Journey extends MetadataType {
1751
1779
  activity?.arguments?.activityData?.updateContactFields ?? [];
1752
1780
  let tempCachedFields = false;
1753
1781
  for (const contactField of contactFields) {
1782
+ if (!contactField.r__dataExtension_key) {
1783
+ continue;
1784
+ }
1785
+ contactField.dataExtensionId = cache.searchForField(
1786
+ 'dataExtension',
1787
+ contactField.r__dataExtension_key,
1788
+ 'CustomerKey',
1789
+ 'ObjectID'
1790
+ );
1791
+ if (!contactField.r__dataExtensionField_name) {
1792
+ continue;
1793
+ }
1794
+ DataExtensionField.buObject = this.buObject;
1795
+ DataExtensionField.client = this.client;
1796
+ DataExtensionField.properties = this.properties;
1797
+ let alreadyFetchedDe = false;
1798
+ if (!cache.getCache().dataExtensionField) {
1799
+ // no dataExtensionField cache yet: retrieve fields for this specific DE
1800
+ tempCachedFields = true;
1801
+ alreadyFetchedDe = true;
1802
+ const fields = await DataExtensionField.retrieveFieldsForSingleDeAuto(
1803
+ contactField.r__dataExtension_key
1804
+ );
1805
+ cache.setMetadata('dataExtensionField', fields);
1806
+ }
1807
+ let fieldObjectId;
1754
1808
  try {
1755
- contactField.dataExtensionId = cache.searchForField(
1756
- 'dataExtension',
1757
- contactField.r__dataExtension_key,
1809
+ fieldObjectId = cache.searchForField(
1810
+ 'dataExtensionField',
1811
+ `[${contactField.r__dataExtension_key}].[${contactField.r__dataExtensionField_name}]`,
1758
1812
  'CustomerKey',
1759
1813
  'ObjectID'
1760
1814
  );
1761
1815
  } catch (ex) {
1762
- Util.logger.warn(
1763
- ` - ${this.definition.type} '${metadata[this.definition.nameField]}' (${
1764
- metadata[this.definition.keyField]
1765
- }) activity-key=${activity.key}: ${ex.message}`
1816
+ // field not in existing cache - retrieve fields for this specific DE
1817
+ if (alreadyFetchedDe) {
1818
+ throw ex;
1819
+ }
1820
+ const fields = await DataExtensionField.retrieveFieldsForSingleDeAuto(
1821
+ contactField.r__dataExtension_key
1766
1822
  );
1767
- }
1768
- try {
1769
- if (!cache.getCache().dataExtensionField) {
1770
- tempCachedFields = true;
1771
- DataExtensionField.buObject = this.buObject;
1772
- DataExtensionField.client = this.client;
1773
- DataExtensionField.properties = this.properties;
1774
- const fields = await DataExtensionField.retrieveFieldsForSingleDe(
1775
- contactField.r__dataExtension_key
1776
- );
1777
- cache.setMetadata('dataExtensionField', fields);
1823
+ if (Object.keys(fields).length > 0) {
1824
+ cache.mergeMetadata('dataExtensionField', fields);
1778
1825
  }
1779
- contactField.field = cache.searchForField(
1826
+ // throws if still not found, handled by outer catch
1827
+ fieldObjectId = cache.searchForField(
1780
1828
  'dataExtensionField',
1781
1829
  `[${contactField.r__dataExtension_key}].[${contactField.r__dataExtensionField_name}]`,
1782
1830
  'CustomerKey',
1783
1831
  'ObjectID'
1784
1832
  );
1785
- delete contactField.r__dataExtensionField_name;
1786
- delete contactField.r__dataExtension_key;
1787
- } catch (ex) {
1788
- Util.logger.warn(
1789
- ` - ${this.definition.type} '${metadata[this.definition.nameField]}'(${
1790
- metadata[this.definition.keyField]
1791
- }) activity - key=${activity.key}: ${ex.message} `
1792
- );
1793
1833
  }
1834
+ contactField.field = fieldObjectId;
1835
+ delete contactField.r__dataExtensionField_name;
1836
+ delete contactField.r__dataExtension_key;
1794
1837
  }
1795
1838
  if (tempCachedFields) {
1796
1839
  // reset dataExtensionField caching to trigger re-caching
@@ -472,7 +472,7 @@ class MetadataType {
472
472
  *
473
473
  * @param {string} key key of the item
474
474
  * @param {string} name name of the item
475
- * @param {{ type: string; key: string; name: any; }[]} namesInFolder names of the items in the same folder
475
+ * @param {{ type: string; key: string; name: string; }[]} namesInFolder names of the items in the same folder
476
476
  * @param {string} [subtype] itemType-name
477
477
  * @returns {string} new name
478
478
  */
@@ -1571,7 +1571,7 @@ class MetadataType {
1571
1571
  * @param {RestError} ex exception
1572
1572
  * @param {string} key id or key of item
1573
1573
  * @param {string} url url to call for retry
1574
- * @returns {Promise.<any>} -
1574
+ * @returns {Promise.<object | null>} -
1575
1575
  */
1576
1576
  static async handleRESTErrors(ex, key, url) {
1577
1577
  // if the ID is too short, the system will throw the 400 error
@@ -2785,14 +2785,17 @@ class MetadataType {
2785
2785
  (key) => !multiTypeKeyList[this.definition.type].includes(key)
2786
2786
  );
2787
2787
  if (notFound && notFound.length) {
2788
- Util.logger.warn(
2789
- Util.getGrayMsg(
2790
- ` ☇ skipping ${this.definition.type} dependenc${notFound.length === 1 ? 'y' : 'ies'} ${notFound.join(', ')}: Not found on your in your project folder.`
2791
- )
2792
- );
2793
- // make sure we don't search for it twice
2794
- notFoundList[this.definition.type] ||= [];
2795
- notFoundList[this.definition.type].push(...notFound);
2788
+ const remainingNotFound = await this.handleNotFoundDependencies(notFound);
2789
+ if (remainingNotFound.length) {
2790
+ Util.logger.warn(
2791
+ Util.getGrayMsg(
2792
+ ` ☇ skipping ${this.definition.type} dependenc${remainingNotFound.length === 1 ? 'y' : 'ies'} ${remainingNotFound.join(', ')}: Not found on your in your project folder.`
2793
+ )
2794
+ );
2795
+ // make sure we don't search for it twice
2796
+ notFoundList[this.definition.type] ||= [];
2797
+ notFoundList[this.definition.type].push(...remainingNotFound);
2798
+ }
2796
2799
  }
2797
2800
  return multiTypeKeyList;
2798
2801
  }
@@ -2805,6 +2808,19 @@ class MetadataType {
2805
2808
  */
2806
2809
  static getDependentFilesExtra(metadataItem, dependentTypeKeyCombo) {}
2807
2810
 
2811
+ /**
2812
+ * Hook called when dependency keys were not found in the primary retrieve folder.
2813
+ * Override in subtypes to show type-specific warnings (e.g. shared/synchronized dataExtensions).
2814
+ * Keys returned by this method still receive the generic "not found" warning.
2815
+ * Used by {@link MetadataType.getDependentFiles}.
2816
+ *
2817
+ * @param {string[]} notFound keys that could not be found in the retrieve folder
2818
+ * @returns {Promise.<string[]>} keys that should still trigger the default "not found" warning
2819
+ */
2820
+ static async handleNotFoundDependencies(notFound) {
2821
+ return notFound;
2822
+ }
2823
+
2808
2824
  /**
2809
2825
  * helper for {@link MetadataType.getDependentFiles}
2810
2826
  *
@@ -2826,7 +2842,7 @@ class MetadataType {
2826
2842
  /**
2827
2843
  * helper for {@link MetadataType.getNestedValue}
2828
2844
  *
2829
- * @param {any} obj the metadataItem to search in (or the result)
2845
+ * @param {unknown} obj the metadataItem to search in (or the result)
2830
2846
  * @param {string[]} nestedKeyParts key in dot-notation split into parts
2831
2847
  * @param {string} dependentType used for types that need custom handling
2832
2848
  * @returns {(string) | (string)[]} result
@@ -132,7 +132,7 @@ class SenderProfile extends MetadataType {
132
132
  *
133
133
  * @param {MetadataTypeItem} metadata a single item
134
134
  * @param {MetadataTypeItem} [metadataCaller] if called from SendClassification this can be used to adjust logs
135
- * @param {any} [definition] type defintiion from SendClassification
135
+ * @param {{type: string, typeName: string, keyField: string, nameField: string}} [definition] type defintiion from SendClassification
136
136
  */
137
137
  static verifySenderEmailAddresses(metadata, metadataCaller, definition) {
138
138
  if (!metadataCaller) {
@@ -9,7 +9,7 @@ export default {
9
9
  'folder-hidden',
10
10
  ],
11
11
  dependencyGraph: {
12
- filterDefinition: ['r__dataFilter_key'],
12
+ dataFilter: ['r__dataFilter_key'],
13
13
  dataExtension: ['r__source_dataExtension_key', 'r__destination_dataExtension_key'],
14
14
  },
15
15
  hasExtended: false,
@@ -30,8 +30,7 @@ export default {
30
30
  maxKeyLength: 36, // confirmed max length
31
31
  type: 'filter',
32
32
  soapType: 'FilterActivity',
33
- typeDescription:
34
- 'Used in automations to filter lists and DEs. Depends on type "FilterDefinitions".',
33
+ typeDescription: 'Used in automations to filter lists and DEs. Depends on type "DataFilter".',
35
34
  typeRetrieveByDefault: true,
36
35
  typeCdpByDefault: true,
37
36
  typeName: 'Automation: Filter Activity',
package/lib/util/auth.js CHANGED
@@ -110,7 +110,11 @@ const Auth = {
110
110
  * @returns {SDK} auth object
111
111
  */
112
112
  function setupSDK(sessionKey, authObject) {
113
- return new SDK(authObject, {
113
+ // SDK 4 declarations require a token and string MID, but its runtime accepts cold credentials and numeric MIDs.
114
+ const sdkAuth = /** @type {ConstructorParameters<typeof SDK>[0]} */ (
115
+ /** @type {unknown} */ (authObject)
116
+ );
117
+ return new SDK(sdkAuth, {
114
118
  eventHandlers: {
115
119
  onLoop: (type, accumulator) => {
116
120
  Util.logger.info(
@@ -184,7 +188,8 @@ function setupSDK(sessionKey, authObject) {
184
188
  const msg =
185
189
  typeof res.data == 'string' ? res.data : JSON.stringify(res.data, null, 2);
186
190
  if (Util.OPTIONS.api === 'cli') {
187
- console.log(`${Util.color.fgMagenta}API RESPONSE <<${Util.color.reset}`, msg); // eslint-disable-line no-console
191
+ // eslint-disable-next-line no-console -- API debugging output is explicitly requested by the CLI option.
192
+ console.log(`${Util.color.fgMagenta}API RESPONSE <<${Util.color.reset}`, msg);
188
193
  } else if (Util.OPTIONS.api === 'log') {
189
194
  Util.logger.debug('API RESPONSE body << \n ' + msg);
190
195
  }
package/lib/util/cache.js CHANGED
@@ -158,9 +158,11 @@ export default {
158
158
  dataStore[overrideMID || currentMID][metadataType][key]
159
159
  )
160
160
  ) {
161
- return Util.resolveObjPath(
162
- returnField,
163
- dataStore[overrideMID || currentMID][metadataType][key]
161
+ return /** @type {string} */ (
162
+ Util.resolveObjPath(
163
+ returnField,
164
+ dataStore[overrideMID || currentMID][metadataType][key]
165
+ )
164
166
  );
165
167
  } else {
166
168
  throw new Error(); // eslint-disable-line unicorn/error-message
package/lib/util/cli.js CHANGED
@@ -87,6 +87,9 @@ const Cli = {
87
87
  return true;
88
88
  } else if (Util.isFalse(Util.skipInteraction?.fixKeysReretrieve)) {
89
89
  return false;
90
+ } else if (Util.skipInteraction) {
91
+ // generic --yes / --skipInteraction: use the confirm default (true = do re-retrieve)
92
+ return true;
90
93
  } else {
91
94
  const fixKeysReretrieve = await confirm({
92
95
  message: `Do you want to re-retrieve dependent types (${dependentTypes.join(