UNPKG

@salesforce/source-deploy-retrieve

Version:

JavaScript library to run Salesforce metadata deploys and retrieves

58 lines 2.5 kB
"use strict"; /* * Copyright 2025, Salesforce, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.customLabelHasFullName = exports.parser = void 0; exports.generateMetaXML = generateMetaXML; exports.generateMetaXMLPath = generateMetaXMLPath; exports.trimMetaXmlSuffix = trimMetaXmlSuffix; const sfError_1 = require("@salesforce/core/sfError"); const fast_xml_parser_1 = require("fast-xml-parser"); const constants_1 = require("../common/constants"); exports.parser = new fast_xml_parser_1.XMLParser({ // include tag attributes and don't parse text node as number ignoreAttributes: false, parseTagValue: false, parseAttributeValue: false, cdataPropName: '__cdata', ignoreDeclaration: true, numberParseOptions: { leadingZeros: false, hex: false }, commentPropName: constants_1.XML_COMMENT_PROP_NAME, }); function generateMetaXML(typeName, apiVersion, status) { let templateResult = '<?xml version="1.0" encoding="UTF-8"?>\n'; templateResult += `<${typeName} xmlns="http://soap.sforce.com/2006/04/metadata">\n`; templateResult += `\t<apiVersion>${apiVersion}.0</apiVersion>\n`; if (status) { templateResult += `\t<status>${status}</status>\n`; } templateResult += `</${typeName}>`; return templateResult; } function generateMetaXMLPath(sourcePath) { return sourcePath.endsWith(constants_1.META_XML_SUFFIX) ? sourcePath : `${sourcePath}${constants_1.META_XML_SUFFIX}`; } function trimMetaXmlSuffix(sourcePath) { return sourcePath.endsWith(constants_1.META_XML_SUFFIX) ? sourcePath.replace(constants_1.META_XML_SUFFIX, '') : sourcePath; } const customLabelHasFullName = (label) => { if (label.fullName === undefined) { throw sfError_1.SfError.create({ message: 'Label does not have a fullName', data: label }); } return true; }; exports.customLabelHasFullName = customLabelHasFullName; //# sourceMappingURL=metadata.js.map