@notionhq/client 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/package.json +1 -1
- package/build/src/Client.d.ts +41 -8
- package/build/src/Client.d.ts.map +1 -1
- package/build/src/Client.js +91 -9
- package/build/src/Client.js.map +1 -1
- package/build/src/api-endpoints.d.ts +512 -3424
- package/build/src/api-endpoints.d.ts.map +1 -1
- package/build/src/api-endpoints.js +43 -1
- package/build/src/api-endpoints.js.map +1 -1
- package/build/src/fetch-types.d.ts +3 -1
- package/build/src/fetch-types.d.ts.map +1 -1
- package/build/src/fetch-types.js.map +1 -1
- package/build/src/index.d.ts +1 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js.map +1 -1
- package/package.json +1 -1
package/build/package.json
CHANGED
package/build/src/Client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import type { Agent } from "node:http";
|
|
4
5
|
import { type Logger, LogLevel } from "./logging";
|
|
5
|
-
import { type GetBlockParameters, type GetBlockResponse, type UpdateBlockParameters, type UpdateBlockResponse, type DeleteBlockParameters, type DeleteBlockResponse, type AppendBlockChildrenParameters, type AppendBlockChildrenResponse, type ListBlockChildrenParameters, type ListBlockChildrenResponse, type ListDatabasesParameters, type ListDatabasesResponse, type GetDatabaseParameters, type GetDatabaseResponse, type QueryDatabaseParameters, type QueryDatabaseResponse, type CreateDatabaseParameters, type CreateDatabaseResponse, type UpdateDatabaseParameters, type UpdateDatabaseResponse, type CreatePageParameters, type CreatePageResponse, type GetPageParameters, type GetPageResponse, type UpdatePageParameters, type UpdatePageResponse, 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 OauthTokenResponse, type OauthTokenParameters, type OauthIntrospectResponse, type OauthIntrospectParameters, type OauthRevokeResponse, type OauthRevokeParameters } from "./api-endpoints";
|
|
6
|
+
import { type GetBlockParameters, type GetBlockResponse, type UpdateBlockParameters, type UpdateBlockResponse, type DeleteBlockParameters, type DeleteBlockResponse, type AppendBlockChildrenParameters, type AppendBlockChildrenResponse, type ListBlockChildrenParameters, type ListBlockChildrenResponse, type ListDatabasesParameters, type ListDatabasesResponse, type GetDatabaseParameters, type GetDatabaseResponse, type QueryDatabaseParameters, type QueryDatabaseResponse, type CreateDatabaseParameters, type CreateDatabaseResponse, type UpdateDatabaseParameters, type UpdateDatabaseResponse, type CreatePageParameters, type CreatePageResponse, type GetPageParameters, type GetPageResponse, type UpdatePageParameters, type UpdatePageResponse, 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 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 } from "./api-endpoints";
|
|
6
7
|
import type { SupportedFetch } from "./fetch-types";
|
|
7
8
|
export interface ClientOptions {
|
|
8
9
|
auth?: string;
|
|
@@ -15,11 +16,16 @@ export interface ClientOptions {
|
|
|
15
16
|
/** Silently ignored in the browser */
|
|
16
17
|
agent?: Agent;
|
|
17
18
|
}
|
|
19
|
+
type FileParam = {
|
|
20
|
+
filename?: string;
|
|
21
|
+
data: string | Blob;
|
|
22
|
+
};
|
|
18
23
|
export interface RequestParameters {
|
|
19
24
|
path: string;
|
|
20
25
|
method: Method;
|
|
21
26
|
query?: QueryParams;
|
|
22
27
|
body?: Record<string, unknown>;
|
|
28
|
+
formDataParams?: Record<string, string | FileParam>;
|
|
23
29
|
/**
|
|
24
30
|
* To authenticate using public API token, `auth` should be passed as a
|
|
25
31
|
* string. If you are trying to complete OAuth, then `auth` should be an object
|
|
@@ -36,14 +42,8 @@ export default class Client {
|
|
|
36
42
|
constructor(options?: ClientOptions);
|
|
37
43
|
/**
|
|
38
44
|
* Sends a request.
|
|
39
|
-
*
|
|
40
|
-
* @param path
|
|
41
|
-
* @param method
|
|
42
|
-
* @param query
|
|
43
|
-
* @param body
|
|
44
|
-
* @returns
|
|
45
45
|
*/
|
|
46
|
-
request<ResponseBody>(
|
|
46
|
+
request<ResponseBody>(args: RequestParameters): Promise<ResponseBody>;
|
|
47
47
|
readonly blocks: {
|
|
48
48
|
/**
|
|
49
49
|
* Retrieve block
|
|
@@ -136,6 +136,39 @@ export default class Client {
|
|
|
136
136
|
*/
|
|
137
137
|
list: (args: WithAuth<ListCommentsParameters>) => Promise<ListCommentsResponse>;
|
|
138
138
|
};
|
|
139
|
+
readonly fileUploads: {
|
|
140
|
+
/**
|
|
141
|
+
* Create a file upload
|
|
142
|
+
*/
|
|
143
|
+
create: (args: WithAuth<CreateFileUploadParameters>) => Promise<CreateFileUploadResponse>;
|
|
144
|
+
/**
|
|
145
|
+
* Retrieve a file upload
|
|
146
|
+
*/
|
|
147
|
+
retrieve: (args: WithAuth<GetFileUploadParameters>) => Promise<GetFileUploadResponse>;
|
|
148
|
+
/**
|
|
149
|
+
* List file uploads
|
|
150
|
+
*/
|
|
151
|
+
list: (args: WithAuth<ListFileUploadsParameters>) => Promise<ListFileUploadsResponse>;
|
|
152
|
+
/**
|
|
153
|
+
* Send a file upload
|
|
154
|
+
*
|
|
155
|
+
* Requires a `file_upload_id`, obtained from the `id` of the Create File
|
|
156
|
+
* Upload API response.
|
|
157
|
+
*
|
|
158
|
+
* The `file` parameter contains the raw file contents or Blob/File object
|
|
159
|
+
* under `file.data`, and an optional `file.filename` string.
|
|
160
|
+
*
|
|
161
|
+
* Supply a stringified `part_number` parameter when using file uploads
|
|
162
|
+
* in multi-part mode.
|
|
163
|
+
*
|
|
164
|
+
* This endpoint sends HTTP multipart/form-data instead of JSON parameters.
|
|
165
|
+
*/
|
|
166
|
+
send: (args: WithAuth<SendFileUploadParameters>) => Promise<SendFileUploadResponse>;
|
|
167
|
+
/**
|
|
168
|
+
* Complete a file upload
|
|
169
|
+
*/
|
|
170
|
+
complete: (args: WithAuth<CompleteFileUploadParameters>) => Promise<CompleteFileUploadResponse>;
|
|
171
|
+
};
|
|
139
172
|
/**
|
|
140
173
|
* Search
|
|
141
174
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EACL,KAAK,MAAM,EACX,QAAQ,EAGT,MAAM,WAAW,CAAA;AAQlB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAErB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAExB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAExB,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAEhC,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAE9B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAE1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAExB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAE1B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE3B,KA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B,CAAC;MAQvC;IAED;;OAEG;IACI,MAAM,SACL,SAAS,gBAAgB,CAAC,KAC/B,QAAQ,cAAc,CAAC,CAQzB;IAED,SAAgB,KAAK;QACnB;;WAEG;sBAEK,oBAAoB,GAAG;YAC3B,SAAS,EAAE,MAAM,CAAA;YACjB,aAAa,EAAE,MAAM,CAAA;SACtB,KACA,QAAQ,kBAAkB,CAAC;QAY9B;;WAEG;2BAEK,yBAAyB,GAAG;YAChC,SAAS,EAAE,MAAM,CAAA;YACjB,aAAa,EAAE,MAAM,CAAA;SACtB,KACA,QAAQ,uBAAuB,CAAC;QAYnC;;WAEG;uBAEK,qBAAqB,GAAG;YAC5B,SAAS,EAAE,MAAM,CAAA;YACjB,aAAa,EAAE,MAAM,CAAA;SACtB,KACA,QAAQ,mBAAmB,CAAC;MAYhC;IAED;;;;;OAKG;IACH,OAAO,CAAC,GAAG;IAUX;;;;;;;;OAQG;IACH,OAAO,CAAC,aAAa;CAQtB;AAKD,KAAK,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AACjD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,eAAe,CAAA;AAE/E,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
package/build/src/Client.js
CHANGED
|
@@ -276,6 +276,76 @@ class Client {
|
|
|
276
276
|
});
|
|
277
277
|
},
|
|
278
278
|
};
|
|
279
|
+
this.fileUploads = {
|
|
280
|
+
/**
|
|
281
|
+
* Create a file upload
|
|
282
|
+
*/
|
|
283
|
+
create: (args) => {
|
|
284
|
+
return this.request({
|
|
285
|
+
path: api_endpoints_1.createFileUpload.path(),
|
|
286
|
+
method: api_endpoints_1.createFileUpload.method,
|
|
287
|
+
query: (0, utils_1.pick)(args, api_endpoints_1.createFileUpload.queryParams),
|
|
288
|
+
body: (0, utils_1.pick)(args, api_endpoints_1.createFileUpload.bodyParams),
|
|
289
|
+
auth: args === null || args === void 0 ? void 0 : args.auth,
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
/**
|
|
293
|
+
* Retrieve a file upload
|
|
294
|
+
*/
|
|
295
|
+
retrieve: (args) => {
|
|
296
|
+
return this.request({
|
|
297
|
+
path: api_endpoints_1.getFileUpload.path(args),
|
|
298
|
+
method: api_endpoints_1.getFileUpload.method,
|
|
299
|
+
query: (0, utils_1.pick)(args, api_endpoints_1.getFileUpload.queryParams),
|
|
300
|
+
auth: args === null || args === void 0 ? void 0 : args.auth,
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
/**
|
|
304
|
+
* List file uploads
|
|
305
|
+
*/
|
|
306
|
+
list: (args) => {
|
|
307
|
+
return this.request({
|
|
308
|
+
path: api_endpoints_1.listFileUploads.path(),
|
|
309
|
+
method: api_endpoints_1.listFileUploads.method,
|
|
310
|
+
query: (0, utils_1.pick)(args, api_endpoints_1.listFileUploads.queryParams),
|
|
311
|
+
auth: args === null || args === void 0 ? void 0 : args.auth,
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
/**
|
|
315
|
+
* Send a file upload
|
|
316
|
+
*
|
|
317
|
+
* Requires a `file_upload_id`, obtained from the `id` of the Create File
|
|
318
|
+
* Upload API response.
|
|
319
|
+
*
|
|
320
|
+
* The `file` parameter contains the raw file contents or Blob/File object
|
|
321
|
+
* under `file.data`, and an optional `file.filename` string.
|
|
322
|
+
*
|
|
323
|
+
* Supply a stringified `part_number` parameter when using file uploads
|
|
324
|
+
* in multi-part mode.
|
|
325
|
+
*
|
|
326
|
+
* This endpoint sends HTTP multipart/form-data instead of JSON parameters.
|
|
327
|
+
*/
|
|
328
|
+
send: (args) => {
|
|
329
|
+
return this.request({
|
|
330
|
+
path: api_endpoints_1.sendFileUpload.path(args),
|
|
331
|
+
method: api_endpoints_1.sendFileUpload.method,
|
|
332
|
+
query: (0, utils_1.pick)(args, api_endpoints_1.sendFileUpload.queryParams),
|
|
333
|
+
formDataParams: (0, utils_1.pick)(args, api_endpoints_1.sendFileUpload.formDataParams),
|
|
334
|
+
auth: args === null || args === void 0 ? void 0 : args.auth,
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
/**
|
|
338
|
+
* Complete a file upload
|
|
339
|
+
*/
|
|
340
|
+
complete: (args) => {
|
|
341
|
+
return this.request({
|
|
342
|
+
path: api_endpoints_1.completeFileUpload.path(args),
|
|
343
|
+
method: api_endpoints_1.completeFileUpload.method,
|
|
344
|
+
query: (0, utils_1.pick)(args, api_endpoints_1.completeFileUpload.queryParams),
|
|
345
|
+
auth: args === null || args === void 0 ? void 0 : args.auth,
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
};
|
|
279
349
|
/**
|
|
280
350
|
* Search
|
|
281
351
|
*/
|
|
@@ -347,14 +417,9 @@ class Client {
|
|
|
347
417
|
}
|
|
348
418
|
/**
|
|
349
419
|
* Sends a request.
|
|
350
|
-
*
|
|
351
|
-
* @param path
|
|
352
|
-
* @param method
|
|
353
|
-
* @param query
|
|
354
|
-
* @param body
|
|
355
|
-
* @returns
|
|
356
420
|
*/
|
|
357
|
-
async request(
|
|
421
|
+
async request(args) {
|
|
422
|
+
const { path, method, query, body, formDataParams, auth } = args;
|
|
358
423
|
this.log(logging_1.LogLevel.INFO, "request start", { method, path });
|
|
359
424
|
// If the body is empty, don't send the body in the HTTP request
|
|
360
425
|
const bodyAsJsonString = !body || Object.entries(body).length === 0
|
|
@@ -365,7 +430,9 @@ class Client {
|
|
|
365
430
|
for (const [key, value] of Object.entries(query)) {
|
|
366
431
|
if (value !== undefined) {
|
|
367
432
|
if (Array.isArray(value)) {
|
|
368
|
-
|
|
433
|
+
for (const val of value) {
|
|
434
|
+
url.searchParams.append(key, decodeURIComponent(val));
|
|
435
|
+
}
|
|
369
436
|
}
|
|
370
437
|
else {
|
|
371
438
|
url.searchParams.append(key, String(value));
|
|
@@ -395,11 +462,26 @@ class Client {
|
|
|
395
462
|
if (bodyAsJsonString !== undefined) {
|
|
396
463
|
headers["content-type"] = "application/json";
|
|
397
464
|
}
|
|
465
|
+
let formData;
|
|
466
|
+
if (formDataParams) {
|
|
467
|
+
delete headers["content-type"];
|
|
468
|
+
formData = new FormData();
|
|
469
|
+
for (const [key, value] of Object.entries(formDataParams)) {
|
|
470
|
+
if (typeof value === "string") {
|
|
471
|
+
formData.append(key, value);
|
|
472
|
+
}
|
|
473
|
+
else if (typeof value === "object") {
|
|
474
|
+
formData.append(key, typeof value.data === "object"
|
|
475
|
+
? value.data
|
|
476
|
+
: new Blob([value.data]), value.filename);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
398
480
|
try {
|
|
399
481
|
const response = await errors_1.RequestTimeoutError.rejectAfterTimeout(__classPrivateFieldGet(this, _Client_fetch, "f").call(this, url.toString(), {
|
|
400
482
|
method: method.toUpperCase(),
|
|
401
483
|
headers,
|
|
402
|
-
body: bodyAsJsonString,
|
|
484
|
+
body: bodyAsJsonString !== null && bodyAsJsonString !== void 0 ? bodyAsJsonString : formData,
|
|
403
485
|
agent: __classPrivateFieldGet(this, _Client_agent, "f"),
|
|
404
486
|
}), __classPrivateFieldGet(this, _Client_timeoutMs, "f"));
|
|
405
487
|
const responseText = await response.text();
|
package/build/src/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,uCAKkB;AAClB,qCAKiB;AACjB,mCAA8B;AAC9B,mDAsEwB;AACxB,kDAGwB;AAiCxB,MAAqB,MAAM;IAazB,YAAmB,OAAuB;;QAZ1C,+BAAc;QACd,mCAAmB;QACnB,iCAAe;QACf,oCAAkB;QAClB,oCAAkB;QAClB,wCAAsB;QACtB,gCAAsB;QACtB,gCAAyB;QACzB,oCAAkB;QAwHlB;;WAE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import {\n type Logger,\n LogLevel,\n logLevelSeverity,\n makeConsoleLogger,\n} from \"./logging\"\nimport {\n buildRequestError,\n isHTTPResponseError,\n isNotionClientError,\n RequestTimeoutError,\n} from \"./errors\"\nimport { pick } from \"./utils\"\nimport {\n type GetBlockParameters,\n type GetBlockResponse,\n getBlock,\n type UpdateBlockParameters,\n type UpdateBlockResponse,\n updateBlock,\n type DeleteBlockParameters,\n type DeleteBlockResponse,\n deleteBlock,\n type AppendBlockChildrenParameters,\n type AppendBlockChildrenResponse,\n appendBlockChildren,\n type ListBlockChildrenParameters,\n type ListBlockChildrenResponse,\n listBlockChildren,\n type ListDatabasesParameters,\n type ListDatabasesResponse,\n listDatabases,\n type GetDatabaseParameters,\n type GetDatabaseResponse,\n getDatabase,\n type QueryDatabaseParameters,\n type QueryDatabaseResponse,\n queryDatabase,\n type CreateDatabaseParameters,\n type CreateDatabaseResponse,\n createDatabase,\n type UpdateDatabaseParameters,\n type UpdateDatabaseResponse,\n updateDatabase,\n type CreatePageParameters,\n type CreatePageResponse,\n createPage,\n type GetPageParameters,\n type GetPageResponse,\n getPage,\n type UpdatePageParameters,\n type UpdatePageResponse,\n updatePage,\n type GetUserParameters,\n type GetUserResponse,\n getUser,\n type ListUsersParameters,\n type ListUsersResponse,\n listUsers,\n type SearchParameters,\n type SearchResponse,\n search,\n type GetSelfParameters,\n type GetSelfResponse,\n getSelf,\n type GetPagePropertyParameters,\n type GetPagePropertyResponse,\n getPageProperty,\n type CreateCommentParameters,\n type CreateCommentResponse,\n createComment,\n type ListCommentsParameters,\n type ListCommentsResponse,\n listComments,\n type OauthTokenResponse,\n type OauthTokenParameters,\n oauthToken,\n type OauthIntrospectResponse,\n type OauthIntrospectParameters,\n oauthIntrospect,\n type OauthRevokeResponse,\n type OauthRevokeParameters,\n oauthRevoke,\n} from \"./api-endpoints\"\nimport {\n version as PACKAGE_VERSION,\n name as PACKAGE_NAME,\n} from \"../package.json\"\nimport type { SupportedFetch } from \"./fetch-types\"\n\nexport interface ClientOptions {\n auth?: string\n timeoutMs?: number\n baseUrl?: string\n logLevel?: LogLevel\n logger?: Logger\n notionVersion?: string\n fetch?: SupportedFetch\n /** Silently ignored in the browser */\n agent?: Agent\n}\n\nexport interface RequestParameters {\n path: string\n method: Method\n query?: QueryParams\n body?: Record<string, unknown>\n /**\n * To authenticate using public API token, `auth` should be passed as a\n * string. If you are trying to complete OAuth, then `auth` should be an object\n * containing your integration's client ID and secret.\n */\n auth?:\n | string\n | {\n client_id: string\n client_secret: string\n }\n}\n\nexport default class Client {\n #auth?: string\n #logLevel: LogLevel\n #logger: Logger\n #prefixUrl: string\n #timeoutMs: number\n #notionVersion: string\n #fetch: SupportedFetch\n #agent: Agent | undefined\n #userAgent: string\n\n static readonly defaultNotionVersion = \"2022-06-28\"\n\n public constructor(options?: ClientOptions) {\n this.#auth = options?.auth\n this.#logLevel = options?.logLevel ?? LogLevel.WARN\n this.#logger = options?.logger ?? makeConsoleLogger(PACKAGE_NAME)\n this.#prefixUrl = `${options?.baseUrl ?? \"https://api.notion.com\"}/v1/`\n this.#timeoutMs = options?.timeoutMs ?? 60_000\n this.#notionVersion = options?.notionVersion ?? Client.defaultNotionVersion\n this.#fetch = options?.fetch ?? fetch\n this.#agent = options?.agent\n this.#userAgent = `notionhq-client/${PACKAGE_VERSION}`\n }\n\n /**\n * Sends a request.\n *\n * @param path\n * @param method\n * @param query\n * @param body\n * @returns\n */\n public async request<ResponseBody>({\n path,\n method,\n query,\n body,\n auth,\n }: RequestParameters): Promise<ResponseBody> {\n this.log(LogLevel.INFO, \"request start\", { method, path })\n\n // If the body is empty, don't send the body in the HTTP request\n const bodyAsJsonString =\n !body || Object.entries(body).length === 0\n ? undefined\n : JSON.stringify(body)\n\n const url = new URL(`${this.#prefixUrl}${path}`)\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n if (Array.isArray(value)) {\n value.forEach(val =>\n url.searchParams.append(key, decodeURIComponent(val))\n )\n } else {\n url.searchParams.append(key, String(value))\n }\n }\n }\n }\n\n // Allow both client ID / client secret based auth as well as token based auth.\n let authorizationHeader: Record<string, string>\n if (typeof auth === \"object\") {\n // Client ID and secret based auth is **ONLY** supported when using the\n // `/oauth/token` endpoint. If this is the case, handle formatting the\n // authorization header as required by `Basic` auth.\n const unencodedCredential = `${auth.client_id}:${auth.client_secret}`\n const encodedCredential =\n Buffer.from(unencodedCredential).toString(\"base64\")\n authorizationHeader = { authorization: `Basic ${encodedCredential}` }\n } else {\n // Otherwise format authorization header as `Bearer` token auth.\n authorizationHeader = this.authAsHeaders(auth)\n }\n\n const headers: Record<string, string> = {\n ...authorizationHeader,\n \"Notion-Version\": this.#notionVersion,\n \"user-agent\": this.#userAgent,\n }\n\n if (bodyAsJsonString !== undefined) {\n headers[\"content-type\"] = \"application/json\"\n }\n try {\n const response = await RequestTimeoutError.rejectAfterTimeout(\n this.#fetch(url.toString(), {\n method: method.toUpperCase(),\n headers,\n body: bodyAsJsonString,\n agent: this.#agent,\n }),\n this.#timeoutMs\n )\n\n const responseText = await response.text()\n if (!response.ok) {\n throw buildRequestError(response, responseText)\n }\n\n const responseJson: ResponseBody = JSON.parse(responseText)\n this.log(LogLevel.INFO, \"request success\", { method, path })\n return responseJson\n } catch (error: unknown) {\n if (!isNotionClientError(error)) {\n throw error\n }\n\n // Log the error if it's one of our known error types\n this.log(LogLevel.WARN, \"request fail\", {\n code: error.code,\n message: error.message,\n })\n\n if (isHTTPResponseError(error)) {\n // The response body may contain sensitive information so it is logged separately at the DEBUG level\n this.log(LogLevel.DEBUG, \"failed response body\", {\n body: error.body,\n })\n }\n\n throw error\n }\n }\n\n /*\n * Notion API endpoints\n */\n\n public readonly blocks = {\n /**\n * Retrieve block\n */\n retrieve: (\n args: WithAuth<GetBlockParameters>\n ): Promise<GetBlockResponse> => {\n return this.request<GetBlockResponse>({\n path: getBlock.path(args),\n method: getBlock.method,\n query: pick(args, getBlock.queryParams),\n body: pick(args, getBlock.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Update block\n */\n update: (\n args: WithAuth<UpdateBlockParameters>\n ): Promise<UpdateBlockResponse> => {\n return this.request<UpdateBlockResponse>({\n path: updateBlock.path(args),\n method: updateBlock.method,\n query: pick(args, updateBlock.queryParams),\n body: pick(args, updateBlock.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Delete block\n */\n delete: (\n args: WithAuth<DeleteBlockParameters>\n ): Promise<DeleteBlockResponse> => {\n return this.request<DeleteBlockResponse>({\n path: deleteBlock.path(args),\n method: deleteBlock.method,\n query: pick(args, deleteBlock.queryParams),\n body: pick(args, deleteBlock.bodyParams),\n auth: args?.auth,\n })\n },\n children: {\n /**\n * Append block children\n */\n append: (\n args: WithAuth<AppendBlockChildrenParameters>\n ): Promise<AppendBlockChildrenResponse> => {\n return this.request<AppendBlockChildrenResponse>({\n path: appendBlockChildren.path(args),\n method: appendBlockChildren.method,\n query: pick(args, appendBlockChildren.queryParams),\n body: pick(args, appendBlockChildren.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve block children\n */\n list: (\n args: WithAuth<ListBlockChildrenParameters>\n ): Promise<ListBlockChildrenResponse> => {\n return this.request<ListBlockChildrenResponse>({\n path: listBlockChildren.path(args),\n method: listBlockChildren.method,\n query: pick(args, listBlockChildren.queryParams),\n body: pick(args, listBlockChildren.bodyParams),\n auth: args?.auth,\n })\n },\n },\n }\n\n public readonly databases = {\n /**\n * List databases\n *\n * @deprecated Please use `search`\n */\n list: (\n args: WithAuth<ListDatabasesParameters>\n ): Promise<ListDatabasesResponse> => {\n return this.request<ListDatabasesResponse>({\n path: listDatabases.path(),\n method: listDatabases.method,\n query: pick(args, listDatabases.queryParams),\n body: pick(args, listDatabases.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve a database\n */\n retrieve: (\n args: WithAuth<GetDatabaseParameters>\n ): Promise<GetDatabaseResponse> => {\n return this.request<GetDatabaseResponse>({\n path: getDatabase.path(args),\n method: getDatabase.method,\n query: pick(args, getDatabase.queryParams),\n body: pick(args, getDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Query a database\n */\n query: (\n args: WithAuth<QueryDatabaseParameters>\n ): Promise<QueryDatabaseResponse> => {\n return this.request<QueryDatabaseResponse>({\n path: queryDatabase.path(args),\n method: queryDatabase.method,\n query: pick(args, queryDatabase.queryParams),\n body: pick(args, queryDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Create a database\n */\n create: (\n args: WithAuth<CreateDatabaseParameters>\n ): Promise<CreateDatabaseResponse> => {\n return this.request<CreateDatabaseResponse>({\n path: createDatabase.path(),\n method: createDatabase.method,\n query: pick(args, createDatabase.queryParams),\n body: pick(args, createDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Update a database\n */\n update: (\n args: WithAuth<UpdateDatabaseParameters>\n ): Promise<UpdateDatabaseResponse> => {\n return this.request<UpdateDatabaseResponse>({\n path: updateDatabase.path(args),\n method: updateDatabase.method,\n query: pick(args, updateDatabase.queryParams),\n body: pick(args, updateDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n }\n\n public readonly pages = {\n /**\n * Create a page\n */\n create: (\n args: WithAuth<CreatePageParameters>\n ): Promise<CreatePageResponse> => {\n return this.request<CreatePageResponse>({\n path: createPage.path(),\n method: createPage.method,\n query: pick(args, createPage.queryParams),\n body: pick(args, createPage.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve a page\n */\n retrieve: (args: WithAuth<GetPageParameters>): Promise<GetPageResponse> => {\n return this.request<GetPageResponse>({\n path: getPage.path(args),\n method: getPage.method,\n query: pick(args, getPage.queryParams),\n body: pick(args, getPage.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Update page properties\n */\n update: (\n args: WithAuth<UpdatePageParameters>\n ): Promise<UpdatePageResponse> => {\n return this.request<UpdatePageResponse>({\n path: updatePage.path(args),\n method: updatePage.method,\n query: pick(args, updatePage.queryParams),\n body: pick(args, updatePage.bodyParams),\n auth: args?.auth,\n })\n },\n properties: {\n /**\n * Retrieve page property\n */\n retrieve: (\n args: WithAuth<GetPagePropertyParameters>\n ): Promise<GetPagePropertyResponse> => {\n return this.request<GetPagePropertyResponse>({\n path: getPageProperty.path(args),\n method: getPageProperty.method,\n query: pick(args, getPageProperty.queryParams),\n body: pick(args, getPageProperty.bodyParams),\n auth: args?.auth,\n })\n },\n },\n }\n\n public readonly users = {\n /**\n * Retrieve a user\n */\n retrieve: (args: WithAuth<GetUserParameters>): Promise<GetUserResponse> => {\n return this.request<GetUserResponse>({\n path: getUser.path(args),\n method: getUser.method,\n query: pick(args, getUser.queryParams),\n body: pick(args, getUser.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * List all users\n */\n list: (args: WithAuth<ListUsersParameters>): Promise<ListUsersResponse> => {\n return this.request<ListUsersResponse>({\n path: listUsers.path(),\n method: listUsers.method,\n query: pick(args, listUsers.queryParams),\n body: pick(args, listUsers.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Get details about bot\n */\n me: (args: WithAuth<GetSelfParameters>): Promise<GetSelfResponse> => {\n return this.request<GetSelfResponse>({\n path: getSelf.path(),\n method: getSelf.method,\n query: pick(args, getSelf.queryParams),\n body: pick(args, getSelf.bodyParams),\n auth: args?.auth,\n })\n },\n }\n\n public readonly comments = {\n /**\n * Create a comment\n */\n create: (\n args: WithAuth<CreateCommentParameters>\n ): Promise<CreateCommentResponse> => {\n return this.request<CreateCommentResponse>({\n path: createComment.path(),\n method: createComment.method,\n query: pick(args, createComment.queryParams),\n body: pick(args, createComment.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * List comments\n */\n list: (\n args: WithAuth<ListCommentsParameters>\n ): Promise<ListCommentsResponse> => {\n return this.request<ListCommentsResponse>({\n path: listComments.path(),\n method: listComments.method,\n query: pick(args, listComments.queryParams),\n body: pick(args, listComments.bodyParams),\n auth: args?.auth,\n })\n },\n }\n\n /**\n * Search\n */\n public search = (\n args: WithAuth<SearchParameters>\n ): Promise<SearchResponse> => {\n return this.request<SearchResponse>({\n path: search.path(),\n method: search.method,\n query: pick(args, search.queryParams),\n body: pick(args, search.bodyParams),\n auth: args?.auth,\n })\n }\n\n public readonly oauth = {\n /**\n * Get token\n */\n token: (\n args: OauthTokenParameters & {\n client_id: string\n client_secret: string\n }\n ): Promise<OauthTokenResponse> => {\n return this.request<OauthTokenResponse>({\n path: oauthToken.path(),\n method: oauthToken.method,\n query: pick(args, oauthToken.queryParams),\n body: pick(args, oauthToken.bodyParams),\n auth: {\n client_id: args.client_id,\n client_secret: args.client_secret,\n },\n })\n },\n /**\n * Introspect token\n */\n introspect: (\n args: OauthIntrospectParameters & {\n client_id: string\n client_secret: string\n }\n ): Promise<OauthIntrospectResponse> => {\n return this.request<OauthIntrospectResponse>({\n path: oauthIntrospect.path(),\n method: oauthIntrospect.method,\n query: pick(args, oauthIntrospect.queryParams),\n body: pick(args, oauthIntrospect.bodyParams),\n auth: {\n client_id: args.client_id,\n client_secret: args.client_secret,\n },\n })\n },\n /**\n * Revoke token\n */\n revoke: (\n args: OauthRevokeParameters & {\n client_id: string\n client_secret: string\n }\n ): Promise<OauthRevokeResponse> => {\n return this.request<OauthRevokeResponse>({\n path: oauthRevoke.path(),\n method: oauthRevoke.method,\n query: pick(args, oauthRevoke.queryParams),\n body: pick(args, oauthRevoke.bodyParams),\n auth: {\n client_id: args.client_id,\n client_secret: args.client_secret,\n },\n })\n },\n }\n\n /**\n * Emits a log message to the console.\n *\n * @param level The level for this message\n * @param args Arguments to send to the console\n */\n private log(\n level: LogLevel,\n message: string,\n extraInfo: Record<string, unknown>\n ) {\n if (logLevelSeverity(level) >= logLevelSeverity(this.#logLevel)) {\n this.#logger(level, message, extraInfo)\n }\n }\n\n /**\n * Transforms an API key or access token into a headers object suitable for an HTTP request.\n *\n * This method uses the instance's value as the default when the input is undefined. If neither are defined, it returns\n * an empty object\n *\n * @param auth API key or access token\n * @returns headers key-value object\n */\n private authAsHeaders(auth?: string): Record<string, string> {\n const headers: Record<string, string> = {}\n const authHeaderValue = auth ?? this.#auth\n if (authHeaderValue !== undefined) {\n headers[\"authorization\"] = `Bearer ${authHeaderValue}`\n }\n return headers\n }\n}\n\n/*\n * Type aliases to support the generic request interface.\n */\ntype Method = \"get\" | \"post\" | \"patch\" | \"delete\"\ntype QueryParams = Record<string, string | number | string[]> | URLSearchParams\n\ntype WithAuth<P> = P & { auth?: string }\n"]}
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,uCAKkB;AAClB,qCAKiB;AACjB,mCAA8B;AAC9B,mDAqFwB;AACxB,kDAGwB;AAwCxB,MAAqB,MAAM;IAazB,YAAmB,OAAuB;;QAZ1C,+BAAc;QACd,mCAAmB;QACnB,iCAAe;QACf,oCAAkB;QAClB,oCAAkB;QAClB,wCAAsB;QACtB,gCAAsB;QACtB,gCAAyB;QACzB,oCAAkB;QAqIlB;;WAEG;QAEa,WAAM,GAAG;YACvB;;eAEG;YACH,QAAQ,EAAE,CACR,IAAkC,EACP,EAAE;gBAC7B,OAAO,IAAI,CAAC,OAAO,CAAmB;oBACpC,IAAI,EAAE,wBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;oBACzB,MAAM,EAAE,wBAAQ,CAAC,MAAM;oBACvB,KAAK,EAAE,IAAA,YAAI,EAAC,IAAI,EAAE,wBAAQ,CAAC,WAAW,CAAC;oBACvC,IAAI,EAAE,IAAA,YAAI,EAAC,IAAI,EAAE,wBAAQ,CAAC,UAAU,CAAC;oBACrC,IAAI,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI;iBACjB,CAAC,CAAA;YACJ,CAAC;YAED;;eAEG;YACH,MAAM,EAAE,CACN,IAAqC,EACP,EAAE;gBAChC,OAAO,IAAI,CAAC,OAAO,CAAsB;oBACvC,IAAI,EAAE,2BAAW,CAAC,IAAI,CAAC,IAAI,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,EAAC,KAAK,CAAC,EAAE;gBAC9B,oGAAoG;gBACpG,IAAI,CAAC,GAAG,CAAC,kBAAQ,CAAC,KAAK,EAAE,sBAAsB,EAAE;oBAC/C,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB,CAAC,CAAA;aACH;YAED,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;IA4cD;;;;;OAKG;IACK,GAAG,CACT,KAAe,EACf,OAAe,EACf,SAAkC;QAElC,IAAI,IAAA,0BAAgB,EAAC,KAAK,CAAC,IAAI,IAAA,0BAAgB,EAAC,uBAAA,IAAI,wBAAU,CAAC,EAAE;YAC/D,uBAAA,IAAI,sBAAQ,MAAZ,IAAI,EAAS,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;SACxC;IACH,CAAC;IAED;;;;;;;;OAQG;IACK,aAAa,CAAC,IAAa;QACjC,MAAM,OAAO,GAA2B,EAAE,CAAA;QAC1C,MAAM,eAAe,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,uBAAA,IAAI,oBAAM,CAAA;QAC1C,IAAI,eAAe,KAAK,SAAS,EAAE;YACjC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,eAAe,EAAE,CAAA;SACvD;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;;AAxnBH,yBAynBC;;AA9mBiB,2BAAoB,GAAG,YAAY,CAAA","sourcesContent":["import type { Agent } from \"node:http\"\nimport {\n type Logger,\n LogLevel,\n logLevelSeverity,\n makeConsoleLogger,\n} from \"./logging\"\nimport {\n buildRequestError,\n isHTTPResponseError,\n isNotionClientError,\n RequestTimeoutError,\n} from \"./errors\"\nimport { pick } from \"./utils\"\nimport {\n type GetBlockParameters,\n type GetBlockResponse,\n getBlock,\n type UpdateBlockParameters,\n type UpdateBlockResponse,\n updateBlock,\n type DeleteBlockParameters,\n type DeleteBlockResponse,\n deleteBlock,\n type AppendBlockChildrenParameters,\n type AppendBlockChildrenResponse,\n appendBlockChildren,\n type ListBlockChildrenParameters,\n type ListBlockChildrenResponse,\n listBlockChildren,\n type ListDatabasesParameters,\n type ListDatabasesResponse,\n listDatabases,\n type GetDatabaseParameters,\n type GetDatabaseResponse,\n getDatabase,\n type QueryDatabaseParameters,\n type QueryDatabaseResponse,\n queryDatabase,\n type CreateDatabaseParameters,\n type CreateDatabaseResponse,\n createDatabase,\n type UpdateDatabaseParameters,\n type UpdateDatabaseResponse,\n updateDatabase,\n type CreatePageParameters,\n type CreatePageResponse,\n createPage,\n type GetPageParameters,\n type GetPageResponse,\n getPage,\n type UpdatePageParameters,\n type UpdatePageResponse,\n updatePage,\n type GetUserParameters,\n type GetUserResponse,\n getUser,\n type ListUsersParameters,\n type ListUsersResponse,\n listUsers,\n type SearchParameters,\n type SearchResponse,\n search,\n type GetSelfParameters,\n type GetSelfResponse,\n getSelf,\n type GetPagePropertyParameters,\n type GetPagePropertyResponse,\n getPageProperty,\n type CreateCommentParameters,\n type CreateCommentResponse,\n createComment,\n type ListCommentsParameters,\n type ListCommentsResponse,\n listComments,\n type OauthTokenResponse,\n type OauthTokenParameters,\n oauthToken,\n type OauthIntrospectResponse,\n type OauthIntrospectParameters,\n oauthIntrospect,\n type OauthRevokeResponse,\n type OauthRevokeParameters,\n oauthRevoke,\n type CreateFileUploadParameters,\n type CreateFileUploadResponse,\n createFileUpload,\n type GetFileUploadResponse,\n type GetFileUploadParameters,\n getFileUpload,\n type SendFileUploadParameters,\n type SendFileUploadResponse,\n sendFileUpload,\n type CompleteFileUploadParameters,\n type CompleteFileUploadResponse,\n completeFileUpload,\n type ListFileUploadsParameters,\n type ListFileUploadsResponse,\n listFileUploads,\n} from \"./api-endpoints\"\nimport {\n version as PACKAGE_VERSION,\n name as PACKAGE_NAME,\n} from \"../package.json\"\nimport type { SupportedFetch } from \"./fetch-types\"\nimport type { Readable } from \"stream\"\n\nexport interface ClientOptions {\n auth?: string\n timeoutMs?: number\n baseUrl?: string\n logLevel?: LogLevel\n logger?: Logger\n notionVersion?: string\n fetch?: SupportedFetch\n /** Silently ignored in the browser */\n agent?: Agent\n}\n\ntype FileParam = {\n filename?: string\n data: string | Blob\n}\n\nexport interface RequestParameters {\n path: string\n method: Method\n query?: QueryParams\n body?: Record<string, unknown>\n formDataParams?: Record<string, string | FileParam>\n /**\n * To authenticate using public API token, `auth` should be passed as a\n * string. If you are trying to complete OAuth, then `auth` should be an object\n * containing your integration's client ID and secret.\n */\n auth?:\n | string\n | {\n client_id: string\n client_secret: string\n }\n}\n\nexport default class Client {\n #auth?: string\n #logLevel: LogLevel\n #logger: Logger\n #prefixUrl: string\n #timeoutMs: number\n #notionVersion: string\n #fetch: SupportedFetch\n #agent: Agent | undefined\n #userAgent: string\n\n static readonly defaultNotionVersion = \"2022-06-28\"\n\n public constructor(options?: ClientOptions) {\n this.#auth = options?.auth\n this.#logLevel = options?.logLevel ?? LogLevel.WARN\n this.#logger = options?.logger ?? makeConsoleLogger(PACKAGE_NAME)\n this.#prefixUrl = `${options?.baseUrl ?? \"https://api.notion.com\"}/v1/`\n this.#timeoutMs = options?.timeoutMs ?? 60_000\n this.#notionVersion = options?.notionVersion ?? Client.defaultNotionVersion\n this.#fetch = options?.fetch ?? fetch\n this.#agent = options?.agent\n this.#userAgent = `notionhq-client/${PACKAGE_VERSION}`\n }\n\n /**\n * Sends a request.\n */\n public async request<ResponseBody>(\n args: RequestParameters\n ): Promise<ResponseBody> {\n const { path, method, query, body, formDataParams, auth } = args\n\n this.log(LogLevel.INFO, \"request start\", { method, path })\n\n // If the body is empty, don't send the body in the HTTP request\n const bodyAsJsonString =\n !body || Object.entries(body).length === 0\n ? undefined\n : JSON.stringify(body)\n\n const url = new URL(`${this.#prefixUrl}${path}`)\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n if (Array.isArray(value)) {\n for (const val of value) {\n url.searchParams.append(key, decodeURIComponent(val))\n }\n } else {\n url.searchParams.append(key, String(value))\n }\n }\n }\n }\n\n // Allow both client ID / client secret based auth as well as token based auth.\n let authorizationHeader: Record<string, string>\n if (typeof auth === \"object\") {\n // Client ID and secret based auth is **ONLY** supported when using the\n // `/oauth/token` endpoint. If this is the case, handle formatting the\n // authorization header as required by `Basic` auth.\n const unencodedCredential = `${auth.client_id}:${auth.client_secret}`\n const encodedCredential =\n Buffer.from(unencodedCredential).toString(\"base64\")\n authorizationHeader = { authorization: `Basic ${encodedCredential}` }\n } else {\n // Otherwise format authorization header as `Bearer` token auth.\n authorizationHeader = this.authAsHeaders(auth)\n }\n\n const headers: Record<string, string> = {\n ...authorizationHeader,\n \"Notion-Version\": this.#notionVersion,\n \"user-agent\": this.#userAgent,\n }\n\n if (bodyAsJsonString !== undefined) {\n headers[\"content-type\"] = \"application/json\"\n }\n\n let formData: FormData | undefined\n if (formDataParams) {\n delete headers[\"content-type\"]\n\n formData = new FormData()\n for (const [key, value] of Object.entries(formDataParams)) {\n if (typeof value === \"string\") {\n formData.append(key, value)\n } else if (typeof value === \"object\") {\n formData.append(\n key,\n typeof value.data === \"object\"\n ? value.data\n : new Blob([value.data]),\n value.filename\n )\n }\n }\n }\n\n try {\n const response = await RequestTimeoutError.rejectAfterTimeout(\n this.#fetch(url.toString(), {\n method: method.toUpperCase(),\n headers,\n body: bodyAsJsonString ?? (formData as unknown as Readable),\n agent: this.#agent,\n }),\n this.#timeoutMs\n )\n\n const responseText = await response.text()\n if (!response.ok) {\n throw buildRequestError(response, responseText)\n }\n\n const responseJson: ResponseBody = JSON.parse(responseText)\n this.log(LogLevel.INFO, \"request success\", { method, path })\n return responseJson\n } catch (error: unknown) {\n if (!isNotionClientError(error)) {\n throw error\n }\n\n // Log the error if it's one of our known error types\n this.log(LogLevel.WARN, \"request fail\", {\n code: error.code,\n message: error.message,\n })\n\n if (isHTTPResponseError(error)) {\n // The response body may contain sensitive information so it is logged separately at the DEBUG level\n this.log(LogLevel.DEBUG, \"failed response body\", {\n body: error.body,\n })\n }\n\n throw error\n }\n }\n\n /*\n * Notion API endpoints\n */\n\n public readonly blocks = {\n /**\n * Retrieve block\n */\n retrieve: (\n args: WithAuth<GetBlockParameters>\n ): Promise<GetBlockResponse> => {\n return this.request<GetBlockResponse>({\n path: getBlock.path(args),\n method: getBlock.method,\n query: pick(args, getBlock.queryParams),\n body: pick(args, getBlock.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Update block\n */\n update: (\n args: WithAuth<UpdateBlockParameters>\n ): Promise<UpdateBlockResponse> => {\n return this.request<UpdateBlockResponse>({\n path: updateBlock.path(args),\n method: updateBlock.method,\n query: pick(args, updateBlock.queryParams),\n body: pick(args, updateBlock.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Delete block\n */\n delete: (\n args: WithAuth<DeleteBlockParameters>\n ): Promise<DeleteBlockResponse> => {\n return this.request<DeleteBlockResponse>({\n path: deleteBlock.path(args),\n method: deleteBlock.method,\n query: pick(args, deleteBlock.queryParams),\n body: pick(args, deleteBlock.bodyParams),\n auth: args?.auth,\n })\n },\n children: {\n /**\n * Append block children\n */\n append: (\n args: WithAuth<AppendBlockChildrenParameters>\n ): Promise<AppendBlockChildrenResponse> => {\n return this.request<AppendBlockChildrenResponse>({\n path: appendBlockChildren.path(args),\n method: appendBlockChildren.method,\n query: pick(args, appendBlockChildren.queryParams),\n body: pick(args, appendBlockChildren.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve block children\n */\n list: (\n args: WithAuth<ListBlockChildrenParameters>\n ): Promise<ListBlockChildrenResponse> => {\n return this.request<ListBlockChildrenResponse>({\n path: listBlockChildren.path(args),\n method: listBlockChildren.method,\n query: pick(args, listBlockChildren.queryParams),\n body: pick(args, listBlockChildren.bodyParams),\n auth: args?.auth,\n })\n },\n },\n }\n\n public readonly databases = {\n /**\n * List databases\n *\n * @deprecated Please use `search`\n */\n list: (\n args: WithAuth<ListDatabasesParameters>\n ): Promise<ListDatabasesResponse> => {\n return this.request<ListDatabasesResponse>({\n path: listDatabases.path(),\n method: listDatabases.method,\n query: pick(args, listDatabases.queryParams),\n body: pick(args, listDatabases.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve a database\n */\n retrieve: (\n args: WithAuth<GetDatabaseParameters>\n ): Promise<GetDatabaseResponse> => {\n return this.request<GetDatabaseResponse>({\n path: getDatabase.path(args),\n method: getDatabase.method,\n query: pick(args, getDatabase.queryParams),\n body: pick(args, getDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Query a database\n */\n query: (\n args: WithAuth<QueryDatabaseParameters>\n ): Promise<QueryDatabaseResponse> => {\n return this.request<QueryDatabaseResponse>({\n path: queryDatabase.path(args),\n method: queryDatabase.method,\n query: pick(args, queryDatabase.queryParams),\n body: pick(args, queryDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Create a database\n */\n create: (\n args: WithAuth<CreateDatabaseParameters>\n ): Promise<CreateDatabaseResponse> => {\n return this.request<CreateDatabaseResponse>({\n path: createDatabase.path(),\n method: createDatabase.method,\n query: pick(args, createDatabase.queryParams),\n body: pick(args, createDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Update a database\n */\n update: (\n args: WithAuth<UpdateDatabaseParameters>\n ): Promise<UpdateDatabaseResponse> => {\n return this.request<UpdateDatabaseResponse>({\n path: updateDatabase.path(args),\n method: updateDatabase.method,\n query: pick(args, updateDatabase.queryParams),\n body: pick(args, updateDatabase.bodyParams),\n auth: args?.auth,\n })\n },\n }\n\n public readonly pages = {\n /**\n * Create a page\n */\n create: (\n args: WithAuth<CreatePageParameters>\n ): Promise<CreatePageResponse> => {\n return this.request<CreatePageResponse>({\n path: createPage.path(),\n method: createPage.method,\n query: pick(args, createPage.queryParams),\n body: pick(args, createPage.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve a page\n */\n retrieve: (args: WithAuth<GetPageParameters>): Promise<GetPageResponse> => {\n return this.request<GetPageResponse>({\n path: getPage.path(args),\n method: getPage.method,\n query: pick(args, getPage.queryParams),\n body: pick(args, getPage.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Update page properties\n */\n update: (\n args: WithAuth<UpdatePageParameters>\n ): Promise<UpdatePageResponse> => {\n return this.request<UpdatePageResponse>({\n path: updatePage.path(args),\n method: updatePage.method,\n query: pick(args, updatePage.queryParams),\n body: pick(args, updatePage.bodyParams),\n auth: args?.auth,\n })\n },\n properties: {\n /**\n * Retrieve page property\n */\n retrieve: (\n args: WithAuth<GetPagePropertyParameters>\n ): Promise<GetPagePropertyResponse> => {\n return this.request<GetPagePropertyResponse>({\n path: getPageProperty.path(args),\n method: getPageProperty.method,\n query: pick(args, getPageProperty.queryParams),\n body: pick(args, getPageProperty.bodyParams),\n auth: args?.auth,\n })\n },\n },\n }\n\n public readonly users = {\n /**\n * Retrieve a user\n */\n retrieve: (args: WithAuth<GetUserParameters>): Promise<GetUserResponse> => {\n return this.request<GetUserResponse>({\n path: getUser.path(args),\n method: getUser.method,\n query: pick(args, getUser.queryParams),\n body: pick(args, getUser.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * List all users\n */\n list: (args: WithAuth<ListUsersParameters>): Promise<ListUsersResponse> => {\n return this.request<ListUsersResponse>({\n path: listUsers.path(),\n method: listUsers.method,\n query: pick(args, listUsers.queryParams),\n body: pick(args, listUsers.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Get details about bot\n */\n me: (args: WithAuth<GetSelfParameters>): Promise<GetSelfResponse> => {\n return this.request<GetSelfResponse>({\n path: getSelf.path(),\n method: getSelf.method,\n query: pick(args, getSelf.queryParams),\n body: pick(args, getSelf.bodyParams),\n auth: args?.auth,\n })\n },\n }\n\n public readonly comments = {\n /**\n * Create a comment\n */\n create: (\n args: WithAuth<CreateCommentParameters>\n ): Promise<CreateCommentResponse> => {\n return this.request<CreateCommentResponse>({\n path: createComment.path(),\n method: createComment.method,\n query: pick(args, createComment.queryParams),\n body: pick(args, createComment.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * List comments\n */\n list: (\n args: WithAuth<ListCommentsParameters>\n ): Promise<ListCommentsResponse> => {\n return this.request<ListCommentsResponse>({\n path: listComments.path(),\n method: listComments.method,\n query: pick(args, listComments.queryParams),\n body: pick(args, listComments.bodyParams),\n auth: args?.auth,\n })\n },\n }\n\n public readonly fileUploads = {\n /**\n * Create a file upload\n */\n create: (\n args: WithAuth<CreateFileUploadParameters>\n ): Promise<CreateFileUploadResponse> => {\n return this.request<CreateFileUploadResponse>({\n path: createFileUpload.path(),\n method: createFileUpload.method,\n query: pick(args, createFileUpload.queryParams),\n body: pick(args, createFileUpload.bodyParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Retrieve a file upload\n */\n retrieve: (\n args: WithAuth<GetFileUploadParameters>\n ): Promise<GetFileUploadResponse> => {\n return this.request<GetFileUploadResponse>({\n path: getFileUpload.path(args),\n method: getFileUpload.method,\n query: pick(args, getFileUpload.queryParams),\n auth: args?.auth,\n })\n },\n\n /**\n * List file uploads\n */\n list: (\n args: WithAuth<ListFileUploadsParameters>\n ): Promise<ListFileUploadsResponse> => {\n return this.request<ListFileUploadsResponse>({\n path: listFileUploads.path(),\n method: listFileUploads.method,\n query: pick(args, listFileUploads.queryParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Send a file upload\n *\n * Requires a `file_upload_id`, obtained from the `id` of the Create File\n * Upload API response.\n *\n * The `file` parameter contains the raw file contents or Blob/File object\n * under `file.data`, and an optional `file.filename` string.\n *\n * Supply a stringified `part_number` parameter when using file uploads\n * in multi-part mode.\n *\n * This endpoint sends HTTP multipart/form-data instead of JSON parameters.\n */\n send: (\n args: WithAuth<SendFileUploadParameters>\n ): Promise<SendFileUploadResponse> => {\n return this.request<SendFileUploadResponse>({\n path: sendFileUpload.path(args),\n method: sendFileUpload.method,\n query: pick(args, sendFileUpload.queryParams),\n formDataParams: pick(args, sendFileUpload.formDataParams),\n auth: args?.auth,\n })\n },\n\n /**\n * Complete a file upload\n */\n complete: (\n args: WithAuth<CompleteFileUploadParameters>\n ): Promise<CompleteFileUploadResponse> => {\n return this.request<CompleteFileUploadResponse>({\n path: completeFileUpload.path(args),\n method: completeFileUpload.method,\n query: pick(args, completeFileUpload.queryParams),\n auth: args?.auth,\n })\n },\n }\n\n /**\n * Search\n */\n public search = (\n args: WithAuth<SearchParameters>\n ): Promise<SearchResponse> => {\n return this.request<SearchResponse>({\n path: search.path(),\n method: search.method,\n query: pick(args, search.queryParams),\n body: pick(args, search.bodyParams),\n auth: args?.auth,\n })\n }\n\n public readonly oauth = {\n /**\n * Get token\n */\n token: (\n args: OauthTokenParameters & {\n client_id: string\n client_secret: string\n }\n ): Promise<OauthTokenResponse> => {\n return this.request<OauthTokenResponse>({\n path: oauthToken.path(),\n method: oauthToken.method,\n query: pick(args, oauthToken.queryParams),\n body: pick(args, oauthToken.bodyParams),\n auth: {\n client_id: args.client_id,\n client_secret: args.client_secret,\n },\n })\n },\n /**\n * Introspect token\n */\n introspect: (\n args: OauthIntrospectParameters & {\n client_id: string\n client_secret: string\n }\n ): Promise<OauthIntrospectResponse> => {\n return this.request<OauthIntrospectResponse>({\n path: oauthIntrospect.path(),\n method: oauthIntrospect.method,\n query: pick(args, oauthIntrospect.queryParams),\n body: pick(args, oauthIntrospect.bodyParams),\n auth: {\n client_id: args.client_id,\n client_secret: args.client_secret,\n },\n })\n },\n /**\n * Revoke token\n */\n revoke: (\n args: OauthRevokeParameters & {\n client_id: string\n client_secret: string\n }\n ): Promise<OauthRevokeResponse> => {\n return this.request<OauthRevokeResponse>({\n path: oauthRevoke.path(),\n method: oauthRevoke.method,\n query: pick(args, oauthRevoke.queryParams),\n body: pick(args, oauthRevoke.bodyParams),\n auth: {\n client_id: args.client_id,\n client_secret: args.client_secret,\n },\n })\n },\n }\n\n /**\n * Emits a log message to the console.\n *\n * @param level The level for this message\n * @param args Arguments to send to the console\n */\n private log(\n level: LogLevel,\n message: string,\n extraInfo: Record<string, unknown>\n ) {\n if (logLevelSeverity(level) >= logLevelSeverity(this.#logLevel)) {\n this.#logger(level, message, extraInfo)\n }\n }\n\n /**\n * Transforms an API key or access token into a headers object suitable for an HTTP request.\n *\n * This method uses the instance's value as the default when the input is undefined. If neither are defined, it returns\n * an empty object\n *\n * @param auth API key or access token\n * @returns headers key-value object\n */\n private authAsHeaders(auth?: string): Record<string, string> {\n const headers: Record<string, string> = {}\n const authHeaderValue = auth ?? this.#auth\n if (authHeaderValue !== undefined) {\n headers[\"authorization\"] = `Bearer ${authHeaderValue}`\n }\n return headers\n }\n}\n\n/*\n * Type aliases to support the generic request interface.\n */\ntype Method = \"get\" | \"post\" | \"patch\" | \"delete\"\ntype QueryParams = Record<string, string | number | string[]> | URLSearchParams\n\ntype WithAuth<P> = P & { auth?: string }\n"]}
|