@salesforce/core 2.36.4 → 2.37.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,16 @@
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
+ ## [2.37.0](https://github.com/forcedotcom/sfdx-core/compare/v2.36.4...v2.37.0) (2022-05-03)
6
+
7
+ ### Features
8
+
9
+ - new cloneSandbox method ([69073dd](https://github.com/forcedotcom/sfdx-core/commit/69073dd71ee7372d13c86aaf052c798a4bea5176))
10
+
11
+ ### Bug Fixes
12
+
13
+ - use tooling api ([c32f19d](https://github.com/forcedotcom/sfdx-core/commit/c32f19d8de6a953f8390fd853d3be023db01d890))
14
+
5
15
  ### [2.36.4](https://github.com/forcedotcom/sfdx-core/compare/v2.36.3...v2.36.4) (2022-04-28)
6
16
 
7
17
  ### Bug Fixes
package/lib/org.d.ts CHANGED
@@ -105,6 +105,17 @@ export declare class Org extends AsyncCreatable<Org.Options> {
105
105
  wait?: Duration;
106
106
  interval?: Duration;
107
107
  }): Promise<SandboxProcessObject>;
108
+ /**
109
+ *
110
+ * @param sandboxReq SandboxRequest options to create the sandbox with
111
+ * @param sandboxName
112
+ * @param options Wait: The amount of time to wait before timing out, defaults to 0, Interval: The time interval between polling defaults to 30 seconds
113
+ * @returns {SandboxProcessObject} the newly created sandbox process object
114
+ */
115
+ cloneSandbox(sandboxReq: SandboxRequest, sandboxName: string, options: {
116
+ wait?: Duration;
117
+ interval?: Duration;
118
+ }): Promise<SandboxProcessObject>;
108
119
  /**
109
120
  * Creates a scratchOrg
110
121
  * 'this' needs to be a valid dev-hub
@@ -358,6 +369,12 @@ export declare class Org extends AsyncCreatable<Org.Options> {
358
369
  * @private
359
370
  */
360
371
  private querySandboxProcess;
372
+ /**
373
+ *
374
+ * @param sandboxNameIn
375
+ * @returns sandboxInfoId
376
+ */
377
+ private querySandboxInfoIdBySandboxName;
361
378
  /**
362
379
  * determines if the sandbox has successfully been created
363
380
  *
package/lib/org.js CHANGED
@@ -100,6 +100,18 @@ class Org extends kit_1.AsyncCreatable {
100
100
  pollInterval,
101
101
  });
102
102
  }
103
+ /**
104
+ *
105
+ * @param sandboxReq SandboxRequest options to create the sandbox with
106
+ * @param sandboxName
107
+ * @param options Wait: The amount of time to wait before timing out, defaults to 0, Interval: The time interval between polling defaults to 30 seconds
108
+ * @returns {SandboxProcessObject} the newly created sandbox process object
109
+ */
110
+ async cloneSandbox(sandboxReq, sandboxName, options) {
111
+ sandboxReq.SourceId = await this.querySandboxInfoIdBySandboxName(sandboxName);
112
+ this.logger.debug('Clone sandbox sourceId %s', sandboxReq.SourceId);
113
+ return this.createSandbox(sandboxReq, options);
114
+ }
103
115
  /**
104
116
  * Creates a scratchOrg
105
117
  * 'this' needs to be a valid dev-hub
@@ -861,6 +873,27 @@ class Org extends kit_1.AsyncCreatable {
861
873
  tooling: true,
862
874
  });
863
875
  }
876
+ /**
877
+ *
878
+ * @param sandboxNameIn
879
+ * @returns sandboxInfoId
880
+ */
881
+ async querySandboxInfoIdBySandboxName(sandboxNameIn) {
882
+ var _a;
883
+ this.logger.debug('QuerySandboxInfoIdBySandboxName called with SandboxName: %s ', sandboxNameIn);
884
+ const queryStr = `SELECT Id, SandboxName FROM SandboxInfo WHERE SandboxName='${sandboxNameIn}'`;
885
+ const queryResult = await this.connection.tooling.query(queryStr);
886
+ this.logger.debug('Return from calling queryToolingApi: %s ', JSON.stringify(queryResult));
887
+ if (((_a = queryResult === null || queryResult === void 0 ? void 0 : queryResult.records) === null || _a === void 0 ? void 0 : _a.length) === 1) {
888
+ return (queryResult === null || queryResult === void 0 ? void 0 : queryResult.records[0]).Id;
889
+ }
890
+ else if (queryResult.records && queryResult.records.length > 1) {
891
+ throw sfdxError_1.SfdxError.create('@salesforce/core', 'org', 'MultiSandboxInfoNotFoundBySandboxName', [sandboxNameIn]);
892
+ }
893
+ else {
894
+ throw sfdxError_1.SfdxError.create('@salesforce/core', 'org', 'SandboxInfoNotFoundBySandboxName', [sandboxNameIn]);
895
+ }
896
+ }
864
897
  /**
865
898
  * determines if the sandbox has successfully been created
866
899
  *
package/messages/org.json CHANGED
@@ -11,5 +11,7 @@
11
11
  "MissingAuthUsername": "The sandbox %s does not have an authorized username.",
12
12
  "OrgPollingTimeout": "Sandbox status is %s; timed out waiting for completion.",
13
13
  "SandboxProcessNotFoundBySandboxName": "We can't find a SandboxProcess with the SandboxName %s.",
14
- "MultiSandboxProcessNotFoundBySandboxName": "We found more than one SandboxProcess with the SandboxName %s."
14
+ "SandboxInfoNotFoundBySandboxName": "We can't find a SandboxInfo with the SandboxName %s.",
15
+ "MultiSandboxProcessNotFoundBySandboxName": "We found more than one SandboxProcess with the SandboxName %s.",
16
+ "MultiSandboxInfoNotFoundBySandboxName": "We found more than one SandboxInfo with the SandboxName %s."
15
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "2.36.4",
3
+ "version": "2.37.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",