@salesforce/core 3.6.5 → 3.7.2

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.
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { AsyncResult, DeployOptions, DeployResultLocator } from 'jsforce/api/metadata';
3
- import { Callback } from 'jsforce/connection';
4
3
  import { JsonCollection, JsonMap, Optional } from '@salesforce/ts-types';
5
- import { Connection as JSForceConnection, ConnectionOptions, ExecuteOptions, QueryResult, RequestInfo, Tooling as JSForceTooling } from 'jsforce';
4
+ import { Connection as JSForceConnection, ConnectionConfig, HttpRequest, QueryOptions, QueryResult, Record, Schema } from 'jsforce';
5
+ import { Tooling as JSForceTooling } from 'jsforce/lib/api/tooling';
6
+ import { StreamPromise } from 'jsforce/lib/util/promise';
6
7
  import { AuthFields, AuthInfo } from '../org/authInfo';
7
8
  import { ConfigAggregator } from '../config/configAggregator';
8
9
  export declare const SFDX_HTTP_HEADERS: {
@@ -14,10 +15,11 @@ declare type recentValidationOptions = {
14
15
  id: string;
15
16
  rest?: boolean;
16
17
  };
17
- export declare type DeployOptionsWithRest = DeployOptions & {
18
+ export declare type DeployOptionsWithRest = Partial<DeployOptions> & {
18
19
  rest?: boolean;
19
20
  };
20
- export interface Tooling extends JSForceTooling {
21
+ export interface Tooling<S extends Schema = Schema> extends JSForceTooling<S> {
22
+ _logger: any;
21
23
  /**
22
24
  * Executes a query and auto-fetches (i.e., "queryMore") all results. This is especially
23
25
  * useful with large query result sizes, such as over 2000 records. The default maximum
@@ -26,7 +28,7 @@ export interface Tooling extends JSForceTooling {
26
28
  * @param soql The SOQL string.
27
29
  * @param options The query options. NOTE: the autoFetch option will always be true.
28
30
  */
29
- autoFetchQuery<T>(soql: string, options?: ExecuteOptions): Promise<QueryResult<T>>;
31
+ autoFetchQuery<T extends Schema = S>(soql: string, options?: QueryOptions): Promise<QueryResult<T>>;
30
32
  }
31
33
  /**
32
34
  * Handles connections and requests to Salesforce Orgs.
@@ -43,14 +45,12 @@ export interface Tooling extends JSForceTooling {
43
45
  * connection.query('SELECT Name from Account');
44
46
  * ```
45
47
  */
46
- export declare class Connection extends JSForceConnection {
48
+ export declare class Connection<S extends Schema = Schema> extends JSForceConnection<S> {
47
49
  /**
48
50
  * Tooling api reference.
49
51
  */
50
- tooling: Tooling;
52
+ get tooling(): Tooling<S>;
51
53
  private logger;
52
- private _transport;
53
- private _normalizeUrl;
54
54
  private options;
55
55
  private username;
56
56
  /**
@@ -60,13 +60,13 @@ export declare class Connection extends JSForceConnection {
60
60
  * @param options The options for the class instance.
61
61
  * @ignore
62
62
  */
63
- constructor(options: Connection.Options);
63
+ constructor(options: Connection.Options<S>);
64
64
  /**
65
65
  * Creates an instance of a Connection. Performs additional async initializations.
66
66
  *
67
67
  * @param options Constructor options.
68
68
  */
69
- static create(this: new (options: Connection.Options) => Connection, options: Connection.Options): Promise<Connection>;
69
+ static create<S extends Schema>(this: new (options: Connection.Options<S>) => Connection<S>, options: Connection.Options<S>): Promise<Connection<S>>;
70
70
  /**
71
71
  * Async initializer.
72
72
  */
@@ -81,7 +81,7 @@ export declare class Connection extends JSForceConnection {
81
81
  * @param options JSForce deploy options + a boolean for rest
82
82
  * @param callback
83
83
  */
84
- deploy(zipInput: Buffer, options: DeployOptionsWithRest, callback?: Callback<AsyncResult>): Promise<DeployResultLocator<AsyncResult>>;
84
+ deploy(zipInput: Buffer, options: DeployOptionsWithRest): Promise<DeployResultLocator<AsyncResult & Schema>>;
85
85
  /**
86
86
  * Send REST API request with given HTTP request info, with connected session information
87
87
  * and SFDX headers.
@@ -89,14 +89,7 @@ export declare class Connection extends JSForceConnection {
89
89
  * @param request HTTP request object or URL to GET request.
90
90
  * @param options HTTP API request options.
91
91
  */
92
- request<T = JsonCollection>(request: RequestInfo | string, options?: JsonMap): Promise<T>;
93
- /**
94
- * Send REST API request with given HTTP request info, with connected session information
95
- * and SFDX headers. This method returns a raw http response which includes a response body and statusCode.
96
- *
97
- * @param request HTTP request object or URL to GET request.
98
- */
99
- requestRaw(request: RequestInfo): Promise<JsonMap>;
92
+ request<R = unknown>(request: string | HttpRequest, options?: JsonMap): StreamPromise<R>;
100
93
  /**
101
94
  * The Force API base url for the instance.
102
95
  */
@@ -167,9 +160,9 @@ export declare class Connection extends JSForceConnection {
167
160
  * fetch size is 10,000 records. Modify this via the options argument.
168
161
  *
169
162
  * @param soql The SOQL string.
170
- * @param executeOptions The query options. NOTE: the autoFetch option will always be true.
163
+ * @param queryOptions The query options. NOTE: the autoFetch option will always be true.
171
164
  */
172
- autoFetchQuery<T>(soql: string, executeOptions?: ExecuteOptions): Promise<QueryResult<T>>;
165
+ autoFetchQuery<T extends Schema = S>(soql: string, queryOptions?: Partial<QueryOptions>): Promise<QueryResult<T>>;
173
166
  /**
174
167
  * Executes a query using either standard REST or Tooling API, returning a single record.
175
168
  * Will throw if either zero records are found OR multiple records are found.
@@ -177,7 +170,7 @@ export declare class Connection extends JSForceConnection {
177
170
  * @param soql The SOQL string.
178
171
  * @param options The query options.
179
172
  */
180
- singleRecordQuery<T>(soql: string, options?: SingleRecordQueryOptions): Promise<T>;
173
+ singleRecordQuery<T extends Record>(soql: string, options?: SingleRecordQueryOptions): Promise<T>;
181
174
  private loadInstanceApiVersion;
182
175
  }
183
176
  export declare const SingleRecordQueryErrors: {
@@ -193,7 +186,7 @@ export declare namespace Connection {
193
186
  /**
194
187
  * Connection Options.
195
188
  */
196
- interface Options {
189
+ interface Options<S extends Schema> {
197
190
  /**
198
191
  * AuthInfo instance.
199
192
  */
@@ -205,7 +198,7 @@ export declare namespace Connection {
205
198
  /**
206
199
  * Additional connection parameters.
207
200
  */
208
- connectionOptions?: ConnectionOptions;
201
+ connectionOptions?: ConnectionConfig<S>;
209
202
  }
210
203
  }
211
204
  export {};
@@ -9,12 +9,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SingleRecordQueryErrors = exports.Connection = exports.DNS_ERROR_NAME = exports.SFDX_HTTP_HEADERS = void 0;
10
10
  /* eslint-disable @typescript-eslint/ban-ts-comment */
11
11
  const url_1 = require("url");
12
+ const FormData = require("form-data");
12
13
  const kit_1 = require("@salesforce/kit");
13
14
  const ts_types_1 = require("@salesforce/ts-types");
14
15
  const jsforce_1 = require("jsforce");
15
- // no types for Transport
16
- // @ts-ignore
17
- const Transport = require("jsforce/lib/transport");
16
+ const tooling_1 = require("jsforce/lib/api/tooling");
18
17
  const myDomainResolver_1 = require("../status/myDomainResolver");
19
18
  const configAggregator_1 = require("../config/configAggregator");
20
19
  const logger_1 = require("../logger");
@@ -27,12 +26,6 @@ const messages = messages_1.Messages.load('@salesforce/core', 'connection', [
27
26
  'domainNotFoundError',
28
27
  'noInstanceUrlError',
29
28
  ]);
30
- /**
31
- * The 'async' in our request override replaces the jsforce promise with the node promise, then returns it back to
32
- * jsforce which expects .thenCall. Add .thenCall to the node promise to prevent breakage.
33
- */
34
- // @ts-ignore
35
- Promise.prototype.thenCall = jsforce_1.Promise.prototype.thenCall;
36
29
  const clientId = `sfdx toolbelt:${process.env.SFDX_SET_CLIENT_IDS || ''}`;
37
30
  exports.SFDX_HTTP_HEADERS = {
38
31
  'content-type': 'application/json',
@@ -69,6 +62,13 @@ class Connection extends jsforce_1.Connection {
69
62
  this.options = options;
70
63
  this.username = options.authInfo.getUsername();
71
64
  }
65
+ // The following are all initialized in either this constructor or the super constructor, sometimes conditionally...
66
+ /**
67
+ * Tooling api reference.
68
+ */
69
+ get tooling() {
70
+ return super.tooling;
71
+ }
72
72
  /**
73
73
  * Creates an instance of a Connection. Performs additional async initializations.
74
74
  *
@@ -87,8 +87,9 @@ class Connection extends jsforce_1.Connection {
87
87
  const configAggregator = options.configAggregator || (await configAggregator_1.ConfigAggregator.create());
88
88
  baseOptions.version = ts_types_1.asString(configAggregator.getInfo('apiVersion').value);
89
89
  }
90
+ const providedOptions = options.authInfo.getConnectionOptions();
90
91
  // Get connection options from auth info and create a new jsForce connection
91
- options.connectionOptions = Object.assign(baseOptions, options.authInfo.getConnectionOptions());
92
+ options.connectionOptions = Object.assign(baseOptions, providedOptions);
92
93
  const conn = new this(options);
93
94
  await conn.init();
94
95
  try {
@@ -129,7 +130,7 @@ class Connection extends jsforce_1.Connection {
129
130
  * @param options JSForce deploy options + a boolean for rest
130
131
  * @param callback
131
132
  */
132
- async deploy(zipInput, options, callback) {
133
+ async deploy(zipInput, options) {
133
134
  const rest = options.rest;
134
135
  // neither API expects this option
135
136
  delete options.rest;
@@ -137,37 +138,29 @@ class Connection extends jsforce_1.Connection {
137
138
  this.logger.debug('deploy with REST');
138
139
  const headers = {
139
140
  Authorization: this && `OAuth ${this.accessToken}`,
140
- clientId: this.oauth2 && this.oauth2.clientId,
141
141
  'Sforce-Call-Options': 'client=sfdx-core',
142
142
  };
143
- const url = `${this.baseUrl()}/metadata/deployRequest`;
144
- const request = Transport.prototype._getHttpRequestModule();
145
- return new Promise((resolve, reject) => {
146
- const req = request.post(url, { headers }, (err, httpResponse, body) => {
147
- let res;
148
- try {
149
- res = JSON.parse(body);
150
- }
151
- catch (e) {
152
- reject(sfdxError_1.SfdxError.wrap(body));
153
- }
154
- resolve(res);
155
- });
156
- const form = req.form();
157
- // Add the zip file
158
- form.append('file', zipInput, {
159
- contentType: 'application/zip',
160
- filename: 'package.xml',
161
- });
162
- // Add the deploy options
163
- form.append('entity_content', JSON.stringify({ deployOptions: options }), {
164
- contentType: 'application/json',
165
- });
143
+ const client = this.oauth2 && this.oauth2.clientId;
144
+ if (client) {
145
+ headers.clientId = client;
146
+ }
147
+ const form = new FormData();
148
+ // Add the zip file
149
+ form.append('file', zipInput, {
150
+ contentType: 'application/zip',
151
+ filename: 'package.xml',
166
152
  });
153
+ // Add the deploy options
154
+ form.append('entity_content', JSON.stringify({ deployOptions: options }), {
155
+ contentType: 'application/json',
156
+ });
157
+ const url = `${this.baseUrl()}/metadata/deployRequest`;
158
+ const httpRequest = { method: 'POST', url, headers, body: form };
159
+ return this.request(httpRequest);
167
160
  }
168
161
  else {
169
162
  this.logger.debug('deploy with SOAP');
170
- return this.metadata.deploy(zipInput, options, callback);
163
+ return this.metadata.deploy(zipInput, options);
171
164
  }
172
165
  }
173
166
  /**
@@ -177,27 +170,12 @@ class Connection extends jsforce_1.Connection {
177
170
  * @param request HTTP request object or URL to GET request.
178
171
  * @param options HTTP API request options.
179
172
  */
180
- async request(request, options) {
181
- const requestInfo = ts_types_1.isString(request) ? { method: 'GET', url: request } : request;
182
- requestInfo.headers = Object.assign({}, exports.SFDX_HTTP_HEADERS, requestInfo.headers);
183
- this.logger.debug(`request: ${JSON.stringify(requestInfo)}`);
184
- return super.request(requestInfo, options);
185
- }
186
- /**
187
- * Send REST API request with given HTTP request info, with connected session information
188
- * and SFDX headers. This method returns a raw http response which includes a response body and statusCode.
189
- *
190
- * @param request HTTP request object or URL to GET request.
191
- */
192
- async requestRaw(request) {
193
- const headers = this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {};
194
- kit_1.merge(headers, exports.SFDX_HTTP_HEADERS, request.headers);
195
- return this._transport.httpRequest({
196
- method: request.method,
197
- url: request.url,
198
- headers,
199
- body: request.body,
200
- });
173
+ request(request, options) {
174
+ const httpRequest = ts_types_1.isString(request) ? { method: 'GET', url: request } : request;
175
+ httpRequest.headers = Object.assign({}, exports.SFDX_HTTP_HEADERS, httpRequest.headers);
176
+ this.logger.debug(`request: ${JSON.stringify(httpRequest)}`);
177
+ // The "as" is a workaround for the jsforce typings.
178
+ return super.request(httpRequest, options);
201
179
  }
202
180
  /**
203
181
  * The Force API base url for the instance.
@@ -347,33 +325,21 @@ class Connection extends jsforce_1.Connection {
347
325
  * fetch size is 10,000 records. Modify this via the options argument.
348
326
  *
349
327
  * @param soql The SOQL string.
350
- * @param executeOptions The query options. NOTE: the autoFetch option will always be true.
328
+ * @param queryOptions The query options. NOTE: the autoFetch option will always be true.
351
329
  */
352
- async autoFetchQuery(soql, executeOptions = {}) {
330
+ async autoFetchQuery(soql, queryOptions = {}) {
353
331
  const config = await configAggregator_1.ConfigAggregator.create();
354
332
  // take the limit from the calling function, then the config, then default 10,000
355
- const maxFetch = config.getInfo('maxQueryLimit').value || executeOptions.maxFetch || 10000;
356
- const options = Object.assign(executeOptions, {
333
+ const maxFetch = config.getInfo('maxQueryLimit').value || queryOptions.maxFetch || 10000;
334
+ const options = Object.assign(queryOptions, {
357
335
  autoFetch: true,
358
336
  maxFetch,
359
337
  });
360
- const records = [];
361
- return new Promise((resolve, reject) => {
362
- const query = this.query(soql, options)
363
- .on('record', (rec) => records.push(rec))
364
- .on('error', (err) => reject(err))
365
- .on('end', () => {
366
- const totalSize = ts_types_1.getNumber(query, 'totalSize') || 0;
367
- if (totalSize > records.length) {
368
- process.emitWarning(`The query result is missing ${totalSize - records.length} records due to a ${maxFetch} record limit. Increase the number of records returned by setting the config value "maxQueryLimit" or the environment variable "SFDX_MAX_QUERY_LIMIT" to ${totalSize} or greater than ${maxFetch}.`);
369
- }
370
- resolve({
371
- done: true,
372
- totalSize,
373
- records,
374
- });
375
- });
376
- });
338
+ const query = await this.query(soql, options);
339
+ if (query.totalSize > query.records.length) {
340
+ process.emitWarning(`The query result is missing ${query.totalSize - query.records.length} records due to a ${maxFetch} record limit. Increase the number of records returned by setting the config value "maxQueryLimit" or the environment variable "SFDX_MAX_QUERY_LIMIT" to ${query.totalSize} or greater than ${maxFetch}.`);
341
+ }
342
+ return query;
377
343
  }
378
344
  /**
379
345
  * Executes a query using either standard REST or Tooling API, returning a single record.
@@ -445,4 +411,10 @@ exports.SingleRecordQueryErrors = {
445
411
  NoRecords: 'SingleRecordQuery_NoRecords',
446
412
  MultipleRecords: 'SingleRecordQuery_MultipleRecords',
447
413
  };
414
+ // jsforce does some interesting proxy loading on lib classes.
415
+ // Setting this in the Connection.tooling getter will not work, it
416
+ // must be set on the prototype.
417
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
418
+ // @ts-ignore
419
+ tooling_1.Tooling.prototype.autoFetchQuery = Connection.prototype.autoFetchQuery; // eslint-disable-line @typescript-eslint/unbound-method
448
420
  //# sourceMappingURL=connection.js.map
package/lib/org/org.js CHANGED
@@ -131,9 +131,11 @@ class Org extends kit_1.AsyncOptionalCreatable {
131
131
  const thisOrgAuthConfig = this.getConnection().getAuthInfoFields();
132
132
  const trimmedId = sfdc_1.sfdc.trimTo15(thisOrgAuthConfig.orgId);
133
133
  const DEV_HUB_SOQL = `SELECT CreatedDate,Edition,ExpirationDate FROM ActiveScratchOrg WHERE ScratchOrg='${trimmedId}'`;
134
- let results;
135
134
  try {
136
- results = await devHubConnection.query(DEV_HUB_SOQL);
135
+ const results = await devHubConnection.query(DEV_HUB_SOQL);
136
+ if (ts_types_1.getNumber(results, 'records.length') !== 1) {
137
+ throw new sfdxError_1.SfdxError('No results', 'NoResultsError');
138
+ }
137
139
  }
138
140
  catch (err) {
139
141
  if (err.name === 'INVALID_TYPE') {
@@ -141,9 +143,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
141
143
  }
142
144
  throw err;
143
145
  }
144
- if (ts_types_1.getNumber(results, 'records.length') !== 1) {
145
- throw new sfdxError_1.SfdxError('No results', 'NoResultsError');
146
- }
147
146
  return thisOrgAuthConfig;
148
147
  }
149
148
  /**
package/lib/org/user.d.ts CHANGED
@@ -168,6 +168,7 @@ export declare class User extends AsyncCreatable<User.Options> {
168
168
  * @param fields The configuration the new user should have.
169
169
  */
170
170
  private createUserInternal;
171
+ private rawRequest;
171
172
  /**
172
173
  * Update the remaining required fields for the user.
173
174
  *
package/lib/org/user.js CHANGED
@@ -10,6 +10,7 @@ exports.User = exports.DefaultUserFields = exports.REQUIRED_FIELDS = void 0;
10
10
  const os_1 = require("os");
11
11
  const kit_1 = require("@salesforce/kit");
12
12
  const ts_types_1 = require("@salesforce/ts-types");
13
+ const http_api_1 = require("jsforce/lib/http-api");
13
14
  const connection_1 = require("../org/connection");
14
15
  const logger_1 = require("../logger");
15
16
  const messages_1 = require("../messages");
@@ -230,7 +231,7 @@ class User extends kit_1.AsyncCreatable {
230
231
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
231
232
  // @ts-ignore TODO: expose `soap` on Connection however appropriate
232
233
  const soap = userConnection.soap;
233
- await soap.setPassword(info.getFields().userId, buffer.toString('utf8'));
234
+ await soap.setPassword(ts_types_1.ensureString(info.getFields().userId), buffer.toString('utf8'));
234
235
  this.logger.debug(`Set password for userId: ${info.getFields().userId}`);
235
236
  resolve();
236
237
  }
@@ -387,7 +388,7 @@ class User extends kit_1.AsyncCreatable {
387
388
  headers: scimHeaders,
388
389
  body,
389
390
  };
390
- const response = await conn.requestRaw(info);
391
+ const response = await this.rawRequest(conn, info);
391
392
  const responseBody = kit_1.parseJsonMap(ts_types_1.ensureString(response['body']));
392
393
  const statusCode = ts_types_1.asNumber(response.statusCode);
393
394
  this.logger.debug(`user create response.statusCode: ${response.statusCode}`);
@@ -418,6 +419,14 @@ class User extends kit_1.AsyncCreatable {
418
419
  userId: fields.id,
419
420
  };
420
421
  }
422
+ async rawRequest(conn, options) {
423
+ return new Promise((resolve, reject) => {
424
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
425
+ const httpApi = new http_api_1.HttpApi(conn, options);
426
+ httpApi.on('response', (response) => resolve(response));
427
+ httpApi.request(options).catch(reject);
428
+ });
429
+ }
421
430
  /**
422
431
  * Update the remaining required fields for the user.
423
432
  *
@@ -1,7 +1,8 @@
1
+ /// <reference types="sfdx-faye" />
1
2
  import { AsyncOptionalCreatable, Duration } from '@salesforce/kit';
2
3
  import { AnyJson } from '@salesforce/ts-types';
3
4
  import { Logger } from '../logger';
4
- import { StatusResult } from './client';
5
+ import { StatusResult } from './streamingClient';
5
6
  /**
6
7
  * This is a polling client that can be used to poll the status of long running tasks. It can be used as a replacement
7
8
  * for Streaming when streaming topics are not available or when streaming handshakes are failing. Why wouldn't you
@@ -1,75 +1,8 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
1
  import { AsyncOptionalCreatable, Duration, Env } from '@salesforce/kit/lib';
4
- import { AnyFunction, AnyJson, JsonMap } from '@salesforce/ts-types/lib';
2
+ import { AnyJson } from '@salesforce/ts-types/lib';
3
+ import type { Client as CometClient, StreamProcessor } from 'sfdx-faye';
5
4
  import { Org } from '../org/org';
6
- import { StatusResult } from './client';
7
- /**
8
- * Types for defining extensions.
9
- */
10
- export interface StreamingExtension {
11
- /**
12
- * Extension for outgoing message.
13
- *
14
- * @param message The message.
15
- * @param callback The callback to invoke after the message is processed.
16
- */
17
- outgoing?: (message: JsonMap, callback: AnyFunction) => void;
18
- /**
19
- * Extension for the incoming message.
20
- *
21
- * @param message The message.
22
- * @param callback The callback to invoke after the message is processed.
23
- */
24
- incoming?: (message: JsonMap, callback: AnyFunction) => void;
25
- }
26
- /**
27
- * Function type for processing messages
28
- */
29
- export declare type StreamProcessor = (message: JsonMap) => StatusResult;
30
- /**
31
- * Comet client interface. The is to allow for mocking the inner streaming Cometd implementation.
32
- * The Faye implementation is used by default but it could be used to adapt another Cometd impl.
33
- */
34
- export declare abstract class CometClient extends EventEmitter {
35
- /**
36
- * Disable polling features.
37
- *
38
- * @param label Polling feature label.
39
- */
40
- abstract disable(label: string): void;
41
- /**
42
- * Add a custom extension to the underlying client.
43
- *
44
- * @param extension The json function for the extension.
45
- */
46
- abstract addExtension(extension: StreamingExtension): void;
47
- /**
48
- * Sets an http header name/value.
49
- *
50
- * @param name The header name.
51
- * @param value The header value.
52
- */
53
- abstract setHeader(name: string, value: string): void;
54
- /**
55
- * handshake with the streaming channel
56
- *
57
- * @param callback Callback for the handshake when it successfully completes. The handshake should throw
58
- * errors when errors are encountered.
59
- */
60
- abstract handshake(callback: () => void): void;
61
- /**
62
- * Subscribes to Comet topics. Subscribe should perform a handshake if one hasn't been performed yet.
63
- *
64
- * @param channel The topic to subscribe to.
65
- * @param callback The callback to execute once a message has been received.
66
- */
67
- abstract subscribe(channel: string, callback: (message: JsonMap) => void): CometSubscription;
68
- /**
69
- * Method to call to disconnect the client from the server.
70
- */
71
- abstract disconnect(): void;
72
- }
5
+ export { Client as CometClient, Message, StreamProcessor, CometSubscription, StatusResult, StreamingExtension, } from 'sfdx-faye';
73
6
  /**
74
7
  * Inner streaming client interface. This implements the Cometd behavior.
75
8
  * Also allows for mocking the functional behavior.
@@ -88,13 +21,6 @@ export interface StreamingClientIfc {
88
21
  */
89
22
  setLogger: (logLine: (message: string) => void) => void;
90
23
  }
91
- /**
92
- * The subscription object returned from the cometd subscribe object.
93
- */
94
- export interface CometSubscription {
95
- callback(callback: () => void): void;
96
- errback(callback: (error: Error) => void): void;
97
- }
98
24
  /**
99
25
  * Api wrapper to support Salesforce streaming. The client contains an internal implementation of a cometd specification.
100
26
  *
@@ -8,15 +8,15 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.StreamingClient = exports.CometClient = void 0;
10
10
  /* eslint-disable @typescript-eslint/ban-ts-comment */
11
- const events_1 = require("events");
12
11
  const url_1 = require("url");
13
12
  const lib_1 = require("@salesforce/kit/lib");
14
13
  const lib_2 = require("@salesforce/ts-types/lib");
15
- // @ts-ignore
16
14
  const Faye = require("sfdx-faye");
17
15
  const logger_1 = require("../logger");
18
16
  const sfdxError_1 = require("../sfdxError");
19
17
  const messages_1 = require("../messages");
18
+ var sfdx_faye_1 = require("sfdx-faye");
19
+ Object.defineProperty(exports, "CometClient", { enumerable: true, get: function () { return sfdx_faye_1.Client; } });
20
20
  messages_1.Messages.importMessagesDirectory(__dirname);
21
21
  const messages = messages_1.Messages.load('@salesforce/core', 'streaming', [
22
22
  'waitParamValidValueError',
@@ -25,13 +25,6 @@ const messages = messages_1.Messages.load('@salesforce/core', 'streaming', [
25
25
  'genericTimeout',
26
26
  'handshakeApiVersionError',
27
27
  ]);
28
- /**
29
- * Comet client interface. The is to allow for mocking the inner streaming Cometd implementation.
30
- * The Faye implementation is used by default but it could be used to adapt another Cometd impl.
31
- */
32
- class CometClient extends events_1.EventEmitter {
33
- }
34
- exports.CometClient = CometClient;
35
28
  /**
36
29
  * Validation helper
37
30
  *
@@ -382,6 +375,7 @@ exports.StreamingClient = StreamingClient;
382
375
  });
383
376
  },
384
377
  setLogger: (logLine) => {
378
+ // @ts-ignore
385
379
  Faye.logger = {};
386
380
  ['info', 'error', 'fatal', 'warn', 'debug'].forEach((element) => {
387
381
  lib_1.set(Faye.logger, element, logLine);
@@ -1,3 +1,4 @@
1
+ /// <reference types="sfdx-faye" />
1
2
  /// <reference types="node" />
2
3
  import { EventEmitter } from 'events';
3
4
  import * as sinonType from 'sinon';
@@ -5,7 +6,7 @@ import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types';
5
6
  import { ConfigContents } from './config/configStore';
6
7
  import { Logger } from './logger';
7
8
  import { SfdxError } from './sfdxError';
8
- import { CometClient, CometSubscription, StreamingExtension } from './status/streamingClient';
9
+ import { CometClient, CometSubscription, Message, StreamingExtension } from './status/streamingClient';
9
10
  import { SfOrg } from './globalInfo';
10
11
  /**
11
12
  * Different parts of the system that are mocked out. They can be restored for
@@ -306,7 +307,7 @@ export interface StreamingMockCometSubscriptionOptions {
306
307
  /**
307
308
  * A list of messages to playback for the client. One message per process tick.
308
309
  */
309
- messagePlaylist?: JsonMap[];
310
+ messagePlaylist?: Message[];
310
311
  }
311
312
  /**
312
313
  * Simulates a comet subscription to a streaming channel.
@@ -366,7 +367,7 @@ export declare class StreamingMockCometClient extends CometClient {
366
367
  * @param channel The streaming channel.
367
368
  * @param callback The function to invoke after the subscription completes.
368
369
  */
369
- subscribe(channel: string, callback: (message: JsonMap) => void): CometSubscription;
370
+ subscribe(channel: string, callback: (message: Message) => void): CometSubscription;
370
371
  /**
371
372
  * Fake disconnect. Does Nothing.
372
373
  */
package/lib/testSetup.js CHANGED
@@ -413,7 +413,7 @@ class StreamingMockCometClient extends streamingClient_1.CometClient {
413
413
  * @param {StreamingMockCometSubscriptionOptions} options Extends the StreamingClient options.
414
414
  */
415
415
  constructor(options) {
416
- super();
416
+ super(options.url);
417
417
  this.options = options;
418
418
  if (!this.options.messagePlaylist) {
419
419
  this.options.messagePlaylist = [{ id: this.options.id }];
@@ -1,4 +1,4 @@
1
- import { OAuth2Options } from 'jsforce';
2
- export declare function getJwtAudienceUrl(options: OAuth2Options & {
1
+ import { OAuth2Config } from 'jsforce';
2
+ export declare function getJwtAudienceUrl(options: OAuth2Config & {
3
3
  createdOrgInstance?: string;
4
4
  }): Promise<string>;
@@ -70,6 +70,7 @@ class SfdcUrl extends url_1.URL {
70
70
  '.salesforce.com',
71
71
  '.salesforceliveagent.com',
72
72
  '.secure.force.com',
73
+ 'crmforce.mil',
73
74
  ];
74
75
  const allowlistOfSalesforceHosts = ['developer.salesforce.com', 'trailhead.salesforce.com'];
75
76
  return allowlistOfSalesforceDomainPatterns.some((pattern) => {
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as http from 'http';
3
3
  import { AsyncCreatable } from '@salesforce/kit';
4
- import { OAuth2Options } from 'jsforce';
5
- import { AuthInfo } from './org/authInfo';
4
+ import { AuthInfo, OAuth2Config } from './org/authInfo';
6
5
  /**
7
6
  * Handles the creation of a web server for web based login flows.
8
7
  *
@@ -80,7 +79,7 @@ export declare class WebOAuthServer extends AsyncCreatable<WebOAuthServer.Option
80
79
  }
81
80
  export declare namespace WebOAuthServer {
82
81
  interface Options {
83
- oauthConfig: OAuth2Options;
82
+ oauthConfig: OAuth2Config;
84
83
  }
85
84
  type Request = http.IncomingMessage & {
86
85
  query: {
@@ -13,6 +13,7 @@ const url_1 = require("url");
13
13
  const net_1 = require("net");
14
14
  const kit_1 = require("@salesforce/kit");
15
15
  const ts_types_1 = require("@salesforce/ts-types");
16
+ const jsforce_1 = require("jsforce");
16
17
  const logger_1 = require("./logger");
17
18
  const authInfo_1 = require("./org/authInfo");
18
19
  const sfdxError_1 = require("./sfdxError");
@@ -132,7 +133,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
132
133
  if (!this.oauthConfig.redirectUri)
133
134
  this.oauthConfig.redirectUri = `http://localhost:${port}/OauthRedirect`;
134
135
  this.webServer = await WebServer.create({ port });
135
- this.oauth2 = new authInfo_1.OAuth2WithVerifier(this.oauthConfig);
136
+ this.oauth2 = new jsforce_1.OAuth2(this.oauthConfig);
136
137
  this.authUrl = authInfo_1.AuthInfo.getAuthorizationUrl(this.oauthConfig, this.oauth2);
137
138
  }
138
139
  /**