UNPKG

sf-decomposer

Version:

Decompose Salesforce metadata into granular, VCS-friendly files; recompose for deployment.

143 lines (142 loc) 7.9 kB
import { ConfigFile, 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; /** * Resolved custom `sidecarElements` spec, when explicitly set in an override. Comma-separated * `element:extension` pairs. When absent, built-in per-type defaults apply (e.g. * `externalServiceRegistration` defaults to `"schema:yaml"`). */ sidecarElements?: string; }; /** * Load and parse the full `.sfdecomposer.config.json` file. Validates the `overrides` array * when present. Throws when the file cannot be read or parsed. */ export declare function loadConfigFile(configPath: string): Promise<ConfigFile>; /** * Validate that a config-supplied manifest path (`config.manifest`, used only when `--manifest` * was not passed on the CLI) exists on disk. Returns the manifest to use going forward: * - unchanged, when no config manifest applies or it exists; * - `undefined`, when it is missing but `metadataTypes` can serve as a fallback (after warning); * - throws, when it is missing and there is no metadataSuffixes fallback either. */ export declare function validateConfigManifest(params: { configManifest: string | undefined; metadataTypes: string[] | undefined; manifest: string | undefined; warn: (message: string) => void; }): Promise<string | undefined>; /** * Split a comma-separated config string (e.g. `metadataSuffixes`, `ignorePackageDirectories`) * into a trimmed string array. Returns `undefined` when the value is absent, empty, or the * sentinel `"."` (which the hooks interpret as "all types, no filter"). */ export declare function parseConfigSuffixes(value: string | undefined): string[] | undefined; /** * Load and validate the `overrides` array from a `.sfdecomposer.config.json` file. * Returns an empty array when the file is missing or unreadable. Throws on invalid JSON * or a malformed `overrides` array (same contract as before `loadConfigFile` was added). */ 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; /** * Validate the `sidecarElements` spec at config-load time. Must be a non-empty * comma-separated list of `element:extension` pairs, each with exactly two colon-separated * parts. Element names must be unique within the spec. Deeper validation (whether the * named element exists in the XML) is left to the runtime crate. */ export declare function validateSidecarElementsSpec(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;