UNPKG

sf-decomposer

Version:

Split large Salesforce metadata files into version-control-friendly pieces and rebuild deployment-ready files.

105 lines (104 loc) 5.8 kB
import { DecomposerOverride } from './types.js'; /** * Resolve the absolute path of the default `.sfdecomposer.config.json`, located in the * repo root (the nearest ancestor directory that contains `sfdx-project.json`). Throws * a clear error when the repo root cannot be located or the config file does not exist. */ export declare function resolveDefaultConfigPath(): Promise<string>; export type ResolvedDecomposeTypeOptions = { format: string; strategy: string; decomposeNestedPerms: boolean; prepurge: boolean; postpurge: boolean; /** Resolved custom `splitTags` spec, when explicitly set in an override. */ splitTags?: string; /** * Resolved custom `multiLevel` spec(s), when explicitly set in an override. Preserves the * input shape (string vs string[]) so the disassembler crate can decide how to parse it; * a single `;`-separated string is treated by the crate as multiple rules. */ multiLevel?: string | string[]; /** * Resolved custom `uniqueIdElements` spec, when explicitly set in an override. Replaces * the hardcoded per-type list; the global defaults (`fullName`, `name`) are still * prepended by `getRegistryValuesBySuffix` regardless. */ uniqueIdElements?: string; }; /** * Load and validate the `overrides` array from a `.sfdecomposer.config.json` file. * Returns an empty array if the file is missing, unreadable, or contains no overrides. */ export declare function loadOverridesFromConfig(configPath: string): Promise<DecomposerOverride[]>; /** * Validate that the overrides array is well-formed. Throws on any structural problem. * Unknown override keys are tolerated (ignored), but forbidden run-scope keys throw. */ export declare function validateOverrides(overrides: DecomposerOverride[]): void; /** * Validate the comma-separated `splitTags` spec at config-load time. Each rule must be of the * form `<tag>:<mode>:<field>` or `<tag>:<path>:<mode>:<field>`, with `mode` ∈ {split, group}. * Tags must be unique within the spec. Deeper validation (e.g. unknown XML tag names) is left * to the underlying disassembler crate at runtime. */ export declare function validateSplitTagsSpec(spec: string, i: number): void; /** * Validate the `multiLevel` spec at config-load time. Each rule must be of the form * `<file_pattern>:<root_to_strip>:<unique_id_elements>`, where `<unique_id_elements>` is * itself a comma-separated list. Three input shapes are supported: a single rule string * (legacy); a string[] of rules (preferred when targeting multiple nested sections); or a * single `;`-separated string of rules (compact form, also accepted by the crate). * * Rules are validated individually and the (file_pattern, root_to_strip) pair must be * unique across rules in the same scope. Deeper checks (whether a file pattern matches * anything, whether the unique-id elements actually exist on the inner XML) are left to * the runtime crate. */ export declare function validateMultiLevelSpec(spec: string | string[], i: number): void; /** * Validate the `uniqueIdElements` spec at config-load time. Must be a non-empty * comma-separated list of element names. Each entry may use `+` to join fields * into a compound key (e.g. `"actionName+pageOrSobjectType+formFactor"`). Deeper * validation (whether the named elements actually exist in the XML) is left to the * runtime crate. */ export declare function validateUniqueIdElementsSpec(spec: string, i: number): void; /** * Parse a component override key of the form `<metadataSuffix>:<fullName>`. Returns `undefined` * when the key is malformed. Only the first colon is treated as the delimiter so fullNames that * contain `/` (folder-typed metadata such as `report:MyFolder/MyReport`) are preserved verbatim. */ export declare function parseComponentKey(key: string): { metadataType: string; fullName: string; } | undefined; /** * Find the override (if any) that targets a specific metadata suffix. */ export declare function getOverrideForType(metadataType: string, overrides?: DecomposerOverride[]): DecomposerOverride | undefined; /** * Find the override (if any) that targets a specific component, identified by its metadata * suffix and SDR fullName. */ export declare function getOverrideForComponent(metadataType: string, fullName: string, overrides?: DecomposerOverride[]): DecomposerOverride | undefined; /** * Returns true when at least one override targets a component of the given metadata type. * Used by the decompose handler to decide whether per-component enumeration is required. */ export declare function hasComponentOverridesForType(metadataType: string, overrides?: DecomposerOverride[]): boolean; /** * Resolve the effective decompose options for a single metadata type. The base values are * the run-wide options (CLI flags or defaults); per-type override values, when present, win. */ export declare function resolveDecomposeOptionsForType(metadataType: string, base: ResolvedDecomposeTypeOptions, overrides?: DecomposerOverride[]): ResolvedDecomposeTypeOptions; /** * Resolve the effective decompose options for a single component. Precedence (highest first): * component-scoped override fields (via `components`), then type-scoped resolved values * (already applied by `resolveDecomposeOptionsForType`), then run-wide base values (passed * through as the typeResolved fallback). * * Hard plugin rules (e.g. labels and loyaltyProgramSetup forced to `unique-id`) are applied * separately by callers, not here, so this function stays pure. */ export declare function resolveDecomposeOptionsForComponent(metadataType: string, fullName: string, typeResolved: ResolvedDecomposeTypeOptions, overrides?: DecomposerOverride[]): ResolvedDecomposeTypeOptions;