@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
94 lines (93 loc) • 3.42 kB
TypeScript
import { AsyncOptionalCreatable } from '@salesforce/kit';
import { Nullable } from '@salesforce/ts-types';
import { AuthFields } from '../../org/authInfo';
import { ConfigContents } from '../../config/configStackTypes';
export type Aliasable = string | Partial<AuthFields>;
export declare const DEFAULT_GROUP = "orgs";
export declare const FILENAME = "alias.json";
export declare class AliasAccessor extends AsyncOptionalCreatable {
private fileLocation;
/** orgs is the default group */
private aliasStore;
/**
* Returns all the aliases for all the values
*/
getAll(): ConfigContents<string>;
/**
* Returns all the aliases for a given entity
*
* @param entity the aliasable entity that you want to get the aliases of
*/
getAll(entity: Aliasable): string[];
/**
* Returns the first alias found for a given entity
*
* @param entity the aliasable entity that you want to get the alias of
*/
get(entity: Aliasable): Nullable<string>;
/**
* Returns the value that corresponds to the given alias if it exists
*
* @param alias the alias that corresponds to a value
*/
getValue(alias: string): Nullable<string>;
/**
* Returns the username that corresponds to the given alias if it exists
*
* @param alias the alias that corresponds to a username
*/
getUsername(alias: string): Nullable<string>;
/**
* If the provided string is an alias, it returns the corresponding username.
* If the provided string is not an alias, we assume that the provided string
* is the username and return it.
*
* This method is helpful when you don't know if the string you have is a username
* or an alias.
*
* @param usernameOrAlias a string that might be a username or might be an alias
*/
resolveUsername(usernameOrAlias: string): string;
/**
* If the provided string is an alias, return it.
* If the provided string is not an alias, return the username of the provided alias
*
* This method is helpful when you don't know if the string you have is a username
* or an alias.
*
* @param usernameOrAlias a string that might be a username or might be an alias
*/
resolveAlias(usernameOrAlias: string): string | undefined;
/**
* Set an alias for the given aliasable entity. Writes to the file
*
* @param alias the alias you want to set
* @param entity the aliasable entity that's being aliased
*/
setAndSave(alias: string, entity: Aliasable): Promise<void>;
/**
* Unset the given alias(es). Writes to the file
*
*/
unsetAndSave(alias: string): Promise<void>;
/**
* Unset all the aliases for the given array of entity.
*
* @param entity the aliasable entity for which you want to unset all aliases
*/
unsetValuesAndSave(aliasees: Aliasable[]): Promise<void>;
/**
* Returns true if the provided alias exists
*
* @param alias the alias you want to check
*/
has(alias: string): boolean;
protected init(): Promise<void>;
/**
* go to the fileSystem and read the file, storing a copy in the class's store
* if the file doesn't exist, create it empty
*/
private readFileToAliasStore;
private saveAliasStoreToFile;
}
export declare const getFileLocation: () => string;