import * as types from "notion-types"; import { Block, BlockMap, Collection, CollectionView, ExtendedRecordMap, NotionMapBox, PageMap, User } from "notion-types"; import isUrl from "is-url-superb"; //#region src/estimate-page-read-time.d.ts type EstimatePageReadTimeOptions = { wordsPerMinute?: number; imageReadTimeInSeconds?: number; }; type ContentStats = { numWords: number; numImages: number; }; type PageReadTimeEstimate = ContentStats & { totalWordsReadTimeInMinutes: number; totalImageReadTimeInMinutes: number; totalReadTimeInMinutes: number; }; /** * Returns an estimate for the time it would take for a person to read the content * in the given Notion page. * * Uses Medium for inspiration. * * @see https://blog.medium.com/read-time-and-you-bc2048ab620c * @see https://github.com/ngryman/reading-time * * TODO: handle non-english content. */ declare function estimatePageReadTime(block: Block, recordMap: ExtendedRecordMap, { wordsPerMinute, imageReadTimeInSeconds }?: EstimatePageReadTimeOptions): PageReadTimeEstimate; /** * Same as `estimatePageReadTime`, except it returns the total time estimate as * a human-readable string. * * For example, "9 minutes" or "less than a minute". */ declare function estimatePageReadTimeAsHumanizedString(block: Block, recordMap: ExtendedRecordMap, opts: EstimatePageReadTimeOptions): string; //#endregion //#region src/format-date.d.ts declare const formatDate: (input: string | number, { month }?: { month?: 'long' | 'short'; }) => string; //#endregion //#region src/format-notion-date-time.d.ts interface NotionDateTime { type: 'datetime'; start_date: string; start_time?: string; time_zone?: string; } declare const formatNotionDateTime: (datetime: NotionDateTime) => string; //#endregion //#region src/get-all-pages-in-space.d.ts /** * 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. * * 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. * @param rootSpaceId - Space ID to scope traversal. * @param getPage - Function used to fetch a single page. * @param opts - Optional config */ declare function getAllPagesInSpace(rootPageId: string, rootSpaceId: string | undefined, getPage: (pageId: string) => Promise, { concurrency, traverseCollections, targetPageId, maxDepth }?: { concurrency?: number; traverseCollections?: boolean; targetPageId?: string; maxDepth?: number; }): Promise; //#endregion //#region src/get-block-collection-id.d.ts declare function getBlockCollectionId(block: Block, recordMap: ExtendedRecordMap): string | null; //#endregion //#region src/get-block-icon.d.ts declare function getBlockIcon(block: Block, recordMap: ExtendedRecordMap): string | null | undefined; //#endregion //#region src/get-block-parent-page.d.ts /** * 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. */ declare const getBlockParentPage: (block: types.Block, recordMap: types.ExtendedRecordMap, { inclusive }?: { inclusive?: boolean; }) => types.PageBlock | null; //#endregion //#region src/get-block-title.d.ts declare function getBlockTitle(block: Block, recordMap: ExtendedRecordMap): string; //#endregion //#region src/get-block-value.d.ts declare function getBlockValue(block: T | NotionMapBox | undefined): T | undefined; //#endregion //#region src/get-canonical-page-id.d.ts /** * Gets the canonical, display-friendly version of a page's ID for use in URLs. */ declare const getCanonicalPageId: (pageId: string, recordMap: ExtendedRecordMap, { uuid }?: { uuid?: boolean; }) => string | null; //#endregion //#region src/get-date-value.d.ts /** * Attempts to find a valid date from a given property. */ declare const getDateValue: (prop: any[]) => types.FormattedDate | null; //#endregion //#region src/get-list-nesting-level.d.ts declare const getListNestingLevel: (blockId: string, blockMap: BlockMap) => number; //#endregion //#region src/get-list-number.d.ts declare function getListNumber(blockId: string, blockMap: BlockMap): any; //#endregion //#region src/get-list-style.d.ts declare function getListStyle(level: number): string; //#endregion //#region src/get-page-breadcrumbs.d.ts declare const getPageBreadcrumbs: (recordMap: types.ExtendedRecordMap, activePageId: string) => Array | null; //#endregion //#region src/get-page-content-block-ids.d.ts /** * Gets the IDs of all blocks contained on a page starting from a root block ID. */ declare const getPageContentBlockIds: (recordMap: types.ExtendedRecordMap, blockId?: string) => string[]; //#endregion //#region src/get-page-image-urls.d.ts /** * Gets URLs of all images contained on the given page. */ declare const getPageImageUrls: (recordMap: types.ExtendedRecordMap, { mapImageUrl }: { mapImageUrl: (url: string, block: types.Block) => string | undefined; }) => string[]; //#endregion //#region src/get-page-property.d.ts /** * Gets the value of a collection property for a given page (collection item). * * @param propertyName property name * @param block Page block, often be first block in blockMap * @param recordMap * @returns - The return value types will follow the following principles: * 1. if property is date type, it will return `number` or `number[]`(depends on `End Date` switch) * 2. property is text-like will return `string` * 3. multi select property will return `string[]` * 4. checkbox property return `boolean` * @todo complete all no-text property type */ declare function getPageProperty(propertyName: string, block: Block, recordMap: ExtendedRecordMap): T; //#endregion //#region src/get-page-table-of-contents.d.ts interface TableOfContentsEntry { id: types.ID; type: types.BlockType; text: string; indentLevel: number; } /** * Gets the metadata for a table of contents block by parsing the page's * H1, H2, and H3 elements. */ declare const getPageTableOfContents: (page: types.PageBlock, recordMap: types.ExtendedRecordMap) => Array; //#endregion //#region src/get-page-title.d.ts declare function getPageTitle(recordMap: ExtendedRecordMap): string | null; //#endregion //#region src/get-page-tweet-ids.d.ts /** * Gets the IDs of all tweets embedded on a page. */ declare const getPageTweetIds: (recordMap: types.ExtendedRecordMap) => string[]; //#endregion //#region src/get-page-tweet-urls.d.ts /** * Gets the URLs of all tweets embedded on a page. */ declare const getPageTweetUrls: (recordMap: types.ExtendedRecordMap) => string[]; //#endregion //#region src/get-text-content.d.ts /** * 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. */ declare const getTextContent: (text?: types.Decoration[]) => string; //#endregion //#region src/group-block-content.d.ts declare function groupBlockContent(blockMap: BlockMap): string[][]; //#endregion //#region src/id-to-uuid.d.ts declare const idToUuid: (id?: string) => string; //#endregion //#region src/is-public-notion-page.d.ts /** Returns whether the root page is reachable through a public permission. */ declare const isPublicNotionPage: (recordMap: ExtendedRecordMap, rootPageId?: string) => boolean; /** Returns whether an image-owning block inherits public page access. */ declare const isPublicNotionBlock: (recordMap: ExtendedRecordMap, blockId: string, rootPageId?: string) => boolean; //#endregion //#region src/map-image-url.d.ts declare const notionImageProxyOrigin = "https://app.notion.com"; declare const isNotionHost: (hostname: string) => boolean; /** Returns whether a URL contains a temporary Notion file signature. */ declare const isNotionSignedFileUrl: (url: string) => boolean; /** Returns whether a temporary Notion file URL carries an expired timestamp. */ declare const isNotionFileUrlExpired: (url: string, now?: number) => boolean; /** Returns the underlying private Notion file URL without changing its form. */ declare const getNotionFileUrl: (url: string) => string | undefined; /** * Returns a stable private Notion file source accepted by Notion's signing and * image proxy endpoints, including from legacy proxy and temporary file URLs. */ declare const getStableNotionFileSource: (url: string) => string | undefined; /** * Resolves a private Notion file URL using signatures added by `notion-client`. * * New record maps store signatures by original URL so blocks with multiple assets * (for example, a page cover and icon) resolve unambiguously. The block ID lookup * keeps older record maps compatible. */ declare const getSignedFileUrl: (url: string | undefined, block: Block, signedUrls: ExtendedRecordMap['signed_urls'] | undefined) => string | undefined; declare const defaultMapImageUrl: (url: string | undefined, block: Block) => string | undefined; /** Resolves the default image URL with the owning record map's access mode. */ declare const resolveDefaultImageUrl: (url: string | undefined, block: Block, { signedUrls, isPublic }: { signedUrls: ExtendedRecordMap['signed_urls'] | undefined; isPublic: boolean; }) => string | undefined; //#endregion //#region src/map-page-url.d.ts declare const defaultMapPageUrl: (rootPageId?: string) => (pageId: string) => string; //#endregion //#region src/merge-record-maps.d.ts declare function mergeRecordMaps(recordMapA: ExtendedRecordMap, recordMapB: ExtendedRecordMap): ExtendedRecordMap; //#endregion //#region src/normalize-title.d.ts declare const normalizeTitle: (title?: string | null) => string; //#endregion //#region src/normalize-url.d.ts declare const normalizeUrl: (url?: string) => string; //#endregion //#region src/parse-page-id.d.ts /** * Robustly extracts the notion page ID from a notion URL or pathname suffix. * * Defaults to returning a UUID (with dashes). */ declare const parsePageId: (id?: string | undefined | null, { uuid }?: { uuid?: boolean; }) => string | undefined; //#endregion //#region src/uuid-to-id.d.ts declare const uuidToId: (uuid: string) => string; //#endregion export { NotionDateTime, TableOfContentsEntry, defaultMapImageUrl, defaultMapPageUrl, estimatePageReadTime, estimatePageReadTimeAsHumanizedString, formatDate, formatNotionDateTime, getAllPagesInSpace, getBlockCollectionId, getBlockIcon, getBlockParentPage, getBlockTitle, getBlockValue, getCanonicalPageId, getDateValue, getListNestingLevel, getListNumber, getListStyle, getNotionFileUrl, getPageBreadcrumbs, getPageContentBlockIds, getPageImageUrls, getPageProperty, getPageTableOfContents, getPageTitle, getPageTweetIds, getPageTweetUrls, getSignedFileUrl, getStableNotionFileSource, getTextContent, groupBlockContent, idToUuid, isNotionFileUrlExpired, isNotionHost, isNotionSignedFileUrl, isPublicNotionBlock, isPublicNotionPage, isUrl, mergeRecordMaps, normalizeTitle, normalizeUrl, notionImageProxyOrigin, parsePageId, resolveDefaultImageUrl, uuidToId }; //# sourceMappingURL=index.d.ts.map