@pga/xml-transformer
v0.0.1
Published
Utilities for performing transformations on xml files e.g. salesforce metadata transformations.
Downloads
5
Keywords
Readme
xml-transformer
Utilities for performing transformations on xml files e.g. salesforce metadata transformations.
Transform Options:
metadata
: Required array of metadata objects
transformer
: Optional transformer function, defaults to generic transformer
Metadata Object Options:
transformations
: Required array of transformation functions to be run on the file. Each function should take in json and return the transformed json
files
: Array of file paths (Strings) to transform. Required if dir
is not present
dir
: String directory of files to transform. Required if files
is not present
filePrefix
: Optional string prefix of filenames in the dir
to be included
Transformation functions:
json
: Required
Returns: transformed json
Example Usage:
const { transform } = require('@pga/xml-transformer')
const { removeProfilePermission, setEnvironmentVariable } = require('@pga/xml-transformer').salesforce
const metadata = [
{
transformations: [removeProfilePermission('ViewPlatformEvents'), removeProfilePermission('ViewDataLeakageEvents)],
files: [
'../force-app/main/default/profiles/System Administrator for Machines.profile-meta.xml'
]
},
{
transformations: [setEnvironmentVariable],
dir: '../force-app/main/default/customMetadata',
filePrefix: 'Environment_Variables.'
}
]
void async function () {
transform(metadata)
}()
Salesforce Transformations:
removeProfilePermission
Removes a permission by name from the profile's userPermissions list
permissionName
: permission name to be removed
setEnvironmentVariable
Sets the value of a custom metadata file by name using the environment variable with the same name
setWorkflowLookup
Sets the lookup value and type for a workflow
value
: the value of the lookup ex. [email protected]type
: the type of the lookup ex. User
setWorkflowSenderType
Sets the workflow sender type
senderType
: the type of sender ex. OrgWideEmailAddress