Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update dependencies, fix build errors #253

Merged
merged 4 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,301 changes: 3,959 additions & 5,342 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,31 @@
]
},
"devDependencies": {
"@apify/eslint-config-ts": "^0.1.2",
"@commitlint/config-conventional": "^13.0.0",
"@types/git-url-parse": "^9.0.0",
"@types/jest": "^27.0.0",
"@types/marked": "^2.0.2",
"@types/node": "^15.6.1",
"@types/request": "^2.48.5",
"@types/underscore": "^1.11.2",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"@apify/eslint-config-ts": "^0.1.4",
"@commitlint/config-conventional": "^13.1.0",
"@types/git-url-parse": "^9.0.1",
"@types/jest": "^27.0.1",
"@types/marked": "^3.0.0",
"@types/node": "^16.7.13",
"@types/request": "^2.48.7",
"@types/underscore": "^1.11.3",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"ajv": "^8.6.2",
"clone-deep": "^4.0.1",
"commitlint": "^13.0.0",
"deploy-web-to-s3": "^1.3.0",
"eslint": "^7.25.0",
"husky": "^7.0.0",
"jest": "^27.0.4",
"commitlint": "^13.1.0",
"deploy-web-to-s3": "^1.3.1",
"eslint": "^7.32.0",
"husky": "^7.0.2",
"jest": "^27.1.1",
"lerna": "^4.0.0",
"lint-staged": "^11.0.0",
"marked": "^3.0.0",
"nock": "^13.0.7",
"lint-staged": "^11.1.2",
"marked": "^3.0.2",
"nock": "^13.1.3",
"strip-ansi": "^6.0.0",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"typescript": "^4.2.4",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.4.2",
"underscore": "^1.13.1"
}
}
2 changes: 1 addition & 1 deletion packages/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"access": "public"
},
"dependencies": {
"git-url-parse": "^11.4.4"
"git-url-parse": "^11.6.0"
}
}
4 changes: 2 additions & 2 deletions packages/hubspot_client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"access": "public"
},
"dependencies": {
"@hubspot/api-client": "^3.4.1",
"underscore": "^1.11.0"
"@hubspot/api-client": "^4.1.0",
"underscore": "^1.13.1"
}
}
24 changes: 15 additions & 9 deletions packages/hubspot_client/src/hubspot_client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'underscore';
import hubspot, { Client } from '@hubspot/api-client';
import hubspot, { Client, HttpError } from '@hubspot/api-client';

// If customer does not have name anywhere, this is used as placeholder when creating user
export const MISSING_NAME_PLACEHOLDER = '[UNNAMED_CUSTOMER]';
Expand Down Expand Up @@ -274,7 +274,8 @@ export class HubspotClient {
try {
const response = await this.client.crm.contacts.basicApi.getById(hubspotContactId);
return response.body;
} catch (error) {
} catch (_error) {
const error = _error as HttpError;
if (error.statusCode && error.statusCode === 404) return null;
throw error;
}
Expand Down Expand Up @@ -401,7 +402,8 @@ export class HubspotClient {
await this.client.crm.contacts.basicApi.update(`${hubspotContactId}`, {
properties: data,
});
} catch (error) {
} catch (_error) {
const error = _error as HttpError;
if (error.statusCode && error.statusCode === 404) throw new Error('Hubspot record not found');
throw error;
}
Expand Down Expand Up @@ -441,7 +443,7 @@ export class HubspotClient {
limit: 1,
after: 0,
};
const response = await this.client.crm.objects.searchApi.search(this.config.invoiceObjectId, publicObjectSearchRequest);
const response = await this.client.crm.objects.searchApi.doSearch(this.config.invoiceObjectId, publicObjectSearchRequest);
const { body } = response;
return body && body.results && body.results.length ? body.results[0] : null;
}
Expand Down Expand Up @@ -469,7 +471,7 @@ export class HubspotClient {
limit: 1,
after: 0,
};
const response = await this.client.crm.objects.searchApi.search(this.config.invoiceObjectId, publicObjectSearchRequest);
const response = await this.client.crm.objects.searchApi.doSearch(this.config.invoiceObjectId, publicObjectSearchRequest);
const { body } = response;
return body && body.results && body.results.length ? body.results[0] : null;
}
Expand Down Expand Up @@ -500,7 +502,8 @@ export class HubspotClient {
try {
const response = await this.client.crm.objects.basicApi.getById(this.config.invoiceObjectId, hubspotInvoiceId);
return response.body;
} catch (error) {
} catch (_error) {
const error = _error as HttpError;
if (error.statusCode && error.statusCode === 404) return null;
throw error;
}
Expand Down Expand Up @@ -595,7 +598,8 @@ export class HubspotClient {
await this.client.crm.objects.basicApi.update(this.config.invoiceObjectId, `${hubspotInvoiceId}`, {
properties: data,
});
} catch (error) {
} catch (_error) {
const error = _error as HttpError;
if (error.statusCode && error.statusCode === 404) throw new Error('Hubspot record not found');
throw error;
}
Expand Down Expand Up @@ -724,7 +728,8 @@ export class HubspotClient {
await this.client.crm.companies.basicApi.update(`${hubspotCompanyId}`, {
properties: data,
});
} catch (error) {
} catch (_error) {
const error = _error as HttpError;
if (error.statusCode && error.statusCode === 404) throw new Error('Hubspot record not found');
throw error;
}
Expand All @@ -744,7 +749,8 @@ export class HubspotClient {
`${hubspotContactId}`,
'company_to_contact',
);
} catch (error) {
} catch (_error) {
const error = _error as HttpError;
if (error.statusCode && error.statusCode === 404) throw new Error('Hubspot record not found');
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"@apify/consts": "^1.3.0",
"@apify/utilities": "^1.1.5",
"marked": "^3.0.0",
"marked": "^3.0.2",
"match-all": "^1.2.6"
}
}
4 changes: 2 additions & 2 deletions packages/markdown/src/marked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ interface MarkedResponse {
export const apifyMarked = (markdown: string): MarkedResponse => {
const renderer = new Renderer();
renderer.heading = customHeadingRenderer;
renderer.code = (code, language) => {
renderer.code = function (code, language) {
if (language) {
return code;
}
return DEFAULT_MARKED_RENDERER.code(code, language, false);
return DEFAULT_MARKED_RENDERER.code.call(this, code, language, false);
};
const tokens = lexer(markdown);

Expand Down
4 changes: 2 additions & 2 deletions packages/salesforce_client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"access": "public"
},
"dependencies": {
"axios": "^0.21.1",
"underscore": "^1.11.0"
"axios": "^0.21.4",
"underscore": "^1.13.1"
}
}
22 changes: 14 additions & 8 deletions packages/salesforce_client/src/salesforce_client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'underscore';
import axios, { Method } from 'axios';
import axios, { AxiosError, Method } from 'axios';
import { URLSearchParams } from 'url';

const AUTH_RETRY_ATTEMPTS = 5;
Expand Down Expand Up @@ -230,14 +230,16 @@ export class SalesforceClient {
});

return response.data;
} catch (error) {
} catch (_error) {
const error = _error as AxiosError;

const maybeStatus = error.response && error.response.status
? error.response && error.response.status
: null;

// NOTE: Multiple choices, it is not an error
if (maybeStatus === 300) {
return error.response.data;
return error.response!.data;
}

// Catch authentication error this means that token expired and we need a new one
Expand Down Expand Up @@ -279,7 +281,8 @@ export class SalesforceClient {
async getAccount(userId: string): Promise<Record<string, any> | null> {
try {
return await this._callApexrestApi(`ApifyAccount/${userId}`, 'GET');
} catch (error) {
} catch (_error) {
const error = _error as Error;
if (error.message === NOT_FOUND_MESSAGE) {
return null;
}
Expand Down Expand Up @@ -368,7 +371,9 @@ export class SalesforceClient {
async getInvoice(invoiceId: string): Promise<Record<string, any> | null> {
try {
return await this._callApexrestApi(`ApifyInvoice/${invoiceId}`, 'GET');
} catch (error) {
} catch (_error) {
const error = _error as Error;

if (error.message === NOT_FOUND_MESSAGE) {
return null;
}
Expand Down Expand Up @@ -443,11 +448,12 @@ export class SalesforceClient {
lead = await this._callApi(lead[0], 'GET');
}
return lead;
} catch (err) {
if (err.message === NOT_FOUND_MESSAGE) {
} catch (_error) {
const error = _error as Error;
if (error.message === NOT_FOUND_MESSAGE) {
return null;
}
throw err;
throw error;
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/utilities/src/health_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class HealthChecker {
try {
const checkPromise = this._performCheck(check);
await timeoutPromise(checkPromise, this.checkTimeoutMillis, 'Check has timed-out');
} catch (err) {
} catch (_err) {
const err = _err as Error;
throw new Error(`Health check test "${check.type}" failed with an error: ${err.message}"`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/src/parse_jsonl_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ParseJsonlStream extends Transform {
this.parseLineAndEmitObject(lines[i]);
}
} catch (err) {
callback(err, null);
callback(err as Error, null);
return;
}

Expand All @@ -76,7 +76,7 @@ export class ParseJsonlStream extends Transform {
this.parseLineAndEmitObject(this.pendingChunk);
this.pendingChunk = null;
} catch (err) {
callback(err, null);
callback(err as Error, null);
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function betterClearInterval(intervalID: { _betterClearInterval: () => vo
// eslint-disable-next-line no-underscore-dangle
intervalID._betterClearInterval();
} catch (e) {
log.exception(e, '_betterClearInterval() threw an exception!?');
log.exception(e as Error, '_betterClearInterval() threw an exception!?');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/src/webhook_payload_template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class WebhookPayloadTemplate {
} else {
// When we catch an error from JSON.parse, but there's
// no variable, we must have an invalid JSON.
throw new InvalidJsonError(err);
throw new InvalidJsonError(err as Error);
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions test/exponential_backoff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ describe('exponential_backoff', () => {
expBackoffMaxRepeats: 5,
expBackoffMillis: 100,
});
} catch (e) {
} catch (_e) {
const e = _e as Error;
expect(e.message).toBe(ERROR_MESSAGE);
expect(funcCalledTimes).toBe(1);
}
Expand All @@ -59,50 +60,50 @@ describe('exponential_backoff', () => {
expBackoffMillis: 50,
});
} catch (e) {
error = e;
error = e as Error;
}
expect(error.message).toBe(ERROR_MESSAGE);
expect(error instanceof Error).toBe(true);
expect(funcCalledTimes).toBe(RETRY_COUNT);
}, 15e3);

it('should validate func param', async () => {
let error;
let error!: Error;
try {
// @ts-expect-error
await retryWithExpBackoff({ func: 'String', expBackoffMaxRepeats: 10, expBackoffMillis: 100 });
} catch (e) {
error = e;
error = e as Error;
}
expect(error.message).toBe('Parameter "func" should be a function.');
});

it('should validate expBackoffMaxRepeats param', async () => {
let error;
let error!: Error;
try {
// @ts-expect-error
await retryWithExpBackoff({ func: () => {}, expBackoffMaxRepeats: 'String', expBackoffMillis: 100 });
} catch (e) {
error = e;
error = e as Error;
}
expect(error.message).toBe('Parameter "expBackoffMaxRepeats" should be a number.');
});

it('should validate expBackoffMillis param', async () => {
let error;
let error!: Error;
try {
// @ts-expect-error
await retryWithExpBackoff({ func: () => {}, expBackoffMaxRepeats: 5, expBackoffMillis: 'String' });
} catch (e) {
error = e;
error = e as Error;
}
expect(error.message).toBe('Parameter "expBackoffMillis" should be a number.');
});

it('should display correct message after 1/2 of retries', async () => {
const logWarningSpy = jest.spyOn(log, 'warning');

let error;
let error!: Exception;
try {
await retryWithExpBackoff({
func: async () => {
Expand All @@ -114,7 +115,7 @@ describe('exponential_backoff', () => {
expBackoffMillis: 10,
});
} catch (e) {
error = e;
error = e as Exception;
}
expect(error.message).toBe('Failed because of XXX');
expect(error.details).toEqual({ foo: 'bar' });
Expand Down
Loading