@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
289 lines (288 loc) • 9.81 kB
TypeScript
import { Nullable } from '@salesforce/ts-types';
import { OrgConfigProperties } from '../org/orgConfigProperties';
import { ConfigFile } from './configFile';
import { ConfigContents, ConfigValue, Key } from './configStackTypes';
/**
* Interface for meta information about config properties
*/
export type 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;
/**
* True if the property is deprecated
*/
deprecated?: boolean;
/**
* Reference to config property name that will eventually replace this one.
* Is only used if deprecated is set to true.
*/
newKey?: string;
};
/**
* Config property input validation
*/
export type 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 SfConfigProperties {
/**
* Disables telemetry reporting
*/
DISABLE_TELEMETRY = "disable-telemetry"
}
export declare const SF_ALLOWED_PROPERTIES: {
key: SfConfigProperties;
description: string;
input: {
validator: (value: ConfigValue) => boolean;
failedMessage: string;
};
}[];
export declare enum SfdxPropertyKeys {
/**
* Username associated with the default dev hub org.
*
* @deprecated Replaced by OrgConfigProperties.TARGET_DEV_HUB in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
* will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
*/
DEFAULT_DEV_HUB_USERNAME = "defaultdevhubusername",
/**
* Username associate with the default org.
*
* @deprecated Replaced by OrgConfigProperties.TARGET_ORG in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
* will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
*/
DEFAULT_USERNAME = "defaultusername",
/**
* The sid for the debugger configuration.
*
* @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_SID in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
ISV_DEBUGGER_SID = "isvDebuggerSid",
/**
* The url for the debugger configuration.
*
* @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
ISV_DEBUGGER_URL = "isvDebuggerUrl",
/**
* The api version
*
* @deprecated Replaced by OrgConfigProperties.ORG_API_VERSION in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
API_VERSION = "apiVersion",
/**
* Disables telemetry reporting
*
* @deprecated Replaced by SfPropertyKeys.DISABLE_TELEMETRY in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
DISABLE_TELEMETRY = "disableTelemetry",
/**
* Custom templates repo or local location.
*
* @deprecated Replaced by OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
CUSTOM_ORG_METADATA_TEMPLATES = "customOrgMetadataTemplates",
/**
* allows users to override the 10,000 result query limit
*
* @deprecated Replaced by OrgConfigProperties.ORG_MAX_QUERY_LIMIT in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
MAX_QUERY_LIMIT = "maxQueryLimit",
/**
* @deprecated
*/
REST_DEPLOY = "restDeploy",
/**
* @deprecated Replaced by OrgConfigProperties.ORG_INSTANCE_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
*/
INSTANCE_URL = "instanceUrl"
}
export declare const SFDX_ALLOWED_PROPERTIES: ({
key: SfdxPropertyKeys;
description: string;
newKey: OrgConfigProperties;
deprecated: boolean;
input: {
validator: (value: ConfigValue) => boolean;
failedMessage: string;
};
encrypted?: undefined;
hidden?: undefined;
} | {
key: SfdxPropertyKeys;
newKey: OrgConfigProperties;
deprecated: boolean;
description: string;
input?: undefined;
encrypted?: undefined;
hidden?: undefined;
} | {
key: SfdxPropertyKeys;
newKey: OrgConfigProperties;
deprecated: boolean;
description: string;
encrypted: boolean;
input: {
validator: (value: ConfigValue) => boolean;
failedMessage: string;
};
hidden?: undefined;
} | {
key: SfdxPropertyKeys;
newKey: SfConfigProperties;
deprecated: boolean;
description: string;
input: {
validator: (value: ConfigValue) => boolean;
failedMessage: string;
};
encrypted?: undefined;
hidden?: undefined;
} | {
key: SfdxPropertyKeys;
description: string;
hidden: boolean;
newKey: string;
deprecated: boolean;
input: {
validator: (value: ConfigValue) => boolean;
failedMessage: string;
};
encrypted?: undefined;
})[];
export declare const SfProperty: {
[index: string]: ConfigPropertyMeta;
};
export type ConfigProperties = ConfigContents;
/**
* 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('target-org', '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<K extends Key<ConfigProperties>>(isGlobal: boolean, propertyName: K, value?: ConfigProperties[K]): Promise<ConfigContents>;
/**
* Clear all the configured properties both local and global.
*/
static clear(): Promise<void>;
static getPropertyConfigMeta(propertyName: string): Nullable<ConfigPropertyMeta>;
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(): 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 SfError}{ name: 'InvalidWriteError' }* Always.
*
* @param newContents Contents to write
*/
writeSync(newContents?: ConfigProperties): ConfigProperties;
/**
* Sets a value for a property.
*
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
* **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
*
* @param key The property to set.
* @param value The value of the property.
*/
set<K extends Key<ConfigProperties>>(key: K, value: ConfigProperties[K]): ConfigProperties;
/**
* Unsets a value for a property.
*
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
*
* @param key The property to unset.
*/
unset(key: string): boolean;
/**
* Get an individual property config.
*
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
*
* @param propertyName The name of the property.
*/
getPropertyConfig(propertyName: string): ConfigPropertyMeta;
/**
* Initializer for supported config types.
*/
protected init(): Promise<void>;
/**
* Encrypts and content properties that have a encryption attribute.
*
* @param encrypt `true` to encrypt.
*/
private cryptProperties;
}