From a4335c5922508342c4041b44bd07ab7ac480008c Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 24 Aug 2020 10:56:31 -0400 Subject: [PATCH 0001/1173] v2.0.0 --- lerna.json | 2 +- packages/notion-client/package.json | 6 +++--- packages/notion-types/package.json | 2 +- packages/notion-utils/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index b06e531d..486c1972 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.2", + "version": "2.0.0", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 01037e3d..4f052d02 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "1.3.2", + "version": "2.0.0", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "saasify-sh/notion-kit", "author": "Saasify ", @@ -16,8 +16,8 @@ }, "dependencies": { "got": "^11.5.2", - "notion-types": "^1.3.2", - "notion-utils": "^1.3.2", + "notion-types": "^2.0.0", + "notion-utils": "^2.0.0", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-types/package.json b/packages/notion-types/package.json index c0d62d22..3de1d2c6 100644 --- a/packages/notion-types/package.json +++ b/packages/notion-types/package.json @@ -1,6 +1,6 @@ { "name": "notion-types", - "version": "1.3.2", + "version": "2.0.0", "description": "TypeScript types for core Notion data structures.", "repository": "saasify-sh/notion-kit", "author": "Saasify ", diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index c5ec4ea9..215f1adf 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "1.3.2", + "version": "2.0.0", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "saasify-sh/notion-kit", "author": "Saasify ", @@ -15,7 +15,7 @@ "test": "ava -v 'build/cjs/**/*.test.js'" }, "dependencies": { - "notion-types": "^1.3.2" + "notion-types": "^2.0.0" }, "devDependencies": { "ava": "^3.11.1", From 3ca2e1edcf08cd0bf31880917b6527501cb03bf6 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 24 Aug 2020 23:11:52 -0400 Subject: [PATCH 0002/1173] =?UTF-8?q?=E2=93=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/notion-client/example.js | 39 +++++++++++++----------- packages/notion-client/src/notion-api.ts | 9 +++--- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/notion-client/example.js b/packages/notion-client/example.js index 944fa730..f07bed10 100644 --- a/packages/notion-client/example.js +++ b/packages/notion-client/example.js @@ -1,4 +1,4 @@ -const { NotionAPI } = require('./build') +const { NotionAPI } = require('./build/cjs') async function main() { const api = new NotionAPI() @@ -7,25 +7,30 @@ async function main() { // const output = await api.getPage('067dd719-a912-471e-a9a3-ac10710e7fdf') // const output = await api.getPage('139ac7d730d54b5e93937a282d8ff635') // const output = await api.getPage('8a586d253f984b85b48254da84465d23') - const output = await api.getPage('b21b2ed02ad446b2af74ee6e262e2124') + // const output = await api.getPage('b21b2ed02ad446b2af74ee6e262e2124') + try { + const output = await api.getPage('3f759cf9d8fe44a5988e0c3b6903e224') - // collection example - // const collectionId = '2d8aec23-8281-4a94-9090-caaf823dd21a' - // const collectionViewId = 'ab639a5a-853e-45e1-9ef7-133b486c0acf' - // const output = await api.getCollectionData(collectionId, collectionViewId) + // collection example + // const collectionId = '2d8aec23-8281-4a94-9090-caaf823dd21a' + // const collectionViewId = 'ab639a5a-853e-45e1-9ef7-133b486c0acf' + // const output = await api.getCollectionData(collectionId, collectionViewId) - // signed url example - // const file = { - // permissionRecord: { - // id: 'd142a056-f104-477c-96d5-2b03fdd8c6e3', - // table: 'block' - // }, - // url: - // 'https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f428f70f-aadc-45e3-acdc-72f762c2fbc9/Aaron_Wang_Design_Resume.pdf' - // } - // const output = await api.getSignedFileUrls([file]) + // signed url example + // const file = { + // permissionRecord: { + // id: 'd142a056-f104-477c-96d5-2b03fdd8c6e3', + // table: 'block' + // }, + // url: + // 'https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f428f70f-aadc-45e3-acdc-72f762c2fbc9/Aaron_Wang_Design_Resume.pdf' + // } + // const output = await api.getSignedFileUrls([file]) - console.log(JSON.stringify(output, null, 2)) + console.log(JSON.stringify(output, null, 2)) + } catch (err) { + console.error(err) + } } main() diff --git a/packages/notion-client/src/notion-api.ts b/packages/notion-client/src/notion-api.ts index c52c5073..430e4a5b 100644 --- a/packages/notion-client/src/notion-api.ts +++ b/packages/notion-client/src/notion-api.ts @@ -1,8 +1,7 @@ -// import { promises as fs } from 'fs' import got from 'got' import pMap from 'p-map' -import { parsePageId, getPageContentBlockIds } from 'notion-utils' +import { parsePageId, getPageContentBlockIds, uuidToId } from 'notion-utils' import * as notion from 'notion-types' import * as types from './types' @@ -43,10 +42,10 @@ export class NotionAPI { } = {} ): Promise { const page = await this.getPageRaw(pageId) - const recordMap = page.recordMap as notion.ExtendedRecordMap + const recordMap = page?.recordMap as notion.ExtendedRecordMap - if (!recordMap.block) { - throw new Error(`Notion page not found "${pageId}"`) + if (!recordMap?.block) { + throw new Error(`Notion page not found "${uuidToId(pageId)}"`) } // ensure that all top-level maps exist From 9604958311bb4e2d0dc763e00ff189da8bfa0fe3 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Aug 2020 07:54:07 -0400 Subject: [PATCH 0003/1173] feat: add a few more util methods --- packages/notion-utils/src/get-block-title.ts | 21 ++++++++++++++++++++ packages/notion-utils/src/get-page-title.ts | 12 +++++++++++ packages/notion-utils/src/index.ts | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 packages/notion-utils/src/get-block-title.ts create mode 100644 packages/notion-utils/src/get-page-title.ts diff --git a/packages/notion-utils/src/get-block-title.ts b/packages/notion-utils/src/get-block-title.ts new file mode 100644 index 00000000..08259a8f --- /dev/null +++ b/packages/notion-utils/src/get-block-title.ts @@ -0,0 +1,21 @@ +import { Block, ExtendedRecordMap } from 'notion-types' +import { getTextContent } from './get-text-content' + +export function getBlockTitle(block: Block, recordMap: ExtendedRecordMap) { + if (block.properties?.title) { + return getTextContent(block.properties.title) + } + + if ( + block.type === 'collection_view_page' || + block.type === 'collection_view' + ) { + const collection = recordMap.collection[block.collection_id]?.value + + if (collection) { + return getTextContent(collection.name) + } + } + + return null +} diff --git a/packages/notion-utils/src/get-page-title.ts b/packages/notion-utils/src/get-page-title.ts new file mode 100644 index 00000000..5b4aace1 --- /dev/null +++ b/packages/notion-utils/src/get-page-title.ts @@ -0,0 +1,12 @@ +import { ExtendedRecordMap } from 'notion-types' +import { getBlockTitle } from './get-block-title' + +export function getPageTitle(recordMap: ExtendedRecordMap) { + const pageBlock = recordMap.block[Object.keys(recordMap.block)[0]]?.value + + if (pageBlock) { + return getBlockTitle(pageBlock, recordMap) + } + + return null +} diff --git a/packages/notion-utils/src/index.ts b/packages/notion-utils/src/index.ts index 14824e78..d1ec1a92 100644 --- a/packages/notion-utils/src/index.ts +++ b/packages/notion-utils/src/index.ts @@ -1,4 +1,6 @@ export * from './get-text-content' +export * from './get-block-title' +export * from './get-page-title' export * from './get-date-value' export * from './get-block-parent-page' export * from './get-page-table-of-contents' From 823ba1130e54712e58f747ae7a2d887f6912a747 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Aug 2020 07:54:19 -0400 Subject: [PATCH 0004/1173] v2.1.0 --- lerna.json | 2 +- packages/notion-client/package.json | 4 ++-- packages/notion-utils/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index 486c1972..33821e6d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.0.0", + "version": "2.1.0", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 4f052d02..b04afeec 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.0.0", + "version": "2.1.0", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "saasify-sh/notion-kit", "author": "Saasify ", @@ -17,7 +17,7 @@ "dependencies": { "got": "^11.5.2", "notion-types": "^2.0.0", - "notion-utils": "^2.0.0", + "notion-utils": "^2.1.0", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index 215f1adf..2a4f612a 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.0.0", + "version": "2.1.0", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "saasify-sh/notion-kit", "author": "Saasify ", From 3abbcd590e7efd37a2cfe1330b33b4d30a583af9 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Aug 2020 08:27:03 -0400 Subject: [PATCH 0005/1173] chore: move to Notion X github organization --- package.json | 4 ++-- packages/notion-client/package.json | 2 +- packages/notion-client/readme.md | 6 +++--- packages/notion-types/package.json | 2 +- packages/notion-types/readme.md | 6 +++--- packages/notion-utils/package.json | 2 +- packages/notion-utils/readme.md | 6 +++--- readme.md | 10 +++++----- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 3c417beb..871045d9 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "notion", "private": true, "description": "TS packages for Notion's unofficial API, data types, and related utilities.", - "repository": "saasify-sh/notion-kit", - "author": "Travis Fischer ", + "repository": "notion-x/notion-kit", + "author": "Travis Fischer ", "license": "MIT", "engines": { "node": ">=12" diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index b04afeec..274bb294 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -2,7 +2,7 @@ "name": "notion-client", "version": "2.1.0", "description": "Robust TypeScript client for the unofficial Notion API.", - "repository": "saasify-sh/notion-kit", + "repository": "notion-x/notion-kit", "author": "Saasify ", "license": "MIT", "main": "build/cjs/index.js", diff --git a/packages/notion-client/readme.md b/packages/notion-client/readme.md index 6610373f..cbc1271c 100644 --- a/packages/notion-client/readme.md +++ b/packages/notion-client/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# notion-client > Robust TypeScript client for the unofficial Notion API. -[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/saasify-sh/notion-kit.svg?branch=master)](https://travis-ci.com/saasify-sh/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Install @@ -38,7 +38,7 @@ const colectionData = await api.getCollectionData( ## Docs -See the [auto-generated docs](https://github.com/saasify-sh/notion-kit/blob/master/docs/notion-client.md). +See the [auto-generated docs](https://github.com/notion-x/notion-kit/blob/master/docs/notion-client.md). ## License diff --git a/packages/notion-types/package.json b/packages/notion-types/package.json index 3de1d2c6..68547179 100644 --- a/packages/notion-types/package.json +++ b/packages/notion-types/package.json @@ -2,7 +2,7 @@ "name": "notion-types", "version": "2.0.0", "description": "TypeScript types for core Notion data structures.", - "repository": "saasify-sh/notion-kit", + "repository": "notion-x/notion-kit", "author": "Saasify ", "license": "MIT", "main": "build/cjs/index.js", diff --git a/packages/notion-types/readme.md b/packages/notion-types/readme.md index 6357d626..f53d36e3 100644 --- a/packages/notion-types/readme.md +++ b/packages/notion-types/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# notion-types > TypeScript types for core Notion data structures. -[![NPM](https://img.shields.io/npm/v/notion-types.svg)](https://www.npmjs.com/package/notion-types) [![Build Status](https://travis-ci.com/saasify-sh/notion-kit.svg?branch=master)](https://travis-ci.com/saasify-sh/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-types.svg)](https://www.npmjs.com/package/notion-types) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Install @@ -24,7 +24,7 @@ import * as notion from 'notion-types' ## Docs -See the [auto-generated docs](https://github.com/saasify-sh/notion-kit/blob/master/docs/notion-types.md). +See the [auto-generated docs](https://github.com/notion-x/notion-kit/blob/master/docs/notion-types.md). ## License diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index 2a4f612a..23e54852 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -2,7 +2,7 @@ "name": "notion-utils", "version": "2.1.0", "description": "Useful utilities for working with Notion data. Isomorphic.", - "repository": "saasify-sh/notion-kit", + "repository": "notion-x/notion-kit", "author": "Saasify ", "license": "MIT", "main": "build/cjs/index.js", diff --git a/packages/notion-utils/readme.md b/packages/notion-utils/readme.md index 5daecd74..5df87609 100644 --- a/packages/notion-utils/readme.md +++ b/packages/notion-utils/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# notion-utils > Useful utilities for working with Notion data. Isomorphic. -[![NPM](https://img.shields.io/npm/v/notion-utils.svg)](https://www.npmjs.com/package/notion-utils) [![Build Status](https://travis-ci.com/saasify-sh/notion-kit.svg?branch=master)](https://travis-ci.com/saasify-sh/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-utils.svg)](https://www.npmjs.com/package/notion-utils) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Install @@ -35,7 +35,7 @@ parsePageId('About-d9ae0c6e7cad49a78e21d240cf2e3d04', { uuid: false }) ## Docs -See the [auto-generated docs](https://github.com/saasify-sh/notion-kit/blob/master/docs/notion-utils.md). +See the [auto-generated docs](https://github.com/notion-x/notion-kit/blob/master/docs/notion-utils.md). ## License diff --git a/readme.md b/readme.md index 2f3c19a7..5ae5ec24 100644 --- a/readme.md +++ b/readme.md @@ -1,18 +1,18 @@

- Notion + TypeScript + Notion + TypeScript

# Notion Kit > TypeScript packages for [Notion's](https://notion.so) unofficial API, data types, and related utilities. -[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/saasify-sh/notion-kit.svg?branch=master)](https://travis-ci.com/saasify-sh/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Features - 🚀 **Simple** - It's all TypeScript. Easy peasy. - ⚡ **Fast** - Concurrent network IO for fetching all resources on a page. -- 💯 **Tests** - Comes with a comprehensive [test suite](https://www.notion.so/saasifysh/Notion-Test-Suite-067dd719a912471ea9a3ac10710e7fdf) covering 98% of Notion functionality. +- 💯 **Tests** - Comes with a comprehensive [test suite](https://www.notion.so/Notion-Test-Suite-067dd719a912471ea9a3ac10710e7fdf) covering 98% of Notion functionality. - 📓 **Docs** - Auto-generated [docs](./docs/index.md) for all packages. - 🔥 **Solid** - Used in production by Notion X (_coming soon_), [Notion VIP](https://www.notion.vip), and [Notion2Site](http://notion2site.com). @@ -97,11 +97,11 @@ The majority of Notion blocks and collection views are fully supported. Please let us know if you find any issues or missing blocks. -All known blocks and most known configuration settings can be found in our [test suite](https://www.notion.so/saasifysh/Notion-Test-Suite-067dd719a912471ea9a3ac10710e7fdf). +All known blocks and most known configuration settings can be found in our [test suite](https://www.notion.so/Notion-Test-Suite-067dd719a912471ea9a3ac10710e7fdf). ## Related -- [Notion Test Suite](https://www.notion.so/saasifysh/Notion-Test-Suite-067dd719a912471ea9a3ac10710e7fdf) - Comprehensive suite of Notion test pages +- [Notion Test Suite](https://www.notion.so/Notion-Test-Suite-067dd719a912471ea9a3ac10710e7fdf) - Comprehensive suite of Notion test pages - Includes all individual blocks - Includes all collection views - Covers most formatting options From aa1bb126986c9d42c211efb969723ea5154d7c04 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Aug 2020 08:27:23 -0400 Subject: [PATCH 0006/1173] v2.2.0 --- lerna.json | 2 +- packages/notion-client/package.json | 6 +++--- packages/notion-types/package.json | 2 +- packages/notion-utils/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index 33821e6d..8e2d00ca 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.1.0", + "version": "2.2.0", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 274bb294..ea5dd17a 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.1.0", + "version": "2.2.0", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "notion-x/notion-kit", "author": "Saasify ", @@ -16,8 +16,8 @@ }, "dependencies": { "got": "^11.5.2", - "notion-types": "^2.0.0", - "notion-utils": "^2.1.0", + "notion-types": "^2.2.0", + "notion-utils": "^2.2.0", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-types/package.json b/packages/notion-types/package.json index 68547179..38e0115d 100644 --- a/packages/notion-types/package.json +++ b/packages/notion-types/package.json @@ -1,6 +1,6 @@ { "name": "notion-types", - "version": "2.0.0", + "version": "2.2.0", "description": "TypeScript types for core Notion data structures.", "repository": "notion-x/notion-kit", "author": "Saasify ", diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index 23e54852..ba97964b 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.1.0", + "version": "2.2.0", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "notion-x/notion-kit", "author": "Saasify ", @@ -15,7 +15,7 @@ "test": "ava -v 'build/cjs/**/*.test.js'" }, "dependencies": { - "notion-types": "^2.0.0" + "notion-types": "^2.2.0" }, "devDependencies": { "ava": "^3.11.1", From 397b26828648fa926a56d4d1c477f26b9d1d68fe Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Aug 2020 08:35:23 -0400 Subject: [PATCH 0007/1173] chore: rename org once more to NotionX --- package.json | 2 +- packages/notion-client/package.json | 2 +- packages/notion-client/readme.md | 6 +++--- packages/notion-types/package.json | 2 +- packages/notion-types/readme.md | 6 +++--- packages/notion-utils/package.json | 2 +- packages/notion-utils/readme.md | 6 +++--- readme.md | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 871045d9..2137f860 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "notion", "private": true, "description": "TS packages for Notion's unofficial API, data types, and related utilities.", - "repository": "notion-x/notion-kit", + "repository": "NotionX/notion-kit", "author": "Travis Fischer ", "license": "MIT", "engines": { diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index ea5dd17a..b5efda74 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -2,7 +2,7 @@ "name": "notion-client", "version": "2.2.0", "description": "Robust TypeScript client for the unofficial Notion API.", - "repository": "notion-x/notion-kit", + "repository": "NotionX/notion-kit", "author": "Saasify ", "license": "MIT", "main": "build/cjs/index.js", diff --git a/packages/notion-client/readme.md b/packages/notion-client/readme.md index cbc1271c..100a3750 100644 --- a/packages/notion-client/readme.md +++ b/packages/notion-client/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# notion-client > Robust TypeScript client for the unofficial Notion API. -[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/NotionX/notion-kit.svg?branch=master)](https://travis-ci.com/NotionX/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Install @@ -38,7 +38,7 @@ const colectionData = await api.getCollectionData( ## Docs -See the [auto-generated docs](https://github.com/notion-x/notion-kit/blob/master/docs/notion-client.md). +See the [auto-generated docs](https://github.com/NotionX/notion-kit/blob/master/docs/notion-client.md). ## License diff --git a/packages/notion-types/package.json b/packages/notion-types/package.json index 38e0115d..3e865f1e 100644 --- a/packages/notion-types/package.json +++ b/packages/notion-types/package.json @@ -2,7 +2,7 @@ "name": "notion-types", "version": "2.2.0", "description": "TypeScript types for core Notion data structures.", - "repository": "notion-x/notion-kit", + "repository": "NotionX/notion-kit", "author": "Saasify ", "license": "MIT", "main": "build/cjs/index.js", diff --git a/packages/notion-types/readme.md b/packages/notion-types/readme.md index f53d36e3..dc8f7a03 100644 --- a/packages/notion-types/readme.md +++ b/packages/notion-types/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# notion-types > TypeScript types for core Notion data structures. -[![NPM](https://img.shields.io/npm/v/notion-types.svg)](https://www.npmjs.com/package/notion-types) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-types.svg)](https://www.npmjs.com/package/notion-types) [![Build Status](https://travis-ci.com/NotionX/notion-kit.svg?branch=master)](https://travis-ci.com/NotionX/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Install @@ -24,7 +24,7 @@ import * as notion from 'notion-types' ## Docs -See the [auto-generated docs](https://github.com/notion-x/notion-kit/blob/master/docs/notion-types.md). +See the [auto-generated docs](https://github.com/NotionX/notion-kit/blob/master/docs/notion-types.md). ## License diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index ba97964b..e48ae60d 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -2,7 +2,7 @@ "name": "notion-utils", "version": "2.2.0", "description": "Useful utilities for working with Notion data. Isomorphic.", - "repository": "notion-x/notion-kit", + "repository": "NotionX/notion-kit", "author": "Saasify ", "license": "MIT", "main": "build/cjs/index.js", diff --git a/packages/notion-utils/readme.md b/packages/notion-utils/readme.md index 5df87609..cad9422e 100644 --- a/packages/notion-utils/readme.md +++ b/packages/notion-utils/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# notion-utils > Useful utilities for working with Notion data. Isomorphic. -[![NPM](https://img.shields.io/npm/v/notion-utils.svg)](https://www.npmjs.com/package/notion-utils) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-utils.svg)](https://www.npmjs.com/package/notion-utils) [![Build Status](https://travis-ci.com/NotionX/notion-kit.svg?branch=master)](https://travis-ci.com/NotionX/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Install @@ -35,7 +35,7 @@ parsePageId('About-d9ae0c6e7cad49a78e21d240cf2e3d04', { uuid: false }) ## Docs -See the [auto-generated docs](https://github.com/notion-x/notion-kit/blob/master/docs/notion-utils.md). +See the [auto-generated docs](https://github.com/NotionX/notion-kit/blob/master/docs/notion-utils.md). ## License diff --git a/readme.md b/readme.md index 5ae5ec24..38209804 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,12 @@

- Notion + TypeScript + Notion + TypeScript

# Notion Kit > TypeScript packages for [Notion's](https://notion.so) unofficial API, data types, and related utilities. -[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/notion-x/notion-kit.svg?branch=master)](https://travis-ci.com/notion-x/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) +[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://travis-ci.com/NotionX/notion-kit.svg?branch=master)](https://travis-ci.com/NotionX/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) ## Features From 47a1475dae06dce8821a019c0f49e1e723a5f1ca Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Aug 2020 08:36:17 -0400 Subject: [PATCH 0008/1173] v2.2.1 --- lerna.json | 2 +- packages/notion-client/package.json | 6 +++--- packages/notion-types/package.json | 2 +- packages/notion-utils/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index 8e2d00ca..8e9569e8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.2.0", + "version": "2.2.1", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index b5efda74..ccf63a60 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.2.0", + "version": "2.2.1", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -16,8 +16,8 @@ }, "dependencies": { "got": "^11.5.2", - "notion-types": "^2.2.0", - "notion-utils": "^2.2.0", + "notion-types": "^2.2.1", + "notion-utils": "^2.2.1", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-types/package.json b/packages/notion-types/package.json index 3e865f1e..c43c1b81 100644 --- a/packages/notion-types/package.json +++ b/packages/notion-types/package.json @@ -1,6 +1,6 @@ { "name": "notion-types", - "version": "2.2.0", + "version": "2.2.1", "description": "TypeScript types for core Notion data structures.", "repository": "NotionX/notion-kit", "author": "Saasify ", diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index e48ae60d..b147dc49 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.2.0", + "version": "2.2.1", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -15,7 +15,7 @@ "test": "ava -v 'build/cjs/**/*.test.js'" }, "dependencies": { - "notion-types": "^2.2.0" + "notion-types": "^2.2.1" }, "devDependencies": { "ava": "^3.11.1", From 2206f6da92f79d08fa129eeb1a51977b6f2fa2c9 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 09:31:04 -0400 Subject: [PATCH 0009/1173] feat: add block utils --- packages/notion-utils/src/get-block-icon.ts | 20 +++++++++++++++++++ .../notion-utils/src/get-block-parent-page.ts | 4 ++-- packages/notion-utils/src/index.ts | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 packages/notion-utils/src/get-block-icon.ts diff --git a/packages/notion-utils/src/get-block-icon.ts b/packages/notion-utils/src/get-block-icon.ts new file mode 100644 index 00000000..935ec5a4 --- /dev/null +++ b/packages/notion-utils/src/get-block-icon.ts @@ -0,0 +1,20 @@ +import { Block, PageBlock, ExtendedRecordMap } from 'notion-types' + +export function getBlockIcon(block: Block, recordMap: ExtendedRecordMap) { + if ((block as PageBlock).format?.page_icon) { + return (block as PageBlock).format?.page_icon + } + + if ( + block.type === 'collection_view_page' || + block.type === 'collection_view' + ) { + const collection = recordMap.collection[block.collection_id]?.value + + if (collection) { + return collection.icon + } + } + + return null +} diff --git a/packages/notion-utils/src/get-block-parent-page.ts b/packages/notion-utils/src/get-block-parent-page.ts index 5ea746b7..eabfb114 100644 --- a/packages/notion-utils/src/get-block-parent-page.ts +++ b/packages/notion-utils/src/get-block-parent-page.ts @@ -10,10 +10,10 @@ export const getBlockParentPage = ( block: types.Block, recordMap: types.ExtendedRecordMap ): types.PageBlock | null => { - while (block?.type !== 'page') { + do { if (!block) return null block = recordMap.block[block.parent_id]?.value - } + } while (block?.type !== 'page') return block } diff --git a/packages/notion-utils/src/index.ts b/packages/notion-utils/src/index.ts index d1ec1a92..c3bb3321 100644 --- a/packages/notion-utils/src/index.ts +++ b/packages/notion-utils/src/index.ts @@ -1,5 +1,6 @@ export * from './get-text-content' export * from './get-block-title' +export * from './get-block-icon' export * from './get-page-title' export * from './get-date-value' export * from './get-block-parent-page' From c7a8978b38c1cd9444ca0fa513cbaeec4715fc00 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 09:32:52 -0400 Subject: [PATCH 0010/1173] chore: update docs --- api-extractor.json | 2 +- ...id.md => notion-types.baseblock.format.md} | 6 ++--- docs/notion-types.baseblock.md | 5 ++-- docs/notion-types.baseblock.parent_table.md | 2 +- docs/notion-types.basecollectionview.md | 3 ++- docs/notion-types.basecollectionview.query.md | 11 +++++++++ .../notion-types.basecollectionview.query2.md | 3 ++- docs/notion-types.baseformula.md | 19 +++++++++++++++ docs/notion-types.baseformula.result_type.md | 11 +++++++++ docs/notion-types.baseformula.type.md | 11 +++++++++ docs/notion-types.basepageblock.format.md | 1 + docs/notion-types.basepageblock.md | 2 +- docs/notion-types.basetextblock.content.md | 11 +++++++++ docs/notion-types.basetextblock.md | 1 + ...notion-types.boardcollectionview.format.md | 4 ++-- docs/notion-types.boardcollectionview.md | 2 +- docs/notion-types.collection.format.md | 2 +- docs/notion-types.collection.md | 5 ++-- docs/notion-types.collection.name.md | 2 +- .../notion-types.collection.template_pages.md | 11 +++++++++ docs/notion-types.collectioncardcover.md | 2 +- ...tion-types.collectioncardcover.property.md | 2 +- ...-types.collectionpropertyschema.formula.md | 11 +++++++++ docs/notion-types.collectionpropertyschema.md | 1 + docs/notion-types.constantformula.md | 21 +++++++++++++++++ docs/notion-types.constantformula.type.md | 11 +++++++++ docs/notion-types.constantformula.value.md | 11 +++++++++ ...notion-types.constantformula.value_type.md | 11 +++++++++ docs/notion-types.dateformat.md | 7 +----- .../notion-types.formatteddate.date_format.md | 11 +++++++++ docs/notion-types.formatteddate.end_date.md | 11 +++++++++ docs/notion-types.formatteddate.md | 21 +++++++++++++++++ docs/notion-types.formatteddate.start_date.md | 11 +++++++++ docs/notion-types.formatteddate.type.md | 11 +++++++++ docs/notion-types.formula.md | 11 +++++++++ docs/notion-types.formulaconstanttype.md | 11 +++++++++ docs/notion-types.formulafunctiontype.md | 11 +++++++++ docs/notion-types.formulaoperatortype.md | 11 +++++++++ docs/notion-types.formularesult.md | 11 +++++++++ docs/notion-types.formularesulttype.md | 11 +++++++++ docs/notion-types.formulatype.md | 11 +++++++++ docs/notion-types.formulavaluetype.md | 11 +++++++++ docs/notion-types.functionformula.args.md | 11 +++++++++ docs/notion-types.functionformula.md | 21 +++++++++++++++++ docs/notion-types.functionformula.name.md | 11 +++++++++ docs/notion-types.functionformula.type.md | 11 +++++++++ ...tion-types.gallerycollectionview.format.md | 2 +- docs/notion-types.gallerycollectionview.md | 2 +- docs/notion-types.id.md | 2 ++ .../notion-types.listcollectionview.format.md | 2 +- docs/notion-types.listcollectionview.md | 2 +- docs/notion-types.md | 23 ++++++++++++++++--- docs/notion-types.operatorformula.args.md | 11 +++++++++ docs/notion-types.operatorformula.md | 22 ++++++++++++++++++ docs/notion-types.operatorformula.name.md | 11 +++++++++ docs/notion-types.operatorformula.operator.md | 11 +++++++++ docs/notion-types.operatorformula.type.md | 11 +++++++++ docs/notion-types.propertyformula.id.md | 11 +++++++++ docs/notion-types.propertyformula.md | 21 +++++++++++++++++ docs/notion-types.propertyformula.name.md | 11 +++++++++ docs/notion-types.propertyformula.type.md | 11 +++++++++ docs/notion-types.propertyid.md | 17 ++++++++++++++ docs/notion-types.propertymap.md | 11 +++++++++ docs/notion-types.propertytype.md | 2 +- docs/notion-types.subdecoration.md | 2 +- docs/notion-types.symbolformula.md | 20 ++++++++++++++++ docs/notion-types.symbolformula.name.md | 11 +++++++++ docs/notion-types.symbolformula.type.md | 11 +++++++++ ...notion-types.tablecollectionview.format.md | 2 +- docs/notion-types.tablecollectionview.md | 2 +- docs/notion-types.underlineformat.md | 11 +++++++++ docs/notion-utils.getblockicon.md | 23 +++++++++++++++++++ docs/notion-utils.getblockparentpage.md | 15 ++++++++++++ docs/notion-utils.getblocktitle.md | 23 +++++++++++++++++++ docs/notion-utils.getdatevalue.md | 13 +++++++++++ docs/notion-utils.getpagecontentblockids.md | 13 +++++++++++ docs/notion-utils.getpagetableofcontents.md | 2 ++ docs/notion-utils.getpagetitle.md | 22 ++++++++++++++++++ docs/notion-utils.md | 13 ++++++++++- 79 files changed, 727 insertions(+), 37 deletions(-) rename docs/{notion-types.collectionpropertyid.md => notion-types.baseblock.format.md} (54%) create mode 100644 docs/notion-types.basecollectionview.query.md create mode 100644 docs/notion-types.baseformula.md create mode 100644 docs/notion-types.baseformula.result_type.md create mode 100644 docs/notion-types.baseformula.type.md create mode 100644 docs/notion-types.basetextblock.content.md create mode 100644 docs/notion-types.collection.template_pages.md create mode 100644 docs/notion-types.collectionpropertyschema.formula.md create mode 100644 docs/notion-types.constantformula.md create mode 100644 docs/notion-types.constantformula.type.md create mode 100644 docs/notion-types.constantformula.value.md create mode 100644 docs/notion-types.constantformula.value_type.md create mode 100644 docs/notion-types.formatteddate.date_format.md create mode 100644 docs/notion-types.formatteddate.end_date.md create mode 100644 docs/notion-types.formatteddate.md create mode 100644 docs/notion-types.formatteddate.start_date.md create mode 100644 docs/notion-types.formatteddate.type.md create mode 100644 docs/notion-types.formula.md create mode 100644 docs/notion-types.formulaconstanttype.md create mode 100644 docs/notion-types.formulafunctiontype.md create mode 100644 docs/notion-types.formulaoperatortype.md create mode 100644 docs/notion-types.formularesult.md create mode 100644 docs/notion-types.formularesulttype.md create mode 100644 docs/notion-types.formulatype.md create mode 100644 docs/notion-types.formulavaluetype.md create mode 100644 docs/notion-types.functionformula.args.md create mode 100644 docs/notion-types.functionformula.md create mode 100644 docs/notion-types.functionformula.name.md create mode 100644 docs/notion-types.functionformula.type.md create mode 100644 docs/notion-types.operatorformula.args.md create mode 100644 docs/notion-types.operatorformula.md create mode 100644 docs/notion-types.operatorformula.name.md create mode 100644 docs/notion-types.operatorformula.operator.md create mode 100644 docs/notion-types.operatorformula.type.md create mode 100644 docs/notion-types.propertyformula.id.md create mode 100644 docs/notion-types.propertyformula.md create mode 100644 docs/notion-types.propertyformula.name.md create mode 100644 docs/notion-types.propertyformula.type.md create mode 100644 docs/notion-types.propertyid.md create mode 100644 docs/notion-types.propertymap.md create mode 100644 docs/notion-types.symbolformula.md create mode 100644 docs/notion-types.symbolformula.name.md create mode 100644 docs/notion-types.symbolformula.type.md create mode 100644 docs/notion-types.underlineformat.md create mode 100644 docs/notion-utils.getblockicon.md create mode 100644 docs/notion-utils.getblockparentpage.md create mode 100644 docs/notion-utils.getblocktitle.md create mode 100644 docs/notion-utils.getdatevalue.md create mode 100644 docs/notion-utils.getpagecontentblockids.md create mode 100644 docs/notion-utils.getpagetitle.md diff --git a/api-extractor.json b/api-extractor.json index 34c1011b..66d128fc 100644 --- a/api-extractor.json +++ b/api-extractor.json @@ -1,7 +1,7 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "mainEntryPointFilePath": "/build/index.d.ts", + "mainEntryPointFilePath": "/build/esm/index.d.ts", "bundledPackages": [], diff --git a/docs/notion-types.collectionpropertyid.md b/docs/notion-types.baseblock.format.md similarity index 54% rename from docs/notion-types.collectionpropertyid.md rename to docs/notion-types.baseblock.format.md index bcd24cfe..1b62c41f 100644 --- a/docs/notion-types.collectionpropertyid.md +++ b/docs/notion-types.baseblock.format.md @@ -1,11 +1,11 @@ -[Home](./index.md) > [notion-types](./notion-types.md) > [CollectionPropertyID](./notion-types.collectionpropertyid.md) +[Home](./index.md) > [notion-types](./notion-types.md) > [BaseBlock](./notion-types.baseblock.md) > [format](./notion-types.baseblock.format.md) -## CollectionPropertyID type +## BaseBlock.format property Signature: ```typescript -export declare type CollectionPropertyID = 'string'; +format?: object; ``` diff --git a/docs/notion-types.baseblock.md b/docs/notion-types.baseblock.md index 7b9c8dbc..f6f88d41 100644 --- a/docs/notion-types.baseblock.md +++ b/docs/notion-types.baseblock.md @@ -4,7 +4,7 @@ ## BaseBlock interface -Base properties shared by all block types. +Base properties shared by all blocks. Signature: @@ -21,12 +21,13 @@ export interface BaseBlock | [created\_by\_id](./notion-types.baseblock.created_by_id.md) | [ID](./notion-types.id.md) | | | [created\_by\_table](./notion-types.baseblock.created_by_table.md) | string | | | [created\_time](./notion-types.baseblock.created_time.md) | number | | +| [format](./notion-types.baseblock.format.md) | object | | | [id](./notion-types.baseblock.id.md) | [ID](./notion-types.id.md) | | | [last\_edited\_by\_id](./notion-types.baseblock.last_edited_by_id.md) | [ID](./notion-types.id.md) | | | [last\_edited\_by\_table](./notion-types.baseblock.last_edited_by_table.md) | string | | | [last\_edited\_time](./notion-types.baseblock.last_edited_time.md) | number | | | [parent\_id](./notion-types.baseblock.parent_id.md) | [ID](./notion-types.id.md) | | -| [parent\_table](./notion-types.baseblock.parent_table.md) | string | | +| [parent\_table](./notion-types.baseblock.parent_table.md) | string \| 'space' \| 'block' \| 'table' | | | [properties](./notion-types.baseblock.properties.md) | any | | | [space\_id](./notion-types.baseblock.space_id.md) | [ID](./notion-types.id.md) | | | [type](./notion-types.baseblock.type.md) | [BlockType](./notion-types.blocktype.md) | | diff --git a/docs/notion-types.baseblock.parent_table.md b/docs/notion-types.baseblock.parent_table.md index 94b6de8a..f4a1bf6d 100644 --- a/docs/notion-types.baseblock.parent_table.md +++ b/docs/notion-types.baseblock.parent_table.md @@ -7,5 +7,5 @@ Signature: ```typescript -parent_table: string; +parent_table: string | 'space' | 'block' | 'table'; ``` diff --git a/docs/notion-types.basecollectionview.md b/docs/notion-types.basecollectionview.md index 67a95859..ffe3bba4 100644 --- a/docs/notion-types.basecollectionview.md +++ b/docs/notion-types.basecollectionview.md @@ -20,7 +20,8 @@ export interface BaseCollectionView | [name](./notion-types.basecollectionview.name.md) | string | | | [parent\_id](./notion-types.basecollectionview.parent_id.md) | [ID](./notion-types.id.md) | | | [parent\_table](./notion-types.basecollectionview.parent_table.md) | string | | -| [query2](./notion-types.basecollectionview.query2.md) | { aggregations?: object\[\]; group\_by: [CollectionPropertyID](./notion-types.collectionpropertyid.md); } | | +| [query](./notion-types.basecollectionview.query.md) | any | | +| [query2](./notion-types.basecollectionview.query2.md) | { filter?: any; aggregations?: object\[\]; group\_by: [PropertyID](./notion-types.propertyid.md); } | | | [type](./notion-types.basecollectionview.type.md) | [CollectionViewType](./notion-types.collectionviewtype.md) | | | [version](./notion-types.basecollectionview.version.md) | number | | diff --git a/docs/notion-types.basecollectionview.query.md b/docs/notion-types.basecollectionview.query.md new file mode 100644 index 00000000..85b7cc01 --- /dev/null +++ b/docs/notion-types.basecollectionview.query.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [BaseCollectionView](./notion-types.basecollectionview.md) > [query](./notion-types.basecollectionview.query.md) + +## BaseCollectionView.query property + +Signature: + +```typescript +query?: any; +``` diff --git a/docs/notion-types.basecollectionview.query2.md b/docs/notion-types.basecollectionview.query2.md index e3bf9c5d..35e23007 100644 --- a/docs/notion-types.basecollectionview.query2.md +++ b/docs/notion-types.basecollectionview.query2.md @@ -8,7 +8,8 @@ ```typescript query2: { + filter?: any; aggregations?: object[]; - group_by: CollectionPropertyID; + group_by: PropertyID; }; ``` diff --git a/docs/notion-types.baseformula.md b/docs/notion-types.baseformula.md new file mode 100644 index 00000000..12e7d9f3 --- /dev/null +++ b/docs/notion-types.baseformula.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [BaseFormula](./notion-types.baseformula.md) + +## BaseFormula interface + +Signature: + +```typescript +export interface BaseFormula +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [result\_type](./notion-types.baseformula.result_type.md) | [FormulaResultType](./notion-types.formularesulttype.md) | | +| [type](./notion-types.baseformula.type.md) | [FormulaType](./notion-types.formulatype.md) | | + diff --git a/docs/notion-types.baseformula.result_type.md b/docs/notion-types.baseformula.result_type.md new file mode 100644 index 00000000..5ada4cc5 --- /dev/null +++ b/docs/notion-types.baseformula.result_type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [BaseFormula](./notion-types.baseformula.md) > [result\_type](./notion-types.baseformula.result_type.md) + +## BaseFormula.result\_type property + +Signature: + +```typescript +result_type: FormulaResultType; +``` diff --git a/docs/notion-types.baseformula.type.md b/docs/notion-types.baseformula.type.md new file mode 100644 index 00000000..a3b1c457 --- /dev/null +++ b/docs/notion-types.baseformula.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [BaseFormula](./notion-types.baseformula.md) > [type](./notion-types.baseformula.type.md) + +## BaseFormula.type property + +Signature: + +```typescript +type: FormulaType; +``` diff --git a/docs/notion-types.basepageblock.format.md b/docs/notion-types.basepageblock.format.md index 6fc337ee..a43d9a14 100644 --- a/docs/notion-types.basepageblock.format.md +++ b/docs/notion-types.basepageblock.format.md @@ -15,5 +15,6 @@ format: { block_locked_by?: string; page_cover?: string; page_icon?: string; + block_color?: Color; }; ``` diff --git a/docs/notion-types.basepageblock.md b/docs/notion-types.basepageblock.md index cfe6aa52..c36aa213 100644 --- a/docs/notion-types.basepageblock.md +++ b/docs/notion-types.basepageblock.md @@ -16,7 +16,7 @@ export interface BasePageBlock extends BaseBlock | Property | Type | Description | | --- | --- | --- | | [file\_ids](./notion-types.basepageblock.file_ids.md) | string\[\] | | -| [format](./notion-types.basepageblock.format.md) | { page\_full\_width?: boolean; page\_small\_text?: boolean; page\_cover\_position?: number; block\_locked?: boolean; block\_locked\_by?: string; page\_cover?: string; page\_icon?: string; } | | +| [format](./notion-types.basepageblock.format.md) | { page\_full\_width?: boolean; page\_small\_text?: boolean; page\_cover\_position?: number; block\_locked?: boolean; block\_locked\_by?: string; page\_cover?: string; page\_icon?: string; block\_color?: [Color](./notion-types.color.md); } | | | [permissions](./notion-types.basepageblock.permissions.md) | { role: [Role](./notion-types.role.md); type: string; }\[\] | | | [properties](./notion-types.basepageblock.properties.md) | { title: [Decoration](./notion-types.decoration.md)\[\]; } | | diff --git a/docs/notion-types.basetextblock.content.md b/docs/notion-types.basetextblock.content.md new file mode 100644 index 00000000..e03213ff --- /dev/null +++ b/docs/notion-types.basetextblock.content.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [BaseTextBlock](./notion-types.basetextblock.md) > [content](./notion-types.basetextblock.content.md) + +## BaseTextBlock.content property + +Signature: + +```typescript +content?: ID[]; +``` diff --git a/docs/notion-types.basetextblock.md b/docs/notion-types.basetextblock.md index 81ddc575..3425fe21 100644 --- a/docs/notion-types.basetextblock.md +++ b/docs/notion-types.basetextblock.md @@ -15,6 +15,7 @@ export interface BaseTextBlock extends BaseBlock | Property | Type | Description | | --- | --- | --- | +| [content](./notion-types.basetextblock.content.md) | [ID](./notion-types.id.md)\[\] | | | [format](./notion-types.basetextblock.format.md) | { block\_color: [Color](./notion-types.color.md); } | | | [properties](./notion-types.basetextblock.properties.md) | { title: [Decoration](./notion-types.decoration.md)\[\]; } | | diff --git a/docs/notion-types.boardcollectionview.format.md b/docs/notion-types.boardcollectionview.format.md index 30e4f6f4..943007ee 100644 --- a/docs/notion-types.boardcollectionview.format.md +++ b/docs/notion-types.boardcollectionview.format.md @@ -12,11 +12,11 @@ format: { board_cover_size: CollectionCardCoverSize; board_cover_aspect: CollectionCardCoverAspect; board_properties: Array<{ - property: CollectionPropertyID; + property: PropertyID; visible: boolean; }>; board_groups2: Array<{ - property: CollectionPropertyID; + property: PropertyID; hidden: boolean; value: { type: PropertyType; diff --git a/docs/notion-types.boardcollectionview.md b/docs/notion-types.boardcollectionview.md index 8b1efdf6..10f63f0e 100644 --- a/docs/notion-types.boardcollectionview.md +++ b/docs/notion-types.boardcollectionview.md @@ -15,6 +15,6 @@ export interface BoardCollectionView extends BaseCollectionView | Property | Type | Description | | --- | --- | --- | -| [format](./notion-types.boardcollectionview.format.md) | { board\_cover: [CollectionCardCover](./notion-types.collectioncardcover.md); board\_cover\_size: [CollectionCardCoverSize](./notion-types.collectioncardcoversize.md); board\_cover\_aspect: [CollectionCardCoverAspect](./notion-types.collectioncardcoveraspect.md); board\_properties: Array<{ property: [CollectionPropertyID](./notion-types.collectionpropertyid.md); visible: boolean; }>; board\_groups2: Array<{ property: [CollectionPropertyID](./notion-types.collectionpropertyid.md); hidden: boolean; value: { type: [PropertyType](./notion-types.propertytype.md); value: string; }; }>; } | | +| [format](./notion-types.boardcollectionview.format.md) | { board\_cover: [CollectionCardCover](./notion-types.collectioncardcover.md); board\_cover\_size: [CollectionCardCoverSize](./notion-types.collectioncardcoversize.md); board\_cover\_aspect: [CollectionCardCoverAspect](./notion-types.collectioncardcoveraspect.md); board\_properties: Array<{ property: [PropertyID](./notion-types.propertyid.md); visible: boolean; }>; board\_groups2: Array<{ property: [PropertyID](./notion-types.propertyid.md); hidden: boolean; value: { type: [PropertyType](./notion-types.propertytype.md); value: string; }; }>; } | | | [type](./notion-types.boardcollectionview.type.md) | 'board' | | diff --git a/docs/notion-types.collection.format.md b/docs/notion-types.collection.format.md index ca3e0653..d046b9ab 100644 --- a/docs/notion-types.collection.format.md +++ b/docs/notion-types.collection.format.md @@ -9,7 +9,7 @@ ```typescript format?: { collection_page_properties?: Array<{ - property: CollectionPropertyID; + property: PropertyID; visible: boolean; }>; }; diff --git a/docs/notion-types.collection.md b/docs/notion-types.collection.md index fc75da0d..c6d933e8 100644 --- a/docs/notion-types.collection.md +++ b/docs/notion-types.collection.md @@ -16,12 +16,13 @@ export interface Collection | --- | --- | --- | | [alive](./notion-types.collection.alive.md) | boolean | | | [copied\_from](./notion-types.collection.copied_from.md) | string | | -| [format](./notion-types.collection.format.md) | { collection\_page\_properties?: Array<{ property: [CollectionPropertyID](./notion-types.collectionpropertyid.md); visible: boolean; }>; } | | +| [format](./notion-types.collection.format.md) | { collection\_page\_properties?: Array<{ property: [PropertyID](./notion-types.propertyid.md); visible: boolean; }>; } | | | [icon](./notion-types.collection.icon.md) | string | | | [id](./notion-types.collection.id.md) | [ID](./notion-types.id.md) | | -| [name](./notion-types.collection.name.md) | string\[\]\[\] | | +| [name](./notion-types.collection.name.md) | [Decoration](./notion-types.decoration.md)\[\] | | | [parent\_id](./notion-types.collection.parent_id.md) | [ID](./notion-types.id.md) | | | [parent\_table](./notion-types.collection.parent_table.md) | string | | | [schema](./notion-types.collection.schema.md) | [CollectionPropertySchemaMap](./notion-types.collectionpropertyschemamap.md) | | +| [template\_pages](./notion-types.collection.template_pages.md) | Array<[ID](./notion-types.id.md)> | | | [version](./notion-types.collection.version.md) | number | | diff --git a/docs/notion-types.collection.name.md b/docs/notion-types.collection.name.md index d003f7da..f97bbb8c 100644 --- a/docs/notion-types.collection.name.md +++ b/docs/notion-types.collection.name.md @@ -7,5 +7,5 @@ Signature: ```typescript -name: string[][]; +name: Decoration[]; ``` diff --git a/docs/notion-types.collection.template_pages.md b/docs/notion-types.collection.template_pages.md new file mode 100644 index 00000000..397b4c90 --- /dev/null +++ b/docs/notion-types.collection.template_pages.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [Collection](./notion-types.collection.md) > [template\_pages](./notion-types.collection.template_pages.md) + +## Collection.template\_pages property + +Signature: + +```typescript +template_pages?: Array; +``` diff --git a/docs/notion-types.collectioncardcover.md b/docs/notion-types.collectioncardcover.md index 0dd297dd..11daa649 100644 --- a/docs/notion-types.collectioncardcover.md +++ b/docs/notion-types.collectioncardcover.md @@ -14,6 +14,6 @@ export interface CollectionCardCover | Property | Type | Description | | --- | --- | --- | -| [property](./notion-types.collectioncardcover.property.md) | [CollectionPropertyID](./notion-types.collectionpropertyid.md) | | +| [property](./notion-types.collectioncardcover.property.md) | [PropertyID](./notion-types.propertyid.md) | | | [type](./notion-types.collectioncardcover.type.md) | [CollectionCardCoverType](./notion-types.collectioncardcovertype.md) | | diff --git a/docs/notion-types.collectioncardcover.property.md b/docs/notion-types.collectioncardcover.property.md index 2cdff516..81f7baed 100644 --- a/docs/notion-types.collectioncardcover.property.md +++ b/docs/notion-types.collectioncardcover.property.md @@ -7,5 +7,5 @@ Signature: ```typescript -property?: CollectionPropertyID; +property?: PropertyID; ``` diff --git a/docs/notion-types.collectionpropertyschema.formula.md b/docs/notion-types.collectionpropertyschema.formula.md new file mode 100644 index 00000000..d3dbaac3 --- /dev/null +++ b/docs/notion-types.collectionpropertyschema.formula.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [CollectionPropertySchema](./notion-types.collectionpropertyschema.md) > [formula](./notion-types.collectionpropertyschema.formula.md) + +## CollectionPropertySchema.formula property + +Signature: + +```typescript +formula?: Formula; +``` diff --git a/docs/notion-types.collectionpropertyschema.md b/docs/notion-types.collectionpropertyschema.md index 639217dc..b673219d 100644 --- a/docs/notion-types.collectionpropertyschema.md +++ b/docs/notion-types.collectionpropertyschema.md @@ -14,6 +14,7 @@ export interface CollectionPropertySchema | Property | Type | Description | | --- | --- | --- | +| [formula](./notion-types.collectionpropertyschema.formula.md) | [Formula](./notion-types.formula.md) | | | [name](./notion-types.collectionpropertyschema.name.md) | string | | | [number\_format](./notion-types.collectionpropertyschema.number_format.md) | [NumberFormat](./notion-types.numberformat.md) | | | [options](./notion-types.collectionpropertyschema.options.md) | [SelectOption](./notion-types.selectoption.md)\[\] | | diff --git a/docs/notion-types.constantformula.md b/docs/notion-types.constantformula.md new file mode 100644 index 00000000..dfd7fb3d --- /dev/null +++ b/docs/notion-types.constantformula.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [ConstantFormula](./notion-types.constantformula.md) + +## ConstantFormula interface + +Signature: + +```typescript +export interface ConstantFormula extends BaseFormula +``` +Extends: [BaseFormula](./notion-types.baseformula.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [type](./notion-types.constantformula.type.md) | 'constant' | | +| [value\_type](./notion-types.constantformula.value_type.md) | [FormulaValueType](./notion-types.formulavaluetype.md) | | +| [value](./notion-types.constantformula.value.md) | any | | + diff --git a/docs/notion-types.constantformula.type.md b/docs/notion-types.constantformula.type.md new file mode 100644 index 00000000..7d3bcb18 --- /dev/null +++ b/docs/notion-types.constantformula.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [ConstantFormula](./notion-types.constantformula.md) > [type](./notion-types.constantformula.type.md) + +## ConstantFormula.type property + +Signature: + +```typescript +type: 'constant'; +``` diff --git a/docs/notion-types.constantformula.value.md b/docs/notion-types.constantformula.value.md new file mode 100644 index 00000000..4f942736 --- /dev/null +++ b/docs/notion-types.constantformula.value.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [ConstantFormula](./notion-types.constantformula.md) > [value](./notion-types.constantformula.value.md) + +## ConstantFormula.value property + +Signature: + +```typescript +value: any; +``` diff --git a/docs/notion-types.constantformula.value_type.md b/docs/notion-types.constantformula.value_type.md new file mode 100644 index 00000000..218fb294 --- /dev/null +++ b/docs/notion-types.constantformula.value_type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [ConstantFormula](./notion-types.constantformula.md) > [value\_type](./notion-types.constantformula.value_type.md) + +## ConstantFormula.value\_type property + +Signature: + +```typescript +value_type: FormulaValueType; +``` diff --git a/docs/notion-types.dateformat.md b/docs/notion-types.dateformat.md index 7a27cfc9..0e4e671d 100644 --- a/docs/notion-types.dateformat.md +++ b/docs/notion-types.dateformat.md @@ -7,10 +7,5 @@ Signature: ```typescript -export declare type DateFormat = ['d', { - type: 'date' | 'daterange'; - start_date: string; - end_date?: string; - date_format: string; -}]; +export declare type DateFormat = ['d', FormattedDate]; ``` diff --git a/docs/notion-types.formatteddate.date_format.md b/docs/notion-types.formatteddate.date_format.md new file mode 100644 index 00000000..9fcdc21f --- /dev/null +++ b/docs/notion-types.formatteddate.date_format.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormattedDate](./notion-types.formatteddate.md) > [date\_format](./notion-types.formatteddate.date_format.md) + +## FormattedDate.date\_format property + +Signature: + +```typescript +date_format?: string; +``` diff --git a/docs/notion-types.formatteddate.end_date.md b/docs/notion-types.formatteddate.end_date.md new file mode 100644 index 00000000..c0102df8 --- /dev/null +++ b/docs/notion-types.formatteddate.end_date.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormattedDate](./notion-types.formatteddate.md) > [end\_date](./notion-types.formatteddate.end_date.md) + +## FormattedDate.end\_date property + +Signature: + +```typescript +end_date?: string; +``` diff --git a/docs/notion-types.formatteddate.md b/docs/notion-types.formatteddate.md new file mode 100644 index 00000000..c8338796 --- /dev/null +++ b/docs/notion-types.formatteddate.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormattedDate](./notion-types.formatteddate.md) + +## FormattedDate interface + +Signature: + +```typescript +export interface FormattedDate +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [date\_format](./notion-types.formatteddate.date_format.md) | string | | +| [end\_date](./notion-types.formatteddate.end_date.md) | string | | +| [start\_date](./notion-types.formatteddate.start_date.md) | string | | +| [type](./notion-types.formatteddate.type.md) | 'date' \| 'daterange' | | + diff --git a/docs/notion-types.formatteddate.start_date.md b/docs/notion-types.formatteddate.start_date.md new file mode 100644 index 00000000..c9a4722d --- /dev/null +++ b/docs/notion-types.formatteddate.start_date.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormattedDate](./notion-types.formatteddate.md) > [start\_date](./notion-types.formatteddate.start_date.md) + +## FormattedDate.start\_date property + +Signature: + +```typescript +start_date: string; +``` diff --git a/docs/notion-types.formatteddate.type.md b/docs/notion-types.formatteddate.type.md new file mode 100644 index 00000000..c8390afc --- /dev/null +++ b/docs/notion-types.formatteddate.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormattedDate](./notion-types.formatteddate.md) > [type](./notion-types.formatteddate.type.md) + +## FormattedDate.type property + +Signature: + +```typescript +type: 'date' | 'daterange'; +``` diff --git a/docs/notion-types.formula.md b/docs/notion-types.formula.md new file mode 100644 index 00000000..3d8ab6fe --- /dev/null +++ b/docs/notion-types.formula.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [Formula](./notion-types.formula.md) + +## Formula type + +Signature: + +```typescript +export declare type Formula = FunctionFormula | OperatorFormula | ConstantFormula | PropertyFormula | SymbolFormula; +``` diff --git a/docs/notion-types.formulaconstanttype.md b/docs/notion-types.formulaconstanttype.md new file mode 100644 index 00000000..45840cc0 --- /dev/null +++ b/docs/notion-types.formulaconstanttype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaConstantType](./notion-types.formulaconstanttype.md) + +## FormulaConstantType type + +Signature: + +```typescript +export declare type FormulaConstantType = 'e' | 'false' | 'true' | 'pi'; +``` diff --git a/docs/notion-types.formulafunctiontype.md b/docs/notion-types.formulafunctiontype.md new file mode 100644 index 00000000..5704a806 --- /dev/null +++ b/docs/notion-types.formulafunctiontype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaFunctionType](./notion-types.formulafunctiontype.md) + +## FormulaFunctionType type + +Signature: + +```typescript +export declare type FormulaFunctionType = 'and' | 'empty' | 'equal' | 'if' | 'larger' | 'largerEq' | 'not' | 'or' | 'smaller' | 'smallerEq' | 'unequal' | 'abs' | 'add' | 'cbrt' | 'ceil' | 'divide' | 'exp' | 'floor' | 'ln' | 'log10' | 'log2' | 'max' | 'min' | 'mod' | 'multiply' | 'pow' | 'round' | 'sign' | 'sqrt' | 'subtract' | 'toNumber' | 'unaryMinus' | 'unaryPlus' | 'concat' | 'contains' | 'format' | 'join' | 'length' | 'replace' | 'replaceAll' | 'slice' | 'test' | 'date' | 'dateAdd' | 'dateBetween' | 'dateSubtract' | 'day' | 'end' | 'formatDate' | 'fromTimestamp' | 'hour' | 'minute' | 'month' | 'now' | 'start' | 'timestamp' | 'year'; +``` diff --git a/docs/notion-types.formulaoperatortype.md b/docs/notion-types.formulaoperatortype.md new file mode 100644 index 00000000..3fefa35c --- /dev/null +++ b/docs/notion-types.formulaoperatortype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaOperatorType](./notion-types.formulaoperatortype.md) + +## FormulaOperatorType type + +Signature: + +```typescript +export declare type FormulaOperatorType = '-' | '*' | '%' | '/' | '+' | '!=' | '<=' | '==' | '>' | '<' | '>='; +``` diff --git a/docs/notion-types.formularesult.md b/docs/notion-types.formularesult.md new file mode 100644 index 00000000..ce09d1be --- /dev/null +++ b/docs/notion-types.formularesult.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaResult](./notion-types.formularesult.md) + +## FormulaResult type + +Signature: + +```typescript +export declare type FormulaResult = string | number | boolean | Date; +``` diff --git a/docs/notion-types.formularesulttype.md b/docs/notion-types.formularesulttype.md new file mode 100644 index 00000000..ba393101 --- /dev/null +++ b/docs/notion-types.formularesulttype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaResultType](./notion-types.formularesulttype.md) + +## FormulaResultType type + +Signature: + +```typescript +export declare type FormulaResultType = 'text' | 'number' | 'boolean' | 'date' | 'checkbox'; +``` diff --git a/docs/notion-types.formulatype.md b/docs/notion-types.formulatype.md new file mode 100644 index 00000000..a7ef453d --- /dev/null +++ b/docs/notion-types.formulatype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaType](./notion-types.formulatype.md) + +## FormulaType type + +Signature: + +```typescript +export declare type FormulaType = 'constant' | 'property' | 'operator' | 'function' | 'symbol'; +``` diff --git a/docs/notion-types.formulavaluetype.md b/docs/notion-types.formulavaluetype.md new file mode 100644 index 00000000..acb5bc1c --- /dev/null +++ b/docs/notion-types.formulavaluetype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FormulaValueType](./notion-types.formulavaluetype.md) + +## FormulaValueType type + +Signature: + +```typescript +export declare type FormulaValueType = 'string' | 'number' | 'boolean' | 'date' | FormulaConstantType; +``` diff --git a/docs/notion-types.functionformula.args.md b/docs/notion-types.functionformula.args.md new file mode 100644 index 00000000..5df3f017 --- /dev/null +++ b/docs/notion-types.functionformula.args.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FunctionFormula](./notion-types.functionformula.md) > [args](./notion-types.functionformula.args.md) + +## FunctionFormula.args property + +Signature: + +```typescript +args: Array; +``` diff --git a/docs/notion-types.functionformula.md b/docs/notion-types.functionformula.md new file mode 100644 index 00000000..7ea4c848 --- /dev/null +++ b/docs/notion-types.functionformula.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FunctionFormula](./notion-types.functionformula.md) + +## FunctionFormula interface + +Signature: + +```typescript +export interface FunctionFormula extends BaseFormula +``` +Extends: [BaseFormula](./notion-types.baseformula.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [args](./notion-types.functionformula.args.md) | Array<[Formula](./notion-types.formula.md)> | | +| [name](./notion-types.functionformula.name.md) | [FormulaFunctionType](./notion-types.formulafunctiontype.md) | | +| [type](./notion-types.functionformula.type.md) | 'function' | | + diff --git a/docs/notion-types.functionformula.name.md b/docs/notion-types.functionformula.name.md new file mode 100644 index 00000000..18a53c3d --- /dev/null +++ b/docs/notion-types.functionformula.name.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FunctionFormula](./notion-types.functionformula.md) > [name](./notion-types.functionformula.name.md) + +## FunctionFormula.name property + +Signature: + +```typescript +name: FormulaFunctionType; +``` diff --git a/docs/notion-types.functionformula.type.md b/docs/notion-types.functionformula.type.md new file mode 100644 index 00000000..c889b10d --- /dev/null +++ b/docs/notion-types.functionformula.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [FunctionFormula](./notion-types.functionformula.md) > [type](./notion-types.functionformula.type.md) + +## FunctionFormula.type property + +Signature: + +```typescript +type: 'function'; +``` diff --git a/docs/notion-types.gallerycollectionview.format.md b/docs/notion-types.gallerycollectionview.format.md index 4db62918..28bb20f6 100644 --- a/docs/notion-types.gallerycollectionview.format.md +++ b/docs/notion-types.gallerycollectionview.format.md @@ -12,7 +12,7 @@ format: { gallery_cover_size: CollectionCardCoverSize; gallery_cover_aspect: CollectionCardCoverAspect; gallery_properties: Array<{ - property: CollectionPropertyID; + property: PropertyID; visible: boolean; }>; }; diff --git a/docs/notion-types.gallerycollectionview.md b/docs/notion-types.gallerycollectionview.md index 4088b58d..b4f76501 100644 --- a/docs/notion-types.gallerycollectionview.md +++ b/docs/notion-types.gallerycollectionview.md @@ -15,6 +15,6 @@ export interface GalleryCollectionView extends BaseCollectionView | Property | Type | Description | | --- | --- | --- | -| [format](./notion-types.gallerycollectionview.format.md) | { gallery\_cover: [CollectionCardCover](./notion-types.collectioncardcover.md); gallery\_cover\_size: [CollectionCardCoverSize](./notion-types.collectioncardcoversize.md); gallery\_cover\_aspect: [CollectionCardCoverAspect](./notion-types.collectioncardcoveraspect.md); gallery\_properties: Array<{ property: [CollectionPropertyID](./notion-types.collectionpropertyid.md); visible: boolean; }>; } | | +| [format](./notion-types.gallerycollectionview.format.md) | { gallery\_cover: [CollectionCardCover](./notion-types.collectioncardcover.md); gallery\_cover\_size: [CollectionCardCoverSize](./notion-types.collectioncardcoversize.md); gallery\_cover\_aspect: [CollectionCardCoverAspect](./notion-types.collectioncardcoveraspect.md); gallery\_properties: Array<{ property: [PropertyID](./notion-types.propertyid.md); visible: boolean; }>; } | | | [type](./notion-types.gallerycollectionview.type.md) | 'gallery' | | diff --git a/docs/notion-types.id.md b/docs/notion-types.id.md index 4bbb401d..9878e721 100644 --- a/docs/notion-types.id.md +++ b/docs/notion-types.id.md @@ -4,6 +4,8 @@ ## ID type +UUID + Signature: ```typescript diff --git a/docs/notion-types.listcollectionview.format.md b/docs/notion-types.listcollectionview.format.md index 6a07cebe..f6e3171a 100644 --- a/docs/notion-types.listcollectionview.format.md +++ b/docs/notion-types.listcollectionview.format.md @@ -9,7 +9,7 @@ ```typescript format: { list_properties: Array<{ - property: CollectionPropertyID; + property: PropertyID; visible: boolean; }>; }; diff --git a/docs/notion-types.listcollectionview.md b/docs/notion-types.listcollectionview.md index 1e0fd870..dfc2e5aa 100644 --- a/docs/notion-types.listcollectionview.md +++ b/docs/notion-types.listcollectionview.md @@ -15,6 +15,6 @@ export interface ListCollectionView extends BaseCollectionView | Property | Type | Description | | --- | --- | --- | -| [format](./notion-types.listcollectionview.format.md) | { list\_properties: Array<{ property: [CollectionPropertyID](./notion-types.collectionpropertyid.md); visible: boolean; }>; } | | +| [format](./notion-types.listcollectionview.format.md) | { list\_properties: Array<{ property: [PropertyID](./notion-types.propertyid.md); visible: boolean; }>; } | | | [type](./notion-types.listcollectionview.type.md) | 'list' | | diff --git a/docs/notion-types.md b/docs/notion-types.md index 37b5146d..8eae47bc 100644 --- a/docs/notion-types.md +++ b/docs/notion-types.md @@ -11,9 +11,10 @@ | [AggregationResult](./notion-types.aggregationresult.md) | | | [APIError](./notion-types.apierror.md) | | | [AudioBlock](./notion-types.audioblock.md) | | -| [BaseBlock](./notion-types.baseblock.md) | Base properties shared by all block types. | +| [BaseBlock](./notion-types.baseblock.md) | Base properties shared by all blocks. | | [BaseCollectionView](./notion-types.basecollectionview.md) | | | [BaseContentBlock](./notion-types.basecontentblock.md) | | +| [BaseFormula](./notion-types.baseformula.md) | | | [BasePageBlock](./notion-types.basepageblock.md) | | | [BaseTextBlock](./notion-types.basetextblock.md) | | | [BoardCollectionView](./notion-types.boardcollectionview.md) | | @@ -32,12 +33,15 @@ | [CollectionViewPageBlock](./notion-types.collectionviewpageblock.md) | | | [ColumnBlock](./notion-types.columnblock.md) | | | [ColumnListBlock](./notion-types.columnlistblock.md) | | +| [ConstantFormula](./notion-types.constantformula.md) | | | [DividerBlock](./notion-types.dividerblock.md) | | | [EmbedBlock](./notion-types.embedblock.md) | | | [EquationBlock](./notion-types.equationblock.md) | | | [ExtendedRecordMap](./notion-types.extendedrecordmap.md) | | | [FigmaBlock](./notion-types.figmablock.md) | | | [FileBlock](./notion-types.fileblock.md) | | +| [FormattedDate](./notion-types.formatteddate.md) | | +| [FunctionFormula](./notion-types.functionformula.md) | | | [GalleryCollectionView](./notion-types.gallerycollectionview.md) | | | [GoogleDriveBlock](./notion-types.googledriveblock.md) | | | [HeaderBlock](./notion-types.headerblock.md) | | @@ -46,9 +50,12 @@ | [MapsBlock](./notion-types.mapsblock.md) | | | [NotionMap](./notion-types.notionmap.md) | | | [NumberedListBlock](./notion-types.numberedlistblock.md) | | +| [OperatorFormula](./notion-types.operatorformula.md) | | | [PageBlock](./notion-types.pageblock.md) | | | [PageChunk](./notion-types.pagechunk.md) | | | [PdfBlock](./notion-types.pdfblock.md) | | +| [PropertyFormula](./notion-types.propertyformula.md) | | +| [PropertyMap](./notion-types.propertymap.md) | | | [QuoteBlock](./notion-types.quoteblock.md) | | | [RecordMap](./notion-types.recordmap.md) | | | [RecordValues](./notion-types.recordvalues.md) | | @@ -58,6 +65,7 @@ | [SelectOption](./notion-types.selectoption.md) | | | [SubHeaderBlock](./notion-types.subheaderblock.md) | | | [SubSubHeaderBlock](./notion-types.subsubheaderblock.md) | | +| [SymbolFormula](./notion-types.symbolformula.md) | | | [TableCollectionView](./notion-types.tablecollectionview.md) | | | [TableOfContentsBlock](./notion-types.tableofcontentsblock.md) | | | [TextBlock](./notion-types.textblock.md) | | @@ -82,7 +90,6 @@ | [CollectionCardCoverSize](./notion-types.collectioncardcoversize.md) | | | [CollectionCardCoverType](./notion-types.collectioncardcovertype.md) | | | [CollectionMap](./notion-types.collectionmap.md) | | -| [CollectionPropertyID](./notion-types.collectionpropertyid.md) | | | [CollectionView](./notion-types.collectionview.md) | | | [CollectionViewMap](./notion-types.collectionviewmap.md) | | | [CollectionViewType](./notion-types.collectionviewtype.md) | Types of collection views supported by Notion | @@ -91,16 +98,26 @@ | [DateFormat](./notion-types.dateformat.md) | | | [Decoration](./notion-types.decoration.md) | | | [ExternalLinkFormat](./notion-types.externallinkformat.md) | | -| [ID](./notion-types.id.md) | | +| [Formula](./notion-types.formula.md) | | +| [FormulaConstantType](./notion-types.formulaconstanttype.md) | | +| [FormulaFunctionType](./notion-types.formulafunctiontype.md) | | +| [FormulaOperatorType](./notion-types.formulaoperatortype.md) | | +| [FormulaResult](./notion-types.formularesult.md) | | +| [FormulaResultType](./notion-types.formularesulttype.md) | | +| [FormulaType](./notion-types.formulatype.md) | | +| [FormulaValueType](./notion-types.formulavaluetype.md) | | +| [ID](./notion-types.id.md) | UUID | | [InlineEquationFormat](./notion-types.inlineequationformat.md) | | | [ItalicFormat](./notion-types.italicformat.md) | | | [LinkFormat](./notion-types.linkformat.md) | | | [NumberFormat](./notion-types.numberformat.md) | Types of number formatting supported by Notion | | [PageFormat](./notion-types.pageformat.md) | | +| [PropertyID](./notion-types.propertyid.md) | Unique identifier for collection properties representing the columns in a traditional relational database.Either a 4-character hash like o;Os or title as a special, reserved property ID for collection title properties.You can think of title properties as primary indexes that are guaranteed to exist as in a traditional database. | | [PropertyType](./notion-types.propertytype.md) | Types of structured data supported by Notion collections | | [Role](./notion-types.role.md) | | | [StrikeFormat](./notion-types.strikeformat.md) | | | [SubDecoration](./notion-types.subdecoration.md) | | +| [UnderlineFormat](./notion-types.underlineformat.md) | | | [UserFormat](./notion-types.userformat.md) | | | [UserMap](./notion-types.usermap.md) | | diff --git a/docs/notion-types.operatorformula.args.md b/docs/notion-types.operatorformula.args.md new file mode 100644 index 00000000..dbd232aa --- /dev/null +++ b/docs/notion-types.operatorformula.args.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [OperatorFormula](./notion-types.operatorformula.md) > [args](./notion-types.operatorformula.args.md) + +## OperatorFormula.args property + +Signature: + +```typescript +args: Array; +``` diff --git a/docs/notion-types.operatorformula.md b/docs/notion-types.operatorformula.md new file mode 100644 index 00000000..01e968bb --- /dev/null +++ b/docs/notion-types.operatorformula.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [OperatorFormula](./notion-types.operatorformula.md) + +## OperatorFormula interface + +Signature: + +```typescript +export interface OperatorFormula extends BaseFormula +``` +Extends: [BaseFormula](./notion-types.baseformula.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [args](./notion-types.operatorformula.args.md) | Array<[Formula](./notion-types.formula.md)> | | +| [name](./notion-types.operatorformula.name.md) | [FormulaFunctionType](./notion-types.formulafunctiontype.md) | | +| [operator](./notion-types.operatorformula.operator.md) | [FormulaOperatorType](./notion-types.formulaoperatortype.md) | | +| [type](./notion-types.operatorformula.type.md) | 'operator' | | + diff --git a/docs/notion-types.operatorformula.name.md b/docs/notion-types.operatorformula.name.md new file mode 100644 index 00000000..d37f4b9f --- /dev/null +++ b/docs/notion-types.operatorformula.name.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [OperatorFormula](./notion-types.operatorformula.md) > [name](./notion-types.operatorformula.name.md) + +## OperatorFormula.name property + +Signature: + +```typescript +name: FormulaFunctionType; +``` diff --git a/docs/notion-types.operatorformula.operator.md b/docs/notion-types.operatorformula.operator.md new file mode 100644 index 00000000..5e745340 --- /dev/null +++ b/docs/notion-types.operatorformula.operator.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [OperatorFormula](./notion-types.operatorformula.md) > [operator](./notion-types.operatorformula.operator.md) + +## OperatorFormula.operator property + +Signature: + +```typescript +operator: FormulaOperatorType; +``` diff --git a/docs/notion-types.operatorformula.type.md b/docs/notion-types.operatorformula.type.md new file mode 100644 index 00000000..f5b47f60 --- /dev/null +++ b/docs/notion-types.operatorformula.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [OperatorFormula](./notion-types.operatorformula.md) > [type](./notion-types.operatorformula.type.md) + +## OperatorFormula.type property + +Signature: + +```typescript +type: 'operator'; +``` diff --git a/docs/notion-types.propertyformula.id.md b/docs/notion-types.propertyformula.id.md new file mode 100644 index 00000000..632de472 --- /dev/null +++ b/docs/notion-types.propertyformula.id.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [PropertyFormula](./notion-types.propertyformula.md) > [id](./notion-types.propertyformula.id.md) + +## PropertyFormula.id property + +Signature: + +```typescript +id: PropertyID; +``` diff --git a/docs/notion-types.propertyformula.md b/docs/notion-types.propertyformula.md new file mode 100644 index 00000000..92bd65ec --- /dev/null +++ b/docs/notion-types.propertyformula.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [PropertyFormula](./notion-types.propertyformula.md) + +## PropertyFormula interface + +Signature: + +```typescript +export interface PropertyFormula extends BaseFormula +``` +Extends: [BaseFormula](./notion-types.baseformula.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [id](./notion-types.propertyformula.id.md) | [PropertyID](./notion-types.propertyid.md) | | +| [name](./notion-types.propertyformula.name.md) | string | | +| [type](./notion-types.propertyformula.type.md) | 'property' | | + diff --git a/docs/notion-types.propertyformula.name.md b/docs/notion-types.propertyformula.name.md new file mode 100644 index 00000000..c394cf89 --- /dev/null +++ b/docs/notion-types.propertyformula.name.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [PropertyFormula](./notion-types.propertyformula.md) > [name](./notion-types.propertyformula.name.md) + +## PropertyFormula.name property + +Signature: + +```typescript +name: string; +``` diff --git a/docs/notion-types.propertyformula.type.md b/docs/notion-types.propertyformula.type.md new file mode 100644 index 00000000..83707b00 --- /dev/null +++ b/docs/notion-types.propertyformula.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [PropertyFormula](./notion-types.propertyformula.md) > [type](./notion-types.propertyformula.type.md) + +## PropertyFormula.type property + +Signature: + +```typescript +type: 'property'; +``` diff --git a/docs/notion-types.propertyid.md b/docs/notion-types.propertyid.md new file mode 100644 index 00000000..5339a533 --- /dev/null +++ b/docs/notion-types.propertyid.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [PropertyID](./notion-types.propertyid.md) + +## PropertyID type + +Unique identifier for collection properties representing the columns in a traditional relational database. + +Either a 4-character hash like `o;Os` or `title` as a special, reserved property ID for collection title properties. + +You can think of `title` properties as primary indexes that are guaranteed to exist as in a traditional database. + +Signature: + +```typescript +export declare type PropertyID = string; +``` diff --git a/docs/notion-types.propertymap.md b/docs/notion-types.propertymap.md new file mode 100644 index 00000000..d84ec621 --- /dev/null +++ b/docs/notion-types.propertymap.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [PropertyMap](./notion-types.propertymap.md) + +## PropertyMap interface + +Signature: + +```typescript +export interface PropertyMap +``` diff --git a/docs/notion-types.propertytype.md b/docs/notion-types.propertytype.md index 5396b656..33817db7 100644 --- a/docs/notion-types.propertytype.md +++ b/docs/notion-types.propertytype.md @@ -9,5 +9,5 @@ Types of structured data supported by Notion collections Signature: ```typescript -export declare type PropertyType = 'title' | 'text' | 'number' | 'select' | 'multi_select' | 'date' | 'person' | 'file' | 'checkbox' | 'url' | 'email' | 'phone_number'; +export declare type PropertyType = 'title' | 'text' | 'number' | 'select' | 'multi_select' | 'date' | 'person' | 'file' | 'checkbox' | 'url' | 'email' | 'phone_number' | 'formula' | 'relation' | 'created_time' | 'created_by' | 'last_edited_time' | 'last_edited_by'; ``` diff --git a/docs/notion-types.subdecoration.md b/docs/notion-types.subdecoration.md index 33eacb69..7fcb81c4 100644 --- a/docs/notion-types.subdecoration.md +++ b/docs/notion-types.subdecoration.md @@ -7,5 +7,5 @@ Signature: ```typescript -export declare type SubDecoration = BoldFormat | ItalicFormat | StrikeFormat | CodeFormat | LinkFormat | ColorFormat | DateFormat | UserFormat | InlineEquationFormat | PageFormat | ExternalLinkFormat; +export declare type SubDecoration = BoldFormat | ItalicFormat | StrikeFormat | CodeFormat | UnderlineFormat | LinkFormat | ColorFormat | DateFormat | UserFormat | InlineEquationFormat | PageFormat | ExternalLinkFormat; ``` diff --git a/docs/notion-types.symbolformula.md b/docs/notion-types.symbolformula.md new file mode 100644 index 00000000..da149618 --- /dev/null +++ b/docs/notion-types.symbolformula.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [SymbolFormula](./notion-types.symbolformula.md) + +## SymbolFormula interface + +Signature: + +```typescript +export interface SymbolFormula extends BaseFormula +``` +Extends: [BaseFormula](./notion-types.baseformula.md) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [name](./notion-types.symbolformula.name.md) | string | | +| [type](./notion-types.symbolformula.type.md) | 'symbol' | | + diff --git a/docs/notion-types.symbolformula.name.md b/docs/notion-types.symbolformula.name.md new file mode 100644 index 00000000..69ef2faa --- /dev/null +++ b/docs/notion-types.symbolformula.name.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [SymbolFormula](./notion-types.symbolformula.md) > [name](./notion-types.symbolformula.name.md) + +## SymbolFormula.name property + +Signature: + +```typescript +name: string; +``` diff --git a/docs/notion-types.symbolformula.type.md b/docs/notion-types.symbolformula.type.md new file mode 100644 index 00000000..e7938557 --- /dev/null +++ b/docs/notion-types.symbolformula.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [SymbolFormula](./notion-types.symbolformula.md) > [type](./notion-types.symbolformula.type.md) + +## SymbolFormula.type property + +Signature: + +```typescript +type: 'symbol'; +``` diff --git a/docs/notion-types.tablecollectionview.format.md b/docs/notion-types.tablecollectionview.format.md index 5dd4349c..1e8c7a2d 100644 --- a/docs/notion-types.tablecollectionview.format.md +++ b/docs/notion-types.tablecollectionview.format.md @@ -10,7 +10,7 @@ format: { table_wrap: boolean; table_properties: Array<{ - property: CollectionPropertyID; + property: PropertyID; visible: boolean; width: number; }>; diff --git a/docs/notion-types.tablecollectionview.md b/docs/notion-types.tablecollectionview.md index 9423e5eb..c6f7ab0d 100644 --- a/docs/notion-types.tablecollectionview.md +++ b/docs/notion-types.tablecollectionview.md @@ -15,7 +15,7 @@ export interface TableCollectionView extends BaseCollectionView | Property | Type | Description | | --- | --- | --- | -| [format](./notion-types.tablecollectionview.format.md) | { table\_wrap: boolean; table\_properties: Array<{ property: [CollectionPropertyID](./notion-types.collectionpropertyid.md); visible: boolean; width: number; }>; } | | +| [format](./notion-types.tablecollectionview.format.md) | { table\_wrap: boolean; table\_properties: Array<{ property: [PropertyID](./notion-types.propertyid.md); visible: boolean; width: number; }>; } | | | [page\_sort](./notion-types.tablecollectionview.page_sort.md) | [ID](./notion-types.id.md)\[\] | | | [type](./notion-types.tablecollectionview.type.md) | 'table' | | diff --git a/docs/notion-types.underlineformat.md b/docs/notion-types.underlineformat.md new file mode 100644 index 00000000..5b9216e9 --- /dev/null +++ b/docs/notion-types.underlineformat.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-types](./notion-types.md) > [UnderlineFormat](./notion-types.underlineformat.md) + +## UnderlineFormat type + +Signature: + +```typescript +export declare type UnderlineFormat = ['_']; +``` diff --git a/docs/notion-utils.getblockicon.md b/docs/notion-utils.getblockicon.md new file mode 100644 index 00000000..ea08853e --- /dev/null +++ b/docs/notion-utils.getblockicon.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getBlockIcon](./notion-utils.getblockicon.md) + +## getBlockIcon() function + +Signature: + +```typescript +export declare function getBlockIcon(block: Block, recordMap: ExtendedRecordMap): string | null | undefined; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| block | [Block](./notion-types.block.md) | | +| recordMap | [ExtendedRecordMap](./notion-types.extendedrecordmap.md) | | + +Returns: + +string \| null \| undefined + diff --git a/docs/notion-utils.getblockparentpage.md b/docs/notion-utils.getblockparentpage.md new file mode 100644 index 00000000..cf7b80df --- /dev/null +++ b/docs/notion-utils.getblockparentpage.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getBlockParentPage](./notion-utils.getblockparentpage.md) + +## getBlockParentPage variable + +Returns the parent page block containing a given page. + +Note that many times this will not be the direct parent block since some non-page content blocks can contain sub-blocks. + +Signature: + +```typescript +getBlockParentPage: (block: types.Block, recordMap: types.ExtendedRecordMap) => types.PageBlock | null +``` diff --git a/docs/notion-utils.getblocktitle.md b/docs/notion-utils.getblocktitle.md new file mode 100644 index 00000000..03c4a0eb --- /dev/null +++ b/docs/notion-utils.getblocktitle.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getBlockTitle](./notion-utils.getblocktitle.md) + +## getBlockTitle() function + +Signature: + +```typescript +export declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap): string | null; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| block | [Block](./notion-types.block.md) | | +| recordMap | [ExtendedRecordMap](./notion-types.extendedrecordmap.md) | | + +Returns: + +string \| null + diff --git a/docs/notion-utils.getdatevalue.md b/docs/notion-utils.getdatevalue.md new file mode 100644 index 00000000..26460174 --- /dev/null +++ b/docs/notion-utils.getdatevalue.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getDateValue](./notion-utils.getdatevalue.md) + +## getDateValue variable + +Attempts to find a valid date from a given property. + +Signature: + +```typescript +getDateValue: (prop: any[]) => types.FormattedDate | null +``` diff --git a/docs/notion-utils.getpagecontentblockids.md b/docs/notion-utils.getpagecontentblockids.md new file mode 100644 index 00000000..201cc0c7 --- /dev/null +++ b/docs/notion-utils.getpagecontentblockids.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getPageContentBlockIds](./notion-utils.getpagecontentblockids.md) + +## getPageContentBlockIds variable + +Gets the IDs of all blocks contained on a page starting from a root block ID. + +Signature: + +```typescript +getPageContentBlockIds: (recordMap: types.ExtendedRecordMap, blockId?: string | undefined) => string[] +``` diff --git a/docs/notion-utils.getpagetableofcontents.md b/docs/notion-utils.getpagetableofcontents.md index 64b0b1bf..ae2edf37 100644 --- a/docs/notion-utils.getpagetableofcontents.md +++ b/docs/notion-utils.getpagetableofcontents.md @@ -4,6 +4,8 @@ ## getPageTableOfContents variable +Gets the metadata for a table of contents block by parsing the page's H1, H2, and H3 elements. + Signature: ```typescript diff --git a/docs/notion-utils.getpagetitle.md b/docs/notion-utils.getpagetitle.md new file mode 100644 index 00000000..959aa0d7 --- /dev/null +++ b/docs/notion-utils.getpagetitle.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getPageTitle](./notion-utils.getpagetitle.md) + +## getPageTitle() function + +Signature: + +```typescript +export declare function getPageTitle(recordMap: ExtendedRecordMap): string | null; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| recordMap | [ExtendedRecordMap](./notion-types.extendedrecordmap.md) | | + +Returns: + +string \| null + diff --git a/docs/notion-utils.md b/docs/notion-utils.md index 7207e635..67f8a3ef 100644 --- a/docs/notion-utils.md +++ b/docs/notion-utils.md @@ -4,6 +4,14 @@ ## notion-utils package +## Functions + +| Function | Description | +| --- | --- | +| [getBlockIcon(block, recordMap)](./notion-utils.getblockicon.md) | | +| [getBlockTitle(block, recordMap)](./notion-utils.getblocktitle.md) | | +| [getPageTitle(recordMap)](./notion-utils.getpagetitle.md) | | + ## Interfaces | Interface | Description | @@ -14,7 +22,10 @@ | Variable | Description | | --- | --- | -| [getPageTableOfContents](./notion-utils.getpagetableofcontents.md) | | +| [getBlockParentPage](./notion-utils.getblockparentpage.md) | Returns the parent page block containing a given page.Note that many times this will not be the direct parent block since some non-page content blocks can contain sub-blocks. | +| [getDateValue](./notion-utils.getdatevalue.md) | Attempts to find a valid date from a given property. | +| [getPageContentBlockIds](./notion-utils.getpagecontentblockids.md) | Gets the IDs of all blocks contained on a page starting from a root block ID. | +| [getPageTableOfContents](./notion-utils.getpagetableofcontents.md) | Gets the metadata for a table of contents block by parsing the page's H1, H2, and H3 elements. | | [getTextContent](./notion-utils.gettextcontent.md) | Gets the raw, unformatted text content of a block's content value.This is useful, for instance, for extracting a block's title without any rich text formatting. | | [idToUuid](./notion-utils.idtouuid.md) | | | [parsePageId](./notion-utils.parsepageid.md) | Robustly extracts the notion page ID from a notion URL or pathname suffix.Defaults to returning a UUID (with dashes). | From 4099715bc8cfebeba960bd77158c66f27e7d533a Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 09:33:01 -0400 Subject: [PATCH 0011/1173] v2.2.2 --- lerna.json | 2 +- packages/notion-client/package.json | 4 ++-- packages/notion-utils/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index 8e9569e8..9afb1302 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.2.1", + "version": "2.2.2", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index ccf63a60..c04d9728 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.2.1", + "version": "2.2.2", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -17,7 +17,7 @@ "dependencies": { "got": "^11.5.2", "notion-types": "^2.2.1", - "notion-utils": "^2.2.1", + "notion-utils": "^2.2.2", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index b147dc49..c91f6ce4 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.2.1", + "version": "2.2.2", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "NotionX/notion-kit", "author": "Saasify ", From 1e030d7916f088dc7fefb2ab3ceedae263463b1e Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 10:31:42 -0400 Subject: [PATCH 0012/1173] =?UTF-8?q?=F0=9F=8E=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/notion-utils/src/parse-page-id.test.ts | 5 +++-- packages/notion-utils/src/parse-page-id.ts | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/notion-utils/src/parse-page-id.test.ts b/packages/notion-utils/src/parse-page-id.test.ts index f680c0d0..f79b6836 100644 --- a/packages/notion-utils/src/parse-page-id.test.ts +++ b/packages/notion-utils/src/parse-page-id.test.ts @@ -28,7 +28,8 @@ const pageIdFixturesFailure = [ '267c0d1f1df8457f9b5c8f7efca16d83a', '267c0d1f1%f8457f9b5c8f7efca16d83', 'Twitter-Automation-Tool', - 'fde5ac74-eea3-4527-8f00-4482710e1af' + 'fde5ac74-eea3-4527-8f00-4482710e1af', + null ] test('utils.parsePageId non-uuid success', (t) => { @@ -51,7 +52,7 @@ test('utils.parsePageId uuid success', (t) => { test('utils.parsePageId failure', (t) => { for (const id of pageIdFixturesFailure) { - const pageId = parsePageId(id) + const pageId = parsePageId(id as string) t.falsy(pageId) } }) diff --git a/packages/notion-utils/src/parse-page-id.ts b/packages/notion-utils/src/parse-page-id.ts index 0a75232e..26d25a63 100644 --- a/packages/notion-utils/src/parse-page-id.ts +++ b/packages/notion-utils/src/parse-page-id.ts @@ -12,6 +12,10 @@ export const parsePageId = ( id: string = '', { uuid = true }: { uuid?: boolean } = {} ) => { + if (!id) { + return null + } + id = id.split('?')[0] const match = id.match(pageIdRe) From 52661f78047b0af3659bdfae19f85886f684ae13 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 12:02:50 -0400 Subject: [PATCH 0013/1173] temp --- packages/notion-client/example.js | 3 ++- packages/notion-client/package.json | 2 +- packages/notion-client/src/notion-api.ts | 6 ++++-- packages/notion-utils/src/get-block-title.ts | 2 +- yarn.lock | 16 ++++++++-------- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/notion-client/example.js b/packages/notion-client/example.js index f07bed10..bae94082 100644 --- a/packages/notion-client/example.js +++ b/packages/notion-client/example.js @@ -8,8 +8,9 @@ async function main() { // const output = await api.getPage('139ac7d730d54b5e93937a282d8ff635') // const output = await api.getPage('8a586d253f984b85b48254da84465d23') // const output = await api.getPage('b21b2ed02ad446b2af74ee6e262e2124') + // const output = await api.getPage('3f759cf9d8fe44a5988e0c3b6903e224') try { - const output = await api.getPage('3f759cf9d8fe44a5988e0c3b6903e224') + const output = await api.getPage('067dd719a912471ea9a3ac10710e7fdf') // collection example // const collectionId = '2d8aec23-8281-4a94-9090-caaf823dd21a' diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index c04d9728..6434b176 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -15,7 +15,7 @@ "test": "ava -v 'build/cjs/**/*.test.js'" }, "dependencies": { - "got": "^11.5.2", + "got": "^11.6.0", "notion-types": "^2.2.1", "notion-utils": "^2.2.2", "p-map": "^4.0.0" diff --git a/packages/notion-client/src/notion-api.ts b/packages/notion-client/src/notion-api.ts index 430e4a5b..a4c99beb 100644 --- a/packages/notion-client/src/notion-api.ts +++ b/packages/notion-client/src/notion-api.ts @@ -365,9 +365,11 @@ export class NotionAPI { headers.cookie = `token_v2=${this._authToken}` } + const url = `${this._apiBaseUrl}/${endpoint}` + console.log('got', { url }) return got - .post(endpoint, { - prefixUrl: this._apiBaseUrl, + .post(url, { + // prefixUrl: this._apiBaseUrl, json: body, headers }) diff --git a/packages/notion-utils/src/get-block-title.ts b/packages/notion-utils/src/get-block-title.ts index 08259a8f..1c146c14 100644 --- a/packages/notion-utils/src/get-block-title.ts +++ b/packages/notion-utils/src/get-block-title.ts @@ -17,5 +17,5 @@ export function getBlockTitle(block: Block, recordMap: ExtendedRecordMap) { } } - return null + return '' } diff --git a/yarn.lock b/yarn.lock index a28ca478..d289d26c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1032,7 +1032,7 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== -"@sindresorhus/is@^3.0.0": +"@sindresorhus/is@^3.1.1": version "3.1.2" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-3.1.2.tgz#548650de521b344e3781fbdb0ece4aa6f729afb8" integrity sha512-JiX9vxoKMmu8Y3Zr2RVathBL1Cdu4Nt4MuNWemt1Nc06A0RAin9c5FArkhGsyMBWfCu4zj+9b+GxtjAnE4qqLQ== @@ -3057,19 +3057,19 @@ globby@^9.2.0: pify "^4.0.1" slash "^2.0.0" -got@^11.5.2: - version "11.5.2" - resolved "https://registry.yarnpkg.com/got/-/got-11.5.2.tgz#772e3f3a06d9c7589c7c94dc3c83cdb31ddbf742" - integrity sha512-yUhpEDLeuGiGJjRSzEq3kvt4zJtAcjKmhIiwNp/eUs75tRlXfWcHo5tcBaMQtnjHWC7nQYT5HkY/l0QOQTkVww== +got@^11.6.0: + version "11.6.0" + resolved "https://registry.yarnpkg.com/got/-/got-11.6.0.tgz#4978c78f3cbc3a45ee95381f8bb6efd1db1f4638" + integrity sha512-ErhWb4IUjQzJ3vGs3+RR12NWlBDDkRciFpAkQ1LPUxi6OnwhGj07gQxjPsyIk69s7qMihwKrKquV6VQq7JNYLA== dependencies: - "@sindresorhus/is" "^3.0.0" + "@sindresorhus/is" "^3.1.1" "@szmarczak/http-timer" "^4.0.5" "@types/cacheable-request" "^6.0.1" "@types/responselike" "^1.0.0" cacheable-lookup "^5.0.3" cacheable-request "^7.0.1" decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.0" + http2-wrapper "^1.0.0-beta.5.2" lowercase-keys "^2.0.0" p-cancelable "^2.0.0" responselike "^2.0.0" @@ -3221,7 +3221,7 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -http2-wrapper@^1.0.0-beta.5.0: +http2-wrapper@^1.0.0-beta.5.2: version "1.0.0-beta.5.2" resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz#8b923deb90144aea65cf834b016a340fc98556f3" integrity sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ== From 5f022591c762a285e015b31444a6488b6a3a81c7 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 12:02:59 -0400 Subject: [PATCH 0014/1173] v2.2.3 --- lerna.json | 2 +- packages/notion-client/package.json | 4 ++-- packages/notion-utils/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index 9afb1302..f8a4e8f9 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.2.2", + "version": "2.2.3", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 6434b176..a1b2d363 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.2.2", + "version": "2.2.3", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -17,7 +17,7 @@ "dependencies": { "got": "^11.6.0", "notion-types": "^2.2.1", - "notion-utils": "^2.2.2", + "notion-utils": "^2.2.3", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index c91f6ce4..d6db2e55 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.2.2", + "version": "2.2.3", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "NotionX/notion-kit", "author": "Saasify ", From 5f65d46c45492e7db88594a50ecaae2cc96fdf86 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 13:10:40 -0400 Subject: [PATCH 0015/1173] feat: replace got with node-fetch --- packages/notion-client/package.json | 3 +- packages/notion-client/src/notion-api.ts | 21 +-- yarn.lock | 159 ++++------------------- 3 files changed, 36 insertions(+), 147 deletions(-) diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index a1b2d363..f8518d5a 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -15,12 +15,13 @@ "test": "ava -v 'build/cjs/**/*.test.js'" }, "dependencies": { - "got": "^11.6.0", + "node-fetch": "^2.6.1", "notion-types": "^2.2.1", "notion-utils": "^2.2.3", "p-map": "^4.0.0" }, "devDependencies": { + "@types/node-fetch": "^2.5.7", "ava": "^3.11.1" } } diff --git a/packages/notion-client/src/notion-api.ts b/packages/notion-client/src/notion-api.ts index a4c99beb..a70ff9c0 100644 --- a/packages/notion-client/src/notion-api.ts +++ b/packages/notion-client/src/notion-api.ts @@ -1,4 +1,4 @@ -import got from 'got' +import fetch from 'node-fetch' import pMap from 'p-map' import { parsePageId, getPageContentBlockIds, uuidToId } from 'notion-utils' @@ -359,20 +359,21 @@ export class NotionAPI { endpoint: string body: object }): Promise { - const headers: any = {} + const headers: any = { + 'Content-Type': 'application/json' + } if (this._authToken) { headers.cookie = `token_v2=${this._authToken}` } const url = `${this._apiBaseUrl}/${endpoint}` - console.log('got', { url }) - return got - .post(url, { - // prefixUrl: this._apiBaseUrl, - json: body, - headers - }) - .json() + console.log('notion fetch', url) + + return fetch(url, { + method: 'post', + body: JSON.stringify(body), + headers + }).then((res) => res.json()) } } diff --git a/yarn.lock b/yarn.lock index d289d26c..c1072ae3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1032,11 +1032,6 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== -"@sindresorhus/is@^3.1.1": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-3.1.2.tgz#548650de521b344e3781fbdb0ece4aa6f729afb8" - integrity sha512-JiX9vxoKMmu8Y3Zr2RVathBL1Cdu4Nt4MuNWemt1Nc06A0RAin9c5FArkhGsyMBWfCu4zj+9b+GxtjAnE4qqLQ== - "@szmarczak/http-timer@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" @@ -1044,28 +1039,11 @@ dependencies: defer-to-connect "^1.0.1" -"@szmarczak/http-timer@^4.0.5": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.5.tgz#bfbd50211e9dfa51ba07da58a14cdfd333205152" - integrity sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ== - dependencies: - defer-to-connect "^2.0.0" - "@types/argparse@1.0.38": version "1.0.38" resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9" integrity sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA== -"@types/cacheable-request@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.1.tgz#5d22f3dded1fd3a84c0bbeb5039a7419c2c91976" - integrity sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ== - dependencies: - "@types/http-cache-semantics" "*" - "@types/keyv" "*" - "@types/node" "*" - "@types/responselike" "*" - "@types/color-name@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" @@ -1079,18 +1057,6 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/http-cache-semantics@*": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a" - integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A== - -"@types/keyv@*": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7" - integrity sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw== - dependencies: - "@types/node" "*" - "@types/minimatch@*": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" @@ -1101,6 +1067,14 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= +"@types/node-fetch@^2.5.7": + version "2.5.7" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.7.tgz#20a2afffa882ab04d44ca786449a276f9f6bbf3c" + integrity sha512-o2WVNf5UhWRkxlf6eq+jMZDu7kjgpgJfl4xVNlvryc95O/6F2ld8ztKX+qu+Rjyet93WAWm5LjeX9H5FGkODvw== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + "@types/node@*", "@types/node@>= 8": version "14.6.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499" @@ -1116,13 +1090,6 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== -"@types/responselike@*", "@types/responselike@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" - integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== - dependencies: - "@types/node" "*" - "@zkochan/cmd-shim@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e" @@ -1615,11 +1582,6 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" -cacheable-lookup@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.3.tgz#049fdc59dffdd4fc285e8f4f82936591bd59fec3" - integrity sha512-W+JBqF9SWe18A72XFzN/V/CULFzPm7sBXzzR6ekkE+3tLG72wFZrBiBZhrZuDoYexop4PHJVdFAKb/Nj9+tm9w== - cacheable-request@^6.0.0: version "6.1.0" resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" @@ -1633,19 +1595,6 @@ cacheable-request@^6.0.0: normalize-url "^4.1.0" responselike "^1.0.2" -cacheable-request@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.1.tgz#062031c2856232782ed694a257fa35da93942a58" - integrity sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^4.0.0" - lowercase-keys "^2.0.0" - normalize-url "^4.1.0" - responselike "^2.0.0" - call-me-maybe@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" @@ -1939,7 +1888,7 @@ columnify@^1.5.4: strip-ansi "^3.0.0" wcwidth "^1.0.0" -combined-stream@^1.0.6, combined-stream@~1.0.6: +combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== @@ -2272,13 +2221,6 @@ decompress-response@^3.3.0: dependencies: mimic-response "^1.0.0" -decompress-response@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" - integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== - dependencies: - mimic-response "^3.1.0" - dedent@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" @@ -2301,11 +2243,6 @@ defer-to-connect@^1.0.1: resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== -defer-to-connect@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.0.tgz#83d6b199db041593ac84d781b5222308ccf4c2c1" - integrity sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg== - define-properties@^1.1.2, define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -2784,6 +2721,15 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= +form-data@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682" + integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" @@ -3057,23 +3003,6 @@ globby@^9.2.0: pify "^4.0.1" slash "^2.0.0" -got@^11.6.0: - version "11.6.0" - resolved "https://registry.yarnpkg.com/got/-/got-11.6.0.tgz#4978c78f3cbc3a45ee95381f8bb6efd1db1f4638" - integrity sha512-ErhWb4IUjQzJ3vGs3+RR12NWlBDDkRciFpAkQ1LPUxi6OnwhGj07gQxjPsyIk69s7qMihwKrKquV6VQq7JNYLA== - dependencies: - "@sindresorhus/is" "^3.1.1" - "@szmarczak/http-timer" "^4.0.5" - "@types/cacheable-request" "^6.0.1" - "@types/responselike" "^1.0.0" - cacheable-lookup "^5.0.3" - cacheable-request "^7.0.1" - decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.2" - lowercase-keys "^2.0.0" - p-cancelable "^2.0.0" - responselike "^2.0.0" - got@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" @@ -3221,14 +3150,6 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -http2-wrapper@^1.0.0-beta.5.2: - version "1.0.0-beta.5.2" - resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz#8b923deb90144aea65cf834b016a340fc98556f3" - integrity sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ== - dependencies: - quick-lru "^5.1.1" - resolve-alpn "^1.0.0" - https-proxy-agent@^2.2.3: version "2.2.4" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" @@ -3743,11 +3664,6 @@ json-buffer@3.0.0: resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= -json-buffer@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" - integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== - json-parse-better-errors@^1.0.0, json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" @@ -3802,13 +3718,6 @@ keyv@^3.0.0: dependencies: json-buffer "3.0.0" -keyv@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.0.1.tgz#9fe703cb4a94d6d11729d320af033307efd02ee6" - integrity sha512-xz6Jv6oNkbhrFCvCP7HQa8AaII8y8LRpoSm661NOKLr4uHuBwhX4epXrPQgF3+xdJnN4Esm5X0xwY4bOlALOtw== - dependencies: - json-buffer "3.0.1" - kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -4255,11 +4164,6 @@ mimic-response@^1.0.0, mimic-response@^1.0.1: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== -mimic-response@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" - integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== - min-indent@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" @@ -4449,6 +4353,11 @@ node-fetch@^2.3.0, node-fetch@^2.5.0: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== +node-fetch@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + node-gyp@^5.0.2: version "5.1.1" resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-5.1.1.tgz#eb915f7b631c937d282e33aed44cb7a025f62a3e" @@ -4722,11 +4631,6 @@ p-cancelable@^1.0.0: resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== -p-cancelable@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.0.0.tgz#4a3740f5bdaf5ed5d7c3e34882c6fb5d6b266a6e" - integrity sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg== - p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -5164,11 +5068,6 @@ quick-lru@^4.0.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== -quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - rc@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" @@ -5403,11 +5302,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -resolve-alpn@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.0.0.tgz#745ad60b3d6aff4b4a48e01b8c0bdc70959e0e8c" - integrity sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA== - resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" @@ -5463,13 +5357,6 @@ responselike@^1.0.2: dependencies: lowercase-keys "^1.0.0" -responselike@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.0.tgz#26391bcc3174f750f9a79eacc40a12a5c42d7723" - integrity sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw== - dependencies: - lowercase-keys "^2.0.0" - restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" From f3a245c4a01ca0f213908af27c03f7200a4833c5 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 13:11:12 -0400 Subject: [PATCH 0016/1173] v2.3.0 --- lerna.json | 2 +- packages/notion-client/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index f8a4e8f9..2df3cb70 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.2.3", + "version": "2.3.0", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index f8518d5a..7476fa12 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.2.3", + "version": "2.3.0", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", From b99252bd338a07cc935c8700b7cbdbf42fd6aff9 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 13:21:33 -0400 Subject: [PATCH 0017/1173] =?UTF-8?q?=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/notion-client/src/notion-api.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/notion-client/src/notion-api.ts b/packages/notion-client/src/notion-api.ts index a70ff9c0..b541f087 100644 --- a/packages/notion-client/src/notion-api.ts +++ b/packages/notion-client/src/notion-api.ts @@ -368,7 +368,6 @@ export class NotionAPI { } const url = `${this._apiBaseUrl}/${endpoint}` - console.log('notion fetch', url) return fetch(url, { method: 'post', From f92bffae1c7dcc2bf2d1bba115ed7d1b2961dda4 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 13:21:41 -0400 Subject: [PATCH 0018/1173] v2.3.1 --- lerna.json | 2 +- packages/notion-client/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index 2df3cb70..01eb8d95 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.3.0", + "version": "2.3.1", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 7476fa12..d73ecc66 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.3.0", + "version": "2.3.1", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", From 0ce22faef123a38b23e00311d3757a4e8e148dfd Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 13:24:36 -0400 Subject: [PATCH 0019/1173] =?UTF-8?q?=F0=9F=9B=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/notion-client/src/notion-api.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/notion-client/src/notion-api.ts b/packages/notion-client/src/notion-api.ts index b541f087..bda68013 100644 --- a/packages/notion-client/src/notion-api.ts +++ b/packages/notion-client/src/notion-api.ts @@ -6,6 +6,9 @@ import * as notion from 'notion-types' import * as types from './types' +/** + * Main Notion API client. + */ export class NotionAPI { private readonly _apiBaseUrl: string private readonly _authToken?: string From fb5f8820142b196aa3e4ef96e59cb5151be6890a Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 13:24:45 -0400 Subject: [PATCH 0020/1173] v2.3.2 --- lerna.json | 2 +- packages/notion-client/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lerna.json b/lerna.json index 01eb8d95..b8f8fb64 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.3.1", + "version": "2.3.2", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index d73ecc66..0aeafce6 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.3.1", + "version": "2.3.2", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", From e32d7dffeca6266b8996edec579c90e0fa0a6477 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 14:31:36 -0400 Subject: [PATCH 0021/1173] minor fixes and add getAllPagesInSpace --- packages/notion-utils/package.json | 3 +- .../src/get-all-pages-in-space.ts | 70 +++++++++++++++++++ packages/notion-utils/src/index.ts | 1 + packages/notion-utils/src/parse-page-id.ts | 2 +- yarn.lock | 20 ++++++ 5 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 packages/notion-utils/src/get-all-pages-in-space.ts diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index d6db2e55..d45bd6f3 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -15,7 +15,8 @@ "test": "ava -v 'build/cjs/**/*.test.js'" }, "dependencies": { - "notion-types": "^2.2.1" + "notion-types": "^2.2.1", + "p-queue": "^6.6.1" }, "devDependencies": { "ava": "^3.11.1", diff --git a/packages/notion-utils/src/get-all-pages-in-space.ts b/packages/notion-utils/src/get-all-pages-in-space.ts new file mode 100644 index 00000000..7ec8c29c --- /dev/null +++ b/packages/notion-utils/src/get-all-pages-in-space.ts @@ -0,0 +1,70 @@ +import PQueue from 'p-queue' + +import { ExtendedRecordMap, ID } from 'notion-types' +import { parsePageId } from './parse-page-id' + +/** + * Performs a traversal over a given Notion workspace starting from a seed page. + * + * Returns a map containing all of the pages that are reachable from the seed + * page in the space. + * + * @param rootPageId - Page ID to start from. + * @param rootSpaceId - Space ID to scope traversal. + * @param getPage - Function used to fetch a single page. + * @param opts - Optional config + * @param opts.concurrency - Optional max concurrency (default 4) + */ +export async function getAllPagesInSpace( + rootPageId: string, + rootSpaceId: string, + getPage: (pageId: string) => Promise, + { + concurrency = 4 + }: { + concurrency?: number + } = {} +): Promise> { + const pages = new Map() + const pendingPageIds = new Set() + const queue = new PQueue({ concurrency }) + + async function processPage(pageId: string) { + pageId = parsePageId(pageId) as string + + if (pageId && !pages.has(pageId) && !pendingPageIds.has(pageId)) { + pendingPageIds.add(pageId) + + queue.add(async () => { + try { + const page = await getPage(pageId) + + Object.keys(page.block) + .filter((key) => { + const block = page.block[key]?.value + if (!block) return + + const isPage = + block.type === 'page' || block.type === 'collection_view_page' + + // the space id check is important because pages can link to pages in other spaces + return isPage && block.space_id === rootSpaceId + }) + .forEach((subPageId) => processPage(subPageId)) + + pages.set(pageId, page) + } catch (err) { + console.warn('page load error', { pageId, spaceId: rootSpaceId }, err) + pages.set(pageId, null) + } + + pendingPageIds.delete(pageId) + }) + } + } + + await processPage(rootPageId) + await queue.onIdle() + + return pages +} diff --git a/packages/notion-utils/src/index.ts b/packages/notion-utils/src/index.ts index c3bb3321..a35deaae 100644 --- a/packages/notion-utils/src/index.ts +++ b/packages/notion-utils/src/index.ts @@ -9,3 +9,4 @@ export * from './get-page-content-block-ids' export * from './parse-page-id' export * from './id-to-uuid' export * from './uuid-to-id' +export * from './get-all-pages-in-space' diff --git a/packages/notion-utils/src/parse-page-id.ts b/packages/notion-utils/src/parse-page-id.ts index 26d25a63..339d1c5a 100644 --- a/packages/notion-utils/src/parse-page-id.ts +++ b/packages/notion-utils/src/parse-page-id.ts @@ -9,7 +9,7 @@ const pageId2Re = /\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{1 * Defaults to returning a UUID (with dashes). */ export const parsePageId = ( - id: string = '', + id: string | null = '', { uuid = true }: { uuid?: boolean } = {} ) => { if (!id) { diff --git a/yarn.lock b/yarn.lock index c1072ae3..5bc17e99 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2512,6 +2512,11 @@ eventemitter3@^3.1.0: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7" integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q== +eventemitter3@^4.0.4: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + execa@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" @@ -4714,11 +4719,26 @@ p-queue@^4.0.0: dependencies: eventemitter3 "^3.1.0" +p-queue@^6.6.1: + version "6.6.1" + resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-6.6.1.tgz#578891ada028a61371ec2692b26614d1b7d2b10a" + integrity sha512-miQiSxLYPYBxGkrldecZC18OTLjdUqnlRebGzPRiVxB8mco7usCmm7hFuxiTvp93K18JnLtE4KMMycjAu/cQQg== + dependencies: + eventemitter3 "^4.0.4" + p-timeout "^3.1.0" + p-reduce@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" integrity sha1-GMKw3ZNqRpClKfgjH1ig/bakffo= +p-timeout@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe" + integrity sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg== + dependencies: + p-finally "^1.0.0" + p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" From 61e55bc7ae7dbf0936625de2fc53f5cda4578794 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 14:31:48 -0400 Subject: [PATCH 0022/1173] v2.3.3 --- lerna.json | 2 +- packages/notion-client/package.json | 4 ++-- packages/notion-utils/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index b8f8fb64..6e0ffb89 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.3.2", + "version": "2.3.3", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 0aeafce6..532db81f 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.3.2", + "version": "2.3.3", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -17,7 +17,7 @@ "dependencies": { "node-fetch": "^2.6.1", "notion-types": "^2.2.1", - "notion-utils": "^2.2.3", + "notion-utils": "^2.3.3", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index d45bd6f3..516869a8 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.2.3", + "version": "2.3.3", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "NotionX/notion-kit", "author": "Saasify ", From 7af2a9a1ca8064f471bf067f637e9723e1900c0f Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 15:16:56 -0400 Subject: [PATCH 0023/1173] feat: add more utils --- .../src/get-all-pages-in-space.ts | 16 +++++---- .../notion-utils/src/get-canonical-page-id.ts | 33 +++++++++++++++++++ packages/notion-utils/src/id-to-uuid.ts | 2 +- packages/notion-utils/src/index.ts | 1 + 4 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 packages/notion-utils/src/get-canonical-page-id.ts diff --git a/packages/notion-utils/src/get-all-pages-in-space.ts b/packages/notion-utils/src/get-all-pages-in-space.ts index 7ec8c29c..517f6b13 100644 --- a/packages/notion-utils/src/get-all-pages-in-space.ts +++ b/packages/notion-utils/src/get-all-pages-in-space.ts @@ -1,8 +1,12 @@ import PQueue from 'p-queue' -import { ExtendedRecordMap, ID } from 'notion-types' +import { ExtendedRecordMap } from 'notion-types' import { parsePageId } from './parse-page-id' +export interface PageMap { + [pageId: string]: ExtendedRecordMap | null +} + /** * Performs a traversal over a given Notion workspace starting from a seed page. * @@ -24,15 +28,15 @@ export async function getAllPagesInSpace( }: { concurrency?: number } = {} -): Promise> { - const pages = new Map() +): Promise { + const pages: PageMap = {} const pendingPageIds = new Set() const queue = new PQueue({ concurrency }) async function processPage(pageId: string) { pageId = parsePageId(pageId) as string - if (pageId && !pages.has(pageId) && !pendingPageIds.has(pageId)) { + if (pageId && !pages[pageId] && !pendingPageIds.has(pageId)) { pendingPageIds.add(pageId) queue.add(async () => { @@ -52,10 +56,10 @@ export async function getAllPagesInSpace( }) .forEach((subPageId) => processPage(subPageId)) - pages.set(pageId, page) + pages[pageId] = page } catch (err) { console.warn('page load error', { pageId, spaceId: rootSpaceId }, err) - pages.set(pageId, null) + pages[pageId] = null } pendingPageIds.delete(pageId) diff --git a/packages/notion-utils/src/get-canonical-page-id.ts b/packages/notion-utils/src/get-canonical-page-id.ts new file mode 100644 index 00000000..16da5cef --- /dev/null +++ b/packages/notion-utils/src/get-canonical-page-id.ts @@ -0,0 +1,33 @@ +import { ExtendedRecordMap } from 'notion-types' +import { uuidToId } from './uuid-to-id' +import { getPageTitle } from './get-page-title' + +/** + * Gets the canonical, display-friendly version of a page's ID for use in URLs. + */ +export const getCanonicalPageId = ( + pageId: string, + recordMap: ExtendedRecordMap +): string | null => { + if (!pageId || !recordMap) return null + + const id = uuidToId(pageId) + const title = normalizeTitle(getPageTitle(recordMap)) + + if (title) { + return `${normalizeTitle(title)}-${id}` + } else { + return id + } +} + +export const normalizeTitle = (title: string | null): string => { + return (title || '') + .replace(/ /g, '-') + .replace(/[^a-zA-Z0-9-]/g, '') + .replace(/--/g, '-') + .replace(/-$/, '') + .replace(/^-/, '') + .trim() + .toLowerCase() +} diff --git a/packages/notion-utils/src/id-to-uuid.ts b/packages/notion-utils/src/id-to-uuid.ts index 6395facc..894976d7 100644 --- a/packages/notion-utils/src/id-to-uuid.ts +++ b/packages/notion-utils/src/id-to-uuid.ts @@ -1,4 +1,4 @@ -export const idToUuid = (id: string) => +export const idToUuid = (id: string = '') => `${id.substr(0, 8)}-${id.substr(8, 4)}-${id.substr(12, 4)}-${id.substr( 16, 4 diff --git a/packages/notion-utils/src/index.ts b/packages/notion-utils/src/index.ts index a35deaae..aed39b8a 100644 --- a/packages/notion-utils/src/index.ts +++ b/packages/notion-utils/src/index.ts @@ -10,3 +10,4 @@ export * from './parse-page-id' export * from './id-to-uuid' export * from './uuid-to-id' export * from './get-all-pages-in-space' +export * from './get-canonical-page-id' From 30a4026ba2781c7664cd69bc093de9cc41ca01d8 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Sun, 6 Sep 2020 15:17:08 -0400 Subject: [PATCH 0024/1173] v2.4.0 --- lerna.json | 2 +- packages/notion-client/package.json | 4 ++-- packages/notion-utils/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index 6e0ffb89..b175285b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.3.3", + "version": "2.4.0", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index 532db81f..c7642cc4 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.3.3", + "version": "2.4.0", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -17,7 +17,7 @@ "dependencies": { "node-fetch": "^2.6.1", "notion-types": "^2.2.1", - "notion-utils": "^2.3.3", + "notion-utils": "^2.4.0", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index 516869a8..36ac2a7d 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.3.3", + "version": "2.4.0", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "NotionX/notion-kit", "author": "Saasify ", From 55fde526d33be9b540b7725ff82d4065fcf3e71c Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 7 Sep 2020 13:51:01 -0400 Subject: [PATCH 0025/1173] bugfix: canonical page ids --- .../notion-utils/src/get-canonical-page-id.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/notion-utils/src/get-canonical-page-id.ts b/packages/notion-utils/src/get-canonical-page-id.ts index 16da5cef..e9513928 100644 --- a/packages/notion-utils/src/get-canonical-page-id.ts +++ b/packages/notion-utils/src/get-canonical-page-id.ts @@ -1,6 +1,6 @@ import { ExtendedRecordMap } from 'notion-types' import { uuidToId } from './uuid-to-id' -import { getPageTitle } from './get-page-title' +import { getBlockTitle } from './get-block-title' /** * Gets the canonical, display-friendly version of a page's ID for use in URLs. @@ -12,13 +12,17 @@ export const getCanonicalPageId = ( if (!pageId || !recordMap) return null const id = uuidToId(pageId) - const title = normalizeTitle(getPageTitle(recordMap)) + const block = recordMap.block[pageId]?.value - if (title) { - return `${normalizeTitle(title)}-${id}` - } else { - return id + if (block) { + const title = normalizeTitle(getBlockTitle(block, recordMap)) + + if (title) { + return `${normalizeTitle(title)}-${id}` + } } + + return id } export const normalizeTitle = (title: string | null): string => { From e6371a8426a29a214c17444d33de9b23b8d6706d Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 7 Sep 2020 13:51:10 -0400 Subject: [PATCH 0026/1173] v2.4.1 --- lerna.json | 2 +- packages/notion-client/package.json | 4 ++-- packages/notion-utils/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index b175285b..75327e39 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.4.0", + "version": "2.4.1", "npmClient": "yarn", "useWorkspaces": true, "packages": [ diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index c7642cc4..ac5baf57 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -1,6 +1,6 @@ { "name": "notion-client", - "version": "2.4.0", + "version": "2.4.1", "description": "Robust TypeScript client for the unofficial Notion API.", "repository": "NotionX/notion-kit", "author": "Saasify ", @@ -17,7 +17,7 @@ "dependencies": { "node-fetch": "^2.6.1", "notion-types": "^2.2.1", - "notion-utils": "^2.4.0", + "notion-utils": "^2.4.1", "p-map": "^4.0.0" }, "devDependencies": { diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index 36ac2a7d..bc12241e 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -1,6 +1,6 @@ { "name": "notion-utils", - "version": "2.4.0", + "version": "2.4.1", "description": "Useful utilities for working with Notion data. Isomorphic.", "repository": "NotionX/notion-kit", "author": "Saasify ", From 5031756fbc551fe426b0501bff56799665703296 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 7 Sep 2020 15:00:21 -0400 Subject: [PATCH 0027/1173] =?UTF-8?q?=F0=9F=A6=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/notion-utils/src/get-canonical-page-id.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/notion-utils/src/get-canonical-page-id.ts b/packages/notion-utils/src/get-canonical-page-id.ts index e9513928..8a26580e 100644 --- a/packages/notion-utils/src/get-canonical-page-id.ts +++ b/packages/notion-utils/src/get-canonical-page-id.ts @@ -18,7 +18,7 @@ export const getCanonicalPageId = ( const title = normalizeTitle(getBlockTitle(block, recordMap)) if (title) { - return `${normalizeTitle(title)}-${id}` + return `${title}-${id}` } } From 60e06b7cdc226609b5e5b8601ca733a6df2e5c51 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Tue, 6 Oct 2020 03:30:05 -0400 Subject: [PATCH 0028/1173] chore: update deps --- docs/notion-client.md | 2 +- docs/notion-client.notionapi.md | 2 + docs/notion-utils.getallpagesinspace.md | 31 +++ docs/notion-utils.getblocktitle.md | 4 +- docs/notion-utils.getcanonicalpageid.md | 13 + docs/notion-utils.idtouuid.md | 2 +- docs/notion-utils.md | 4 + docs/notion-utils.normalizetitle.md | 11 + docs/notion-utils.pagemap.md | 11 + docs/notion-utils.parsepageid.md | 2 +- package.json | 5 +- packages/notion-client/package.json | 2 +- packages/notion-utils/package.json | 3 +- .../src/get-all-pages-in-space.ts | 1 - yarn.lock | 251 +++++++++--------- 15 files changed, 208 insertions(+), 136 deletions(-) create mode 100644 docs/notion-utils.getallpagesinspace.md create mode 100644 docs/notion-utils.getcanonicalpageid.md create mode 100644 docs/notion-utils.normalizetitle.md create mode 100644 docs/notion-utils.pagemap.md diff --git a/docs/notion-client.md b/docs/notion-client.md index c696fb86..f471f7ad 100644 --- a/docs/notion-client.md +++ b/docs/notion-client.md @@ -8,7 +8,7 @@ | Class | Description | | --- | --- | -| [NotionAPI](./notion-client.notionapi.md) | | +| [NotionAPI](./notion-client.notionapi.md) | Main Notion API client. | ## Interfaces diff --git a/docs/notion-client.notionapi.md b/docs/notion-client.notionapi.md index d7908d99..8aa3e150 100644 --- a/docs/notion-client.notionapi.md +++ b/docs/notion-client.notionapi.md @@ -4,6 +4,8 @@ ## NotionAPI class +Main Notion API client. + Signature: ```typescript diff --git a/docs/notion-utils.getallpagesinspace.md b/docs/notion-utils.getallpagesinspace.md new file mode 100644 index 00000000..d6846d14 --- /dev/null +++ b/docs/notion-utils.getallpagesinspace.md @@ -0,0 +1,31 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getAllPagesInSpace](./notion-utils.getallpagesinspace.md) + +## getAllPagesInSpace() function + +Performs a traversal over a given Notion workspace starting from a seed page. + +Returns a map containing all of the pages that are reachable from the seed page in the space. + +Signature: + +```typescript +export declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string, getPage: (pageId: string) => Promise, { concurrency }?: { + concurrency?: number; +}): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| rootPageId | string | Page ID to start from. | +| rootSpaceId | string | Space ID to scope traversal. | +| getPage | (pageId: string) => Promise<[ExtendedRecordMap](./notion-types.extendedrecordmap.md)> | Function used to fetch a single page. | +| { concurrency } | { concurrency?: number; } | | + +Returns: + +Promise<[PageMap](./notion-utils.pagemap.md)> + diff --git a/docs/notion-utils.getblocktitle.md b/docs/notion-utils.getblocktitle.md index 03c4a0eb..13b25604 100644 --- a/docs/notion-utils.getblocktitle.md +++ b/docs/notion-utils.getblocktitle.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap): string | null; +export declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap): string; ``` ## Parameters @@ -19,5 +19,5 @@ export declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap Returns: -string \| null +string diff --git a/docs/notion-utils.getcanonicalpageid.md b/docs/notion-utils.getcanonicalpageid.md new file mode 100644 index 00000000..4b2054f4 --- /dev/null +++ b/docs/notion-utils.getcanonicalpageid.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [getCanonicalPageId](./notion-utils.getcanonicalpageid.md) + +## getCanonicalPageId variable + +Gets the canonical, display-friendly version of a page's ID for use in URLs. + +Signature: + +```typescript +getCanonicalPageId: (pageId: string, recordMap: ExtendedRecordMap) => string | null +``` diff --git a/docs/notion-utils.idtouuid.md b/docs/notion-utils.idtouuid.md index f7b98b2f..6366264e 100644 --- a/docs/notion-utils.idtouuid.md +++ b/docs/notion-utils.idtouuid.md @@ -7,5 +7,5 @@ Signature: ```typescript -idToUuid: (id: string) => string +idToUuid: (id?: string) => string ``` diff --git a/docs/notion-utils.md b/docs/notion-utils.md index 67f8a3ef..f0ec3747 100644 --- a/docs/notion-utils.md +++ b/docs/notion-utils.md @@ -8,6 +8,7 @@ | Function | Description | | --- | --- | +| [getAllPagesInSpace(rootPageId, rootSpaceId, getPage, { concurrency })](./notion-utils.getallpagesinspace.md) | Performs a traversal over a given Notion workspace starting from a seed page.Returns a map containing all of the pages that are reachable from the seed page in the space. | | [getBlockIcon(block, recordMap)](./notion-utils.getblockicon.md) | | | [getBlockTitle(block, recordMap)](./notion-utils.getblocktitle.md) | | | [getPageTitle(recordMap)](./notion-utils.getpagetitle.md) | | @@ -16,6 +17,7 @@ | Interface | Description | | --- | --- | +| [PageMap](./notion-utils.pagemap.md) | | | [TableOfContentsEntry](./notion-utils.tableofcontentsentry.md) | | ## Variables @@ -23,11 +25,13 @@ | Variable | Description | | --- | --- | | [getBlockParentPage](./notion-utils.getblockparentpage.md) | Returns the parent page block containing a given page.Note that many times this will not be the direct parent block since some non-page content blocks can contain sub-blocks. | +| [getCanonicalPageId](./notion-utils.getcanonicalpageid.md) | Gets the canonical, display-friendly version of a page's ID for use in URLs. | | [getDateValue](./notion-utils.getdatevalue.md) | Attempts to find a valid date from a given property. | | [getPageContentBlockIds](./notion-utils.getpagecontentblockids.md) | Gets the IDs of all blocks contained on a page starting from a root block ID. | | [getPageTableOfContents](./notion-utils.getpagetableofcontents.md) | Gets the metadata for a table of contents block by parsing the page's H1, H2, and H3 elements. | | [getTextContent](./notion-utils.gettextcontent.md) | Gets the raw, unformatted text content of a block's content value.This is useful, for instance, for extracting a block's title without any rich text formatting. | | [idToUuid](./notion-utils.idtouuid.md) | | +| [normalizeTitle](./notion-utils.normalizetitle.md) | | | [parsePageId](./notion-utils.parsepageid.md) | Robustly extracts the notion page ID from a notion URL or pathname suffix.Defaults to returning a UUID (with dashes). | | [uuidToId](./notion-utils.uuidtoid.md) | | diff --git a/docs/notion-utils.normalizetitle.md b/docs/notion-utils.normalizetitle.md new file mode 100644 index 00000000..cddeb7b8 --- /dev/null +++ b/docs/notion-utils.normalizetitle.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [normalizeTitle](./notion-utils.normalizetitle.md) + +## normalizeTitle variable + +Signature: + +```typescript +normalizeTitle: (title: string | null) => string +``` diff --git a/docs/notion-utils.pagemap.md b/docs/notion-utils.pagemap.md new file mode 100644 index 00000000..e4891ea5 --- /dev/null +++ b/docs/notion-utils.pagemap.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [notion-utils](./notion-utils.md) > [PageMap](./notion-utils.pagemap.md) + +## PageMap interface + +Signature: + +```typescript +export interface PageMap +``` diff --git a/docs/notion-utils.parsepageid.md b/docs/notion-utils.parsepageid.md index 3405fa1a..f5fbbb41 100644 --- a/docs/notion-utils.parsepageid.md +++ b/docs/notion-utils.parsepageid.md @@ -11,7 +11,7 @@ Defaults to returning a UUID (with dashes). Signature: ```typescript -parsePageId: (id?: string, { uuid }?: { +parsePageId: (id?: string | null, { uuid }?: { uuid?: boolean | undefined; }) => string | null ``` diff --git a/package.json b/package.json index 2137f860..dad307b9 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,7 @@ "del-cli": "^3.0.1", "lerna": "^3.22.1", "npm-run-all": "^4.1.5", - "prettier": "^2.0.5", - "typescript": "^4.0.2", - "yarn": "^1.22.4" + "prettier": "^2.1.2", + "typescript": "^4.0.3" } } diff --git a/packages/notion-client/package.json b/packages/notion-client/package.json index ac5baf57..a987041f 100644 --- a/packages/notion-client/package.json +++ b/packages/notion-client/package.json @@ -22,6 +22,6 @@ }, "devDependencies": { "@types/node-fetch": "^2.5.7", - "ava": "^3.11.1" + "ava": "^3.13.0" } } diff --git a/packages/notion-utils/package.json b/packages/notion-utils/package.json index bc12241e..93512285 100644 --- a/packages/notion-utils/package.json +++ b/packages/notion-utils/package.json @@ -19,7 +19,6 @@ "p-queue": "^6.6.1" }, "devDependencies": { - "ava": "^3.11.1", - "ts-node": "^8.10.2" + "ava": "^3.13.0" } } diff --git a/packages/notion-utils/src/get-all-pages-in-space.ts b/packages/notion-utils/src/get-all-pages-in-space.ts index 517f6b13..5f43bfd5 100644 --- a/packages/notion-utils/src/get-all-pages-in-space.ts +++ b/packages/notion-utils/src/get-all-pages-in-space.ts @@ -17,7 +17,6 @@ export interface PageMap { * @param rootSpaceId - Space ID to scope traversal. * @param getPage - Function used to fetch a single page. * @param opts - Optional config - * @param opts.concurrency - Optional max concurrency (default 4) */ export async function getAllPagesInSpace( rootPageId: string, diff --git a/yarn.lock b/yarn.lock index 5bc17e99..a4dec51d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -790,18 +790,26 @@ write-file-atomic "^2.3.0" "@microsoft/api-documenter@^7.8.28": - version "7.8.34" - resolved "https://registry.yarnpkg.com/@microsoft/api-documenter/-/api-documenter-7.8.34.tgz#06c18a2283aea11d7e4dbc3123393d7b4d567f1b" - integrity sha512-f0eIaELznP303LyDsyJMYyz8hEU+uiatpdDvWa1vhMKYoiVluRwT2jPZowIUSOaNOzcNKOR/cl09smDX/MBP9w== + version "7.9.7" + resolved "https://registry.yarnpkg.com/@microsoft/api-documenter/-/api-documenter-7.9.7.tgz#965137674e136434d42ce4516a0f65bb99ed7314" + integrity sha512-wSlBDGbUd4Ld7YB8wmvsZ2yCwVdUh8zXmJHmggpZ13/TF/sForhhjd3MXfj0348h1RpVKE3foPxfxsDP6ON1Eg== dependencies: - "@microsoft/api-extractor-model" "7.8.18" + "@microsoft/api-extractor-model" "7.10.3" "@microsoft/tsdoc" "0.12.19" - "@rushstack/node-core-library" "3.29.1" - "@rushstack/ts-command-line" "4.6.3" + "@rushstack/node-core-library" "3.34.3" + "@rushstack/ts-command-line" "4.7.3" colors "~1.2.1" js-yaml "~3.13.1" resolve "~1.17.0" +"@microsoft/api-extractor-model@7.10.3": + version "7.10.3" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.10.3.tgz#f687f324e940bd71e3e73b5b262a54594b0ea61c" + integrity sha512-etP4NbZpj+zPCuO3YYigIYXkXq5zYhfE3vo/hrCj1OOd/159HDbSHnEQrNWRVy5TR79RAzHvkYAwtLYKeYP8Ag== + dependencies: + "@microsoft/tsdoc" "0.12.19" + "@rushstack/node-core-library" "3.34.3" + "@microsoft/api-extractor-model@7.8.0": version "7.8.0" resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.8.0.tgz#5f532998f01109f23d57b422803bbdf5ad655d80" @@ -810,14 +818,6 @@ "@microsoft/tsdoc" "0.12.19" "@rushstack/node-core-library" "3.19.7" -"@microsoft/api-extractor-model@7.8.18": - version "7.8.18" - resolved "https://registry.yarnpkg.com/@microsoft/api-extractor-model/-/api-extractor-model-7.8.18.tgz#15a0a53216b921a42388ab29ddee3eb33c2d9995" - integrity sha512-f/cotp4xvhhhpqAvnHd+M5xfaWIwokZfrezDcCEW4BFQMdjB7VhhXMA62Std/2E83B1YZ+/QsWoIZPaGuIcbBg== - dependencies: - "@microsoft/tsdoc" "0.12.19" - "@rushstack/node-core-library" "3.29.1" - "@microsoft/api-extractor@7.8.2-pr1796.0": version "7.8.2-pr1796.0" resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.8.2-pr1796.0.tgz#1a174168c7a9a07d9c1790508fc71331ee36a8fe" @@ -994,16 +994,17 @@ timsort "~0.3.0" z-schema "~3.18.3" -"@rushstack/node-core-library@3.29.1": - version "3.29.1" - resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-3.29.1.tgz#99d246b3e0573b78a2f9669356b29d70e3e25773" - integrity sha512-EHPZOy6/6lc9e1rfvB46sSXXsyaGMMfjBthGsRBqjmLedwUd6pFounlTtrGolugmW7DjRgs7wwvfYbsBcOW/vQ== +"@rushstack/node-core-library@3.34.3": + version "3.34.3" + resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-3.34.3.tgz#a59a1e452dcc79bd4e5f0840b4e9603551668f85" + integrity sha512-WNXHEk5/uoZsbrKzGpYUzDDymJvZarRkByab4uS1fbEcTSDFSVB9e0rREzCkU9yDAQlRutbFwiTXLu3LVR5F6w== dependencies: "@types/node" "10.17.13" colors "~1.2.1" fs-extra "~7.0.1" import-lazy "~4.0.0" jju "~1.4.0" + resolve "~1.17.0" semver "~7.3.0" timsort "~0.3.0" z-schema "~3.18.3" @@ -1017,10 +1018,10 @@ argparse "~1.0.9" colors "~1.2.1" -"@rushstack/ts-command-line@4.6.3": - version "4.6.3" - resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.6.3.tgz#0c4213a340e6e56a9a910f962e2db6f061cf81e2" - integrity sha512-mSkUDnc88kxiC9dKDVCNm1d08Ih918vSpLZGi1XHy/gYiQy4JcEW/O4MlqGAY9vNRigtm0dg4iJTiae+FTIxfA== +"@rushstack/ts-command-line@4.7.3": + version "4.7.3" + resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.7.3.tgz#fa72c637d70aa29c201f8f016f7db626f2d23a2c" + integrity sha512-8FNrUSbMgKLgRVcsg1STsIC2xAdyes7qJtVwg36hSnBAMZgCCIM+Z36nnxyrnYTS/6qwiXv7fwVaUxXH+SyiAQ== dependencies: "@types/argparse" "1.0.38" argparse "~1.0.9" @@ -1239,11 +1240,6 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - argparse@^1.0.7, argparse@~1.0.9: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -1360,10 +1356,10 @@ atob@^2.1.2: resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== -ava@^3.11.1: - version "3.12.1" - resolved "https://registry.yarnpkg.com/ava/-/ava-3.12.1.tgz#0181b5ca10d178539a0d503e0fc9244146303717" - integrity sha512-cS41+X+UfrcPed+CIgne/YV/6eWxaUjHEPH+W8WvNSqWTWku5YitjZGE5cMHFuJxwHELdR541xTBRn8Uwi4PSw== +ava@^3.13.0: + version "3.13.0" + resolved "https://registry.yarnpkg.com/ava/-/ava-3.13.0.tgz#df789d71ace66db99b213395338288d6d4322690" + integrity sha512-yzky+gark5PdsFFlZ4CnBVxm/OgBUWtn9vAsSSnuooVJNOk5ER17HJXVeUzy63LIt06Zy34oThcn+2ZqgMs7SA== dependencies: "@concordance/react" "^2.0.0" acorn "^8.0.1" @@ -1385,8 +1381,8 @@ ava@^3.11.1: concordance "^5.0.1" convert-source-map "^1.7.0" currently-unhandled "^0.4.1" - debug "^4.1.1" - del "^5.1.0" + debug "^4.2.0" + del "^6.0.0" emittery "^0.7.1" equal-length "^1.0.0" figures "^3.2.0" @@ -1395,19 +1391,20 @@ ava@^3.11.1: import-local "^3.0.2" indent-string "^4.0.0" is-error "^2.2.2" - is-plain-object "^4.1.1" + is-plain-object "^5.0.0" is-promise "^4.0.0" lodash "^4.17.20" matcher "^3.0.0" md5-hex "^3.0.1" - mem "^6.1.0" + mem "^6.1.1" ms "^2.1.2" - ora "^5.0.0" + ora "^5.1.0" + p-event "^4.2.0" p-map "^4.0.0" picomatch "^2.2.2" pkg-conf "^3.1.0" plur "^4.0.0" - pretty-ms "^7.0.0" + pretty-ms "^7.0.1" read-pkg "^5.2.0" resolve-cwd "^3.0.0" slash "^3.0.0" @@ -1419,7 +1416,7 @@ ava@^3.11.1: trim-off-newlines "^1.0.1" update-notifier "^4.1.1" write-file-atomic "^3.0.3" - yargs "^15.4.1" + yargs "^16.0.3" aws-sign2@~0.7.0: version "0.7.0" @@ -1801,14 +1798,14 @@ cliui@^5.0.0: strip-ansi "^5.2.0" wrap-ansi "^5.1.0" -cliui@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" - integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ== +cliui@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.1.tgz#a4cb67aad45cd83d8d05128fc9f4d8fbb887e6b3" + integrity sha512-rcvHOWyGyid6I1WjT/3NatKj2kDt9OdSHSXpyLXaMWFbKpGACNW8pRhhdPUq9MWUOdwn8Rz9AVETjF4105rZZQ== dependencies: string-width "^4.2.0" strip-ansi "^6.0.0" - wrap-ansi "^6.2.0" + wrap-ansi "^7.0.0" clone-deep@^4.0.1: version "4.0.1" @@ -2184,12 +2181,12 @@ debug@^3.1.0: dependencies: ms "^2.1.1" -debug@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== +debug@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" + integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== dependencies: - ms "^2.1.1" + ms "2.1.2" debuglog@^1.0.1: version "1.0.1" @@ -2294,6 +2291,20 @@ del@^5.1.0: rimraf "^3.0.0" slash "^3.0.0" +del@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/del/-/del-6.0.0.tgz#0b40d0332cea743f1614f818be4feb717714c952" + integrity sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ== + dependencies: + globby "^11.0.1" + graceful-fs "^4.2.4" + is-glob "^4.0.1" + is-path-cwd "^2.2.0" + is-path-inside "^3.0.2" + p-map "^4.0.0" + rimraf "^3.0.2" + slash "^3.0.0" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -2322,11 +2333,6 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - dir-glob@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.2.2.tgz#fa09f0694153c8918b18ba0deafae94769fc50c4" @@ -2477,6 +2483,11 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" +escalade@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.0.tgz#e8e2d7c7a8b76f6ee64c2181d6b8151441602d4e" + integrity sha512-mAk+hPSO8fLDkhV7V0dXazH5pDc6MrjBTPyD3VeKzxnVFjH1MIxbCdqGZB9O8+EwWakZs3ZCbDS4IpRt79V1ig== + escape-goat@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" @@ -2828,7 +2839,7 @@ genfun@^5.0.0: resolved "https://registry.yarnpkg.com/genfun/-/genfun-5.0.0.tgz#9dd9710a06900a5c4a5bf57aca5da4e52fe76537" integrity sha512-KGDOARWVga7+rnB3z9Sd2Letx515owfk0hSxHGuqjANb1M+x2bGZGqHLiozPsYMdM2OubeMni/Hpwmjq6qIUhA== -get-caller-file@^2.0.1: +get-caller-file@^2.0.1, get-caller-file@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== @@ -3025,7 +3036,7 @@ got@^9.6.0: to-readable-stream "^1.0.0" url-parse-lax "^3.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2: +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== @@ -3521,7 +3532,7 @@ is-path-cwd@^2.2.0: resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== -is-path-inside@^3.0.1: +is-path-inside@^3.0.1, is-path-inside@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.2.tgz#f5220fc82a3e233757291dddc9c5877f2a1f3017" integrity sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg== @@ -3538,11 +3549,16 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-plain-object@^4.0.0, is-plain-object@^4.1.1: +is-plain-object@^4.0.0: version "4.1.1" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-4.1.1.tgz#1a14d6452cbd50790edc7fdaa0aed5a40a35ebb5" integrity sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA== +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + is-promise@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-4.0.0.tgz#42ff9f84206c1991d26debf520dd5c01042dd2f3" @@ -3957,11 +3973,6 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - make-fetch-happen@^5.0.0: version "5.0.2" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-5.0.2.tgz#aa8387104f2687edca01c8687ee45013d02d19bd" @@ -4027,10 +4038,10 @@ md5-hex@^3.0.1: dependencies: blueimp-md5 "^2.10.0" -mem@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/mem/-/mem-6.1.0.tgz#846eca0bd4708a8f04b9c3f3cd769e194ae63c5c" - integrity sha512-RlbnLQgRHk5lwqTtpEkBTQ2ll/CG/iB+J4Hy2Wh97PjgZgXgWJWrFF+XXujh3UUVLvR4OOTgZzcWMMwnehlEUg== +mem@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/mem/-/mem-6.1.1.tgz#ea110c2ebc079eca3022e6b08c85a795e77f6318" + integrity sha512-Ci6bIfq/UgcxPTYa8dQQ5FY3BzKkT894bwXWXxC/zqs0XgMO2cT20CGkOqda7gZNkmK5VP4x89IGZ6K7hfbn3Q== dependencies: map-age-cleaner "^0.1.3" mimic-fn "^3.0.0" @@ -4283,7 +4294,7 @@ ms@2.0.0: resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= -ms@^2.0.0, ms@^2.1.1, ms@^2.1.2: +ms@2.1.2, ms@^2.0.0, ms@^2.1.1, ms@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4591,10 +4602,10 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" -ora@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ora/-/ora-5.0.0.tgz#4f0b34f2994877b49b452a707245ab1e9f6afccb" - integrity sha512-s26qdWqke2kjN/wC4dy+IQPBIMWBJlSU/0JZhk30ZDBLelW25rv66yutUWARMigpGPzcXHb+Nac5pNhN/WsARw== +ora@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/ora/-/ora-5.1.0.tgz#b188cf8cd2d4d9b13fd25383bc3e5cba352c94f8" + integrity sha512-9tXIMPvjZ7hPTbk8DFq1f7Kow/HU/pQYB60JbNq+QnGwcyhWVZaQ4hM9zQDEsPxw/muLpgiHSaumUZxCAmod/w== dependencies: chalk "^4.1.0" cli-cursor "^3.1.0" @@ -4641,6 +4652,13 @@ p-defer@^1.0.0: resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= +p-event@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/p-event/-/p-event-4.2.0.tgz#af4b049c8acd91ae81083ebd1e6f5cae2044c1b5" + integrity sha512-KXatOjCRXXkSePPb1Nbi0p0m+gQAwdlbhi4wQKJPI1HsMQS9g+Sqp2o+QHziPr7eYJyOZet836KoHEVM1mwOrQ== + dependencies: + p-timeout "^3.1.0" + p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -4972,15 +4990,15 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@^2.0.5: - version "2.1.0" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.0.tgz#5a9789f767a243118c60f3e56d95cb6544914fbb" - integrity sha512-lz28cCbA1cDFHVuY8vvj6QuqOwIpyIfPUYkSl8AZ/vxH8qBXMMjE2knfLHCrZCmUsK/H1bg1P0tOo0dJkTJHvw== +prettier@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" + integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== -pretty-ms@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-7.0.0.tgz#45781273110caf35f55cab21a8a9bd403a233dc0" - integrity sha512-J3aPWiC5e9ZeZFuSeBraGxSkGMOvulSWsxDByOcbD1Pr75YL3LSNIKIb52WXbCLE1sS5s4inBBbryjF4Y05Ceg== +pretty-ms@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-7.0.1.tgz#7d903eaab281f7d8e03c66f867e239dc32fb73e8" + integrity sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q== dependencies: parse-ms "^2.1.0" @@ -5415,7 +5433,7 @@ rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3: dependencies: glob "^7.1.3" -rimraf@^3.0.0: +rimraf@^3.0.0, rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== @@ -5637,7 +5655,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.17, source-map-support@^0.5.19: +source-map-support@^0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -6112,17 +6130,6 @@ trim-off-newlines@^1.0.0, trim-off-newlines@^1.0.1: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= -ts-node@^8.10.2: - version "8.10.2" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" - integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== - dependencies: - arg "^4.1.0" - diff "^4.0.1" - make-error "^1.1.1" - source-map-support "^0.5.17" - yn "3.1.1" - tslib@^1.9.0: version "1.13.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" @@ -6172,10 +6179,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" - integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== +typescript@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5" + integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg== typescript@~3.7.2: version "3.7.5" @@ -6420,10 +6427,10 @@ wrap-ansi@^5.1.0: string-width "^3.0.0" strip-ansi "^5.0.0" -wrap-ansi@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" - integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== dependencies: ansi-styles "^4.0.0" string-width "^4.1.0" @@ -6500,6 +6507,11 @@ y18n@^4.0.0: resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== +y18n@^5.0.1: + version "5.0.2" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.2.tgz#48218df5da2731b4403115c39a1af709c873f829" + integrity sha512-CkwaeZw6dQgqgPGeTWKMXCRmMcBgETFlTml1+ZOO+q7kGst8NREJ+eWwFNPVUQ4QGdAaklbqCZHH6Zuep1RjiA== + yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" @@ -6513,7 +6525,7 @@ yargs-parser@^15.0.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^18.1.2, yargs-parser@^18.1.3: +yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== @@ -6521,6 +6533,11 @@ yargs-parser@^18.1.2, yargs-parser@^18.1.3: camelcase "^5.0.0" decamelize "^1.2.0" +yargs-parser@^20.0.0: + version "20.2.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.1.tgz#28f3773c546cdd8a69ddae68116b48a5da328e77" + integrity sha512-yYsjuSkjbLMBp16eaOt7/siKTjNVjMm3SoJnIg3sEh/JsvqVVDyjRKmaJV4cl+lNIgq6QEco2i3gDebJl7/vLA== + yargs@^14.2.2: version "14.2.3" resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.3.tgz#1a1c3edced1afb2a2fea33604bc6d1d8d688a414" @@ -6538,32 +6555,18 @@ yargs@^14.2.2: y18n "^4.0.0" yargs-parser "^15.0.1" -yargs@^15.4.1: - version "15.4.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" - integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== +yargs@^16.0.3: + version "16.0.3" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.0.3.tgz#7a919b9e43c90f80d4a142a89795e85399a7e54c" + integrity sha512-6+nLw8xa9uK1BOEOykaiYAJVh6/CjxWXK/q9b5FpRgNslt8s22F2xMBqVIKgCRjNgGvGPBy8Vog7WN7yh4amtA== dependencies: - cliui "^6.0.0" - decamelize "^1.2.0" - find-up "^4.1.0" - get-caller-file "^2.0.1" + cliui "^7.0.0" + escalade "^3.0.2" + get-caller-file "^2.0.5" require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" string-width "^4.2.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^18.1.2" - -yarn@^1.22.4: - version "1.22.4" - resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.4.tgz#01c1197ca5b27f21edc8bc472cd4c8ce0e5a470e" - integrity sha512-oYM7hi/lIWm9bCoDMEWgffW8aiNZXCWeZ1/tGy0DWrN6vmzjCXIKu2Y21o8DYVBUtiktwKcNoxyGl/2iKLUNGA== - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + y18n "^5.0.1" + yargs-parser "^20.0.0" z-schema@~3.18.3: version "3.18.4" From 5133ab49b6cfdb69fac210f045f21bfd63368917 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Tue, 6 Oct 2020 04:17:04 -0400 Subject: [PATCH 0029/1173] feat: import react-notion fork from Notion X --- packages/react-notion-x/package.json | 48 + packages/react-notion-x/readme.md | 28 + packages/react-notion-x/src/block.tsx | 553 +++ .../react-notion-x/src/components/asset.tsx | 163 + .../react-notion-x/src/components/audio.tsx | 17 + .../src/components/checkbox.tsx | 23 + .../react-notion-x/src/components/code.tsx | 24 + .../src/components/collection-card.tsx | 176 + .../components/collection-column-title.tsx | 19 + .../src/components/collection-row.tsx | 63 + .../src/components/collection-view-board.tsx | 108 + .../components/collection-view-gallery.tsx | 51 + .../src/components/collection-view-list.tsx | 74 + .../src/components/collection-view-table.tsx | 131 + .../src/components/collection-view.tsx | 29 + .../src/components/collection.tsx | 165 + .../src/components/collections.md | 28 + .../src/components/equation.tsx | 29 + .../react-notion-x/src/components/file.tsx | 38 + .../src/components/google-drive.tsx | 80 + .../src/components/graceful-image.tsx | 3 + .../src/components/lazy-image.tsx | 100 + .../react-notion-x/src/components/notes.md | 52 + .../src/components/page-header.tsx | 126 + .../src/components/page-icon.tsx | 76 + .../src/components/page-title.tsx | 49 + .../src/components/property.tsx | 267 ++ .../src/components/search-dialog.tsx | 209 + .../react-notion-x/src/components/temp.html | 3158 ++++++++++++++ .../react-notion-x/src/components/text.tsx | 204 + packages/react-notion-x/src/context.tsx | 100 + packages/react-notion-x/src/eval-formula.ts | 413 ++ packages/react-notion-x/src/icons/check.svg | 11 + packages/react-notion-x/src/icons/check.tsx | 11 + .../src/icons/chevron-down-icon.tsx | 10 + .../react-notion-x/src/icons/clear-icon.tsx | 11 + .../src/icons/collection-view-board.svg | 9 + .../src/icons/collection-view-board.tsx | 11 + .../src/icons/collection-view-calendar.svg | 9 + .../src/icons/collection-view-calendar.tsx | 11 + .../src/icons/collection-view-gallery.svg | 9 + .../src/icons/collection-view-gallery.tsx | 11 + .../src/icons/collection-view-icon.tsx | 34 + .../src/icons/collection-view-list.svg | 9 + .../src/icons/collection-view-list.tsx | 11 + .../src/icons/collection-view-table.svg | 9 + .../src/icons/collection-view-table.tsx | 11 + .../src/icons/default-page-icon.tsx | 10 + .../react-notion-x/src/icons/empty-icon.tsx | 10 + .../react-notion-x/src/icons/file-icon.tsx | 10 + .../react-notion-x/src/icons/link-icon.tsx | 19 + .../react-notion-x/src/icons/loading-icon.tsx | 56 + .../src/icons/property-icon.tsx | 56 + .../react-notion-x/src/icons/search-icon.tsx | 11 + .../src/icons/type-checkbox.svg | 11 + .../src/icons/type-checkbox.tsx | 11 + .../react-notion-x/src/icons/type-date.svg | 11 + .../react-notion-x/src/icons/type-date.tsx | 11 + .../react-notion-x/src/icons/type-email.svg | 11 + .../react-notion-x/src/icons/type-email.tsx | 11 + .../react-notion-x/src/icons/type-file.svg | 11 + .../react-notion-x/src/icons/type-file.tsx | 11 + .../react-notion-x/src/icons/type-formula.svg | 9 + .../react-notion-x/src/icons/type-formula.tsx | 11 + .../src/icons/type-multi-select.svg | 11 + .../src/icons/type-multi-select.tsx | 11 + .../react-notion-x/src/icons/type-number.svg | 11 + .../react-notion-x/src/icons/type-number.tsx | 11 + .../src/icons/type-person-2.svg | 9 + .../src/icons/type-person-2.tsx | 11 + .../react-notion-x/src/icons/type-person.svg | 11 + .../react-notion-x/src/icons/type-person.tsx | 11 + .../src/icons/type-phone-number.svg | 11 + .../src/icons/type-phone-number.tsx | 11 + .../src/icons/type-relation.svg | 9 + .../src/icons/type-relation.tsx | 11 + .../react-notion-x/src/icons/type-select.svg | 11 + .../react-notion-x/src/icons/type-select.tsx | 11 + .../react-notion-x/src/icons/type-text.svg | 11 + .../react-notion-x/src/icons/type-text.tsx | 11 + .../src/icons/type-timestamp.svg | 9 + .../src/icons/type-timestamp.tsx | 11 + .../react-notion-x/src/icons/type-title.svg | 11 + .../react-notion-x/src/icons/type-title.tsx | 11 + .../react-notion-x/src/icons/type-url.svg | 11 + .../react-notion-x/src/icons/type-url.tsx | 11 + packages/react-notion-x/src/index.tsx | 4 + packages/react-notion-x/src/renderer.tsx | 123 + packages/react-notion-x/src/styles.css | 2175 ++++++++++ packages/react-notion-x/src/types.ts | 33 + packages/react-notion-x/src/utils.ts | 95 + packages/react-notion-x/tsconfig.cjs.json | 8 + packages/react-notion-x/tsconfig.json | 15 + tsconfig.json | 8 +- tsdx.config.js | 5 + yarn.lock | 3809 ++++++++++++++++- 96 files changed, 13496 insertions(+), 76 deletions(-) create mode 100644 packages/react-notion-x/package.json create mode 100644 packages/react-notion-x/readme.md create mode 100644 packages/react-notion-x/src/block.tsx create mode 100644 packages/react-notion-x/src/components/asset.tsx create mode 100644 packages/react-notion-x/src/components/audio.tsx create mode 100644 packages/react-notion-x/src/components/checkbox.tsx create mode 100644 packages/react-notion-x/src/components/code.tsx create mode 100644 packages/react-notion-x/src/components/collection-card.tsx create mode 100644 packages/react-notion-x/src/components/collection-column-title.tsx create mode 100644 packages/react-notion-x/src/components/collection-row.tsx create mode 100644 packages/react-notion-x/src/components/collection-view-board.tsx create mode 100644 packages/react-notion-x/src/components/collection-view-gallery.tsx create mode 100644 packages/react-notion-x/src/components/collection-view-list.tsx create mode 100644 packages/react-notion-x/src/components/collection-view-table.tsx create mode 100644 packages/react-notion-x/src/components/collection-view.tsx create mode 100644 packages/react-notion-x/src/components/collection.tsx create mode 100644 packages/react-notion-x/src/components/collections.md create mode 100644 packages/react-notion-x/src/components/equation.tsx create mode 100644 packages/react-notion-x/src/components/file.tsx create mode 100644 packages/react-notion-x/src/components/google-drive.tsx create mode 100644 packages/react-notion-x/src/components/graceful-image.tsx create mode 100644 packages/react-notion-x/src/components/lazy-image.tsx create mode 100644 packages/react-notion-x/src/components/notes.md create mode 100644 packages/react-notion-x/src/components/page-header.tsx create mode 100644 packages/react-notion-x/src/components/page-icon.tsx create mode 100644 packages/react-notion-x/src/components/page-title.tsx create mode 100644 packages/react-notion-x/src/components/property.tsx create mode 100644 packages/react-notion-x/src/components/search-dialog.tsx create mode 100644 packages/react-notion-x/src/components/temp.html create mode 100644 packages/react-notion-x/src/components/text.tsx create mode 100644 packages/react-notion-x/src/context.tsx create mode 100644 packages/react-notion-x/src/eval-formula.ts create mode 100644 packages/react-notion-x/src/icons/check.svg create mode 100644 packages/react-notion-x/src/icons/check.tsx create mode 100644 packages/react-notion-x/src/icons/chevron-down-icon.tsx create mode 100644 packages/react-notion-x/src/icons/clear-icon.tsx create mode 100644 packages/react-notion-x/src/icons/collection-view-board.svg create mode 100644 packages/react-notion-x/src/icons/collection-view-board.tsx create mode 100644 packages/react-notion-x/src/icons/collection-view-calendar.svg create mode 100644 packages/react-notion-x/src/icons/collection-view-calendar.tsx create mode 100644 packages/react-notion-x/src/icons/collection-view-gallery.svg create mode 100644 packages/react-notion-x/src/icons/collection-view-gallery.tsx create mode 100644 packages/react-notion-x/src/icons/collection-view-icon.tsx create mode 100644 packages/react-notion-x/src/icons/collection-view-list.svg create mode 100644 packages/react-notion-x/src/icons/collection-view-list.tsx create mode 100644 packages/react-notion-x/src/icons/collection-view-table.svg create mode 100644 packages/react-notion-x/src/icons/collection-view-table.tsx create mode 100644 packages/react-notion-x/src/icons/default-page-icon.tsx create mode 100644 packages/react-notion-x/src/icons/empty-icon.tsx create mode 100644 packages/react-notion-x/src/icons/file-icon.tsx create mode 100644 packages/react-notion-x/src/icons/link-icon.tsx create mode 100644 packages/react-notion-x/src/icons/loading-icon.tsx create mode 100644 packages/react-notion-x/src/icons/property-icon.tsx create mode 100644 packages/react-notion-x/src/icons/search-icon.tsx create mode 100644 packages/react-notion-x/src/icons/type-checkbox.svg create mode 100644 packages/react-notion-x/src/icons/type-checkbox.tsx create mode 100644 packages/react-notion-x/src/icons/type-date.svg create mode 100644 packages/react-notion-x/src/icons/type-date.tsx create mode 100644 packages/react-notion-x/src/icons/type-email.svg create mode 100644 packages/react-notion-x/src/icons/type-email.tsx create mode 100644 packages/react-notion-x/src/icons/type-file.svg create mode 100644 packages/react-notion-x/src/icons/type-file.tsx create mode 100644 packages/react-notion-x/src/icons/type-formula.svg create mode 100644 packages/react-notion-x/src/icons/type-formula.tsx create mode 100644 packages/react-notion-x/src/icons/type-multi-select.svg create mode 100644 packages/react-notion-x/src/icons/type-multi-select.tsx create mode 100644 packages/react-notion-x/src/icons/type-number.svg create mode 100644 packages/react-notion-x/src/icons/type-number.tsx create mode 100644 packages/react-notion-x/src/icons/type-person-2.svg create mode 100644 packages/react-notion-x/src/icons/type-person-2.tsx create mode 100644 packages/react-notion-x/src/icons/type-person.svg create mode 100644 packages/react-notion-x/src/icons/type-person.tsx create mode 100644 packages/react-notion-x/src/icons/type-phone-number.svg create mode 100644 packages/react-notion-x/src/icons/type-phone-number.tsx create mode 100644 packages/react-notion-x/src/icons/type-relation.svg create mode 100644 packages/react-notion-x/src/icons/type-relation.tsx create mode 100644 packages/react-notion-x/src/icons/type-select.svg create mode 100644 packages/react-notion-x/src/icons/type-select.tsx create mode 100644 packages/react-notion-x/src/icons/type-text.svg create mode 100644 packages/react-notion-x/src/icons/type-text.tsx create mode 100644 packages/react-notion-x/src/icons/type-timestamp.svg create mode 100644 packages/react-notion-x/src/icons/type-timestamp.tsx create mode 100644 packages/react-notion-x/src/icons/type-title.svg create mode 100644 packages/react-notion-x/src/icons/type-title.tsx create mode 100644 packages/react-notion-x/src/icons/type-url.svg create mode 100644 packages/react-notion-x/src/icons/type-url.tsx create mode 100644 packages/react-notion-x/src/index.tsx create mode 100644 packages/react-notion-x/src/renderer.tsx create mode 100644 packages/react-notion-x/src/styles.css create mode 100644 packages/react-notion-x/src/types.ts create mode 100644 packages/react-notion-x/src/utils.ts create mode 100644 packages/react-notion-x/tsconfig.cjs.json create mode 100644 packages/react-notion-x/tsconfig.json create mode 100644 tsdx.config.js diff --git a/packages/react-notion-x/package.json b/packages/react-notion-x/package.json new file mode 100644 index 00000000..924ec70f --- /dev/null +++ b/packages/react-notion-x/package.json @@ -0,0 +1,48 @@ +{ + "name": "react-notion-x", + "version": "2.2.1", + "description": "Notion renderer for React that powers Notion X.", + "repository": "NotionX/notion-kit", + "author": "Saasify ", + "license": "MIT", + "main": "build/cjs/index.js", + "module": "build/esm/index.js", + "typings": "build/esm/index.d.ts", + "engines": { + "node": ">=12" + }, + "dependencies": { + "@matejmazur/react-katex": "^3.1.3", + "classnames": "^2.2.6", + "date-fns": "^2.15.0", + "format-number": "^3.0.0", + "is-url-superb": "^4.0.0", + "katex": "^0.12.0", + "lodash.throttle": "^4.1.1", + "medium-zoom": "^1.0.6", + "notion-types": "^2.2.1", + "notion-utils": "^2.4.1", + "prismjs": "^1.20.0", + "rc-dropdown": "^3.1.2", + "rc-menu": "^8.5.2", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-image": "^4.0.3", + "react-lazy-images": "^1.1.0", + "react-modal": "^3.11.2", + "react-pdf": "^4.2.0", + "react-tweet-embed": "^1.2.2", + "react-use": "^15.3.3" + }, + "devDependencies": { + "@types/classnames": "^2.2.10", + "@types/next": "^9.0.0", + "@types/node": "^14.6.0", + "@types/react": "^16.9.46", + "@types/react-modal": "^3.10.5", + "@types/react-pdf": "^4.0.5" + }, + "peerDependencies": { + "next": "^9.5.3" + } +} diff --git a/packages/react-notion-x/readme.md b/packages/react-notion-x/readme.md new file mode 100644 index 00000000..c038b719 --- /dev/null +++ b/packages/react-notion-x/readme.md @@ -0,0 +1,28 @@ +

+ Notion X +

+ +# React Notion X + +> Notion renderer for React that powers Notion X. + +[![NPM](https://img.shields.io/npm/v/react-notion-x.svg)](https://www.npmjs.com/package/react-notion-x) [![Build Status](https://travis-ci.com/NotionX/notion-kit.svg?branch=master)](https://travis-ci.com/NotionX/notion-kit) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) + +## Install + +```bash +npm install react-notion-x +``` + +## Usage + +TODO + +## License + +MIT © [Travis Fischer](https://transitivebullsh.it) + +Support my OSS work by following me on twitter twitter diff --git a/packages/react-notion-x/src/block.tsx b/packages/react-notion-x/src/block.tsx new file mode 100644 index 00000000..d06e94a2 --- /dev/null +++ b/packages/react-notion-x/src/block.tsx @@ -0,0 +1,553 @@ +import * as React from 'react' +import cs from 'classnames' +import dynamic from 'next/dynamic' + +import * as types from './types' +import { Asset } from './components/asset' +import { Checkbox } from './components/checkbox' +import { PageIcon } from './components/page-icon' +import { PageTitle } from './components/page-title' +import { LinkIcon } from './icons/link-icon' +import { PageHeader } from './components/page-header' +import { GoogleDrive } from './components/google-drive' +import { Audio } from './components/audio' +import { File } from './components/file' +import { Equation } from './components/equation' +import { GracefulImage } from './components/graceful-image' +import { LazyImage } from './components/lazy-image' +import { useNotionContext } from './context' +import { + classNames, + getTextContent, + getListNumber, + getPageTableOfContents, + getBlockParentPage, + uuidToId +} from './utils' +import { Text } from './components/text' + +// load heavier components asynchronously +const Code = dynamic(() => import('./components/code')) +const Collection = dynamic(() => import('./components/collection')) +const CollectionRow = dynamic(() => import('./components/collection-row')) + +interface BlockProps { + block: types.Block + level: number + + className?: string + bodyClassName?: string + footer?: React.ReactNode +} + +export const Block: React.FC = (props) => { + const { + components, + fullPage, + darkMode, + recordMap, + mapPageUrl, + mapImageUrl + } = useNotionContext() + + const { block, children, level, className, bodyClassName, footer } = props + + if (!block) { + return null + } + + // ugly hack to make viewing raw collection views work properly + // e.g., 6d886ca87ab94c21a16e3b82b43a57fb + if (level === 0 && block.type === 'collection_view') { + ;(block as any).type = 'collection_view_page' + } + + switch (block.type) { + case 'collection_view_page': + // fallthrough + case 'page': + if (level === 0) { + const { + page_icon, + page_cover, + page_cover_position, + page_full_width, + page_small_text + } = block.format || {} + + if (fullPage) { + const properties = + block.type === 'page' + ? block.properties + : { + title: recordMap.collection[block.collection_id]?.value?.name + } + + const coverPosition = (1 - (page_cover_position || 0.5)) * 100 + + return ( +
+
+
+ + +
+ {page_cover && ( + + )} + +
+ {page_icon && ( + + )} + +
+ +
+ + {block.type === 'page' && + block.parent_table === 'collection' && ( + + )} + + {block.type === 'collection_view_page' && ( + + )} + + {children} +
+ + {footer} +
+
+
+
+ ) + } else { + return ( +
+ {block.type === 'page' && block.parent_table === 'collection' && ( + + )} + + {block.type === 'collection_view_page' && ( + + )} + + {children} +
+ ) + } + } else { + const blockColor = block.format?.block_color + + return ( + + + + ) + } + + case 'header': + // fallthrough + case 'sub_header': + // fallthrough + case 'sub_sub_header': { + if (!block.properties) return null + + const blockColor = block.format?.block_color + const id = uuidToId(block.id) + const title = + getTextContent(block.properties.title) || `Notion Header ${id}` + + return ( +

+ + + + + +

+ ) + } + + case 'divider': + return
+ + case 'text': + if (!block.properties) { + return
 
+ } + + const blockColor = block.format?.block_color + + return ( +
+ + + {children &&
{children}
} +
+ ) + + case 'bulleted_list': + // fallthrough + case 'numbered_list': + const wrapList = (content: React.ReactNode, start?: number) => + block.type === 'bulleted_list' ? ( +
    {content}
+ ) : ( +
    + {content} +
+ ) + + let output: JSX.Element | null = null + + if (block.content) { + output = ( + <> + {block.properties && ( +
  • + +
  • + )} + {wrapList(children)} + + ) + } else { + output = block.properties ? ( +
  • + +
  • + ) : null + } + + const isTopLevel = + block.type !== recordMap.block[block.parent_id]?.value?.type + const start = getListNumber(block.id, recordMap.block) + + return isTopLevel ? wrapList(output, start) : output + + case 'tweet': + // fallthrough + case 'maps': + // fallthrough + case 'pdf': + // fallthrough + case 'figma': + // fallthrough + case 'image': + // fallthrough + case 'embed': + // fallthrough + case 'video': + const value = block as types.BaseContentBlock + + return ( +
    + + + {value.properties.caption && ( +
    + +
    + )} +
    + ) + + case 'drive': + return + + case 'audio': + return