UNPKG

@narkdown/notion-parser

Version:

Parse notion response

43 lines (42 loc) 2.62 kB
import type { QueryDatabaseResponse } from '@notionhq/client/build/src/api-endpoints'; import type { ValueOf, IterableElement } from 'type-fest'; export declare type PropertyValues = ValueOf<IterableElement<QueryDatabaseResponse['results']>['properties']>; export declare type PropertyType = PropertyValues['type']; export declare type PropertyValue<PropertyKey extends PropertyType> = Extract<PropertyValues, { type: PropertyKey; }>; export declare const SUPPORTED_PROPERTIES: PropertyType[]; export declare type PropertyOptions = { date: { timeZone?: string; format?: string; }; }; export declare type Annotations = IterableElement<PropertyValue<'title'>['title']>['annotations']; export declare const annotationParsers: Record<keyof Annotations, (string_: string) => string>; export declare const applyAnnotations: (text: string, annotations: Annotations) => string; export declare const applyLink: (text: string, href: string) => string; export declare const title: (value: PropertyValue<'title'>) => string; export declare const rich_text: (value: PropertyValue<'rich_text'>) => string; export declare const number: ({ number }: PropertyValue<'number'>) => number; export declare const select: ({ select }: PropertyValue<'select'>) => string; export declare const multi_select: ({ multi_select }: PropertyValue<'multi_select'>) => string; export declare const date: (options?: { timeZone?: string | undefined; format?: string | undefined; } | undefined) => ({ date }: PropertyValue<'date'>) => string; export declare const checkbox: ({ checkbox }: PropertyValue<'checkbox'>) => ":white_check_mark:" | ":x:"; export declare const url: ({ url }: PropertyValue<'url'>) => string; export declare const email: ({ email }: PropertyValue<'email'>) => string; export declare const phone_number: ({ phone_number }: PropertyValue<'phone_number'>) => string; export declare const created_time: (options?: { timeZone?: string | undefined; format?: string | undefined; } | undefined) => ({ created_time }: PropertyValue<'created_time'>) => string; export declare const last_edited_time: (options?: { timeZone?: string | undefined; format?: string | undefined; } | undefined) => ({ last_edited_time }: PropertyValue<'last_edited_time'>) => string; export declare const properties: (options?: Partial<PropertyOptions> | undefined) => (value: PropertyValues) => string | null; export declare type GetRows = (results: QueryDatabaseResponse['results']) => Array<Record<string, string | null>>; export declare const getRows: (options?: Partial<PropertyOptions> | undefined) => GetRows;