UNPKG

@pagenote/notion-database

Version:

make notion as a real-database for server

37 lines (36 loc) 1.39 kB
import { EmptyObject, Filter, NotionTableCreateProperties, ObjectType, SupportNotionTypes } from './notionType'; import { ListBlockChildrenResponse } from '@notionhq/client/build/src/api-endpoints'; export declare const NOTION_RESERVED_KEY = "title"; /** * 示例表格数据,ObjectType: 基于 JavaScript 类型自动推断类型, SupportNotionTypes 指定类型 */ export type NotionObjectSchema = Record<string, ObjectType | SupportNotionTypes> & { [NOTION_RESERVED_KEY]?: SupportNotionTypes.title; }; export type AllowFilter<T extends NotionObjectSchema> = Partial<T> | Filter | { [key: string]: string; }; /** * 返回的js 对象,额外添加的notion属性 TODO 删除 __notion_开头的字段,保存时 */ export type AppendNotionPropertiesDocumentFields = { __notion_id?: string; __notion_primary?: string; __notion_url?: string; __notion_icon?: string; __notion_cover?: string; }; export type AppendNotionDetailDocumentFields = { __blocks?: ListBlockChildrenResponse['results']; __markdown?: string; }; export type ResponseNotionPropertiesDocument<T> = AppendNotionPropertiesDocumentFields & T; /** * 创建一个 notion 表格的 schema 结构定义 */ export type NotionDatabaseCreateSchema = { __notion_primary?: { type: SupportNotionTypes.title; title: EmptyObject; }; } & NotionTableCreateProperties;