UNPKG

salesforce-alm

Version:

This package contains tools, and APIs, for an improved salesforce.com developer experience.

66 lines (65 loc) 3.07 kB
import { Logger } from '@salesforce/core'; import { AsyncCreatable } from '@salesforce/kit'; import { Nullable } from '@salesforce/ts-types'; import { MetadataType } from './metadataType'; import { SourcePathInfo } from './sourcePathStatusManager'; import MetadataRegistry = require('./metadataRegistry'); import { NonDecomposedElementsIndex } from './nonDecomposedElementsIndex'; interface SourceLocationsOptions { metadataRegistry: MetadataRegistry; sourcePathInfos: SourcePathInfo[]; shouldBuildIndices: boolean; username: string; } export declare type MetadataPathsIndex = Map<string, string[]>; export declare type FilePathsIndex = Map<string, string[]>; /** * SourceLocations maintains 2 different indices: `filePathsIndex` and `metadataPathsIndex`. * * The `filePathsIndex` is a map of metadata keys to the file locations, e.g. * ``` * { * ApexClass__myClass: [~/workspace/my-project/classes/myClass.cls], * CustomObject__myObject__c.myField: [~/workspace/my-project/objects/myObject/fields/myField__c.field-meta.xml] * } * ``` * The `metadataPathsIndex` is a map of metadata keys to the meta file locations, e.g. * ``` * { * ApexClass__myClass: [~/workspace/my-project/classes/myClass.cls-meta.xml] * CustomObject__myObject__c: [~/workspace/my-project/objects/myObject/myObject__c.object-meta.xml] * } * ``` * The main difference between these two indices is that `filePathsIndex` contains entries for all workspace elements, * whereas the `metadataPathsIndex` ONLY contains the entries for the aggregate workspace elements. * * We allow multiple file paths per metadata key because the same metadata could live in multiple packages, e.g. CustomLabels. * When getting a file path based on a given key, we use SfdxProject.getActivePackage() to determine which path to return. * */ export declare class SourceLocations extends AsyncCreatable<SourceLocationsOptions> { logger: Logger; private static _metadataPathsIndex; private static _filePathsIndex; private static _nonDecomposedElementsIndex; private metadataRegistry; private sourcePathInfos; private shouldBuildIndices; private username; constructor(options: SourceLocationsOptions); protected init(): Promise<void>; getMetadataPath(metadataType: string, fullName: string): Nullable<string>; addMetadataPath(metadataType: string, fullName: string, metadataPath: string): void; getFilePath(metadataType: string, fullName: string): Nullable<string>; addFilePath(pathMetadataType: MetadataType, sourcePath: string): void; private getPathByActivePackage; private buildIndices; private isInvalidPath; static get filePathsIndex(): FilePathsIndex; static set filePathsIndex(newIndex: FilePathsIndex); static get metadataPathsIndex(): MetadataPathsIndex; static set metadataPathsIndex(newIndex: MetadataPathsIndex); static get nonDecomposedElementsIndex(): NonDecomposedElementsIndex; static set nonDecomposedElementsIndex(newIndex: NonDecomposedElementsIndex); } export {};