notion-utils
Advanced tools
Comparing version 3.4.2 to 3.4.8
@@ -8,2 +8,6 @@ import { ExtendedRecordMap, PageMap } from 'notion-types'; | ||
* | ||
* If `rootSpaceId` is not defined, the space ID of the root page will be used | ||
* to scope traversal. | ||
* | ||
* | ||
* @param rootPageId - Page ID to start from. | ||
@@ -14,5 +18,5 @@ * @param rootSpaceId - Space ID to scope traversal. | ||
*/ | ||
export declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string, getPage: (pageId: string) => Promise<ExtendedRecordMap>, { concurrency, traverseCollections }?: { | ||
export declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string | undefined, getPage: (pageId: string) => Promise<ExtendedRecordMap>, { concurrency, traverseCollections }?: { | ||
concurrency?: number; | ||
traverseCollections?: boolean; | ||
}): Promise<PageMap>; |
@@ -50,2 +50,6 @@ "use strict"; | ||
* | ||
* If `rootSpaceId` is not defined, the space ID of the root page will be used | ||
* to scope traversal. | ||
* | ||
* | ||
* @param rootPageId - Page ID to start from. | ||
@@ -67,10 +71,18 @@ * @param rootSpaceId - Space ID to scope traversal. | ||
queue.add(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var page_1, _i, _a, collectionViews, _b, _c, collectionData, blockIds, _d, blockIds_1, collectionItemId, err_1; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
var page_1, spaceId, _i, _a, collectionViews, _b, _c, collectionData, blockIds, _d, blockIds_1, collectionItemId, err_1; | ||
var _e, _f; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_e.trys.push([0, 2, , 3]); | ||
_g.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, getPage(pageId)]; | ||
case 1: | ||
page_1 = _e.sent(); | ||
page_1 = _g.sent(); | ||
spaceId = (_f = (_e = page_1.block[pageId]) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.space_id; | ||
if (!rootSpaceId) { | ||
rootSpaceId = spaceId; | ||
} | ||
else if (rootSpaceId !== spaceId) { | ||
return [2 /*return*/]; | ||
} | ||
Object.keys(page_1.block) | ||
@@ -107,3 +119,3 @@ .filter(function (key) { | ||
case 2: | ||
err_1 = _e.sent(); | ||
err_1 = _g.sent(); | ||
console.warn('page load error', { pageId: pageId, spaceId: rootSpaceId }, err_1); | ||
@@ -110,0 +122,0 @@ pages[pageId] = null; |
@@ -15,3 +15,4 @@ "use strict"; | ||
var _a; | ||
var toc = (_a = page.content) === null || _a === void 0 ? void 0 : _a.map(function (blockId) { | ||
var toc = (_a = page.content, (_a !== null && _a !== void 0 ? _a : [])) | ||
.map(function (blockId) { | ||
var _a, _b; | ||
@@ -33,3 +34,4 @@ var block = (_a = recordMap.block[blockId]) === null || _a === void 0 ? void 0 : _a.value; | ||
return null; | ||
}).filter(Boolean); | ||
}) | ||
.filter(Boolean); | ||
var indentLevelStack = [ | ||
@@ -36,0 +38,0 @@ { |
@@ -8,2 +8,6 @@ import { ExtendedRecordMap, PageMap } from 'notion-types'; | ||
* | ||
* If `rootSpaceId` is not defined, the space ID of the root page will be used | ||
* to scope traversal. | ||
* | ||
* | ||
* @param rootPageId - Page ID to start from. | ||
@@ -14,5 +18,5 @@ * @param rootSpaceId - Space ID to scope traversal. | ||
*/ | ||
export declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string, getPage: (pageId: string) => Promise<ExtendedRecordMap>, { concurrency, traverseCollections }?: { | ||
export declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string | undefined, getPage: (pageId: string) => Promise<ExtendedRecordMap>, { concurrency, traverseCollections }?: { | ||
concurrency?: number; | ||
traverseCollections?: boolean; | ||
}): Promise<PageMap>; |
@@ -45,2 +45,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
* | ||
* If `rootSpaceId` is not defined, the space ID of the root page will be used | ||
* to scope traversal. | ||
* | ||
* | ||
* @param rootPageId - Page ID to start from. | ||
@@ -62,10 +66,18 @@ * @param rootSpaceId - Space ID to scope traversal. | ||
queue.add(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var page_1, _i, _a, collectionViews, _b, _c, collectionData, blockIds, _d, blockIds_1, collectionItemId, err_1; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
var page_1, spaceId, _i, _a, collectionViews, _b, _c, collectionData, blockIds, _d, blockIds_1, collectionItemId, err_1; | ||
var _e, _f; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_e.trys.push([0, 2, , 3]); | ||
_g.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, getPage(pageId)]; | ||
case 1: | ||
page_1 = _e.sent(); | ||
page_1 = _g.sent(); | ||
spaceId = (_f = (_e = page_1.block[pageId]) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.space_id; | ||
if (!rootSpaceId) { | ||
rootSpaceId = spaceId; | ||
} | ||
else if (rootSpaceId !== spaceId) { | ||
return [2 /*return*/]; | ||
} | ||
Object.keys(page_1.block) | ||
@@ -102,3 +114,3 @@ .filter(function (key) { | ||
case 2: | ||
err_1 = _e.sent(); | ||
err_1 = _g.sent(); | ||
console.warn('page load error', { pageId: pageId, spaceId: rootSpaceId }, err_1); | ||
@@ -105,0 +117,0 @@ pages[pageId] = null; |
@@ -13,3 +13,4 @@ import { getTextContent } from './get-text-content'; | ||
var _a; | ||
var toc = (_a = page.content) === null || _a === void 0 ? void 0 : _a.map(function (blockId) { | ||
var toc = (_a = page.content, (_a !== null && _a !== void 0 ? _a : [])) | ||
.map(function (blockId) { | ||
var _a, _b; | ||
@@ -31,3 +32,4 @@ var block = (_a = recordMap.block[blockId]) === null || _a === void 0 ? void 0 : _a.value; | ||
return null; | ||
}).filter(Boolean); | ||
}) | ||
.filter(Boolean); | ||
var indentLevelStack = [ | ||
@@ -34,0 +36,0 @@ { |
{ | ||
"name": "notion-utils", | ||
"version": "3.4.2", | ||
"version": "3.4.8", | ||
"description": "Useful utilities for working with Notion data. Isomorphic.", | ||
@@ -24,3 +24,3 @@ "repository": "NotionX/react-notion-x", | ||
}, | ||
"gitHead": "af3944d3e39ba1d8e5b7dec55613044bd6eb8594" | ||
"gitHead": "595c96d75aeea2c50b6635adcead29db5c809404" | ||
} |
@@ -12,2 +12,6 @@ import PQueue from 'p-queue' | ||
* | ||
* If `rootSpaceId` is not defined, the space ID of the root page will be used | ||
* to scope traversal. | ||
* | ||
* | ||
* @param rootPageId - Page ID to start from. | ||
@@ -20,3 +24,3 @@ * @param rootSpaceId - Space ID to scope traversal. | ||
rootPageId: string, | ||
rootSpaceId: string, | ||
rootSpaceId: string | undefined, | ||
getPage: (pageId: string) => Promise<ExtendedRecordMap>, | ||
@@ -44,3 +48,10 @@ { | ||
const page = await getPage(pageId) | ||
const spaceId = page.block[pageId]?.value?.space_id | ||
if (!rootSpaceId) { | ||
rootSpaceId = spaceId | ||
} else if (rootSpaceId !== spaceId) { | ||
return | ||
} | ||
Object.keys(page.block) | ||
@@ -47,0 +58,0 @@ .filter((key) => { |
@@ -25,4 +25,4 @@ import * as types from 'notion-types' | ||
): Array<TableOfContentsEntry> => { | ||
const toc = page.content | ||
?.map((blockId) => { | ||
const toc = (page.content ?? []) | ||
.map((blockId: string) => { | ||
const block = recordMap.block[blockId]?.value | ||
@@ -29,0 +29,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
745297
8653