@salesforce/core 3.23.8 → 3.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,15 +35,13 @@ class GlobalInfoOrgAccessor {
35
35
  return !!this.getAll()[username];
36
36
  }
37
37
  set(username, org) {
38
- var _a;
39
38
  // For legacy, and to keep things standard, some things wants the username in auth info.
40
- (_a = org.username) !== null && _a !== void 0 ? _a : (org.username = username);
39
+ org.username ?? (org.username = username);
41
40
  this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
42
41
  }
43
42
  update(username, org) {
44
- var _a;
45
43
  // For legacy, and to keep things standard, some things wants the username in auth info.
46
- (_a = org.username) !== null && _a !== void 0 ? _a : (org.username = username);
44
+ org.username ?? (org.username = username);
47
45
  this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
48
46
  }
49
47
  unset(username) {
@@ -176,17 +174,16 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
176
174
  * @param org
177
175
  */
178
176
  set(username, org) {
179
- var _a, _b;
180
177
  const config = this.configs.get(username);
181
178
  if (config) {
182
179
  config.setContentsFromObject(org);
183
180
  const contents = config.getContents();
184
- (_a = contents.username) !== null && _a !== void 0 ? _a : (contents.username = username);
181
+ contents.username ?? (contents.username = username);
185
182
  this.contents.set(username, contents);
186
183
  }
187
184
  else {
188
185
  // @ts-ignore
189
- (_b = org.username) !== null && _b !== void 0 ? _b : (org.username = username);
186
+ org.username ?? (org.username = username);
190
187
  this.contents.set(username, org);
191
188
  }
192
189
  }
@@ -207,8 +204,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
207
204
  * @param username
208
205
  */
209
206
  async remove(username) {
210
- var _a;
211
- await ((_a = this.configs.get(username)) === null || _a === void 0 ? void 0 : _a.unlink());
207
+ await this.configs.get(username)?.unlink();
212
208
  this.configs.delete(username);
213
209
  this.contents.delete(username);
214
210
  }
@@ -39,8 +39,7 @@ class GlobalInfoSandboxAccessor {
39
39
  * @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
40
40
  */
41
41
  get(sandboxOrgId) {
42
- var _a;
43
- return sandboxOrgId ? (_a = this.getAll()[sandboxOrgId]) !== null && _a !== void 0 ? _a : null : null;
42
+ return sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null;
44
43
  }
45
44
  /**
46
45
  * Returns true if the given sandbox org id exists
@@ -48,8 +47,7 @@ class GlobalInfoSandboxAccessor {
48
47
  * @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
49
48
  */
50
49
  has(sandboxOrgId) {
51
- var _a;
52
- return !!(sandboxOrgId ? (_a = this.getAll()[sandboxOrgId]) !== null && _a !== void 0 ? _a : null : null);
50
+ return !!(sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null);
53
51
  }
54
52
  /**
55
53
  * Set an sandboxOrgId for the given sandbox entity
@@ -50,13 +50,12 @@ class SfdxDataHandler {
50
50
  exports.SfdxDataHandler = SfdxDataHandler;
51
51
  class BaseHandler {
52
52
  async merge(sfData = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
53
- var _a, _b;
54
53
  const sfdxData = await this.migrate();
55
54
  const merged = (0, globalInfoConfig_1.deepCopy)(sfData);
56
55
  // Only merge the key this handler is responsible for.
57
56
  const key = this.sfKey;
58
- const sfKeys = Object.keys((_a = sfData[key]) !== null && _a !== void 0 ? _a : {});
59
- const sfdxKeys = Object.keys((_b = sfdxData[key]) !== null && _b !== void 0 ? _b : {});
57
+ const sfKeys = Object.keys(sfData[key] ?? {});
58
+ const sfdxKeys = Object.keys(sfdxData[key] ?? {});
60
59
  const commonKeys = sfKeys.filter((k) => sfdxKeys.includes(k));
61
60
  for (const k of commonKeys) {
62
61
  const [newer, older] = [sfData[key][k], sfdxData[key][k]].sort((a, b) => {
@@ -115,12 +114,11 @@ class AuthHandler extends BaseHandler {
115
114
  }));
116
115
  }
117
116
  async findChanges(latest, original) {
118
- var _a;
119
117
  const latestAuths = latest.orgs;
120
118
  const originalAuths = original.orgs;
121
119
  const changed = {};
122
120
  for (const [username, auth] of Object.entries(latestAuths)) {
123
- const originalAuth = (_a = originalAuths[username]) !== null && _a !== void 0 ? _a : {};
121
+ const originalAuth = originalAuths[username] ?? {};
124
122
  if (!isEqual(auth, originalAuth)) {
125
123
  changed[username] = auth;
126
124
  }
@@ -218,13 +216,12 @@ class SandboxesHandler extends BaseHandler {
218
216
  this.sfKey = types_1.SfInfoKeys.SANDBOXES;
219
217
  }
220
218
  async merge(sfData = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
221
- var _a, _b;
222
219
  const sfdxData = await this.migrate();
223
220
  const merged = (0, globalInfoConfig_1.deepCopy)(sfData);
224
221
  // Only merge the key this handler is responsible for.
225
222
  const key = this.sfKey;
226
- const sfKeys = Object.keys((_a = sfData[key]) !== null && _a !== void 0 ? _a : {});
227
- const sfdxKeys = Object.keys((_b = sfdxData[key]) !== null && _b !== void 0 ? _b : {});
223
+ const sfKeys = Object.keys(sfData[key] ?? {});
224
+ const sfdxKeys = Object.keys(sfdxData[key] ?? {});
228
225
  // sandbox entries for .sf and .sfdx contain static data. Given there
229
226
  // can be no mutation during the life of the sandbox, having to merge common keys
230
227
  // is unnecessary.
@@ -289,12 +286,11 @@ class SandboxesHandler extends BaseHandler {
289
286
  }));
290
287
  }
291
288
  async findChanges(latest, original) {
292
- var _a;
293
289
  const latestSandboxes = latest.sandboxes;
294
290
  const originalSandboxes = original.sandboxes;
295
291
  const changed = {};
296
292
  for (const [sandboxOrgId, sandbox] of Object.entries(latestSandboxes)) {
297
- const originalSandbox = (_a = originalSandboxes[sandboxOrgId]) !== null && _a !== void 0 ? _a : {};
293
+ const originalSandbox = originalSandboxes[sandboxOrgId] ?? {};
298
294
  if (!isEqual(sandbox, originalSandbox)) {
299
295
  changed[sandboxOrgId] = sandbox;
300
296
  }
@@ -53,7 +53,6 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
53
53
  * in the polling options.
54
54
  */
55
55
  async subscribe() {
56
- var _a;
57
56
  let errorInPollingFunction; // keep this around for returning in the catch block
58
57
  const doPoll = async () => {
59
58
  let result;
@@ -89,7 +88,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
89
88
  }
90
89
  await lifecycleEvents_1.Lifecycle.getInstance().emit('POLLING_TIME_OUT', error);
91
90
  this.logger.debug('Polling timed out');
92
- throw new sfError_1.SfError('The client has timed out.', (_a = this.options.timeoutErrorName) !== null && _a !== void 0 ? _a : 'PollingClientTimeout');
91
+ throw new sfError_1.SfError('The client has timed out.', this.options.timeoutErrorName ?? 'PollingClientTimeout');
93
92
  }
94
93
  }
95
94
  }
package/lib/testSetup.js CHANGED
@@ -41,11 +41,10 @@ const global_1 = require("./global");
41
41
  * - length: the length of the unique id as presented in hexadecimal.
42
42
  */
43
43
  function uniqid(options) {
44
- var _a, _b;
45
- const uniqueString = (0, crypto_1.randomBytes)(Math.ceil(((_a = options === null || options === void 0 ? void 0 : options.length) !== null && _a !== void 0 ? _a : 32) / 2.0))
44
+ const uniqueString = (0, crypto_1.randomBytes)(Math.ceil((options?.length ?? 32) / 2.0))
46
45
  .toString('hex')
47
- .slice(0, (_b = options === null || options === void 0 ? void 0 : options.length) !== null && _b !== void 0 ? _b : 32);
48
- if (!(options === null || options === void 0 ? void 0 : options.template)) {
46
+ .slice(0, options?.length ?? 32);
47
+ if (!options?.template) {
49
48
  return uniqueString;
50
49
  }
51
50
  return options.template.includes('%s')
@@ -168,9 +167,8 @@ const instantiateContext = (sinon) => {
168
167
  return orgMap.has(username);
169
168
  });
170
169
  const retrieveContents = async function () {
171
- var _a;
172
170
  const username = (0, path_1.basename)(this.path.replace('.json', ''));
173
- return Promise.resolve((_a = orgMap.get(username)) !== null && _a !== void 0 ? _a : {});
171
+ return Promise.resolve(orgMap.get(username) ?? {});
174
172
  };
175
173
  this.configStubs.AuthInfoConfig = { retrieveContents };
176
174
  },
@@ -179,9 +177,8 @@ const instantiateContext = (sinon) => {
179
177
  const sandboxMap = new Map(entries);
180
178
  (0, ts_sinon_1.stubMethod)(testContext.SANDBOX, sandboxAccessor_1.SandboxAccessor.prototype, 'getAllFiles').returns([...sandboxMap.keys()].map((o) => `${o}.sandbox.json`));
181
179
  const retrieveContents = async function () {
182
- var _a;
183
180
  const username = (0, path_1.basename)(this.path.replace('.sandbox.json', ''));
184
- return Promise.resolve((_a = sandboxMap.get(username)) !== null && _a !== void 0 ? _a : {});
181
+ return Promise.resolve(sandboxMap.get(username) ?? {});
185
182
  };
186
183
  this.configStubs.SandboxOrgConfig = { retrieveContents };
187
184
  },
@@ -595,7 +592,7 @@ class MockTestOrgData {
595
592
  this.testId = id;
596
593
  this.userId = `user_id_${this.testId}`;
597
594
  this.orgId = `${this.testId}`;
598
- this.username = (options === null || options === void 0 ? void 0 : options.username) || `admin_${this.testId}@gb.org`;
595
+ this.username = options?.username || `admin_${this.testId}@gb.org`;
599
596
  this.loginUrl = `https://login.${this.testId}.salesforce.com`;
600
597
  this.instanceUrl = `https://instance.${this.testId}.salesforce.com`;
601
598
  this.clientId = `${this.testId}/client_id`;
@@ -702,9 +699,9 @@ class MockTestSandboxData {
702
699
  constructor(id = uniqid(), options) {
703
700
  this.id = id;
704
701
  this.sandboxOrgId = id;
705
- this.prodOrgUsername = (options === null || options === void 0 ? void 0 : options.prodOrgUsername) || `admin_${id}@gb.org`;
706
- this.sandboxName = (options === null || options === void 0 ? void 0 : options.name) || `sandbox_${id}`;
707
- this.username = (options === null || options === void 0 ? void 0 : options.username) || `${this.prodOrgUsername}.sandbox`;
702
+ this.prodOrgUsername = options?.prodOrgUsername || `admin_${id}@gb.org`;
703
+ this.sandboxName = options?.name || `sandbox_${id}`;
704
+ this.username = options?.username || `${this.prodOrgUsername}.sandbox`;
708
705
  }
709
706
  /**
710
707
  * Return the auth config file contents.
@@ -11,9 +11,8 @@ const kit_1 = require("@salesforce/kit");
11
11
  const myDomainResolver_1 = require("../status/myDomainResolver");
12
12
  const sfdc_1 = require("./sfdc");
13
13
  async function checkLightningDomain(url) {
14
- var _a, _b;
15
- const domain = `https://${(_a = /https?:\/\/([^.]*)/.exec(url)) === null || _a === void 0 ? void 0 : _a.slice(1, 2).pop()}.lightning.force.com`;
16
- const quantity = (_b = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240)) !== null && _b !== void 0 ? _b : 0;
14
+ const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.slice(1, 2).pop()}.lightning.force.com`;
15
+ const quantity = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240) ?? 0;
17
16
  const timeout = new kit_1.Duration(quantity, kit_1.Duration.Unit.SECONDS);
18
17
  if (sfdc_1.sfdc.isInternalUrl(url) || timeout.seconds === 0) {
19
18
  return true;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import * as http from 'http';
3
+ import { JwtOAuth2Config } from 'jsforce';
3
4
  import { AsyncCreatable } from '@salesforce/kit';
4
- import { AuthInfo, OAuth2Config } from './org/authInfo';
5
+ import { AuthInfo } from './org';
5
6
  /**
6
7
  * Handles the creation of a web server for web based login flows.
7
8
  *
@@ -79,7 +80,7 @@ export declare class WebOAuthServer extends AsyncCreatable<WebOAuthServer.Option
79
80
  }
80
81
  export declare namespace WebOAuthServer {
81
82
  interface Options {
82
- oauthConfig: OAuth2Config;
83
+ oauthConfig: JwtOAuth2Config;
83
84
  }
84
85
  type Request = http.IncomingMessage & {
85
86
  query: {
@@ -11,11 +11,11 @@ const http = require("http");
11
11
  const querystring_1 = require("querystring");
12
12
  const url_1 = require("url");
13
13
  const net_1 = require("net");
14
+ const jsforce_1 = require("jsforce");
14
15
  const kit_1 = require("@salesforce/kit");
15
16
  const ts_types_1 = require("@salesforce/ts-types");
16
- const jsforce_1 = require("jsforce");
17
17
  const logger_1 = require("./logger");
18
- const authInfo_1 = require("./org/authInfo");
18
+ const org_1 = require("./org");
19
19
  const sfError_1 = require("./sfError");
20
20
  const messages_1 = require("./messages");
21
21
  const sfProject_1 = require("./sfProject");
@@ -85,7 +85,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
85
85
  this.executeOauthRequest()
86
86
  .then(async (response) => {
87
87
  try {
88
- const authInfo = await authInfo_1.AuthInfo.create({
88
+ const authInfo = await org_1.AuthInfo.create({
89
89
  oauth2Options: this.oauthConfig,
90
90
  oauth2: this.oauth2,
91
91
  });
@@ -127,14 +127,14 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
127
127
  this.logger = await logger_1.Logger.child(this.constructor.name);
128
128
  const port = await WebOAuthServer.determineOauthPort();
129
129
  if (!this.oauthConfig.clientId)
130
- this.oauthConfig.clientId = authInfo_1.DEFAULT_CONNECTED_APP_INFO.clientId;
130
+ this.oauthConfig.clientId = org_1.DEFAULT_CONNECTED_APP_INFO.clientId;
131
131
  if (!this.oauthConfig.loginUrl)
132
- this.oauthConfig.loginUrl = authInfo_1.AuthInfo.getDefaultInstanceUrl();
132
+ this.oauthConfig.loginUrl = org_1.AuthInfo.getDefaultInstanceUrl();
133
133
  if (!this.oauthConfig.redirectUri)
134
134
  this.oauthConfig.redirectUri = `http://localhost:${port}/OauthRedirect`;
135
135
  this.webServer = await WebServer.create({ port });
136
136
  this.oauth2 = new jsforce_1.OAuth2(this.oauthConfig);
137
- this.authUrl = authInfo_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
137
+ this.authUrl = org_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
138
138
  }
139
139
  /**
140
140
  * Executes the oauth request
@@ -18,26 +18,6 @@ Expected 'durationDays' to be an integer number.
18
18
 
19
19
  Expected 'retry' to be an integer number.
20
20
 
21
- # WaitValidationMaxError
22
-
23
- Expected 'wait' greater than or equal to %s but received %s.
24
-
25
- # NoScratchOrgInfoError
26
-
27
- No ScratchOrgInfo object found in the Dev Hub you specified. Check that the ID and the Dev Hub are correct.
28
-
29
- # ScratchOrgDeletedError
30
-
31
- That scratch org has been deleted, so you can't connect to it anymore.
32
-
33
21
  # CacheMissError
34
22
 
35
23
  The ScratchOrgInfoId %s was not found in the cache.
36
-
37
- # StillInProgressError
38
-
39
- The scratch org is not ready yet (Status = %).
40
-
41
- # action.StillInProgress
42
-
43
- Wait for a few minutes, and then try the <%= config.bin %> <%= command.id %> command again
@@ -14,6 +14,22 @@ See https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_ob
14
14
 
15
15
  The request to create a scratch org returned an unexpected status
16
16
 
17
+ # StillInProgressError
18
+
19
+ The scratch org is not ready yet (Status = %).
20
+
21
+ # action.StillInProgress
22
+
23
+ Wait for a few minutes, and then try the <%= config.bin %> <%= command.id %> command again
24
+
25
+ # NoScratchOrgInfoError
26
+
27
+ No ScratchOrgInfo object found in the Dev Hub you specified. Check that the ID and the Dev Hub are correct.
28
+
29
+ # ScratchOrgDeletedError
30
+
31
+ That scratch org has been deleted, so you can't connect to it anymore.
32
+
17
33
  # INVALID_ID_FIELD
18
34
 
19
35
  Provide a valid template ID, in the format 0TTxxxxxxxxxxxx.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.23.8",
3
+ "version": "3.24.1",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -49,7 +49,7 @@
49
49
  "form-data": "^4.0.0",
50
50
  "graceful-fs": "^4.2.9",
51
51
  "js2xmlparser": "^4.0.1",
52
- "jsforce": "2.0.0-beta.14",
52
+ "jsforce": "^2.0.0-beta.16",
53
53
  "jsonwebtoken": "8.5.1",
54
54
  "mkdirp": "1.0.4",
55
55
  "ts-retry-promise": "^0.6.0"