@salesforce/core 6.0.1-crdt.0 → 6.1.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.
- package/README.md +3 -3
- package/lib/config/authInfoConfig.d.ts +1 -1
- package/lib/config/config.d.ts +6 -29
- package/lib/config/config.js +91 -113
- package/lib/config/configAggregator.js +1 -0
- package/lib/config/configFile.d.ts +3 -1
- package/lib/config/configFile.js +44 -67
- package/lib/config/configStore.d.ts +20 -29
- package/lib/config/configStore.js +50 -53
- package/lib/config/envVars.js +3 -2
- package/lib/config/lwwMap.d.ts +4 -5
- package/lib/config/lwwMap.js +19 -16
- package/lib/config/lwwRegister.d.ts +2 -3
- package/lib/config/lwwRegister.js +6 -7
- package/lib/config/sandboxOrgConfig.js +1 -1
- package/lib/config/sandboxProcessCache.d.ts +1 -1
- package/lib/crypto/crypto.js +4 -3
- package/lib/crypto/keyChain.js +1 -0
- package/lib/crypto/keyChainImpl.d.ts +2 -2
- package/lib/crypto/keyChainImpl.js +9 -8
- package/lib/crypto/secureBuffer.js +1 -1
- package/lib/deviceOauthService.d.ts +1 -1
- package/lib/deviceOauthService.js +8 -6
- package/lib/exported.d.ts +3 -4
- package/lib/exported.js +6 -6
- package/lib/global.js +4 -4
- package/lib/logger/logger.js +6 -5
- package/lib/logger/memoryLogger.d.ts +1 -1
- package/lib/logger/memoryLogger.js +2 -2
- package/lib/logger/transformStream.d.ts +1 -1
- package/lib/logger/transformStream.js +3 -3
- package/lib/messageTransformer.js +2 -2
- package/lib/messages.js +5 -5
- package/lib/org/authInfo.js +11 -10
- package/lib/org/authRemover.d.ts +1 -2
- package/lib/org/authRemover.js +2 -12
- package/lib/org/connection.js +3 -2
- package/lib/org/org.js +9 -8
- package/lib/org/orgConfigProperties.js +3 -2
- package/lib/org/permissionSetAssignment.js +15 -13
- package/lib/org/scratchOrgCreate.js +2 -1
- package/lib/org/scratchOrgErrorCodes.js +1 -0
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -0
- package/lib/org/scratchOrgInfoApi.js +1 -0
- package/lib/org/scratchOrgInfoGenerator.js +3 -2
- package/lib/org/scratchOrgSettingsGenerator.js +3 -3
- package/lib/org/user.js +4 -3
- package/lib/schema/validator.js +2 -2
- package/lib/sfError.d.ts +1 -1
- package/lib/sfProject.d.ts +6 -6
- package/lib/sfProject.js +18 -21
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +1 -2
- package/lib/stateAggregator/accessors/aliasAccessor.js +3 -2
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +2 -2
- package/lib/stateAggregator/accessors/orgAccessor.js +8 -6
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +1 -1
- package/lib/stateAggregator/stateAggregator.d.ts +0 -2
- package/lib/stateAggregator/stateAggregator.js +0 -2
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +6 -6
- package/lib/status/pollingClient.js +1 -1
- package/lib/status/streamingClient.js +4 -3
- package/lib/status/types.d.ts +1 -1
- package/lib/status/types.js +2 -2
- package/lib/testSetup.d.ts +3 -7
- package/lib/testSetup.js +47 -39
- package/lib/util/cache.js +14 -14
- package/lib/util/checkLightningDomain.js +2 -2
- package/lib/util/directoryWriter.d.ts +1 -1
- package/lib/util/directoryWriter.js +7 -7
- package/lib/util/fileLocking.d.ts +24 -0
- package/lib/util/fileLocking.js +91 -0
- package/lib/util/findUppercaseKeys.d.ts +2 -0
- package/lib/util/findUppercaseKeys.js +29 -0
- package/lib/util/internal.js +7 -6
- package/lib/util/sfdc.d.ts +0 -18
- package/lib/util/sfdc.js +1 -42
- package/lib/util/sfdcUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.js +9 -8
- package/lib/util/structuredWriter.d.ts +1 -1
- package/lib/util/time.d.ts +1 -0
- package/lib/util/time.js +13 -0
- package/lib/util/uniqid.js +3 -3
- package/lib/util/zipWriter.d.ts +1 -1
- package/lib/util/zipWriter.js +2 -2
- package/lib/webOAuthServer.d.ts +2 -2
- package/lib/webOAuthServer.js +16 -15
- package/package.json +14 -38
- package/lib/config/tokensConfig.d.ts +0 -10
- package/lib/config/tokensConfig.js +0 -29
- package/lib/org/index.d.ts +0 -6
- package/lib/org/index.js +0 -29
- package/lib/schema/printer.d.ts +0 -81
- package/lib/schema/printer.js +0 -263
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +0 -63
- package/lib/stateAggregator/accessors/tokenAccessor.js +0 -80
- package/lib/stateAggregator/index.d.ts +0 -4
- package/lib/stateAggregator/index.js +0 -27
- package/lib/util/jsonXmlTools.d.ts +0 -14
- package/lib/util/jsonXmlTools.js +0 -39
package/lib/util/cache.js
CHANGED
|
@@ -29,37 +29,37 @@ class Cache extends Map {
|
|
|
29
29
|
__classPrivateFieldSet(this, _Cache_lookups, 0, "f");
|
|
30
30
|
}
|
|
31
31
|
static get hits() {
|
|
32
|
-
return __classPrivateFieldGet(
|
|
32
|
+
return __classPrivateFieldGet(_a.instance(), _Cache_hits, "f");
|
|
33
33
|
}
|
|
34
34
|
static get lookups() {
|
|
35
|
-
return __classPrivateFieldGet(
|
|
35
|
+
return __classPrivateFieldGet(_a.instance(), _Cache_lookups, "f");
|
|
36
36
|
}
|
|
37
37
|
static instance() {
|
|
38
|
-
if (!__classPrivateFieldGet(
|
|
39
|
-
__classPrivateFieldSet(
|
|
40
|
-
__classPrivateFieldSet(
|
|
38
|
+
if (!__classPrivateFieldGet(_a, _a, "f", _Cache_instance)) {
|
|
39
|
+
__classPrivateFieldSet(_a, _a, true, "f", _Cache_enabled);
|
|
40
|
+
__classPrivateFieldSet(_a, _a, new _a(), "f", _Cache_instance);
|
|
41
41
|
}
|
|
42
|
-
return __classPrivateFieldGet(
|
|
42
|
+
return __classPrivateFieldGet(_a, _a, "f", _Cache_instance);
|
|
43
43
|
}
|
|
44
44
|
static set(key, value) {
|
|
45
|
-
if (__classPrivateFieldGet(
|
|
46
|
-
|
|
45
|
+
if (__classPrivateFieldGet(_a, _a, "f", _Cache_enabled)) {
|
|
46
|
+
_a.instance().set(key, value);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
static get(key) {
|
|
50
50
|
var _b, _c, _d;
|
|
51
|
-
if (!__classPrivateFieldGet(
|
|
51
|
+
if (!__classPrivateFieldGet(_a, _a, "f", _Cache_enabled)) {
|
|
52
52
|
return undefined;
|
|
53
53
|
}
|
|
54
|
-
__classPrivateFieldSet(_b =
|
|
55
|
-
__classPrivateFieldSet(_d =
|
|
56
|
-
return __classPrivateFieldGet(
|
|
54
|
+
__classPrivateFieldSet(_b = _a.instance(), _Cache_lookups, (_c = __classPrivateFieldGet(_b, _Cache_lookups, "f"), _c++, _c), "f");
|
|
55
|
+
__classPrivateFieldSet(_d = _a.instance(), _Cache_hits, __classPrivateFieldGet(_d, _Cache_hits, "f") + (_a.instance().has(key) ? 1 : 0), "f");
|
|
56
|
+
return __classPrivateFieldGet(_a, _a, "f", _Cache_instance).get(key);
|
|
57
57
|
}
|
|
58
58
|
static disable() {
|
|
59
|
-
__classPrivateFieldSet(
|
|
59
|
+
__classPrivateFieldSet(_a, _a, false, "f", _Cache_enabled);
|
|
60
60
|
}
|
|
61
61
|
static enable() {
|
|
62
|
-
__classPrivateFieldSet(
|
|
62
|
+
__classPrivateFieldSet(_a, _a, true, "f", _Cache_enabled);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
exports.Cache = Cache;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
* Licensed under the BSD 3-Clause license.
|
|
7
7
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const node_url_1 = require("node:url");
|
|
10
10
|
const kit_1 = require("@salesforce/kit");
|
|
11
11
|
const myDomainResolver_1 = require("../status/myDomainResolver");
|
|
12
12
|
const sfdcUrl_1 = require("./sfdcUrl");
|
|
@@ -18,7 +18,7 @@ async function checkLightningDomain(url) {
|
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
const resolver = await myDomainResolver_1.MyDomainResolver.create({
|
|
21
|
-
url: new
|
|
21
|
+
url: new node_url_1.URL(domain),
|
|
22
22
|
timeout,
|
|
23
23
|
frequency: new kit_1.Duration(1, kit_1.Duration.Unit.SECONDS),
|
|
24
24
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Readable } from 'stream';
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
4
|
import { StructuredWriter } from './structuredWriter';
|
|
5
5
|
export declare class DirectoryWriter implements StructuredWriter {
|
|
6
6
|
private readonly rootDestination?;
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.DirectoryWriter = void 0;
|
|
10
|
-
const
|
|
11
|
-
const fs = require("fs");
|
|
12
|
-
const os = require("os");
|
|
13
|
-
const path = require("path");
|
|
14
|
-
const
|
|
15
|
-
const pipeline = (0,
|
|
10
|
+
const node_stream_1 = require("node:stream");
|
|
11
|
+
const fs = require("node:fs");
|
|
12
|
+
const os = require("node:os");
|
|
13
|
+
const path = require("node:path");
|
|
14
|
+
const node_util_1 = require("node:util");
|
|
15
|
+
const pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
|
16
16
|
class DirectoryWriter {
|
|
17
17
|
constructor(rootDestination) {
|
|
18
18
|
this.rootDestination = rootDestination;
|
|
@@ -31,7 +31,7 @@ class DirectoryWriter {
|
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
32
|
const destPath = path.join(this.rootDestination, targetPath);
|
|
33
33
|
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
34
|
-
if (contents instanceof
|
|
34
|
+
if (contents instanceof node_stream_1.Readable) {
|
|
35
35
|
const writeStream = fs.createWriteStream(destPath);
|
|
36
36
|
await pipeline(contents, writeStream);
|
|
37
37
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type LockInitResponse = {
|
|
2
|
+
writeAndUnlock: (data: string) => Promise<void>;
|
|
3
|
+
unlock: () => Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
type LockInitSyncResponse = {
|
|
6
|
+
writeAndUnlock: (data: string) => void;
|
|
7
|
+
unlock: () => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
*This method exists as a separate function so it can be used by ConfigFile OR outside of ConfigFile.
|
|
12
|
+
*
|
|
13
|
+
* @param filePath where to save the file
|
|
14
|
+
* @returns 2 functions:
|
|
15
|
+
* - writeAndUnlock: a function that takes the data to write and writes it to the file, then unlocks the file whether write succeeded or not
|
|
16
|
+
* - unlock: a function that unlocks the file (in case you don't end up calling writeAndUnlock)
|
|
17
|
+
*/
|
|
18
|
+
export declare const lockInit: (filePath: string) => Promise<LockInitResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* prefer async {@link lockInit}.
|
|
21
|
+
* See its documentation for details.
|
|
22
|
+
*/
|
|
23
|
+
export declare const lockInitSync: (filePath: string) => LockInitSyncResponse;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lockInitSync = exports.lockInit = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const fs = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
const proper_lockfile_1 = require("proper-lockfile");
|
|
13
|
+
const sfError_1 = require("../sfError");
|
|
14
|
+
const logger_1 = require("../logger/logger");
|
|
15
|
+
const lockRetryOptions_1 = require("./lockRetryOptions");
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*This method exists as a separate function so it can be used by ConfigFile OR outside of ConfigFile.
|
|
19
|
+
*
|
|
20
|
+
* @param filePath where to save the file
|
|
21
|
+
* @returns 2 functions:
|
|
22
|
+
* - writeAndUnlock: a function that takes the data to write and writes it to the file, then unlocks the file whether write succeeded or not
|
|
23
|
+
* - unlock: a function that unlocks the file (in case you don't end up calling writeAndUnlock)
|
|
24
|
+
*/
|
|
25
|
+
const lockInit = async (filePath) => {
|
|
26
|
+
// make sure we can write to the directory
|
|
27
|
+
try {
|
|
28
|
+
await fs.promises.mkdir((0, node_path_1.dirname)(filePath), { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw sfError_1.SfError.wrap(err);
|
|
32
|
+
}
|
|
33
|
+
const [unlock] = await Promise.all(fs.existsSync(filePath)
|
|
34
|
+
? // if the file exists, wait for it to be unlocked
|
|
35
|
+
[(0, proper_lockfile_1.lock)(filePath, lockRetryOptions_1.lockRetryOptions)]
|
|
36
|
+
: // lock the entire directory to keep others from trying to create the file while we are
|
|
37
|
+
[
|
|
38
|
+
(0, proper_lockfile_1.lock)((0, node_path_1.dirname)(filePath), lockRetryOptions_1.lockRetryOptions),
|
|
39
|
+
(await logger_1.Logger.child('fileLocking.lockInit')).debug(`No file found at ${filePath}. Write will create it. Locking the entire directory until file is written.`),
|
|
40
|
+
]);
|
|
41
|
+
return {
|
|
42
|
+
writeAndUnlock: async (data) => {
|
|
43
|
+
const logger = await logger_1.Logger.child('fileLocking.writeAndUnlock');
|
|
44
|
+
logger.debug(`Writing to file: ${filePath}`);
|
|
45
|
+
try {
|
|
46
|
+
await fs.promises.writeFile(filePath, data);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await unlock();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
unlock,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.lockInit = lockInit;
|
|
56
|
+
/**
|
|
57
|
+
* prefer async {@link lockInit}.
|
|
58
|
+
* See its documentation for details.
|
|
59
|
+
*/
|
|
60
|
+
const lockInitSync = (filePath) => {
|
|
61
|
+
// make sure we can write to the directory
|
|
62
|
+
try {
|
|
63
|
+
fs.mkdirSync((0, node_path_1.dirname)(filePath), { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
throw sfError_1.SfError.wrap(err);
|
|
67
|
+
}
|
|
68
|
+
const [unlock] = fs.existsSync(filePath)
|
|
69
|
+
? // if the file exists, wait for it to be unlocked
|
|
70
|
+
[(0, proper_lockfile_1.lockSync)(filePath, lockRetryOptions_1.lockRetryOptions)]
|
|
71
|
+
: // lock the entire directory to keep others from trying to create the file while we are
|
|
72
|
+
[
|
|
73
|
+
(0, proper_lockfile_1.lockSync)((0, node_path_1.dirname)(filePath), lockRetryOptions_1.lockRetryOptions),
|
|
74
|
+
logger_1.Logger.childFromRoot('fileLocking.lockInit').debug(`No file found at ${filePath}. Write will create it. Locking the entire directory until file is written.`),
|
|
75
|
+
];
|
|
76
|
+
return {
|
|
77
|
+
writeAndUnlock: (data) => {
|
|
78
|
+
const logger = logger_1.Logger.childFromRoot('fileLocking.writeAndUnlock');
|
|
79
|
+
logger.debug(`Writing to file: ${filePath}`);
|
|
80
|
+
try {
|
|
81
|
+
fs.writeFileSync(filePath, data);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
unlock();
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
unlock,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.lockInitSync = lockInitSync;
|
|
91
|
+
//# sourceMappingURL=fileLocking.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023, 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.findUpperCaseKeys = void 0;
|
|
10
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
11
|
+
const kit_1 = require("@salesforce/kit");
|
|
12
|
+
const findUpperCaseKeys = (data, sectionBlocklist = []) => {
|
|
13
|
+
let key;
|
|
14
|
+
(0, kit_1.findKey)(data, (val, k) => {
|
|
15
|
+
if (/^[A-Z]/.test(k)) {
|
|
16
|
+
key = k;
|
|
17
|
+
}
|
|
18
|
+
else if ((0, ts_types_1.isJsonMap)(val)) {
|
|
19
|
+
if (sectionBlocklist.includes(k)) {
|
|
20
|
+
return key;
|
|
21
|
+
}
|
|
22
|
+
key = (0, exports.findUpperCaseKeys)((0, ts_types_1.asJsonMap)(val));
|
|
23
|
+
}
|
|
24
|
+
return key;
|
|
25
|
+
});
|
|
26
|
+
return key;
|
|
27
|
+
};
|
|
28
|
+
exports.findUpperCaseKeys = findUpperCaseKeys;
|
|
29
|
+
//# sourceMappingURL=findUppercaseKeys.js.map
|
package/lib/util/internal.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.traverse = exports.resolveProjectPathSync = exports.resolveProjectPath = exports.SFDX_PROJECT_JSON = void 0;
|
|
10
|
-
const fs = require("fs");
|
|
11
|
-
const
|
|
10
|
+
const fs = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
12
|
const messages_1 = require("../messages");
|
|
13
|
+
;
|
|
13
14
|
const messages = new messages_1.Messages('@salesforce/core', 'config', new Map([["unknownConfigKey", "Unknown config name: %s."], ["deprecatedConfigKey", "Deprecated config name: %s. Please use %s instead."], ["invalidWrite", "The writeSync method is not allowed on SfdxConfig. Use the async write method instead."], ["invalidConfigValue", "Invalid config value: %s."], ["invalidInstanceUrl", "Specify a valid Salesforce instance URL."], ["invalidApiVersion", "Specify a valid Salesforce API version, for example, 42.0."], ["invalidCustomOrgMetadataTemplates", "Specify a valid repository URL or directory for the custom org metadata templates."], ["invalidIsvDebuggerSid", "Specify a valid Debugger SID."], ["invalidIsvDebuggerUrl", "Specify a valid Debugger URL."], ["invalidNumberConfigValue", "Specify a valid positive integer, for example, 150000."], ["invalidBooleanConfigValue", "The config value can only be set to true or false."], ["invalidProjectWorkspace", "This directory does not contain a valid Salesforce DX project."], ["schemaValidationError", "The config file \"%s\" is not schema valid.\nDue to: %s"], ["schemaValidationError.actions", ["Fix the invalid entries at %s."]], ["missingDefaultPath", "In sfdx-project.json, be sure to specify which package directory (path) is the default. Example: `[{ \"path\": \"packageDirectory1\", \"default\": true }, { \"path\": \"packageDirectory2\" }]`"], ["missingPackageDirectory", "The path \"%s\", specified in sfdx-project.json, does not exist. Be sure this directory is included in your project root."], ["invalidPackageDirectory", "The path \"%s\", specified in sfdx-project.json, must be indicated as a relative path to the project root."], ["multipleDefaultPaths", "In sfdx-project.json, indicate only one package directory (path) as the default."], ["singleNonDefaultPackage", "The sfdx-project.json file must include one, and only one, default package directory (path). Because your sfdx-project.json file contains only one package directory, it must be the default. Remove the `\"default\": false` key and try again."], ["target-org", "Username or alias of the org that all commands run against by default. (sf only)"], ["target-dev-hub", "Username or alias of your default Dev Hub org. (sf only)"], ["defaultUsername", "Username or alias of the org that all commands run against by default. (sfdx only)"], ["defaultDevHubUsername", "Username or alias of your default Dev Hub org. (sfdx only)"], ["isvDebuggerSid", "ISV debugger SID (sfdx only)"], ["isvDebuggerUrl", "ISV debugger URL (sfdx only)"], ["org-isv-debugger-sid", "ISV debugger SID."], ["org-isv-debugger-url", "ISV debugger URL."], ["apiVersion", "API version of your project. Default: API version of your Dev Hub org. (sfdx only)"], ["org-api-version", "API version of your project. Default: API version of your Dev Hub org."], ["disableTelemetry", "Disables the collection of usage and user environment information, etc. Default: false. (sfdx only)"], ["disable-telemetry", "Disables the collection of usage and user environment information, etc. Default: false."], ["maxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000. (sfdx only)"], ["org-max-query-limit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000."], ["restDeploy", "Whether deployments use the Metadata REST API (true) or SOAP API (false, default value). (sfdx only)"], ["instanceUrl", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com. (sfdx only)"], ["org-instance-url", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com."], ["customOrgMetadataTemplates", "A valid repository URL or directory for the custom org metadata templates."], ["org-custom-metadata-templates", "A valid repository URL or directory for the custom org metadata templates."], ["invalidId", "The given id %s is not a valid 15 or 18 character Salesforce ID."]]));
|
|
14
15
|
/**
|
|
15
16
|
* The name of the project config file.
|
|
@@ -75,12 +76,12 @@ exports.traverse = {
|
|
|
75
76
|
forFile: async (dir, file) => {
|
|
76
77
|
let foundProjectDir;
|
|
77
78
|
try {
|
|
78
|
-
fs.statSync((0,
|
|
79
|
+
fs.statSync((0, node_path_1.join)(dir, file));
|
|
79
80
|
foundProjectDir = dir;
|
|
80
81
|
}
|
|
81
82
|
catch (err) {
|
|
82
83
|
if (err && err.code === 'ENOENT') {
|
|
83
|
-
const nextDir = (0,
|
|
84
|
+
const nextDir = (0, node_path_1.resolve)(dir, '..');
|
|
84
85
|
if (nextDir !== dir) {
|
|
85
86
|
// stop at root
|
|
86
87
|
foundProjectDir = await exports.traverse.forFile(nextDir, file);
|
|
@@ -100,12 +101,12 @@ exports.traverse = {
|
|
|
100
101
|
forFileSync: (dir, file) => {
|
|
101
102
|
let foundProjectDir;
|
|
102
103
|
try {
|
|
103
|
-
fs.statSync((0,
|
|
104
|
+
fs.statSync((0, node_path_1.join)(dir, file));
|
|
104
105
|
foundProjectDir = dir;
|
|
105
106
|
}
|
|
106
107
|
catch (err) {
|
|
107
108
|
if (err && err.code === 'ENOENT') {
|
|
108
|
-
const nextDir = (0,
|
|
109
|
+
const nextDir = (0, node_path_1.resolve)(dir, '..');
|
|
109
110
|
if (nextDir !== dir) {
|
|
110
111
|
// stop at root
|
|
111
112
|
foundProjectDir = exports.traverse.forFileSync(nextDir, file);
|
package/lib/util/sfdc.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { JsonMap, Optional } from '@salesforce/ts-types';
|
|
2
1
|
/**
|
|
3
2
|
* Converts an 18 character Salesforce ID to 15 characters.
|
|
4
3
|
*
|
|
@@ -19,14 +18,6 @@ export declare const validateApiVersion: (value: string) => boolean;
|
|
|
19
18
|
* @param value The email as a string.
|
|
20
19
|
*/
|
|
21
20
|
export declare const validateEmail: (value: string) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @deprecated use `new SfdcUrl(url).isInternalUrl()`
|
|
25
|
-
* Tests whether a given url is an internal Salesforce domain
|
|
26
|
-
*
|
|
27
|
-
* @param url
|
|
28
|
-
*/
|
|
29
|
-
export declare const isInternalUrl: (url: string) => boolean;
|
|
30
21
|
/**
|
|
31
22
|
* Tests whether a Salesforce ID is in the correct format, a 15- or 18-character length string with only letters and numbers
|
|
32
23
|
*
|
|
@@ -39,15 +30,6 @@ export declare const validateSalesforceId: (value: string) => boolean;
|
|
|
39
30
|
* @param value The path as a string.
|
|
40
31
|
*/
|
|
41
32
|
export declare const validatePathDoesNotContainInvalidChars: (value: string) => boolean;
|
|
42
|
-
/**
|
|
43
|
-
* @deprecated
|
|
44
|
-
* // TODO: move this to a module-scope function in sfProject
|
|
45
|
-
* Returns the first key within the object that has an upper case first letter.
|
|
46
|
-
*
|
|
47
|
-
* @param data The object in which to check key casing.
|
|
48
|
-
* @param sectionBlocklist properties in the object to exclude from the search. e.g. a blocklist of `["a"]` and data of `{ "a": { "B" : "b"}}` would ignore `B` because it is in the object value under `a`.
|
|
49
|
-
*/
|
|
50
|
-
export declare const findUpperCaseKeys: (data?: JsonMap, sectionBlocklist?: string[]) => Optional<string>;
|
|
51
33
|
export declare const accessTokenRegex: RegExp;
|
|
52
34
|
export declare const sfdxAuthUrlRegex: RegExp;
|
|
53
35
|
/**
|
package/lib/util/sfdc.js
CHANGED
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.matchesAccessToken = exports.sfdxAuthUrlRegex = exports.accessTokenRegex = exports.
|
|
10
|
-
const kit_1 = require("@salesforce/kit");
|
|
11
|
-
const ts_types_1 = require("@salesforce/ts-types");
|
|
9
|
+
exports.matchesAccessToken = exports.sfdxAuthUrlRegex = exports.accessTokenRegex = exports.validatePathDoesNotContainInvalidChars = exports.validateSalesforceId = exports.validateEmail = exports.validateApiVersion = exports.trimTo15 = void 0;
|
|
12
10
|
function trimTo15(id) {
|
|
13
11
|
if (!id) {
|
|
14
12
|
return undefined;
|
|
@@ -33,20 +31,6 @@ exports.validateApiVersion = validateApiVersion;
|
|
|
33
31
|
*/
|
|
34
32
|
const validateEmail = (value) => /^[^.][^@]*@[^.]+(\.[^.\s]+)+$/.test(value);
|
|
35
33
|
exports.validateEmail = validateEmail;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @deprecated use `new SfdcUrl(url).isInternalUrl()`
|
|
39
|
-
* Tests whether a given url is an internal Salesforce domain
|
|
40
|
-
*
|
|
41
|
-
* @param url
|
|
42
|
-
*/
|
|
43
|
-
const isInternalUrl = (url) => {
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
|
45
|
-
const SfdcUrl = require('./sfdcUrl');
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
47
|
-
return new SfdcUrl(url).isInternalUrl();
|
|
48
|
-
};
|
|
49
|
-
exports.isInternalUrl = isInternalUrl;
|
|
50
34
|
/**
|
|
51
35
|
* Tests whether a Salesforce ID is in the correct format, a 15- or 18-character length string with only letters and numbers
|
|
52
36
|
*
|
|
@@ -63,31 +47,6 @@ const validatePathDoesNotContainInvalidChars = (value) =>
|
|
|
63
47
|
// eslint-disable-next-line no-useless-escape
|
|
64
48
|
!/[\["\?<>\|\]]+/.test(value);
|
|
65
49
|
exports.validatePathDoesNotContainInvalidChars = validatePathDoesNotContainInvalidChars;
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated
|
|
68
|
-
* // TODO: move this to a module-scope function in sfProject
|
|
69
|
-
* Returns the first key within the object that has an upper case first letter.
|
|
70
|
-
*
|
|
71
|
-
* @param data The object in which to check key casing.
|
|
72
|
-
* @param sectionBlocklist properties in the object to exclude from the search. e.g. a blocklist of `["a"]` and data of `{ "a": { "B" : "b"}}` would ignore `B` because it is in the object value under `a`.
|
|
73
|
-
*/
|
|
74
|
-
const findUpperCaseKeys = (data, sectionBlocklist = []) => {
|
|
75
|
-
let key;
|
|
76
|
-
(0, kit_1.findKey)(data, (val, k) => {
|
|
77
|
-
if (/^[A-Z]/.test(k)) {
|
|
78
|
-
key = k;
|
|
79
|
-
}
|
|
80
|
-
else if ((0, ts_types_1.isJsonMap)(val)) {
|
|
81
|
-
if (sectionBlocklist.includes(k)) {
|
|
82
|
-
return key;
|
|
83
|
-
}
|
|
84
|
-
key = (0, exports.findUpperCaseKeys)((0, ts_types_1.asJsonMap)(val));
|
|
85
|
-
}
|
|
86
|
-
return key;
|
|
87
|
-
});
|
|
88
|
-
return key;
|
|
89
|
-
};
|
|
90
|
-
exports.findUpperCaseKeys = findUpperCaseKeys;
|
|
91
50
|
exports.accessTokenRegex = /(00D\w{12,15})![.\w]*/;
|
|
92
51
|
exports.sfdxAuthUrlRegex = /force:\/\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]*):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/;
|
|
93
52
|
/**
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { URL } from 'url';
|
|
2
|
+
import { URL } from 'node:url';
|
|
3
3
|
export declare function getLoginAudienceCombos(audienceUrl: string, loginUrl: string): Array<[string, string]>;
|
|
4
4
|
export declare class SfdcUrl extends URL {
|
|
5
5
|
/**
|
|
@@ -46,7 +46,7 @@ export declare class SfdcUrl extends URL {
|
|
|
46
46
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
47
47
|
* @throws {@link SfError} If can't resolve DNS.
|
|
48
48
|
*/
|
|
49
|
-
checkLightningDomain(): Promise<true
|
|
49
|
+
checkLightningDomain(): Promise<true>;
|
|
50
50
|
/**
|
|
51
51
|
* Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
|
|
52
52
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.SfdcUrl = exports.getLoginAudienceCombos = void 0;
|
|
10
|
-
const
|
|
10
|
+
const node_url_1 = require("node:url");
|
|
11
11
|
const kit_1 = require("@salesforce/kit");
|
|
12
12
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
13
|
const myDomainResolver_1 = require("../status/myDomainResolver");
|
|
@@ -29,15 +29,15 @@ function getLoginAudienceCombos(audienceUrl, loginUrl) {
|
|
|
29
29
|
].filter(([login, audience]) => !((login === SfdcUrl.PRODUCTION && audience === SfdcUrl.SANDBOX) ||
|
|
30
30
|
(login === SfdcUrl.SANDBOX && audience === SfdcUrl.PRODUCTION)));
|
|
31
31
|
const reduced = filtered.reduce((acc, [login, audience]) => {
|
|
32
|
-
const l = new
|
|
33
|
-
const a = new
|
|
32
|
+
const l = new node_url_1.URL(login);
|
|
33
|
+
const a = new node_url_1.URL(audience);
|
|
34
34
|
acc.set(`${l.origin}:${a.origin}`, [login, audience]);
|
|
35
35
|
return acc;
|
|
36
36
|
}, new Map());
|
|
37
37
|
return [...reduced.values()];
|
|
38
38
|
}
|
|
39
39
|
exports.getLoginAudienceCombos = getLoginAudienceCombos;
|
|
40
|
-
class SfdcUrl extends
|
|
40
|
+
class SfdcUrl extends node_url_1.URL {
|
|
41
41
|
constructor(input, base) {
|
|
42
42
|
super(input.toString(), base);
|
|
43
43
|
if (this.protocol !== 'https:' && !SfdcUrl.cache.has(this.origin)) {
|
|
@@ -47,7 +47,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
47
47
|
}
|
|
48
48
|
static isValidUrl(input) {
|
|
49
49
|
try {
|
|
50
|
-
new
|
|
50
|
+
new node_url_1.URL(input.toString());
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
53
|
catch {
|
|
@@ -69,7 +69,8 @@ class SfdcUrl extends url_1.URL {
|
|
|
69
69
|
this.logger.debug(`Audience URL overridden by env var SFDX_AUDIENCE_URL=${envVarVal}`);
|
|
70
70
|
return envVarVal;
|
|
71
71
|
}
|
|
72
|
-
if ((createdOrgInstance && /^gs1/gi.test(createdOrgInstance)) ||
|
|
72
|
+
if (Boolean(createdOrgInstance && /^gs1/gi.test(createdOrgInstance)) ||
|
|
73
|
+
/(gs1.my.salesforce.com)/gi.test(this.origin)) {
|
|
73
74
|
return 'https://gs1.salesforce.com';
|
|
74
75
|
}
|
|
75
76
|
return SfdcUrl.PRODUCTION;
|
|
@@ -154,7 +155,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
154
155
|
return true;
|
|
155
156
|
}
|
|
156
157
|
const resolver = await myDomainResolver_1.MyDomainResolver.create({
|
|
157
|
-
url: new
|
|
158
|
+
url: new node_url_1.URL(this.toLightningDomain()),
|
|
158
159
|
timeout,
|
|
159
160
|
frequency: new kit_1.Duration(1, kit_1.Duration.Unit.SECONDS),
|
|
160
161
|
});
|
|
@@ -172,7 +173,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
172
173
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
173
174
|
const timeout = new kit_1.Duration(quantity, kit_1.Duration.Unit.SECONDS);
|
|
174
175
|
const resolver = await myDomainResolver_1.MyDomainResolver.create({
|
|
175
|
-
url: new
|
|
176
|
+
url: new node_url_1.URL(this.origin),
|
|
176
177
|
timeout,
|
|
177
178
|
frequency: new kit_1.Duration(1, kit_1.Duration.Unit.SECONDS),
|
|
178
179
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Readable } from 'stream';
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
4
|
export interface StructuredWriter {
|
|
5
5
|
addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
|
|
6
6
|
finalize(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const nowBigInt: () => bigint;
|
package/lib/util/time.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nowBigInt = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
11
|
+
const nowBigInt = () => BigInt((node_perf_hooks_1.performance.now() + node_perf_hooks_1.performance.timeOrigin) * 1000000);
|
|
12
|
+
exports.nowBigInt = nowBigInt;
|
|
13
|
+
//# sourceMappingURL=time.js.map
|
package/lib/util/uniqid.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.uniqid = void 0;
|
|
|
7
7
|
* Licensed under the BSD 3-Clause license.
|
|
8
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
11
|
-
const util = require("util");
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const util = require("node:util");
|
|
12
12
|
/**
|
|
13
13
|
* A function to generate a unique id and return it in the context of a template, if supplied.
|
|
14
14
|
*
|
|
@@ -20,7 +20,7 @@ const util = require("util");
|
|
|
20
20
|
* - length: the length of the unique id as presented in hexadecimal.
|
|
21
21
|
*/
|
|
22
22
|
function uniqid(options) {
|
|
23
|
-
const uniqueString = (0,
|
|
23
|
+
const uniqueString = (0, node_crypto_1.randomBytes)(Math.ceil((options?.length ?? 32) / 2))
|
|
24
24
|
.toString('hex')
|
|
25
25
|
.slice(0, options?.length ?? 32);
|
|
26
26
|
if (!options?.template) {
|
package/lib/util/zipWriter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Readable, Writable } from 'stream';
|
|
3
|
+
import { Readable, Writable } from 'node:stream';
|
|
4
4
|
import { StructuredWriter } from './structuredWriter';
|
|
5
5
|
export declare class ZipWriter extends Writable implements StructuredWriter {
|
|
6
6
|
private readonly rootDestination?;
|
package/lib/util/zipWriter.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ZipWriter = void 0;
|
|
10
|
-
const
|
|
10
|
+
const node_stream_1 = require("node:stream");
|
|
11
11
|
const JSZip = require("jszip");
|
|
12
12
|
const logger_1 = require("../logger/logger");
|
|
13
13
|
const sfError_1 = require("../sfError");
|
|
14
|
-
class ZipWriter extends
|
|
14
|
+
class ZipWriter extends node_stream_1.Writable {
|
|
15
15
|
constructor(rootDestination) {
|
|
16
16
|
super({ objectMode: true });
|
|
17
17
|
this.rootDestination = rootDestination;
|
package/lib/webOAuthServer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import * as http from 'http';
|
|
2
|
+
import * as http from 'node:http';
|
|
3
3
|
import { AsyncCreatable } from '@salesforce/kit';
|
|
4
|
-
import { AuthInfo } from './org';
|
|
4
|
+
import { AuthInfo } from './org/authInfo';
|
|
5
5
|
import { JwtOAuth2Config } from './org/authInfo';
|
|
6
6
|
/**
|
|
7
7
|
* Handles the creation of a web server for web based login flows.
|