From 3a2da968abf4e3332291e33cac6919025cfa39b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 6 Jun 2023 07:05:49 +0200 Subject: [PATCH] #964: define actual maxKeyLength per type --- lib/metadataTypes/MetadataType.js | 13 +++++++------ lib/metadataTypes/definitions/Asset.definition.js | 1 + .../definitions/Automation.definition.js | 1 + .../definitions/DataExtension.definition.js | 1 + .../definitions/DataExtract.definition.js | 1 + .../definitions/EmailSend.definition.js | 1 + lib/metadataTypes/definitions/Event.definition.js | 1 + lib/metadataTypes/definitions/Filter.definition.js | 1 + .../definitions/ImportFile.definition.js | 1 + .../definitions/MobileKeyword.definition.js | 1 + lib/metadataTypes/definitions/Query.definition.js | 1 + lib/metadataTypes/definitions/Role.definition.js | 1 + .../definitions/TriggeredSend.definition.js | 1 + lib/metadataTypes/definitions/User.definition.js | 1 + 14 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/metadataTypes/MetadataType.js b/lib/metadataTypes/MetadataType.js index 58d1d48f4..92b1686de 100644 --- a/lib/metadataTypes/MetadataType.js +++ b/lib/metadataTypes/MetadataType.js @@ -656,6 +656,7 @@ class MetadataType { metadataMap[metadataKey][this.definition.keyField] ); // Update if it already exists; Create it if not + const maxKeyLength = this.definition.maxKeyLength || 36; if ( Util.logger.level === 'debug' && metadataMap[metadataKey][this.definition.idField] && @@ -709,11 +710,11 @@ class MetadataType { // NOTE: trim twice while getting the newKey value to remove leading spaces before limiting the length const newKey = (metadataMap[metadataKey][Util.OPTIONS.changeKeyField] + '') .trim() - .slice(0, 36) + .slice(0, maxKeyLength) .trim(); - if (metadataMap[metadataKey][Util.OPTIONS.changeKeyField] + '' > 36) { + if (metadataMap[metadataKey][Util.OPTIONS.changeKeyField] + '' > maxKeyLength) { Util.logger.warn( - `Customer Keys may not exceed 36 characters. Truncated the value in field ${Util.OPTIONS.changeKeyField} to ${newKey}` + `${this.definition.type} ${this.definition.keyField} may not exceed ${maxKeyLength} characters. Truncated the value in field ${Util.OPTIONS.changeKeyField} to ${newKey}` ); } if (metadataKey == newKey) { @@ -733,10 +734,10 @@ class MetadataType { } } else if (Util.OPTIONS.changeKeyValue) { // NOTE: trim twice while getting the newKey value to remove leading spaces before limiting the length - const newKey = Util.OPTIONS.changeKeyValue.trim().slice(0, 36).trim(); - if (Util.OPTIONS.changeKeyValue.trim().length > 36) { + const newKey = Util.OPTIONS.changeKeyValue.trim().slice(0, maxKeyLength).trim(); + if (Util.OPTIONS.changeKeyValue.trim().length > maxKeyLength) { Util.logger.warn( - `Customer Keys may not exceed 36 characters. Truncated your value to ${newKey}` + `${this.definition.type} ${this.definition.keyField} may not exceed ${maxKeyLength} characters. Truncated your value to ${newKey}` ); } if (this.definition.keyField == this.definition.idField) { diff --git a/lib/metadataTypes/definitions/Asset.definition.js b/lib/metadataTypes/definitions/Asset.definition.js index ad6007658..96d427258 100644 --- a/lib/metadataTypes/definitions/Asset.definition.js +++ b/lib/metadataTypes/definitions/Asset.definition.js @@ -13,6 +13,7 @@ module.exports = { lastmodDateField: 'modifiedDate', lastmodNameField: 'modifiedBy.name', restPagination: true, + maxKeyLength: 36, // confirmed max length type: 'asset', typeDescription: 'Assets from Content Builder grouped into subtypes.', typeRetrieveByDefault: ['asset', 'code', 'textfile', 'block', 'message', 'template', 'other'], diff --git a/lib/metadataTypes/definitions/Automation.definition.js b/lib/metadataTypes/definitions/Automation.definition.js index 9f8560b49..c7ab19a19 100644 --- a/lib/metadataTypes/definitions/Automation.definition.js +++ b/lib/metadataTypes/definitions/Automation.definition.js @@ -47,6 +47,7 @@ module.exports = { lastmodDateField: 'lastSavedDate', lastmodNameField: 'lastSavedByName', restPagination: true, + maxKeyLength: 200, // confirmed max length statusMapping: { AwaitingTrigger: 7, Building: 1, diff --git a/lib/metadataTypes/definitions/DataExtension.definition.js b/lib/metadataTypes/definitions/DataExtension.definition.js index ff68df684..67a224d45 100644 --- a/lib/metadataTypes/definitions/DataExtension.definition.js +++ b/lib/metadataTypes/definitions/DataExtension.definition.js @@ -96,6 +96,7 @@ module.exports = { lastmodDateField: 'ModifiedDate', lastmodNameField: null, restPagination: false, + maxKeyLength: 200, // confirmed max length type: 'dataExtension', typeDescription: 'Database table schemas.', typeRetrieveByDefault: true, diff --git a/lib/metadataTypes/definitions/DataExtract.definition.js b/lib/metadataTypes/definitions/DataExtract.definition.js index 4736cc7d8..0b0f009e8 100644 --- a/lib/metadataTypes/definitions/DataExtract.definition.js +++ b/lib/metadataTypes/definitions/DataExtract.definition.js @@ -11,6 +11,7 @@ module.exports = { lastmodNameField: 'modifiedBy', nameField: 'name', restPagination: true, + maxKeyLength: 36, // confirmed max length type: 'dataExtract', typeDescription: 'Creates zipped files in your FTP directory or convert XML into CSV.', typeRetrieveByDefault: true, diff --git a/lib/metadataTypes/definitions/EmailSend.definition.js b/lib/metadataTypes/definitions/EmailSend.definition.js index d8a8241fe..9be557b4e 100644 --- a/lib/metadataTypes/definitions/EmailSend.definition.js +++ b/lib/metadataTypes/definitions/EmailSend.definition.js @@ -14,6 +14,7 @@ module.exports = { lastmodDateField: 'ModifiedDate', lastmodNameField: null, restPagination: null, + maxKeyLength: 36, // confirmed max length type: 'emailSend', soapType: 'emailSendDefinition', typeDescription: 'Mainly used in Automations as "Send Email Activity".', diff --git a/lib/metadataTypes/definitions/Event.definition.js b/lib/metadataTypes/definitions/Event.definition.js index 9a923af67..b2217d881 100644 --- a/lib/metadataTypes/definitions/Event.definition.js +++ b/lib/metadataTypes/definitions/Event.definition.js @@ -11,6 +11,7 @@ module.exports = { lastmodDateField: 'modifiedDate', lastmodNameField: 'modifiedBy', restPagination: true, + maxKeyLength: 200, // confirmed max length type: 'event', typeDescription: 'Used in Journeys (Interactions) to define Entry Events.', typeRetrieveByDefault: true, diff --git a/lib/metadataTypes/definitions/Filter.definition.js b/lib/metadataTypes/definitions/Filter.definition.js index e93ccfb01..ef6499104 100644 --- a/lib/metadataTypes/definitions/Filter.definition.js +++ b/lib/metadataTypes/definitions/Filter.definition.js @@ -11,6 +11,7 @@ module.exports = { lastmodDateField: 'modifiedDate', lastmodNameField: null, restPagination: true, + maxKeyLength: 36, // confirmed max length type: 'filter', typeDescription: 'BETA: Part of how filtered Data Extensions are created. Depends on type "FilterDefinitions".', diff --git a/lib/metadataTypes/definitions/ImportFile.definition.js b/lib/metadataTypes/definitions/ImportFile.definition.js index 27bf5c20c..b1938c785 100644 --- a/lib/metadataTypes/definitions/ImportFile.definition.js +++ b/lib/metadataTypes/definitions/ImportFile.definition.js @@ -22,6 +22,7 @@ module.exports = { DataExtension: 255, Email: 0, }, + maxKeyLength: 36, // confirmed max length type: 'importFile', typeDescription: 'Reads files in FTP directory for further processing.', typeRetrieveByDefault: true, diff --git a/lib/metadataTypes/definitions/MobileKeyword.definition.js b/lib/metadataTypes/definitions/MobileKeyword.definition.js index 72ac918af..5108ae965 100644 --- a/lib/metadataTypes/definitions/MobileKeyword.definition.js +++ b/lib/metadataTypes/definitions/MobileKeyword.definition.js @@ -12,6 +12,7 @@ module.exports = { lastmodNameField: null, restPagination: true, restPageSize: 50, + maxKeyLength: 50, // assumed max length type: 'mobileKeyword', typeDescription: 'Used for managing subscriptions for Mobile numbers in Mobile Connect', typeRetrieveByDefault: true, diff --git a/lib/metadataTypes/definitions/Query.definition.js b/lib/metadataTypes/definitions/Query.definition.js index adfbff659..98d047421 100644 --- a/lib/metadataTypes/definitions/Query.definition.js +++ b/lib/metadataTypes/definitions/Query.definition.js @@ -21,6 +21,7 @@ module.exports = { Overwrite: 0, Update: 1, }, + maxKeyLength: 36, // confirmed max length type: 'query', typeDescription: 'Select & transform data using SQL.', typeRetrieveByDefault: true, diff --git a/lib/metadataTypes/definitions/Role.definition.js b/lib/metadataTypes/definitions/Role.definition.js index d6de32622..0f5a6c0b6 100644 --- a/lib/metadataTypes/definitions/Role.definition.js +++ b/lib/metadataTypes/definitions/Role.definition.js @@ -23,6 +23,7 @@ module.exports = { createdNameField: null, lastmodDateField: 'ModifiedDate', lastmodNameField: null, + maxKeyLength: 36, // confirmed max length type: 'role', typeDescription: 'User Roles define groups that are used to grant users access to SFMC systems.', diff --git a/lib/metadataTypes/definitions/TriggeredSend.definition.js b/lib/metadataTypes/definitions/TriggeredSend.definition.js index 789afad7f..e5afad57e 100644 --- a/lib/metadataTypes/definitions/TriggeredSend.definition.js +++ b/lib/metadataTypes/definitions/TriggeredSend.definition.js @@ -21,6 +21,7 @@ module.exports = { lastmodDateField: 'ModifiedDate', lastmodNameField: null, restPagination: null, + maxKeyLength: 36, // confirmed max length type: 'triggeredSend', soapType: 'triggeredSendDefinition', typeDescription: 'DEPRECATED: Sends emails via API or DataExtension Event.', diff --git a/lib/metadataTypes/definitions/User.definition.js b/lib/metadataTypes/definitions/User.definition.js index 34d3b5e0b..34fea1006 100644 --- a/lib/metadataTypes/definitions/User.definition.js +++ b/lib/metadataTypes/definitions/User.definition.js @@ -12,6 +12,7 @@ module.exports = { createdNameField: null, lastmodDateField: 'ModifiedDate', lastmodNameField: 'Client.ModifiedBy', + maxKeyLength: 50, // confirmed max length type: 'user', soapType: 'AccountUser', typeDescription: 'Marketing Cloud users',