Skip to content

Commit

Permalink
feat: Upgrade TypeScript to v5 (no-changelog) (#5755)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Mar 30, 2023
1 parent b69129b commit 87e979c
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 129 deletions.
7 changes: 7 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"declaration": false,
"sourceMap": false
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"tsc-watch": "^6.0.0",
"typescript": "*",
"turbo": "1.8.8"
},
"pnpm": {
Expand All @@ -75,8 +76,9 @@
"http-cache-semantics": "4.1.1",
"jsonwebtoken": "9.0.0",
"prettier": "^2.8.3",
"tslib": "^2.5.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"typescript": "^5.0.2",
"cpy@8>globby": "^11.1.0",
"qqjs>globby": "^11.1.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Autopilot/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export async function autopilotApiRequestAllItems(
responseData = await autopilotApiRequest.call(this, method, endpoint, body, query);
endpoint = `${base}/${responseData.bookmark}`;
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
if (query.limit && returnData.length >= query.limit && !returnAll) {
const limit = query.limit as number | undefined;
if (limit && returnData.length >= limit && !returnAll) {
return returnData;
}
} while (responseData.bookmark !== undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ export async function awsApiRequestSOAPAllItems(
returnData.push(get(responseData, propertyName) as IDataObject);
}
}
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export async function awsApiRequestSOAPAllItems(
returnData.push(get(responseData, propertyName) as IDataObject);
}
}
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/ClickUp/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export async function clickupApiRequestAllItems(
responseData = await clickupApiRequest.call(this, method, resource, body, query);
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
query.page++;
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (responseData[propertyName] && responseData[propertyName].length !== 0);
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Clockify/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export async function clockifyApiRequestAllItems(

returnData.push.apply(returnData, responseData as IDataObject[]);

if (query.limit && returnData.length >= query.limit) {
const limit = query.limit as number | undefined;
if (limit && returnData.length >= limit) {
return returnData;
}

Expand Down
9 changes: 5 additions & 4 deletions packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function goToWebinarApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
method: string,
endpoint: string,
qs: IDataObject,
query: IDataObject,
body: IDataObject,
resource: string,
) {
Expand All @@ -103,7 +103,7 @@ export async function goToWebinarApiRequestAllItems(
let responseData;

do {
responseData = await goToWebinarApiRequest.call(this, method, endpoint, qs, body);
responseData = await goToWebinarApiRequest.call(this, method, endpoint, query, body);

if (responseData.page && parseInt(responseData.page.totalElements as string, 10) === 0) {
return [];
Expand All @@ -113,8 +113,9 @@ export async function goToWebinarApiRequestAllItems(
returnData.push(...(responseData as IDataObject[]));
}

if (qs.limit && returnData.length >= qs.limit) {
returnData = returnData.splice(0, qs.limit as number);
const limit = query.limit as number | undefined;
if (limit && returnData.length >= limit) {
returnData = returnData.splice(0, limit);
return returnData;
}
} while (
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/HelpScout/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export async function helpscoutApiRequestAllItems(
responseData = await helpscoutApiRequest.call(this, method, endpoint, body, query, uri);
uri = get(responseData, '_links.next.href');
returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]);
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (responseData._links?.next?.href !== undefined);
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Hubspot/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export async function hubspotApiRequestAllItems(
}
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
//ticket:getAll endpoint does not support setting a limit, so return once the limit is reached
if (query.limit && query.limit <= returnData.length && endpoint.includes('/tickets/paged')) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length && endpoint.includes('/tickets/paged')) {
return returnData;
}
} while (responseData.hasMore || responseData['has-more'] || responseData.paging);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export async function microsoftApiRequestAllItems(
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
uri = responseData['@odata.nextLink'];
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (responseData['@odata.nextLink'] !== undefined);
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Notion/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export async function notionApiRequestAllItems(
body.start_cursor = next_cursor;
}
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (responseData.has_more !== false);
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Orbit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export async function orbitApiRequestAllItems(
}

query.page++;
if (query.limit && returnData.length >= query.limit) {
const limit = query.limit as number | undefined;
if (limit && returnData.length >= limit) {
return returnData;
}
} while (responseData.data.length !== 0);
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/S3/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export async function s3ApiRequestSOAPAllItems(
returnData.push(get(responseData, propertyName) as IDataObject);
}
}
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (
Expand Down
5 changes: 3 additions & 2 deletions packages/nodes-base/nodes/SendGrid/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ export async function sendGridApiRequestAllItems(

do {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
responseData = await sendGridApiRequest.call(this, endpoint, method, body, query, uri); // posible bug, as function does not have uri parameter
responseData = await sendGridApiRequest.call(this, endpoint, method, body, query, uri); // possible bug, as function does not have uri parameter
uri = responseData._metadata.next;
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
if (query.limit && returnData.length >= query.limit) {
const limit = query.limit as number | undefined;
if (limit && returnData.length >= limit) {
return returnData;
}
} while (responseData._metadata.next !== undefined);
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/SentryIo/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export async function sentryApiRequestAllItems(
link = responseData.headers.link;
uri = getNext(link as string);
returnData.push.apply(returnData, responseData.body as IDataObject[]);
if (query.limit && query.limit >= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit >= returnData.length) {
return;
}
} while (hasMore(link as string));
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Taiga/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export async function taigaApiRequestAllItems(
});
returnData.push.apply(returnData, responseData.body as IDataObject[]);
uri = responseData.headers['x-pagination-next'];
if (query.limit && returnData.length >= query.limit) {
const limit = query.limit as number | undefined;
if (limit && returnData.length >= limit) {
return returnData;
}
} while (
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Zendesk/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export async function zendeskApiRequestAllItems(
responseData = await zendeskApiRequest.call(this, method, resource, body, query, uri);
uri = responseData.next_page;
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
if (query.limit && query.limit <= returnData.length) {
const limit = query.limit as number | undefined;
if (limit && limit <= returnData.length) {
return returnData;
}
} while (responseData.next_page !== undefined && responseData.next_page !== null);
Expand Down
2 changes: 1 addition & 1 deletion packages/workflow/src/Extensions/ArrayExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function pluck(value: unknown[], extraArgs: unknown[]): unknown[] {
if (current && typeof current === 'object') {
const p: unknown[] = [];
Object.keys(current).forEach((k) => {
extraArgs.forEach((field: string) => {
(extraArgs as string[]).forEach((field) => {
if (current && field === k) {
p.push((current as { [key: string]: unknown })[k]);
}
Expand Down
19 changes: 10 additions & 9 deletions packages/workflow/src/Extensions/DateExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { ExpressionExtensionError } from './../ExpressionError';
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import { DateTime } from 'luxon';
import type { DateTimeUnit, DurationLike, DurationObjectUnits, LocaleOptions } from 'luxon';
import type {
DateTimeUnit,
DurationLike,
DurationObjectUnits,
LocaleOptions,
WeekdayNumbers,
} from 'luxon';
import type { ExtensionMap } from './Extensions';
import { convertToDateTime } from './utils';

Expand Down Expand Up @@ -166,15 +172,10 @@ function isInLast(date: Date | DateTime, extraArgs: unknown[]): boolean {
return dateInThePast <= thisDate && thisDate <= DateTime.now();
}

const WEEKEND_DAYS: WeekdayNumbers[] = [6, 7];
function isWeekend(date: Date | DateTime): boolean {
enum DAYS {
saturday = 6,
sunday = 7,
}
if (isDateTime(date)) {
return [DAYS.saturday, DAYS.sunday].includes(date.weekday);
}
return [DAYS.saturday, DAYS.sunday].includes(DateTime.fromJSDate(date).weekday);
const { weekday } = isDateTime(date) ? date : DateTime.fromJSDate(date);
return WEEKEND_DAYS.includes(weekday);
}

function minus(date: Date | DateTime, extraArgs: unknown[]): Date | DateTime {
Expand Down
Loading

0 comments on commit 87e979c

Please sign in to comment.