UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

224 lines (223 loc) 6.76 kB
import { JsonPrimitive } from '@salesforce/ts-types'; import { ConfigFile } from './configFile'; import { ConfigContents, ConfigValue } from './configStore'; /** * Interface for meta information about config properties */ export interface ConfigPropertyMeta { /** * The config property name. */ key: string; /** * Description */ description: string; /** * Reference to the config data input validation. */ input?: ConfigPropertyMetaInput; /** * True if the property should be indirectly hidden from the user. */ hidden?: boolean; /** * True if the property values should be stored encrypted. */ encrypted?: boolean; } /** * Config property input validation */ export interface ConfigPropertyMetaInput { /** * Tests if the input value is valid and returns true if the input data is valid. * * @param value The input value. */ validator: (value: ConfigValue) => boolean; /** * The message to return in the error if the validation fails. */ failedMessage: string | ((value: ConfigValue) => string); } export declare enum SfdxPropertyKeys { /** * Username associated with the default dev hub org. */ DEFAULT_DEV_HUB_USERNAME = "defaultdevhubusername", /** * Username associate with the default org. */ DEFAULT_USERNAME = "defaultusername", /** * The sid for the debugger configuration. */ ISV_DEBUGGER_SID = "isvDebuggerSid", /** * The url for the debugger configuration. */ ISV_DEBUGGER_URL = "isvDebuggerUrl", /** * The api version */ API_VERSION = "apiVersion", /** * Disables telemetry reporting */ DISABLE_TELEMETRY = "disableTelemetry", /** * allows users to override the 10,000 result query limit */ MAX_QUERY_LIMIT = "maxQueryLimit", /** */ REST_DEPLOY = "restDeploy", /** */ INSTANCE_URL = "instanceUrl" } export declare const SFDX_ALLOWED_PROPERTIES: ({ key: SfdxPropertyKeys; description: string; input: { validator: (value: ConfigValue) => boolean; failedMessage: string; }; hidden?: undefined; encrypted?: undefined; } | { key: SfdxPropertyKeys; description: string; hidden: boolean; input: { validator: (value: ConfigValue) => boolean; failedMessage: string; }; encrypted?: undefined; } | { key: SfdxPropertyKeys; description: string; input?: undefined; hidden?: undefined; encrypted?: undefined; } | { key: SfdxPropertyKeys; description: string; encrypted: boolean; input: { validator: (value: ConfigValue) => boolean; failedMessage: string; }; hidden?: undefined; })[]; export declare const SfProperty: { [index: string]: ConfigPropertyMeta; }; export declare type ConfigProperties = { [index: string]: JsonPrimitive; }; /** * The files where sfdx config values are stored for projects and the global space. * * *Note:* It is not recommended to instantiate this object directly when resolving * config values. Instead use {@link ConfigAggregator} * * ``` * const localConfig = await Config.create(); * localConfig.set('defaultusername', 'username@company.org'); * await localConfig.write(); * ``` * https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_config_values.htm */ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigProperties> { private static allowedProperties; private sfdxPath?; constructor(options?: ConfigFile.Options); /** * Returns the default file name for a config file. * * **See** {@link CONFIG_FILE_NAME} */ static getFileName(): string; /** * Returns an array of objects representing the allowed config properties. */ static getAllowedProperties(): ConfigPropertyMeta[]; /** * Add an array of allowed config properties. * * @param metas Array of objects to set as the allowed config properties. */ static addAllowedProperties(metas: ConfigPropertyMeta[]): void; /** * The value of a supported config property. * * @param isGlobal True for a global config. False for a local config. * @param propertyName The name of the property to set. * @param value The property value. */ static update(isGlobal: boolean, propertyName: string, value?: ConfigValue): Promise<ConfigContents>; /** * Clear all the configured properties both local and global. */ static clear(): Promise<void>; private static propertyConfigMap; /** * Read, assign, and return the config contents. */ read(force?: boolean): Promise<ConfigProperties>; readSync(force?: boolean): ConfigProperties; /** * Writes Config properties taking into account encrypted properties. * * @param newContents The new Config value to persist. */ write(newContents?: ConfigProperties): Promise<ConfigProperties>; /** * DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously. * Call {@link SfdxConfig.write} instead. * * **Throws** *{@link SfdxError}{ name: 'InvalidWriteError' }* Always. * * @param newContents Contents to write */ writeSync(newContents?: ConfigProperties): ConfigProperties; /** * Sets a value for a property. * * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported. * **Throws** *{@link SfdxError}{ name: 'InvalidConfigValueError' }* If the input validator fails. * * @param key The property to set. * @param value The value of the property. */ set(key: string, value: JsonPrimitive): ConfigProperties; /** * Unsets a value for a property. * * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* If the input validator fails. * * @param key The property to unset. */ unset(key: string): boolean; /** * Initializer for supported config types. */ protected init(): Promise<void>; private readSfdxConfigSync; private writeSfdxConfig; private getSfdxPath; /** * Get an individual property config. * * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported. * * @param propertyName The name of the property. */ private getPropertyConfig; /** * Encrypts and content properties that have a encryption attribute. * * @param encrypt `true` to encrypt. */ private cryptProperties; }