@salesforce/core 3.19.1 → 3.19.4
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 +14 -0
- package/README.md +6 -18
- package/lib/config/aliasesConfig.d.ts +12 -0
- package/lib/config/aliasesConfig.js +27 -0
- package/lib/config/authInfoConfig.d.ts +19 -0
- package/lib/config/authInfoConfig.js +35 -0
- package/lib/config/configAggregator.d.ts +5 -3
- package/lib/config/configAggregator.js +13 -1
- package/lib/config/configFile.js +2 -2
- package/lib/config/configGroup.d.ts +141 -0
- package/lib/config/configGroup.js +224 -0
- package/lib/config/configStore.d.ts +2 -2
- package/lib/config/configStore.js +1 -2
- package/lib/config/tokensConfig.d.ts +10 -0
- package/lib/config/tokensConfig.js +28 -0
- package/lib/crypto/keyChainImpl.js +1 -1
- package/lib/exported.d.ts +1 -1
- package/lib/exported.js +6 -5
- package/lib/global.d.ts +8 -0
- package/lib/global.js +10 -0
- package/lib/org/authInfo.d.ts +3 -2
- package/lib/org/authInfo.js +55 -37
- package/lib/org/authRemover.d.ts +6 -5
- package/lib/org/authRemover.js +22 -16
- package/lib/org/connection.js +1 -1
- package/lib/org/org.d.ts +12 -4
- package/lib/org/org.js +28 -26
- package/lib/org/scratchOrgCreate.js +5 -8
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.d.ts +79 -1
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.js +119 -2
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +53 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +201 -0
- package/lib/{globalInfo → stateAggregator}/accessors/sandboxAccessor.d.ts +12 -1
- package/lib/{globalInfo → stateAggregator}/accessors/sandboxAccessor.js +22 -2
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +28 -0
- package/lib/{globalInfo → stateAggregator}/accessors/tokenAccessor.js +34 -2
- package/lib/{globalInfo → stateAggregator}/globalInfoConfig.d.ts +11 -8
- package/lib/{globalInfo → stateAggregator}/globalInfoConfig.js +7 -4
- package/lib/stateAggregator/index.d.ts +7 -0
- package/lib/{globalInfo → stateAggregator}/index.js +5 -1
- package/lib/{globalInfo → stateAggregator}/sfdxDataHandler.d.ts +7 -1
- package/lib/{globalInfo → stateAggregator}/sfdxDataHandler.js +25 -2
- package/lib/stateAggregator/stateAggregator.d.ts +20 -0
- package/lib/stateAggregator/stateAggregator.js +38 -0
- package/lib/{globalInfo → stateAggregator}/types.d.ts +25 -10
- package/lib/{globalInfo → stateAggregator}/types.js +3 -0
- package/lib/testSetup.d.ts +30 -6
- package/lib/testSetup.js +79 -11
- package/lib/util/sfdcUrl.d.ts +3 -9
- package/lib/util/sfdcUrl.js +29 -28
- package/messages/core.md +10 -0
- package/messages/scratchOrgCreate.md +0 -4
- package/messages/scratchOrgInfoApi.md +4 -0
- package/package.json +4 -4
- 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/index.d.ts +0 -6
|
@@ -0,0 +1,201 @@
|
|
|
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 = exports.BaseOrgAccessor = exports.GlobalInfoOrgAccessor = void 0;
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const kit_1 = require("@salesforce/kit");
|
|
13
|
+
const authInfoConfig_1 = require("../../config/authInfoConfig");
|
|
14
|
+
const global_1 = require("../../global");
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
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
|
+
var _a;
|
|
39
|
+
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
40
|
+
(_a = org.username) !== null && _a !== void 0 ? _a : (org.username = username);
|
|
41
|
+
this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
42
|
+
}
|
|
43
|
+
update(username, org) {
|
|
44
|
+
var _a;
|
|
45
|
+
// For legacy, and to keep things standard, some things wants the username in auth info.
|
|
46
|
+
(_a = org.username) !== null && _a !== void 0 ? _a : (org.username = username);
|
|
47
|
+
this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
|
|
48
|
+
}
|
|
49
|
+
unset(username) {
|
|
50
|
+
delete this.globalInfo.get(types_1.SfInfoKeys.ORGS)[username];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.GlobalInfoOrgAccessor = GlobalInfoOrgAccessor;
|
|
54
|
+
function chunk(array, chunkSize) {
|
|
55
|
+
const final = [];
|
|
56
|
+
for (let i = 0, len = array.length; i < len; i += chunkSize)
|
|
57
|
+
final.push(array.slice(i, i + chunkSize));
|
|
58
|
+
return final;
|
|
59
|
+
}
|
|
60
|
+
class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(...arguments);
|
|
63
|
+
this.configs = new Map();
|
|
64
|
+
this.contents = new Map();
|
|
65
|
+
}
|
|
66
|
+
async read(username, decrypt = false, throwOnNotFound = true) {
|
|
67
|
+
try {
|
|
68
|
+
const config = await this.initAuthFile(username, throwOnNotFound);
|
|
69
|
+
this.configs.set(username, config);
|
|
70
|
+
return this.get(username, decrypt);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async readAll(decrypt = false) {
|
|
77
|
+
const fileChunks = chunk(await this.getAllFiles(), 50);
|
|
78
|
+
for (const fileChunk of fileChunks) {
|
|
79
|
+
const promises = fileChunk.map(async (f) => {
|
|
80
|
+
const username = this.parseUsername(f);
|
|
81
|
+
const config = await this.initAuthFile(username);
|
|
82
|
+
this.configs.set(username, config);
|
|
83
|
+
});
|
|
84
|
+
await Promise.all(promises);
|
|
85
|
+
}
|
|
86
|
+
return this.getAll(decrypt);
|
|
87
|
+
}
|
|
88
|
+
get(username, decrypt = false) {
|
|
89
|
+
const config = this.configs.get(username);
|
|
90
|
+
if (config) {
|
|
91
|
+
this.contents.set(username, config.getContents(decrypt));
|
|
92
|
+
}
|
|
93
|
+
return this.contents.get(username);
|
|
94
|
+
}
|
|
95
|
+
getAll(decrypt = false) {
|
|
96
|
+
return [...this.configs.keys()].reduce((orgs, username) => {
|
|
97
|
+
const org = this.get(username, decrypt);
|
|
98
|
+
return org && !(0, kit_1.isEmpty)(org) ? orgs.concat([org]) : orgs;
|
|
99
|
+
}, []);
|
|
100
|
+
}
|
|
101
|
+
has(username) {
|
|
102
|
+
return this.contents.has(username);
|
|
103
|
+
}
|
|
104
|
+
async exists(username) {
|
|
105
|
+
const config = this.configs.get(username);
|
|
106
|
+
return config ? await config.exists() : false;
|
|
107
|
+
}
|
|
108
|
+
async stat(username) {
|
|
109
|
+
const config = this.configs.get(username);
|
|
110
|
+
return config ? await config.stat() : null;
|
|
111
|
+
}
|
|
112
|
+
async hasFile(username) {
|
|
113
|
+
try {
|
|
114
|
+
await fs.promises.access(this.parseFilename(username));
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
this.logger.debug(`No auth file found for ${username}`);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async list() {
|
|
123
|
+
return this.getAllFiles();
|
|
124
|
+
}
|
|
125
|
+
set(username, org) {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
const config = this.configs.get(username);
|
|
128
|
+
if (config) {
|
|
129
|
+
config.setContentsFromObject(org);
|
|
130
|
+
const contents = config.getContents();
|
|
131
|
+
(_a = contents.username) !== null && _a !== void 0 ? _a : (contents.username = username);
|
|
132
|
+
this.contents.set(username, contents);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
(_b = org.username) !== null && _b !== void 0 ? _b : (org.username = username);
|
|
137
|
+
this.contents.set(username, org);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
update(username, org) {
|
|
141
|
+
const existing = this.get(username) || {};
|
|
142
|
+
const merged = Object.assign({}, existing, org);
|
|
143
|
+
return this.set(username, merged);
|
|
144
|
+
}
|
|
145
|
+
async remove(username) {
|
|
146
|
+
var _a;
|
|
147
|
+
await ((_a = this.configs.get(username)) === null || _a === void 0 ? void 0 : _a.unlink());
|
|
148
|
+
this.configs.delete(username);
|
|
149
|
+
this.contents.delete(username);
|
|
150
|
+
}
|
|
151
|
+
async write(username) {
|
|
152
|
+
const config = this.configs.get(username);
|
|
153
|
+
if (config) {
|
|
154
|
+
return (await config.write());
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const contents = this.contents.get(username) || {};
|
|
158
|
+
await this.read(username, false, false);
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
160
|
+
const config = this.configs.get(username);
|
|
161
|
+
config.setContentsFromObject(contents);
|
|
162
|
+
return (await config.write());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async init() {
|
|
166
|
+
this.logger = await logger_1.Logger.child(this.constructor.name);
|
|
167
|
+
}
|
|
168
|
+
async getAllFiles() {
|
|
169
|
+
const regex = this.getFileRegex();
|
|
170
|
+
try {
|
|
171
|
+
return (await fs.promises.readdir(global_1.Global.DIR)).filter((file) => regex.test(file));
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
parseUsername(filename) {
|
|
178
|
+
return filename.replace(this.getFileExtension(), '');
|
|
179
|
+
}
|
|
180
|
+
parseFilename(username) {
|
|
181
|
+
return path.join(global_1.Global.DIR, `${username}${this.getFileExtension()}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.BaseOrgAccessor = BaseOrgAccessor;
|
|
185
|
+
class OrgAccessor extends BaseOrgAccessor {
|
|
186
|
+
async initAuthFile(username, throwOnNotFound = false) {
|
|
187
|
+
return authInfoConfig_1.AuthInfoConfig.create({
|
|
188
|
+
...authInfoConfig_1.AuthInfoConfig.getOptions(username),
|
|
189
|
+
throwOnNotFound,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
getFileRegex() {
|
|
193
|
+
// The regular expression that filters files stored in $HOME/.sfdx
|
|
194
|
+
return /^[^.][^@]*@[^.]+(\.[^.\s]+)+\.json$/;
|
|
195
|
+
}
|
|
196
|
+
getFileExtension() {
|
|
197
|
+
return '.json';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.OrgAccessor = OrgAccessor;
|
|
201
|
+
//# sourceMappingURL=orgAccessor.js.map
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Nullable } from '@salesforce/ts-types';
|
|
2
|
+
import { SandboxOrgConfig } from '../../config/sandboxOrgConfig';
|
|
3
|
+
import { SandboxFields } from '../../org';
|
|
2
4
|
import { GlobalInfo } from '../globalInfoConfig';
|
|
3
5
|
import { SfSandbox, SfSandboxes } from '../types';
|
|
4
|
-
|
|
6
|
+
import { BaseOrgAccessor } from './orgAccessor';
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
export declare class GlobalInfoSandboxAccessor {
|
|
5
11
|
private globalInfo;
|
|
6
12
|
constructor(globalInfo: GlobalInfo);
|
|
7
13
|
/**
|
|
@@ -34,3 +40,8 @@ export declare class SandboxAccessor {
|
|
|
34
40
|
set(sandboxOrgId: string, entity: SfSandbox): void;
|
|
35
41
|
unset(sandboxOrgId: string): void;
|
|
36
42
|
}
|
|
43
|
+
export declare class SandboxAccessor extends BaseOrgAccessor<SandboxOrgConfig, SandboxFields> {
|
|
44
|
+
protected initAuthFile(username: string, throwOnNotFound?: boolean): Promise<SandboxOrgConfig>;
|
|
45
|
+
protected getFileRegex(): RegExp;
|
|
46
|
+
protected getFileExtension(): string;
|
|
47
|
+
}
|
|
@@ -6,9 +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.SandboxAccessor = void 0;
|
|
9
|
+
exports.SandboxAccessor = exports.GlobalInfoSandboxAccessor = void 0;
|
|
10
|
+
const sandboxOrgConfig_1 = require("../../config/sandboxOrgConfig");
|
|
10
11
|
const types_1 = require("../types");
|
|
11
|
-
|
|
12
|
+
const orgAccessor_1 = require("./orgAccessor");
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
16
|
+
class GlobalInfoSandboxAccessor {
|
|
12
17
|
constructor(globalInfo) {
|
|
13
18
|
this.globalInfo = globalInfo;
|
|
14
19
|
}
|
|
@@ -59,5 +64,20 @@ class SandboxAccessor {
|
|
|
59
64
|
delete this.globalInfo.get(types_1.SfInfoKeys.SANDBOXES)[sandboxOrgId];
|
|
60
65
|
}
|
|
61
66
|
}
|
|
67
|
+
exports.GlobalInfoSandboxAccessor = GlobalInfoSandboxAccessor;
|
|
68
|
+
class SandboxAccessor extends orgAccessor_1.BaseOrgAccessor {
|
|
69
|
+
async initAuthFile(username, throwOnNotFound = false) {
|
|
70
|
+
return sandboxOrgConfig_1.SandboxOrgConfig.create({
|
|
71
|
+
...sandboxOrgConfig_1.SandboxOrgConfig.getOptions(username),
|
|
72
|
+
throwOnNotFound,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
getFileRegex() {
|
|
76
|
+
return /^(00D.*?)\.sandbox\.json$/;
|
|
77
|
+
}
|
|
78
|
+
getFileExtension() {
|
|
79
|
+
return '.sandbox.json';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
62
82
|
exports.SandboxAccessor = SandboxAccessor;
|
|
63
83
|
//# sourceMappingURL=sandboxAccessor.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
2
|
+
import { Optional } from '@salesforce/ts-types';
|
|
3
|
+
import { GlobalInfo } from '../globalInfoConfig';
|
|
4
|
+
import { SfTokens, SfToken, Timestamp } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
*/
|
|
8
|
+
export declare class GlobaInfoTokenAccessor {
|
|
9
|
+
private globalInfo;
|
|
10
|
+
constructor(globalInfo: GlobalInfo);
|
|
11
|
+
getAll(decrypt?: boolean): SfTokens;
|
|
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
|
+
}
|
|
18
|
+
export declare class TokenAccessor extends AsyncOptionalCreatable {
|
|
19
|
+
private config;
|
|
20
|
+
getAll(decrypt?: boolean): SfTokens;
|
|
21
|
+
get(name: string, decrypt?: boolean): Optional<SfToken & Timestamp>;
|
|
22
|
+
has(name: string): boolean;
|
|
23
|
+
set(name: string, token: SfToken): void;
|
|
24
|
+
update(name: string, token: Partial<SfToken>): void;
|
|
25
|
+
unset(name: string): void;
|
|
26
|
+
write(): Promise<SfTokens>;
|
|
27
|
+
protected init(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -6,9 +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.TokenAccessor = void 0;
|
|
9
|
+
exports.TokenAccessor = exports.GlobaInfoTokenAccessor = void 0;
|
|
10
|
+
const kit_1 = require("@salesforce/kit");
|
|
11
|
+
const tokensConfig_1 = require("../../config/tokensConfig");
|
|
10
12
|
const types_1 = require("../types");
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
16
|
+
class GlobaInfoTokenAccessor {
|
|
12
17
|
constructor(globalInfo) {
|
|
13
18
|
this.globalInfo = globalInfo;
|
|
14
19
|
}
|
|
@@ -31,5 +36,32 @@ class TokenAccessor {
|
|
|
31
36
|
delete this.globalInfo.get(types_1.SfInfoKeys.TOKENS)[name];
|
|
32
37
|
}
|
|
33
38
|
}
|
|
39
|
+
exports.GlobaInfoTokenAccessor = GlobaInfoTokenAccessor;
|
|
40
|
+
class TokenAccessor extends kit_1.AsyncOptionalCreatable {
|
|
41
|
+
getAll(decrypt = false) {
|
|
42
|
+
return this.config.getContents(decrypt) || {};
|
|
43
|
+
}
|
|
44
|
+
get(name, decrypt = false) {
|
|
45
|
+
return this.config.get(name, decrypt);
|
|
46
|
+
}
|
|
47
|
+
has(name) {
|
|
48
|
+
return !!this.getAll()[name];
|
|
49
|
+
}
|
|
50
|
+
set(name, token) {
|
|
51
|
+
this.config.set(name, token);
|
|
52
|
+
}
|
|
53
|
+
update(name, token) {
|
|
54
|
+
this.config.update(name, token);
|
|
55
|
+
}
|
|
56
|
+
unset(name) {
|
|
57
|
+
this.config.unset(name);
|
|
58
|
+
}
|
|
59
|
+
async write() {
|
|
60
|
+
return this.config.write();
|
|
61
|
+
}
|
|
62
|
+
async init() {
|
|
63
|
+
this.config = await tokensConfig_1.TokensConfig.create();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
34
66
|
exports.TokenAccessor = TokenAccessor;
|
|
35
67
|
//# sourceMappingURL=tokenAccessor.js.map
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { AnyJson } from '@salesforce/ts-types';
|
|
2
2
|
import { ConfigFile } from '../config/configFile';
|
|
3
3
|
import { ConfigValue } from '../config/configStore';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { GlobalInfoOrgAccessor } from './accessors/orgAccessor';
|
|
5
|
+
import { GlobaInfoTokenAccessor } from './accessors/tokenAccessor';
|
|
6
|
+
import { GlobalInfoAliasAccessor } from './accessors/aliasAccessor';
|
|
7
7
|
import { SfInfo } from './types';
|
|
8
|
-
import {
|
|
8
|
+
import { GlobalInfoSandboxAccessor } from './accessors/sandboxAccessor';
|
|
9
9
|
export declare function deepCopy<T extends AnyJson>(data: T): T;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use StateAggregator instead.
|
|
12
|
+
*/
|
|
10
13
|
export declare class GlobalInfo extends ConfigFile<ConfigFile.Options, SfInfo> {
|
|
11
14
|
protected static encryptedKeys: RegExp[];
|
|
12
15
|
private static EMPTY_DATA_MODEL;
|
|
@@ -25,10 +28,10 @@ export declare class GlobalInfo extends ConfigFile<ConfigFile.Options, SfInfo> {
|
|
|
25
28
|
* Gets default options for the SfConfig
|
|
26
29
|
*/
|
|
27
30
|
static getDefaultOptions(): ConfigFile.Options;
|
|
28
|
-
get orgs():
|
|
29
|
-
get tokens():
|
|
30
|
-
get aliases():
|
|
31
|
-
get sandboxes():
|
|
31
|
+
get orgs(): GlobalInfoOrgAccessor;
|
|
32
|
+
get tokens(): GlobaInfoTokenAccessor;
|
|
33
|
+
get aliases(): GlobalInfoAliasAccessor;
|
|
34
|
+
get sandboxes(): GlobalInfoSandboxAccessor;
|
|
32
35
|
set(key: string, value: ConfigValue): void;
|
|
33
36
|
write(newContents?: SfInfo): Promise<SfInfo>;
|
|
34
37
|
protected init(): Promise<void>;
|
|
@@ -20,6 +20,9 @@ function deepCopy(data) {
|
|
|
20
20
|
return JSON.parse(JSON.stringify(data));
|
|
21
21
|
}
|
|
22
22
|
exports.deepCopy = deepCopy;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated use StateAggregator instead.
|
|
25
|
+
*/
|
|
23
26
|
class GlobalInfo extends configFile_1.ConfigFile {
|
|
24
27
|
constructor() {
|
|
25
28
|
super(...arguments);
|
|
@@ -57,16 +60,16 @@ class GlobalInfo extends configFile_1.ConfigFile {
|
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
62
|
get orgs() {
|
|
60
|
-
return new orgAccessor_1.
|
|
63
|
+
return new orgAccessor_1.GlobalInfoOrgAccessor(this);
|
|
61
64
|
}
|
|
62
65
|
get tokens() {
|
|
63
|
-
return new tokenAccessor_1.
|
|
66
|
+
return new tokenAccessor_1.GlobaInfoTokenAccessor(this);
|
|
64
67
|
}
|
|
65
68
|
get aliases() {
|
|
66
|
-
return new aliasAccessor_1.
|
|
69
|
+
return new aliasAccessor_1.GlobalInfoAliasAccessor(this);
|
|
67
70
|
}
|
|
68
71
|
get sandboxes() {
|
|
69
|
-
return new sandboxAccessor_1.
|
|
72
|
+
return new sandboxAccessor_1.GlobalInfoSandboxAccessor(this);
|
|
70
73
|
}
|
|
71
74
|
set(key, value) {
|
|
72
75
|
if ((0, ts_types_1.isPlainObject)(value)) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './globalInfoConfig';
|
|
2
|
+
export * from './sfdxDataHandler';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export { GlobalInfoOrgAccessor, OrgAccessor } from './accessors/orgAccessor';
|
|
5
|
+
export { GlobalInfoAliasAccessor, AliasAccessor } from './accessors/aliasAccessor';
|
|
6
|
+
export { GlobaInfoTokenAccessor, TokenAccessor } from './accessors/tokenAccessor';
|
|
7
|
+
export * from './stateAggregator';
|
|
@@ -16,14 +16,18 @@ 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.TokenAccessor = exports.AliasAccessor = exports.OrgAccessor = void 0;
|
|
19
|
+
exports.TokenAccessor = exports.GlobaInfoTokenAccessor = exports.AliasAccessor = exports.GlobalInfoAliasAccessor = exports.OrgAccessor = exports.GlobalInfoOrgAccessor = void 0;
|
|
20
20
|
__exportStar(require("./globalInfoConfig"), exports);
|
|
21
21
|
__exportStar(require("./sfdxDataHandler"), exports);
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
23
|
var orgAccessor_1 = require("./accessors/orgAccessor");
|
|
24
|
+
Object.defineProperty(exports, "GlobalInfoOrgAccessor", { enumerable: true, get: function () { return orgAccessor_1.GlobalInfoOrgAccessor; } });
|
|
24
25
|
Object.defineProperty(exports, "OrgAccessor", { enumerable: true, get: function () { return orgAccessor_1.OrgAccessor; } });
|
|
25
26
|
var aliasAccessor_1 = require("./accessors/aliasAccessor");
|
|
27
|
+
Object.defineProperty(exports, "GlobalInfoAliasAccessor", { enumerable: true, get: function () { return aliasAccessor_1.GlobalInfoAliasAccessor; } });
|
|
26
28
|
Object.defineProperty(exports, "AliasAccessor", { enumerable: true, get: function () { return aliasAccessor_1.AliasAccessor; } });
|
|
27
29
|
var tokenAccessor_1 = require("./accessors/tokenAccessor");
|
|
30
|
+
Object.defineProperty(exports, "GlobaInfoTokenAccessor", { enumerable: true, get: function () { return tokenAccessor_1.GlobaInfoTokenAccessor; } });
|
|
28
31
|
Object.defineProperty(exports, "TokenAccessor", { enumerable: true, get: function () { return tokenAccessor_1.TokenAccessor; } });
|
|
32
|
+
__exportStar(require("./stateAggregator"), exports);
|
|
29
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -11,7 +11,7 @@ interface Changes<T> {
|
|
|
11
11
|
deleted: string[];
|
|
12
12
|
}
|
|
13
13
|
export declare class SfdxDataHandler {
|
|
14
|
-
handlers: (AuthHandler | AliasesHandler | SandboxesHandler)[];
|
|
14
|
+
handlers: (AuthHandler | AliasesHandler | SandboxesHandler | TokensHandler)[];
|
|
15
15
|
private original;
|
|
16
16
|
write(latest?: SfInfo): Promise<void>;
|
|
17
17
|
merge(sfData?: SfInfo): Promise<SfInfo>;
|
|
@@ -50,4 +50,10 @@ export declare class SandboxesHandler extends BaseHandler<SfInfoKeys.SANDBOXES>
|
|
|
50
50
|
listAllSandboxes(): Promise<SfSandbox[]>;
|
|
51
51
|
private findChanges;
|
|
52
52
|
}
|
|
53
|
+
export declare class TokensHandler extends BaseHandler<SfInfoKeys.TOKENS> {
|
|
54
|
+
private static SFDX_TOKENS_FILENAME;
|
|
55
|
+
sfKey: typeof SfInfoKeys.TOKENS;
|
|
56
|
+
migrate(): Promise<Pick<SfInfo, SfInfoKeys.TOKENS>>;
|
|
57
|
+
write(latest: SfInfo): Promise<void>;
|
|
58
|
+
}
|
|
53
59
|
export {};
|
|
@@ -6,7 +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.SandboxesHandler = exports.AliasesHandler = exports.AuthHandler = exports.SfdxDataHandler = void 0;
|
|
9
|
+
exports.TokensHandler = exports.SandboxesHandler = exports.AliasesHandler = exports.AuthHandler = exports.SfdxDataHandler = void 0;
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
@@ -29,7 +29,7 @@ function isEqual(object1, object2) {
|
|
|
29
29
|
}
|
|
30
30
|
class SfdxDataHandler {
|
|
31
31
|
constructor() {
|
|
32
|
-
this.handlers = [new AuthHandler(), new AliasesHandler(), new SandboxesHandler()];
|
|
32
|
+
this.handlers = [new AuthHandler(), new AliasesHandler(), new SandboxesHandler(), new TokensHandler()];
|
|
33
33
|
}
|
|
34
34
|
async write(latest = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
|
|
35
35
|
await Promise.all(this.handlers.map((handler) => handler.write(latest, this.original)));
|
|
@@ -306,4 +306,27 @@ class SandboxesHandler extends BaseHandler {
|
|
|
306
306
|
exports.SandboxesHandler = SandboxesHandler;
|
|
307
307
|
// The regular expression that filters files stored in $HOME/.sfdx
|
|
308
308
|
SandboxesHandler.sandboxFilenameFilterRegEx = /^(00D.*?)\.sandbox\.json$/;
|
|
309
|
+
class TokensHandler extends BaseHandler {
|
|
310
|
+
constructor() {
|
|
311
|
+
super(...arguments);
|
|
312
|
+
this.sfKey = types_1.SfInfoKeys.TOKENS;
|
|
313
|
+
}
|
|
314
|
+
async migrate() {
|
|
315
|
+
const filePath = (0, path_1.join)(global_1.Global.SFDX_DIR, TokensHandler.SFDX_TOKENS_FILENAME);
|
|
316
|
+
try {
|
|
317
|
+
const x = await fs.promises.readFile(filePath, 'utf8');
|
|
318
|
+
const tokens = (0, kit_1.parseJson)(x);
|
|
319
|
+
return { [this.sfKey]: tokens };
|
|
320
|
+
}
|
|
321
|
+
catch (e) {
|
|
322
|
+
return { [this.sfKey]: {} };
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async write(latest) {
|
|
326
|
+
const filePath = (0, path_1.join)(global_1.Global.SFDX_DIR, TokensHandler.SFDX_TOKENS_FILENAME);
|
|
327
|
+
await fs.promises.writeFile(filePath, JSON.stringify(latest[types_1.SfInfoKeys.TOKENS], null, 2));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
exports.TokensHandler = TokensHandler;
|
|
331
|
+
TokensHandler.SFDX_TOKENS_FILENAME = 'tokens.json';
|
|
309
332
|
//# sourceMappingURL=sfdxDataHandler.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
2
|
+
import { AliasAccessor } from './accessors/aliasAccessor';
|
|
3
|
+
import { OrgAccessor } from './accessors/orgAccessor';
|
|
4
|
+
import { SandboxAccessor } from './accessors/sandboxAccessor';
|
|
5
|
+
import { TokenAccessor } from './accessors/tokenAccessor';
|
|
6
|
+
export declare class StateAggregator extends AsyncOptionalCreatable {
|
|
7
|
+
private static instance;
|
|
8
|
+
aliases: AliasAccessor;
|
|
9
|
+
orgs: OrgAccessor;
|
|
10
|
+
sandboxes: SandboxAccessor;
|
|
11
|
+
tokens: TokenAccessor;
|
|
12
|
+
static getInstance(): Promise<StateAggregator>;
|
|
13
|
+
/**
|
|
14
|
+
* Clear the cache to force reading from disk.
|
|
15
|
+
*
|
|
16
|
+
* *NOTE: Only call this method if you must and you know what you are doing.*
|
|
17
|
+
*/
|
|
18
|
+
static clearInstance(): void;
|
|
19
|
+
protected init(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, 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.StateAggregator = void 0;
|
|
10
|
+
const kit_1 = require("@salesforce/kit");
|
|
11
|
+
const aliasAccessor_1 = require("./accessors/aliasAccessor");
|
|
12
|
+
const orgAccessor_1 = require("./accessors/orgAccessor");
|
|
13
|
+
const sandboxAccessor_1 = require("./accessors/sandboxAccessor");
|
|
14
|
+
const tokenAccessor_1 = require("./accessors/tokenAccessor");
|
|
15
|
+
class StateAggregator extends kit_1.AsyncOptionalCreatable {
|
|
16
|
+
static async getInstance() {
|
|
17
|
+
if (!StateAggregator.instance) {
|
|
18
|
+
StateAggregator.instance = await StateAggregator.create();
|
|
19
|
+
}
|
|
20
|
+
return StateAggregator.instance;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Clear the cache to force reading from disk.
|
|
24
|
+
*
|
|
25
|
+
* *NOTE: Only call this method if you must and you know what you are doing.*
|
|
26
|
+
*/
|
|
27
|
+
static clearInstance() {
|
|
28
|
+
delete StateAggregator.instance;
|
|
29
|
+
}
|
|
30
|
+
async init() {
|
|
31
|
+
this.orgs = await orgAccessor_1.OrgAccessor.create();
|
|
32
|
+
this.sandboxes = await sandboxAccessor_1.SandboxAccessor.create();
|
|
33
|
+
this.aliases = await aliasAccessor_1.AliasAccessor.create();
|
|
34
|
+
this.tokens = await tokenAccessor_1.TokenAccessor.create();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.StateAggregator = StateAggregator;
|
|
38
|
+
//# sourceMappingURL=stateAggregator.js.map
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { JsonMap } from '@salesforce/ts-types';
|
|
2
|
+
import { AuthFields } from '../org';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated
|
|
5
|
+
*/
|
|
2
6
|
export declare enum SfInfoKeys {
|
|
3
7
|
ORGS = "orgs",
|
|
4
8
|
TOKENS = "tokens",
|
|
@@ -9,12 +13,13 @@ export declare type Timestamp = {
|
|
|
9
13
|
timestamp: string;
|
|
10
14
|
};
|
|
11
15
|
export declare type SfEntry = JsonMap;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
export declare type SfOrg = AuthFields & SfEntry;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
18
23
|
export interface SfOrgs {
|
|
19
24
|
[key: string]: SfOrg & Timestamp;
|
|
20
25
|
}
|
|
@@ -23,16 +28,21 @@ export declare type SfToken = {
|
|
|
23
28
|
url: string;
|
|
24
29
|
user?: string;
|
|
25
30
|
} & SfEntry;
|
|
26
|
-
|
|
31
|
+
/**
|
|
32
|
+
*/
|
|
33
|
+
export declare type SfTokens = {
|
|
27
34
|
[key: string]: SfToken & Timestamp;
|
|
28
|
-
}
|
|
35
|
+
};
|
|
29
36
|
/**
|
|
30
37
|
* The key will always be the alias and the value will always be the username, e.g.
|
|
31
38
|
* { "MyAlias": "user@salesforce.com" }
|
|
32
39
|
*/
|
|
33
|
-
export
|
|
40
|
+
export declare type SfAliases = {
|
|
34
41
|
[alias: string]: string;
|
|
35
|
-
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated
|
|
45
|
+
*/
|
|
36
46
|
export declare type SfSandbox = {
|
|
37
47
|
sandboxOrgId: string;
|
|
38
48
|
prodOrgUsername: string;
|
|
@@ -45,10 +55,15 @@ export declare type SfSandbox = {
|
|
|
45
55
|
* The key will always be the sandbox username and the value will always be the
|
|
46
56
|
* production org username
|
|
47
57
|
* { "user@salesforce.com.mysandbox": "user@salesforce.com" }
|
|
58
|
+
*
|
|
59
|
+
* @deprecated
|
|
48
60
|
*/
|
|
49
61
|
export interface SfSandboxes {
|
|
50
62
|
[sandboxOrgId: string]: SfSandbox;
|
|
51
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated
|
|
66
|
+
*/
|
|
52
67
|
export declare type SfInfo = {
|
|
53
68
|
[SfInfoKeys.ORGS]: SfOrgs;
|
|
54
69
|
[SfInfoKeys.TOKENS]: SfTokens;
|