UNPKG

@langchain/community

Version:
1 lines • 8.23 kB
{"version":3,"file":"notionapi.d.cts","names":["APIResponseError","Client","isFullBlock","isFullPage","isFullDatabase","Document","AsyncCaller","BaseDocumentLoader","GuardType","T","U","GetBlockResponse","Parameters","GetPageResponse","GetDatabaseResponse","BlockObjectResponse","PageObjectResponse","DatabaseObjectResponse","GetResponse","PagePropertiesType","PagePropertiesValue","isPageResponse","_notionhq_client_build_src_api_endpoints0","PartialBlockObjectResponse","PartialDatabaseObjectResponse","PartialPageObjectResponse","isDatabaseResponse","isErrorResponse","isPage","isDatabase","OnDocumentLoadedCallback","NotionAPILoaderOptions","ConstructorParameters","NotionAPILoader","Promise"],"sources":["../../../src/document_loaders/web/notionapi.d.ts"],"sourcesContent":["import { APIResponseError, Client, isFullBlock, isFullPage, isFullDatabase } from \"@notionhq/client\";\nimport { Document } from \"@langchain/core/documents\";\nimport { AsyncCaller } from \"@langchain/core/utils/async_caller\";\nimport { BaseDocumentLoader } from \"@langchain/core/document_loaders/base\";\ntype GuardType<T> = T extends (x: any, ...rest: any) => x is infer U ? U : never;\nexport type GetBlockResponse = Parameters<typeof isFullBlock>[0];\nexport type GetPageResponse = Parameters<typeof isFullPage>[0];\nexport type GetDatabaseResponse = Parameters<typeof isFullDatabase>[0];\nexport type BlockObjectResponse = GuardType<typeof isFullBlock>;\nexport type PageObjectResponse = GuardType<typeof isFullPage>;\nexport type DatabaseObjectResponse = GuardType<typeof isFullDatabase>;\nexport type GetResponse = GetBlockResponse | GetPageResponse | GetDatabaseResponse | APIResponseError;\nexport type PagePropertiesType = PageObjectResponse[\"properties\"];\nexport type PagePropertiesValue = PagePropertiesType[keyof PagePropertiesType];\nexport declare const isPageResponse: (res: GetResponse) => res is import(\"@notionhq/client/build/src/api-endpoints\").DatabaseObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PageObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PartialBlockObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PartialDatabaseObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PartialPageObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").BlockObjectResponse;\nexport declare const isDatabaseResponse: (res: GetResponse) => res is import(\"@notionhq/client/build/src/api-endpoints\").DatabaseObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PageObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PartialBlockObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PartialDatabaseObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").PartialPageObjectResponse | import(\"@notionhq/client/build/src/api-endpoints\").BlockObjectResponse;\nexport declare const isErrorResponse: (res: GetResponse) => res is APIResponseError;\nexport declare const isPage: (res: GetResponse) => res is import(\"@notionhq/client/build/src/api-endpoints\").PageObjectResponse;\nexport declare const isDatabase: (res: GetResponse) => res is import(\"@notionhq/client/build/src/api-endpoints\").DatabaseObjectResponse;\nexport type OnDocumentLoadedCallback = (current: number, total: number, currentTitle?: string, rootTitle?: string) => void;\nexport type NotionAPILoaderOptions = {\n clientOptions: ConstructorParameters<typeof Client>[0];\n id: string;\n callerOptions?: ConstructorParameters<typeof AsyncCaller>[0];\n onDocumentLoaded?: OnDocumentLoadedCallback;\n propertiesAsHeader?: boolean;\n};\n/**\n * A class that extends the BaseDocumentLoader class. It represents a\n * document loader for loading documents from Notion using the Notion API.\n * @example\n * ```typescript\n * const pageLoader = new NotionAPILoader({\n * clientOptions: { auth: \"<NOTION_INTEGRATION_TOKEN>\" },\n * id: \"<PAGE_ID>\",\n * type: \"page\",\n * });\n * const pageDocs = await pageLoader.load();\n * const splitDocs = await splitter.splitDocuments(pageDocs);\n *\n * const dbLoader = new NotionAPILoader({\n * clientOptions: { auth: \"<NOTION_INTEGRATION_TOKEN>\" },\n * id: \"<DATABASE_ID>\",\n * type: \"database\",\n * propertiesAsHeader: true,\n * });\n * const dbDocs = await dbLoader.load();\n * ```\n */\nexport declare class NotionAPILoader extends BaseDocumentLoader {\n private caller;\n private notionClient;\n private n2mClient;\n private id;\n private pageQueue;\n private pageCompleted;\n pageQueueTotal: number;\n private documents;\n private rootTitle;\n private onDocumentLoaded;\n private propertiesAsHeader;\n constructor(options: NotionAPILoaderOptions);\n /**\n * Adds a selection of page ids to the pageQueue and removes duplicates.\n * @param items An array of string ids\n */\n private addToQueue;\n /**\n * Parses a Notion GetResponse object (page or database) and returns a string of the title.\n * @param obj The Notion GetResponse object to parse.\n * @returns The string of the title.\n */\n private getTitle;\n /**\n * Parses the property type and returns a string\n * @param page The Notion page property to parse.\n * @returns A string of parsed property.\n */\n private getPropValue;\n /**\n * Parses the properties of a Notion page and returns them as key-value\n * pairs.\n * @param page The Notion page to parse.\n * @returns An object containing the parsed properties as key-value pairs.\n */\n private parsePageProperties;\n /**\n * Parses the details of a Notion page and returns them as an object.\n * @param page The Notion page to parse.\n * @returns An object containing the parsed details of the page.\n */\n private parsePageDetails;\n private loadBlock;\n private loadBlocks;\n private loadPage;\n private loadDatabase;\n /**\n * Loads the documents from Notion based on the specified options.\n * @returns A Promise that resolves to an array of Documents.\n */\n load(): Promise<Document[]>;\n}\nexport {};\n//# sourceMappingURL=notionapi.d.ts.map"],"mappings":";;;;;;;KAIKQ,eAAeC,qDAAmDC;KAC3DC,gBAAAA,GAAmBC,kBAAkBV;KACrCW,eAAAA,GAAkBD,kBAAkBT;AAF3CK,KAGOM,mBAAAA,GAAsBF,UAHsC,CAAA,OAGpBR,cAHoB,CAAA,CAAA,CAAA,CAAA;AAC5DO,KAGAI,mBAAAA,GAAsBP,SAHeN,CAAAA,OAGEA,WAHV,CAAA;AAC7BW,KAGAG,kBAAAA,GAAqBR,SAHeL,CAAAA,OAGEA,UAHV,CAAA;AAC5BW,KAGAG,sBAAAA,GAAyBT,SAHeJ,CAAAA,OAGEA,cAHV,CAAA;AAChCW,KAGAG,WAAAA,GAAcP,gBAHyBT,GAGNW,eAHXL,GAG6BM,mBAHpB,GAG0Cd,gBAH1C;AAC/BgB,KAGAG,kBA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