import { AsyncCreatable } from '@salesforce/kit'; import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types'; import { AuthFields, AuthInfo } from './authInfo'; import { ConfigAggregator } from './config/configAggregator'; import { OrgUsersConfig } from './config/orgUsersConfig'; import { Connection } from './connection'; /** * Provides a way to manage a locally authenticated Org. * * **See** {@link AuthInfo} * * **See** {@link Connection} * * **See** {@link Aliases} * * **See** {@link Config} * * ``` * // Email username * const org1: Org = await Org.create({ aliasOrUsername: 'foo@example.com' });//tslint:disable-line:no-unused-variable * // The defaultusername config property * const org2: Org = await Org.create({}); * // Full Connection * const org3: Org = await Org.create({ * connection: await Connection.create(await AuthInfo.create({ username: 'username' })) * }); * ``` * * **See** https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_usernames_orgs.htm */ export declare class Org extends AsyncCreatable { private status; private configAggregator; private logger; private connection; private options; /** * @ignore */ constructor(options: Org.Options); /** * Clean all data files in the org's data path. Usually /.sfdx/orgs/. * @param orgDataPath A relative path other than "orgs/". * @param throwWhenRemoveFails Should the remove org operations throw an error on failure? */ cleanLocalOrgData(orgDataPath?: string, throwWhenRemoveFails?: boolean): Promise; /** * @ignore */ retrieveOrgUsersConfig(): Promise; /** * Removes the scratch org config file at $HOME/.sfdx/[name].json, any project level org * files, all user auth files for the org, matching default config settings, and any * matching aliases. * @param throwWhenRemoveFails Determines if the call should throw an error or fail silently. */ remove(throwWhenRemoveFails?: boolean): Promise; /** * Check that this org is a scratch org by asking the dev hub if it knows about it. * * **Throws** *{@link SfdxError}{ name: 'NotADevHub' }* Not a Dev Hub. * * **Throws** *{@link SfdxError}{ name: 'NoResults' }* No results. * * @param devHubUsername The username of the dev hub org. */ checkScratchOrg(devHubUsername?: string): Promise>; /** * Returns the Org object or null if this org is not affiliated with a Dev Hub (according to the local config). */ getDevHubOrg(): Promise>; /** * Returns `true` if the org is a Dev Hub. */ isDevHubOrg(): boolean; /** * Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object. */ refreshAuth(): Promise; /** * Reads and returns the content of all user auth files for this org as an array. */ readUserAuthFiles(): Promise; /** * Adds a username to the user config for this org. For convenience `this` object is returned. * * ``` * const org: Org = await Org.create(await Connection.create(await AuthInfo.create('foo@example.com'))); * const userAuth: AuthInfo = await AuthInfo.create('bar@example.com'); * await org.addUsername(userAuth); * ``` * * @param {AuthInfo | string} auth The AuthInfo for the username to add. */ addUsername(auth: AuthInfo | string): Promise; /** * Removes a username from the user config for this object. For convenience `this` object is returned. * * **Throws** *{@link SfdxError}{ name: 'MissingAuthInfo' }* Auth info is missing. * * @param {AuthInfo | string} auth The AuthInfo containing the username to remove. */ removeUsername(auth: AuthInfo | string): Promise; /** * Retrieves the highest api version that is supported by the target server instance. If the apiVersion configured for * Sfdx is greater than the one returned in this call an api version mismatch occurs. In the case of the CLI that * results in a warning. */ retrieveMaxApiVersion(): Promise; /** * Returns the admin username used to create the org. */ getUsername(): Optional; /** * Returns the orgId for this org. */ getOrgId(): string; /** * Returns for the config aggregator. */ getConfigAggregator(): ConfigAggregator; /** * Returns an org field. Returns undefined if the field is not set or invalid. */ getField(key: Org.Fields): AnyJson; /** * Returns a map of requested fields. */ getFields(keys: Org.Fields[]): JsonMap; /** * Returns the JSForce connection for the org. */ getConnection(): Connection; /** * Initialize async components. */ protected init(): Promise; /** * **Throws** *{@link SfdxError} Throws and unsupported error. */ protected getDefaultOptions(): Org.Options; private manageDelete; } export declare namespace Org { /** * Constructor Options for and Org. */ interface Options { aliasOrUsername?: string; connection?: Connection; aggregator?: ConfigAggregator; isDevHub?: boolean; } /** * Scratch Org status. */ enum Status { /** * The scratch org is active. */ ACTIVE = "ACTIVE", /** * The scratch org has expired. */ EXPIRED = "EXPIRED", /** * The org is a scratch Org but no dev hub is indicated. */ UNKNOWN = "UNKNOWN", /** * The dev hub configuration is reporting an active Scratch org but the AuthInfo cannot be found. */ MISSING = "MISSING" } /** * Org Fields. */ enum Fields { /** * The org alias. */ ALIAS = "alias", CREATED = "created", /** * The Salesforce instance the org was created on. e.g. `cs42`. */ CREATED_ORG_INSTANCE = "createdOrgInstance", /** * The username of the dev hub org that created this org. Only populated for scratch orgs. */ DEV_HUB_USERNAME = "devHubUsername", /** * The full url of the instance the org lives on. */ INSTANCE_URL = "instanceUrl", /** * Is the current org a dev hub org. e.g. They have access to the `ScratchOrgInfo` object. */ IS_DEV_HUB = "isDevHub", /** * The login url of the org. e.g. `https://login.salesforce.com` or `https://test.salesforce.com`. */ LOGIN_URL = "loginUrl", /** * The org ID. */ ORG_ID = "orgId", /** * The `OrgStatus` of the org. */ STATUS = "status", /** * The snapshot used to create the scratch org. */ SNAPSHOT = "snapshot" } }