Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides a way to manage a locally authenticated Org.

see

AuthInfo

see

Connection

see

Aliases

see

Config

example

// 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

Hierarchy

Index

Methods

addUsername

  • Adds a username to the user config for this org.

    example

    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);

    Parameters

    • auth: AuthInfo | string

      The AuthInfo for the username to add.

    Returns Promise<Org>

    For convenience this object is returned.

checkScratchOrg

  • checkScratchOrg(devHubUsername?: undefined | string): Promise<Partial<AuthFields>>
  • Check that this org is a scratch org by asking the dev hub if it knows about it.

    throws

    {SfdxError} {name: 'NotADevHub'} Not a Dev Hub.

    throws

    {SfdxError} {name: 'NoResults'} No results.

    Parameters

    • Optional devHubUsername: undefined | string

    Returns Promise<Partial<AuthFields>>

cleanLocalOrgData

  • cleanLocalOrgData(orgDataPath?: undefined | string, throwWhenRemoveFails?: boolean): Promise<void>
  • Clean all data files in the org's data path. Usually /.sfdx/orgs/.

    Parameters

    • Optional orgDataPath: undefined | string
    • Default value throwWhenRemoveFails: boolean = false

      Should the remove org operations throw an error on failure?

    Returns Promise<void>

getConfigAggregator

  • Returns for the config aggregator.

    Returns ConfigAggregator

getConnection

  • Returns the JSForce connection for the org.

    Returns Connection

Protected getDefaultOptions

getDevHubOrg

  • getDevHubOrg(): Promise<Optional<Org>>
  • Returns the Org object or null if this org is not affiliated with a Dev Hub (according to the local config).

    Returns Promise<Optional<Org>>

getField

  • Returns an org field. Returns undefined if the field is not set or invalid.

    Parameters

    Returns AnyJson

getFields

  • Returns a map of requested fields.

    Parameters

    Returns JsonMap

getOrgId

  • getOrgId(): string
  • Returns the orgId for this org.

    Returns string

getUsername

  • getUsername(): Optional<string>
  • Returns the admin username used to create the org.

    Returns Optional<string>

Protected init

  • init(): Promise<void>
  • Returns Promise<void>

isDevHubOrg

  • isDevHubOrg(): boolean
  • Returns true if the org is a Dev Hub.

    Returns boolean

readUserAuthFiles

  • readUserAuthFiles(): Promise<AuthInfo[]>
  • Reads and returns the content of all user auth files for this org as an array. @returns {Promise<AuthInfo[]>}

    Returns Promise<AuthInfo[]>

refreshAuth

  • refreshAuth(): Promise<void>
  • Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.

    Returns Promise<void>

remove

  • remove(throwWhenRemoveFails?: boolean): Promise<void>
  • 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.

    Parameters

    • Default value throwWhenRemoveFails: boolean = false

    Returns Promise<void>

removeUsername

  • removeUsername(auth: AuthInfo | string): Promise<Org>
  • Removes a username from the user config for this object.

    throws

    {SfdxError} {name: 'MissingAuthInfo'} Auth info is missing.

    Parameters

    • auth: AuthInfo | string

      The AuthInfo containing the username to remove.

    Returns Promise<Org>

    For convenience this object is returned.

retrieveMaxApiVersion

  • retrieveMaxApiVersion(): Promise<string>
  • 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.

    Returns Promise<string>

    The max api version number, i.e 46.0.

retrieveOrgUsersConfig

Static create

  • create<P, T>(this: object, options: P): Promise<T>
  • Asynchronously constructs and initializes a new instance of a concrete subclass with the provided options.

    Type parameters

    • P

    • T: AsyncCreatable<P>

    Parameters

    • this: object
    • options: P

      An options object providing initialization params to the async constructor.

    Returns Promise<T>