UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

94 lines (93 loc) 3.58 kB
import { Optional } from '@salesforce/ts-types'; import { Duration } from '@salesforce/kit'; import { RecordResult } from 'jsforce'; import { Org } from './org'; import { AuthInfo } from './authInfo'; import SettingsGenerator, { ObjectSetting } from './scratchOrgSettingsGenerator'; export interface ScratchOrgInfo { AdminEmail?: string; readonly CreatedDate?: string; ConnectedAppCallbackUrl?: string; ConnectedAppConsumerKey?: string; Country?: string; Description?: string; DurationDays?: string; Edition?: string; readonly ErrorCode?: string; readonly ExpirationDate?: string; Features?: string; HasSampleData?: boolean; readonly Id?: string; Language?: string; LoginUrl: string; readonly Name?: string; Namespace?: string; OrgName?: string; Release?: 'Current' | 'Previous' | 'Preview'; readonly ScratchOrg?: string; SourceOrg?: string; readonly AuthCode: string; Snapshot: string; readonly Status: 'New' | 'Creating' | 'Active' | 'Error' | 'Deleted'; readonly SignupEmail: string; readonly SignupUsername: string; readonly SignupInstance: string; Username: string; settings?: Record<string, unknown>; objectSettings?: { [objectName: string]: ObjectSetting; }; orgPreferences?: { enabled: string[]; disabled: string[]; }; } export interface JsForceError extends Error { errorCode: string; fields: string[]; } /** * after we successfully signup an org we need to trade the auth token for access and refresh token. * * @param scratchOrgInfoComplete - The completed ScratchOrgInfo which should contain an access token. * @param hubOrg - the environment hub org * @param clientSecret - The OAuth client secret. May be null for JWT OAuth flow. * @param signupTargetLoginUrlConfig - Login url * @param retry - auth retry attempts * @returns {Promise<AuthInfo>} */ export declare const authorizeScratchOrg: (options: { scratchOrgInfoComplete: ScratchOrgInfo; hubOrg: Org; clientSecret?: string; signupTargetLoginUrlConfig?: string; retry?: number; }) => Promise<AuthInfo>; /** * This extracts orgPrefs/settings from the user input and performs a basic scratchOrgInfo request. * * @param hubOrg - the environment hub org * @param scratchOrgRequest - An object containing the fields of the ScratchOrgInfo * @param settings - An object containing org settings * @returns {Promise<RecordResult>} */ export declare const requestScratchOrgCreation: (hubOrg: Org, scratchOrgRequest: ScratchOrgInfo, settings: SettingsGenerator) => Promise<RecordResult>; /** * This retrieves the ScratchOrgInfo, polling until the status is Active or Error * * @param hubOrg * @param scratchOrgInfoId - the id of the scratchOrgInfo that we are retrieving * @param timeout - A Duration object * @returns {Promise<ScratchOrgInfo>} */ export declare const pollForScratchOrgInfo: (hubOrg: Org, scratchOrgInfoId: string, timeout?: Duration) => Promise<ScratchOrgInfo>; /** * This authenticates into the newly created org and sets org preferences * * @param scratchOrgAuthInfo - an object containing the AuthInfo of the ScratchOrg * @param apiVersion - the target api version * @param orgSettings - The ScratchOrg settings * @param scratchOrg - The scratchOrg Org info * @returns {Promise<Optional<AuthInfo>>} */ export declare const deploySettingsAndResolveUrl: (scratchOrgAuthInfo: AuthInfo, apiVersion: string, orgSettings: SettingsGenerator, scratchOrg: Org) => Promise<Optional<AuthInfo>>;