refactor(core): Introduce overload for number-type node parameter (no-changelog) (#4644)

* 📘 Set up overloads

* 📘 Add temporary assertion

* 🔥 Remove inferrable number assertions

* ✏️ Add ticket ref
This commit is contained in:
Iván Ovejero
2022-11-18 15:26:22 +01:00
committed by GitHub
parent 600b285a44
commit 0565194473
166 changed files with 783 additions and 689 deletions

View File

@@ -47,7 +47,9 @@ export class NotionV1 implements INodeType {
loadOptions: {
async getDatabaseProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const databaseId = this.getCurrentNodeParameter('databaseId', { extractValue: true }) as string;
const databaseId = this.getCurrentNodeParameter('databaseId', {
extractValue: true,
}) as string;
const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
for (const key of Object.keys(properties)) {
//remove parameters that cannot be set from the API.
@@ -81,7 +83,9 @@ export class NotionV1 implements INodeType {
},
async getFilterProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const databaseId = this.getCurrentNodeParameter('databaseId', { extractValue: true }) as string;
const databaseId = this.getCurrentNodeParameter('databaseId', {
extractValue: true,
}) as string;
const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
for (const key of Object.keys(properties)) {
returnData.push({
@@ -105,7 +109,9 @@ export class NotionV1 implements INodeType {
},
async getPropertySelectValues(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const [name, type] = (this.getCurrentNodeParameter('&key') as string).split('|');
const databaseId = this.getCurrentNodeParameter('databaseId', { extractValue: true }) as string;
const databaseId = this.getCurrentNodeParameter('databaseId', {
extractValue: true,
}) as string;
const resource = this.getCurrentNodeParameter('resource') as string;
const operation = this.getCurrentNodeParameter('operation') as string;
const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
@@ -142,7 +148,9 @@ export class NotionV1 implements INodeType {
},
async getDatabaseIdFromPage(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const pageId = extractPageId(this.getCurrentNodeParameter('pageId', { extractValue: true }) as string);
const pageId = extractPageId(
this.getCurrentNodeParameter('pageId', { extractValue: true }) as string,
);
const {
parent: { database_id: databaseId },
} = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`);
@@ -180,7 +188,9 @@ export class NotionV1 implements INodeType {
async getDatabaseOptionsFromPage(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const pageId = extractPageId(this.getCurrentNodeParameter('pageId', { extractValue: true }) as string);
const pageId = extractPageId(
this.getCurrentNodeParameter('pageId', { extractValue: true }) as string,
);
const [name, type] = (this.getCurrentNodeParameter('&key') as string).split('|');
const {
parent: { database_id: databaseId },
@@ -228,7 +238,9 @@ export class NotionV1 implements INodeType {
if (resource === 'block') {
if (operation === 'append') {
for (let i = 0; i < length; i++) {
const blockId = extractPageId(this.getNodeParameter('blockId', i, '', { extractValue: true }) as string);
const blockId = extractPageId(
this.getNodeParameter('blockId', i, '', { extractValue: true }) as string,
);
const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[];
extractDatabaseMentionRLC(blockValues);
const body: IDataObject = {
@@ -262,7 +274,7 @@ export class NotionV1 implements INodeType {
{},
);
} else {
qs.page_size = this.getNodeParameter('limit', i) as number;
qs.page_size = this.getNodeParameter('limit', i);
responseData = await notionApiRequest.call(
this,
'GET',
@@ -285,7 +297,9 @@ export class NotionV1 implements INodeType {
if (resource === 'database') {
if (operation === 'get') {
for (let i = 0; i < length; i++) {
const databaseId = extractDatabaseId(this.getNodeParameter('databaseId', i, '', { extractValue: true }) as string);
const databaseId = extractDatabaseId(
this.getNodeParameter('databaseId', i, '', { extractValue: true }) as string,
);
responseData = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
const executionData = this.helpers.constructExecutionMetaData(
@@ -311,7 +325,7 @@ export class NotionV1 implements INodeType {
body,
);
} else {
body['page_size'] = this.getNodeParameter('limit', i) as number;
body['page_size'] = this.getNodeParameter('limit', i);
responseData = await notionApiRequest.call(this, 'POST', `/search`, body);
responseData = responseData.results;
}
@@ -334,7 +348,9 @@ export class NotionV1 implements INodeType {
parent: {},
properties: {},
};
body.parent['database_id'] = this.getNodeParameter('databaseId', i, '', { extractValue: true }) as string;
body.parent['database_id'] = this.getNodeParameter('databaseId', i, '', {
extractValue: true,
}) as string;
const properties = this.getNodeParameter(
'propertiesUi.propertyValues',
i,
@@ -402,7 +418,7 @@ export class NotionV1 implements INodeType {
{},
);
} else {
body.page_size = this.getNodeParameter('limit', i) as number;
body.page_size = this.getNodeParameter('limit', i);
responseData = await notionApiRequest.call(
this,
'POST',
@@ -426,7 +442,9 @@ export class NotionV1 implements INodeType {
if (operation === 'update') {
for (let i = 0; i < length; i++) {
const pageId = extractPageId(this.getNodeParameter('pageId', i, '', { extractValue: true }) as string);
const pageId = extractPageId(
this.getNodeParameter('pageId', i, '', { extractValue: true }) as string,
);
const simple = this.getNodeParameter('simple', i) as boolean;
const properties = this.getNodeParameter(
'propertiesUi.propertyValues',
@@ -473,7 +491,7 @@ export class NotionV1 implements INodeType {
if (returnAll) {
responseData = await notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
qs.limit = this.getNodeParameter('limit', i);
responseData = await notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
responseData = responseData.splice(0, qs.limit);
}
@@ -496,7 +514,9 @@ export class NotionV1 implements INodeType {
parent: {},
properties: {},
};
body.parent['page_id'] = extractPageId(this.getNodeParameter('pageId', i, '', { extractValue: true }) as string);
body.parent['page_id'] = extractPageId(
this.getNodeParameter('pageId', i, '', { extractValue: true }) as string,
);
body.properties = formatTitle(this.getNodeParameter('title', i) as string);
const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[];
extractDatabaseMentionRLC(blockValues);
@@ -561,7 +581,7 @@ export class NotionV1 implements INodeType {
body,
);
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
qs.limit = this.getNodeParameter('limit', i);
responseData = await notionApiRequestAllItems.call(
this,
'results',