Skip to content

Commit

Permalink
Merge pull request #2006 from Accenture/task/2005-resolve-locationtyp…
Browse files Browse the repository at this point in the history
…eid-on-filelocation

task/2005 resolve locationTypeId on fileLocation
  • Loading branch information
JoernBerkefeld authored Jan 21, 2025
2 parents 70dd9e9 + 1989c34 commit 0062a70
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 13 deletions.
44 changes: 39 additions & 5 deletions @types/lib/metadataTypes/FileLocation.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/FileLocation.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions @types/lib/metadataTypes/definitions/FileLocation.definition.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 43 additions & 5 deletions lib/metadataTypes/FileLocation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import MetadataType from './MetadataType.js';
import { Util } from '../util/util.js';

/**
* @typedef {import('../../types/mcdev.d.js').BuObject} BuObject
Expand All @@ -20,10 +21,10 @@ import MetadataType from './MetadataType.js';
*
* @augments MetadataType
*/
class FtpLocation extends MetadataType {
class FileLocation extends MetadataType {
/**
* Retrieves Metadata of FtpLocation
* Endpoint /automation/v1/ftplocations/ return all FtpLocations
* Retrieves Metadata of FileLocation
* Endpoint /automation/v1/ftplocations/ return all FileLocations
*
* @param {string} retrieveDir Directory where retrieved metadata directory will be saved
* @param {void | string[]} [_] unused parameter
Expand All @@ -43,10 +44,47 @@ class FtpLocation extends MetadataType {
static async retrieveForCache() {
return super.retrieveREST(null, '/automation/v1/ftplocations/');
}

/**
* prepares a import definition for deployment
*
* @param {MetadataTypeItem} metadata a single importDef
* @returns {Promise.<MetadataTypeItem>} Promise
*/
static async preDeployTasks(metadata) {
if (metadata.c__locationType) {
metadata.locationTypeId = this.definition.locationTypeMapping[metadata.c__locationType];
}
return metadata;
}

/**
* manages post retrieve steps
*
* @param {MetadataTypeItem} metadata a single item
* @returns {MetadataTypeItem} parsed metadata
*/
static postRetrieveTasks(metadata) {
if (metadata.locationTypeId) {
try {
metadata.c__locationType = Util.inverseGet(
this.definition.locationTypeMapping,
metadata.locationTypeId
);
delete metadata.locationTypeId;
} catch {
Util.logger.info(
'Please report this new & unknown locationTypeId to the mcdev developer team via github: ' +
metadata.locationTypeId
);
}
}
return metadata;
}
}

// Assign definition to static attributes
import MetadataTypeDefinitions from '../MetadataTypeDefinitions.js';
FtpLocation.definition = MetadataTypeDefinitions.fileLocation;
FileLocation.definition = MetadataTypeDefinitions.fileLocation;

export default FtpLocation;
export default FileLocation;
24 changes: 22 additions & 2 deletions lib/metadataTypes/definitions/FileLocation.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ export default {
'Used for export or import of files to/from Marketing Cloud. Previously this was labeled ftpLocation.',
typeRetrieveByDefault: true,
typeName: 'File Location',
locationTypeMapping: {
'Enhanced FTP Site Import Directory': 0,
'External FTP Site': 1,
'External SFTP Site': 2,
'External FTPS Site': 3,
'Salesforce Objects and Reports': 4,
Safehouse: 5,
'Enhanced FTP Site Export Directory': 6,
'Legacy Import Directory': 8,
'Relative location under FTP Site': 9,
'Amazon Simple Storage Service': 13,
'Azure Blob Storage': 15,
'Google Cloud Storage': 16,
},
fields: {
id: {
isCreateable: false,
Expand All @@ -34,19 +48,25 @@ export default {
isCreateable: false,
isUpdateable: false,
retrieving: true,
template: false,
template: true,
},
name: {
isCreateable: false,
isUpdateable: false,
retrieving: true,
template: false,
template: true,
},
relPath: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
c__locationType: {
isCreateable: false,
isUpdateable: false,
retrieving: true,
template: true,
},
},
};

0 comments on commit 0062a70

Please sign in to comment.