@notionhq/client
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "@notionhq/client", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A simple and easy to use client for the Notion API", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -5,3 +5,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.search = exports.createDatabase = exports.listDatabases = exports.queryDatabase = exports.updateDatabase = exports.getDatabase = exports.appendBlockChildren = exports.listBlockChildren = exports.deleteBlock = exports.updateBlock = exports.getBlock = exports.updatePage = exports.getPage = exports.createPage = exports.listUsers = exports.getUser = void 0; | ||
exports.search = exports.createDatabase = exports.listDatabases = exports.queryDatabase = exports.updateDatabase = exports.getDatabase = exports.appendBlockChildren = exports.listBlockChildren = exports.deleteBlock = exports.updateBlock = exports.getBlock = exports.updatePage = exports.getPage = exports.createPage = exports.listUsers = exports.getUser = exports.getSelf = void 0; | ||
exports.getSelf = { | ||
method: "get", | ||
pathParams: [], | ||
queryParams: [], | ||
bodyParams: [], | ||
path: () => `users/me`, | ||
}; | ||
exports.getUser = { | ||
@@ -62,4 +69,5 @@ method: "get", | ||
"numbered_list_item", | ||
"toggle", | ||
"equation", | ||
"to_do", | ||
"toggle", | ||
"code", | ||
@@ -66,0 +74,0 @@ ], |
/// <reference types="node" /> | ||
import type { Agent } from "http"; | ||
import { Logger, LogLevel } from "./logging"; | ||
import { GetBlockParameters, GetBlockResponse, UpdateBlockParameters, UpdateBlockResponse, DeleteBlockParameters, DeleteBlockResponse, AppendBlockChildrenParameters, AppendBlockChildrenResponse, ListBlockChildrenParameters, ListBlockChildrenResponse, ListDatabasesParameters, ListDatabasesResponse, GetDatabaseParameters, GetDatabaseResponse, QueryDatabaseParameters, QueryDatabaseResponse, CreateDatabaseParameters, CreateDatabaseResponse, UpdateDatabaseParameters, UpdateDatabaseResponse, CreatePageParameters, CreatePageResponse, GetPageParameters, GetPageResponse, UpdatePageParameters, UpdatePageResponse, GetUserParameters, GetUserResponse, ListUsersParameters, ListUsersResponse, SearchParameters, SearchResponse } from "./api-endpoints"; | ||
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 } from "./api-endpoints"; | ||
import { SupportedFetch } from "./fetch-types"; | ||
@@ -109,2 +109,6 @@ export interface ClientOptions { | ||
list: (args: WithAuth<ListUsersParameters>) => Promise<ListUsersResponse>; | ||
/** | ||
* Get details about bot | ||
*/ | ||
me: (args: WithAuth<GetSelfParameters>) => Promise<GetSelfResponse>; | ||
}; | ||
@@ -111,0 +115,0 @@ /** |
@@ -44,4 +44,4 @@ "use strict"; | ||
method: api_endpoints_1.getBlock.method, | ||
query: helpers_1.pick(args, api_endpoints_1.getBlock.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.getBlock.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.getBlock.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.getBlock.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -57,4 +57,4 @@ }); | ||
method: api_endpoints_1.updateBlock.method, | ||
query: helpers_1.pick(args, api_endpoints_1.updateBlock.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.updateBlock.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.updateBlock.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.updateBlock.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -70,4 +70,4 @@ }); | ||
method: api_endpoints_1.deleteBlock.method, | ||
query: helpers_1.pick(args, api_endpoints_1.deleteBlock.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.deleteBlock.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.deleteBlock.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.deleteBlock.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -84,4 +84,4 @@ }); | ||
method: api_endpoints_1.appendBlockChildren.method, | ||
query: helpers_1.pick(args, api_endpoints_1.appendBlockChildren.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.appendBlockChildren.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.appendBlockChildren.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.appendBlockChildren.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -97,4 +97,4 @@ }); | ||
method: api_endpoints_1.listBlockChildren.method, | ||
query: helpers_1.pick(args, api_endpoints_1.listBlockChildren.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.listBlockChildren.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.listBlockChildren.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.listBlockChildren.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -115,4 +115,4 @@ }); | ||
method: api_endpoints_1.listDatabases.method, | ||
query: helpers_1.pick(args, api_endpoints_1.listDatabases.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.listDatabases.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.listDatabases.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.listDatabases.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -128,4 +128,4 @@ }); | ||
method: api_endpoints_1.getDatabase.method, | ||
query: helpers_1.pick(args, api_endpoints_1.getDatabase.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.getDatabase.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.getDatabase.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.getDatabase.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -141,4 +141,4 @@ }); | ||
method: api_endpoints_1.queryDatabase.method, | ||
query: helpers_1.pick(args, api_endpoints_1.queryDatabase.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.queryDatabase.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.queryDatabase.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.queryDatabase.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -154,4 +154,4 @@ }); | ||
method: api_endpoints_1.createDatabase.method, | ||
query: helpers_1.pick(args, api_endpoints_1.createDatabase.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.createDatabase.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.createDatabase.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.createDatabase.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -167,4 +167,4 @@ }); | ||
method: api_endpoints_1.updateDatabase.method, | ||
query: helpers_1.pick(args, api_endpoints_1.updateDatabase.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.updateDatabase.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.updateDatabase.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.updateDatabase.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -182,4 +182,4 @@ }); | ||
method: api_endpoints_1.createPage.method, | ||
query: helpers_1.pick(args, api_endpoints_1.createPage.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.createPage.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.createPage.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.createPage.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -195,4 +195,4 @@ }); | ||
method: api_endpoints_1.getPage.method, | ||
query: helpers_1.pick(args, api_endpoints_1.getPage.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.getPage.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.getPage.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.getPage.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -208,4 +208,4 @@ }); | ||
method: api_endpoints_1.updatePage.method, | ||
query: helpers_1.pick(args, api_endpoints_1.updatePage.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.updatePage.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.updatePage.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.updatePage.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -223,4 +223,4 @@ }); | ||
method: api_endpoints_1.getUser.method, | ||
query: helpers_1.pick(args, api_endpoints_1.getUser.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.getUser.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.getUser.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.getUser.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -236,11 +236,23 @@ }); | ||
method: api_endpoints_1.listUsers.method, | ||
query: helpers_1.pick(args, api_endpoints_1.listUsers.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.listUsers.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.listUsers.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.listUsers.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
}); | ||
}, | ||
/** | ||
* Get details about bot | ||
*/ | ||
me: (args) => { | ||
return this.request({ | ||
path: api_endpoints_1.getSelf.path(), | ||
method: api_endpoints_1.getSelf.method, | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.getSelf.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.getSelf.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
}); | ||
}, | ||
}; | ||
__classPrivateFieldSet(this, _Client_auth, options === null || options === void 0 ? void 0 : options.auth, "f"); | ||
__classPrivateFieldSet(this, _Client_logLevel, (_a = options === null || options === void 0 ? void 0 : options.logLevel) !== null && _a !== void 0 ? _a : logging_1.LogLevel.WARN, "f"); | ||
__classPrivateFieldSet(this, _Client_logger, (_b = options === null || options === void 0 ? void 0 : options.logger) !== null && _b !== void 0 ? _b : logging_1.makeConsoleLogger(package_json_1.name), "f"); | ||
__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"); | ||
__classPrivateFieldSet(this, _Client_prefixUrl, ((_c = options === null || options === void 0 ? void 0 : options.baseUrl) !== null && _c !== void 0 ? _c : "https://api.notion.com") + "/v1/", "f"); | ||
@@ -293,3 +305,3 @@ __classPrivateFieldSet(this, _Client_timeoutMs, (_d = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _d !== void 0 ? _d : 60000, "f"); | ||
if (!response.ok) { | ||
throw errors_1.buildRequestError(response, responseText); | ||
throw (0, errors_1.buildRequestError)(response, responseText); | ||
} | ||
@@ -301,3 +313,3 @@ const responseJson = JSON.parse(responseText); | ||
catch (error) { | ||
if (!errors_1.isNotionClientError(error)) { | ||
if (!(0, errors_1.isNotionClientError)(error)) { | ||
throw error; | ||
@@ -310,3 +322,3 @@ } | ||
}); | ||
if (errors_1.isHTTPResponseError(error)) { | ||
if ((0, errors_1.isHTTPResponseError)(error)) { | ||
// The response body may contain sensitive information so it is logged separately at the DEBUG level | ||
@@ -327,4 +339,4 @@ this.log(logging_1.LogLevel.DEBUG, `failed response body`, { | ||
method: api_endpoints_1.search.method, | ||
query: helpers_1.pick(args, api_endpoints_1.search.queryParams), | ||
body: helpers_1.pick(args, api_endpoints_1.search.bodyParams), | ||
query: (0, helpers_1.pick)(args, api_endpoints_1.search.queryParams), | ||
body: (0, helpers_1.pick)(args, api_endpoints_1.search.bodyParams), | ||
auth: args === null || args === void 0 ? void 0 : args.auth, | ||
@@ -340,3 +352,3 @@ }); | ||
log(level, message, extraInfo) { | ||
if (logging_1.logLevelSeverity(level) >= logging_1.logLevelSeverity(__classPrivateFieldGet(this, _Client_logLevel, "f"))) { | ||
if ((0, logging_1.logLevelSeverity)(level) >= (0, logging_1.logLevelSeverity)(__classPrivateFieldGet(this, _Client_logLevel, "f"))) { | ||
__classPrivateFieldGet(this, _Client_logger, "f").call(this, level, message, extraInfo); | ||
@@ -343,0 +355,0 @@ } |
@@ -40,3 +40,3 @@ "use strict"; | ||
function isNotionClientError(error) { | ||
return helpers_1.isObject(error) && error instanceof NotionClientErrorBase; | ||
return (0, helpers_1.isObject)(error) && error instanceof NotionClientErrorBase; | ||
} | ||
@@ -190,3 +190,3 @@ exports.isNotionClientError = isNotionClientError; | ||
} | ||
if (!helpers_1.isObject(parsed) || | ||
if (!(0, helpers_1.isObject)(parsed) || | ||
typeof parsed["message"] !== "string" || | ||
@@ -193,0 +193,0 @@ !isAPIErrorCode(parsed["code"])) { |
@@ -32,3 +32,3 @@ "use strict"; | ||
default: | ||
return helpers_1.assertNever(level); | ||
return (0, helpers_1.assertNever)(level); | ||
} | ||
@@ -35,0 +35,0 @@ } |
{ | ||
"name": "@notionhq/client", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A simple and easy to use client for the Notion API", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4159330
36058