@salesforce/core 3.23.6 → 3.23.9

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/config/authInfoConfig.js +1 -1
  3. package/lib/config/config.js +5 -7
  4. package/lib/config/configAggregator.js +5 -7
  5. package/lib/config/configStore.js +1 -2
  6. package/lib/config/envVars.js +1 -2
  7. package/lib/deviceOauthService.d.ts +2 -2
  8. package/lib/deviceOauthService.js +6 -7
  9. package/lib/org/authInfo.d.ts +4 -12
  10. package/lib/org/authInfo.js +18 -44
  11. package/lib/org/connection.d.ts +3 -8
  12. package/lib/org/connection.js +10 -58
  13. package/lib/org/org.js +18 -28
  14. package/lib/org/permissionSetAssignment.js +1 -2
  15. package/lib/org/scratchOrgCreate.js +13 -11
  16. package/lib/org/scratchOrgInfoApi.js +3 -4
  17. package/lib/org/scratchOrgInfoGenerator.js +9 -12
  18. package/lib/org/scratchOrgSettingsGenerator.d.ts +17 -7
  19. package/lib/org/scratchOrgSettingsGenerator.js +44 -25
  20. package/lib/org/user.js +2 -3
  21. package/lib/sfProject.js +1 -2
  22. package/lib/stateAggregator/accessors/aliasAccessor.js +13 -26
  23. package/lib/stateAggregator/accessors/orgAccessor.js +5 -9
  24. package/lib/stateAggregator/accessors/sandboxAccessor.js +2 -4
  25. package/lib/stateAggregator/sfdxDataHandler.js +6 -10
  26. package/lib/status/pollingClient.js +1 -2
  27. package/lib/testSetup.js +9 -12
  28. package/lib/util/checkLightningDomain.js +2 -3
  29. package/lib/util/directoryWriter.d.ts +11 -0
  30. package/lib/util/directoryWriter.js +52 -0
  31. package/lib/util/structuredWriter.d.ts +8 -0
  32. package/lib/util/structuredWriter.js +3 -0
  33. package/lib/util/zipWriter.d.ts +6 -5
  34. package/lib/util/zipWriter.js +8 -4
  35. package/lib/webOAuthServer.d.ts +3 -2
  36. package/lib/webOAuthServer.js +6 -6
  37. package/package.json +4 -2
@@ -36,8 +36,7 @@ class GlobalInfoAliasAccessor {
36
36
  * @param entity the aliasable entity that you want to get the alias of
37
37
  */
38
38
  get(entity) {
39
- var _a;
40
- return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
39
+ return this.getAll(entity).find((alias) => alias) ?? null;
41
40
  }
42
41
  /**
43
42
  * Returns the value that corresponds to the given alias if it exists
@@ -45,8 +44,7 @@ class GlobalInfoAliasAccessor {
45
44
  * @param alias the alias that corresponds to a value
46
45
  */
47
46
  getValue(alias) {
48
- var _a;
49
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
47
+ return this.getAll()[alias] ?? null;
50
48
  }
51
49
  /**
52
50
  * Returns the username that corresponds to the given alias if it exists
@@ -54,8 +52,7 @@ class GlobalInfoAliasAccessor {
54
52
  * @param alias the alias that corresponds to a username
55
53
  */
56
54
  getUsername(alias) {
57
- var _a;
58
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
55
+ return this.getAll()[alias] ?? null;
59
56
  }
60
57
  /**
61
58
  * If the provided string is an alias, it returns the corresponding value.
@@ -68,8 +65,7 @@ class GlobalInfoAliasAccessor {
68
65
  * @param valueOrAlias a string that might be a value or might be an alias
69
66
  */
70
67
  resolveValue(valueOrAlias) {
71
- var _a;
72
- return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
68
+ return this.getValue(valueOrAlias) ?? valueOrAlias;
73
69
  }
74
70
  /**
75
71
  * If the provided string is an alias, it returns the corresponding username.
@@ -82,8 +78,7 @@ class GlobalInfoAliasAccessor {
82
78
  * @param usernameOrAlias a string that might be a username or might be an alias
83
79
  */
84
80
  resolveUsername(usernameOrAlias) {
85
- var _a;
86
- return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
81
+ return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
87
82
  }
88
83
  /**
89
84
  * Set an alias for the given aliasable entity
@@ -121,10 +116,9 @@ class GlobalInfoAliasAccessor {
121
116
  * Returns the username of given aliasable entity
122
117
  */
123
118
  getNameOf(entity) {
124
- var _a;
125
119
  if (typeof entity === 'string')
126
120
  return entity;
127
- const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
121
+ const aliaseeName = entity.username ?? entity.user;
128
122
  if (!aliaseeName) {
129
123
  throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
130
124
  }
@@ -153,8 +147,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
153
147
  * @param entity the aliasable entity that you want to get the alias of
154
148
  */
155
149
  get(entity) {
156
- var _a;
157
- return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
150
+ return this.getAll(entity).find((alias) => alias) ?? null;
158
151
  }
159
152
  /**
160
153
  * Returns the value that corresponds to the given alias if it exists
@@ -162,8 +155,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
162
155
  * @param alias the alias that corresponds to a value
163
156
  */
164
157
  getValue(alias) {
165
- var _a;
166
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
158
+ return this.getAll()[alias] ?? null;
167
159
  }
168
160
  /**
169
161
  * Returns the username that corresponds to the given alias if it exists
@@ -171,8 +163,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
171
163
  * @param alias the alias that corresponds to a username
172
164
  */
173
165
  getUsername(alias) {
174
- var _a;
175
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
166
+ return this.getAll()[alias] ?? null;
176
167
  }
177
168
  /**
178
169
  * If the provided string is an alias, it returns the corresponding value.
@@ -185,8 +176,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
185
176
  * @param valueOrAlias a string that might be a value or might be an alias
186
177
  */
187
178
  resolveValue(valueOrAlias) {
188
- var _a;
189
- return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
179
+ return this.getValue(valueOrAlias) ?? valueOrAlias;
190
180
  }
191
181
  /**
192
182
  * If the provided string is an alias, it returns the corresponding username.
@@ -199,8 +189,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
199
189
  * @param usernameOrAlias a string that might be a username or might be an alias
200
190
  */
201
191
  resolveUsername(usernameOrAlias) {
202
- var _a;
203
- return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
192
+ return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
204
193
  }
205
194
  /**
206
195
  * If the provided string is an alias, return it.
@@ -212,10 +201,9 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
212
201
  * @param usernameOrAlias a string that might be a username or might be an alias
213
202
  */
214
203
  resolveAlias(usernameOrAlias) {
215
- var _a;
216
204
  if (this.has(usernameOrAlias))
217
205
  return usernameOrAlias;
218
- return (_a = Object.entries(this.getAll()).find(([, username]) => username === usernameOrAlias)) === null || _a === void 0 ? void 0 : _a[0];
206
+ return Object.entries(this.getAll()).find(([, username]) => username === usernameOrAlias)?.[0];
219
207
  }
220
208
  /**
221
209
  * Set an alias for the given aliasable entity
@@ -260,10 +248,9 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
260
248
  * Returns the username of given aliasable entity
261
249
  */
262
250
  getNameOf(entity) {
263
- var _a;
264
251
  if (typeof entity === 'string')
265
252
  return entity;
266
- const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
253
+ const aliaseeName = entity.username ?? entity.user;
267
254
  if (!aliaseeName) {
268
255
  throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
269
256
  }
@@ -35,15 +35,13 @@ class GlobalInfoOrgAccessor {
35
35
  return !!this.getAll()[username];
36
36
  }
37
37
  set(username, org) {
38
- var _a;
39
38
  // 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);
39
+ org.username ?? (org.username = username);
41
40
  this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
42
41
  }
43
42
  update(username, org) {
44
- var _a;
45
43
  // 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);
44
+ org.username ?? (org.username = username);
47
45
  this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
48
46
  }
49
47
  unset(username) {
@@ -176,17 +174,16 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
176
174
  * @param org
177
175
  */
178
176
  set(username, org) {
179
- var _a, _b;
180
177
  const config = this.configs.get(username);
181
178
  if (config) {
182
179
  config.setContentsFromObject(org);
183
180
  const contents = config.getContents();
184
- (_a = contents.username) !== null && _a !== void 0 ? _a : (contents.username = username);
181
+ contents.username ?? (contents.username = username);
185
182
  this.contents.set(username, contents);
186
183
  }
187
184
  else {
188
185
  // @ts-ignore
189
- (_b = org.username) !== null && _b !== void 0 ? _b : (org.username = username);
186
+ org.username ?? (org.username = username);
190
187
  this.contents.set(username, org);
191
188
  }
192
189
  }
@@ -207,8 +204,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
207
204
  * @param username
208
205
  */
209
206
  async remove(username) {
210
- var _a;
211
- await ((_a = this.configs.get(username)) === null || _a === void 0 ? void 0 : _a.unlink());
207
+ await this.configs.get(username)?.unlink();
212
208
  this.configs.delete(username);
213
209
  this.contents.delete(username);
214
210
  }
@@ -39,8 +39,7 @@ class GlobalInfoSandboxAccessor {
39
39
  * @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
40
40
  */
41
41
  get(sandboxOrgId) {
42
- var _a;
43
- return sandboxOrgId ? (_a = this.getAll()[sandboxOrgId]) !== null && _a !== void 0 ? _a : null : null;
42
+ return sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null;
44
43
  }
45
44
  /**
46
45
  * Returns true if the given sandbox org id exists
@@ -48,8 +47,7 @@ class GlobalInfoSandboxAccessor {
48
47
  * @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
49
48
  */
50
49
  has(sandboxOrgId) {
51
- var _a;
52
- return !!(sandboxOrgId ? (_a = this.getAll()[sandboxOrgId]) !== null && _a !== void 0 ? _a : null : null);
50
+ return !!(sandboxOrgId ? this.getAll()[sandboxOrgId] ?? null : null);
53
51
  }
54
52
  /**
55
53
  * Set an sandboxOrgId for the given sandbox entity
@@ -50,13 +50,12 @@ class SfdxDataHandler {
50
50
  exports.SfdxDataHandler = SfdxDataHandler;
51
51
  class BaseHandler {
52
52
  async merge(sfData = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
53
- var _a, _b;
54
53
  const sfdxData = await this.migrate();
55
54
  const merged = (0, globalInfoConfig_1.deepCopy)(sfData);
56
55
  // Only merge the key this handler is responsible for.
57
56
  const key = this.sfKey;
58
- const sfKeys = Object.keys((_a = sfData[key]) !== null && _a !== void 0 ? _a : {});
59
- const sfdxKeys = Object.keys((_b = sfdxData[key]) !== null && _b !== void 0 ? _b : {});
57
+ const sfKeys = Object.keys(sfData[key] ?? {});
58
+ const sfdxKeys = Object.keys(sfdxData[key] ?? {});
60
59
  const commonKeys = sfKeys.filter((k) => sfdxKeys.includes(k));
61
60
  for (const k of commonKeys) {
62
61
  const [newer, older] = [sfData[key][k], sfdxData[key][k]].sort((a, b) => {
@@ -115,12 +114,11 @@ class AuthHandler extends BaseHandler {
115
114
  }));
116
115
  }
117
116
  async findChanges(latest, original) {
118
- var _a;
119
117
  const latestAuths = latest.orgs;
120
118
  const originalAuths = original.orgs;
121
119
  const changed = {};
122
120
  for (const [username, auth] of Object.entries(latestAuths)) {
123
- const originalAuth = (_a = originalAuths[username]) !== null && _a !== void 0 ? _a : {};
121
+ const originalAuth = originalAuths[username] ?? {};
124
122
  if (!isEqual(auth, originalAuth)) {
125
123
  changed[username] = auth;
126
124
  }
@@ -218,13 +216,12 @@ class SandboxesHandler extends BaseHandler {
218
216
  this.sfKey = types_1.SfInfoKeys.SANDBOXES;
219
217
  }
220
218
  async merge(sfData = globalInfoConfig_1.GlobalInfo.emptyDataModel) {
221
- var _a, _b;
222
219
  const sfdxData = await this.migrate();
223
220
  const merged = (0, globalInfoConfig_1.deepCopy)(sfData);
224
221
  // Only merge the key this handler is responsible for.
225
222
  const key = this.sfKey;
226
- const sfKeys = Object.keys((_a = sfData[key]) !== null && _a !== void 0 ? _a : {});
227
- const sfdxKeys = Object.keys((_b = sfdxData[key]) !== null && _b !== void 0 ? _b : {});
223
+ const sfKeys = Object.keys(sfData[key] ?? {});
224
+ const sfdxKeys = Object.keys(sfdxData[key] ?? {});
228
225
  // sandbox entries for .sf and .sfdx contain static data. Given there
229
226
  // can be no mutation during the life of the sandbox, having to merge common keys
230
227
  // is unnecessary.
@@ -289,12 +286,11 @@ class SandboxesHandler extends BaseHandler {
289
286
  }));
290
287
  }
291
288
  async findChanges(latest, original) {
292
- var _a;
293
289
  const latestSandboxes = latest.sandboxes;
294
290
  const originalSandboxes = original.sandboxes;
295
291
  const changed = {};
296
292
  for (const [sandboxOrgId, sandbox] of Object.entries(latestSandboxes)) {
297
- const originalSandbox = (_a = originalSandboxes[sandboxOrgId]) !== null && _a !== void 0 ? _a : {};
293
+ const originalSandbox = originalSandboxes[sandboxOrgId] ?? {};
298
294
  if (!isEqual(sandbox, originalSandbox)) {
299
295
  changed[sandboxOrgId] = sandbox;
300
296
  }
@@ -53,7 +53,6 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
53
53
  * in the polling options.
54
54
  */
55
55
  async subscribe() {
56
- var _a;
57
56
  let errorInPollingFunction; // keep this around for returning in the catch block
58
57
  const doPoll = async () => {
59
58
  let result;
@@ -89,7 +88,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
89
88
  }
90
89
  await lifecycleEvents_1.Lifecycle.getInstance().emit('POLLING_TIME_OUT', error);
91
90
  this.logger.debug('Polling timed out');
92
- throw new sfError_1.SfError('The client has timed out.', (_a = this.options.timeoutErrorName) !== null && _a !== void 0 ? _a : 'PollingClientTimeout');
91
+ throw new sfError_1.SfError('The client has timed out.', this.options.timeoutErrorName ?? 'PollingClientTimeout');
93
92
  }
94
93
  }
95
94
  }
package/lib/testSetup.js CHANGED
@@ -41,11 +41,10 @@ const global_1 = require("./global");
41
41
  * - length: the length of the unique id as presented in hexadecimal.
42
42
  */
43
43
  function uniqid(options) {
44
- var _a, _b;
45
- const uniqueString = (0, crypto_1.randomBytes)(Math.ceil(((_a = options === null || options === void 0 ? void 0 : options.length) !== null && _a !== void 0 ? _a : 32) / 2.0))
44
+ const uniqueString = (0, crypto_1.randomBytes)(Math.ceil((options?.length ?? 32) / 2.0))
46
45
  .toString('hex')
47
- .slice(0, (_b = options === null || options === void 0 ? void 0 : options.length) !== null && _b !== void 0 ? _b : 32);
48
- if (!(options === null || options === void 0 ? void 0 : options.template)) {
46
+ .slice(0, options?.length ?? 32);
47
+ if (!options?.template) {
49
48
  return uniqueString;
50
49
  }
51
50
  return options.template.includes('%s')
@@ -168,9 +167,8 @@ const instantiateContext = (sinon) => {
168
167
  return orgMap.has(username);
169
168
  });
170
169
  const retrieveContents = async function () {
171
- var _a;
172
170
  const username = (0, path_1.basename)(this.path.replace('.json', ''));
173
- return Promise.resolve((_a = orgMap.get(username)) !== null && _a !== void 0 ? _a : {});
171
+ return Promise.resolve(orgMap.get(username) ?? {});
174
172
  };
175
173
  this.configStubs.AuthInfoConfig = { retrieveContents };
176
174
  },
@@ -179,9 +177,8 @@ const instantiateContext = (sinon) => {
179
177
  const sandboxMap = new Map(entries);
180
178
  (0, ts_sinon_1.stubMethod)(testContext.SANDBOX, sandboxAccessor_1.SandboxAccessor.prototype, 'getAllFiles').returns([...sandboxMap.keys()].map((o) => `${o}.sandbox.json`));
181
179
  const retrieveContents = async function () {
182
- var _a;
183
180
  const username = (0, path_1.basename)(this.path.replace('.sandbox.json', ''));
184
- return Promise.resolve((_a = sandboxMap.get(username)) !== null && _a !== void 0 ? _a : {});
181
+ return Promise.resolve(sandboxMap.get(username) ?? {});
185
182
  };
186
183
  this.configStubs.SandboxOrgConfig = { retrieveContents };
187
184
  },
@@ -595,7 +592,7 @@ class MockTestOrgData {
595
592
  this.testId = id;
596
593
  this.userId = `user_id_${this.testId}`;
597
594
  this.orgId = `${this.testId}`;
598
- this.username = (options === null || options === void 0 ? void 0 : options.username) || `admin_${this.testId}@gb.org`;
595
+ this.username = options?.username || `admin_${this.testId}@gb.org`;
599
596
  this.loginUrl = `https://login.${this.testId}.salesforce.com`;
600
597
  this.instanceUrl = `https://instance.${this.testId}.salesforce.com`;
601
598
  this.clientId = `${this.testId}/client_id`;
@@ -702,9 +699,9 @@ class MockTestSandboxData {
702
699
  constructor(id = uniqid(), options) {
703
700
  this.id = id;
704
701
  this.sandboxOrgId = id;
705
- this.prodOrgUsername = (options === null || options === void 0 ? void 0 : options.prodOrgUsername) || `admin_${id}@gb.org`;
706
- this.sandboxName = (options === null || options === void 0 ? void 0 : options.name) || `sandbox_${id}`;
707
- this.username = (options === null || options === void 0 ? void 0 : options.username) || `${this.prodOrgUsername}.sandbox`;
702
+ this.prodOrgUsername = options?.prodOrgUsername || `admin_${id}@gb.org`;
703
+ this.sandboxName = options?.name || `sandbox_${id}`;
704
+ this.username = options?.username || `${this.prodOrgUsername}.sandbox`;
708
705
  }
709
706
  /**
710
707
  * Return the auth config file contents.
@@ -11,9 +11,8 @@ const kit_1 = require("@salesforce/kit");
11
11
  const myDomainResolver_1 = require("../status/myDomainResolver");
12
12
  const sfdc_1 = require("./sfdc");
13
13
  async function checkLightningDomain(url) {
14
- var _a, _b;
15
- const domain = `https://${(_a = /https?:\/\/([^.]*)/.exec(url)) === null || _a === void 0 ? void 0 : _a.slice(1, 2).pop()}.lightning.force.com`;
16
- const quantity = (_b = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240)) !== null && _b !== void 0 ? _b : 0;
14
+ const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.slice(1, 2).pop()}.lightning.force.com`;
15
+ const quantity = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240) ?? 0;
17
16
  const timeout = new kit_1.Duration(quantity, kit_1.Duration.Unit.SECONDS);
18
17
  if (sfdc_1.sfdc.isInternalUrl(url) || timeout.seconds === 0) {
19
18
  return true;
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ import { StructuredWriter } from './structuredWriter';
4
+ export declare class DirectoryWriter implements StructuredWriter {
5
+ private readonly rootDestination?;
6
+ constructor(rootDestination?: string | undefined);
7
+ addToStore(contents: string | Readable | Buffer, targetPath: string): Promise<void>;
8
+ finalize(): Promise<void>;
9
+ getDestinationPath(): string | undefined;
10
+ get buffer(): Buffer;
11
+ }
@@ -0,0 +1,52 @@
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.DirectoryWriter = void 0;
10
+ const stream_1 = require("stream");
11
+ const fs = require("fs");
12
+ const os = require("os");
13
+ const path = require("path");
14
+ const util_1 = require("util");
15
+ const pipeline = (0, util_1.promisify)(stream_1.pipeline);
16
+ class DirectoryWriter {
17
+ constructor(rootDestination) {
18
+ this.rootDestination = rootDestination;
19
+ if (!this.rootDestination) {
20
+ this.rootDestination = fs.mkdtempSync(`${os.tmpdir()}${path.sep}`);
21
+ }
22
+ else {
23
+ fs.mkdirSync(this.rootDestination, { recursive: true });
24
+ }
25
+ }
26
+ async addToStore(contents, targetPath) {
27
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
28
+ const destPath = path.join(this.rootDestination, targetPath);
29
+ fs.mkdirSync(path.dirname(destPath), { recursive: true });
30
+ if (contents instanceof stream_1.Readable) {
31
+ const writeStream = fs.createWriteStream(destPath);
32
+ await pipeline(contents, writeStream);
33
+ }
34
+ else if (typeof contents === 'string') {
35
+ fs.writeFileSync(destPath, contents);
36
+ }
37
+ else if (contents instanceof Buffer) {
38
+ fs.writeFileSync(destPath, contents);
39
+ }
40
+ }
41
+ finalize() {
42
+ return Promise.resolve(undefined);
43
+ }
44
+ getDestinationPath() {
45
+ return this.rootDestination;
46
+ }
47
+ get buffer() {
48
+ throw new Error('Not implemented');
49
+ }
50
+ }
51
+ exports.DirectoryWriter = DirectoryWriter;
52
+ //# sourceMappingURL=directoryWriter.js.map
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ export interface StructuredWriter {
4
+ addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
5
+ finalize(): Promise<void>;
6
+ getDestinationPath(): string | undefined;
7
+ get buffer(): Buffer;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=structuredWriter.js.map
@@ -1,13 +1,14 @@
1
1
  /// <reference types="node" />
2
- import { pipeline as cbPipeline, Readable, Writable } from 'stream';
3
- export declare const pipeline: typeof cbPipeline.__promisify__;
4
- export declare class ZipWriter extends Writable {
5
- private rootDestination?;
2
+ import { Readable, Writable } from 'stream';
3
+ import { StructuredWriter } from './structuredWriter';
4
+ export declare class ZipWriter extends Writable implements StructuredWriter {
5
+ private readonly rootDestination?;
6
6
  private zip;
7
7
  private buffers;
8
8
  constructor(rootDestination?: string | undefined);
9
- addToZip(contents: string | Readable | Buffer, path: string): void;
9
+ addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
10
10
  finalize(): Promise<void>;
11
+ getDestinationPath(): string | undefined;
11
12
  private getOutputStream;
12
13
  private getInputBuffer;
13
14
  get buffer(): Buffer;
@@ -6,12 +6,12 @@
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.ZipWriter = exports.pipeline = void 0;
9
+ exports.ZipWriter = void 0;
10
10
  const fs_1 = require("fs");
11
11
  const stream_1 = require("stream");
12
12
  const util_1 = require("util");
13
13
  const archiver_1 = require("archiver");
14
- exports.pipeline = (0, util_1.promisify)(stream_1.pipeline);
14
+ const pipeline = (0, util_1.promisify)(stream_1.pipeline);
15
15
  class ZipWriter extends stream_1.Writable {
16
16
  constructor(rootDestination) {
17
17
  super({ objectMode: true });
@@ -21,15 +21,19 @@ class ZipWriter extends stream_1.Writable {
21
21
  // higher values = diminishing returns on compression and made conversion slower
22
22
  this.zip = (0, archiver_1.create)('zip', { zlib: { level: 3 } });
23
23
  this.buffers = [];
24
- void (0, exports.pipeline)(this.zip, this.getOutputStream());
24
+ void pipeline(this.zip, this.getOutputStream());
25
25
  }
26
- addToZip(contents, path) {
26
+ async addToStore(contents, path) {
27
27
  this.zip.append(contents, { name: path });
28
+ return Promise.resolve();
28
29
  }
29
30
  async finalize() {
30
31
  await this.zip.finalize();
31
32
  await this.getInputBuffer();
32
33
  }
34
+ getDestinationPath() {
35
+ return this.rootDestination;
36
+ }
33
37
  getOutputStream() {
34
38
  if (this.rootDestination) {
35
39
  return (0, fs_1.createWriteStream)(this.rootDestination);
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import * as http from 'http';
3
+ import { JwtOAuth2Config } from 'jsforce';
3
4
  import { AsyncCreatable } from '@salesforce/kit';
4
- import { AuthInfo, OAuth2Config } from './org/authInfo';
5
+ import { AuthInfo } from './org';
5
6
  /**
6
7
  * Handles the creation of a web server for web based login flows.
7
8
  *
@@ -79,7 +80,7 @@ export declare class WebOAuthServer extends AsyncCreatable<WebOAuthServer.Option
79
80
  }
80
81
  export declare namespace WebOAuthServer {
81
82
  interface Options {
82
- oauthConfig: OAuth2Config;
83
+ oauthConfig: JwtOAuth2Config;
83
84
  }
84
85
  type Request = http.IncomingMessage & {
85
86
  query: {
@@ -11,11 +11,11 @@ const http = require("http");
11
11
  const querystring_1 = require("querystring");
12
12
  const url_1 = require("url");
13
13
  const net_1 = require("net");
14
+ const jsforce_1 = require("jsforce");
14
15
  const kit_1 = require("@salesforce/kit");
15
16
  const ts_types_1 = require("@salesforce/ts-types");
16
- const jsforce_1 = require("jsforce");
17
17
  const logger_1 = require("./logger");
18
- const authInfo_1 = require("./org/authInfo");
18
+ const org_1 = require("./org");
19
19
  const sfError_1 = require("./sfError");
20
20
  const messages_1 = require("./messages");
21
21
  const sfProject_1 = require("./sfProject");
@@ -85,7 +85,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
85
85
  this.executeOauthRequest()
86
86
  .then(async (response) => {
87
87
  try {
88
- const authInfo = await authInfo_1.AuthInfo.create({
88
+ const authInfo = await org_1.AuthInfo.create({
89
89
  oauth2Options: this.oauthConfig,
90
90
  oauth2: this.oauth2,
91
91
  });
@@ -127,14 +127,14 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
127
127
  this.logger = await logger_1.Logger.child(this.constructor.name);
128
128
  const port = await WebOAuthServer.determineOauthPort();
129
129
  if (!this.oauthConfig.clientId)
130
- this.oauthConfig.clientId = authInfo_1.DEFAULT_CONNECTED_APP_INFO.clientId;
130
+ this.oauthConfig.clientId = org_1.DEFAULT_CONNECTED_APP_INFO.clientId;
131
131
  if (!this.oauthConfig.loginUrl)
132
- this.oauthConfig.loginUrl = authInfo_1.AuthInfo.getDefaultInstanceUrl();
132
+ this.oauthConfig.loginUrl = org_1.AuthInfo.getDefaultInstanceUrl();
133
133
  if (!this.oauthConfig.redirectUri)
134
134
  this.oauthConfig.redirectUri = `http://localhost:${port}/OauthRedirect`;
135
135
  this.webServer = await WebServer.create({ port });
136
136
  this.oauth2 = new jsforce_1.OAuth2(this.oauthConfig);
137
- this.authUrl = authInfo_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
137
+ this.authUrl = org_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
138
138
  }
139
139
  /**
140
140
  * Executes the oauth request
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.23.6",
3
+ "version": "3.23.9",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -49,7 +49,7 @@
49
49
  "form-data": "^4.0.0",
50
50
  "graceful-fs": "^4.2.9",
51
51
  "js2xmlparser": "^4.0.1",
52
- "jsforce": "2.0.0-beta.14",
52
+ "jsforce": "beta",
53
53
  "jsonwebtoken": "8.5.1",
54
54
  "mkdirp": "1.0.4",
55
55
  "ts-retry-promise": "^0.6.0"
@@ -60,6 +60,7 @@
60
60
  "@salesforce/prettier-config": "^0.0.2",
61
61
  "@salesforce/ts-sinon": "^1.3.21",
62
62
  "@types/archiver": "^5.3.1",
63
+ "@types/chai-string": "^1.4.2",
63
64
  "@types/debug": "0.0.31",
64
65
  "@types/jsen": "0.0.21",
65
66
  "@types/jsonwebtoken": "8.5.7",
@@ -68,6 +69,7 @@
68
69
  "@typescript-eslint/eslint-plugin": "^4.33.0",
69
70
  "@typescript-eslint/parser": "4.33.0",
70
71
  "chai": "^4.3.4",
72
+ "chai-string": "^1.5.0",
71
73
  "commitizen": "^3.1.2",
72
74
  "eslint": "^7.27.0",
73
75
  "eslint-config-prettier": "^6.15.0",