notion-utils
Advanced tools
Comparing version
@@ -65,6 +65,7 @@ import * as types from 'notion-types'; | ||
*/ | ||
declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string | undefined, getPage: (pageId: string) => Promise<ExtendedRecordMap>, { concurrency, traverseCollections, targetPageId }?: { | ||
declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string | undefined, getPage: (pageId: string) => Promise<ExtendedRecordMap>, { concurrency, traverseCollections, targetPageId, maxDepth }?: { | ||
concurrency?: number; | ||
traverseCollections?: boolean; | ||
targetPageId?: string; | ||
maxDepth?: number; | ||
}): Promise<PageMap>; | ||
@@ -71,0 +72,0 @@ |
@@ -325,3 +325,4 @@ // src/estimate-page-read-time.ts | ||
traverseCollections = true, | ||
targetPageId | ||
targetPageId, | ||
maxDepth = Number.POSITIVE_INFINITY | ||
} = {}) { | ||
@@ -331,3 +332,6 @@ const pages = {}; | ||
const queue = new PQueue({ concurrency }); | ||
async function processPage(pageId) { | ||
async function processPage(pageId, depth = 0) { | ||
if (depth > maxDepth) { | ||
return; | ||
} | ||
if (targetPageId && pendingPageIds.has(targetPageId)) { | ||
@@ -369,3 +373,3 @@ return; | ||
})) { | ||
void processPage(subPageId); | ||
void processPage(subPageId, depth + 1); | ||
} | ||
@@ -380,3 +384,3 @@ if (traverseCollections) { | ||
for (const collectionItemId of blockIds) { | ||
void processPage(collectionItemId); | ||
void processPage(collectionItemId, depth + 1); | ||
} | ||
@@ -383,0 +387,0 @@ } |
{ | ||
"name": "notion-utils", | ||
"version": "7.4.1", | ||
"version": "7.4.2", | ||
"type": "module", | ||
@@ -30,3 +30,3 @@ "description": "Useful utilities for working with Notion data. Isomorphic.", | ||
"p-queue": "^8.1.0", | ||
"notion-types": "7.4.1" | ||
"notion-types": "7.4.2" | ||
}, | ||
@@ -33,0 +33,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
87336
0.45%1021
0.49%+ Added
- Removed
Updated