@notionhq/client 2.2.10 → 2.2.11

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/client",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "description": "A simple and easy to use client for the Notion API",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import type { Agent } from "http";
4
4
  import { Logger, LogLevel } from "./logging";
5
- 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";
5
+ 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, OauthTokenResponse, OauthTokenParameters } from "./api-endpoints";
6
6
  import { SupportedFetch } from "./fetch-types";
7
7
  export interface ClientOptions {
8
8
  auth?: string;
@@ -20,7 +20,15 @@ export interface RequestParameters {
20
20
  method: Method;
21
21
  query?: QueryParams;
22
22
  body?: Record<string, unknown>;
23
- auth?: string;
23
+ /**
24
+ * To authenticate using public API token, `auth` should be passed as a
25
+ * string. If you are trying to complete OAuth, then `auth` should be an object
26
+ * containing your integration's client ID and secret.
27
+ */
28
+ auth?: string | {
29
+ client_id: string;
30
+ client_secret: string;
31
+ };
24
32
  }
25
33
  export default class Client {
26
34
  #private;
@@ -132,6 +140,15 @@ export default class Client {
132
140
  * Search
133
141
  */
134
142
  search: (args: WithAuth<SearchParameters>) => Promise<SearchResponse>;
143
+ readonly oauth: {
144
+ /**
145
+ * Get token
146
+ */
147
+ token: (args: OauthTokenParameters & {
148
+ client_id: string;
149
+ client_secret: string;
150
+ }) => Promise<OauthTokenResponse>;
151
+ };
135
152
  /**
136
153
  * Emits a log message to the console.
137
154
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EACL,MAAM,EACN,QAAQ,EAGT,MAAM,WAAW,CAAA;AAQlB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAEhB,qBAAqB,EACrB,mBAAmB,EAEnB,qBAAqB,EACrB,mBAAmB,EAEnB,6BAA6B,EAC7B,2BAA2B,EAE3B,2BAA2B,EAC3B,yBAAyB,EAEzB,uBAAuB,EACvB,qBAAqB,EAErB,qBAAqB,EACrB,mBAAmB,EAEnB,uBAAuB,EACvB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,iBAAiB,CAAC;QAUvE;;WAEG;mBACQ,SAAS,iBAAiB,CAAC,KAAG,QAAQ,eAAe,CAAC;MASlE;IAED,SAAgB,QAAQ;QACtB;;WAEG;uBAEK,SAAS,uBAAuB,CAAC,KACtC,QAAQ,qBAAqB,CAAC;QAUjC;;WAEG;qBAEK,SAAS,sBAAsB,CAAC,KACrC,QAAQ,oBAAoB,CAAC;MASjC;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;MAY/B;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"}
@@ -289,6 +289,23 @@ class Client {
289
289
  auth: args === null || args === void 0 ? void 0 : args.auth,
290
290
  });
291
291
  };
292
+ this.oauth = {
293
+ /**
294
+ * Get token
295
+ */
296
+ token: (args) => {
297
+ return this.request({
298
+ path: api_endpoints_1.oauthToken.path(),
299
+ method: api_endpoints_1.oauthToken.method,
300
+ query: (0, utils_1.pick)(args, api_endpoints_1.oauthToken.queryParams),
301
+ body: (0, utils_1.pick)(args, api_endpoints_1.oauthToken.bodyParams),
302
+ auth: {
303
+ client_id: args.client_id,
304
+ client_secret: args.client_secret,
305
+ },
306
+ });
307
+ },
308
+ };
292
309
  __classPrivateFieldSet(this, _Client_auth, options === null || options === void 0 ? void 0 : options.auth, "f");
293
310
  __classPrivateFieldSet(this, _Client_logLevel, (_a = options === null || options === void 0 ? void 0 : options.logLevel) !== null && _a !== void 0 ? _a : logging_1.LogLevel.WARN, "f");
294
311
  __classPrivateFieldSet(this, _Client_logger, (_b = options === null || options === void 0 ? void 0 : options.logger) !== null && _b !== void 0 ? _b : (0, logging_1.makeConsoleLogger)(package_json_1.name), "f");
@@ -327,8 +344,22 @@ class Client {
327
344
  }
328
345
  }
329
346
  }
347
+ // Allow both client ID / client secret based auth as well as token based auth.
348
+ let authorizationHeader;
349
+ if (typeof auth === "object") {
350
+ // Client ID and secret based auth is **ONLY** supported when using the
351
+ // `/oauth/token` endpoint. If this is the case, handle formatting the
352
+ // authorization header as required by `Basic` auth.
353
+ const unencodedCredential = `${auth.client_id}:${auth.client_secret}`;
354
+ const encodedCredential = Buffer.from(unencodedCredential).toString("base64");
355
+ authorizationHeader = { authorization: `Basic ${encodedCredential}` };
356
+ }
357
+ else {
358
+ // Otherwise format authorization header as `Bearer` token auth.
359
+ authorizationHeader = this.authAsHeaders(auth);
360
+ }
330
361
  const headers = {
331
- ...this.authAsHeaders(auth),
362
+ ...authorizationHeader,
332
363
  "Notion-Version": __classPrivateFieldGet(this, _Client_notionVersion, "f"),
333
364
  "user-agent": __classPrivateFieldGet(this, _Client_userAgent, "f"),
334
365
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,uCAKkB;AAClB,qCAKiB;AACjB,mCAA8B;AAC9B,mDA6DwB;AACxB,2CAAkC;AAClC,kDAGwB;AAuBxB,MAAqB,MAAM;IAazB,YAAmB,OAAuB;;QAZ1C,+BAAc;QACd,mCAAmB;QACnB,iCAAe;QACf,oCAAkB;QAClB,oCAAkB;QAClB,wCAAsB;QACtB,gCAAsB;QACtB,gCAAyB;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K,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;;AAxcH,yBAycC;;AA9biB,2BAAoB,GAAG,YAAY,CAAA","sourcesContent":["import type { Agent } from \"http\"\nimport {\n 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 GetBlockParameters,\n GetBlockResponse,\n getBlock,\n UpdateBlockParameters,\n UpdateBlockResponse,\n updateBlock,\n DeleteBlockParameters,\n DeleteBlockResponse,\n deleteBlock,\n AppendBlockChildrenParameters,\n AppendBlockChildrenResponse,\n appendBlockChildren,\n ListBlockChildrenParameters,\n ListBlockChildrenResponse,\n listBlockChildren,\n ListDatabasesParameters,\n ListDatabasesResponse,\n listDatabases,\n GetDatabaseParameters,\n GetDatabaseResponse,\n getDatabase,\n QueryDatabaseParameters,\n QueryDatabaseResponse,\n queryDatabase,\n CreateDatabaseParameters,\n CreateDatabaseResponse,\n createDatabase,\n UpdateDatabaseParameters,\n UpdateDatabaseResponse,\n updateDatabase,\n CreatePageParameters,\n CreatePageResponse,\n createPage,\n GetPageParameters,\n GetPageResponse,\n getPage,\n UpdatePageParameters,\n UpdatePageResponse,\n updatePage,\n GetUserParameters,\n GetUserResponse,\n getUser,\n ListUsersParameters,\n ListUsersResponse,\n listUsers,\n SearchParameters,\n SearchResponse,\n search,\n GetSelfParameters,\n GetSelfResponse,\n getSelf,\n GetPagePropertyParameters,\n GetPagePropertyResponse,\n getPageProperty,\n CreateCommentParameters,\n CreateCommentResponse,\n createComment,\n ListCommentsParameters,\n ListCommentsResponse,\n listComments,\n} from \"./api-endpoints\"\nimport nodeFetch from \"node-fetch\"\nimport {\n version as PACKAGE_VERSION,\n name as PACKAGE_NAME,\n} from \"../package.json\"\nimport { 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 auth?: string\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 ?? nodeFetch\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 const headers: Record<string, string> = {\n ...this.authAsHeaders(auth),\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 /**\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,mDAgEwB;AACxB,2CAAkC;AAClC,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;;WAEG;QAEa,WAAM,GAAG;YACvB;;eAEG;YACH,QAAQ,EAAE,CACR,IAAkC,EACP,EAAE;gBAC7B,OAAO,IAAI,CAAC,OAAO,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AC1C,IAAI,eAAe,KAAK,SAAS,EAAE;YACjC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,eAAe,EAAE,CAAA;SACvD;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;;AA9eH,yBA+eC;;AApeiB,2BAAoB,GAAG,YAAY,CAAA","sourcesContent":["import type { Agent } from \"http\"\nimport {\n 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 GetBlockParameters,\n GetBlockResponse,\n getBlock,\n UpdateBlockParameters,\n UpdateBlockResponse,\n updateBlock,\n DeleteBlockParameters,\n DeleteBlockResponse,\n deleteBlock,\n AppendBlockChildrenParameters,\n AppendBlockChildrenResponse,\n appendBlockChildren,\n ListBlockChildrenParameters,\n ListBlockChildrenResponse,\n listBlockChildren,\n ListDatabasesParameters,\n ListDatabasesResponse,\n listDatabases,\n GetDatabaseParameters,\n GetDatabaseResponse,\n getDatabase,\n QueryDatabaseParameters,\n QueryDatabaseResponse,\n queryDatabase,\n CreateDatabaseParameters,\n CreateDatabaseResponse,\n createDatabase,\n UpdateDatabaseParameters,\n UpdateDatabaseResponse,\n updateDatabase,\n CreatePageParameters,\n CreatePageResponse,\n createPage,\n GetPageParameters,\n GetPageResponse,\n getPage,\n UpdatePageParameters,\n UpdatePageResponse,\n updatePage,\n GetUserParameters,\n GetUserResponse,\n getUser,\n ListUsersParameters,\n ListUsersResponse,\n listUsers,\n SearchParameters,\n SearchResponse,\n search,\n GetSelfParameters,\n GetSelfResponse,\n getSelf,\n GetPagePropertyParameters,\n GetPagePropertyResponse,\n getPageProperty,\n CreateCommentParameters,\n CreateCommentResponse,\n createComment,\n ListCommentsParameters,\n ListCommentsResponse,\n listComments,\n OauthTokenResponse,\n OauthTokenParameters,\n oauthToken,\n} from \"./api-endpoints\"\nimport nodeFetch from \"node-fetch\"\nimport {\n version as PACKAGE_VERSION,\n name as PACKAGE_NAME,\n} from \"../package.json\"\nimport { 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 ?? nodeFetch\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\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"]}
@@ -72,6 +72,52 @@ type BooleanFormulaPropertyResponse = {
72
72
  boolean: boolean | null;
73
73
  };
74
74
  type FormulaPropertyResponse = StringFormulaPropertyResponse | DateFormulaPropertyResponse | NumberFormulaPropertyResponse | BooleanFormulaPropertyResponse;
75
+ type VerificationPropertyUnverifiedResponse = {
76
+ state: "unverified";
77
+ date: null;
78
+ verified_by: null;
79
+ };
80
+ type VerificationPropertyResponse = {
81
+ state: "verified" | "expired";
82
+ date: DateResponse | null;
83
+ verified_by: {
84
+ id: IdRequest;
85
+ } | null | {
86
+ person: {
87
+ email?: string;
88
+ };
89
+ id: IdRequest;
90
+ type?: "person";
91
+ name?: string | null;
92
+ avatar_url?: string | null;
93
+ object?: "user";
94
+ } | null | {
95
+ bot: EmptyObject | {
96
+ owner: {
97
+ type: "user";
98
+ user: {
99
+ type: "person";
100
+ person: {
101
+ email: string;
102
+ };
103
+ name: string | null;
104
+ avatar_url: string | null;
105
+ id: IdRequest;
106
+ object: "user";
107
+ } | PartialUserObjectResponse;
108
+ } | {
109
+ type: "workspace";
110
+ workspace: true;
111
+ };
112
+ workspace_name: string | null;
113
+ };
114
+ id: IdRequest;
115
+ type?: "bot";
116
+ name?: string | null;
117
+ avatar_url?: string | null;
118
+ object?: "user";
119
+ } | null;
120
+ };
75
121
  type AnnotationResponse = {
76
122
  bold: boolean;
77
123
  italic: boolean;
@@ -239,6 +285,10 @@ export type PageObjectResponse = {
239
285
  number: number | null;
240
286
  };
241
287
  id: string;
288
+ } | {
289
+ type: "verification";
290
+ verification: VerificationPropertyUnverifiedResponse | null | VerificationPropertyResponse | null;
291
+ id: string;
242
292
  } | {
243
293
  type: "title";
244
294
  title: Array<RichTextItemResponse>;
@@ -270,6 +320,73 @@ export type PageObjectResponse = {
270
320
  } | {
271
321
  type: "array";
272
322
  array: Array<{
323
+ type: "number";
324
+ number: number | null;
325
+ } | {
326
+ type: "url";
327
+ url: string | null;
328
+ } | {
329
+ type: "select";
330
+ select: SelectPropertyResponse | null;
331
+ } | {
332
+ type: "multi_select";
333
+ multi_select: Array<SelectPropertyResponse>;
334
+ } | {
335
+ type: "status";
336
+ status: SelectPropertyResponse | null;
337
+ } | {
338
+ type: "date";
339
+ date: DateResponse | null;
340
+ } | {
341
+ type: "email";
342
+ email: string | null;
343
+ } | {
344
+ type: "phone_number";
345
+ phone_number: string | null;
346
+ } | {
347
+ type: "checkbox";
348
+ checkbox: boolean;
349
+ } | {
350
+ type: "files";
351
+ files: Array<{
352
+ file: {
353
+ url: string;
354
+ expiry_time: string;
355
+ };
356
+ name: StringRequest;
357
+ type?: "file";
358
+ } | {
359
+ external: {
360
+ url: TextRequest;
361
+ };
362
+ name: StringRequest;
363
+ type?: "external";
364
+ }>;
365
+ } | {
366
+ type: "created_by";
367
+ created_by: PartialUserObjectResponse | UserObjectResponse;
368
+ } | {
369
+ type: "created_time";
370
+ created_time: string;
371
+ } | {
372
+ type: "last_edited_by";
373
+ last_edited_by: PartialUserObjectResponse | UserObjectResponse;
374
+ } | {
375
+ type: "last_edited_time";
376
+ last_edited_time: string;
377
+ } | {
378
+ type: "formula";
379
+ formula: FormulaPropertyResponse;
380
+ } | {
381
+ type: "unique_id";
382
+ unique_id: {
383
+ prefix: string | null;
384
+ number: number | null;
385
+ };
386
+ } | {
387
+ type: "verification";
388
+ verification: VerificationPropertyUnverifiedResponse | null | VerificationPropertyResponse | null;
389
+ } | {
273
390
  type: "title";
274
391
  title: Array<RichTextItemResponse>;
275
392
  } | {
@@ -590,6 +707,7 @@ export type Heading1BlockObjectResponse = {
590
707
  heading_1: {
591
708
  rich_text: Array<RichTextItemResponse>;
592
709
  color: ApiColor;
710
+ is_toggleable: boolean;
593
711
  };
594
712
  parent: {
595
713
  type: "database_id";
@@ -618,6 +736,7 @@ export type Heading2BlockObjectResponse = {
618
736
  heading_2: {
619
737
  rich_text: Array<RichTextItemResponse>;
620
738
  color: ApiColor;
739
+ is_toggleable: boolean;
621
740
  };
622
741
  parent: {
623
742
  type: "database_id";
@@ -646,6 +765,7 @@ export type Heading3BlockObjectResponse = {
646
765
  heading_3: {
647
766
  rich_text: Array<RichTextItemResponse>;
648
767
  color: ApiColor;
768
+ is_toggleable: boolean;
649
769
  };
650
770
  parent: {
651
771
  type: "database_id";
@@ -1649,6 +1769,12 @@ export type UniqueIdPropertyItemObjectResponse = {
1649
1769
  object: "property_item";
1650
1770
  id: string;
1651
1771
  };
1772
+ export type VerificationPropertyItemObjectResponse = {
1773
+ type: "verification";
1774
+ verification: VerificationPropertyUnverifiedResponse | null | VerificationPropertyResponse | null;
1775
+ object: "property_item";
1776
+ id: string;
1777
+ };
1652
1778
  export type TitlePropertyItemObjectResponse = {
1653
1779
  type: "title";
1654
1780
  title: RichTextItemResponse;
@@ -1701,7 +1827,7 @@ export type RollupPropertyItemObjectResponse = {
1701
1827
  object: "property_item";
1702
1828
  id: string;
1703
1829
  };
1704
- export type PropertyItemObjectResponse = NumberPropertyItemObjectResponse | UrlPropertyItemObjectResponse | SelectPropertyItemObjectResponse | MultiSelectPropertyItemObjectResponse | StatusPropertyItemObjectResponse | DatePropertyItemObjectResponse | EmailPropertyItemObjectResponse | PhoneNumberPropertyItemObjectResponse | CheckboxPropertyItemObjectResponse | FilesPropertyItemObjectResponse | CreatedByPropertyItemObjectResponse | CreatedTimePropertyItemObjectResponse | LastEditedByPropertyItemObjectResponse | LastEditedTimePropertyItemObjectResponse | FormulaPropertyItemObjectResponse | UniqueIdPropertyItemObjectResponse | TitlePropertyItemObjectResponse | RichTextPropertyItemObjectResponse | PeoplePropertyItemObjectResponse | RelationPropertyItemObjectResponse | RollupPropertyItemObjectResponse;
1830
+ export type PropertyItemObjectResponse = NumberPropertyItemObjectResponse | UrlPropertyItemObjectResponse | SelectPropertyItemObjectResponse | MultiSelectPropertyItemObjectResponse | StatusPropertyItemObjectResponse | DatePropertyItemObjectResponse | EmailPropertyItemObjectResponse | PhoneNumberPropertyItemObjectResponse | CheckboxPropertyItemObjectResponse | FilesPropertyItemObjectResponse | CreatedByPropertyItemObjectResponse | CreatedTimePropertyItemObjectResponse | LastEditedByPropertyItemObjectResponse | LastEditedTimePropertyItemObjectResponse | FormulaPropertyItemObjectResponse | UniqueIdPropertyItemObjectResponse | VerificationPropertyItemObjectResponse | TitlePropertyItemObjectResponse | RichTextPropertyItemObjectResponse | PeoplePropertyItemObjectResponse | RelationPropertyItemObjectResponse | RollupPropertyItemObjectResponse;
1705
1831
  export type CommentObjectResponse = {
1706
1832
  object: "comment";
1707
1833
  id: string;
@@ -6926,5 +7052,47 @@ export declare const listComments: {
6926
7052
  readonly bodyParams: readonly [];
6927
7053
  readonly path: () => string;
6928
7054
  };
7055
+ type OauthTokenBodyParameters = {
7056
+ grant_type: string;
7057
+ code: string;
7058
+ redirect_uri?: string;
7059
+ external_account?: {
7060
+ key: string;
7061
+ name: string;
7062
+ };
7063
+ };
7064
+ export type OauthTokenParameters = OauthTokenBodyParameters;
7065
+ export type OauthTokenResponse = {
7066
+ access_token: string;
7067
+ token_type: "bearer";
7068
+ bot_id: string;
7069
+ workspace_icon: string | null;
7070
+ workspace_name: string | null;
7071
+ workspace_id: string;
7072
+ owner: {
7073
+ type: "user";
7074
+ user: {
7075
+ type: "person";
7076
+ person: {
7077
+ email: string;
7078
+ };
7079
+ name: string | null;
7080
+ avatar_url: string | null;
7081
+ id: IdRequest;
7082
+ object: "user";
7083
+ } | PartialUserObjectResponse;
7084
+ } | {
7085
+ type: "workspace";
7086
+ workspace: true;
7087
+ };
7088
+ duplicated_template_id: string | null;
7089
+ };
7090
+ export declare const oauthToken: {
7091
+ readonly method: "post";
7092
+ readonly pathParams: readonly [];
7093
+ readonly queryParams: readonly [];
7094
+ readonly bodyParams: readonly ["grant_type", "code", "redirect_uri", "external_account"];
7095
+ readonly path: () => string;
7096
+ };
6929
7097
  export {};
6930
7098
  //# sourceMappingURL=api-endpoints.d.ts.map