@salesforce/core 8.30.3 → 8.31.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/lib/org/authInfo.d.ts +0 -1
- package/lib/org/authInfo.js +4 -26
- package/lib/org/determineOrg.d.ts +2 -0
- package/lib/org/determineOrg.js +42 -0
- package/lib/org/org.d.ts +9 -0
- package/lib/org/org.js +14 -0
- package/lib/testSetup.d.ts +1 -0
- package/lib/testSetup.js +3 -0
- package/package.json +3 -3
package/lib/org/authInfo.d.ts
CHANGED
package/lib/org/authInfo.js
CHANGED
|
@@ -54,6 +54,7 @@ const messages_1 = require("../messages");
|
|
|
54
54
|
const sfdcUrl_1 = require("../util/sfdcUrl");
|
|
55
55
|
const findSuggestion_1 = require("../util/findSuggestion");
|
|
56
56
|
const connection_1 = require("./connection");
|
|
57
|
+
const determineOrg_1 = require("./determineOrg");
|
|
57
58
|
const org_1 = require("./org");
|
|
58
59
|
const orgConfigProperties_1 = require("./orgConfigProperties");
|
|
59
60
|
;
|
|
@@ -267,6 +268,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
267
268
|
// This is so we don't have to call authInfo.getFields(true) and decrypt again OR accidentally save an
|
|
268
269
|
// authInfo before it is necessary.
|
|
269
270
|
const logger = await logger_1.Logger.child('Common', { tag: 'identifyPossibleScratchOrgs' });
|
|
271
|
+
await (0, determineOrg_1.determineOrg)(orgAuthInfo);
|
|
270
272
|
// return if we already know the hub org, we know it is a devhub or prod-like, or no orgId present
|
|
271
273
|
if (Boolean(fields.isDevHub) || Boolean(fields.devHubUsername) || !fields.orgId)
|
|
272
274
|
return;
|
|
@@ -753,14 +755,12 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
753
755
|
}
|
|
754
756
|
}
|
|
755
757
|
authConfig.isDevHub = await this.determineIfDevHub((0, ts_types_1.ensureString)(authConfig.instanceUrl), (0, ts_types_1.ensureString)(authConfig.accessToken));
|
|
756
|
-
const namespacePrefix = await this.getNamespacePrefix((0, ts_types_1.ensureString)(authConfig.instanceUrl), (0, ts_types_1.ensureString)(authConfig.accessToken));
|
|
757
|
-
if (namespacePrefix) {
|
|
758
|
-
authConfig.namespacePrefix = namespacePrefix;
|
|
759
|
-
}
|
|
760
758
|
if (authConfig.username)
|
|
761
759
|
await this.stateAggregator.orgs.read(authConfig.username, false, false);
|
|
762
760
|
// Update the auth fields WITH encryption
|
|
763
761
|
this.update(authConfig);
|
|
762
|
+
// Populate Organization metadata (orgEdition, isScratch, isSandbox, etc.) in a single query.
|
|
763
|
+
await (0, determineOrg_1.determineOrg)(this);
|
|
764
764
|
}
|
|
765
765
|
return this;
|
|
766
766
|
}
|
|
@@ -1029,28 +1029,6 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
1029
1029
|
}
|
|
1030
1030
|
throw new sfError_1.SfError(errorMsg);
|
|
1031
1031
|
}
|
|
1032
|
-
async getNamespacePrefix(instanceUrl, accessToken) {
|
|
1033
|
-
// Make a REST call for the Organization obj directly. Normally this is done via a connection
|
|
1034
|
-
// but we don't want to create circular dependencies or lots of snowflakes
|
|
1035
|
-
// within this file to support it.
|
|
1036
|
-
const apiVersion = 'v51.0'; // hardcoding to v51.0 just for this call is okay.
|
|
1037
|
-
const instance = (0, ts_types_1.ensure)(instanceUrl);
|
|
1038
|
-
const baseUrl = new sfdcUrl_1.SfdcUrl(instance);
|
|
1039
|
-
const namespacePrefixOrgUrl = `${baseUrl.toString()}/services/data/${apiVersion}/query?q=Select%20Namespaceprefix%20FROM%20Organization`;
|
|
1040
|
-
const headers = Object.assign({ Authorization: `Bearer ${accessToken}` }, connection_1.SFDX_HTTP_HEADERS);
|
|
1041
|
-
try {
|
|
1042
|
-
const res = await new transport_1.default().httpRequest({ url: namespacePrefixOrgUrl, method: 'GET', headers });
|
|
1043
|
-
if (res.statusCode >= 400) {
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1046
|
-
const namespacePrefix = JSON.parse(res.body);
|
|
1047
|
-
return (0, ts_types_1.ensureString)(namespacePrefix.records[0]?.NamespacePrefix);
|
|
1048
|
-
}
|
|
1049
|
-
catch (err) {
|
|
1050
|
-
/* Doesn't have a namespace */
|
|
1051
|
-
return;
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
1032
|
/**
|
|
1055
1033
|
* Returns `true` if the org is a Dev Hub.
|
|
1056
1034
|
*
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.determineOrg = determineOrg;
|
|
10
|
+
const logger_1 = require("../logger/logger");
|
|
11
|
+
const connection_1 = require("./connection");
|
|
12
|
+
const org_1 = require("./org");
|
|
13
|
+
async function determineOrg(orgAuthInfo) {
|
|
14
|
+
const fields = orgAuthInfo.getFields();
|
|
15
|
+
if (fields.orgEdition && fields.namespacePrefix !== undefined)
|
|
16
|
+
return;
|
|
17
|
+
try {
|
|
18
|
+
const conn = await connection_1.Connection.create({ authInfo: orgAuthInfo });
|
|
19
|
+
const result = await conn.singleRecordQuery('SELECT Name, InstanceName, IsSandbox, TrialExpirationDate, NamespacePrefix, OrganizationType FROM Organization');
|
|
20
|
+
if (fields.orgEdition) {
|
|
21
|
+
await orgAuthInfo.save({
|
|
22
|
+
[org_1.Org.Fields.NAMESPACE_PREFIX]: result.NamespacePrefix,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
await orgAuthInfo.save({
|
|
27
|
+
[org_1.Org.Fields.NAME]: result.Name,
|
|
28
|
+
[org_1.Org.Fields.INSTANCE_NAME]: result.InstanceName,
|
|
29
|
+
[org_1.Org.Fields.NAMESPACE_PREFIX]: result.NamespacePrefix,
|
|
30
|
+
[org_1.Org.Fields.IS_SANDBOX]: result.IsSandbox && !result.TrialExpirationDate,
|
|
31
|
+
[org_1.Org.Fields.IS_SCRATCH]: result.IsSandbox && Boolean(result.TrialExpirationDate),
|
|
32
|
+
[org_1.Org.Fields.TRIAL_EXPIRATION_DATE]: result.TrialExpirationDate,
|
|
33
|
+
[org_1.Org.Fields.ORG_EDITION]: result.OrganizationType,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const logger = await logger_1.Logger.child('AuthInfo', { tag: 'determineOrg' });
|
|
39
|
+
logger.debug('determineOrg failed', err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=determineOrg.js.map
|
package/lib/org/org.d.ts
CHANGED
|
@@ -67,6 +67,13 @@ export type SandboxProcessObject = {
|
|
|
67
67
|
EndDate?: string;
|
|
68
68
|
Features?: string[];
|
|
69
69
|
};
|
|
70
|
+
export type PostCopyConfigEntry = {
|
|
71
|
+
ConfigurationName: string;
|
|
72
|
+
Label: string;
|
|
73
|
+
Fields: Record<string, string>;
|
|
74
|
+
IsActive: boolean;
|
|
75
|
+
ExecutionOrder: number;
|
|
76
|
+
};
|
|
70
77
|
export type SandboxRequest = {
|
|
71
78
|
SandboxName: string;
|
|
72
79
|
LicenseType?: string;
|
|
@@ -76,6 +83,7 @@ export type SandboxRequest = {
|
|
|
76
83
|
ApexClassId?: string;
|
|
77
84
|
ActivationUserGroupId?: string;
|
|
78
85
|
Features?: string[] | string;
|
|
86
|
+
PostCopyConfig?: PostCopyConfigEntry[] | string;
|
|
79
87
|
};
|
|
80
88
|
export type ResumeSandboxRequest = {
|
|
81
89
|
SandboxName?: string;
|
|
@@ -100,6 +108,7 @@ export type SandboxInfo = {
|
|
|
100
108
|
ActivationUserGroupId?: string;
|
|
101
109
|
CopyArchivedActivities?: boolean;
|
|
102
110
|
Features?: string[];
|
|
111
|
+
PostCopyConfig?: PostCopyConfigEntry[] | string;
|
|
103
112
|
};
|
|
104
113
|
export type ScratchOrgRequest = Omit<ScratchOrgCreateOptions, 'hubOrg'>;
|
|
105
114
|
export type SandboxFields = {
|
package/lib/org/org.js
CHANGED
|
@@ -49,6 +49,7 @@ const messages_1 = require("../messages");
|
|
|
49
49
|
const stateAggregator_1 = require("../stateAggregator/stateAggregator");
|
|
50
50
|
const pollingClient_1 = require("../status/pollingClient");
|
|
51
51
|
const connection_1 = require("./connection");
|
|
52
|
+
const determineOrg_1 = require("./determineOrg");
|
|
52
53
|
const authInfo_1 = require("./authInfo");
|
|
53
54
|
const scratchOrgCreate_1 = require("./scratchOrgCreate");
|
|
54
55
|
const orgConfigProperties_1 = require("./orgConfigProperties");
|
|
@@ -104,6 +105,7 @@ const sandboxInfoFields = [
|
|
|
104
105
|
'SourceId',
|
|
105
106
|
'ActivationUserGroupId',
|
|
106
107
|
'Features',
|
|
108
|
+
'PostCopyConfig',
|
|
107
109
|
];
|
|
108
110
|
/**
|
|
109
111
|
* Provides a way to manage a locally authenticated Org.
|
|
@@ -268,6 +270,9 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
268
270
|
if (sandboxReq.Features && Array.isArray(sandboxReq.Features)) {
|
|
269
271
|
sandboxReq.Features = JSON.stringify(sandboxReq.Features);
|
|
270
272
|
}
|
|
273
|
+
if (sandboxReq.PostCopyConfig && Array.isArray(sandboxReq.PostCopyConfig)) {
|
|
274
|
+
sandboxReq.PostCopyConfig = JSON.stringify(sandboxReq.PostCopyConfig);
|
|
275
|
+
}
|
|
271
276
|
const createResult = await this.connection.tooling.create('SandboxInfo', sandboxReq);
|
|
272
277
|
this.logger.debug(createResult, 'Return from calling tooling.create');
|
|
273
278
|
if (Array.isArray(createResult) || !createResult.success) {
|
|
@@ -302,6 +307,9 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
302
307
|
interval: kit_1.Duration.seconds(30),
|
|
303
308
|
}) {
|
|
304
309
|
this.logger.debug(sandboxInfo, 'RefreshSandbox called with SandboxInfo');
|
|
310
|
+
if (sandboxInfo.PostCopyConfig && Array.isArray(sandboxInfo.PostCopyConfig)) {
|
|
311
|
+
sandboxInfo.PostCopyConfig = JSON.stringify(sandboxInfo.PostCopyConfig);
|
|
312
|
+
}
|
|
305
313
|
const refreshResult = await this.connection.tooling.update('SandboxInfo', sandboxInfo);
|
|
306
314
|
this.logger.debug(refreshResult, 'Return from calling tooling.update');
|
|
307
315
|
if (!refreshResult.success) {
|
|
@@ -1024,6 +1032,12 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
1024
1032
|
this.connection = this.options.connection;
|
|
1025
1033
|
}
|
|
1026
1034
|
this.orgId = this.getField(Org.Fields.ORG_ID);
|
|
1035
|
+
try {
|
|
1036
|
+
await (0, determineOrg_1.determineOrg)(this.getConnection().getAuthInfo());
|
|
1037
|
+
}
|
|
1038
|
+
catch {
|
|
1039
|
+
// best effort — connection may not support getAuthInfo (e.g. passed-in mock)
|
|
1040
|
+
}
|
|
1027
1041
|
}
|
|
1028
1042
|
/**
|
|
1029
1043
|
* **Throws** *{@link SfError}{ name: 'NotSupportedError' }* Throws an unsupported error.
|
package/lib/testSetup.d.ts
CHANGED
package/lib/testSetup.js
CHANGED
|
@@ -759,6 +759,7 @@ class MockTestOrgData {
|
|
|
759
759
|
isExpired;
|
|
760
760
|
password;
|
|
761
761
|
namespacePrefix;
|
|
762
|
+
orgEdition;
|
|
762
763
|
constructor(id = (0, uniqid_1.uniqid)(), options) {
|
|
763
764
|
this.testId = id;
|
|
764
765
|
this.userId = `user_id_${this.testId}`;
|
|
@@ -773,6 +774,7 @@ class MockTestOrgData {
|
|
|
773
774
|
this.refreshToken = `${this.testId}/refreshToken`;
|
|
774
775
|
this.redirectUri = 'http://localhost:1717/OauthRedirect';
|
|
775
776
|
this.namespacePrefix = `acme_${this.testId}`;
|
|
777
|
+
this.orgEdition = 'Developer Edition';
|
|
776
778
|
}
|
|
777
779
|
/**
|
|
778
780
|
* Add devhub username to properties.
|
|
@@ -852,6 +854,7 @@ class MockTestOrgData {
|
|
|
852
854
|
config.devHubUsername = this.devHubUsername;
|
|
853
855
|
}
|
|
854
856
|
config.isDevHub = this.isDevHub;
|
|
857
|
+
config.orgEdition = this.orgEdition;
|
|
855
858
|
if (this.password) {
|
|
856
859
|
config.password = crypto.encrypt(this.password);
|
|
857
860
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.31.0",
|
|
4
4
|
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"change-case": "^4.1.2",
|
|
69
69
|
"fast-levenshtein": "^3.0.0",
|
|
70
70
|
"faye": "^1.4.1",
|
|
71
|
-
"form-data": "^4.0.
|
|
71
|
+
"form-data": "^4.0.5",
|
|
72
72
|
"js2xmlparser": "^4.0.1",
|
|
73
73
|
"jsonwebtoken": "9.0.3",
|
|
74
74
|
"jszip": "3.10.1",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@types/proper-lockfile": "^4.1.4",
|
|
91
91
|
"@types/semver": "^7.7.1",
|
|
92
92
|
"benchmark": "^2.1.4",
|
|
93
|
-
"esbuild": "^0.
|
|
93
|
+
"esbuild": "^0.28.0",
|
|
94
94
|
"mocha": "^11.7.5",
|
|
95
95
|
"ts-node": "^10.9.2",
|
|
96
96
|
"ts-patch": "^3.3.0",
|