@salesforce/core 4.0.0 → 4.1.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/LICENSE.txt +1 -1
- package/README.md +93 -44
- package/lib/config/authInfoConfig.d.ts +19 -0
- package/lib/config/authInfoConfig.js +35 -0
- package/lib/config/config.d.ts +87 -22
- package/lib/config/config.js +117 -65
- package/lib/config/configAggregator.d.ts +41 -35
- package/lib/config/configAggregator.js +102 -73
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +38 -29
- package/lib/config/configStore.d.ts +9 -9
- package/lib/config/configStore.js +17 -15
- package/lib/config/envVars.d.ts +15 -9
- package/lib/config/envVars.js +71 -47
- package/lib/config/orgUsersConfig.js +2 -0
- package/lib/config/sandboxOrgConfig.js +2 -0
- package/lib/config/sandboxProcessCache.d.ts +16 -0
- package/lib/config/sandboxProcessCache.js +38 -0
- package/lib/config/tokensConfig.d.ts +10 -0
- package/lib/config/tokensConfig.js +29 -0
- package/lib/config/ttlConfig.d.ts +34 -0
- package/lib/config/ttlConfig.js +50 -0
- package/lib/crypto/crypto.js +15 -22
- package/lib/crypto/keyChain.js +2 -3
- package/lib/crypto/keyChainImpl.d.ts +5 -3
- package/lib/crypto/keyChainImpl.js +58 -61
- package/lib/crypto/secureBuffer.d.ts +1 -1
- package/lib/deviceOauthService.d.ts +3 -3
- package/lib/deviceOauthService.js +27 -25
- package/lib/exported.d.ts +15 -12
- package/lib/exported.js +28 -16
- package/lib/global.d.ts +11 -3
- package/lib/global.js +39 -12
- package/lib/lifecycleEvents.d.ts +1 -1
- package/lib/lifecycleEvents.js +3 -0
- package/lib/logger.d.ts +19 -9
- package/lib/logger.js +112 -86
- package/lib/messages.d.ts +53 -36
- package/lib/messages.js +81 -91
- package/lib/org/authInfo.d.ts +56 -20
- package/lib/org/authInfo.js +232 -131
- package/lib/org/authRemover.d.ts +8 -7
- package/lib/org/authRemover.js +32 -28
- package/lib/org/connection.d.ts +13 -37
- package/lib/org/connection.js +78 -124
- package/lib/org/index.js +5 -1
- package/lib/org/org.d.ts +151 -48
- package/lib/org/org.js +468 -225
- package/lib/org/orgConfigProperties.d.ts +64 -3
- package/lib/org/orgConfigProperties.js +96 -4
- package/lib/org/permissionSetAssignment.js +4 -13
- package/lib/org/scratchOrgCache.d.ts +20 -0
- package/lib/org/scratchOrgCache.js +33 -0
- package/lib/org/scratchOrgCreate.d.ts +28 -17
- package/lib/org/scratchOrgCreate.js +125 -53
- package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
- package/lib/org/scratchOrgErrorCodes.js +34 -17
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
- package/lib/org/scratchOrgInfoApi.d.ts +21 -47
- package/lib/org/scratchOrgInfoApi.js +129 -63
- package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
- package/lib/org/scratchOrgInfoGenerator.js +76 -62
- package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
- package/lib/org/scratchOrgLifecycleEvents.js +41 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
- package/lib/org/scratchOrgSettingsGenerator.js +165 -98
- package/lib/org/scratchOrgTypes.d.ts +43 -0
- package/lib/org/scratchOrgTypes.js +9 -0
- package/lib/org/user.d.ts +1 -1
- package/lib/org/user.js +25 -34
- package/lib/schema/printer.d.ts +6 -0
- package/lib/schema/printer.js +34 -31
- package/lib/schema/validator.d.ts +12 -10
- package/lib/schema/validator.js +56 -76
- package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
- package/lib/{sfdxError.js → sfError.js} +40 -30
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
- package/lib/sfProject.js +651 -0
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +129 -0
- package/lib/stateAggregator/accessors/aliasAccessor.js +263 -0
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
- package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
- package/lib/stateAggregator/index.d.ts +4 -0
- package/lib/stateAggregator/index.js +27 -0
- package/lib/stateAggregator/stateAggregator.d.ts +25 -0
- package/lib/stateAggregator/stateAggregator.js +46 -0
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +4 -4
- package/lib/status/pollingClient.js +4 -4
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +58 -63
- package/lib/status/types.d.ts +2 -2
- package/lib/testSetup.d.ts +204 -75
- package/lib/testSetup.js +468 -164
- package/lib/util/cache.d.ts +2 -2
- package/lib/util/cache.js +6 -6
- package/lib/util/checkLightningDomain.js +3 -4
- package/lib/util/directoryWriter.d.ts +12 -0
- package/lib/util/directoryWriter.js +54 -0
- package/lib/util/getJwtAudienceUrl.js +1 -1
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +65 -8
- package/lib/util/jsonXmlTools.js +2 -4
- package/lib/util/mapKeys.d.ts +9 -9
- package/lib/util/mapKeys.js +13 -9
- package/lib/util/sfdc.d.ts +51 -51
- package/lib/util/sfdc.js +74 -79
- package/lib/util/sfdcUrl.d.ts +5 -19
- package/lib/util/sfdcUrl.js +40 -49
- package/lib/util/structuredWriter.d.ts +9 -0
- package/lib/util/structuredWriter.js +3 -0
- package/lib/util/zipWriter.d.ts +8 -6
- package/lib/util/zipWriter.js +13 -13
- package/lib/webOAuthServer.d.ts +20 -6
- package/lib/webOAuthServer.js +102 -56
- package/messageTransformer/messageTransformer.ts +93 -0
- package/messages/auth.md +9 -1
- package/messages/config.md +42 -6
- package/messages/connection.md +8 -0
- package/messages/core.md +10 -0
- package/messages/envVars.md +37 -3
- package/messages/org.md +21 -1
- package/messages/scratchOrgCreate.md +2 -6
- package/messages/scratchOrgErrorCodes.md +17 -1
- package/messages/scratchOrgInfoApi.md +9 -0
- package/messages/scratchOrgInfoGenerator.md +9 -1
- package/package.json +123 -46
- package/CHANGELOG.md +0 -1244
- package/lib/config/keychainConfig.d.ts +0 -19
- package/lib/config/keychainConfig.js +0 -43
- package/lib/globalInfo/accessors/aliasAccessor.d.ts +0 -83
- package/lib/globalInfo/accessors/aliasAccessor.js +0 -130
- package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/orgAccessor.js +0 -45
- package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
- package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
- package/lib/globalInfo/globalInfoConfig.js +0 -105
- package/lib/globalInfo/index.d.ts +0 -6
- package/lib/globalInfo/index.js +0 -29
- package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
- package/lib/globalInfo/sfdxDataHandler.js +0 -217
- package/lib/globalInfo/types.d.ts +0 -39
- package/lib/globalInfo/types.js +0 -10
- package/lib/sfdxProject.js +0 -557
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ConfigFile } from './configFile';
|
|
2
|
-
import { ConfigContents } from './configStore';
|
|
3
|
-
/**
|
|
4
|
-
* Represent a key chain config backed by a json file.
|
|
5
|
-
*/
|
|
6
|
-
export declare class KeychainConfig extends ConfigFile<ConfigFile.Options> {
|
|
7
|
-
static getFileName(): string;
|
|
8
|
-
/**
|
|
9
|
-
* Gets default options for the KeychainConfig
|
|
10
|
-
*/
|
|
11
|
-
static getDefaultOptions(): ConfigFile.Options;
|
|
12
|
-
/**
|
|
13
|
-
* Write the config file with new contents. If no new contents are passed in
|
|
14
|
-
* it will write this.contents that was set from read(). Returns the written contents.
|
|
15
|
-
*
|
|
16
|
-
* @param newContents the new contents of the file
|
|
17
|
-
*/
|
|
18
|
-
write(newContents?: ConfigContents): Promise<ConfigContents>;
|
|
19
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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.KeychainConfig = void 0;
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
const fs_1 = require("../util/fs");
|
|
12
|
-
const configFile_1 = require("./configFile");
|
|
13
|
-
/**
|
|
14
|
-
* Represent a key chain config backed by a json file.
|
|
15
|
-
*/
|
|
16
|
-
// istanbul ignore next - getPassword/setPassword is always mocked out
|
|
17
|
-
class KeychainConfig extends configFile_1.ConfigFile {
|
|
18
|
-
static getFileName() {
|
|
19
|
-
return 'key.json';
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Gets default options for the KeychainConfig
|
|
23
|
-
*/
|
|
24
|
-
static getDefaultOptions() {
|
|
25
|
-
return configFile_1.ConfigFile.getDefaultOptions(true, KeychainConfig.getFileName());
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Write the config file with new contents. If no new contents are passed in
|
|
29
|
-
* it will write this.contents that was set from read(). Returns the written contents.
|
|
30
|
-
*
|
|
31
|
-
* @param newContents the new contents of the file
|
|
32
|
-
*/
|
|
33
|
-
async write(newContents) {
|
|
34
|
-
if (newContents != null) {
|
|
35
|
-
this.setContents(newContents);
|
|
36
|
-
}
|
|
37
|
-
await fs_1.fs.mkdirp((0, path_1.dirname)(this.getPath()));
|
|
38
|
-
await fs_1.fs.writeFile(this.getPath(), JSON.stringify(this.getContents(), null, 4), { mode: '600' });
|
|
39
|
-
return this.getContents();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.KeychainConfig = KeychainConfig;
|
|
43
|
-
//# sourceMappingURL=keychainConfig.js.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Nullable } from '@salesforce/ts-types';
|
|
2
|
-
import { GlobalInfo } from '../globalInfoConfig';
|
|
3
|
-
import { SfAliases, SfOrg, SfToken } from '../types';
|
|
4
|
-
export declare type Aliasable = string | Partial<SfOrg> | Partial<SfToken>;
|
|
5
|
-
export declare class AliasAccessor {
|
|
6
|
-
private globalInfo;
|
|
7
|
-
constructor(globalInfo: GlobalInfo);
|
|
8
|
-
/**
|
|
9
|
-
* Returns all the aliases for all the values
|
|
10
|
-
*/
|
|
11
|
-
getAll(): SfAliases;
|
|
12
|
-
/**
|
|
13
|
-
* Returns all the aliases for a given entity
|
|
14
|
-
*
|
|
15
|
-
* @param entity the aliasable entity that you want to get the aliases of
|
|
16
|
-
*/
|
|
17
|
-
getAll(entity: Aliasable): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Returns the first alias found for a given entity
|
|
20
|
-
*
|
|
21
|
-
* @param entity the aliasable entity that you want to get the alias of
|
|
22
|
-
*/
|
|
23
|
-
get(entity: Aliasable): Nullable<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the value that corresponds to the given alias if it exists
|
|
26
|
-
*
|
|
27
|
-
* @param alias the alias that corresponds to a value
|
|
28
|
-
*/
|
|
29
|
-
getValue(alias: string): Nullable<string>;
|
|
30
|
-
/**
|
|
31
|
-
* Returns the username that corresponds to the given alias if it exists
|
|
32
|
-
*
|
|
33
|
-
* @param alias the alias that corresponds to a username
|
|
34
|
-
*/
|
|
35
|
-
getUsername(alias: string): Nullable<string>;
|
|
36
|
-
/**
|
|
37
|
-
* If the provided string is an alias, it returns the corresponding value.
|
|
38
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
39
|
-
* is the value and return it.
|
|
40
|
-
*
|
|
41
|
-
* This method is helpful when you don't know if the string you have is a value
|
|
42
|
-
* or an alias.
|
|
43
|
-
*
|
|
44
|
-
* @param valueOrAlias a string that might be a value or might be an alias
|
|
45
|
-
*/
|
|
46
|
-
resolveValue(valueOrAlias: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* If the provided string is an alias, it returns the corresponding username.
|
|
49
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
50
|
-
* is the username and return it.
|
|
51
|
-
*
|
|
52
|
-
* This method is helpful when you don't know if the string you have is a username
|
|
53
|
-
* or an alias.
|
|
54
|
-
*
|
|
55
|
-
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
56
|
-
*/
|
|
57
|
-
resolveUsername(usernameOrAlias: string): string;
|
|
58
|
-
/**
|
|
59
|
-
* Set an alias for the given aliasable entity
|
|
60
|
-
*
|
|
61
|
-
* @param alias the alias you want to set
|
|
62
|
-
* @param entity the aliasable entity that's being aliased
|
|
63
|
-
*/
|
|
64
|
-
set(alias: string, entity: Aliasable): void;
|
|
65
|
-
/**
|
|
66
|
-
* Updates the alias for the given aliasable entity
|
|
67
|
-
*
|
|
68
|
-
* @param alias the alias you want to set
|
|
69
|
-
* @param entity the aliasable entity that's being aliased
|
|
70
|
-
*/
|
|
71
|
-
update(alias: string, entity: Aliasable): void;
|
|
72
|
-
unset(alias: string): void;
|
|
73
|
-
/**
|
|
74
|
-
* This method unsets all the aliases for the given entity.
|
|
75
|
-
*
|
|
76
|
-
* @param entity the aliasable entity for which you want to unset all aliases
|
|
77
|
-
*/
|
|
78
|
-
unsetAll(entity: Aliasable): void;
|
|
79
|
-
/**
|
|
80
|
-
* Returns the username of given aliasable entity
|
|
81
|
-
*/
|
|
82
|
-
private getNameOf;
|
|
83
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021, 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.AliasAccessor = void 0;
|
|
10
|
-
const sfdxError_1 = require("../../sfdxError");
|
|
11
|
-
const types_1 = require("../types");
|
|
12
|
-
class AliasAccessor {
|
|
13
|
-
constructor(globalInfo) {
|
|
14
|
-
this.globalInfo = globalInfo;
|
|
15
|
-
}
|
|
16
|
-
getAll(entity) {
|
|
17
|
-
const all = this.globalInfo.get(types_1.SfInfoKeys.ALIASES) || {};
|
|
18
|
-
if (entity) {
|
|
19
|
-
const value = this.getNameOf(entity);
|
|
20
|
-
return Object.entries(all)
|
|
21
|
-
.filter((entry) => entry[1] === value)
|
|
22
|
-
.map((entry) => entry[0]);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return all;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns the first alias found for a given entity
|
|
30
|
-
*
|
|
31
|
-
* @param entity the aliasable entity that you want to get the alias of
|
|
32
|
-
*/
|
|
33
|
-
get(entity) {
|
|
34
|
-
var _a;
|
|
35
|
-
return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns the value that corresponds to the given alias if it exists
|
|
39
|
-
*
|
|
40
|
-
* @param alias the alias that corresponds to a value
|
|
41
|
-
*/
|
|
42
|
-
getValue(alias) {
|
|
43
|
-
var _a;
|
|
44
|
-
return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Returns the username that corresponds to the given alias if it exists
|
|
48
|
-
*
|
|
49
|
-
* @param alias the alias that corresponds to a username
|
|
50
|
-
*/
|
|
51
|
-
getUsername(alias) {
|
|
52
|
-
var _a;
|
|
53
|
-
return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* If the provided string is an alias, it returns the corresponding value.
|
|
57
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
58
|
-
* is the value and return it.
|
|
59
|
-
*
|
|
60
|
-
* This method is helpful when you don't know if the string you have is a value
|
|
61
|
-
* or an alias.
|
|
62
|
-
*
|
|
63
|
-
* @param valueOrAlias a string that might be a value or might be an alias
|
|
64
|
-
*/
|
|
65
|
-
resolveValue(valueOrAlias) {
|
|
66
|
-
var _a;
|
|
67
|
-
return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* If the provided string is an alias, it returns the corresponding username.
|
|
71
|
-
* If the provided string is not an alias, we assume that the provided string
|
|
72
|
-
* is the username and return it.
|
|
73
|
-
*
|
|
74
|
-
* This method is helpful when you don't know if the string you have is a username
|
|
75
|
-
* or an alias.
|
|
76
|
-
*
|
|
77
|
-
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
78
|
-
*/
|
|
79
|
-
resolveUsername(usernameOrAlias) {
|
|
80
|
-
var _a;
|
|
81
|
-
return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : 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
|
-
var _a;
|
|
120
|
-
if (typeof entity === 'string')
|
|
121
|
-
return entity;
|
|
122
|
-
const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
|
|
123
|
-
if (!aliaseeName) {
|
|
124
|
-
throw new sfdxError_1.SfdxError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
|
|
125
|
-
}
|
|
126
|
-
return aliaseeName;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.AliasAccessor = AliasAccessor;
|
|
130
|
-
//# sourceMappingURL=aliasAccessor.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Optional } from '@salesforce/ts-types';
|
|
2
|
-
import { GlobalInfo } from '../globalInfoConfig';
|
|
3
|
-
import { SfOrgs, SfOrg } from '../types';
|
|
4
|
-
export declare class OrgAccessor {
|
|
5
|
-
private globalInfo;
|
|
6
|
-
constructor(globalInfo: GlobalInfo);
|
|
7
|
-
getAll(decrypt?: boolean): SfOrgs;
|
|
8
|
-
get(username: string, decrypt?: boolean): Optional<SfOrg>;
|
|
9
|
-
has(username: string): boolean;
|
|
10
|
-
set(username: string, org: SfOrg): void;
|
|
11
|
-
update(username: string, org: Partial<SfOrg>): void;
|
|
12
|
-
unset(username: string): void;
|
|
13
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021, 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.OrgAccessor = void 0;
|
|
10
|
-
const types_1 = require("../types");
|
|
11
|
-
class OrgAccessor {
|
|
12
|
-
constructor(globalInfo) {
|
|
13
|
-
this.globalInfo = globalInfo;
|
|
14
|
-
}
|
|
15
|
-
getAll(decrypt = false) {
|
|
16
|
-
return this.globalInfo.get(types_1.SfInfoKeys.ORGS, decrypt);
|
|
17
|
-
}
|
|
18
|
-
get(username, decrypt = false) {
|
|
19
|
-
const auth = this.globalInfo.get(`${types_1.SfInfoKeys.ORGS}["${username}"]`, decrypt);
|
|
20
|
-
// For legacy, some things wants the username in the returned auth info.
|
|
21
|
-
if (auth && !auth.username)
|
|
22
|
-
auth.username = username;
|
|
23
|
-
return auth;
|
|
24
|
-
}
|
|
25
|
-
has(username) {
|
|
26
|
-
return !!this.getAll()[username];
|
|
27
|
-
}
|
|
28
|
-
set(username, org) {
|
|
29
|
-
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
30
|
-
if (!org.username)
|
|
31
|
-
org.username = username;
|
|
32
|
-
this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
33
|
-
}
|
|
34
|
-
update(username, org) {
|
|
35
|
-
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
36
|
-
if (!org.username)
|
|
37
|
-
org.username = username;
|
|
38
|
-
this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
39
|
-
}
|
|
40
|
-
unset(username) {
|
|
41
|
-
delete this.globalInfo.get(types_1.SfInfoKeys.ORGS)[username];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.OrgAccessor = OrgAccessor;
|
|
45
|
-
//# sourceMappingURL=orgAccessor.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Optional } from '@salesforce/ts-types';
|
|
2
|
-
import { GlobalInfo } from '../globalInfoConfig';
|
|
3
|
-
import { SfTokens, SfToken, Timestamp } from '../types';
|
|
4
|
-
export declare class TokenAccessor {
|
|
5
|
-
private globalInfo;
|
|
6
|
-
constructor(globalInfo: GlobalInfo);
|
|
7
|
-
getAll(decrypt?: boolean): SfTokens;
|
|
8
|
-
get(name: string, decrypt?: boolean): Optional<SfToken & Timestamp>;
|
|
9
|
-
has(name: string): boolean;
|
|
10
|
-
set(name: string, token: SfToken): void;
|
|
11
|
-
update(name: string, token: Partial<SfToken>): void;
|
|
12
|
-
unset(name: string): void;
|
|
13
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021, 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.TokenAccessor = void 0;
|
|
10
|
-
const types_1 = require("../types");
|
|
11
|
-
class TokenAccessor {
|
|
12
|
-
constructor(globalInfo) {
|
|
13
|
-
this.globalInfo = globalInfo;
|
|
14
|
-
}
|
|
15
|
-
getAll(decrypt = false) {
|
|
16
|
-
return this.globalInfo.get(types_1.SfInfoKeys.TOKENS, decrypt) || {};
|
|
17
|
-
}
|
|
18
|
-
get(name, decrypt = false) {
|
|
19
|
-
return this.globalInfo.get(`${types_1.SfInfoKeys.TOKENS}["${name}"]`, decrypt);
|
|
20
|
-
}
|
|
21
|
-
has(name) {
|
|
22
|
-
return !!this.getAll()[name];
|
|
23
|
-
}
|
|
24
|
-
set(name, token) {
|
|
25
|
-
this.globalInfo.set(`${types_1.SfInfoKeys.TOKENS}["${name}"]`, token);
|
|
26
|
-
}
|
|
27
|
-
update(name, token) {
|
|
28
|
-
this.globalInfo.update(`${types_1.SfInfoKeys.TOKENS}["${name}"]`, token);
|
|
29
|
-
}
|
|
30
|
-
unset(name) {
|
|
31
|
-
delete this.globalInfo.get(types_1.SfInfoKeys.TOKENS)[name];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.TokenAccessor = TokenAccessor;
|
|
35
|
-
//# sourceMappingURL=tokenAccessor.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AnyJson } from '@salesforce/ts-types';
|
|
2
|
-
import { ConfigFile } from '../config/configFile';
|
|
3
|
-
import { ConfigValue } from '../config/configStore';
|
|
4
|
-
import { OrgAccessor } from './accessors/orgAccessor';
|
|
5
|
-
import { TokenAccessor } from './accessors/tokenAccessor';
|
|
6
|
-
import { AliasAccessor } from './accessors/aliasAccessor';
|
|
7
|
-
import { SfInfo } from './types';
|
|
8
|
-
export declare function deepCopy<T extends AnyJson>(data: T): T;
|
|
9
|
-
export declare class GlobalInfo extends ConfigFile<ConfigFile.Options, SfInfo> {
|
|
10
|
-
protected static encryptedKeys: RegExp[];
|
|
11
|
-
private static EMPTY_DATA_MODEL;
|
|
12
|
-
private static instance;
|
|
13
|
-
private sfdxHandler;
|
|
14
|
-
static get emptyDataModel(): SfInfo;
|
|
15
|
-
static getInstance(): Promise<GlobalInfo>;
|
|
16
|
-
/**
|
|
17
|
-
* Clear the cache to force reading from disk.
|
|
18
|
-
*
|
|
19
|
-
* *NOTE: Only call this method if you must and you know what you are doing.*
|
|
20
|
-
*/
|
|
21
|
-
static clearInstance(): void;
|
|
22
|
-
static getFileName(): string;
|
|
23
|
-
/**
|
|
24
|
-
* Gets default options for the SfConfig
|
|
25
|
-
*/
|
|
26
|
-
static getDefaultOptions(): ConfigFile.Options;
|
|
27
|
-
get orgs(): OrgAccessor;
|
|
28
|
-
get tokens(): TokenAccessor;
|
|
29
|
-
get aliases(): AliasAccessor;
|
|
30
|
-
set(key: string, value: ConfigValue): void;
|
|
31
|
-
write(newContents?: SfInfo): Promise<SfInfo>;
|
|
32
|
-
protected init(): Promise<void>;
|
|
33
|
-
private timestamp;
|
|
34
|
-
private loadSfData;
|
|
35
|
-
private mergeWithSfdxData;
|
|
36
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GlobalInfo = exports.deepCopy = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (c) 2020, 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 ts_types_1 = require("@salesforce/ts-types");
|
|
11
|
-
const global_1 = require("../global");
|
|
12
|
-
const configFile_1 = require("../config/configFile");
|
|
13
|
-
const sfdxDataHandler_1 = require("./sfdxDataHandler");
|
|
14
|
-
const orgAccessor_1 = require("./accessors/orgAccessor");
|
|
15
|
-
const tokenAccessor_1 = require("./accessors/tokenAccessor");
|
|
16
|
-
const aliasAccessor_1 = require("./accessors/aliasAccessor");
|
|
17
|
-
const types_1 = require("./types");
|
|
18
|
-
function deepCopy(data) {
|
|
19
|
-
return JSON.parse(JSON.stringify(data));
|
|
20
|
-
}
|
|
21
|
-
exports.deepCopy = deepCopy;
|
|
22
|
-
class GlobalInfo extends configFile_1.ConfigFile {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
this.sfdxHandler = new sfdxDataHandler_1.SfdxDataHandler();
|
|
26
|
-
}
|
|
27
|
-
static get emptyDataModel() {
|
|
28
|
-
return deepCopy(GlobalInfo.EMPTY_DATA_MODEL);
|
|
29
|
-
}
|
|
30
|
-
static async getInstance() {
|
|
31
|
-
if (!GlobalInfo.instance) {
|
|
32
|
-
GlobalInfo.instance = await GlobalInfo.create();
|
|
33
|
-
}
|
|
34
|
-
return GlobalInfo.instance;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Clear the cache to force reading from disk.
|
|
38
|
-
*
|
|
39
|
-
* *NOTE: Only call this method if you must and you know what you are doing.*
|
|
40
|
-
*/
|
|
41
|
-
static clearInstance() {
|
|
42
|
-
delete GlobalInfo.instance;
|
|
43
|
-
}
|
|
44
|
-
static getFileName() {
|
|
45
|
-
return 'sf.json';
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Gets default options for the SfConfig
|
|
49
|
-
*/
|
|
50
|
-
static getDefaultOptions() {
|
|
51
|
-
return {
|
|
52
|
-
isGlobal: true,
|
|
53
|
-
isState: true,
|
|
54
|
-
filename: GlobalInfo.getFileName(),
|
|
55
|
-
stateFolder: global_1.Global.SF_STATE_FOLDER,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
get orgs() {
|
|
59
|
-
return new orgAccessor_1.OrgAccessor(this);
|
|
60
|
-
}
|
|
61
|
-
get tokens() {
|
|
62
|
-
return new tokenAccessor_1.TokenAccessor(this);
|
|
63
|
-
}
|
|
64
|
-
get aliases() {
|
|
65
|
-
return new aliasAccessor_1.AliasAccessor(this);
|
|
66
|
-
}
|
|
67
|
-
set(key, value) {
|
|
68
|
-
if ((0, ts_types_1.isPlainObject)(value)) {
|
|
69
|
-
value = this.timestamp(value);
|
|
70
|
-
}
|
|
71
|
-
super.set(key, value);
|
|
72
|
-
}
|
|
73
|
-
async write(newContents) {
|
|
74
|
-
const result = await super.write(newContents);
|
|
75
|
-
if (global_1.Global.SFDX_INTEROPERABILITY)
|
|
76
|
-
await this.sfdxHandler.write(result);
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
async init() {
|
|
80
|
-
await this.initCrypto();
|
|
81
|
-
const contents = global_1.Global.SFDX_INTEROPERABILITY ? await this.mergeWithSfdxData() : await this.loadSfData();
|
|
82
|
-
this.setContents(contents);
|
|
83
|
-
}
|
|
84
|
-
timestamp(data) {
|
|
85
|
-
return { ...data, timestamp: new Date() };
|
|
86
|
-
}
|
|
87
|
-
async loadSfData() {
|
|
88
|
-
const data = await this.read();
|
|
89
|
-
return { ...GlobalInfo.emptyDataModel, ...data };
|
|
90
|
-
}
|
|
91
|
-
async mergeWithSfdxData() {
|
|
92
|
-
const sfData = await this.loadSfData();
|
|
93
|
-
const merged = await this.sfdxHandler.merge(sfData);
|
|
94
|
-
await this.write(merged);
|
|
95
|
-
return merged;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.GlobalInfo = GlobalInfo;
|
|
99
|
-
GlobalInfo.encryptedKeys = [/token/gi, /password/gi, /secret/gi];
|
|
100
|
-
GlobalInfo.EMPTY_DATA_MODEL = {
|
|
101
|
-
[types_1.SfInfoKeys.ORGS]: {},
|
|
102
|
-
[types_1.SfInfoKeys.TOKENS]: {},
|
|
103
|
-
[types_1.SfInfoKeys.ALIASES]: {},
|
|
104
|
-
};
|
|
105
|
-
//# sourceMappingURL=globalInfoConfig.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './globalInfoConfig';
|
|
2
|
-
export * from './sfdxDataHandler';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export { OrgAccessor } from './accessors/orgAccessor';
|
|
5
|
-
export { AliasAccessor } from './accessors/aliasAccessor';
|
|
6
|
-
export { TokenAccessor } from './accessors/tokenAccessor';
|
package/lib/globalInfo/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021, 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
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.TokenAccessor = exports.AliasAccessor = exports.OrgAccessor = void 0;
|
|
20
|
-
__exportStar(require("./globalInfoConfig"), exports);
|
|
21
|
-
__exportStar(require("./sfdxDataHandler"), exports);
|
|
22
|
-
__exportStar(require("./types"), exports);
|
|
23
|
-
var orgAccessor_1 = require("./accessors/orgAccessor");
|
|
24
|
-
Object.defineProperty(exports, "OrgAccessor", { enumerable: true, get: function () { return orgAccessor_1.OrgAccessor; } });
|
|
25
|
-
var aliasAccessor_1 = require("./accessors/aliasAccessor");
|
|
26
|
-
Object.defineProperty(exports, "AliasAccessor", { enumerable: true, get: function () { return aliasAccessor_1.AliasAccessor; } });
|
|
27
|
-
var tokenAccessor_1 = require("./accessors/tokenAccessor");
|
|
28
|
-
Object.defineProperty(exports, "TokenAccessor", { enumerable: true, get: function () { return tokenAccessor_1.TokenAccessor; } });
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ConfigFile } from '../config/configFile';
|
|
2
|
-
import { SfOrgs, SfOrg, SfInfo, SfInfoKeys } from './types';
|
|
3
|
-
interface Handler<T extends SfInfoKeys> {
|
|
4
|
-
sfKey: T;
|
|
5
|
-
merge: (sfData: SfInfo) => Promise<Partial<SfInfo>>;
|
|
6
|
-
migrate: () => Promise<Pick<SfInfo, T>>;
|
|
7
|
-
write: (latest: SfInfo, original: SfInfo) => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
interface Changes<T> {
|
|
10
|
-
changed: T;
|
|
11
|
-
deleted: string[];
|
|
12
|
-
}
|
|
13
|
-
export declare class SfdxDataHandler {
|
|
14
|
-
handlers: (AuthHandler | AliasesHandler)[];
|
|
15
|
-
private original;
|
|
16
|
-
write(latest?: SfInfo): Promise<void>;
|
|
17
|
-
merge(sfData?: SfInfo): Promise<SfInfo>;
|
|
18
|
-
private setOriginal;
|
|
19
|
-
}
|
|
20
|
-
declare abstract class BaseHandler<T extends SfInfoKeys> implements Handler<T> {
|
|
21
|
-
abstract sfKey: T;
|
|
22
|
-
merge(sfData?: SfInfo): Promise<Partial<SfInfo>>;
|
|
23
|
-
abstract migrate(): Promise<Pick<SfInfo, T>>;
|
|
24
|
-
abstract write(latest: SfInfo, original: SfInfo): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
export declare class AuthHandler extends BaseHandler<SfInfoKeys.ORGS> {
|
|
27
|
-
private static authFilenameFilterRegEx;
|
|
28
|
-
sfKey: typeof SfInfoKeys.ORGS;
|
|
29
|
-
migrate(): Promise<Pick<SfInfo, SfInfoKeys.ORGS>>;
|
|
30
|
-
write(latest: SfInfo, original: SfInfo): Promise<void>;
|
|
31
|
-
findChanges(latest: SfInfo, original: SfInfo): Promise<Changes<SfOrgs>>;
|
|
32
|
-
createAuthFileConfig(username: string): Promise<ConfigFile<ConfigFile.Options>>;
|
|
33
|
-
listAllAuthFiles(): Promise<string[]>;
|
|
34
|
-
listAllAuthorizations(): Promise<SfOrg[]>;
|
|
35
|
-
}
|
|
36
|
-
export declare class AliasesHandler extends BaseHandler<SfInfoKeys.ALIASES> {
|
|
37
|
-
private static SFDX_ALIASES_FILENAME;
|
|
38
|
-
sfKey: typeof SfInfoKeys.ALIASES;
|
|
39
|
-
migrate(): Promise<Pick<SfInfo, SfInfoKeys.ALIASES>>;
|
|
40
|
-
merge(sfData?: SfInfo): Promise<Partial<SfInfo>>;
|
|
41
|
-
write(latest: SfInfo): Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
export {};
|