@salesforce/core 3.24.5 → 3.26.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 +18 -0
- package/lib/config/config.js +7 -0
- package/lib/exported.d.ts +1 -1
- package/lib/exported.js +2 -4
- package/lib/org/authRemover.js +2 -7
- package/lib/org/orgConfigProperties.js +5 -0
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +3 -86
- package/lib/stateAggregator/accessors/aliasAccessor.js +1 -117
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +3 -24
- package/lib/stateAggregator/accessors/orgAccessor.js +14 -44
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +0 -39
- package/lib/stateAggregator/accessors/sandboxAccessor.js +1 -55
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +12 -18
- package/lib/stateAggregator/accessors/tokenAccessor.js +2 -30
- package/lib/stateAggregator/index.d.ts +3 -6
- package/lib/stateAggregator/index.js +3 -13
- package/lib/testSetup.js +0 -2
- package/messages/config.md +8 -0
- package/package.json +1 -1
- package/lib/stateAggregator/globalInfoConfig.d.ts +0 -41
- package/lib/stateAggregator/globalInfoConfig.js +0 -113
- package/lib/stateAggregator/sfdxDataHandler.d.ts +0 -59
- package/lib/stateAggregator/sfdxDataHandler.js +0 -328
- package/lib/stateAggregator/types.d.ts +0 -72
- package/lib/stateAggregator/types.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
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.26.0](https://github.com/forcedotcom/sfdx-core/compare/v3.25.1...v3.26.0) (2022-08-04)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- remove GlobalInfo ([57bd0fa](https://github.com/forcedotcom/sfdx-core/commit/57bd0fa50c5fe3cc859ca107fd0a18dc1b871c1f))
|
|
10
|
+
|
|
11
|
+
### [3.25.1](https://github.com/forcedotcom/sfdx-core/compare/v3.25.0...v3.25.1) (2022-08-03)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- add interop between templates config/env var ([eea3d05](https://github.com/forcedotcom/sfdx-core/commit/eea3d055b75ceb61639e06bc53e309a01f70a8e2))
|
|
16
|
+
|
|
17
|
+
## [3.25.0](https://github.com/forcedotcom/sfdx-core/compare/v3.24.5...v3.25.0) (2022-07-29)
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
- orgAccessor.get has throwOnNotFound option ([a2ee821](https://github.com/forcedotcom/sfdx-core/commit/a2ee8219adf692de7de17ba254e05f501ef5814c))
|
|
22
|
+
|
|
5
23
|
### [3.24.5](https://github.com/forcedotcom/sfdx-core/compare/v3.24.4...v3.24.5) (2022-07-28)
|
|
6
24
|
|
|
7
25
|
### Bug Fixes
|
package/lib/config/config.js
CHANGED
|
@@ -40,6 +40,7 @@ const messages = messages_1.Messages.load('@salesforce/core', 'config', [
|
|
|
40
40
|
'restDeploy',
|
|
41
41
|
'instanceUrl',
|
|
42
42
|
'disable-telemetry',
|
|
43
|
+
'customOrgMetadataTemplates',
|
|
43
44
|
]);
|
|
44
45
|
const SFDX_CONFIG_FILE_NAME = 'sfdx-config.json';
|
|
45
46
|
const CONFIG_FILE_NAME = 'config.json';
|
|
@@ -200,6 +201,12 @@ exports.SFDX_ALLOWED_PROPERTIES = [
|
|
|
200
201
|
failedMessage: messages.getMessage('invalidBooleanConfigValue'),
|
|
201
202
|
},
|
|
202
203
|
},
|
|
204
|
+
{
|
|
205
|
+
key: SfdxPropertyKeys.CUSTOM_ORG_METADATA_TEMPLATES,
|
|
206
|
+
newKey: orgConfigProperties_1.OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES,
|
|
207
|
+
deprecated: true,
|
|
208
|
+
description: messages.getMessage(SfdxPropertyKeys.CUSTOM_ORG_METADATA_TEMPLATES),
|
|
209
|
+
},
|
|
203
210
|
{
|
|
204
211
|
key: SfdxPropertyKeys.REST_DEPLOY,
|
|
205
212
|
description: messages.getMessage(SfdxPropertyKeys.REST_DEPLOY),
|
package/lib/exported.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ConfigFile } from './config/configFile';
|
|
|
3
3
|
export { TTLConfig } from './config/ttlConfig';
|
|
4
4
|
export { envVars, EnvironmentVariable, SUPPORTED_ENV_VARS, EnvVars } from './config/envVars';
|
|
5
5
|
export { ConfigContents, ConfigEntry, ConfigStore, ConfigValue } from './config/configStore';
|
|
6
|
-
export {
|
|
6
|
+
export { SfTokens, StateAggregator } from './stateAggregator';
|
|
7
7
|
export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } from './deviceOauthService';
|
|
8
8
|
export { OrgUsersConfig } from './config/orgUsersConfig';
|
|
9
9
|
export { ConfigPropertyMeta, ConfigPropertyMetaInput, Config, SfdxPropertyKeys, SfConfigProperties, SFDX_ALLOWED_PROPERTIES, SF_ALLOWED_PROPERTIES, } from './config/config';
|
package/lib/exported.js
CHANGED
|
@@ -16,8 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SfError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.SfProjectJson = exports.SfProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.SfdxConfigAggregator = exports.ConfigAggregator = exports.SandboxRequestCache = exports.SF_ALLOWED_PROPERTIES = exports.SFDX_ALLOWED_PROPERTIES = exports.SfConfigProperties = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.StateAggregator = exports.
|
|
20
|
-
exports.ScratchOrgCache = exports.scratchOrgLifecycleStages = exports.scratchOrgLifecycleEventName = exports.scratchOrgResume = exports.scratchOrgCreate = exports.PermissionSetAssignment =
|
|
19
|
+
exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SfError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.SfProjectJson = exports.SfProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.SfdxConfigAggregator = exports.ConfigAggregator = exports.SandboxRequestCache = exports.SF_ALLOWED_PROPERTIES = exports.SFDX_ALLOWED_PROPERTIES = exports.SfConfigProperties = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.StateAggregator = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.TTLConfig = exports.ConfigFile = void 0;
|
|
20
|
+
exports.ScratchOrgCache = exports.scratchOrgLifecycleStages = exports.scratchOrgLifecycleEventName = exports.scratchOrgResume = exports.scratchOrgCreate = exports.PermissionSetAssignment = void 0;
|
|
21
21
|
const messages_1 = require("./messages");
|
|
22
22
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
23
23
|
var configFile_1 = require("./config/configFile");
|
|
@@ -30,8 +30,6 @@ Object.defineProperty(exports, "EnvironmentVariable", { enumerable: true, get: f
|
|
|
30
30
|
Object.defineProperty(exports, "SUPPORTED_ENV_VARS", { enumerable: true, get: function () { return envVars_1.SUPPORTED_ENV_VARS; } });
|
|
31
31
|
Object.defineProperty(exports, "EnvVars", { enumerable: true, get: function () { return envVars_1.EnvVars; } });
|
|
32
32
|
var stateAggregator_1 = require("./stateAggregator");
|
|
33
|
-
Object.defineProperty(exports, "GlobalInfo", { enumerable: true, get: function () { return stateAggregator_1.GlobalInfo; } });
|
|
34
|
-
Object.defineProperty(exports, "SfInfoKeys", { enumerable: true, get: function () { return stateAggregator_1.SfInfoKeys; } });
|
|
35
33
|
Object.defineProperty(exports, "StateAggregator", { enumerable: true, get: function () { return stateAggregator_1.StateAggregator; } });
|
|
36
34
|
var deviceOauthService_1 = require("./deviceOauthService");
|
|
37
35
|
Object.defineProperty(exports, "DeviceOauthService", { enumerable: true, get: function () { return deviceOauthService_1.DeviceOauthService; } });
|
package/lib/org/authRemover.js
CHANGED
|
@@ -14,7 +14,6 @@ const messages_1 = require("../messages");
|
|
|
14
14
|
const stateAggregator_1 = require("../stateAggregator");
|
|
15
15
|
const orgConfigProperties_1 = require("./orgConfigProperties");
|
|
16
16
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
17
|
-
const coreMessages = messages_1.Messages.load('@salesforce/core', 'core', ['namedOrgNotFound']);
|
|
18
17
|
const messages = messages_1.Messages.load('@salesforce/core', 'auth', ['targetOrgNotSet']);
|
|
19
18
|
/**
|
|
20
19
|
* Handles the removing of authorizations, which includes deleting the auth file
|
|
@@ -72,12 +71,8 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
72
71
|
* @returns {Promise<SfOrg>}
|
|
73
72
|
*/
|
|
74
73
|
async findAuth(usernameOrAlias) {
|
|
75
|
-
const username = await this.resolveUsername(usernameOrAlias
|
|
76
|
-
|
|
77
|
-
if (!auth) {
|
|
78
|
-
throw coreMessages.createError('namedOrgNotFound');
|
|
79
|
-
}
|
|
80
|
-
return auth;
|
|
74
|
+
const username = await this.resolveUsername(usernameOrAlias ?? this.getTargetOrg());
|
|
75
|
+
return this.stateAggregator.orgs.get(username, false, true);
|
|
81
76
|
}
|
|
82
77
|
/**
|
|
83
78
|
* Finds all org authorizations in the global info file (.sf/sf.json)
|
|
@@ -27,6 +27,7 @@ const messages = messages_1.Messages.load('@salesforce/core', 'config', [
|
|
|
27
27
|
'org-max-query-limit',
|
|
28
28
|
'target-dev-hub',
|
|
29
29
|
'target-org',
|
|
30
|
+
'org-custom-metadata-templates',
|
|
30
31
|
]);
|
|
31
32
|
var OrgConfigProperties;
|
|
32
33
|
(function (OrgConfigProperties) {
|
|
@@ -64,6 +65,10 @@ var OrgConfigProperties;
|
|
|
64
65
|
OrgConfigProperties["ORG_ISV_DEBUGGER_URL"] = "org-isv-debugger-url";
|
|
65
66
|
})(OrgConfigProperties = exports.OrgConfigProperties || (exports.OrgConfigProperties = {}));
|
|
66
67
|
exports.ORG_CONFIG_ALLOWED_PROPERTIES = [
|
|
68
|
+
{
|
|
69
|
+
key: OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES,
|
|
70
|
+
description: messages.getMessage(OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES),
|
|
71
|
+
},
|
|
67
72
|
{
|
|
68
73
|
key: OrgConfigProperties.TARGET_ORG,
|
|
69
74
|
description: messages.getMessage(OrgConfigProperties.TARGET_ORG),
|
|
@@ -1,91 +1,8 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
2
2
|
import { Nullable } from '@salesforce/ts-types';
|
|
3
|
-
import { ConfigContents } from '../../exported';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export declare type Aliasable = string | Partial<SfOrg> | Partial<SfToken>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
export declare class GlobalInfoAliasAccessor {
|
|
11
|
-
private globalInfo;
|
|
12
|
-
constructor(globalInfo: GlobalInfo);
|
|
13
|
-
/**
|
|
14
|
-
* Returns all the aliases for all the values
|
|
15
|
-
*/
|
|
16
|
-
getAll(): SfAliases;
|
|
17
|
-
/**
|
|
18
|
-
* Returns all the aliases for a given entity
|
|
19
|
-
*
|
|
20
|
-
* @param entity the aliasable entity that you want to get the aliases of
|
|
21
|
-
*/
|
|
22
|
-
getAll(entity: Aliasable): string[];
|
|
23
|
-
/**
|
|
24
|
-
* Returns the first alias found for a given entity
|
|
25
|
-
*
|
|
26
|
-
* @param entity the aliasable entity that you want to get the alias of
|
|
27
|
-
*/
|
|
28
|
-
get(entity: Aliasable): Nullable<string>;
|
|
29
|
-
/**
|
|
30
|
-
* Returns the value that corresponds to the given alias if it exists
|
|
31
|
-
*
|
|
32
|
-
* @param alias the alias that corresponds to a value
|
|
33
|
-
*/
|
|
34
|
-
getValue(alias: string): Nullable<string>;
|
|
35
|
-
/**
|
|
36
|
-
* Returns the username that corresponds to the given alias if it exists
|
|
37
|
-
*
|
|
38
|
-
* @param alias the alias that corresponds to a username
|
|
39
|
-
*/
|
|
40
|
-
getUsername(alias: string): Nullable<string>;
|
|
41
|
-
/**
|
|
42
|
-
* If the provided string is an alias, it returns the corresponding value.
|
|
43
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
44
|
-
* is the value and return it.
|
|
45
|
-
*
|
|
46
|
-
* This method is helpful when you don't know if the string you have is a value
|
|
47
|
-
* or an alias.
|
|
48
|
-
*
|
|
49
|
-
* @param valueOrAlias a string that might be a value or might be an alias
|
|
50
|
-
*/
|
|
51
|
-
resolveValue(valueOrAlias: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* If the provided string is an alias, it returns the corresponding username.
|
|
54
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
55
|
-
* is the username and return it.
|
|
56
|
-
*
|
|
57
|
-
* This method is helpful when you don't know if the string you have is a username
|
|
58
|
-
* or an alias.
|
|
59
|
-
*
|
|
60
|
-
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
61
|
-
*/
|
|
62
|
-
resolveUsername(usernameOrAlias: string): string;
|
|
63
|
-
/**
|
|
64
|
-
* Set an alias for the given aliasable entity
|
|
65
|
-
*
|
|
66
|
-
* @param alias the alias you want to set
|
|
67
|
-
* @param entity the aliasable entity that's being aliased
|
|
68
|
-
*/
|
|
69
|
-
set(alias: string, entity: Aliasable): void;
|
|
70
|
-
/**
|
|
71
|
-
* Updates the alias for the given aliasable entity
|
|
72
|
-
*
|
|
73
|
-
* @param alias the alias you want to set
|
|
74
|
-
* @param entity the aliasable entity that's being aliased
|
|
75
|
-
*/
|
|
76
|
-
update(alias: string, entity: Aliasable): void;
|
|
77
|
-
unset(alias: string): void;
|
|
78
|
-
/**
|
|
79
|
-
* This method unsets all the aliases for the given entity.
|
|
80
|
-
*
|
|
81
|
-
* @param entity the aliasable entity for which you want to unset all aliases
|
|
82
|
-
*/
|
|
83
|
-
unsetAll(entity: Aliasable): void;
|
|
84
|
-
/**
|
|
85
|
-
* Returns the username of given aliasable entity
|
|
86
|
-
*/
|
|
87
|
-
private getNameOf;
|
|
88
|
-
}
|
|
3
|
+
import { AuthFields, ConfigContents } from '../../exported';
|
|
4
|
+
import { SfToken } from './tokenAccessor';
|
|
5
|
+
export declare type Aliasable = string | (Partial<AuthFields> & Partial<SfToken>);
|
|
89
6
|
export declare class AliasAccessor extends AsyncOptionalCreatable {
|
|
90
7
|
private config;
|
|
91
8
|
/**
|
|
@@ -6,126 +6,10 @@
|
|
|
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.AliasAccessor =
|
|
9
|
+
exports.AliasAccessor = void 0;
|
|
10
10
|
const kit_1 = require("@salesforce/kit");
|
|
11
11
|
const aliasesConfig_1 = require("../../config/aliasesConfig");
|
|
12
12
|
const sfError_1 = require("../../sfError");
|
|
13
|
-
const types_1 = require("../types");
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated
|
|
16
|
-
*/
|
|
17
|
-
class GlobalInfoAliasAccessor {
|
|
18
|
-
constructor(globalInfo) {
|
|
19
|
-
this.globalInfo = globalInfo;
|
|
20
|
-
}
|
|
21
|
-
getAll(entity) {
|
|
22
|
-
const all = this.globalInfo.get(types_1.SfInfoKeys.ALIASES) || {};
|
|
23
|
-
if (entity) {
|
|
24
|
-
const value = this.getNameOf(entity);
|
|
25
|
-
return Object.entries(all)
|
|
26
|
-
.filter((entry) => entry[1] === value)
|
|
27
|
-
.map((entry) => entry[0]);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return all;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns the first alias found for a given entity
|
|
35
|
-
*
|
|
36
|
-
* @param entity the aliasable entity that you want to get the alias of
|
|
37
|
-
*/
|
|
38
|
-
get(entity) {
|
|
39
|
-
return this.getAll(entity).find((alias) => alias) ?? null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Returns the value that corresponds to the given alias if it exists
|
|
43
|
-
*
|
|
44
|
-
* @param alias the alias that corresponds to a value
|
|
45
|
-
*/
|
|
46
|
-
getValue(alias) {
|
|
47
|
-
return this.getAll()[alias] ?? null;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Returns the username that corresponds to the given alias if it exists
|
|
51
|
-
*
|
|
52
|
-
* @param alias the alias that corresponds to a username
|
|
53
|
-
*/
|
|
54
|
-
getUsername(alias) {
|
|
55
|
-
return this.getAll()[alias] ?? null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* If the provided string is an alias, it returns the corresponding value.
|
|
59
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
60
|
-
* is the value and return it.
|
|
61
|
-
*
|
|
62
|
-
* This method is helpful when you don't know if the string you have is a value
|
|
63
|
-
* or an alias.
|
|
64
|
-
*
|
|
65
|
-
* @param valueOrAlias a string that might be a value or might be an alias
|
|
66
|
-
*/
|
|
67
|
-
resolveValue(valueOrAlias) {
|
|
68
|
-
return this.getValue(valueOrAlias) ?? valueOrAlias;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* If the provided string is an alias, it returns the corresponding username.
|
|
72
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
73
|
-
* is the username and return it.
|
|
74
|
-
*
|
|
75
|
-
* This method is helpful when you don't know if the string you have is a username
|
|
76
|
-
* or an alias.
|
|
77
|
-
*
|
|
78
|
-
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
79
|
-
*/
|
|
80
|
-
resolveUsername(usernameOrAlias) {
|
|
81
|
-
return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Set an alias for the given aliasable entity
|
|
85
|
-
*
|
|
86
|
-
* @param alias the alias you want to set
|
|
87
|
-
* @param entity the aliasable entity that's being aliased
|
|
88
|
-
*/
|
|
89
|
-
set(alias, entity) {
|
|
90
|
-
const value = this.getNameOf(entity);
|
|
91
|
-
this.globalInfo.set(`${types_1.SfInfoKeys.ALIASES}["${alias}"]`, value);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Updates the alias for the given aliasable entity
|
|
95
|
-
*
|
|
96
|
-
* @param alias the alias you want to set
|
|
97
|
-
* @param entity the aliasable entity that's being aliased
|
|
98
|
-
*/
|
|
99
|
-
update(alias, entity) {
|
|
100
|
-
const value = this.getNameOf(entity);
|
|
101
|
-
this.globalInfo.update(`${types_1.SfInfoKeys.ALIASES}["${alias}"]`, value);
|
|
102
|
-
}
|
|
103
|
-
unset(alias) {
|
|
104
|
-
delete this.globalInfo.get(types_1.SfInfoKeys.ALIASES)[alias];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* This method unsets all the aliases for the given entity.
|
|
108
|
-
*
|
|
109
|
-
* @param entity the aliasable entity for which you want to unset all aliases
|
|
110
|
-
*/
|
|
111
|
-
unsetAll(entity) {
|
|
112
|
-
const aliases = this.getAll(entity);
|
|
113
|
-
aliases.forEach((alias) => this.unset(alias));
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Returns the username of given aliasable entity
|
|
117
|
-
*/
|
|
118
|
-
getNameOf(entity) {
|
|
119
|
-
if (typeof entity === 'string')
|
|
120
|
-
return entity;
|
|
121
|
-
const aliaseeName = entity.username ?? entity.user;
|
|
122
|
-
if (!aliaseeName) {
|
|
123
|
-
throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
|
|
124
|
-
}
|
|
125
|
-
return aliaseeName;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.GlobalInfoAliasAccessor = GlobalInfoAliasAccessor;
|
|
129
13
|
class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
130
14
|
getAll(entity) {
|
|
131
15
|
// This will only return aliases under "orgs". This will need to be modified
|
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
-
import { Nullable
|
|
3
|
+
import { Nullable } from '@salesforce/ts-types';
|
|
4
4
|
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
5
5
|
import { AuthInfoConfig } from '../../config/authInfoConfig';
|
|
6
|
-
import { GlobalInfo } from '../globalInfoConfig';
|
|
7
|
-
import { SfOrgs, SfOrg } from '../types';
|
|
8
6
|
import { AuthFields } from '../../org';
|
|
9
7
|
import { ConfigFile } from '../../config/configFile';
|
|
10
8
|
import { ConfigContents } from '../../config/configStore';
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated
|
|
13
|
-
*/
|
|
14
|
-
export declare class GlobalInfoOrgAccessor {
|
|
15
|
-
private globalInfo;
|
|
16
|
-
constructor(globalInfo: GlobalInfo);
|
|
17
|
-
getAll(decrypt?: boolean): SfOrgs;
|
|
18
|
-
get(username: string, decrypt?: boolean): Optional<SfOrg>;
|
|
19
|
-
has(username: string): boolean;
|
|
20
|
-
set(username: string, org: SfOrg): void;
|
|
21
|
-
update(username: string, org: Partial<SfOrg>): void;
|
|
22
|
-
unset(username: string): void;
|
|
23
|
-
}
|
|
24
9
|
export declare abstract class BaseOrgAccessor<T extends ConfigFile, P extends ConfigContents> extends AsyncOptionalCreatable {
|
|
25
10
|
private configs;
|
|
26
11
|
private contents;
|
|
27
12
|
private logger;
|
|
28
13
|
/**
|
|
29
|
-
* Read the auth file for the given
|
|
14
|
+
* Read the auth file for the given username. Once the file has been read, it can be re-accessed with the `get` method.
|
|
30
15
|
*
|
|
31
16
|
* @param username username to read
|
|
32
17
|
* @param decrypt if true, decrypt encrypted values
|
|
@@ -39,13 +24,7 @@ export declare abstract class BaseOrgAccessor<T extends ConfigFile, P extends Co
|
|
|
39
24
|
* @param decrypt if true, decrypt encrypted values
|
|
40
25
|
*/
|
|
41
26
|
readAll(decrypt?: boolean): Promise<P[]>;
|
|
42
|
-
|
|
43
|
-
* Return the contents of the username's auth file from cache. The `read` or `readAll` methods must be called first in order to populate the cache.
|
|
44
|
-
*
|
|
45
|
-
* @param username username to get
|
|
46
|
-
* @param decrypt if true, decrypt encrypted values
|
|
47
|
-
*/
|
|
48
|
-
get(username: string, decrypt?: boolean): Nullable<P>;
|
|
27
|
+
get(username: string, decrypt?: boolean, throwOnNotFound?: true): P;
|
|
49
28
|
/**
|
|
50
29
|
* Return the contents of all the auth files from cache. The `read` or `readAll` methods must be called first in order to populate the cache.
|
|
51
30
|
*
|
|
@@ -6,49 +6,14 @@
|
|
|
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.OrgAccessor = exports.BaseOrgAccessor =
|
|
9
|
+
exports.OrgAccessor = exports.BaseOrgAccessor = void 0;
|
|
10
10
|
const fs = require("fs");
|
|
11
11
|
const path = require("path");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
13
13
|
const authInfoConfig_1 = require("../../config/authInfoConfig");
|
|
14
14
|
const global_1 = require("../../global");
|
|
15
|
-
const types_1 = require("../types");
|
|
16
15
|
const logger_1 = require("../../logger");
|
|
17
|
-
|
|
18
|
-
* @deprecated
|
|
19
|
-
*/
|
|
20
|
-
class GlobalInfoOrgAccessor {
|
|
21
|
-
constructor(globalInfo) {
|
|
22
|
-
this.globalInfo = globalInfo;
|
|
23
|
-
}
|
|
24
|
-
getAll(decrypt = false) {
|
|
25
|
-
return this.globalInfo.get(types_1.SfInfoKeys.ORGS, decrypt);
|
|
26
|
-
}
|
|
27
|
-
get(username, decrypt = false) {
|
|
28
|
-
const auth = this.globalInfo.get(`${types_1.SfInfoKeys.ORGS}["${username}"]`, decrypt);
|
|
29
|
-
// For legacy, some things wants the username in the returned auth info.
|
|
30
|
-
if (auth && !auth.username)
|
|
31
|
-
auth.username = username;
|
|
32
|
-
return auth;
|
|
33
|
-
}
|
|
34
|
-
has(username) {
|
|
35
|
-
return !!this.getAll()[username];
|
|
36
|
-
}
|
|
37
|
-
set(username, org) {
|
|
38
|
-
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
39
|
-
org.username ?? (org.username = username);
|
|
40
|
-
this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
41
|
-
}
|
|
42
|
-
update(username, org) {
|
|
43
|
-
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
44
|
-
org.username ?? (org.username = username);
|
|
45
|
-
this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
46
|
-
}
|
|
47
|
-
unset(username) {
|
|
48
|
-
delete this.globalInfo.get(types_1.SfInfoKeys.ORGS)[username];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.GlobalInfoOrgAccessor = GlobalInfoOrgAccessor;
|
|
16
|
+
const messages_1 = require("../../messages");
|
|
52
17
|
function chunk(array, chunkSize) {
|
|
53
18
|
const final = [];
|
|
54
19
|
for (let i = 0, len = array.length; i < len; i += chunkSize)
|
|
@@ -62,7 +27,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
62
27
|
this.contents = new Map();
|
|
63
28
|
}
|
|
64
29
|
/**
|
|
65
|
-
* Read the auth file for the given
|
|
30
|
+
* Read the auth file for the given username. Once the file has been read, it can be re-accessed with the `get` method.
|
|
66
31
|
*
|
|
67
32
|
* @param username username to read
|
|
68
33
|
* @param decrypt if true, decrypt encrypted values
|
|
@@ -96,13 +61,21 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
96
61
|
return this.getAll(decrypt);
|
|
97
62
|
}
|
|
98
63
|
/**
|
|
99
|
-
* Return the contents of the username's auth file from cache.
|
|
64
|
+
* Return the contents of the username's auth file from cache.
|
|
65
|
+
* The `read` or `readAll` methods must be called first in order to populate the cache.
|
|
66
|
+
* If throwOnNotFound is not true, an empty object {} is returned if the org is not found.
|
|
100
67
|
*
|
|
101
68
|
* @param username username to get
|
|
102
69
|
* @param decrypt if true, decrypt encrypted values
|
|
70
|
+
* @param throwOnNotFound if true, throw if the auth file does not already exist in the cache
|
|
103
71
|
*/
|
|
104
|
-
get(username, decrypt = false) {
|
|
72
|
+
get(username, decrypt = false, throwOnNotFound = false) {
|
|
105
73
|
const config = this.configs.get(username);
|
|
74
|
+
if (throwOnNotFound && config?.keys().length === 0) {
|
|
75
|
+
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
76
|
+
const messages = messages_1.Messages.load('@salesforce/core', 'core', ['namedOrgNotFound']);
|
|
77
|
+
throw messages.createError('namedOrgNotFound', [username]);
|
|
78
|
+
}
|
|
106
79
|
if (config) {
|
|
107
80
|
this.contents.set(username, config.getContents(decrypt));
|
|
108
81
|
}
|
|
@@ -115,10 +88,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
115
88
|
* @returns
|
|
116
89
|
*/
|
|
117
90
|
getAll(decrypt = false) {
|
|
118
|
-
return [...this.configs.keys()].
|
|
119
|
-
const org = this.get(username, decrypt);
|
|
120
|
-
return org && !(0, kit_1.isEmpty)(org) ? orgs.concat([org]) : orgs;
|
|
121
|
-
}, []);
|
|
91
|
+
return [...this.configs.keys()].map((username) => this.get(username, decrypt)).filter((org) => !(0, kit_1.isEmpty)(org));
|
|
122
92
|
}
|
|
123
93
|
/**
|
|
124
94
|
* Returns true if the username has been cached.
|
|
@@ -1,45 +1,6 @@
|
|
|
1
|
-
import { Nullable } from '@salesforce/ts-types';
|
|
2
1
|
import { SandboxOrgConfig } from '../../config/sandboxOrgConfig';
|
|
3
2
|
import { SandboxFields } from '../../org';
|
|
4
|
-
import { GlobalInfo } from '../globalInfoConfig';
|
|
5
|
-
import { SfSandbox, SfSandboxes } from '../types';
|
|
6
3
|
import { BaseOrgAccessor } from './orgAccessor';
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
export declare class GlobalInfoSandboxAccessor {
|
|
11
|
-
private globalInfo;
|
|
12
|
-
constructor(globalInfo: GlobalInfo);
|
|
13
|
-
/**
|
|
14
|
-
* Returns all the sandboxes (or all the sandboxes for a given prod org)
|
|
15
|
-
*
|
|
16
|
-
* @param entity entity as a string should be a production org username
|
|
17
|
-
* and when entity is a SfSandbox, the prod org entity.prodOrgUsername will
|
|
18
|
-
* used in the filter.
|
|
19
|
-
*/
|
|
20
|
-
getAll(entity?: string | SfSandbox): SfSandboxes;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the SfSandbox config entry that corresponds to the given
|
|
23
|
-
* sandbox org id if it exists
|
|
24
|
-
*
|
|
25
|
-
* @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
|
|
26
|
-
*/
|
|
27
|
-
get(sandboxOrgId?: string): Nullable<SfSandbox>;
|
|
28
|
-
/**
|
|
29
|
-
* Returns true if the given sandbox org id exists
|
|
30
|
-
*
|
|
31
|
-
* @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
|
|
32
|
-
*/
|
|
33
|
-
has(sandboxOrgId?: string): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Set an sandboxOrgId for the given sandbox entity
|
|
36
|
-
*
|
|
37
|
-
* @param sandboxOrgId the sandboxOrgId you want to set
|
|
38
|
-
* @param entity the sandbox entity
|
|
39
|
-
*/
|
|
40
|
-
set(sandboxOrgId: string, entity: SfSandbox): void;
|
|
41
|
-
unset(sandboxOrgId: string): void;
|
|
42
|
-
}
|
|
43
4
|
export declare class SandboxAccessor extends BaseOrgAccessor<SandboxOrgConfig, SandboxFields> {
|
|
44
5
|
protected initAuthFile(username: string, throwOnNotFound?: boolean): Promise<SandboxOrgConfig>;
|
|
45
6
|
protected getFileRegex(): RegExp;
|
|
@@ -6,63 +6,9 @@
|
|
|
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.SandboxAccessor =
|
|
9
|
+
exports.SandboxAccessor = void 0;
|
|
10
10
|
const sandboxOrgConfig_1 = require("../../config/sandboxOrgConfig");
|
|
11
|
-
const types_1 = require("../types");
|
|
12
11
|
const orgAccessor_1 = require("./orgAccessor");
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
class GlobalInfoSandboxAccessor {
|
|
17
|
-
constructor(globalInfo) {
|
|
18
|
-
this.globalInfo = globalInfo;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Returns all the sandboxes (or all the sandboxes for a given prod org)
|
|
22
|
-
*
|
|
23
|
-
* @param entity entity as a string should be a production org username
|
|
24
|
-
* and when entity is a SfSandbox, the prod org entity.prodOrgUsername will
|
|
25
|
-
* used in the filter.
|
|
26
|
-
*/
|
|
27
|
-
getAll(entity) {
|
|
28
|
-
const all = this.globalInfo.get(types_1.SfInfoKeys.SANDBOXES) || {};
|
|
29
|
-
if (!entity) {
|
|
30
|
-
return all;
|
|
31
|
-
}
|
|
32
|
-
const prodOrgUsername = typeof entity === 'string' ? entity : entity.prodOrgUsername;
|
|
33
|
-
return Object.fromEntries(Object.entries(all).filter(([, value]) => value.prodOrgUsername === prodOrgUsername));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Returns the SfSandbox config entry that corresponds to the given
|
|
37
|
-
* sandbox org id if it exists
|
|
38
|
-
*
|
|
39
|
-
* @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
|
|
40
|
-
*/
|
|
41
|
-
get(sandboxOrgId) {
|
|
42
|
-
return sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns true if the given sandbox org id exists
|
|
46
|
-
*
|
|
47
|
-
* @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
|
|
48
|
-
*/
|
|
49
|
-
has(sandboxOrgId) {
|
|
50
|
-
return !!(sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Set an sandboxOrgId for the given sandbox entity
|
|
54
|
-
*
|
|
55
|
-
* @param sandboxOrgId the sandboxOrgId you want to set
|
|
56
|
-
* @param entity the sandbox entity
|
|
57
|
-
*/
|
|
58
|
-
set(sandboxOrgId, entity) {
|
|
59
|
-
this.globalInfo.set(`${types_1.SfInfoKeys.SANDBOXES}["${sandboxOrgId}"]`, entity);
|
|
60
|
-
}
|
|
61
|
-
unset(sandboxOrgId) {
|
|
62
|
-
delete this.globalInfo.get(types_1.SfInfoKeys.SANDBOXES)[sandboxOrgId];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.GlobalInfoSandboxAccessor = GlobalInfoSandboxAccessor;
|
|
66
12
|
class SandboxAccessor extends orgAccessor_1.BaseOrgAccessor {
|
|
67
13
|
async initAuthFile(username, throwOnNotFound = false) {
|
|
68
14
|
return sandboxOrgConfig_1.SandboxOrgConfig.create({
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
2
|
-
import { Optional } from '@salesforce/ts-types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get(name: string, decrypt?: boolean): Optional<SfToken & Timestamp>;
|
|
13
|
-
has(name: string): boolean;
|
|
14
|
-
set(name: string, token: SfToken): void;
|
|
15
|
-
update(name: string, token: Partial<SfToken>): void;
|
|
16
|
-
unset(name: string): void;
|
|
17
|
-
}
|
|
2
|
+
import { JsonMap, Optional } from '@salesforce/ts-types';
|
|
3
|
+
export declare type SfToken = {
|
|
4
|
+
token: string;
|
|
5
|
+
url: string;
|
|
6
|
+
user?: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
} & JsonMap;
|
|
9
|
+
export declare type SfTokens = {
|
|
10
|
+
[key: string]: SfToken;
|
|
11
|
+
};
|
|
18
12
|
export declare class TokenAccessor extends AsyncOptionalCreatable {
|
|
19
13
|
private config;
|
|
20
14
|
/**
|
|
@@ -29,9 +23,9 @@ export declare class TokenAccessor extends AsyncOptionalCreatable {
|
|
|
29
23
|
*
|
|
30
24
|
* @param name
|
|
31
25
|
* @param decrypt
|
|
32
|
-
* @returns {Optional<SfToken
|
|
26
|
+
* @returns {Optional<SfToken>}
|
|
33
27
|
*/
|
|
34
|
-
get(name: string, decrypt?: boolean): Optional<SfToken
|
|
28
|
+
get(name: string, decrypt?: boolean): Optional<SfToken>;
|
|
35
29
|
/**
|
|
36
30
|
* Return true if a given name has a token associated with it.
|
|
37
31
|
*
|