1 | import { ConfigFile } from './configFile';
|
2 | import { ConfigContents, ConfigValue } from './configStore';
|
3 | /**
|
4 | * Interface for meta information about config properties
|
5 | */
|
6 | export interface ConfigPropertyMeta {
|
7 | /**
|
8 | * The config property name.
|
9 | */
|
10 | key: string;
|
11 | /**
|
12 | * Reference to the config data input validation.
|
13 | */
|
14 | input?: ConfigPropertyMetaInput;
|
15 | /**
|
16 | * True if the property should be indirectly hidden from the user.
|
17 | */
|
18 | hidden?: boolean;
|
19 | /**
|
20 | * True if the property values should be stored encrypted.
|
21 | */
|
22 | encrypted?: boolean;
|
23 | }
|
24 | /**
|
25 | * Config property input validation
|
26 | */
|
27 | export interface ConfigPropertyMetaInput {
|
28 | /**
|
29 | * Tests if the input value is valid and returns true if the input data is valid.
|
30 | *
|
31 | * @param value The input value.
|
32 | */
|
33 | validator: (value: ConfigValue) => boolean;
|
34 | /**
|
35 | * The message to return in the error if the validation fails.
|
36 | */
|
37 | failedMessage: string;
|
38 | }
|
39 | /**
|
40 | * The files where sfdx config values are stored for projects and the global space.
|
41 | *
|
42 | * *Note:* It is not recommended to instantiate this object directly when resolving
|
43 | * config values. Instead use {@link ConfigAggregator}
|
44 | *
|
45 | * ```
|
46 | * const localConfig = await Config.create({});
|
47 | * localConfig.set('defaultusername', 'username@company.org');
|
48 | * await localConfig.write();
|
49 | * ```
|
50 | * https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_config_values.htm
|
51 | */
|
52 | export declare class Config extends ConfigFile<ConfigFile.Options> {
|
53 | /**
|
54 | * Username associated with the default dev hub org.
|
55 | *
|
56 | * @deprecated Replaced by OrgConfigProperties.TARGET_DEV_HUB in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
57 | */
|
58 | static readonly DEFAULT_DEV_HUB_USERNAME: string;
|
59 | /**
|
60 | * Username associate with the default org.
|
61 | *
|
62 | * @deprecated Replaced by OrgConfigProperties.TARGET_ORG in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
63 | */
|
64 | static readonly DEFAULT_USERNAME: string;
|
65 | /**
|
66 | * The sid for the debugger configuration.
|
67 | */
|
68 | static readonly ISV_DEBUGGER_SID: string;
|
69 | /**
|
70 | * The url for the debugger configuration.
|
71 | */
|
72 | static readonly ISV_DEBUGGER_URL: string;
|
73 | /**
|
74 | * The api version
|
75 | */
|
76 | static readonly API_VERSION = "apiVersion";
|
77 | /**
|
78 | * Disables telemetry reporting
|
79 | */
|
80 | static readonly DISABLE_TELEMETRY = "disableTelemetry";
|
81 | /**
|
82 | * Custom templates repo or local location.
|
83 | */
|
84 | static readonly CUSTOM_ORG_METADATA_TEMPLATES = "customOrgMetadataTemplates";
|
85 | /**
|
86 | * allows users to override the 10,000 result query limit
|
87 | */
|
88 | static readonly MAX_QUERY_LIMIT = "maxQueryLimit";
|
89 | private static get propertyConfigMap();
|
90 | private static allowedProperties;
|
91 | private static messages;
|
92 | private crypto?;
|
93 | constructor(options?: ConfigFile.Options);
|
94 | /**
|
95 | * Returns the default file name for a config file.
|
96 | *
|
97 | * **See** { SFDX_CONFIG_FILE_NAME}
|
98 | */
|
99 | static getFileName(): string;
|
100 | /**
|
101 | * Returns an array of objects representing the allowed config properties.
|
102 | */
|
103 | static getAllowedProperties(): ConfigPropertyMeta[];
|
104 | /**
|
105 | * Add an array of allowed config properties.
|
106 | *
|
107 | * @param metas Array of objects to set as the allowed config properties.
|
108 | */
|
109 | static addAllowedProperties(metas: ConfigPropertyMeta[]): void;
|
110 | /**
|
111 | * Gets default options.
|
112 | *
|
113 | * @param isGlobal Make the config global.
|
114 | * @param filename Override the default file. {@link Config.getFileName}
|
115 | */
|
116 | static getDefaultOptions(isGlobal?: boolean, filename?: string): ConfigFile.Options;
|
117 | /**
|
118 | * The value of a supported config property.
|
119 | *
|
120 | * @param isGlobal True for a global config. False for a local config.
|
121 | * @param propertyName The name of the property to set.
|
122 | * @param value The property value.
|
123 | */
|
124 | static update(isGlobal: boolean, propertyName: string, value?: ConfigValue): Promise<ConfigContents>;
|
125 | /**
|
126 | * Clear all the configured properties both local and global.
|
127 | */
|
128 | static clear(): Promise<void>;
|
129 | /**
|
130 | * Read, assign, and return the config contents.
|
131 | */
|
132 | read(force?: boolean): Promise<ConfigContents>;
|
133 | /**
|
134 | * Writes Config properties taking into account encrypted properties.
|
135 | *
|
136 | * @param newContents The new Config value to persist.
|
137 | */
|
138 | write(newContents?: ConfigContents): Promise<ConfigContents>;
|
139 | /**
|
140 | * DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
|
141 | * Call {@link SfdxConfig.write} instead.
|
142 | *
|
143 | * **Throws** *{@link SfdxError}{ name: 'InvalidWrite' }* Always.
|
144 | *
|
145 | * @param newContents Contents to write
|
146 | */
|
147 | writeSync(newContents?: ConfigContents): ConfigContents;
|
148 | /**
|
149 | * Sets a value for a property.
|
150 | *
|
151 | * **Throws** *{@link SfdxError}{ name: 'InvalidConfigValue' }* If the input validator fails.
|
152 | *
|
153 | * @param key The property to set.
|
154 | * @param value The value of the property.
|
155 | */
|
156 | set(key: string, value: ConfigValue): ConfigContents;
|
157 | /**
|
158 | * Unsets a value for a property.
|
159 | *
|
160 | * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKey' }* If the input validator fails.
|
161 | *
|
162 | * @param key The property to unset.
|
163 | */
|
164 | unset(key: string): boolean;
|
165 | /**
|
166 | * Initializer for supported config types.
|
167 | */
|
168 | protected init(): Promise<void>;
|
169 | /**
|
170 | * Initialize the crypto dependency.
|
171 | */
|
172 | private initCrypto;
|
173 | /**
|
174 | * Closes the crypto dependency. Crypto should be close after it's used and no longer needed.
|
175 | */
|
176 | private clearCrypto;
|
177 | /**
|
178 | * Get an individual property config.
|
179 | *
|
180 | * @param propertyName The name of the property.
|
181 | */
|
182 | private getPropertyConfig;
|
183 | /**
|
184 | * Encrypts and content properties that have a encryption attribute.
|
185 | *
|
186 | * @param encrypt `true` to encrypt.
|
187 | */
|
188 | private cryptProperties;
|
189 | }
|