import type { Agent } from "node:http"; import type { GetPluginDirectoryParameters } from "./api-endpoints"; import { type Logger, LogLevel } from "./logging"; import { type GetPageMarkdownParameters, type GetPageMarkdownResponse, type UpdatePageMarkdownParameters, type UpdatePageMarkdownResponse, type OauthTokenResponse, type OauthTokenParameters, type OauthIntrospectResponse, type OauthIntrospectParameters, type OauthRevokeResponse, type OauthRevokeParameters, type GetFileUploadResponse, type GetFileUploadParameters, type SendFileUploadParameters, type SendFileUploadResponse, type CompleteFileUploadParameters, type CompleteFileUploadResponse, type ListFileUploadsParameters, type ListFileUploadsResponse, type CreateViewParameters, type CreateViewResponse, type UpdateViewParameters, type UpdateViewResponse, type CreateViewQueryParameters, type CreateViewQueryResponse, type ListCustomEmojisParameters, type ListCustomEmojisResponse, type UpdateSessionStreamParameters, type UpdateSessionStreamResponse } from "./api-endpoints"; import { type QueryMeetingNotesResponse } from "./api-endpoints/meeting-notes"; import type { QueryMeetingNotesParameters } from "./meeting-notes"; import type { SupportedFetch } from "./fetch-types"; export type RetryOptions = { /** * Maximum number of retry attempts. Set to 0 to disable retries. * @default 2 */ maxRetries?: number; /** * Initial delay between retries in milliseconds. * Used as base for exponential back-off when retry-after header is absent. * @default 1000 */ initialRetryDelayMs?: number; /** * Maximum delay between retries in milliseconds. * @default 60000 */ maxRetryDelayMs?: number; }; export type ClientOptions = { auth?: string; timeoutMs?: number; baseUrl?: string; logLevel?: LogLevel; logger?: Logger; notionVersion?: string; fetch?: SupportedFetch; /** Silently ignored in the browser */ agent?: Agent; /** * Configuration for automatic retries on rate limit (429) and server errors. * Set to false to disable retries entirely. */ retry?: RetryOptions | false; /** * Allows the client to use a Notion token inside a browser page or worker. * Without it, using a token there throws `BrowserTokenNotAllowedError`. * Anyone who can load the page can read the token and act as your * connection, so only set this for pages that nobody else can open. */ dangerouslyAllowBrowser?: boolean; }; type FileParam = { filename?: string; data: string | Blob; }; export type RequestParameters = { path: string; method: Method; query?: QueryParams; body?: Record; formDataParams?: Record; headers?: Record; /** * To authenticate using public API token, `auth` should be passed as a * string. If you are trying to complete OAuth, then `auth` should be an object * containing your integration's client ID and secret. */ auth?: string | { client_id: string; client_secret: string; }; }; export default class Client { #private; static readonly defaultNotionVersion = "2025-09-03"; constructor(options?: ClientOptions); /** * Sends a request. */ request(args: RequestParameters): Promise; /** * Opens an SSE response and yields each parsed event as it arrives. */ private streamRequest; /** * Builds the full URL with query parameters. */ private buildRequestUrl; /** * Serializes the request body to JSON string if non-empty. */ private serializeBody; /** * Builds the request headers including auth and content-type. */ private buildRequestHeaders; /** * Builds the authorization header based on auth type. */ private buildAuthHeader; /** * Builds FormData from form parameters if provided. * Also removes content-type header to let fetch set the boundary. */ private buildFormData; /** * Executes the request with retry logic. */ private executeWithRetry; /** * Executes a single HTTP request (no retry). */ private executeSingleRequest; /** * Opens an SSE response without consuming its body. Retry orchestration is * shared with JSON requests so only the initial, retryable HTTP failures are * retried; once a stream has opened, its events are never replayed. */ private executeSingleStreamRequest; /** * Logs a request error with appropriate detail level. */ private logRequestError; /** * Extracts request_id from an object if present. */ private extractRequestId; /** * Determines if an error can be retried based on its error code and method. * Rate limits (429) and service overloads (529) are always retryable since * the server explicitly asks us to retry. Server errors (500, 503) are only * retried for idempotent methods (GET, DELETE) to avoid duplicate side * effects. */ private canRetry; /** * Calculates the delay before the next retry attempt. * Uses retry-after header if present, otherwise exponential back-off with * jitter. */ private calculateRetryDelay; /** * Parses the retry-after header value. * Supports both delta-seconds (e.g., "120") and HTTP-date formats. * Returns the delay in milliseconds, or undefined if not present or invalid. */ private parseRetryAfterHeader; private sleep; readonly plugins: { list: (args?: ({ page_size?: number | undefined; start_cursor?: string | null | undefined; } & { auth?: string; }) | undefined) => Promise; retrieve: (args: WithAuth) => Promise; }; readonly skills: { retrieve: (args: { id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; }; readonly agents: { query: (args?: ({ query?: string | undefined; filter?: { property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; } | { and: Array<{ property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; } | { and: Array<{ property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; }>; } | { or: Array<{ property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; }>; }>; } | { or: Array<{ property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; } | { and: Array<{ property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; }>; } | { or: Array<{ property: "id"; id: { equals: string; }; } | { property: "agent_type"; string: { equals: "notion_ai" | "custom_agent" | "autofill_custom_agent"; }; } | { property: "created_by"; people: { contains: string; }; } | { property: "created_time"; date: { after?: string; before?: string; }; } | { property: "favorited"; checkbox: { equals: boolean; }; } | { property: "connections"; mcp_server: { contains: string; }; } | { property: "status"; status: { in: Array<"active" | "disabled" | "deleted">; }; } | { property: "model_mode"; select: { equals: "auto" | "pinned"; }; } | { property: "agent_version"; number: { equals: number; }; } | { property: "last_run_at"; date: { after?: string; before?: string; }; }>; }>; } | undefined; sorts?: Array<{ property: "created_time" | "last_run_at"; direction: "ascending" | "descending"; }> | undefined; start_cursor?: string | null | undefined; page_size?: number | undefined; verbose?: boolean | undefined; include_deleted?: boolean | undefined; } & { auth?: string; }) | undefined) => Promise; retrieve: (args: { agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; } & { verbose?: boolean; } & { auth?: string; }) => Promise; delete: (args: { agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; } & { auth?: string; }) => Promise; retrieveInsights: (args: { agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; } & { start_time?: number; end_time?: number; } & { auth?: string; }) => Promise; updateStatus: (args: { agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; } & { status: "active" | "disabled"; } & { auth?: string; }) => Promise; updateCreditLimit: (args: { agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; } & { credit_limit: number | null; } & { auth?: string; }) => Promise; batch: (args: { operations: Array<{ action: "update_status"; agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; fields: { status: "active" | "disabled"; }; } | { action: "update_credit_limit"; agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; fields: { credit_limit: number | null; }; } | { action: "delete"; agent_id: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; }>; } & { auth?: string; }) => Promise; }; readonly sessions: { /** * Retrieve a session */ retrieve: (args: { session_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; /** * Update a session */ update: (args: ({ message: string; agent_id?: import("./api-endpoints").IdRequest | "notion_ai" | "33333333-3333-3333-3333-333333333333"; session_id?: import("./api-endpoints").IdRequest; attachments?: Array<{ file_upload: { id: string; }; type?: "file_upload"; name?: string; }>; metadata?: Record; prompt_context?: string; } | { session_id: import("./api-endpoints").IdRequest; actions: Array<{ action_id: import("./api-endpoints").IdRequest; option_id: "approve" | "reject"; }>; metadata?: Record; } | { session_id: import("./api-endpoints").IdRequest; continue_from: string; }) & { auth?: string; }) => Promise; /** * Open a session stream */ stream: (args: WithAuth) => AsyncIterable; /** * Cancel a session */ cancel: (args: { session_id: import("./api-endpoints").IdRequest; } & { event_id?: string; } & { auth?: string; }) => Promise; /** * Query sessions */ query: (args?: ({ query?: string | undefined; filter?: { property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "agent_id"; string: { equals: string; }; } | { property: "status"; status: { equals?: "queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated"; in?: Array<"queued" | "in_progress" | "requires_action" | "completed" | "failed" | "canceled" | "terminated">; }; } | { property: "created_at" | "updated_at"; timestamp: { before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; }>; } | undefined; sorts?: Array<{ property: "created_at" | "updated_at"; direction: "ascending" | "descending"; }> | undefined; start_cursor?: string | null | undefined; page_size?: number | undefined; } & { auth?: string; }) | undefined) => Promise; /** * Query session events */ queryEvents: (args: { session_id: import("./api-endpoints").IdRequest; } & { filter?: { property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; }>; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; } | { and: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; } | { or: Array<{ property: "id"; string: { equals: string; }; } | { property: "type"; event_type: { equals?: "user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status"; in?: Array<"user.message" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "session.status">; }; } | { property: "sequence"; number: { greater_than?: number; greater_than_or_equal_to?: number; less_than?: number; less_than_or_equal_to?: number; }; } | { property: "created_at"; timestamp: { equals?: string; before?: string; after?: string; on_or_before?: string; on_or_after?: string; }; }>; }>; }>; }; sorts?: Array<{ property: "sequence" | "created_at"; direction: "ascending" | "descending"; }>; start_cursor?: string | null; page_size?: number; } & { auth?: string; }) => Promise; }; readonly asyncTasks: { retrieve: (args: { task_id: string; } & { auth?: string; }) => Promise; }; readonly blocks: { /** * Retrieve block */ retrieve: (args: { block_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; /** * Update block */ update: (args: import("./api-endpoints").UpdateBlockParameters & { auth?: string; }) => Promise; /** * Delete block */ delete: (args: { block_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; children: { list: (args: { block_id: import("./api-endpoints").IdRequest; } & { start_cursor?: string | null; page_size?: number; } & { auth?: string; }) => Promise; append: (args: { block_id: import("./api-endpoints").IdRequest; } & { children: Array; after?: import("./api-endpoints").IdRequest; position?: import("./api-endpoints").ContentPositionSchema; } & { auth?: string; }) => Promise; }; meetingNotes: { /** * Create a meeting note */ create: (args: ({ title?: string; language?: "auto" | "en" | "zh-CN" | "zh-TW" | "es" | "fr" | "de" | "ja" | "ko" | "pt" | "ru" | "th" | "vi" | "id" | "da" | "fi" | "no" | "nl" | "it" | "sv" | "ar" | "he" | "pl"; options?: { kickoff_summary?: boolean; }; } & ({ source: { type: "file_upload"; file_upload_id: import("./api-endpoints").IdRequest; }; parent: { type: "page_id"; page_id: import("./api-endpoints").IdRequest; }; } | { source: { type: "block"; block_id: import("./api-endpoints").IdRequest; }; parent?: never; })) & { auth?: string; }) => Promise; /** * Query meeting notes */ query: (args: WithAuth) => Promise; }; }; readonly databases: { retrieve: (args: { database_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; update: (args: { database_id: import("./api-endpoints").IdRequest; } & { parent?: { type: "page_id" | "workspace"; } & ({ type: "page_id"; page_id: import("./api-endpoints").IdRequest; } | { type: "workspace"; workspace: true; }); title?: Array; description?: Array; is_inline?: boolean; icon?: import("./api-endpoints").PageIconRequest; cover?: import("./api-endpoints").PageCoverRequest; in_trash?: boolean; archived?: boolean; is_locked?: boolean; } & { auth?: string; }) => Promise; create: (args: { parent: { type: "page_id" | "workspace"; } & ({ type: "page_id"; page_id: import("./api-endpoints").IdRequest; } | { type: "workspace"; workspace: true; }); title?: Array; description?: Array; is_inline?: boolean; initial_data_source?: import("./api-endpoints").InitialDataSourceRequest; database_type?: "tasks" | "projects" | "skills"; icon?: import("./api-endpoints").PageIconRequest; cover?: import("./api-endpoints").PageCoverRequest; } & { auth?: string; }) => Promise; }; readonly dataSources: { retrieve: (args: { data_source_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; update: (args: { data_source_id: import("./api-endpoints").IdRequest; } & { title?: Array; icon?: import("./api-endpoints").PageIconRequest | null; properties?: Record; }; } | { type?: "multi_select"; multi_select: { options?: Array<{ color?: import("./api-endpoints").SelectColor; description?: string | null; } & ({ name: string; id?: string; } | { id: string; name?: string; })>; }; } | { type?: "status"; status: import("./api-endpoints").StatusPropertyConfigUpdateRequest; } | { type?: "relation"; relation: { data_source_id: import("./api-endpoints").IdRequest; } & ({ type?: "single_property"; single_property: import("./api-endpoints").EmptyObject; } | { type?: "dual_property"; dual_property: { synced_property_id?: string; synced_property_name?: string; }; }); } | { type?: "rollup"; rollup: { function: import("./api-endpoints").RollupFunction; } & ({ relation_property_name: string; rollup_property_name: string; } | { relation_property_id: string; rollup_property_name: string; } | { relation_property_name: string; rollup_property_id: string; } | { relation_property_id: string; rollup_property_id: string; }); } | { type?: "unique_id"; unique_id: { prefix?: string | null; }; } | { type?: "title"; title: import("./api-endpoints").EmptyObject; } | { type?: "rich_text"; rich_text: import("./api-endpoints").EmptyObject; } | { type?: "url"; url: import("./api-endpoints").EmptyObject; } | { type?: "people"; people: import("./api-endpoints").EmptyObject; } | { type?: "files"; files: import("./api-endpoints").EmptyObject; } | { type?: "email"; email: import("./api-endpoints").EmptyObject; } | { type?: "phone_number"; phone_number: import("./api-endpoints").EmptyObject; } | { type?: "date"; date: import("./api-endpoints").EmptyObject; } | { type?: "checkbox"; checkbox: import("./api-endpoints").EmptyObject; } | { type?: "created_by"; created_by: import("./api-endpoints").EmptyObject; } | { type?: "created_time"; created_time: import("./api-endpoints").EmptyObject; } | { type?: "last_edited_by"; last_edited_by: import("./api-endpoints").EmptyObject; } | { type?: "last_edited_time"; last_edited_time: import("./api-endpoints").EmptyObject; } | { type?: "place"; place: import("./api-endpoints").EmptyObject; })) | { name: string; } | null>; in_trash?: boolean; archived?: boolean; parent?: import("./api-endpoints").ParentOfDataSourceRequest; } & { auth?: string; }) => Promise; query: (args: { data_source_id: import("./api-endpoints").IdRequest; } & { filter_properties?: Array; } & { sorts?: Array<{ property: string; direction: "ascending" | "descending"; } | { timestamp: "created_time" | "last_edited_time"; direction: "ascending" | "descending"; }>; filter?: { or: import("./api-endpoints").GroupFilterOperatorArray; } | { and: import("./api-endpoints").GroupFilterOperatorArray; } | import("./api-endpoints").PropertyFilter | import("./api-endpoints").TimestampFilter; start_cursor?: string | null; page_size?: number; in_trash?: boolean; archived?: boolean; result_type?: "page" | "data_source"; } & { auth?: string; }) => Promise; create: (args: { parent: import("./api-endpoints").ParentOfDataSourceRequest; properties: Record; title?: Array; icon?: import("./api-endpoints").PageIconRequest | null; } & { auth?: string; }) => Promise; listTemplates: (args: { data_source_id: import("./api-endpoints").IdRequest; } & { name?: string; start_cursor?: string | null; page_size?: number; } & { auth?: string; }) => Promise; }; readonly pages: { /** * Create a page */ create: (args: { filter_properties?: Array; } & { parent?: { page_id: import("./api-endpoints").IdRequest; type?: "page_id"; } | { database_id: import("./api-endpoints").IdRequest; type?: "database_id"; } | { data_source_id: import("./api-endpoints").IdRequest; type?: "data_source_id"; } | { workspace: true; type?: "workspace"; }; properties?: Record; type?: "title"; } | { rich_text: Array; type?: "rich_text"; } | { number: number | null; type?: "number"; } | { url: import("./api-endpoints").TextRequest | null; type?: "url"; } | { select: { id: import("./api-endpoints").StringRequest; name?: import("./api-endpoints").TextRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | { name: import("./api-endpoints").TextRequest; id?: import("./api-endpoints").StringRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | null; type?: "select"; } | { multi_select: Array<{ id: import("./api-endpoints").StringRequest; name?: import("./api-endpoints").TextRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | { name: import("./api-endpoints").TextRequest; id?: import("./api-endpoints").StringRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; }>; type?: "multi_select"; } | { people: Array; type?: "people"; } | { email: import("./api-endpoints").StringRequest | null; type?: "email"; } | { phone_number: import("./api-endpoints").StringRequest | null; type?: "phone_number"; } | { date: import("./api-endpoints").DateRequest | null; type?: "date"; } | { checkbox: boolean; type?: "checkbox"; } | { relation: Array; type?: "relation"; } | { files: Array; type?: "files"; } | { status: { id: import("./api-endpoints").StringRequest; name?: import("./api-endpoints").TextRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | { name: import("./api-endpoints").TextRequest; id?: import("./api-endpoints").StringRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | null; type?: "status"; } | { place: { lat: number; lon: number; name?: string | null; address?: string | null; aws_place_id?: string | null; google_place_id?: string | null; } | null; type?: "place"; } | { verification: { state: "verified"; date?: import("./api-endpoints").DateRequest; } | { state: "unverified"; }; type?: "verification"; }>; icon?: import("./api-endpoints").PageIconRequest | null; cover?: import("./api-endpoints").PageCoverRequest | null; content?: Array; children?: Array; markdown?: string; allow_async?: boolean; template?: { type: "none"; } | { type: "default"; timezone?: import("./api-endpoints").TemplateTimezone; } | { type: "template_id"; template_id: import("./api-endpoints").IdRequest; timezone?: import("./api-endpoints").TemplateTimezone; }; position?: import("./api-endpoints").PagePositionSchema; } & { auth?: string; }) => Promise; /** * Retrieve a page */ retrieve: (args: { page_id: import("./api-endpoints").IdRequest; } & { filter_properties?: Array; } & { auth?: string; }) => Promise; /** * Update page properties */ update: (args: { page_id: import("./api-endpoints").IdRequest; } & { filter_properties?: Array; } & { properties?: Record; type?: "title"; } | { rich_text: Array; type?: "rich_text"; } | { number: number | null; type?: "number"; } | { url: import("./api-endpoints").TextRequest | null; type?: "url"; } | { select: { id: import("./api-endpoints").StringRequest; name? /** * Executes the request with retry logic. */: import("./api-endpoints").TextRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | { name: import("./api-endpoints").TextRequest; id?: import("./api-endpoints").StringRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | null; type?: "select"; } | { multi_select: Array<{ id: import("./api-endpoints").StringRequest; name?: import("./api-endpoints").TextRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | { name: import("./api-endpoints").TextRequest; id?: import("./api-endpoints").StringRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; }>; type?: "multi_select"; } | { people: Array; type?: "people"; } | { email: import("./api-endpoints").StringRequest | null; type?: "email"; } | { phone_number: import("./api-endpoints").StringRequest | null; type?: "phone_number"; } | { date: import("./api-endpoints").DateRequest | null; type?: "date"; } | { checkbox: boolean; type?: "checkbox"; } | { relation: Array; type?: "relation"; } | { files: Array; type?: "files"; } | { status: { id: import("./api-endpoints").StringRequest; name?: import("./api-endpoints").TextRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | { name: import("./api-endpoints").TextRequest; id?: import("./api-endpoints").StringRequest; color?: import("./api-endpoints").SelectColor; description?: import("./api-endpoints").TextRequest | null; } | null; type?: "status"; } | { place: { lat: number; lon: number; name?: string | null; address?: string | null; aws_place_id?: string | null; google_place_id?: string | null; } | null; type?: "place"; } | { verification: { state: "verified"; date?: import("./api-endpoints").DateRequest; } | { state: "unverified"; }; type?: "verification"; }>; icon?: import("./api-endpoints").PageIconRequest | null; cover?: import("./api-endpoints").PageCoverRequest | null; is_locked?: boolean; template?: { type: "default"; timezone?: import("./api-endpoints").TemplateTimezone; } | { type: "template_id"; template_id: import("./api-endpoints").IdRequest; timezone?: import("./api-endpoints").TemplateTimezone; }; erase_content?: boolean; in_trash?: boolean; archived?: boolean; is_archived?: boolean; } & { auth?: string; }) => Promise; /** * Move a page */ move: (args: { page_id: import("./api-endpoints").IdRequest; } & { parent: { page_id: import("./api-endpoints").IdRequest; type?: "page_id"; } | { data_source_id: import("./api-endpoints").IdRequest; type?: "data_source_id"; }; } & { auth?: string; }) => Promise; /** * Retrieve a page as markdown */ retrieveMarkdown: (args: WithAuth) => Promise; /** * Update a page's content as markdown */ updateMarkdown: (args: WithAuth) => Promise; properties: { retrieve: (args: { page_id: import("./api-endpoints").IdRequest; property_id: string; } & { start_cursor?: string | null; page_size?: number; } & { auth?: string; }) => Promise; }; }; readonly users: { me: (args?: ({} & { auth?: string; }) | undefined) => Promise; retrieve: (args: { user_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; list: (args?: ({ start_cursor?: string | null | undefined; page_size?: number | undefined; } & { auth?: string; }) | undefined) => Promise; }; readonly customEmojis: { /** * List custom emojis */ list: (args?: WithAuth) => Promise; }; readonly comments: { create: (args: ({ attachments?: Array<{ file_upload_id: string; type?: "file_upload"; }>; display_name?: { type: "integration"; } | { type: "user"; } | { type: "custom"; custom: { name: string; }; }; } & ({ parent: { page_id: import("./api-endpoints").IdRequest; type?: "page_id"; } | { block_id: import("./api-endpoints").IdRequest; type?: "block_id"; }; rich_text: Array; } | { parent: { page_id: import("./api-endpoints").IdRequest; type?: "page_id"; } | { block_id: import("./api-endpoints").IdRequest; type?: "block_id"; }; markdown: string; } | { discussion_id: import("./api-endpoints").IdRequest; rich_text: Array; } | { discussion_id: import("./api-endpoints").IdRequest; markdown: string; })) & { auth?: string; }) => Promise; list: (args: { block_id: import("./api-endpoints").IdRequest; start_cursor?: string | null; page_size?: number; } & { auth?: string; }) => Promise; retrieve: (args: { comment_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; update: (args: import("./api-endpoints").UpdateCommentParameters & { auth?: string; }) => Promise; delete: (args: { comment_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; }; readonly fileUploads: { /** * Create a file upload */ create: (args?: ({ mode?: "single_part" | "multi_part" | "external_url" | undefined; filename?: string | undefined; content_type?: string | undefined; number_of_parts?: number | undefined; external_url?: string | undefined; } & { auth?: string; }) | undefined) => Promise; /** * Retrieve a file upload */ retrieve: (args: WithAuth) => Promise; /** * List file uploads */ list: (args: WithAuth) => Promise; /** * Send a file upload * * Requires a `file_upload_id`, obtained from the `id` of the Create File * Upload API response. * * The `file` parameter contains the raw file contents or Blob/File object * under `file.data`, and an optional `file.filename` string. * * Supply a stringified `part_number` parameter when using file uploads * in multi-part mode. * * This endpoint sends HTTP multipart/form-data instead of JSON parameters. */ send: (args: WithAuth) => Promise; /** * Complete a file upload */ complete: (args: WithAuth) => Promise; }; readonly views: { /** * Create a view */ create: (args: WithAuth) => Promise; /** * Retrieve a view */ retrieve: (args: { view_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; /** * Update a view */ update: (args: WithAuth) => Promise; /** * Delete a view */ delete: (args: { view_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; /** * List views for a database */ list: (args?: ({ database_id?: import("./api-endpoints").IdRequest | undefined; data_source_id?: import("./api-endpoints").IdRequest | undefined; start_cursor?: string | null | undefined; page_size?: number | undefined; } & { auth?: string; }) | undefined) => Promise; queries: { /** * Create a view query */ create: (args: WithAuth) => Promise; /** * Get view query results */ results: (args: { view_id: import("./api-endpoints").IdRequest; query_id: import("./api-endpoints").IdRequest; } & { start_cursor?: string | null; page_size?: number; } & { auth?: string; }) => Promise; /** * Delete a view query */ delete: (args: { view_id: import("./api-endpoints").IdRequest; query_id: import("./api-endpoints").IdRequest; } & { auth?: string; }) => Promise; }; }; /** * Search */ search: (args?: ({ sort?: { timestamp: "last_edited_time"; direction: "ascending" | "descending"; } | { property: "relevance"; } | undefined; query?: string | undefined; start_cursor?: string | null | undefined; page_size?: number | undefined; filter?: { property: "object"; value: "page" | "data_source"; in_trash?: boolean; } | { in_trash: boolean; } | undefined; } & { auth?: string; }) | undefined) => Promise; readonly oauth: { /** * Get token */ token: (args: OauthTokenParameters & { client_id: string; client_secret: string; }) => Promise; /** * Introspect token */ introspect: (args: OauthIntrospectParameters & { client_id: string; client_secret: string; }) => Promise; /** * Revoke token */ revoke: (args: OauthRevokeParameters & { client_id: string; client_secret: string; }) => Promise; }; /** * Logs a warning when the caller passes parameters that are not recognized * by the endpoint definition. This helps catch typos and renamed parameters * (e.g. `archived` vs `in_trash` for `databases.update`) that would * otherwise be silently dropped by `pick()`. */ private warnUnknownParams; /** * Emits a log message to the console. * * @param level The level for this message * @param args Arguments to send to the console */ private log; /** * Blocks a token or client secret inside a browser unless the caller opted * in. Covers both the constructor `auth` and per-request `auth`, since a * page that asks the visitor to type a token usually uses the latter. A * client without a token stays usable, for example behind a proxy that * adds the token on a server. */ private assertTokenAllowedHere; /** * Transforms an API key or access token into a headers object suitable for an HTTP request. * * This method uses the instance's value as the default when the input is undefined. If neither are defined, it returns * an empty object * * @param auth API key or access token * @returns headers key-value object */ private authAsHeaders; } type Method = "get" | "post" | "patch" | "delete"; type QueryParams = Record | URLSearchParams; type WithAuth

= P & { auth?: string; }; export {}; //# sourceMappingURL=Client.d.ts.map