@salesforce/core 3.16.0 → 3.17.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.17.0](https://github.com/forcedotcom/sfdx-core/compare/v3.16.2...v3.17.0) (2022-05-12)
6
+
7
+ ### Features
8
+
9
+ - sandboxStatus for v3 ([#571](https://github.com/forcedotcom/sfdx-core/issues/571)) ([60a004b](https://github.com/forcedotcom/sfdx-core/commit/60a004b663d918ec8b37d6ded7ddf12ce112b7f8))
10
+
11
+ ### [3.16.2](https://github.com/forcedotcom/sfdx-core/compare/v3.16.1...v3.16.2) (2022-05-11)
12
+
13
+ ### [3.16.1](https://github.com/forcedotcom/sfdx-core/compare/v3.16.0...v3.16.1) (2022-05-11)
14
+
15
+ ### Bug Fixes
16
+
17
+ - homedir can change after Core loads ([bb1e4f5](https://github.com/forcedotcom/sfdx-core/commit/bb1e4f5b1f59269f6d48a5389b1d76eeee252db0))
18
+
5
19
  ## [3.16.0](https://github.com/forcedotcom/sfdx-core/compare/v3.15.5...v3.16.0) (2022-05-04)
6
20
 
7
21
  ### Features
@@ -317,7 +317,7 @@ const _darwinImpl = {
317
317
  }
318
318
  },
319
319
  };
320
- const secretFile = path.join((0, os_1.homedir)(), global_1.Global.SFDX_STATE_FOLDER, 'key.json');
320
+ const getSecretFile = () => path.join(global_1.Global.SFDX_DIR, 'key.json');
321
321
  var SecretField;
322
322
  (function (SecretField) {
323
323
  SecretField["SERVICE"] = "service";
@@ -331,6 +331,7 @@ async function _writeFile(opts, fn) {
331
331
  [SecretField.KEY]: opts.password,
332
332
  [SecretField.SERVICE]: opts.service,
333
333
  };
334
+ const secretFile = getSecretFile();
334
335
  await mkdirp(path.dirname(secretFile));
335
336
  await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
336
337
  fn(null, contents);
@@ -341,7 +342,7 @@ async function _writeFile(opts, fn) {
341
342
  }
342
343
  async function _readFile() {
343
344
  // The file and access is validated before this method is called
344
- const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(secretFile, 'utf8'));
345
+ const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(getSecretFile(), 'utf8'));
345
346
  return {
346
347
  account: (0, ts_types_1.ensureString)(fileContents[SecretField.ACCOUNT]),
347
348
  password: (0, ts_types_1.asString)(fileContents[SecretField.KEY]),
@@ -368,7 +369,7 @@ class GenericKeychainAccess {
368
369
  else {
369
370
  // if the service and account names don't match then maybe someone or something is editing
370
371
  // that file. #donotallow
371
- fn(messages.createError('genericKeychainServiceError', [secretFile]));
372
+ fn(messages.createError('genericKeychainServiceError', [getSecretFile()]));
372
373
  }
373
374
  }
374
375
  catch (readJsonErr) {
@@ -428,6 +429,7 @@ class GenericUnixKeychainAccess extends GenericKeychainAccess {
428
429
  await cb(err);
429
430
  }
430
431
  else {
432
+ const secretFile = getSecretFile();
431
433
  const stats = await fs.promises.stat(secretFile);
432
434
  const octalModeStr = (stats.mode & 0o777).toString(8);
433
435
  const EXPECTED_OCTAL_PERM_VALUE = '600';
@@ -453,7 +455,7 @@ class GenericWindowsKeychainAccess extends GenericKeychainAccess {
453
455
  }
454
456
  else {
455
457
  try {
456
- await fs.promises.access(secretFile, fs.constants.R_OK | fs.constants.W_OK);
458
+ await fs.promises.access(getSecretFile(), fs.constants.R_OK | fs.constants.W_OK);
457
459
  await cb(null);
458
460
  }
459
461
  catch (e) {
package/lib/global.d.ts CHANGED
@@ -33,13 +33,13 @@ export declare class Global {
33
33
  *
34
34
  * **See** {@link Global.SFDX_STATE_FOLDER}
35
35
  */
36
- static readonly SFDX_DIR: string;
36
+ static get SFDX_DIR(): string;
37
37
  /**
38
38
  * The full system path to the global sf state folder.
39
39
  *
40
40
  * **See** {@link Global.SF_STATE_FOLDER}
41
41
  */
42
- static readonly SF_DIR: string;
42
+ static get SF_DIR(): string;
43
43
  /**
44
44
  * The full system path to the global log file.
45
45
  */
package/lib/global.js CHANGED
@@ -28,6 +28,22 @@ var Mode;
28
28
  * Global constants, methods, and configuration.
29
29
  */
30
30
  class Global {
31
+ /**
32
+ * The full system path to the global sfdx state folder.
33
+ *
34
+ * **See** {@link Global.SFDX_STATE_FOLDER}
35
+ */
36
+ static get SFDX_DIR() {
37
+ return path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
38
+ }
39
+ /**
40
+ * The full system path to the global sf state folder.
41
+ *
42
+ * **See** {@link Global.SF_STATE_FOLDER}
43
+ */
44
+ static get SF_DIR() {
45
+ return path.join(os.homedir(), Global.SF_STATE_FOLDER);
46
+ }
31
47
  /**
32
48
  * Gets the current mode environment variable as a {@link Mode} instance.
33
49
  *
@@ -64,18 +80,6 @@ Global.SFDX_STATE_FOLDER = '.sfdx';
64
80
  * The global folder in which sf state is stored.
65
81
  */
66
82
  Global.SF_STATE_FOLDER = '.sf';
67
- /**
68
- * The full system path to the global sfdx state folder.
69
- *
70
- * **See** {@link Global.SFDX_STATE_FOLDER}
71
- */
72
- Global.SFDX_DIR = path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
73
- /**
74
- * The full system path to the global sf state folder.
75
- *
76
- * **See** {@link Global.SF_STATE_FOLDER}
77
- */
78
- Global.SF_DIR = path.join(os.homedir(), Global.SF_STATE_FOLDER);
79
83
  /**
80
84
  * The full system path to the global log file.
81
85
  */
@@ -20,15 +20,6 @@ export declare type DeployOptionsWithRest = Partial<DeployOptions> & {
20
20
  };
21
21
  export interface Tooling<S extends Schema = Schema> extends JSForceTooling<S> {
22
22
  _logger: any;
23
- /**
24
- * Executes a query and auto-fetches (i.e., "queryMore") all results. This is especially
25
- * useful with large query result sizes, such as over 2000 records. The default maximum
26
- * fetch size is 10,000 records. Modify this via the options argument.
27
- *
28
- * @param soql The SOQL string.
29
- * @param options The query options. NOTE: the autoFetch option will always be true.
30
- */
31
- autoFetchQuery<T extends Schema = S>(soql: string, options?: QueryOptions): Promise<QueryResult<T>>;
32
23
  }
33
24
  /**
34
25
  * Handles connections and requests to Salesforce Orgs.
@@ -58,8 +58,6 @@ class Connection extends jsforce_1.Connection {
58
58
  */
59
59
  constructor(options) {
60
60
  super(options.connectionOptions || {});
61
- // eslint-disable-next-line @typescript-eslint/unbound-method
62
- this.tooling.autoFetchQuery = Connection.prototype.autoFetchQuery;
63
61
  this.options = options;
64
62
  this.username = options.authInfo.getUsername();
65
63
  }
package/lib/org/org.d.ts CHANGED
@@ -140,6 +140,17 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
140
140
  * @returns {ScratchOrgCreateResult}
141
141
  */
142
142
  scratchOrgCreate(options: ScratchOrgRequest): Promise<ScratchOrgCreateResult>;
143
+ /**
144
+ * Reports sandbox org creation status. If the org is ready, authenticates to the org.
145
+ *
146
+ * @param {sandboxname} string the sandbox name
147
+ * @param options Wait: The amount of time to wait before timing out, Interval: The time interval between polling
148
+ * @returns {SandboxProcessObject} the sandbox process object
149
+ */
150
+ sandboxStatus(sandboxname: string, options: {
151
+ wait?: Duration;
152
+ interval?: Duration;
153
+ }): Promise<SandboxProcessObject>;
143
154
  /**
144
155
  * Clean all data files in the org's data path. Usually <workspace>/.sfdx/orgs/<username>.
145
156
  *
@@ -348,6 +359,29 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
348
359
  * **Throws** *{@link SfError}{ name: 'NotSupportedError' }* Throws an unsupported error.
349
360
  */
350
361
  protected getDefaultOptions(): Org.Options;
362
+ /**
363
+ * Gets the sandboxProcessObject and then polls for it to complete.
364
+ *
365
+ * @param sandboxProcessName sanbox process name
366
+ * @param options { wait?: Duration; interval?: Duration }
367
+ * @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
368
+ */
369
+ private authWithRetriesByName;
370
+ /**
371
+ * Polls the sandbox org for the sandboxProcessObject.
372
+ *
373
+ * @param sandboxProcessObj: The in-progress sandbox signup request
374
+ * @param options { wait?: Duration; interval?: Duration }
375
+ * @returns {SandboxProcessObject}
376
+ */
377
+ private authWithRetries;
378
+ /**
379
+ * Query the sandbox for the SandboxProcessObject by sandbox name
380
+ *
381
+ * @param sandboxName The name of the sandbox to query
382
+ * @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
383
+ */
384
+ private queryLatestSandboxProcessBySandboxName;
351
385
  private queryProduction;
352
386
  private destroySandbox;
353
387
  private destroyScratchOrg;
package/lib/org/org.js CHANGED
@@ -41,6 +41,8 @@ const messages = messages_1.Messages.load('@salesforce/core', 'org', [
41
41
  'scratchOrgNotFound',
42
42
  'AuthInfoOrgIdUndefined',
43
43
  'sandboxCreateNotComplete',
44
+ 'SandboxProcessNotFoundBySandboxName',
45
+ 'MultiSandboxProcessNotFoundBySandboxName',
44
46
  ]);
45
47
  var OrgTypes;
46
48
  (function (OrgTypes) {
@@ -192,6 +194,16 @@ class Org extends kit_1.AsyncOptionalCreatable {
192
194
  async scratchOrgCreate(options) {
193
195
  return (0, scratchOrgCreate_1.scratchOrgCreate)({ ...options, hubOrg: this });
194
196
  }
197
+ /**
198
+ * Reports sandbox org creation status. If the org is ready, authenticates to the org.
199
+ *
200
+ * @param {sandboxname} string the sandbox name
201
+ * @param options Wait: The amount of time to wait before timing out, Interval: The time interval between polling
202
+ * @returns {SandboxProcessObject} the sandbox process object
203
+ */
204
+ async sandboxStatus(sandboxname, options) {
205
+ return this.authWithRetriesByName(sandboxname, options);
206
+ }
195
207
  /**
196
208
  * Clean all data files in the org's data path. Usually <workspace>/.sfdx/orgs/<username>.
197
209
  *
@@ -710,6 +722,58 @@ class Org extends kit_1.AsyncOptionalCreatable {
710
722
  getDefaultOptions() {
711
723
  throw new sfError_1.SfError('Not Supported', 'NotSupportedError');
712
724
  }
725
+ /**
726
+ * Gets the sandboxProcessObject and then polls for it to complete.
727
+ *
728
+ * @param sandboxProcessName sanbox process name
729
+ * @param options { wait?: Duration; interval?: Duration }
730
+ * @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
731
+ */
732
+ async authWithRetriesByName(sandboxProcessName, options) {
733
+ return this.authWithRetries(await this.queryLatestSandboxProcessBySandboxName(sandboxProcessName), options);
734
+ }
735
+ /**
736
+ * Polls the sandbox org for the sandboxProcessObject.
737
+ *
738
+ * @param sandboxProcessObj: The in-progress sandbox signup request
739
+ * @param options { wait?: Duration; interval?: Duration }
740
+ * @returns {SandboxProcessObject}
741
+ */
742
+ async authWithRetries(sandboxProcessObj, options = {
743
+ wait: kit_1.Duration.minutes(0),
744
+ interval: kit_1.Duration.seconds(30),
745
+ }) {
746
+ const [wait, pollInterval] = this.validateWaitOptions(options);
747
+ this.logger.debug(`AuthWithRetries sandboxProcessObj ${sandboxProcessObj}, max wait time of ${wait.minutes} minutes`);
748
+ return this.pollStatusAndAuth({
749
+ sandboxProcessObj,
750
+ wait,
751
+ pollInterval,
752
+ });
753
+ }
754
+ /**
755
+ * Query the sandbox for the SandboxProcessObject by sandbox name
756
+ *
757
+ * @param sandboxName The name of the sandbox to query
758
+ * @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
759
+ */
760
+ async queryLatestSandboxProcessBySandboxName(sandboxNameIn) {
761
+ var _a;
762
+ const { tooling } = this.getConnection();
763
+ this.logger.debug('QueryLatestSandboxProcessBySandboxName called with SandboxName: %s ', sandboxNameIn);
764
+ const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE SandboxName='${sandboxNameIn}' AND Status != 'D' ORDER BY CreatedDate DESC LIMIT 1`;
765
+ const queryResult = await tooling.query(queryStr);
766
+ this.logger.debug('Return from calling queryToolingApi: %s ', queryResult);
767
+ if (((_a = queryResult === null || queryResult === void 0 ? void 0 : queryResult.records) === null || _a === void 0 ? void 0 : _a.length) === 1) {
768
+ return queryResult.records[0];
769
+ }
770
+ else if (queryResult.records && queryResult.records.length > 1) {
771
+ throw messages.createError('MultiSandboxProcessNotFoundBySandboxName', [sandboxNameIn]);
772
+ }
773
+ else {
774
+ throw messages.createError('SandboxProcessNotFoundBySandboxName', [sandboxNameIn]);
775
+ }
776
+ }
713
777
  async queryProduction(org, field, value) {
714
778
  return org.connection.singleRecordQuery(`SELECT SandboxInfoId FROM SandboxProcess WHERE ${field} ='${value}' AND Status NOT IN ('D', 'E')`, { tooling: true });
715
779
  }
package/messages/org.md CHANGED
@@ -53,3 +53,11 @@ AuthInfo orgId is undefined.
53
53
  # sandboxCreateNotComplete
54
54
 
55
55
  The sandbox creation has not completed.
56
+
57
+ # SandboxProcessNotFoundBySandboxName
58
+
59
+ We can't find a SandboxProcess with the SandboxName %s.
60
+
61
+ # MultiSandboxProcessNotFoundBySandboxName
62
+
63
+ We found more than one SandboxProcess with the SandboxName %s.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
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",