@salesforce/core 6.7.6 → 6.7.7-qa.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.
Files changed (57) hide show
  1. package/lib/config/authInfoConfig.js +1 -1
  2. package/lib/config/config.js +6 -5
  3. package/lib/config/configAggregator.js +7 -2
  4. package/lib/config/configFile.js +6 -2
  5. package/lib/config/configStore.js +17 -14
  6. package/lib/config/lwwMap.js +12 -19
  7. package/lib/config/lwwRegister.js +1 -0
  8. package/lib/crypto/crypto.js +3 -1
  9. package/lib/crypto/keyChainImpl.js +2 -0
  10. package/lib/crypto/secureBuffer.js +3 -4
  11. package/lib/deviceOauthService.d.ts +1 -1
  12. package/lib/deviceOauthService.js +8 -6
  13. package/lib/global.js +22 -22
  14. package/lib/index.d.ts +1 -1
  15. package/lib/lifecycleEvents.js +5 -2
  16. package/lib/logger/logger.js +31 -29
  17. package/lib/logger/memoryLogger.js +1 -1
  18. package/lib/messages.js +41 -30
  19. package/lib/org/authInfo.d.ts +1 -1
  20. package/lib/org/authInfo.js +65 -67
  21. package/lib/org/authRemover.js +7 -2
  22. package/lib/org/connection.d.ts +4 -4
  23. package/lib/org/connection.js +33 -22
  24. package/lib/org/org.js +30 -23
  25. package/lib/org/permissionSetAssignment.js +2 -0
  26. package/lib/org/scratchOrgFeatureDeprecation.js +1 -0
  27. package/lib/org/scratchOrgInfoApi.d.ts +1 -1
  28. package/lib/org/scratchOrgInfoApi.js +4 -5
  29. package/lib/org/scratchOrgInfoGenerator.d.ts +2 -2
  30. package/lib/org/scratchOrgInfoGenerator.js +13 -15
  31. package/lib/org/scratchOrgSettingsGenerator.d.ts +4 -4
  32. package/lib/org/scratchOrgSettingsGenerator.js +9 -2
  33. package/lib/org/user.js +24 -16
  34. package/lib/schema/validator.js +4 -0
  35. package/lib/sfError.d.ts +20 -6
  36. package/lib/sfError.js +48 -37
  37. package/lib/sfProject.d.ts +3 -0
  38. package/lib/sfProject.js +25 -15
  39. package/lib/stateAggregator/accessors/aliasAccessor.d.ts +0 -35
  40. package/lib/stateAggregator/accessors/aliasAccessor.js +4 -68
  41. package/lib/stateAggregator/accessors/orgAccessor.js +5 -10
  42. package/lib/stateAggregator/stateAggregator.js +4 -1
  43. package/lib/status/myDomainResolver.js +3 -1
  44. package/lib/status/pollingClient.js +5 -0
  45. package/lib/status/streamingClient.js +16 -4
  46. package/lib/testSetup.d.ts +2 -2
  47. package/lib/testSetup.js +75 -29
  48. package/lib/util/cache.js +21 -35
  49. package/lib/util/directoryWriter.js +1 -0
  50. package/lib/util/getJwtAudienceUrl.d.ts +1 -1
  51. package/lib/util/sfdc.js +1 -1
  52. package/lib/util/sfdcUrl.js +7 -6
  53. package/lib/util/zipWriter.js +4 -1
  54. package/lib/webOAuthServer.js +20 -9
  55. package/package.json +62 -4
  56. package/lib/util/checkLightningDomain.d.ts +0 -2
  57. package/lib/util/checkLightningDomain.js +0 -30
@@ -10,7 +10,6 @@ exports.getFileLocation = exports.AliasAccessor = exports.FILENAME = exports.DEF
10
10
  const node_path_1 = require("node:path");
11
11
  const node_os_1 = require("node:os");
12
12
  const promises_1 = require("node:fs/promises");
13
- const node_fs_1 = require("node:fs");
14
13
  const proper_lockfile_1 = require("proper-lockfile");
15
14
  const kit_1 = require("@salesforce/kit");
16
15
  const global_1 = require("../../global");
@@ -19,6 +18,10 @@ const lockRetryOptions_1 = require("../../util/lockRetryOptions");
19
18
  exports.DEFAULT_GROUP = 'orgs';
20
19
  exports.FILENAME = 'alias.json';
21
20
  class AliasAccessor extends kit_1.AsyncOptionalCreatable {
21
+ // set in init method
22
+ fileLocation;
23
+ /** orgs is the default group */
24
+ aliasStore;
22
25
  getAll(entity) {
23
26
  // This will only return aliases under "orgs". This will need to be modified
24
27
  // if/when we want to support more aliases groups.
@@ -83,19 +86,6 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
83
86
  return usernameOrAlias;
84
87
  return Array.from(this.aliasStore.entries()).find(([, value]) => value === usernameOrAlias)?.[0];
85
88
  }
86
- /**
87
- * Set an alias for the given aliasable entity. Writes to the file
88
- *
89
- * @deprecated use setAndSave
90
- * @param alias the alias you want to set
91
- * @param entity the aliasable entity that's being aliased
92
- */
93
- set(alias, entity) {
94
- // get a very fresh copy to merge with to avoid conflicts
95
- this.readFileToAliasStoreSync();
96
- this.aliasStore.set(alias, getNameOf(entity));
97
- this.saveAliasStoreToFileSync();
98
- }
99
89
  /**
100
90
  * Set an alias for the given aliasable entity. Writes to the file
101
91
  *
@@ -108,17 +98,6 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
108
98
  this.aliasStore.set(alias, getNameOf(entity));
109
99
  return this.saveAliasStoreToFile();
110
100
  }
111
- /**
112
- * Unset the given alias. Writes to the file
113
- *
114
- * @deprecated use unsetAndSave
115
- *
116
- */
117
- unset(alias) {
118
- this.readFileToAliasStoreSync();
119
- this.aliasStore.delete(alias);
120
- this.saveAliasStoreToFileSync();
121
- }
122
101
  /**
123
102
  * Unset the given alias(es). Writes to the file
124
103
  *
@@ -128,19 +107,6 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
128
107
  this.aliasStore.delete(alias);
129
108
  return this.saveAliasStoreToFile();
130
109
  }
131
- /**
132
- * Unsets all the aliases for the given entity.
133
- *
134
- * @deprecated use unsetValuesAndSave
135
- *
136
- * @param entity the aliasable entity for which you want to unset all aliases
137
- */
138
- unsetAll(entity) {
139
- this.readFileToAliasStoreSync();
140
- const aliases = this.getAll(entity);
141
- aliases.forEach((a) => this.aliasStore.delete(a));
142
- this.saveAliasStoreToFileSync();
143
- }
144
110
  /**
145
111
  * Unset all the aliases for the given array of entity.
146
112
  *
@@ -153,12 +119,6 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
153
119
  .map((a) => this.aliasStore.delete(a));
154
120
  return this.saveAliasStoreToFile();
155
121
  }
156
- /**
157
- * @deprecated the set/unset methods now write to the file when called. Use (un)setAndSave instead of calling (un)set and then calling write()
158
- */
159
- async write() {
160
- return Promise.resolve(this.getAll());
161
- }
162
122
  /**
163
123
  * Returns true if the provided alias exists
164
124
  *
@@ -198,30 +158,6 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
198
158
  await (0, promises_1.writeFile)(this.fileLocation, aliasStoreToRawFileContents(this.aliasStore));
199
159
  return unlockIfLocked(this.fileLocation);
200
160
  }
201
- /**
202
- * @deprecated use the async version of this method instead
203
- * provided for the legacy sync set/unset methods. */
204
- readFileToAliasStoreSync() {
205
- // the file is guaranteed to exist because this init method ensures it
206
- // put a lock in place. This method is only used by legacy set/unset methods.
207
- (0, proper_lockfile_1.lockSync)(this.fileLocation, lockRetryOptions_1.lockOptions);
208
- this.aliasStore = fileContentsRawToAliasStore((0, node_fs_1.readFileSync)(this.fileLocation, 'utf-8'));
209
- }
210
- /**
211
- * @deprecated use the async version of this method instead
212
- * provided for the legacy sync set/unset methods */
213
- saveAliasStoreToFileSync() {
214
- (0, node_fs_1.writeFileSync)(this.fileLocation, aliasStoreToRawFileContents(this.aliasStore));
215
- try {
216
- (0, proper_lockfile_1.unlockSync)(this.fileLocation);
217
- }
218
- catch (e) {
219
- // ignore the error. If it wasn't locked, that's what we wanted
220
- if (errorIsNotAcquired(e))
221
- return;
222
- throw e;
223
- }
224
- }
225
161
  }
226
162
  exports.AliasAccessor = AliasAccessor;
227
163
  /**
@@ -46,12 +46,10 @@ function chunk(array, chunkSize) {
46
46
  return final;
47
47
  }
48
48
  class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
49
- constructor() {
50
- super(...arguments);
51
- this.configs = new Map();
52
- /** map of Org files by username */
53
- this.contents = new Map();
54
- }
49
+ configs = new Map();
50
+ /** map of Org files by username */
51
+ contents = new Map();
52
+ logger;
55
53
  /**
56
54
  * Read the auth file for the given username. Once the file has been read, it can be re-accessed with the `get` method.
57
55
  *
@@ -187,10 +185,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
187
185
  }
188
186
  }
189
187
  else {
190
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
191
- // @ts-ignore
192
- org.username ??= username;
193
- this.contents.set(username, org);
188
+ this.contents.set(username, { ...org, username: org.username ?? username });
194
189
  }
195
190
  }
196
191
  /**
@@ -13,6 +13,10 @@ const aliasAccessor_1 = require("./accessors/aliasAccessor");
13
13
  const orgAccessor_1 = require("./accessors/orgAccessor");
14
14
  const sandboxAccessor_1 = require("./accessors/sandboxAccessor");
15
15
  class StateAggregator extends kit_1.AsyncOptionalCreatable {
16
+ static instanceMap = new Map();
17
+ aliases;
18
+ orgs;
19
+ sandboxes;
16
20
  /**
17
21
  * Reuse a StateAggregator if one was already created for the current global state directory
18
22
  * Otherwise, create one and adds it to map for future reuse.
@@ -40,5 +44,4 @@ class StateAggregator extends kit_1.AsyncOptionalCreatable {
40
44
  }
41
45
  }
42
46
  exports.StateAggregator = StateAggregator;
43
- StateAggregator.instanceMap = new Map();
44
47
  //# sourceMappingURL=stateAggregator.js.map
@@ -37,6 +37,9 @@ const DNS_RETRY_FREQ = Math.max(1, new kit_1.Env().getNumber('SFDX_DNS_RETRY_FRE
37
37
  * ```
38
38
  */
39
39
  class MyDomainResolver extends kit_1.AsyncOptionalCreatable {
40
+ static DEFAULT_DOMAIN = new node_url_1.URL('https://login.salesforce.com');
41
+ logger;
42
+ options;
40
43
  /**
41
44
  * Constructor
42
45
  * **Do not directly construct instances of this class -- use {@link MyDomainResolver.create} instead.**
@@ -122,5 +125,4 @@ class MyDomainResolver extends kit_1.AsyncOptionalCreatable {
122
125
  }
123
126
  }
124
127
  exports.MyDomainResolver = MyDomainResolver;
125
- MyDomainResolver.DEFAULT_DOMAIN = new node_url_1.URL('https://login.salesforce.com');
126
128
  //# sourceMappingURL=myDomainResolver.js.map
@@ -32,6 +32,8 @@ const lifecycleEvents_1 = require("../lifecycleEvents");
32
32
  * ```
33
33
  */
34
34
  class PollingClient extends kit_1.AsyncOptionalCreatable {
35
+ logger;
36
+ options;
35
37
  /**
36
38
  * Constructor
37
39
  *
@@ -99,6 +101,9 @@ exports.PollingClient = PollingClient;
99
101
  * seconds;
100
102
  */
101
103
  class DefaultPollingOptions {
104
+ frequency;
105
+ poll;
106
+ timeout;
102
107
  /**
103
108
  * constructor
104
109
  *
@@ -97,6 +97,10 @@ function validateTimeout(newTime, existingTime) {
97
97
  * ```
98
98
  */
99
99
  class StreamingClient extends lib_1.AsyncOptionalCreatable {
100
+ targetUrl;
101
+ options;
102
+ logger;
103
+ cometClient;
100
104
  /**
101
105
  * Constructor
102
106
  *
@@ -164,6 +168,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
164
168
  outgoing: (message, callback) => {
165
169
  if (message.channel === '/meta/subscribe') {
166
170
  if (!message.ext) {
171
+ // eslint-disable-next-line no-param-reassign
167
172
  message.ext = {};
168
173
  }
169
174
  const replayFromMap = {};
@@ -326,6 +331,17 @@ exports.StreamingClient = StreamingClient;
326
331
  * Default Streaming Options. Uses Faye as the cometd impl.
327
332
  */
328
333
  class DefaultOptions {
334
+ static SFDX_ENABLE_FAYE_COOKIES_ALLOW_ALL_PATHS = 'SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING';
335
+ static SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING = 'SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING';
336
+ static DEFAULT_SUBSCRIBE_TIMEOUT = lib_1.Duration.minutes(3);
337
+ static DEFAULT_HANDSHAKE_TIMEOUT = lib_1.Duration.seconds(30);
338
+ apiVersion;
339
+ org;
340
+ streamProcessor;
341
+ subscribeTimeout;
342
+ handshakeTimeout;
343
+ channel;
344
+ streamingImpl;
329
345
  /**
330
346
  * Constructor for DefaultStreamingOptions
331
347
  *
@@ -399,10 +415,6 @@ exports.StreamingClient = StreamingClient;
399
415
  this.handshakeTimeout = validateTimeout(newTime, DefaultOptions.DEFAULT_HANDSHAKE_TIMEOUT);
400
416
  }
401
417
  }
402
- DefaultOptions.SFDX_ENABLE_FAYE_COOKIES_ALLOW_ALL_PATHS = 'SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING';
403
- DefaultOptions.SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING = 'SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING';
404
- DefaultOptions.DEFAULT_SUBSCRIBE_TIMEOUT = lib_1.Duration.minutes(3);
405
- DefaultOptions.DEFAULT_HANDSHAKE_TIMEOUT = lib_1.Duration.seconds(30);
406
418
  StreamingClient.DefaultOptions = DefaultOptions;
407
419
  /**
408
420
  * Connection state
@@ -11,6 +11,7 @@ import { SandboxFields } from './org/org';
11
11
  import { AuthFields } from './org/authInfo';
12
12
  import { uniqid } from './util/uniqid';
13
13
  export { uniqid };
14
+ export { SecureBuffer } from './crypto/secureBuffer';
14
15
  /**
15
16
  * Different parts of the system that are mocked out. They can be restored for
16
17
  * individual tests. Test's stubs should always go on the DEFAULT which is exposed
@@ -195,7 +196,6 @@ export declare class TestContext {
195
196
  * This is called automatically when the class is instantiated unless the setup option is set to false.
196
197
  */
197
198
  setup(): void;
198
- private requireSinon;
199
199
  }
200
200
  /**
201
201
  * Instantiate a @salesforce/core test context. This is automatically created by `const $$ = testSetup()`
@@ -269,7 +269,7 @@ export declare const restoreContext: (testContext: TestContext) => void;
269
269
  *
270
270
  * **See** {@link shouldThrow}
271
271
  */
272
- export declare const unexpectedResult: SfError<unknown>;
272
+ export declare const unexpectedResult: SfError<AnyJson>;
273
273
  /**
274
274
  * Use for this testing pattern:
275
275
  * ```
package/lib/testSetup.js CHANGED
@@ -23,13 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.MockTestSandboxData = exports.MockTestOrgData = exports.StreamingMockCometClient = exports.StreamingMockCometSubscription = exports.StreamingMockSubscriptionCall = exports.shouldThrowSync = exports.shouldThrow = exports.unexpectedResult = exports.restoreContext = exports.stubContext = exports.instantiateContext = exports.TestContext = exports.uniqid = void 0;
26
+ exports.MockTestSandboxData = exports.MockTestOrgData = exports.StreamingMockCometClient = exports.StreamingMockCometSubscription = exports.StreamingMockSubscriptionCall = exports.shouldThrowSync = exports.shouldThrow = exports.unexpectedResult = exports.restoreContext = exports.stubContext = exports.instantiateContext = exports.TestContext = exports.SecureBuffer = exports.uniqid = void 0;
27
27
  /*
28
28
  * Copyright (c) 2020, salesforce.com, inc.
29
29
  * All rights reserved.
30
30
  * Licensed under the BSD 3-Clause license.
31
31
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
32
32
  */
33
+ /* eslint-disable no-param-reassign */ // mutate ALL the THINGS!
33
34
  /* eslint-disable @typescript-eslint/ban-ts-comment */
34
35
  /* eslint-disable class-methods-use-this */
35
36
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
@@ -58,25 +59,43 @@ const sandboxAccessor_1 = require("./stateAggregator/accessors/sandboxAccessor")
58
59
  const global_1 = require("./global");
59
60
  const uniqid_1 = require("./util/uniqid");
60
61
  Object.defineProperty(exports, "uniqid", { enumerable: true, get: function () { return uniqid_1.uniqid; } });
62
+ // stuff previously imported via /lib/foo and used in unit tests
63
+ var secureBuffer_1 = require("./crypto/secureBuffer");
64
+ Object.defineProperty(exports, "SecureBuffer", { enumerable: true, get: function () { return secureBuffer_1.SecureBuffer; } });
61
65
  /**
62
66
  * Instantiate a @salesforce/core test context.
63
67
  */
64
68
  class TestContext {
69
+ /**
70
+ * The default sandbox is cleared out before each test run.
71
+ *
72
+ * **See** [sinon sandbox]{@link https://sinonjs.org/releases/v14/sandbox/}.
73
+ */
74
+ SANDBOX;
75
+ /**
76
+ * An object of different sandboxes. Used when
77
+ * needing to restore parts of the system for customized testing.
78
+ */
79
+ SANDBOXES;
80
+ /**
81
+ * The test logger that is used when {@link Logger.child} is used anywhere. It uses memory logging.
82
+ */
83
+ TEST_LOGGER;
84
+ /**
85
+ * id A unique id for the test run.
86
+ */
87
+ id = (0, uniqid_1.uniqid)();
88
+ /**
89
+ * An object used in tests that interact with config files.
90
+ */
91
+ configStubs = {};
92
+ /**
93
+ * A record of stubs created during instantiation.
94
+ */
95
+ stubs = {};
65
96
  constructor(options = {}) {
66
- /**
67
- * id A unique id for the test run.
68
- */
69
- this.id = (0, uniqid_1.uniqid)();
70
- /**
71
- * An object used in tests that interact with config files.
72
- */
73
- this.configStubs = {};
74
- /**
75
- * A record of stubs created during instantiation.
76
- */
77
- this.stubs = {};
78
97
  const opts = { setup: true, ...options };
79
- const sinon = this.requireSinon(opts.sinon);
98
+ const sinon = requireSinon(opts.sinon);
80
99
  ;
81
100
  // Create a global sinon sandbox and a test logger instance for use within tests.
82
101
  this.SANDBOX = opts.sandbox ?? sinon.createSandbox();
@@ -312,21 +331,20 @@ class TestContext {
312
331
  this.restore();
313
332
  });
314
333
  }
315
- requireSinon(sinon) {
316
- if (sinon)
317
- return sinon;
318
- try {
319
- // eslint-disable-next-line import/no-extraneous-dependencies
320
- sinon = require('sinon');
321
- }
322
- catch (e) {
323
- throw new Error('The package sinon was not found. Add it to your package.json and pass it in to new TestContext({sinon})');
324
- }
325
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
326
- return sinon;
327
- }
328
334
  }
329
335
  exports.TestContext = TestContext;
336
+ const requireSinon = (sinon) => {
337
+ if (sinon)
338
+ return sinon;
339
+ try {
340
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies
341
+ const newSinon = require('sinon');
342
+ return newSinon;
343
+ }
344
+ catch (e) {
345
+ throw new Error('The package sinon was not found. Add it to your package.json and pass it in to new TestContext({sinon})');
346
+ }
347
+ };
330
348
  function getTestLocalPath(uid) {
331
349
  return (0, node_path_1.join)((0, node_os_1.tmpdir)(), uid, 'sfdx_core', 'local');
332
350
  }
@@ -600,6 +618,9 @@ var StreamingMockSubscriptionCall;
600
618
  * Simulates a comet subscription to a streaming channel.
601
619
  */
602
620
  class StreamingMockCometSubscription extends node_events_1.EventEmitter {
621
+ static SUBSCRIPTION_COMPLETE = 'subscriptionComplete';
622
+ static SUBSCRIPTION_FAILED = 'subscriptionFailed';
623
+ options;
603
624
  constructor(options) {
604
625
  super();
605
626
  this.options = options;
@@ -635,14 +656,13 @@ class StreamingMockCometSubscription extends node_events_1.EventEmitter {
635
656
  }
636
657
  }
637
658
  exports.StreamingMockCometSubscription = StreamingMockCometSubscription;
638
- StreamingMockCometSubscription.SUBSCRIPTION_COMPLETE = 'subscriptionComplete';
639
- StreamingMockCometSubscription.SUBSCRIPTION_FAILED = 'subscriptionFailed';
640
659
  /**
641
660
  * Simulates a comet client. To the core streaming client this mocks the internal comet impl.
642
661
  * The uses setTimeout(0ms) event loop phase just so the client can simulate actual streaming without the response
643
662
  * latency.
644
663
  */
645
664
  class StreamingMockCometClient extends streamingClient_1.CometClient {
665
+ options;
646
666
  /**
647
667
  * Constructor
648
668
  *
@@ -717,6 +737,27 @@ exports.StreamingMockCometClient = StreamingMockCometClient;
717
737
  * ```
718
738
  */
719
739
  class MockTestOrgData {
740
+ testId;
741
+ aliases;
742
+ configs;
743
+ username;
744
+ devHubUsername;
745
+ orgId;
746
+ loginUrl;
747
+ instanceUrl;
748
+ clientId;
749
+ clientSecret;
750
+ authcode;
751
+ accessToken;
752
+ refreshToken;
753
+ tracksSource;
754
+ userId;
755
+ redirectUri;
756
+ isDevHub;
757
+ isScratchOrg;
758
+ isExpired;
759
+ password;
760
+ namespacePrefix;
720
761
  constructor(id = (0, uniqid_1.uniqid)(), options) {
721
762
  this.testId = id;
722
763
  this.userId = `user_id_${this.testId}`;
@@ -834,6 +875,11 @@ exports.MockTestOrgData = MockTestOrgData;
834
875
  * ```
835
876
  */
836
877
  class MockTestSandboxData {
878
+ id;
879
+ sandboxOrgId;
880
+ prodOrgUsername;
881
+ sandboxName;
882
+ username;
837
883
  constructor(id = (0, uniqid_1.uniqid)(), options) {
838
884
  this.id = id;
839
885
  this.sandboxOrgId = id;
package/lib/util/cache.js CHANGED
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _a, _Cache_instance, _Cache_enabled, _Cache_hits, _Cache_lookups;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.Cache = void 0;
16
4
  /*
@@ -20,51 +8,49 @@ exports.Cache = void 0;
20
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
21
9
  */
22
10
  class Cache extends Map {
11
+ /* eslint-disable @typescript-eslint/explicit-member-accessibility */
12
+ static #instance;
13
+ static #enabled = true;
14
+ #hits;
15
+ #lookups;
23
16
  /* eslint-enable @typescript-eslint/explicit-member-accessibility */
24
17
  constructor() {
25
18
  super();
26
- _Cache_hits.set(this, void 0);
27
- _Cache_lookups.set(this, void 0);
28
- __classPrivateFieldSet(this, _Cache_hits, 0, "f");
29
- __classPrivateFieldSet(this, _Cache_lookups, 0, "f");
19
+ this.#hits = 0;
20
+ this.#lookups = 0;
30
21
  }
31
22
  static get hits() {
32
- return __classPrivateFieldGet(_a.instance(), _Cache_hits, "f");
23
+ return Cache.instance().#hits;
33
24
  }
34
25
  static get lookups() {
35
- return __classPrivateFieldGet(_a.instance(), _Cache_lookups, "f");
26
+ return Cache.instance().#lookups;
36
27
  }
37
28
  static instance() {
38
- if (!__classPrivateFieldGet(_a, _a, "f", _Cache_instance)) {
39
- __classPrivateFieldSet(_a, _a, true, "f", _Cache_enabled);
40
- __classPrivateFieldSet(_a, _a, new _a(), "f", _Cache_instance);
29
+ if (!Cache.#instance) {
30
+ Cache.#enabled = true;
31
+ Cache.#instance = new Cache();
41
32
  }
42
- return __classPrivateFieldGet(_a, _a, "f", _Cache_instance);
33
+ return Cache.#instance;
43
34
  }
44
35
  static set(key, value) {
45
- if (__classPrivateFieldGet(_a, _a, "f", _Cache_enabled)) {
46
- _a.instance().set(key, value);
36
+ if (Cache.#enabled) {
37
+ Cache.instance().set(key, value);
47
38
  }
48
39
  }
49
40
  static get(key) {
50
- var _b, _c, _d;
51
- if (!__classPrivateFieldGet(_a, _a, "f", _Cache_enabled)) {
41
+ if (!Cache.#enabled) {
52
42
  return undefined;
53
43
  }
54
- __classPrivateFieldSet(_b = _a.instance(), _Cache_lookups, (_c = __classPrivateFieldGet(_b, _Cache_lookups, "f"), _c++, _c), "f");
55
- __classPrivateFieldSet(_d = _a.instance(), _Cache_hits, __classPrivateFieldGet(_d, _Cache_hits, "f") + (_a.instance().has(key) ? 1 : 0), "f");
56
- return __classPrivateFieldGet(_a, _a, "f", _Cache_instance).get(key);
44
+ Cache.instance().#lookups++;
45
+ Cache.instance().#hits += Cache.instance().has(key) ? 1 : 0;
46
+ return Cache.#instance.get(key);
57
47
  }
58
48
  static disable() {
59
- __classPrivateFieldSet(_a, _a, false, "f", _Cache_enabled);
49
+ Cache.#enabled = false;
60
50
  }
61
51
  static enable() {
62
- __classPrivateFieldSet(_a, _a, true, "f", _Cache_enabled);
52
+ Cache.#enabled = true;
63
53
  }
64
54
  }
65
55
  exports.Cache = Cache;
66
- _a = Cache, _Cache_hits = new WeakMap(), _Cache_lookups = new WeakMap();
67
- /* eslint-disable @typescript-eslint/explicit-member-accessibility */
68
- _Cache_instance = { value: void 0 };
69
- _Cache_enabled = { value: true };
70
56
  //# sourceMappingURL=cache.js.map
@@ -37,6 +37,7 @@ const path = __importStar(require("node:path"));
37
37
  const node_util_1 = require("node:util");
38
38
  const pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
39
39
  class DirectoryWriter {
40
+ rootDestination;
40
41
  constructor(rootDestination) {
41
42
  this.rootDestination = rootDestination;
42
43
  if (!this.rootDestination) {
@@ -1,4 +1,4 @@
1
- import { OAuth2Config } from 'jsforce';
1
+ import { OAuth2Config } from '@jsforce/jsforce-node';
2
2
  export declare function getJwtAudienceUrl(options: OAuth2Config & {
3
3
  createdOrgInstance?: string;
4
4
  }): Promise<string>;
package/lib/util/sfdc.js CHANGED
@@ -12,7 +12,7 @@ function trimTo15(id) {
12
12
  return undefined;
13
13
  }
14
14
  if (id.length && id.length > 15) {
15
- id = id.substring(0, 15);
15
+ return id.substring(0, 15);
16
16
  }
17
17
  return id;
18
18
  }
@@ -38,6 +38,13 @@ function getLoginAudienceCombos(audienceUrl, loginUrl) {
38
38
  }
39
39
  exports.getLoginAudienceCombos = getLoginAudienceCombos;
40
40
  class SfdcUrl extends node_url_1.URL {
41
+ /**
42
+ * Salesforce URLs
43
+ */
44
+ static SANDBOX = 'https://test.salesforce.com';
45
+ static PRODUCTION = 'https://login.salesforce.com';
46
+ static cache = new Set();
47
+ logger;
41
48
  constructor(input, base) {
42
49
  super(input.toString(), base);
43
50
  if (this.protocol !== 'https:' && !SfdcUrl.cache.has(this.origin)) {
@@ -194,10 +201,4 @@ class SfdcUrl extends node_url_1.URL {
194
201
  }
195
202
  }
196
203
  exports.SfdcUrl = SfdcUrl;
197
- /**
198
- * Salesforce URLs
199
- */
200
- SfdcUrl.SANDBOX = 'https://test.salesforce.com';
201
- SfdcUrl.PRODUCTION = 'https://login.salesforce.com';
202
- SfdcUrl.cache = new Set();
203
204
  //# sourceMappingURL=sfdcUrl.js.map
@@ -15,10 +15,13 @@ const jszip_1 = __importDefault(require("jszip"));
15
15
  const logger_1 = require("../logger/logger");
16
16
  const sfError_1 = require("../sfError");
17
17
  class ZipWriter extends node_stream_1.Writable {
18
+ rootDestination;
19
+ zip = (0, jszip_1.default)();
20
+ zipBuffer;
21
+ logger;
18
22
  constructor(rootDestination) {
19
23
  super({ objectMode: true });
20
24
  this.rootDestination = rootDestination;
21
- this.zip = (0, jszip_1.default)();
22
25
  const destination = rootDestination ? `for: ${rootDestination}` : 'in memory';
23
26
  this.logger = logger_1.Logger.childFromRoot(this.constructor.name);
24
27
  this.logger.debug(`generating zip ${destination}`);