import type { Agent } from "node:http"; import { type Logger, LogLevel } from "./logging"; import { type GetBlockParameters, type GetBlockResponse, type UpdateBlockParameters, type UpdateBlockResponse, type DeleteBlockParameters, type DeleteBlockResponse, type AppendBlockChildrenParameters, type AppendBlockChildrenResponse, type ListBlockChildrenParameters, type ListBlockChildrenResponse, type QueryDataSourceParameters, type QueryDataSourceResponse, type CreateDataSourceParameters, type CreateDataSourceResponse, type UpdateDataSourceParameters, type UpdateDataSourceResponse, type GetDataSourceParameters, type GetDataSourceResponse, type CreatePageParameters, type CreatePageResponse, type GetPageParameters, type GetPageResponse, type UpdatePageParameters, type UpdatePageResponse, type MovePageParameters, type MovePageResponse, type GetPageMarkdownParameters, type GetPageMarkdownResponse, type UpdatePageMarkdownParameters, type UpdatePageMarkdownResponse, type GetUserParameters, type GetUserResponse, type ListUsersParameters, type ListUsersResponse, type SearchParameters, type SearchResponse, type GetSelfParameters, type GetSelfResponse, type GetPagePropertyParameters, type GetPagePropertyResponse, type CreateCommentParameters, type CreateCommentResponse, type ListCommentsParameters, type ListCommentsResponse, type GetCommentParameters, type GetCommentResponse, type OauthTokenResponse, type OauthTokenParameters, type OauthIntrospectResponse, type OauthIntrospectParameters, type OauthRevokeResponse, type OauthRevokeParameters, type CreateFileUploadParameters, type CreateFileUploadResponse, type GetFileUploadResponse, type GetFileUploadParameters, type SendFileUploadParameters, type SendFileUploadResponse, type CompleteFileUploadParameters, type CompleteFileUploadResponse, type ListFileUploadsParameters, type ListFileUploadsResponse, GetDatabaseParameters, GetDatabaseResponse, CreateDatabaseResponse, CreateDatabaseParameters, UpdateDatabaseParameters, UpdateDatabaseResponse, ListDataSourceTemplatesResponse, ListDataSourceTemplatesParameters, type ListDatabaseViewsParameters, type ListDatabaseViewsResponse, type CreateViewParameters, type CreateViewResponse, type GetViewParameters, type GetViewResponse, type UpdateViewParameters, type UpdateViewResponse, type DeleteViewParameters, type DeleteViewResponse, type CreateViewQueryParameters, type CreateViewQueryResponse, type GetViewQueryResultsParameters, type GetViewQueryResultsResponse, type DeleteViewQueryParameters, type DeleteViewQueryResponse, type ListCustomEmojisParameters, type ListCustomEmojisResponse } from "./api-endpoints"; 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; }; 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; /** * 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; /** * 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) 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 blocks: { /** * Retrieve block */ retrieve: (args: WithAuth) => Promise; /** * Update block */ update: (args: WithAuth) => Promise; /** * Delete block */ delete: (args: WithAuth) => Promise; children: { /** * Append block children */ append: (args: WithAuth) => Promise; /** * Retrieve block children */ list: (args: WithAuth) => Promise; }; }; readonly databases: { /** * Retrieve a database */ retrieve: (args: WithAuth) => Promise; /** * Create a database */ create: (args: WithAuth) => Promise; /** * Update a database */ update: (args: WithAuth) => Promise; }; readonly dataSources: { /** * Retrieve a data source */ retrieve: (args: WithAuth) => Promise; /** * Query a data source */ query: (args: WithAuth) => Promise; /** * Create a data source */ create: (args: WithAuth) => Promise; /** * Update a data source */ update: (args: WithAuth) => Promise; /** * List page templates that are available for a data source */ listTemplates: (args: WithAuth) => Promise; }; readonly pages: { /** * Create a page */ create: (args: WithAuth) => Promise; /** * Retrieve a page */ retrieve: (args: WithAuth) => Promise; /** * Update page properties */ update: (args: WithAuth) => Promise; /** * Move a page */ move: (args: WithAuth) => Promise; /** * Retrieve a page as markdown */ retrieveMarkdown: (args: WithAuth) => Promise; /** * Update a page's content as markdown */ updateMarkdown: (args: WithAuth) => Promise; properties: { /** * Retrieve page property */ retrieve: (args: WithAuth) => Promise; }; }; readonly users: { /** * Retrieve a user */ retrieve: (args: WithAuth) => Promise; /** * List all users */ list: (args: WithAuth) => Promise; /** * Get details about bot */ me: (args: WithAuth) => Promise; }; readonly customEmojis: { /** * List custom emojis */ list: (args?: WithAuth) => Promise; }; readonly comments: { /** * Create a comment */ create: (args: WithAuth) => Promise; /** * List comments */ list: (args: WithAuth) => Promise; /** * Retrieve a comment */ retrieve: (args: WithAuth) => Promise; }; readonly fileUploads: { /** * Create a file upload */ create: (args: WithAuth) => 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: WithAuth) => Promise; /** * Update a view */ update: (args: WithAuth) => Promise; /** * Delete a view */ delete: (args: WithAuth) => Promise; /** * List views for a database */ list: (args: WithAuth) => Promise; queries: { /** * Create a view query */ create: (args: WithAuth) => Promise; /** * Get view query results */ results: (args: WithAuth) => Promise; /** * Delete a view query */ delete: (args: WithAuth) => Promise; }; }; /** * Search */ search: (args: WithAuth) => 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; /** * 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