How to use the @salesforce/core.Org.create function in @salesforce/core

To help you get started, we’ve selected a few @salesforce/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ChuckJonas / ts-force / ts-force-gen / src / index.ts View on Github external
config.sObjects = (args.sObjects || args.s).split(',');
    }

    if (config.auth.accessToken === undefined) {
        // if just username is set, load from sfdx
        if (config.auth.username !== undefined && config.auth.password === undefined) {
            let username = await Aliases.fetch(config.auth.username);
            if (username) {
                config.auth.username = username;
            }
            console.log(config.auth.username);
            let connection: Connection = await Connection.create({
                authInfo: await AuthInfo.create({ username: config.auth.username }
                )
            });
            let org = await Org.create({ connection });
            await org.refreshAuth();
            connection = org.getConnection();

            config.auth.accessToken = connection.accessToken;
            config.auth.instanceUrl = connection.instanceUrl;
        } else if (config.auth.username !== undefined && config.auth.password !== undefined) {

            // otherwise lets try username/password flow
            let pwConfig = new UsernamePasswordConfig(
                config.auth.clientId,
                config.auth.clientSecret,
                config.auth.oAuthHost,
                config.auth.username,
                config.auth.password
            );
github eltoroit / ETCopyData / src / @ELTOROIT / OrgManager.ts View on Github external
return new Promise((resolve, reject) => {
			try {
				this.alias = alias;
				Org.create({ aliasOrUsername: alias })
					.then((resOrg: Org) => {
						this.conn = resOrg.getConnection();
						// LEARNING: How to generate the URL that sfdx force:org:open generates?
						// this.conn.instanceUrl + "/secur/frontdoor.jsp\?sid\=" + this.conn.accessToken
						Util.writeLog(`[${this.alias}] Alias for username: [${resOrg.getUsername()}]`, LogLevel.INFO);
						this.order = new SchemaOrder(this);
						this.discovery = new SchemaDiscovery(this);
						resolve(this);
					});
			} catch (ex) {
				this.resetValues(this.alias);
				const msg = "Alias [" + this.alias + "] does not reference a valid org";
				Util.throwError(msg);
				reject(msg);
			}
		});
github forcedotcom / salesforcedx-vscode / packages / salesforcedx-sobjects-faux-generator / src / describe / sObjectDescribe.ts View on Github external
public async describeSObjectBatch(
    projectPath: string,
    types: string[],
    nextToProcess: number
  ): Promise {
    try {
      const org = await Org.create({
        aliasOrUsername: await ConfigUtil.getUsername(projectPath)
      });

      if (!this.accessToken || !this.instanceUrl) {
        await this.getConnectionData(org);
      }

      let response: XHRResponse;
      let options: XHROptions;
      try {
        options = this.buildXHROptions(types, nextToProcess);
        response = await this.runRequest(options);
      } catch (e) {
        if (e.status !== 401) {
          throw e;
        }