notion-client
Advanced tools
Comparing version 0.4.0 to 1.0.0
@@ -56,5 +56,6 @@ "use strict"; | ||
const pendingBlocks = Object.keys(recordMap.block).flatMap((blockId) => { | ||
var _a, _b; | ||
const block = recordMap.block[blockId]; | ||
const content = block.value && block.value.content; | ||
return content && block.value.type !== 'page' | ||
const content = (_a = block.value) === null || _a === void 0 ? void 0 : _a.content; | ||
return content && ((_b = block.value) === null || _b === void 0 ? void 0 : _b.type) !== 'page' | ||
? content.filter((id) => !recordMap.block[id]) | ||
@@ -77,3 +78,3 @@ : []; | ||
const block = recordMap.block[blockId].value; | ||
if (block.type === 'collection_view') { | ||
if ((block === null || block === void 0 ? void 0 : block.type) === 'collection_view') { | ||
return block.view_ids.map((collectionViewId) => ({ | ||
@@ -115,5 +116,6 @@ collectionId: block.collection_id, | ||
const block = recordMap.block[blockId].value; | ||
if (block.type === 'pdf' || | ||
block.type === 'audio' || | ||
block.type === 'file') { | ||
if (block && | ||
(block.type === 'pdf' || | ||
block.type === 'audio' || | ||
block.type === 'file')) { | ||
const source = (_c = (_b = (_a = block.properties) === null || _a === void 0 ? void 0 : _a.source) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[0]; | ||
@@ -120,0 +122,0 @@ if (source) { |
{ | ||
"name": "notion-client", | ||
"version": "0.4.0", | ||
"description": "TypeScript client for the unofficial Notion API.", | ||
"version": "1.0.0", | ||
"description": "Robust TypeScript client for the unofficial Notion API.", | ||
"repository": "saasify-sh/notion", | ||
@@ -18,4 +18,4 @@ "author": "Saasify <dev@saasify.sh>", | ||
"got": "^11.5.2", | ||
"notion-types": "^0.4.0", | ||
"notion-utils": "^0.4.0", | ||
"notion-types": "^1.0.0", | ||
"notion-utils": "^1.0.0", | ||
"p-map": "^4.0.0" | ||
@@ -26,3 +26,3 @@ }, | ||
}, | ||
"gitHead": "76f2886c3a82acae47ac440ea859328fc5821e1e" | ||
"gitHead": "3b23749ac247ac84f50d5db4952f244228e15b48" | ||
} |
@@ -7,3 +7,3 @@ <p align="center"> | ||
> TypeScript client for the unofficial Notion API. | ||
> Robust TypeScript client for the unofficial Notion API. | ||
@@ -25,9 +25,9 @@ [![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.svg?branch=master)](https://travis-ci.com/saasify-sh/notion) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io) | ||
// you can optionally pass an authToken to access private notion resources | ||
const api = new NotionAPI() | ||
// this will fetch all blocks for the given page as well as any collection data | ||
// for collection views contained on the page | ||
// fetch a page's content, including all async blocks, collection queries, and signed urls | ||
const page = await api.getPage('067dd719-a912-471e-a9a3-ac10710e7fdf') | ||
// example of fetching the data for a specific collection instance | ||
// fetch the data for a specific collection instance | ||
const collectionId = '2d8aec23-8281-4a94-9090-caaf823dd21a' | ||
@@ -34,0 +34,0 @@ const collectionViewId = 'ab639a5a-853e-45e1-9ef7-133b486c0acf' |
@@ -65,5 +65,5 @@ import got from 'got' | ||
const block = recordMap.block[blockId] | ||
const content = block.value && block.value.content | ||
const content = block.value?.content | ||
return content && block.value.type !== 'page' | ||
return content && block.value?.type !== 'page' | ||
? content.filter((id) => !recordMap.block[id]) | ||
@@ -94,3 +94,3 @@ : [] | ||
if (block.type === 'collection_view') { | ||
if (block?.type === 'collection_view') { | ||
return block.view_ids.map((collectionViewId) => ({ | ||
@@ -165,5 +165,6 @@ collectionId: block.collection_id, | ||
if ( | ||
block.type === 'pdf' || | ||
block.type === 'audio' || | ||
block.type === 'file' | ||
block && | ||
(block.type === 'pdf' || | ||
block.type === 'audio' || | ||
block.type === 'file') | ||
) { | ||
@@ -170,0 +171,0 @@ const source = block.properties?.source?.[0]?.[0] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
352847
35
4842
1
+ Added@babel/runtime@7.26.7(transitive)
+ Addeddate-fns@2.30.0(transitive)
+ Addednotion-types@1.3.2(transitive)
+ Addednotion-utils@1.3.2(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removednotion-types@0.4.0(transitive)
- Removednotion-utils@0.4.0(transitive)
Updatednotion-types@^1.0.0
Updatednotion-utils@^1.0.0