Robust TypeScript client for the unofficial Notion API.
94
Build a utility that fetches a Notion page and recursively hydrates any pages referenced through relation properties. The result should include the merged record map for the base page plus all fetched relation pages, using the dependency's built-in hydration features rather than custom HTTP calls.
maxDepth set to 1, only first-level relation pages are fetched; deeper relation links are left unresolved in the resulting record map. @test@generates
export interface HydrationOptions {
maxDepth?: number; // defaults to 2
includeMissingBlocks?: boolean; // fetch child blocks for fetched relation pages
hydrateRelations?: boolean; // defaults to true
signal?: AbortSignal;
}
export interface RecordMap {
block: Record<string, any>;
collection?: Record<string, any>;
collection_view?: Record<string, any>;
collection_query?: Record<string, any>;
notion_user?: Record<string, any>;
signed_urls?: Record<string, string>;
}
export interface HydratedPage {
recordMap: RecordMap;
fetchedRelationPageIds: string[];
}
export async function hydratePageWithRelations(
pageId: string,
options?: HydrationOptions
): Promise<HydratedPage>;Used to retrieve pages, recursively hydrate relation-linked records, and optionally fetch missing child blocks through its relation-aware page fetching features.
Install with Tessl CLI
npx tessl i tessl/npm-notion-clientevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10