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 UpdateCommentParameters, type UpdateCommentResponse, type DeleteCommentParameters, type DeleteCommentResponse, 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<string, unknown>;
    formDataParams?: Record<string, string | FileParam>;
    headers?: Record<string, string>;
    /**
     * 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<ResponseBody extends object>(args: RequestParameters): Promise<ResponseBody>;
    /**
     * 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<GetBlockParameters>) => Promise<GetBlockResponse>;
        /**
         * Update block
         */
        update: (args: WithAuth<UpdateBlockParameters>) => Promise<UpdateBlockResponse>;
        /**
         * Delete block
         */
        delete: (args: WithAuth<DeleteBlockParameters>) => Promise<DeleteBlockResponse>;
        children: {
            /**
             * Append block children
             */
            append: (args: WithAuth<AppendBlockChildrenParameters>) => Promise<AppendBlockChildrenResponse>;
            /**
             * Retrieve block children
             */
            list: (args: WithAuth<ListBlockChildrenParameters>) => Promise<ListBlockChildrenResponse>;
        };
    };
    readonly databases: {
        /**
         * Retrieve a database
         */
        retrieve: (args: WithAuth<GetDatabaseParameters>) => Promise<GetDatabaseResponse>;
        /**
         * Create a database
         */
        create: (args: WithAuth<CreateDatabaseParameters>) => Promise<CreateDatabaseResponse>;
        /**
         * Update a database
         */
        update: (args: WithAuth<UpdateDatabaseParameters>) => Promise<UpdateDatabaseResponse>;
    };
    readonly dataSources: {
        /**
         * Retrieve a data source
         */
        retrieve: (args: WithAuth<GetDataSourceParameters>) => Promise<GetDataSourceResponse>;
        /**
         * Query a data source
         */
        query: (args: WithAuth<QueryDataSourceParameters>) => Promise<QueryDataSourceResponse>;
        /**
         * Create a data source
         */
        create: (args: WithAuth<CreateDataSourceParameters>) => Promise<CreateDataSourceResponse>;
        /**
         * Update a data source
         */
        update: (args: WithAuth<UpdateDataSourceParameters>) => Promise<UpdateDataSourceResponse>;
        /**
         * List page templates that are available for a data source
         */
        listTemplates: (args: WithAuth<ListDataSourceTemplatesParameters>) => Promise<ListDataSourceTemplatesResponse>;
    };
    readonly pages: {
        /**
         * Create a page
         */
        create: (args: WithAuth<CreatePageParameters>) => Promise<CreatePageResponse>;
        /**
         * Retrieve a page
         */
        retrieve: (args: WithAuth<GetPageParameters>) => Promise<GetPageResponse>;
        /**
         * Update page properties
         */
        update: (args: WithAuth<UpdatePageParameters>) => Promise<UpdatePageResponse>;
        /**
         * Move a page
         */
        move: (args: WithAuth<MovePageParameters>) => Promise<MovePageResponse>;
        /**
         * Retrieve a page as markdown
         */
        retrieveMarkdown: (args: WithAuth<GetPageMarkdownParameters>) => Promise<GetPageMarkdownResponse>;
        /**
         * Update a page's content as markdown
         */
        updateMarkdown: (args: WithAuth<UpdatePageMarkdownParameters>) => Promise<UpdatePageMarkdownResponse>;
        properties: {
            /**
             * Retrieve page property
             */
            retrieve: (args: WithAuth<GetPagePropertyParameters>) => Promise<GetPagePropertyResponse>;
        };
    };
    readonly users: {
        /**
         * Retrieve a user
         */
        retrieve: (args: WithAuth<GetUserParameters>) => Promise<GetUserResponse>;
        /**
         * List all users
         */
        list: (args: WithAuth<ListUsersParameters>) => Promise<ListUsersResponse>;
        /**
         * Get details about bot
         */
        me: (args: WithAuth<GetSelfParameters>) => Promise<GetSelfResponse>;
    };
    readonly customEmojis: {
        /**
         * List custom emojis
         */
        list: (args?: WithAuth<ListCustomEmojisParameters>) => Promise<ListCustomEmojisResponse>;
    };
    readonly comments: {
        /**
         * Create a comment
         */
        create: (args: WithAuth<CreateCommentParameters>) => Promise<CreateCommentResponse>;
        /**
         * List comments
         */
        list: (args: WithAuth<ListCommentsParameters>) => Promise<ListCommentsResponse>;
        /**
         * Retrieve a comment
         */
        retrieve: (args: WithAuth<GetCommentParameters>) => Promise<GetCommentResponse>;
        /**
         * Update a comment
         */
        update: (args: WithAuth<UpdateCommentParameters>) => Promise<UpdateCommentResponse>;
        /**
         * Delete a comment
         */
        delete: (args: WithAuth<DeleteCommentParameters>) => Promise<DeleteCommentResponse>;
    };
    readonly fileUploads: {
        /**
         * Create a file upload
         */
        create: (args: WithAuth<CreateFileUploadParameters>) => Promise<CreateFileUploadResponse>;
        /**
         * Retrieve a file upload
         */
        retrieve: (args: WithAuth<GetFileUploadParameters>) => Promise<GetFileUploadResponse>;
        /**
         * List file uploads
         */
        list: (args: WithAuth<ListFileUploadsParameters>) => Promise<ListFileUploadsResponse>;
        /**
         * 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<SendFileUploadParameters>) => Promise<SendFileUploadResponse>;
        /**
         * Complete a file upload
         */
        complete: (args: WithAuth<CompleteFileUploadParameters>) => Promise<CompleteFileUploadResponse>;
    };
    readonly views: {
        /**
         * Create a view
         */
        create: (args: WithAuth<CreateViewParameters>) => Promise<CreateViewResponse>;
        /**
         * Retrieve a view
         */
        retrieve: (args: WithAuth<GetViewParameters>) => Promise<GetViewResponse>;
        /**
         * Update a view
         */
        update: (args: WithAuth<UpdateViewParameters>) => Promise<UpdateViewResponse>;
        /**
         * Delete a view
         */
        delete: (args: WithAuth<DeleteViewParameters>) => Promise<DeleteViewResponse>;
        /**
         * List views for a database
         */
        list: (args: WithAuth<ListDatabaseViewsParameters>) => Promise<ListDatabaseViewsResponse>;
        queries: {
            /**
             * Create a view query
             */
            create: (args: WithAuth<CreateViewQueryParameters>) => Promise<CreateViewQueryResponse>;
            /**
             * Get view query results
             */
            results: (args: WithAuth<GetViewQueryResultsParameters>) => Promise<GetViewQueryResultsResponse>;
            /**
             * Delete a view query
             */
            delete: (args: WithAuth<DeleteViewQueryParameters>) => Promise<DeleteViewQueryResponse>;
        };
    };
    /**
     * Search
     */
    search: (args: WithAuth<SearchParameters>) => Promise<SearchResponse>;
    readonly oauth: {
        /**
         * Get token
         */
        token: (args: OauthTokenParameters & {
            client_id: string;
            client_secret: string;
        }) => Promise<OauthTokenResponse>;
        /**
         * Introspect token
         */
        introspect: (args: OauthIntrospectParameters & {
            client_id: string;
            client_secret: string;
        }) => Promise<OauthIntrospectResponse>;
        /**
         * Revoke token
         */
        revoke: (args: OauthRevokeParameters & {
            client_id: string;
            client_secret: string;
        }) => Promise<OauthRevokeResponse>;
    };
    /**
     * 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<string, string | number | boolean | string[]> | URLSearchParams;
type WithAuth<P> = P & {
    auth?: string;
};
export {};
//# sourceMappingURL=Client.d.ts.map