File size: 5,832 Bytes
7d9f678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/// <reference types="node" />
import type { Agent } from "http";
import { Logger, LogLevel } from "./logging";
import { GetBlockParameters, GetBlockResponse, UpdateBlockParameters, UpdateBlockResponse, DeleteBlockParameters, DeleteBlockResponse, AppendBlockChildrenParameters, AppendBlockChildrenResponse, ListBlockChildrenParameters, ListBlockChildrenResponse, ListDatabasesParameters, ListDatabasesResponse, GetDatabaseParameters, GetDatabaseResponse, QueryDatabaseParameters, QueryDatabaseResponse, CreateDatabaseParameters, CreateDatabaseResponse, UpdateDatabaseParameters, UpdateDatabaseResponse, CreatePageParameters, CreatePageResponse, GetPageParameters, GetPageResponse, UpdatePageParameters, UpdatePageResponse, GetUserParameters, GetUserResponse, ListUsersParameters, ListUsersResponse, SearchParameters, SearchResponse, GetSelfParameters, GetSelfResponse, GetPagePropertyParameters, GetPagePropertyResponse, CreateCommentParameters, CreateCommentResponse, ListCommentsParameters, ListCommentsResponse } from "./api-endpoints";
import { SupportedFetch } from "./fetch-types";
export interface ClientOptions {
    auth?: string;
    timeoutMs?: number;
    baseUrl?: string;
    logLevel?: LogLevel;
    logger?: Logger;
    notionVersion?: string;
    fetch?: SupportedFetch;
    /** Silently ignored in the browser */
    agent?: Agent;
}
export interface RequestParameters {
    path: string;
    method: Method;
    query?: QueryParams;
    body?: Record<string, unknown>;
    auth?: string;
}
export default class Client {
    #private;
    static readonly defaultNotionVersion = "2022-06-28";
    constructor(options?: ClientOptions);
    /**
     * Sends a request.
     *
     * @param path
     * @param method
     * @param query
     * @param body
     * @returns
     */
    request<ResponseBody>({ path, method, query, body, auth, }: RequestParameters): Promise<ResponseBody>;
    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: {
        /**
         * List databases
         *
         * @deprecated Please use `search`
         */
        list: (args: WithAuth<ListDatabasesParameters>) => Promise<ListDatabasesResponse>;
        /**
         * Retrieve a database
         */
        retrieve: (args: WithAuth<GetDatabaseParameters>) => Promise<GetDatabaseResponse>;
        /**
         * Query a database
         */
        query: (args: WithAuth<QueryDatabaseParameters>) => Promise<QueryDatabaseResponse>;
        /**
         * Create a database
         */
        create: (args: WithAuth<CreateDatabaseParameters>) => Promise<CreateDatabaseResponse>;
        /**
         * Update a database
         */
        update: (args: WithAuth<UpdateDatabaseParameters>) => Promise<UpdateDatabaseResponse>;
    };
    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>;
        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 comments: {
        /**
         * Create a comment
         */
        create: (args: WithAuth<CreateCommentParameters>) => Promise<CreateCommentResponse>;
        /**
         * List comments
         */
        list: (args: WithAuth<ListCommentsParameters>) => Promise<ListCommentsResponse>;
    };
    /**
     * Search
     */
    search: (args: WithAuth<SearchParameters>) => Promise<SearchResponse>;
    /**
     * 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 | string[]> | URLSearchParams;
type WithAuth<P> = P & {
    auth?: string;
};
export {};
//# sourceMappingURL=Client.d.ts.map