Skip to content

Commit

Permalink
Merge pull request #1385 from Accenture/bug/1377-data-extension-folde…
Browse files Browse the repository at this point in the history
…r-creation-bug-700

Bug/1377 data extension folder creation bug 700
  • Loading branch information
JoernBerkefeld authored Jun 26, 2024
2 parents 9c8f436 + 2fd179a commit 65ae7d1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
1 change: 1 addition & 0 deletions @types/lib/metadataTypes/Folder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ declare namespace Folder {
dependencies: any[];
subTypes: string[];
deployFolderTypes: string[];
deployFolderTypesRest: string[];
deployFolderBlacklist: string[];
folderTypesFromParent: string[];
hasExtended: boolean;
Expand Down
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Folder.d.ts.map

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

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare namespace _default {
let dependencies: any[];
let subTypes: string[];
let deployFolderTypes: string[];
let deployFolderTypesRest: string[];
let deployFolderBlacklist: string[];
let folderTypesFromParent: string[];
let hasExtended: boolean;
Expand Down
53 changes: 33 additions & 20 deletions lib/metadataTypes/Folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,29 +351,42 @@ class Folder extends MetadataType {
}
const path = metadataEntry.Path;
try {
// * We tried using the SOAP endpoint for creating folders but that did not support folders for automations nor journeys. This rest endpoint seems to cover everything though
const restPayload = {
parentCatId: metadataEntry.ParentFolder.ID,
name: metadataEntry.Name,
catType: metadataEntry.ContentType,
};
const response = await super.createREST(restPayload, '/email/v1/category', true);
if (response?.objectId) {
// convert the response to the same format as the SOAP response
metadataEntry.ID = response.objectId;
// the following is a bit of a hack to make the response look like the SOAP response; not sure if we actually need that anywhere like this --> future developers feel free to double check
const returnObject = {
Results: [
{
Object: metadataEntry,
},
],
if (this.definition.deployFolderTypesRest.includes(metadataEntry.ContentType)) {
// * The SOAP endpoint for creating folders does not support folders for automations nor journeys. The Rest endpoint on the other hand errors out on certain characters in the folder names that are actually valid. We therefore only use Rest for the folder types that are not supported by SOAP.
const restPayload = {
parentCatId: metadataEntry.ParentFolder.ID,
name: metadataEntry.Name,
catType: metadataEntry.ContentType,
};
const response = await super.createREST(restPayload, '/email/v1/category', true);
if (response?.objectId) {
// convert the response to the same format as the SOAP response
metadataEntry.ID = response.objectId;
// the following is a bit of a hack to make the response look like the SOAP response; not sure if we actually need that anywhere like this --> future developers feel free to double check
const returnObject = {
Results: [
{
Object: metadataEntry,
},
],
};

Util.logger.info(` - created folder: ${path}`);
return returnObject;
Util.logger.info(` - created folder: ${path}`);
return returnObject;
} else {
throw new Error(response);
}
} else {
throw new Error(response);
const response = await super.createSOAP(metadataEntry, true);
if (response) {
response.Results[0].Object = metadataEntry;
response.Results[0].Object.ID = response.Results[0].NewID;
response.Results[0].Object.CustomerKey = metadataEntry.CustomerKey;
delete response.Results[0].Object.$;

Util.logger.info(` - created folder: ${path}`);
return response;
}
}
} catch (ex) {
if (ex?.results) {
Expand Down
2 changes: 2 additions & 0 deletions lib/metadataTypes/definitions/Folder.definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
subTypes: [
'asset-shared',
'asset',
'automations',
'contextual_suppression_list',
'dataextension',
'filteractivity',
Expand Down Expand Up @@ -52,6 +53,7 @@ export default {
'triggered_send_journeybuilder',
'triggered_send',
],
deployFolderTypesRest: ['automations', 'journey', 'triggered_send_journeybuilder'],
deployFolderBlacklist: [
// lower-case values!
'shared data extensions',
Expand Down

0 comments on commit 65ae7d1

Please sign in to comment.