/** * Notion client types. */ import type { BaseIntegrationClient } from "../../types.js"; import type { SupportsApiRequest } from "../base/index.js"; /** * Notion client for workspace and database interactions. * * Provides the generic apiRequest() method for any Notion API endpoint. * Use this to interact with Notion's databases, pages, blocks, and other endpoints. * * @example * ```typescript * import { z } from 'zod'; * * // Declare in api(): integrations: { notion: notion(INTEGRATION_ID) } * // In run(), access via ctx.integrations.notion * * // Define schemas * const PageSchema = z.object({ * id: z.string(), * object: z.literal('page'), * properties: z.record(z.any()), * }); * * // Get a page * const page = await ctx.integrations.notion.apiRequest( * { * method: 'GET', * path: '/v1/pages/page-id', * }, * { response: PageSchema } * ); * * // Query a database * const DatabaseQueryRequestSchema = z.object({ * filter: z.object({ * property: z.string(), * select: z.object({ * equals: z.string(), * }), * }).optional(), * }); * * const DatabaseQuerySchema = z.object({ * results: z.array(PageSchema), * has_more: z.boolean(), * }); * * const results = await ctx.integrations.notion.apiRequest( * { * method: 'POST', * path: '/v1/databases/database-id/query', * body: { * filter: { * property: 'Status', * select: { equals: 'Done' }, * }, * }, * }, * { * body: DatabaseQueryRequestSchema, * response: DatabaseQuerySchema, * } * ); * ``` */ export interface NotionClient extends BaseIntegrationClient, SupportsApiRequest { // apiRequest() method inherited from SupportsApiRequest }