UNPKG

sfdx-hardis

Version:

Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards

120 lines 4.41 kB
import { XMLBuilder, XMLParser } from "fast-xml-parser"; import { DocBuilderRoot } from "./docBuilderRoot.js"; import { mdTableCell } from "../gitProvider/utilsMarkdown.js"; export class DocBuilderObject extends DocBuilderRoot { docType = "Object"; promptKey = "PROMPT_DESCRIBE_OBJECT"; placeholder = "<!-- Object description -->"; xmlRootKey = "CustomObject"; static buildIndexTable(prefix, objectDescriptions) { const lines = []; lines.push(...[ "## Objects", "", "| Name | Label | Description |", "| :-------- | :---- | :---------- | " ]); for (const objectDescription of objectDescriptions) { const objectNameCell = `[${objectDescription.name}](${prefix}${objectDescription.name}.md)`; lines.push(...[ `| ${objectNameCell} | ${objectDescription.label || ""} | ${mdTableCell(objectDescription.description)} |` ]); } lines.push(""); return lines; } static buildCustomFieldsTable(fields) { if (!Array.isArray(fields)) { fields = [fields]; } if (fields.length === 0) { return []; } const lines = []; lines.push(...[ "## Fields", "", "| Name | Label | Type | Description |", "| :-------- | :---- | :--: | :---------- | " ]); for (const field of fields) { lines.push(...[ `| ${field.fullName} | ${field.label || ""} | ${field.type || ""} | ${mdTableCell(String(field.description))} |` ]); } lines.push(""); return lines; } static buildValidationRulesTable(validationRules) { if (!Array.isArray(validationRules)) { validationRules = [validationRules]; } if (validationRules.length === 0) { return []; } const lines = []; lines.push(...[ "## Validation Rules", "", "| Rule | Active | Description | Formula |", "| :-------- | :---- | :---------- | :------ |" ]); for (const rule of validationRules) { lines.push(...[ `| ${rule.fullName} | ${rule.active ? "Yes" : "No ⚠️"} | ${rule.description || ""} | ${mdTableCell(rule.errorConditionFormula)} |` ]); } lines.push(""); return lines; } async buildInitialMarkdownLines() { return [ '', '<!-- Mermaid schema -->', '', '<!-- Object description -->', '', '<!-- Attributes tables -->', '', '<!-- Flows table -->', '', '<!-- Apex table -->', '', '<!-- Pages table -->', '', '<!-- Profiles table -->', '', '<!-- PermissionSets table -->', ]; } stripXmlForAi() { const xmlObj = new XMLParser().parse(this.metadataXml); // Remove record types picklist values if (xmlObj?.CustomObject?.recordTypes) { if (!Array.isArray(xmlObj.CustomObject.recordTypes)) { xmlObj.CustomObject.recordTypes = [xmlObj.CustomObject.recordTypes]; } for (const recordType of xmlObj?.CustomObject?.recordTypes || []) { delete recordType.picklistValues; } } // Remove actionOverrides with formFactors as they already exist in default if (xmlObj?.CustomObject?.actionOverrides) { if (!Array.isArray(xmlObj.CustomObject.actionOverrides)) { xmlObj.CustomObject.actionOverrides = [xmlObj.CustomObject.actionOverrides]; } xmlObj.CustomObject.actionOverrides = xmlObj.CustomObject.actionOverrides.filter(actionOverride => !actionOverride.formFactor); } // Remove compact layouts if (xmlObj?.CustomObject?.compactLayouts) { delete xmlObj.CustomObject.compactLayouts; } // Remove compact layouts if (xmlObj?.CustomObject?.listViews) { delete xmlObj.CustomObject.listViews; } const xmlStripped = new XMLBuilder().build(xmlObj); return xmlStripped; } } //# sourceMappingURL=docBuilderObject.js.map