Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handling folders during various operations #208

Merged
merged 8 commits into from
Nov 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: update registry script for folder relations
Bryan Powell committed Nov 20, 2020
commit 55ff9dce0aa8520c627f271ff7e3db262860269c
5 changes: 5 additions & 0 deletions scripts/update-registry/typeOverride.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"emailservicesfunction": {
"suffix": null
},
"emailtemplatefolder": {
"id": "emailfolder",
"name": "EmailFolder",
"suffix": "emailFolder"
}
Comment on lines +5 to 9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type doesn't follow the typeName + "Folder" pattern like the rest, so add an override for it

}
25 changes: 17 additions & 8 deletions scripts/update-registry/update.js
Original file line number Diff line number Diff line change
@@ -32,31 +32,40 @@ function update(registry, describeResult) {
const typeOverrides = JSON.parse(fs.readFileSync(path.join(__dirname, 'typeOverride.json')))

for (const object of describeResult.metadataObjects) {
const typeId = object.xmlName.toLowerCase();
const { xmlName: name, suffix, directoryName, inFolder, childXmlNames } = object;
let typeId = object.xmlName.toLowerCase();
const { xmlName: name, suffix, directoryName, inFolder, childXmlNames, folderContentType } = object;

// If it's a type with folders, process the folder type later
if (inFolder === 'true') {
let folderTypeId;
if (inFolder === 'true' || inFolder === true) {
describeResult.metadataObjects.push({
xmlName: `${name}Folder`,
suffix: `${typeId}Folder`,
directoryName,
inFolder: false,
folderContentType: typeId
});
folderTypeId = `${typeId}folder`
}

let type = registry.types[typeId] || {
const generatedType = {
id: typeId,
name,
suffix,
directoryName,
inFolder: inFolder === 'true' || inFolder === true,
strictDirectoryName: !suffix
strictDirectoryName: !suffix,
folderType: folderTypeId,
folderContentType
};
let type = deepmerge(generatedType, registry.types[typeId] || {})

// apply type override if one exists
if (typeOverrides[typeId]) {
type = deepmerge(type, typeOverrides[typeId])
const typeOverride = typeOverrides[typeId]
if (typeOverride) {
type = deepmerge(type, typeOverride)
if (typeOverride.id) {
typeId = typeOverride.id
}
}

if (childXmlNames) {
36 changes: 20 additions & 16 deletions src/metadata-registry/data/registry.json
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
"suffix": "labels",
"directoryName": "labels",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"customlabel": {
@@ -29,8 +30,7 @@
"directories": {
"customLabels": "customlabel"
}
},
"strictDirectoryName": false
}
},
"navigationmenu": {
"id": "navigationmenu",
@@ -579,6 +579,7 @@
"suffix": "workflow",
"directoryName": "workflows",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"workflowfieldupdate": {
@@ -641,15 +642,15 @@
"workflowOutboundMessages": "workflowoutboundmessage",
"workflowRules": "workflowrule"
}
},
"strictDirectoryName": false
}
},
"assignmentrules": {
"id": "assignmentrules",
"name": "AssignmentRules",
"suffix": "assignmentRules",
"directoryName": "assignmentRules",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"assignmentrule": {
@@ -665,15 +666,15 @@
"directories": {
"assignmentRules": "assignmentrule"
}
},
"strictDirectoryName": false
}
},
"autoresponserules": {
"id": "autoresponserules",
"name": "AutoResponseRules",
"suffix": "autoResponseRules",
"directoryName": "autoResponseRules",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"autoresponserule": {
@@ -689,15 +690,15 @@
"directories": {
"autoResponseRules": "autoresponserule"
}
},
"strictDirectoryName": false
}
},
"escalationrules": {
"id": "escalationrules",
"name": "EscalationRules",
"suffix": "escalationRules",
"directoryName": "escalationRules",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"escalationrule": {
@@ -713,8 +714,7 @@
"directories": {
"escalationRules": "escalationrule"
}
},
"strictDirectoryName": false
}
},
"posttemplate": {
"id": "posttemplate",
@@ -908,6 +908,7 @@
"suffix": "matchingRule",
"directoryName": "matchingRules",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"matchingrule": {
@@ -923,8 +924,7 @@
"directories": {
"matchingRules": "matchingrule"
}
},
"strictDirectoryName": false
}
},
"duplicaterule": {
"id": "duplicaterule",
@@ -1091,6 +1091,7 @@
"suffix": "sharingRules",
"directoryName": "sharingRules",
"inFolder": false,
"strictDirectoryName": false,
"children": {
"types": {
"sharingownerrule": {
@@ -1128,8 +1129,7 @@
"sharingOwnerRules": "sharingownerrule",
"sharingCriteriaRules": "sharingcriteriarule"
}
},
"strictDirectoryName": false
}
},
"sharingset": {
"id": "sharingset",
@@ -1708,6 +1708,7 @@
"suffix": "reportFolder",
"directoryName": "reports",
"inFolder": false,
"strictDirectoryName": false,
"folderContentType": "report"
},
"dashboardfolder": {
@@ -1716,6 +1717,7 @@
"suffix": "dashboardFolder",
"directoryName": "dashboards",
"inFolder": false,
"strictDirectoryName": false,
"folderContentType": "dashboard"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is folderContentType going to be updated by the describe api script, etc ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, I'll update the registry script

},
"documentfolder": {
@@ -1724,6 +1726,7 @@
"suffix": "documentFolder",
"directoryName": "documents",
"inFolder": false,
"strictDirectoryName": false,
"folderContentType": "document"
},
"emailfolder": {
@@ -1732,6 +1735,7 @@
"suffix": "emailFolder",
"directoryName": "email",
"inFolder": false,
"strictDirectoryName": false,
"folderContentType": "emailtemplate"
},
"inboundnetworkconnection": {
@@ -2042,7 +2046,7 @@
"reportFolder": "reportfolder",
"dashboardFolder": "dashboardfolder",
"documentFolder": "documentfolder",
"emailFolder": "emailFolder",
"emailFolder": "emailfolder",
"inboundNetworkConnection": "inboundnetworkconnection",
"outboundNetworkConnection": "outboundnetworkconnection",
"mutingpermissionset": "mutingpermissionset",
@@ -2099,4 +2103,4 @@
"botversion": "bot"
},
"apiVersion": "50.0"
}
}