mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
277b6b73c3
* use resource locator component for database -> get (Notion V1/V2) * getDatabases search function for V1/V2 with url * updated database get list placeholder * get database RLC by url - regex support optional workspace domain names * fixed linting error * listSearch getDatabases support filter query * support extractValue in getCurrentNodeParameter for RLC * RLC for database page create/getAll operation * RLC for database get operation support "By ID" with optional v param. * use RLC in append blocks operation * use RLC in NotionTrigger.nodes.ts * removed unused loadOptions getDatabases * support database RLC in createPage/createDbPage operation * page create operation use RLC for parent page param * page archive operation use RLC for page param * removed unused imports * fixed missing extractPageId in NotionV1.node.ts * database page get operation use RLC for page param * database page update operation use RLC for page param * block getAll children operation use RLC for page param * block append operation use RLC for block param * support databaseId with optional '-' characters * support blockId with optional '-' characters * support pageId with optional '-' characters * improved RLC descriptions and hints * NotionTrigger node support databseId with optional '-' characters * stricter RLC by ID regex rules for uuids * stricter RLC by URL regex rules for uuids * stricter RLC by ID regex rules for uuids (support max length) * RLC regex from URL allow both http and https * RLC by ID only allow uuid v4 with optional dash * removed RLC from URL hint "Use Notion's copy link..." * RLC from URL only allow uuid v4 * DB Status Column: Support Simplify Properties * Notion Credentials: Support custom Notion-Version header Use latest Notion-Version 2022-02-22 if not set * DB Status Column: Support DB Page Create/Update * DB Status Column: Support DB Page GetMany Filters * removed unused paginationToken args * Database Get: RLC by URL improve validation error message
39 lines
989 B
TypeScript
39 lines
989 B
TypeScript
import { IDataObject, ILoadOptionsFunctions, INodeListSearchItems, INodeListSearchResult } from "n8n-workflow";
|
|
import { notionApiRequestAllItems } from "./GenericFunctions";
|
|
|
|
export async function getDatabases(
|
|
this: ILoadOptionsFunctions,
|
|
filter?: string,
|
|
): Promise<INodeListSearchResult> {
|
|
const returnData: INodeListSearchItems[] = [];
|
|
const body: IDataObject = {
|
|
page_size: 100,
|
|
query: filter,
|
|
filter: { property: 'object', value: 'database' },
|
|
};
|
|
const databases = await notionApiRequestAllItems.call(
|
|
this,
|
|
'results',
|
|
'POST',
|
|
`/search`,
|
|
body,
|
|
);
|
|
for (const database of databases) {
|
|
returnData.push({
|
|
name: database.title[0]?.plain_text || database.id,
|
|
value: database.id,
|
|
url: database.url,
|
|
});
|
|
}
|
|
returnData.sort((a, b) => {
|
|
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
|
|
return -1;
|
|
}
|
|
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
});
|
|
return { results: returnData };
|
|
}
|