This library provides client-side management of Salesforce DX projects, org authentication, connections to Salesforce APIs, and various other utilities. These libraries are used by and follow patterns of the Salesforce CLI.
Requires Node.js v8.4 or greater and TypeScript target es2017.
As a beta feature, Salesforce DX Core Library is a preview and isn’t part of the “Services” under your master subscription agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature. You can provide feedback and suggestions for Salesforce DX Core Library in the issues section of this repo.
Create, read, update, and delete authentication information for an org.
Create an instance of an API connection to a Salesforce org.
Create a representation of an org based on an already authenticated alias, username, or default. The representation has a connection and other useful methods for interacting with an org and its users.
Create an instance of a streaming API connection to a Salesforce org for a particular streaming channel.
Represents a config file at either a local or global path. The config file extends the ConfigStore which provides map-like functions to interact with config values. The following classes are config files.
Aggregates local, global, and environment config values using Config and environment variables.
Represents a Salesforce DX project, defined by the file sfdx-project.json.
All logging in sfdx-core is accomplished through this logging class. Anyone can also use the logger to log their own log lines to the sfdx.log file or to any other log file or stream by utilizing the log level flags and envars set by the CLI or framework.
An error class that is always thrown from sfdx-core, providing useful formatting and contextual data.
Manage user messages that are accessible by all plugins and consumers of sfdx-core.
The type of entries in a config store defined by the key and value type of ConfigContents.
The allowed types stored in a config store.
Function type for processing messages
Required fields type needed to represent a Salesforce User object.
The default file system mode to use when creating directories.
The default file system mode to use when creating files.
Promisified version of fs.access.
A convenience reference to https://nodejs.org/api/fs.html#fs_fs_constants
to reduce the need to import multiple fs modules.
Promisified version of mkdirp.
Promisified version of fs.open.
Promisified version of fs.readFile.
Promisified version of fs.readdir.
Promisified version of fs.rmdir.
Promisified version of fs.stat.
Use to mock out different pieces of sfdx-core to make testing easier. This will mock out logging to a file, config file reading and writing, local and global path resolution, and http request using connection (soon).
A pre-canned error for try/catch testing.
Promisified version of fs.unlink.
Promisified version of fs.writeFile.
Returns the first key within the object that has an upper case first letter.
The object in which to check key casing.
Returns true if a provided URL contains a Salesforce owned domain.
The URL to inspect.
Read a file and convert it to JSON.
The path of the file.
The contents of the file as a JSON object.
Read a file and convert it to JSON, throwing an error if the parsed contents are not a JsonMap.
The path of the file.
The contents of the file as a JSON object.
Deletes a folder recursively, removing all descending files and folders.
The path to remove.
Performs an upward directory search for an sfdx project file.
The absolute path to the project.
Gets the os level keychain impl.
The os platform.
The keychain impl.
Use for this testing pattern:
try { await call() assert.fail('this should never happen'); } catch (e) { ... }
Just do this
try { await shouldThrow(call()); // If this succeeds unexpectedResultError is thrown. } catch(e) { ... }
The async function that is expected to throw.
Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a
specific file name. Resolves with the directory path containing the located file, or null if the file was
not found.
The directory path in which to start the upward search.
The file name to look for.
Converts an 18 character Salesforce ID to 15 characters.
The id to convert.
Tests whether an API version matches the format i.0.
The API version as a string.
Tests whether an email matches the format `me@my.org`
The email as a string.
Tests whether a path is in the correct format; the value doesn't include the characters "[", "]", "?", "<", ">", "?", "|"
The path as a string.
Tests whether a Salesforce ID is in the correct format, a 15- or 18-character length string with only letters and numbers
The ID as a string.
Convert a JSON-compatible object to a string and write it to a file.
The path of the file to write.
The JSON object to write.
A Map of Required Salesforce User fields.
The type of content a config stores.