@jsforce/jsforce-node 3.2.0 → 3.2.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.
@@ -20,6 +20,7 @@ class BaseRegistry {
20
20
  return (this._registryConfig.connections ||
21
21
  (this._registryConfig.connections = {}));
22
22
  }
23
+ // eslint-disable-next-line @typescript-eslint/require-await
23
24
  async getConnectionNames() {
24
25
  return Object.keys(this._getConnections());
25
26
  }
@@ -45,6 +46,7 @@ class BaseRegistry {
45
46
  }
46
47
  return connConfig_;
47
48
  }
49
+ // eslint-disable-next-line @typescript-eslint/require-await
48
50
  async saveConnectionConfig(name, connConfig) {
49
51
  const connections = this._getConnections();
50
52
  const { oauth2, ...connConfig_ } = connConfig;
@@ -70,23 +72,28 @@ class BaseRegistry {
70
72
  }
71
73
  return null;
72
74
  }
75
+ // eslint-disable-next-line @typescript-eslint/require-await
73
76
  async setDefaultConnection(name) {
74
77
  this._registryConfig['default'] = name;
75
78
  this._saveConfig();
76
79
  }
80
+ // eslint-disable-next-line @typescript-eslint/require-await
77
81
  async removeConnectionConfig(name) {
78
82
  const connections = this._getConnections();
79
83
  delete connections[name];
80
84
  this._saveConfig();
81
85
  }
86
+ // eslint-disable-next-line @typescript-eslint/require-await
82
87
  async getClientConfig(name) {
83
88
  const clients = this._getClients();
84
89
  const clientConfig = clients[name];
85
90
  return clientConfig && { ...clientConfig };
86
91
  }
92
+ // eslint-disable-next-line @typescript-eslint/require-await
87
93
  async getClientNames() {
88
94
  return Object.keys(this._getClients());
89
95
  }
96
+ // eslint-disable-next-line @typescript-eslint/require-await
90
97
  async registerClientConfig(name, clientConfig) {
91
98
  const clients = this._getClients();
92
99
  clients[name] = clientConfig;
@@ -120,9 +120,11 @@ class SfdxRegistry {
120
120
  async removeConnectionConfig(name) {
121
121
  await this._execCommand('force:org:delete', { u: name });
122
122
  }
123
+ // eslint-disable-next-line @typescript-eslint/require-await
123
124
  async getClientConfig(_name) {
124
125
  return null;
125
126
  }
127
+ // eslint-disable-next-line @typescript-eslint/require-await
126
128
  async getClientNames() {
127
129
  return [];
128
130
  }
@@ -34,7 +34,7 @@ export type RegistryConfig = {
34
34
  /**
35
35
  *
36
36
  */
37
- export interface Registry {
37
+ export type Registry = {
38
38
  getConnectionNames(): Promise<string[]>;
39
39
  getConnection<S extends Schema = Schema>(name?: string): Promise<Connection<S> | null>;
40
40
  getConnectionConfig(name?: string): Promise<ConnectionConfig | null>;
@@ -44,4 +44,4 @@ export interface Registry {
44
44
  getClientConfig(name: string): Promise<ClientConfig | null>;
45
45
  getClientNames(): Promise<string[]>;
46
46
  registerClientConfig(name: string, clientConfig: ClientConfig): Promise<void>;
47
- }
47
+ };
package/lib/request.js CHANGED
@@ -56,7 +56,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
56
56
  const controller = new abort_controller_1.default();
57
57
  let retryCount = 0;
58
58
  const retryOpts = {
59
- statusCodes: options.retry?.statusCodes ?? [429, 500, 502, 503, 504],
59
+ statusCodes: options.retry?.statusCodes ?? [420, 429, 500, 502, 503, 504],
60
60
  maxRetries: options.retry?.maxRetries ?? 5,
61
61
  minTimeout: options.retry?.minTimeout ?? 500,
62
62
  timeoutFactor: options.retry?.timeoutFactor ?? 2,
@@ -120,6 +120,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
120
120
  ? { body: input }
121
121
  : {}),
122
122
  redirect: 'manual',
123
+ // @ts-expect-error - differing types of signal? this started abruptly
123
124
  signal: controller.signal,
124
125
  agent,
125
126
  };
@@ -127,7 +128,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
127
128
  const res = await (0, node_fetch_1.default)(url, fetchOpts);
128
129
  if (shouldRetryRequest(retryOpts.maxRetries, res)) {
129
130
  logger.debug(`retrying for the ${retryCount + 1} time`);
130
- logger.debug(`reason: statusCode match`);
131
+ logger.debug('reason: statusCode match');
131
132
  await sleep(retryCount === 0
132
133
  ? retryOpts.minTimeout
133
134
  : retryOpts.minTimeout * retryOpts.timeoutFactor ** retryCount);
@@ -141,7 +142,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
141
142
  return res;
142
143
  }
143
144
  catch (err) {
144
- logger.debug(`Request failed`);
145
+ logger.debug('Request failed');
145
146
  const error = err;
146
147
  // request was canceled by consumer (AbortController), skip retry and rethrow.
147
148
  if (error.name === 'AbortError') {
@@ -149,7 +150,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
149
150
  }
150
151
  if (shouldRetryRequest(retryOpts.maxRetries, error)) {
151
152
  logger.debug(`retrying for the ${retryCount + 1} time`);
152
- logger.debug(`Error: ${error}`);
153
+ logger.debug(`Error: ${err.message}`);
153
154
  await sleep(retryCount === 0
154
155
  ? retryOpts.minTimeout
155
156
  : retryOpts.minTimeout * retryOpts.timeoutFactor ** retryCount);
@@ -157,7 +158,7 @@ async function startFetchRequest(request, options, input, output, emitter, count
157
158
  // jsforce may switch to node's fetch which doesn't emit this event on retries.
158
159
  emitter.emit('retry', retryCount);
159
160
  retryCount++;
160
- return await fetchWithRetries(maxRetry);
161
+ return fetchWithRetries(maxRetry);
161
162
  }
162
163
  logger.debug('Skipping retry...');
163
164
  if (maxRetry === retryCount) {
@@ -53,6 +53,9 @@ class SessionRefreshDelegate {
53
53
  await this._refreshPromise;
54
54
  this._logger.info('<refresh complete>');
55
55
  }
56
+ catch (err) {
57
+ throw new Error(`Unable to refresh session due to: ${err.message}`);
58
+ }
56
59
  finally {
57
60
  this._refreshPromise = undefined;
58
61
  this._lastRefreshedAt = Date.now();
package/lib/soap.js CHANGED
@@ -59,7 +59,7 @@ function castTypeUsingSchema(value, schema, schemaDict = {}) {
59
59
  const v = obj[k];
60
60
  const nillable = (Array.isArray(s) && s.length === 2 && s[0] === '?') ||
61
61
  ((0, function_1.isMapObject)(s) && '?' in s) ||
62
- (typeof s === 'string' && s[0] === '?');
62
+ (typeof s === 'string' && s.startsWith('?'));
63
63
  if (typeof v === 'undefined' && nillable) {
64
64
  return o;
65
65
  }
@@ -70,7 +70,7 @@ function castTypeUsingSchema(value, schema, schemaDict = {}) {
70
70
  }, obj);
71
71
  }
72
72
  else {
73
- const nillable = typeof schema === 'string' && schema[0] === '?';
73
+ const nillable = typeof schema === 'string' && schema.startsWith('?');
74
74
  const type = typeof schema === 'string'
75
75
  ? nillable
76
76
  ? schema.substring(1)
@@ -135,9 +135,9 @@ function toXML(name, value) {
135
135
  if ((0, function_1.isMapObject)(value)) {
136
136
  for (const k of Object.keys(value)) {
137
137
  const v = value[k];
138
- if (k[0] === '@') {
138
+ if (k.startsWith('@')) {
139
139
  const kk = k.substring(1);
140
- attrs.push(kk + '="' + v + '"');
140
+ attrs.push(`${kk}="${v}"`);
141
141
  }
142
142
  else {
143
143
  elems.push(toXML(k, v));
@@ -75,7 +75,7 @@ function createFieldExpression(field, value) {
75
75
  else if (typeof value === 'object' && value !== null) {
76
76
  // Otherwise, if an object was passed then process the supplied ops.
77
77
  for (const k of Object.keys(value)) {
78
- if (k[0] === '$') {
78
+ if (k.startsWith('$')) {
79
79
  op = k;
80
80
  _value = value[k];
81
81
  break;
package/lib/transport.js CHANGED
@@ -146,7 +146,7 @@ class XdProxyTransport extends Transport {
146
146
  httpRequest(req, _options = {}) {
147
147
  const xdProxyUrl = this._xdProxyUrl;
148
148
  const { url, body, ...rreq } = req;
149
- const canonicalUrl = url.indexOf('/') === 0 ? baseUrl + url : url;
149
+ const canonicalUrl = url.startsWith('/') ? baseUrl + url : url;
150
150
  const xdProxyReq = createXdProxyRequest({ ...rreq, url: canonicalUrl, body }, xdProxyUrl);
151
151
  return super.httpRequest(xdProxyReq, {
152
152
  followRedirect: (redirectUrl) => createXdProxyRequest({ ...rreq, method: 'GET', url: redirectUrl }, xdProxyUrl),
@@ -3,15 +3,15 @@ import { StringKeys } from './util';
3
3
  /**
4
4
  *
5
5
  */
6
- type FieldPath_3<SO extends SObjectDefinition> = '*' | StringKeys<SO['Fields']>[];
6
+ type FieldPath_3<SO extends SObjectDefinition> = '*' | Array<StringKeys<SO['Fields']>>;
7
7
  type FieldPath_2<SO extends SObjectDefinition, PSOR extends SO['ParentReferences'] = SO['ParentReferences']> = '*' | StringKeys<SO['Fields']> | {
8
- [K in StringKeys<PSOR>]?: '*' | FieldPath_3<Extract<PSOR[K], SObjectDefinition>>[];
8
+ [K in StringKeys<PSOR>]?: '*' | Array<FieldPath_3<Extract<PSOR[K], SObjectDefinition>>>;
9
9
  };
10
10
  type FieldPath_1<SO extends SObjectDefinition, PSOR extends SO['ParentReferences'] = SO['ParentReferences']> = '*' | StringKeys<SO['Fields']> | {
11
- [K in StringKeys<PSOR>]?: '*' | FieldPath_2<Extract<PSOR[K], SObjectDefinition>>[];
11
+ [K in StringKeys<PSOR>]?: '*' | Array<FieldPath_2<Extract<PSOR[K], SObjectDefinition>>>;
12
12
  };
13
13
  type FieldPathSpecifier_<S extends Schema, N extends string, SO extends SObjectDefinition = S['SObjects'][N], PSOR extends SO['ParentReferences'] = SO['ParentReferences']> = '*' | StringKeys<SO['Fields']> | {
14
- [K in StringKeys<PSOR>]?: '*' | FieldPath_1<Extract<PSOR[K], SObjectDefinition>>[];
14
+ [K in StringKeys<PSOR>]?: '*' | Array<FieldPath_1<Extract<PSOR[K], SObjectDefinition>>>;
15
15
  };
16
16
  export type FieldPathSpecifier<S extends Schema, N extends string> = FieldPathSpecifier_<S, N>;
17
17
  export type FieldProjectionConfigObject = {
@@ -19,7 +19,7 @@ export type Address = {
19
19
  street: string | null;
20
20
  };
21
21
  export type SObjectFieldType = number | boolean | DateString | BlobString | string | Address;
22
- export interface SObjectDefinition<N extends string = string> {
22
+ export type SObjectDefinition<N extends string = string> = {
23
23
  Name: N;
24
24
  Fields: {
25
25
  [name: string]: SObjectFieldType | null;
@@ -30,12 +30,12 @@ export interface SObjectDefinition<N extends string = string> {
30
30
  ChildRelationships: {
31
31
  [name: string]: SObjectDefinition;
32
32
  };
33
- }
34
- export interface Schema {
33
+ };
34
+ export type Schema = {
35
35
  SObjects: {
36
36
  [name: string]: SObjectDefinition;
37
37
  };
38
- }
38
+ };
39
39
  /**
40
40
  *
41
41
  */