@salesforce/core 3.16.2 → 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,12 @@
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
+
5
11
  ### [3.16.2](https://github.com/forcedotcom/sfdx-core/compare/v3.16.1...v3.16.2) (2022-05-11)
6
12
 
7
13
  ### [3.16.1](https://github.com/forcedotcom/sfdx-core/compare/v3.16.0...v3.16.1) (2022-05-11)
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.2",
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",