UNPKG

@salesforce/core

Version:

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

51 lines 2.29 kB
"use strict"; /* * Copyright 2026, Salesforce, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.determineOrg = determineOrg; const logger_1 = require("../logger/logger"); const connection_1 = require("./connection"); const org_1 = require("./org"); async function determineOrg(orgAuthInfo) { const fields = orgAuthInfo.getFields(); if (fields.orgEdition && fields.namespacePrefix !== undefined) return; try { const conn = await connection_1.Connection.create({ authInfo: orgAuthInfo }); const result = await conn.singleRecordQuery('SELECT Name, InstanceName, IsSandbox, TrialExpirationDate, NamespacePrefix, OrganizationType FROM Organization'); if (fields.orgEdition) { await orgAuthInfo.save({ [org_1.Org.Fields.NAMESPACE_PREFIX]: result.NamespacePrefix, }); } else { await orgAuthInfo.save({ [org_1.Org.Fields.NAME]: result.Name, [org_1.Org.Fields.INSTANCE_NAME]: result.InstanceName, [org_1.Org.Fields.NAMESPACE_PREFIX]: result.NamespacePrefix, [org_1.Org.Fields.IS_SANDBOX]: result.IsSandbox && !result.TrialExpirationDate, [org_1.Org.Fields.IS_SCRATCH]: result.IsSandbox && Boolean(result.TrialExpirationDate), [org_1.Org.Fields.TRIAL_EXPIRATION_DATE]: result.TrialExpirationDate, [org_1.Org.Fields.ORG_EDITION]: result.OrganizationType, }); } } catch (err) { const logger = await logger_1.Logger.child('AuthInfo', { tag: 'determineOrg' }); logger.debug('determineOrg failed', err); } } //# sourceMappingURL=determineOrg.js.map