UNPKG

sfdx-plugin-package-xml

Version:

explore metadata in an org and generate a package.xml manifest

46 lines 1.73 kB
const SEPARATOR = ":"; /** * @param metadataComponentName colon-separated type and fullName (e.g. `CustomField:Account.Industry`) */ export function parseMetadataComponentName(metadataComponentName) { const [type, fullName, _] = metadataComponentName.split(SEPARATOR); if (!type || !fullName || _) { throw new Error(`Invalid syntax of metadata component name: ${metadataComponentName} Expected colon-separated type and fullName (e.g. 'CustomField:Account.Industry')`); } const metadataComponent = { type, fullName, }; return validateMetadataComponent(metadataComponent); } /** * @returns colon-separated type and fullName (e.g. `CustomField:Account.Industry`) */ export function toMetadataComponentName(metadataComponent) { validateMetadataComponent(metadataComponent); return `${metadataComponent.type}${SEPARATOR}${metadataComponent.fullName}`; } export function validateMetadataComponent(metadataComponent) { if (!metadataComponent.type || !metadataComponent.fullName || typeof metadataComponent.type !== "string" || typeof metadataComponent.fullName !== "string") { throw new Error(`${JSON.stringify(metadataComponent)} is not a valid MetadataComponent`); } return metadataComponent; } export function ensureMetadataComponentPattern(input) { if (!input.includes(":")) { return `${input}:*`; } return input; } export function simplifyMetadataComponentPattern(input) { const metadataComponent = parseMetadataComponentName(input); if (/^[*./]+$/.test(metadataComponent.fullName)) { return metadataComponent.type; } return input; } //# sourceMappingURL=metadata-component.js.map