Skip to content

Commit 37e6a2d

Browse files
author
Olha Virolainen
authored
Update sailor version to 2.6.17 (#3)
Update sailor version to 2.6.17
1 parent bfaf482 commit 37e6a2d

17 files changed

+160
-37
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.1 (October 23, 2020)
2+
3+
* Update sailor version to 2.6.17
4+
15
## 2.0.0 (October 2, 2020)
26

37
* First commit of v2 branch. See https://github.com/elasticio/salesforce-component for the v1 component version details

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![CircleCI](https://circleci.com/gh/elasticio/salesforce-component.svg)](https://circleci.com/gh/elasticio/salesforce-component)
1+
[![CircleCI](https://circleci.com/gh/elasticio/salesforce-component-v2.svg?style=svg&circle-token=4407ac16eb7e472a4533a176ca180c2c89d41777)](https://circleci.com/gh/elasticio/salesforce-component-v2)
22
# Salesforce Component
33
## Table of Contents
44

lib/actions/lookupObject.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ module.exports.process = async function processAction(message, configuration) {
8383

8484
lookupCache.useCache(configuration.enableCacheUsage);
8585
const queryKey = lookupCache.generateKeyFromDataArray(configuration.sobject, whereCondition);
86-
this.logger.trace(`Current request key hash: "${queryKey}"`);
8786
if (lookupCache.hasKey(queryKey)) {
8887
this.logger.info('Cached response found!');
8988
const response = lookupCache.getResponse(queryKey);

lib/actions/lookupObjects.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ module.exports.process = async function processAction(message, configuration) {
188188
this.logger.debug(`Preparing to query ${configuration.sobject} objects...`);
189189
this.logger.debug('Building a wherePart...');
190190
const wherePart = await getWherePart.call(this, message, configuration);
191-
this.logger.trace('Where part: ', wherePart);
192191

193192
let limit;
194193
let offset;
@@ -217,7 +216,6 @@ module.exports.process = async function processAction(message, configuration) {
217216
lookupCache.useCache(configuration.enableCacheUsage);
218217
const queryKey = lookupCache.generateKeyFromDataArray(configuration.sobject, wherePart,
219218
offset, limit, configuration.includeDeleted);
220-
this.logger.trace(`Current request key hash: "${queryKey}"`);
221219
if (lookupCache.hasKey(queryKey)) {
222220
this.logger.info('Cached response found!');
223221
records = lookupCache.getResponse(queryKey);

lib/actions/query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports.process = async function processAction(message, configuration) {
99
throw new Error('batchSize must be a number');
1010
}
1111
const { query } = message.body;
12-
this.logger.trace('Starting SOQL Select batchSize=%s query=%s', batchSize, query);
12+
this.logger.debug('Starting SOQL Select: batchSize=%s', batchSize);
1313
if (configuration.allowResultAsSet) {
1414
this.logger.info('Selected EmitAllHandler');
1515
const result = await callJSForceMethod.call(this, configuration, 'queryEmitAll', query);

lib/actions/upsert.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,22 @@ module.exports.process = async function upsertObject(message, configuration) {
3737
const { sobject } = configuration;
3838
if (message.body.Id) {
3939
configuration.lookupField = 'Id';
40-
this.logger.info('Upserting sobject=%s by internalId', sobject);
41-
this.logger.trace('Upserting sobject=%s by internalId=%s, data: %j', sobject, message.body.Id, message);
40+
this.logger.debug('Upserting sobject=%s by internalId', sobject);
41+
this.logger.trace('Upserting sobject=%s by internalId=%s', sobject, message.body.Id);
4242
await callJSForceMethod.call(this, configuration, 'sobjectUpdate', message);
4343
} else {
4444
if (!configuration.extIdField) {
4545
throw Error('Can not find internalId/externalId ids');
4646
}
4747
configuration.lookupField = configuration.extIdField;
48-
this.logger.info('Upserting sobject=%s by externalId', sobject);
49-
this.logger.trace('Upserting sobject=%s by externalId=%s, data: %j', sobject, configuration.extIdField, message);
48+
this.logger.debug('Upserting sobject=%s by externalId', sobject);
49+
this.logger.trace('Upserting sobject=%s by externalId=%s', sobject, configuration.extIdField);
5050
await callJSForceMethod.call(this, configuration, 'sobjectUpsert', message);
5151
}
5252

5353
const lookupResults = await callJSForceMethod.call(this, configuration, 'sobjectLookup', message);
5454
if (lookupResults.length === 1) {
55-
this.logger.info('sobject=%s was successfully upserted by %s', sobject, configuration.lookupField);
56-
this.logger.trace('sobject=%s was successfully upserted by %s=%s', sobject, configuration.lookupField, message.body[configuration.lookupField]);
55+
this.logger.debug('sobject=%s was successfully upserted by %s', sobject, configuration.lookupField);
5756
await this.emit('data', messages.newMessageWithBody(lookupResults[0]));
5857
return;
5958
}

lib/entry.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@ module.exports.process = async function process(message, configuration, snapshot
2525
snapshot = {
2626
previousLastModified: configuration.startTime || '1970-01-01T00:00:00.000Z',
2727
};
28-
this.logger.trace('Created snapshot: %j', snapshot);
2928
} else if (typeof snapshot === 'string') {
3029
// for backward compatibility
3130
snapshot = { previousLastModified: snapshot };
32-
this.logger.trace('Snapshot has been converted to: %j', snapshot);
31+
this.logger.debug('Snapshot has been converted');
3332
} else {
34-
this.logger.trace('Got snapshot: %j', snapshot);
33+
this.logger.debug('Snapshot received');
3534
}
3635
const { linkedObjects = [] } = configuration;
3736
const singlePagePerInterval = (configuration.singlePagePerInterval !== 'no');
3837
const maxTime = configuration.endTime ? ` AND LastModifiedDate <= ${configuration.endTime}` : '';
3938
let hasMorePages = true;
4039
let lastSeenTime = snapshot.previousLastModified;
41-
let maxFetch = configuration.maxFetch ? configuration.parseInt(configuration.maxFetch, 10) : 1000;
40+
let maxFetch = configuration.maxFetch ? parseInt(configuration.maxFetch, 10) : 1000;
4241

4342
if (configuration.sizeOfPollingPage) {
4443
this.logger.debug('Current sizeOfPollingPage=%s, maxFetch=%s', configuration.sizeOfPollingPage, maxFetch);
@@ -98,7 +97,7 @@ module.exports.process = async function process(message, configuration, snapshot
9897

9998
if (snapshot.previousLastModified !== lastSeenTime) {
10099
snapshot.previousLastModified = lastSeenTime;
101-
this.logger.trace('emitting new snapshot: %j', snapshot);
100+
this.logger.debug('emitting new snapshot...');
102101
await this.emit('snapshot', snapshot);
103102
}
104103
await this.emit('end');

lib/helpers/wrapper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ exports.callJSForceMethod = async function callJSForceMethod(configuration, meth
2727
iteration -= 1;
2828
try {
2929
this.logger.debug('Iteration: %s', REFRESH_TOKEN_RETRIES - iteration);
30-
this.logger.trace('AccessToken = %s, Iteration: %s', accessToken, REFRESH_TOKEN_RETRIES - iteration);
3130
const cfg = {
3231
...configuration,
3332
access_token: accessToken,
@@ -44,15 +43,15 @@ exports.callJSForceMethod = async function callJSForceMethod(configuration, meth
4443
this.logger.debug('Method %s was successfully executed', method);
4544
break;
4645
} catch (e) {
47-
this.logger.error('Got error: ', e);
46+
this.logger.error('Got error %s', e.name || '');
4847
if (e.name === 'INVALID_SESSION_ID') {
4948
try {
5049
this.logger.debug('Session is expired, trying to refresh token...');
5150
accessToken = await refreshToken(this, secretId);
5251
this.logger.debug('Token is successfully refreshed');
5352
client = undefined;
5453
} catch (err) {
55-
this.logger.error(err, 'Failed to refresh token');
54+
this.logger.error('Failed to refresh token');
5655
}
5756
} else {
5857
throw e;

lib/salesForceClient.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ class SalesForceClient {
241241
})
242242
.execute({ autoFetch: true, maxFetch: limit });
243243
} catch (e) {
244-
this.logger.trace('Lookup query failed', e);
245244
this.logger.error('Lookup query failed');
246245
throw e;
247246
}

lib/triggers/query.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ const { callJSForceMethod } = require('../helpers/wrapper');
44
exports.process = async function processTrigger(msg, configuration) {
55
this.logger.info('Starting Query trigger');
66
const { query, outputMethod = 'emitIndividually' } = configuration;
7-
const records = await callJSForceMethod.call(this, configuration, 'queryEmitAll', query);
7+
let records;
8+
try {
9+
records = await callJSForceMethod.call(this, configuration, 'queryEmitAll', query);
10+
} catch (e) {
11+
const errorMsg = e.message ? e.message.replace(query, '').replace(/\s+/g, ' ').trim() : 'Error occurred during query execution';
12+
const error = new Error(errorMsg);
13+
error.name = e.name || 'unknown error';
14+
this.logger.error(errorMsg);
15+
throw errorMsg;
16+
}
817
if (records.length === 0) {
918
await this.emit('data', messages.newEmptyMessage());
1019
} else if (outputMethod === 'emitAll') {

0 commit comments

Comments
 (0)