import { ExportRecordResult, ExportSchema, ExportableItem } from "../types.js"; import { NotionDataSource, NotionExportConfig, NotionPage, NotionPropertyType } from "./types.js"; import { Client, CreateDatabaseParameters } from "@notionhq/client"; //#region src/shared/datasources/export/notion/handler.d.ts /** Notion writes one page per request and throttles around 3 requests/second. */ declare const NOTION_MAX_ITEMS_PER_RUN = 100; type PropertyConfig = CreateDatabaseParameters extends { initial_data_source?: { properties?: infer P; }; } ? P extends Record ? V : never : never; type PageProperties = NonNullable[0]["properties"]>; type PageProperty = PageProperties[string]; /** Build the Notion property configuration of a datasource schema. */ declare function buildNotionProperties(schema: ExportSchema): Record; /** Convert one item value to the Notion payload matching the remote property type. */ declare function toNotionValue(value: unknown, type: NotionPropertyType | string): PageProperty | null; /** * Build the page properties for one item: apply the configured mapping, then coerce * each value to its remote property type. Properties absent from the remote data * source are skipped rather than failing the whole page. */ declare function mapItemToNotionProperties(data: Record, config: Pick): PageProperties; /** Pages the integration can use as a parent for a new database. */ declare function fetchNotionParentPages(accessToken: string): Promise; /** Existing data sources the items could be written to. */ declare function fetchNotionDataSources(accessToken: string): Promise; /** Create a Notion database (and its data source) under `parentPageId`. */ declare function createNotionDatabase({ accessToken, parentPageId, name, schema }: { accessToken: string; parentPageId: string; name: string; schema: ExportSchema; }): Promise; /** * Add to an existing data source the properties missing on the Notion side, and * return the configuration to store. Properties removed from the datasource are left * in place on Notion. */ declare function attachNotionDataSource({ accessToken, dataSourceId, schema, fieldMapping }: { accessToken: string; dataSourceId: string; schema: ExportSchema; fieldMapping?: Record; }): Promise; /** * Create or update one Notion page per item. Notion has no batch endpoint, so items * are pushed sequentially and a failing item never stops the others. */ declare function upsertNotionRecords({ accessToken, config, items }: { accessToken: string; config: NotionExportConfig; items: ExportableItem[]; }): Promise; /** Notion has no hard delete: a removed item archives its page (moves it to trash). */ declare function deleteNotionRecords({ accessToken, recordIds }: { accessToken: string; recordIds: string[]; }): Promise; //#endregion export { NOTION_MAX_ITEMS_PER_RUN, attachNotionDataSource, buildNotionProperties, createNotionDatabase, deleteNotionRecords, fetchNotionDataSources, fetchNotionParentPages, mapItemToNotionProperties, toNotionValue, upsertNotionRecords }; //# sourceMappingURL=handler.d.ts.map