@notionhq/client 5.26.0 → 5.27.1
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/README.md +130 -129
- package/build/package.json +4 -3
- package/build/src/Client.d.ts +1867 -130
- package/build/src/Client.d.ts.map +1 -1
- package/build/src/Client.js +95 -571
- package/build/src/Client.js.map +1 -1
- package/build/src/api-endpoint-methods.d.ts +920 -0
- package/build/src/api-endpoint-methods.d.ts.map +1 -0
- package/build/src/api-endpoint-methods.js +171 -0
- package/build/src/api-endpoint-methods.js.map +1 -0
- package/build/src/api-endpoints/agent-skills.d.ts +68 -0
- package/build/src/api-endpoints/agent-skills.d.ts.map +1 -0
- package/build/src/api-endpoints/agent-skills.js +36 -0
- package/build/src/api-endpoints/agent-skills.js.map +1 -0
- package/build/src/api-endpoints/agents.d.ts +173 -146
- package/build/src/api-endpoints/agents.d.ts.map +1 -1
- package/build/src/api-endpoints/agents.js.map +1 -1
- package/build/src/api-endpoints/data-sources.d.ts +1 -0
- package/build/src/api-endpoints/data-sources.d.ts.map +1 -1
- package/build/src/api-endpoints/data-sources.js.map +1 -1
- package/build/src/api-endpoints/databases.d.ts +3 -1
- package/build/src/api-endpoints/databases.d.ts.map +1 -1
- package/build/src/api-endpoints/databases.js +1 -0
- package/build/src/api-endpoints/databases.js.map +1 -1
- package/build/src/api-endpoints/file-uploads.d.ts.map +1 -1
- package/build/src/api-endpoints/file-uploads.js.map +1 -1
- package/build/src/api-endpoints/pages.d.ts.map +1 -1
- package/build/src/api-endpoints/pages.js.map +1 -1
- package/build/src/api-endpoints/users.d.ts.map +1 -1
- package/build/src/api-endpoints/users.js.map +1 -1
- package/build/src/api-endpoints.d.ts +1 -0
- package/build/src/api-endpoints.d.ts.map +1 -1
- package/build/src/api-endpoints.js +1 -0
- package/build/src/api-endpoints.js.map +1 -1
- package/build/src/errors.d.ts +11 -0
- package/build/src/errors.d.ts.map +1 -1
- package/build/src/errors.js +20 -1
- package/build/src/errors.js.map +1 -1
- package/build/src/helpers.d.ts +4 -4
- package/build/src/helpers.d.ts.map +1 -1
- package/build/src/helpers.js.map +1 -1
- package/build/src/index.d.ts +2 -2
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -1
- package/build/src/index.js.map +1 -1
- package/build/src/webhooks.d.ts +12 -19
- package/build/src/webhooks.d.ts.map +1 -1
- package/build/src/webhooks.js +27 -35
- package/build/src/webhooks.js.map +1 -1
- package/package.json +4 -3
|
@@ -20,6 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./api-endpoints/agent-skills"), exports);
|
|
23
24
|
__exportStar(require("./api-endpoints/agents"), exports);
|
|
24
25
|
__exportStar(require("./api-endpoints/async-tasks"), exports);
|
|
25
26
|
__exportStar(require("./api-endpoints/blocks"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-endpoints.js","sourceRoot":"","sources":["../../src/api-endpoints.ts"],"names":[],"mappings":";AAAA,sBAAsB;AACtB,+CAA+C;AAC/C,EAAE;AACF,kEAAkE;AAClE,+DAA+D;AAC/D,8CAA8C;;;;;;;;;;;;;;;;AAE9C,yDAAsC;AACtC,8DAA2C;AAC3C,yDAAsC;AACtC,2DAAwC;AACxC,yDAAsC;AACtC,gEAA6C;AAC7C,+DAA4C;AAC5C,4DAAyC;AACzC,+DAA4C;AAC5C,gEAA6C;AAC7C,wDAAqC;AACrC,wDAAqC;AACrC,yDAAsC;AACtC,wDAAqC;AACrC,wDAAqC;AACrC,2DAAwC","sourcesContent":["// cspell:disable-file\n// Note: This is a generated file. DO NOT EDIT!\n//\n// This barrel re-exports all API types from per-resource modules.\n// Import from this file for backwards compatibility, or import\n// directly from the specific resource module.\n\nexport * from \"./api-endpoints/agents\"\nexport * from \"./api-endpoints/async-tasks\"\nexport * from \"./api-endpoints/blocks\"\nexport * from \"./api-endpoints/comments\"\nexport * from \"./api-endpoints/common\"\nexport * from \"./api-endpoints/custom-emojis\"\nexport * from \"./api-endpoints/data-sources\"\nexport * from \"./api-endpoints/databases\"\nexport * from \"./api-endpoints/file-uploads\"\nexport * from \"./api-endpoints/meeting-notes\"\nexport * from \"./api-endpoints/oauth\"\nexport * from \"./api-endpoints/pages\"\nexport * from \"./api-endpoints/search\"\nexport * from \"./api-endpoints/users\"\nexport * from \"./api-endpoints/views\"\nexport * from \"./api-endpoints/webhooks\"\n"]}
|
|
1
|
+
{"version":3,"file":"api-endpoints.js","sourceRoot":"","sources":["../../src/api-endpoints.ts"],"names":[],"mappings":";AAAA,sBAAsB;AACtB,+CAA+C;AAC/C,EAAE;AACF,kEAAkE;AAClE,+DAA+D;AAC/D,8CAA8C;;;;;;;;;;;;;;;;AAE9C,+DAA4C;AAC5C,yDAAsC;AACtC,8DAA2C;AAC3C,yDAAsC;AACtC,2DAAwC;AACxC,yDAAsC;AACtC,gEAA6C;AAC7C,+DAA4C;AAC5C,4DAAyC;AACzC,+DAA4C;AAC5C,gEAA6C;AAC7C,wDAAqC;AACrC,wDAAqC;AACrC,yDAAsC;AACtC,wDAAqC;AACrC,wDAAqC;AACrC,2DAAwC","sourcesContent":["// cspell:disable-file\n// Note: This is a generated file. DO NOT EDIT!\n//\n// This barrel re-exports all API types from per-resource modules.\n// Import from this file for backwards compatibility, or import\n// directly from the specific resource module.\n\nexport * from \"./api-endpoints/agent-skills\"\nexport * from \"./api-endpoints/agents\"\nexport * from \"./api-endpoints/async-tasks\"\nexport * from \"./api-endpoints/blocks\"\nexport * from \"./api-endpoints/comments\"\nexport * from \"./api-endpoints/common\"\nexport * from \"./api-endpoints/custom-emojis\"\nexport * from \"./api-endpoints/data-sources\"\nexport * from \"./api-endpoints/databases\"\nexport * from \"./api-endpoints/file-uploads\"\nexport * from \"./api-endpoints/meeting-notes\"\nexport * from \"./api-endpoints/oauth\"\nexport * from \"./api-endpoints/pages\"\nexport * from \"./api-endpoints/search\"\nexport * from \"./api-endpoints/users\"\nexport * from \"./api-endpoints/views\"\nexport * from \"./api-endpoints/webhooks\"\n"]}
|
package/build/src/errors.d.ts
CHANGED
|
@@ -65,6 +65,17 @@ export declare class InvalidPathParameterError extends NotionClientErrorBase<Cli
|
|
|
65
65
|
constructor(message?: string);
|
|
66
66
|
static isInvalidPathParameterError(error: unknown): error is InvalidPathParameterError;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Error thrown when the client would send a token or client secret from a
|
|
70
|
+
* browser page or worker without `dangerouslyAllowBrowser: true`. Anyone who
|
|
71
|
+
* can load the page can read the token, so this is blocked by default.
|
|
72
|
+
*
|
|
73
|
+
* This is a setup error, not an API error, so it is not a `NotionClientError`.
|
|
74
|
+
*/
|
|
75
|
+
export declare class BrowserTokenNotAllowedError extends Error {
|
|
76
|
+
readonly name = "BrowserTokenNotAllowedError";
|
|
77
|
+
constructor(message?: string);
|
|
78
|
+
}
|
|
68
79
|
/**
|
|
69
80
|
* Validates that a request path does not contain path traversal sequences.
|
|
70
81
|
* Throws InvalidPathParameterError if the path contains ".." segments,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAIjD;;GAEG;AACH,oBAAY,YAAY;IACtB,YAAY,iBAAiB;IAC7B,kBAAkB,wBAAwB;IAC1C,cAAc,qBAAqB;IACnC,WAAW,iBAAiB;IAC5B,WAAW,iBAAiB;IAC5B,iBAAiB,wBAAwB;IACzC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,mBAAmB,0BAA0B;IAC7C,eAAe,qBAAqB;IACpC,kBAAkB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,aAAa,CAAC;IAC5F,QAAQ,CAAC,IAAI,8BAA6B;gBAE9B,IAAI,EAAE;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;QAC3B,OAAO,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;QACrC,WAAW,EAAE,MAAM,CAAA;KACpB;IAmBD,MAAM,CAAC,0BAA0B,CAC/B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,wBAAwB;CAKrC;AAmBD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,YAAY,CAAC;IACnE,QAAQ,CAAC,IAAI,sBAAqB;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAEvC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB;CAGrE;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,MAAM,GACf,gBAAgB,GAAG,wBAAwB,CAmB7C"}
|
package/build/src/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APIResponseError = exports.UnknownHTTPResponseError = exports.InvalidPathParameterError = exports.RequestTimeoutError = exports.ClientErrorCode = exports.APIErrorCode = void 0;
|
|
3
|
+
exports.APIResponseError = exports.UnknownHTTPResponseError = exports.BrowserTokenNotAllowedError = exports.InvalidPathParameterError = exports.RequestTimeoutError = exports.ClientErrorCode = exports.APIErrorCode = void 0;
|
|
4
4
|
exports.isNotionClientError = isNotionClientError;
|
|
5
5
|
exports.validateRequestPath = validateRequestPath;
|
|
6
6
|
exports.getResponseHeader = getResponseHeader;
|
|
@@ -101,6 +101,25 @@ class InvalidPathParameterError extends NotionClientErrorBase {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
exports.InvalidPathParameterError = InvalidPathParameterError;
|
|
104
|
+
/**
|
|
105
|
+
* Error thrown when the client would send a token or client secret from a
|
|
106
|
+
* browser page or worker without `dangerouslyAllowBrowser: true`. Anyone who
|
|
107
|
+
* can load the page can read the token, so this is blocked by default.
|
|
108
|
+
*
|
|
109
|
+
* This is a setup error, not an API error, so it is not a `NotionClientError`.
|
|
110
|
+
*/
|
|
111
|
+
class BrowserTokenNotAllowedError extends Error {
|
|
112
|
+
constructor(message = "It looks like you're running in a browser. Using a Notion " +
|
|
113
|
+
"token here is blocked by default: anyone who can load the page can " +
|
|
114
|
+
"read the token and act as your connection. Keep the token on a " +
|
|
115
|
+
"server instead. If only you can open this page and you accept the " +
|
|
116
|
+
"risk, pass `dangerouslyAllowBrowser: true` to the Client. See " +
|
|
117
|
+
"https://developers.notion.com/guides/get-started/handling-api-keys#calling-the-api-from-a-browser") {
|
|
118
|
+
super(message);
|
|
119
|
+
this.name = "BrowserTokenNotAllowedError";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.BrowserTokenNotAllowedError = BrowserTokenNotAllowedError;
|
|
104
123
|
/**
|
|
105
124
|
* Validates that a request path does not contain path traversal sequences.
|
|
106
125
|
* Throws InvalidPathParameterError if the path contains ".." segments,
|
package/build/src/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AA0EA,kDAIC;AA6ED,kDAwBC;AAQD,8CA2BC;AA8DD,kDAaC;AAwED,8CAsBC;AA9XD,mCAAkC;AAGlC;;GAEG;AACH,IAAY,YAeX;AAfD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,0DAA0C,CAAA;IAC1C,mDAAmC,CAAA;IACnC,4CAA4B,CAAA;IAC5B,4CAA4B,CAAA;IAC5B,yDAAyC,CAAA;IACzC,kDAAkC,CAAA;IAClC,4CAA4B,CAAA;IAC5B,oDAAoC,CAAA;IACp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A;IAE7D,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC;QAC1B,eAAe;QACf,UAAU;KACX,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAa;IACnC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,aAAa,CAAA;AAC1D,CAAC","sourcesContent":["import { SupportedResponse } from \"./fetch-types\"\nimport { isObject } from \"./utils\"\nimport { Assert } from \"./type-utils\"\n\n/**\n * Error codes returned in responses from the API.\n */\nexport enum APIErrorCode {\n Unauthorized = \"unauthorized\",\n RestrictedResource = \"restricted_resource\",\n ObjectNotFound = \"object_not_found\",\n RateLimited = \"rate_limited\",\n InvalidJSON = \"invalid_json\",\n InvalidRequestURL = \"invalid_request_url\",\n InvalidRequest = \"invalid_request\",\n InvalidBeta = \"invalid_beta\",\n ValidationError = \"validation_error\",\n ConflictError = \"conflict_error\",\n InternalServerError = \"internal_server_error\",\n ServiceOverload = \"service_overload\",\n ServiceUnavailable = \"service_unavailable\",\n GatewayTimeout = \"gateway_timeout\",\n}\n\n/**\n * Error codes generated for client errors.\n */\nexport enum ClientErrorCode {\n RequestTimeout = \"notionhq_client_request_timeout\",\n ResponseError = \"notionhq_client_response_error\",\n InvalidPathParameter = \"notionhq_client_invalid_path_parameter\",\n}\n\n/**\n * Error codes on errors thrown by the `Client`.\n */\nexport type NotionErrorCode = APIErrorCode | ClientErrorCode\n\n/**\n * Base error type.\n */\nabstract class NotionClientErrorBase<\n Code extends NotionErrorCode,\n> extends Error {\n abstract code: Code\n}\n\n/**\n * Error type that encompasses all the kinds of errors that the Notion client will throw.\n */\nexport type NotionClientError =\n | RequestTimeoutError\n | UnknownHTTPResponseError\n | APIResponseError\n | InvalidPathParameterError\n\n// Assert that NotionClientError's `code` property is a narrow type.\n// This prevents us from accidentally regressing to `string`-typed name field.\ntype _assertCodeIsNarrow = Assert<NotionErrorCode, NotionClientError[\"code\"]>\n\n// Assert that the type of `name` in NotionErrorCode is a narrow type.\n// This prevents us from accidentally regressing to `string`-typed name field.\ntype _assertNameIsNarrow = Assert<\n | \"RequestTimeoutError\"\n | \"UnknownHTTPResponseError\"\n | \"APIResponseError\"\n | \"InvalidPathParameterError\",\n NotionClientError[\"name\"]\n>\n\n/**\n * @param error any value, usually a caught error.\n * @returns `true` if error is a `NotionClientError`.\n */\nexport function isNotionClientError(\n error: unknown\n): error is NotionClientError {\n return isObject(error) && error instanceof NotionClientErrorBase\n}\n\n/**\n * Narrows down the types of a NotionClientError.\n * @param error any value, usually a caught error.\n * @param codes an object mapping from possible error codes to `true`\n * @returns `true` if error is a `NotionClientError` with a code in `codes`.\n */\nfunction isNotionClientErrorWithCode<Code extends NotionErrorCode>(\n error: unknown,\n codes: { [C in Code]: true }\n): error is NotionClientError & { code: Code } {\n return isNotionClientError(error) && error.code in codes\n}\n\n/**\n * Error thrown by the client if a request times out.\n */\nexport class RequestTimeoutError extends NotionClientErrorBase<ClientErrorCode.RequestTimeout> {\n readonly code = ClientErrorCode.RequestTimeout\n readonly name = \"RequestTimeoutError\"\n\n constructor(message = \"Request to Notion API has timed out\") {\n super(message)\n }\n\n static isRequestTimeoutError(error: unknown): error is RequestTimeoutError {\n return isNotionClientErrorWithCode(error, {\n [ClientErrorCode.RequestTimeout]: true,\n })\n }\n\n static rejectAfterTimeout<T>(\n promise: Promise<T>,\n timeoutMS: number\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(new RequestTimeoutError())\n }, timeoutMS)\n\n promise\n .then(resolve)\n .catch(reject)\n .then(() => clearTimeout(timeoutId))\n })\n }\n}\n\n/**\n * Error thrown when a path parameter contains invalid characters such as\n * path traversal sequences (..) that could alter the intended API endpoint.\n */\nexport class InvalidPathParameterError extends NotionClientErrorBase<ClientErrorCode.InvalidPathParameter> {\n readonly code = ClientErrorCode.InvalidPathParameter\n readonly name = \"InvalidPathParameterError\"\n\n constructor(\n message = \"Path parameter contains invalid characters that could alter the request path\"\n ) {\n super(message)\n }\n\n static isInvalidPathParameterError(\n error: unknown\n ): error is InvalidPathParameterError {\n return isNotionClientErrorWithCode(error, {\n [ClientErrorCode.InvalidPathParameter]: true,\n })\n }\n}\n\n/**\n * Validates that a request path does not contain path traversal sequences.\n * Throws InvalidPathParameterError if the path contains \"..\" segments,\n * including URL-encoded variants like %2e%2e.\n */\nexport function validateRequestPath(path: string): void {\n // Check for literal path traversal\n if (path.includes(\"..\")) {\n throw new InvalidPathParameterError(\n `Request path \"${path}\" contains path traversal sequence \"..\"`\n )\n }\n\n // Check for URL-encoded path traversal (%2e = '.')\n // Only decode if path contains potential encoded dots\n if (/%2e/i.test(path)) {\n let decoded: string\n try {\n decoded = decodeURIComponent(path)\n } catch {\n // Invalid percent encoding - not a traversal concern\n return\n }\n if (decoded.includes(\"..\")) {\n throw new InvalidPathParameterError(\n `Request path \"${path}\" contains encoded path traversal sequence`\n )\n }\n }\n}\n\n/**\n * Reads a header by name from a `SupportedResponse[\"headers\"]`, which is typed\n * as `unknown` because the SDK supports any `fetch` implementation. Handles\n * both a standard `Headers` object and a plain record. Header names are\n * case-insensitive per RFC 9110, so plain records are matched case-insensitively.\n */\nexport function getResponseHeader(\n headers: unknown,\n name: string\n): string | undefined {\n if (!isObject(headers)) {\n return undefined\n }\n\n const get = headers[\"get\"]\n if (typeof get === \"function\") {\n const value: unknown = get.call(headers, name)\n return typeof value === \"string\" ? value : undefined\n }\n\n const lowerName = name.toLowerCase()\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() !== lowerName) {\n continue\n }\n if (typeof value === \"string\") {\n return value\n }\n if (Array.isArray(value) && typeof value[0] === \"string\") {\n return value[0]\n }\n }\n return undefined\n}\n\ntype HTTPResponseErrorCode = ClientErrorCode.ResponseError | APIErrorCode\n\ntype AdditionalData = Record<string, string | string[]>\n\nclass HTTPResponseError<\n Code extends HTTPResponseErrorCode,\n> extends NotionClientErrorBase<Code> {\n readonly name: string = \"HTTPResponseError\"\n readonly code: Code\n readonly status: number\n readonly headers: SupportedResponse[\"headers\"]\n readonly body: string\n readonly additional_data: AdditionalData | undefined\n readonly request_id: string | undefined\n /**\n * Value of the `cf-ray` response header, when present.\n */\n readonly ray_id: string | undefined\n\n constructor(args: {\n code: Code\n status: number\n message: string\n headers: SupportedResponse[\"headers\"]\n rawBodyText: string\n additional_data: AdditionalData | undefined\n request_id: string | undefined\n }) {\n super(args.message)\n const { code, status, headers, rawBodyText, additional_data, request_id } =\n args\n this.code = code\n this.status = status\n this.headers = headers\n this.body = rawBodyText\n this.additional_data = additional_data\n this.request_id =\n request_id ?? getResponseHeader(headers, \"x-notion-request-id\")\n this.ray_id = getResponseHeader(headers, \"cf-ray\")\n }\n}\n\nconst httpResponseErrorCodes: { [C in HTTPResponseErrorCode]: true } = {\n [ClientErrorCode.ResponseError]: true,\n [APIErrorCode.Unauthorized]: true,\n [APIErrorCode.RestrictedResource]: true,\n [APIErrorCode.ObjectNotFound]: true,\n [APIErrorCode.RateLimited]: true,\n [APIErrorCode.InvalidJSON]: true,\n [APIErrorCode.InvalidRequestURL]: true,\n [APIErrorCode.InvalidRequest]: true,\n [APIErrorCode.InvalidBeta]: true,\n [APIErrorCode.ValidationError]: true,\n [APIErrorCode.ConflictError]: true,\n [APIErrorCode.InternalServerError]: true,\n [APIErrorCode.ServiceOverload]: true,\n [APIErrorCode.ServiceUnavailable]: true,\n [APIErrorCode.GatewayTimeout]: true,\n}\n\nexport function isHTTPResponseError(\n error: unknown\n): error is UnknownHTTPResponseError | APIResponseError {\n if (!isNotionClientErrorWithCode(error, httpResponseErrorCodes)) {\n return false\n }\n\n type _assert = Assert<\n UnknownHTTPResponseError | APIResponseError,\n typeof error\n >\n\n return true\n}\n\n/**\n * Error thrown if an API call responds with an unknown error code, or does not respond with\n * a property-formatted error.\n */\nexport class UnknownHTTPResponseError extends HTTPResponseError<ClientErrorCode.ResponseError> {\n readonly name = \"UnknownHTTPResponseError\"\n\n constructor(args: {\n status: number\n message: string | undefined\n headers: SupportedResponse[\"headers\"]\n rawBodyText: string\n }) {\n const ray_id = getResponseHeader(args.headers, \"cf-ray\")\n const request_id = getResponseHeader(args.headers, \"x-notion-request-id\")\n super({\n ...args,\n code: ClientErrorCode.ResponseError,\n message:\n args.message ??\n buildUnknownResponseMessage({\n status: args.status,\n contentType: getResponseHeader(args.headers, \"content-type\"),\n ray_id,\n request_id,\n }),\n additional_data: undefined,\n request_id,\n })\n }\n\n static isUnknownHTTPResponseError(\n error: unknown\n ): error is UnknownHTTPResponseError {\n return isNotionClientErrorWithCode(error, {\n [ClientErrorCode.ResponseError]: true,\n })\n }\n}\n\nconst apiErrorCodes: { [C in APIErrorCode]: true } = {\n [APIErrorCode.Unauthorized]: true,\n [APIErrorCode.RestrictedResource]: true,\n [APIErrorCode.ObjectNotFound]: true,\n [APIErrorCode.RateLimited]: true,\n [APIErrorCode.InvalidJSON]: true,\n [APIErrorCode.InvalidRequestURL]: true,\n [APIErrorCode.InvalidRequest]: true,\n [APIErrorCode.InvalidBeta]: true,\n [APIErrorCode.ValidationError]: true,\n [APIErrorCode.ConflictError]: true,\n [APIErrorCode.InternalServerError]: true,\n [APIErrorCode.ServiceOverload]: true,\n [APIErrorCode.ServiceUnavailable]: true,\n [APIErrorCode.GatewayTimeout]: true,\n}\n\n/**\n * A response from the API indicating a problem.\n * Use the `code` property to handle various kinds of errors. All its possible values are in `APIErrorCode`.\n */\nexport class APIResponseError extends HTTPResponseError<APIErrorCode> {\n readonly name = \"APIResponseError\"\n readonly request_id: string | undefined\n\n static isAPIResponseError(error: unknown): error is APIResponseError {\n return isNotionClientErrorWithCode(error, apiErrorCodes)\n }\n}\n\nexport function buildRequestError(\n response: SupportedResponse,\n bodyText: string\n): APIResponseError | UnknownHTTPResponseError {\n const apiErrorResponseBody = parseAPIErrorResponseBody(bodyText)\n if (apiErrorResponseBody !== undefined) {\n return new APIResponseError({\n code: apiErrorResponseBody.code,\n message: apiErrorResponseBody.message,\n headers: response.headers,\n status: response.status,\n rawBodyText: bodyText,\n additional_data: apiErrorResponseBody.additional_data,\n request_id: apiErrorResponseBody.request_id,\n })\n }\n return new UnknownHTTPResponseError({\n message: undefined,\n headers: response.headers,\n status: response.status,\n rawBodyText: bodyText,\n })\n}\n\n/**\n * Builds the default message for an unrecognized HTTP response.\n *\n * A response with a Cloudflare Ray ID but no Notion request ID was answered\n * before it reached the API. The message surfaces the Ray ID rather than\n * leaving callers to infer it from an HTML body.\n */\nfunction buildUnknownResponseMessage(args: {\n status: number\n contentType: string | undefined\n ray_id: string | undefined\n request_id: string | undefined\n}): string {\n const { status, contentType, ray_id, request_id } = args\n const base = `Request to Notion API failed with status: ${status}`\n if (ray_id === undefined || request_id !== undefined) {\n return base\n }\n const contentTypeNote =\n contentType !== undefined ? ` (content-type: ${contentType})` : \"\"\n const blockedRequestNote =\n status === 403\n ? \" This may mean the request was blocked by a network security rule.\"\n : \"\"\n return (\n `${base}. The response was returned by Notion's edge proxy before reaching ` +\n `the Notion API${contentTypeNote}.${blockedRequestNote} Cloudflare Ray ID: ` +\n `${ray_id}. Include this ID when contacting Notion support.`\n )\n}\n\nfunction parseAPIErrorResponseBody(body: string):\n | {\n code: APIErrorCode\n message: string\n additional_data: AdditionalData | undefined\n request_id: string | undefined\n }\n | undefined {\n if (typeof body !== \"string\") {\n return\n }\n\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch (parseError) {\n return\n }\n\n if (\n !isObject(parsed) ||\n typeof parsed[\"message\"] !== \"string\" ||\n !isAPIErrorCode(parsed[\"code\"])\n ) {\n return\n }\n\n const additional_data = parsed[\"additional_data\"] as\n | AdditionalData\n | undefined\n const request_id = parsed[\"request_id\"] as string | undefined\n\n return {\n ...parsed,\n code: parsed[\"code\"],\n message: parsed[\"message\"],\n additional_data,\n request_id,\n }\n}\n\nfunction isAPIErrorCode(code: unknown): code is APIErrorCode {\n return typeof code === \"string\" && code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G,IAAI,qEAAqE;QAC5E,iBAAiB,eAAe,IAAI,kBAAkB,sBAAsB;QAC5E,GAAG,MAAM,mDAAmD,CAC7D,CAAA;AACH,CAAC;AAED,SAAS,yBAAyB,CAAC,IAAY;IAQ7C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAM;IACR,CAAC;IAED,IAAI,MAAe,CAAA;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,UAAU,EAAE,CAAC;QACpB,OAAM;IACR,CAAC;IAED,IACE,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC;QACjB,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,QAAQ;QACrC,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAC/B,CAAC;QACD,OAAM;IACR,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAEnC,CAAA;IACb,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAuB,CAAA;IAE7D,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC;QAC1B,eAAe;QACf,UAAU;KACX,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAa;IACnC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,aAAa,CAAA;AAC1D,CAAC","sourcesContent":["import { SupportedResponse } from \"./fetch-types\"\nimport { isObject } from \"./utils\"\nimport { Assert } from \"./type-utils\"\n\n/**\n * Error codes returned in responses from the API.\n */\nexport enum APIErrorCode {\n Unauthorized = \"unauthorized\",\n RestrictedResource = \"restricted_resource\",\n ObjectNotFound = \"object_not_found\",\n RateLimited = \"rate_limited\",\n InvalidJSON = \"invalid_json\",\n InvalidRequestURL = \"invalid_request_url\",\n InvalidRequest = \"invalid_request\",\n InvalidBeta = \"invalid_beta\",\n ValidationError = \"validation_error\",\n ConflictError = \"conflict_error\",\n InternalServerError = \"internal_server_error\",\n ServiceOverload = \"service_overload\",\n ServiceUnavailable = \"service_unavailable\",\n GatewayTimeout = \"gateway_timeout\",\n}\n\n/**\n * Error codes generated for client errors.\n */\nexport enum ClientErrorCode {\n RequestTimeout = \"notionhq_client_request_timeout\",\n ResponseError = \"notionhq_client_response_error\",\n InvalidPathParameter = \"notionhq_client_invalid_path_parameter\",\n}\n\n/**\n * Error codes on errors thrown by the `Client`.\n */\nexport type NotionErrorCode = APIErrorCode | ClientErrorCode\n\n/**\n * Base error type.\n */\nabstract class NotionClientErrorBase<\n Code extends NotionErrorCode,\n> extends Error {\n abstract code: Code\n}\n\n/**\n * Error type that encompasses all the kinds of errors that the Notion client will throw.\n */\nexport type NotionClientError =\n | RequestTimeoutError\n | UnknownHTTPResponseError\n | APIResponseError\n | InvalidPathParameterError\n\n// Assert that NotionClientError's `code` property is a narrow type.\n// This prevents us from accidentally regressing to `string`-typed name field.\ntype _assertCodeIsNarrow = Assert<NotionErrorCode, NotionClientError[\"code\"]>\n\n// Assert that the type of `name` in NotionErrorCode is a narrow type.\n// This prevents us from accidentally regressing to `string`-typed name field.\ntype _assertNameIsNarrow = Assert<\n | \"RequestTimeoutError\"\n | \"UnknownHTTPResponseError\"\n | \"APIResponseError\"\n | \"InvalidPathParameterError\",\n NotionClientError[\"name\"]\n>\n\n/**\n * @param error any value, usually a caught error.\n * @returns `true` if error is a `NotionClientError`.\n */\nexport function isNotionClientError(\n error: unknown\n): error is NotionClientError {\n return isObject(error) && error instanceof NotionClientErrorBase\n}\n\n/**\n * Narrows down the types of a NotionClientError.\n * @param error any value, usually a caught error.\n * @param codes an object mapping from possible error codes to `true`\n * @returns `true` if error is a `NotionClientError` with a code in `codes`.\n */\nfunction isNotionClientErrorWithCode<Code extends NotionErrorCode>(\n error: unknown,\n codes: { [C in Code]: true }\n): error is NotionClientError & { code: Code } {\n return isNotionClientError(error) && error.code in codes\n}\n\n/**\n * Error thrown by the client if a request times out.\n */\nexport class RequestTimeoutError extends NotionClientErrorBase<ClientErrorCode.RequestTimeout> {\n readonly code = ClientErrorCode.RequestTimeout\n readonly name = \"RequestTimeoutError\"\n\n constructor(message = \"Request to Notion API has timed out\") {\n super(message)\n }\n\n static isRequestTimeoutError(error: unknown): error is RequestTimeoutError {\n return isNotionClientErrorWithCode(error, {\n [ClientErrorCode.RequestTimeout]: true,\n })\n }\n\n static rejectAfterTimeout<T>(\n promise: Promise<T>,\n timeoutMS: number\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n reject(new RequestTimeoutError())\n }, timeoutMS)\n\n promise\n .then(resolve)\n .catch(reject)\n .then(() => clearTimeout(timeoutId))\n })\n }\n}\n\n/**\n * Error thrown when a path parameter contains invalid characters such as\n * path traversal sequences (..) that could alter the intended API endpoint.\n */\nexport class InvalidPathParameterError extends NotionClientErrorBase<ClientErrorCode.InvalidPathParameter> {\n readonly code = ClientErrorCode.InvalidPathParameter\n readonly name = \"InvalidPathParameterError\"\n\n constructor(\n message = \"Path parameter contains invalid characters that could alter the request path\"\n ) {\n super(message)\n }\n\n static isInvalidPathParameterError(\n error: unknown\n ): error is InvalidPathParameterError {\n return isNotionClientErrorWithCode(error, {\n [ClientErrorCode.InvalidPathParameter]: true,\n })\n }\n}\n\n/**\n * Error thrown when the client would send a token or client secret from a\n * browser page or worker without `dangerouslyAllowBrowser: true`. Anyone who\n * can load the page can read the token, so this is blocked by default.\n *\n * This is a setup error, not an API error, so it is not a `NotionClientError`.\n */\nexport class BrowserTokenNotAllowedError extends Error {\n readonly name = \"BrowserTokenNotAllowedError\"\n\n constructor(\n message = \"It looks like you're running in a browser. Using a Notion \" +\n \"token here is blocked by default: anyone who can load the page can \" +\n \"read the token and act as your connection. Keep the token on a \" +\n \"server instead. If only you can open this page and you accept the \" +\n \"risk, pass `dangerouslyAllowBrowser: true` to the Client. See \" +\n \"https://developers.notion.com/guides/get-started/handling-api-keys#calling-the-api-from-a-browser\"\n ) {\n super(message)\n }\n}\n\n/**\n * Validates that a request path does not contain path traversal sequences.\n * Throws InvalidPathParameterError if the path contains \"..\" segments,\n * including URL-encoded variants like %2e%2e.\n */\nexport function validateRequestPath(path: string): void {\n // Check for literal path traversal\n if (path.includes(\"..\")) {\n throw new InvalidPathParameterError(\n `Request path \"${path}\" contains path traversal sequence \"..\"`\n )\n }\n\n // Check for URL-encoded path traversal (%2e = '.')\n // Only decode if path contains potential encoded dots\n if (/%2e/i.test(path)) {\n let decoded: string\n try {\n decoded = decodeURIComponent(path)\n } catch {\n // Invalid percent encoding - not a traversal concern\n return\n }\n if (decoded.includes(\"..\")) {\n throw new InvalidPathParameterError(\n `Request path \"${path}\" contains encoded path traversal sequence`\n )\n }\n }\n}\n\n/**\n * Reads a header by name from a `SupportedResponse[\"headers\"]`, which is typed\n * as `unknown` because the SDK supports any `fetch` implementation. Handles\n * both a standard `Headers` object and a plain record. Header names are\n * case-insensitive per RFC 9110, so plain records are matched case-insensitively.\n */\nexport function getResponseHeader(\n headers: unknown,\n name: string\n): string | undefined {\n if (!isObject(headers)) {\n return undefined\n }\n\n const get = headers[\"get\"]\n if (typeof get === \"function\") {\n const value: unknown = get.call(headers, name)\n return typeof value === \"string\" ? value : undefined\n }\n\n const lowerName = name.toLowerCase()\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() !== lowerName) {\n continue\n }\n if (typeof value === \"string\") {\n return value\n }\n if (Array.isArray(value) && typeof value[0] === \"string\") {\n return value[0]\n }\n }\n return undefined\n}\n\ntype HTTPResponseErrorCode = ClientErrorCode.ResponseError | APIErrorCode\n\ntype AdditionalData = Record<string, string | string[]>\n\nclass HTTPResponseError<\n Code extends HTTPResponseErrorCode,\n> extends NotionClientErrorBase<Code> {\n readonly name: string = \"HTTPResponseError\"\n readonly code: Code\n readonly status: number\n readonly headers: SupportedResponse[\"headers\"]\n readonly body: string\n readonly additional_data: AdditionalData | undefined\n readonly request_id: string | undefined\n /**\n * Value of the `cf-ray` response header, when present.\n */\n readonly ray_id: string | undefined\n\n constructor(args: {\n code: Code\n status: number\n message: string\n headers: SupportedResponse[\"headers\"]\n rawBodyText: string\n additional_data: AdditionalData | undefined\n request_id: string | undefined\n }) {\n super(args.message)\n const { code, status, headers, rawBodyText, additional_data, request_id } =\n args\n this.code = code\n this.status = status\n this.headers = headers\n this.body = rawBodyText\n this.additional_data = additional_data\n this.request_id =\n request_id ?? getResponseHeader(headers, \"x-notion-request-id\")\n this.ray_id = getResponseHeader(headers, \"cf-ray\")\n }\n}\n\nconst httpResponseErrorCodes: { [C in HTTPResponseErrorCode]: true } = {\n [ClientErrorCode.ResponseError]: true,\n [APIErrorCode.Unauthorized]: true,\n [APIErrorCode.RestrictedResource]: true,\n [APIErrorCode.ObjectNotFound]: true,\n [APIErrorCode.RateLimited]: true,\n [APIErrorCode.InvalidJSON]: true,\n [APIErrorCode.InvalidRequestURL]: true,\n [APIErrorCode.InvalidRequest]: true,\n [APIErrorCode.InvalidBeta]: true,\n [APIErrorCode.ValidationError]: true,\n [APIErrorCode.ConflictError]: true,\n [APIErrorCode.InternalServerError]: true,\n [APIErrorCode.ServiceOverload]: true,\n [APIErrorCode.ServiceUnavailable]: true,\n [APIErrorCode.GatewayTimeout]: true,\n}\n\nexport function isHTTPResponseError(\n error: unknown\n): error is UnknownHTTPResponseError | APIResponseError {\n if (!isNotionClientErrorWithCode(error, httpResponseErrorCodes)) {\n return false\n }\n\n type _assert = Assert<\n UnknownHTTPResponseError | APIResponseError,\n typeof error\n >\n\n return true\n}\n\n/**\n * Error thrown if an API call responds with an unknown error code, or does not respond with\n * a property-formatted error.\n */\nexport class UnknownHTTPResponseError extends HTTPResponseError<ClientErrorCode.ResponseError> {\n readonly name = \"UnknownHTTPResponseError\"\n\n constructor(args: {\n status: number\n message: string | undefined\n headers: SupportedResponse[\"headers\"]\n rawBodyText: string\n }) {\n const ray_id = getResponseHeader(args.headers, \"cf-ray\")\n const request_id = getResponseHeader(args.headers, \"x-notion-request-id\")\n super({\n ...args,\n code: ClientErrorCode.ResponseError,\n message:\n args.message ??\n buildUnknownResponseMessage({\n status: args.status,\n contentType: getResponseHeader(args.headers, \"content-type\"),\n ray_id,\n request_id,\n }),\n additional_data: undefined,\n request_id,\n })\n }\n\n static isUnknownHTTPResponseError(\n error: unknown\n ): error is UnknownHTTPResponseError {\n return isNotionClientErrorWithCode(error, {\n [ClientErrorCode.ResponseError]: true,\n })\n }\n}\n\nconst apiErrorCodes: { [C in APIErrorCode]: true } = {\n [APIErrorCode.Unauthorized]: true,\n [APIErrorCode.RestrictedResource]: true,\n [APIErrorCode.ObjectNotFound]: true,\n [APIErrorCode.RateLimited]: true,\n [APIErrorCode.InvalidJSON]: true,\n [APIErrorCode.InvalidRequestURL]: true,\n [APIErrorCode.InvalidRequest]: true,\n [APIErrorCode.InvalidBeta]: true,\n [APIErrorCode.ValidationError]: true,\n [APIErrorCode.ConflictError]: true,\n [APIErrorCode.InternalServerError]: true,\n [APIErrorCode.ServiceOverload]: true,\n [APIErrorCode.ServiceUnavailable]: true,\n [APIErrorCode.GatewayTimeout]: true,\n}\n\n/**\n * A response from the API indicating a problem.\n * Use the `code` property to handle various kinds of errors. All its possible values are in `APIErrorCode`.\n */\nexport class APIResponseError extends HTTPResponseError<APIErrorCode> {\n readonly name = \"APIResponseError\"\n readonly request_id: string | undefined\n\n static isAPIResponseError(error: unknown): error is APIResponseError {\n return isNotionClientErrorWithCode(error, apiErrorCodes)\n }\n}\n\nexport function buildRequestError(\n response: SupportedResponse,\n bodyText: string\n): APIResponseError | UnknownHTTPResponseError {\n const apiErrorResponseBody = parseAPIErrorResponseBody(bodyText)\n if (apiErrorResponseBody !== undefined) {\n return new APIResponseError({\n code: apiErrorResponseBody.code,\n message: apiErrorResponseBody.message,\n headers: response.headers,\n status: response.status,\n rawBodyText: bodyText,\n additional_data: apiErrorResponseBody.additional_data,\n request_id: apiErrorResponseBody.request_id,\n })\n }\n return new UnknownHTTPResponseError({\n message: undefined,\n headers: response.headers,\n status: response.status,\n rawBodyText: bodyText,\n })\n}\n\n/**\n * Builds the default message for an unrecognized HTTP response.\n *\n * A response with a Cloudflare Ray ID but no Notion request ID was answered\n * before it reached the API. The message surfaces the Ray ID rather than\n * leaving callers to infer it from an HTML body.\n */\nfunction buildUnknownResponseMessage(args: {\n status: number\n contentType: string | undefined\n ray_id: string | undefined\n request_id: string | undefined\n}): string {\n const { status, contentType, ray_id, request_id } = args\n const base = `Request to Notion API failed with status: ${status}`\n if (ray_id === undefined || request_id !== undefined) {\n return base\n }\n const contentTypeNote =\n contentType !== undefined ? ` (content-type: ${contentType})` : \"\"\n const blockedRequestNote =\n status === 403\n ? \" This may mean the request was blocked by a network security rule.\"\n : \"\"\n return (\n `${base}. The response was returned by Notion's edge proxy before reaching ` +\n `the Notion API${contentTypeNote}.${blockedRequestNote} Cloudflare Ray ID: ` +\n `${ray_id}. Include this ID when contacting Notion support.`\n )\n}\n\nfunction parseAPIErrorResponseBody(body: string):\n | {\n code: APIErrorCode\n message: string\n additional_data: AdditionalData | undefined\n request_id: string | undefined\n }\n | undefined {\n if (typeof body !== \"string\") {\n return\n }\n\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch (parseError) {\n return\n }\n\n if (\n !isObject(parsed) ||\n typeof parsed[\"message\"] !== \"string\" ||\n !isAPIErrorCode(parsed[\"code\"])\n ) {\n return\n }\n\n const additional_data = parsed[\"additional_data\"] as\n | AdditionalData\n | undefined\n const request_id = parsed[\"request_id\"] as string | undefined\n\n return {\n ...parsed,\n code: parsed[\"code\"],\n message: parsed[\"message\"],\n additional_data,\n request_id,\n }\n}\n\nfunction isAPIErrorCode(code: unknown): code is APIErrorCode {\n return typeof code === \"string\" && code in apiErrorCodes\n}\n"]}
|
package/build/src/helpers.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ type ListDataSourceTemplatesArgs = PaginatedArgs & {
|
|
|
70
70
|
* @param client A Notion client instance.
|
|
71
71
|
* @param args Arguments including the data_source_id and optional start_cursor.
|
|
72
72
|
*/
|
|
73
|
-
export declare function iterateDataSourceTemplates(client: Client, args: ListDataSourceTemplatesArgs): AsyncIterableIterator<DataSourceTemplate>;
|
|
73
|
+
export declare function iterateDataSourceTemplates(client: Pick<Client, "dataSources">, args: ListDataSourceTemplatesArgs): AsyncIterableIterator<DataSourceTemplate>;
|
|
74
74
|
/**
|
|
75
75
|
* Collect all data source templates into an in-memory array.
|
|
76
76
|
*
|
|
@@ -86,7 +86,7 @@ export declare function iterateDataSourceTemplates(client: Client, args: ListDat
|
|
|
86
86
|
* @param client A Notion client instance.
|
|
87
87
|
* @param args Arguments including the data_source_id and optional start_cursor.
|
|
88
88
|
*/
|
|
89
|
-
export declare function collectDataSourceTemplates(client: Client, args: ListDataSourceTemplatesArgs): Promise<DataSourceTemplate[]>;
|
|
89
|
+
export declare function collectDataSourceTemplates(client: Pick<Client, "dataSources">, args: ListDataSourceTemplatesArgs): Promise<DataSourceTemplate[]>;
|
|
90
90
|
type DataSourceRow = QueryDataSourceResponse["results"][number];
|
|
91
91
|
/**
|
|
92
92
|
* A filter the full-query helpers can combine with a created_time window bound.
|
|
@@ -147,7 +147,7 @@ export type FullDataSourceQueryArgs = Omit<QueryDataSourceParameters, "start_cur
|
|
|
147
147
|
* @param args Query arguments. `start_cursor` and `sorts` are managed by the
|
|
148
148
|
* helper; `filter` is combined with the created_time window bound.
|
|
149
149
|
*/
|
|
150
|
-
export declare function iterateAllDataSourceRows(client: Client, args: FullDataSourceQueryArgs): AsyncIterableIterator<DataSourceRow>;
|
|
150
|
+
export declare function iterateAllDataSourceRows(client: Pick<Client, "dataSources">, args: FullDataSourceQueryArgs): AsyncIterableIterator<DataSourceRow>;
|
|
151
151
|
/**
|
|
152
152
|
* Collect every row of a data source into an in-memory array, including rows
|
|
153
153
|
* past the per-query result limit. See {@link iterateAllDataSourceRows} for how
|
|
@@ -169,7 +169,7 @@ export declare function iterateAllDataSourceRows(client: Client, args: FullDataS
|
|
|
169
169
|
* @param client A Notion client instance.
|
|
170
170
|
* @param args Query arguments. See {@link iterateAllDataSourceRows}.
|
|
171
171
|
*/
|
|
172
|
-
export declare function collectAllDataSourceRows(client: Client, args: FullDataSourceQueryArgs): Promise<DataSourceRow[]>;
|
|
172
|
+
export declare function collectAllDataSourceRows(client: Pick<Client, "dataSources">, args: FullDataSourceQueryArgs): Promise<DataSourceRow[]>;
|
|
173
173
|
type ObjectResponse = PageObjectResponse | PartialPageObjectResponse | DataSourceObjectResponse | PartialDataSourceObjectResponse | DatabaseObjectResponse | PartialDatabaseObjectResponse | BlockObjectResponse | PartialBlockObjectResponse;
|
|
174
174
|
/**
|
|
175
175
|
* @returns `true` if `response` is a full `BlockObjectResponse`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,+BAA+B,EAC/B,2BAA2B,EAC3B,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,+BAA+B,EAC/B,mCAAmC,EACnC,yBAAyB,EACzB,yBAAyB,EACzB,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAElC,KAAK,aAAa,GAAG;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,CAAC,EAAE,CAAA;IAC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,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,CAC9D,EAAE,EACF,EAAE,CACH,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAA;AACnD,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,OAAO,eAAe,CAAC,WAAW,CAAC,CAAA;AACrC,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,OAAO,eAAe,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,YAAoB;IACjD,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACtD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,mEAAmE;IACnE,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;IACpE,IAAI,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {\n BlockObjectResponse,\n CommentObjectResponse,\n DatabaseObjectResponse,\n DataSourceObjectResponse,\n DataSourceViewObjectResponse,\n EquationRichTextItemResponse,\n GroupFilterOperatorArray,\n ListDataSourceTemplatesResponse,\n MentionRichTextItemResponse,\n PageObjectResponse,\n PartialBlockObjectResponse,\n PartialCommentObjectResponse,\n PartialDatabaseObjectResponse,\n PartialDataSourceObjectResponse,\n PartialDataSourceViewObjectResponse,\n PartialPageObjectResponse,\n PartialUserObjectResponse,\n PropertyFilter,\n QueryDataSourceParameters,\n QueryDataSourceResponse,\n RichTextItemResponse,\n RichTextItemResponseCommon,\n TextRichTextItemResponse,\n TimestampFilter,\n UserObjectResponse,\n} from \"./api-endpoints\"\nimport type Client from \"./Client\"\n\ntype PaginatedArgs = {\n start_cursor?: string | null\n}\n\ntype PaginatedList<T> = {\n object: \"list\"\n results: T[]\n next_cursor: string | null\n has_more: boolean\n}\n\n/**\n * Returns an async iterator over the results of any paginated Notion API.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const block of iteratePaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })) {\n * // Do something with block.\n * }\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function* iteratePaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): AsyncIterableIterator<Item> {\n let nextCursor: string | null | undefined = firstPageArgs.start_cursor\n do {\n const response: PaginatedList<Item> = await listFn({\n ...firstPageArgs,\n start_cursor: nextCursor,\n })\n yield* response.results\n nextCursor = response.next_cursor\n } while (nextCursor)\n}\n\n/**\n * Collect all of the results of paginating an API into an in-memory array.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const blocks = await collectPaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })\n * // Do something with blocks.\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function collectPaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): Promise<Item[]> {\n const results: Item[] = []\n for await (const item of iteratePaginatedAPI(listFn, firstPageArgs)) {\n results.push(item)\n }\n return results\n}\n\ntype DataSourceTemplate = ListDataSourceTemplatesResponse[\"templates\"][number]\n\ntype ListDataSourceTemplatesArgs = PaginatedArgs & {\n data_source_id: string\n name?: string\n page_size?: number\n}\n\n/**\n * Returns an async iterator over data source templates.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const template of iterateDataSourceTemplates(notion, {\n * data_source_id: dataSourceId,\n * })) {\n * console.log(template.name, template.is_default)\n * }\n * ```\n *\n * @param client A Notion client instance.\n * @param args Arguments including the data_source_id and optional start_cursor.\n */\nexport async function* iterateDataSourceTemplates(\n client: Client,\n args: ListDataSourceTemplatesArgs\n): AsyncIterableIterator<DataSourceTemplate> {\n let nextCursor: string | null | undefined = args.start_cursor\n do {\n const response: ListDataSourceTemplatesResponse =\n await client.dataSources.listTemplates({\n ...args,\n start_cursor: nextCursor,\n })\n yield* response.templates\n nextCursor = response.next_cursor\n } while (nextCursor)\n}\n\n/**\n * Collect all data source templates into an in-memory array.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const templates = await collectDataSourceTemplates(notion, {\n * data_source_id: dataSourceId,\n * })\n * // Do something with templates.\n * ```\n *\n * @param client A Notion client instance.\n * @param args Arguments including the data_source_id and optional start_cursor.\n */\nexport async function collectDataSourceTemplates(\n client: Client,\n args: ListDataSourceTemplatesArgs\n): Promise<DataSourceTemplate[]> {\n const results: DataSourceTemplate[] = []\n for await (const template of iterateDataSourceTemplates(client, args)) {\n results.push(template)\n }\n return results\n}\n\ntype DataSourceRow = QueryDataSourceResponse[\"results\"][number]\n\n/**\n * A filter the full-query helpers can combine with a created_time window bound.\n *\n * A top-level `or` filter is intentionally excluded: the helpers add a\n * created_time lower bound with `and`, and Notion only supports two levels of\n * filter nesting, so an `or` at the root leaves no room for the bound. Express\n * such queries as an `and` group, or run the helper once per `or` branch and\n * merge the results.\n */\nexport type FullDataSourceQueryFilter =\n | PropertyFilter\n | TimestampFilter\n | { and: GroupFilterOperatorArray }\n\n/**\n * Arguments for the full-query helpers. The same as `dataSources.query`, minus\n * the fields the helper controls: `start_cursor` (pagination is automatic) and\n * `sorts` (the helper sorts by created_time to partition). `filter` is narrowed\n * to {@link FullDataSourceQueryFilter}.\n */\nexport type FullDataSourceQueryArgs = Omit<\n QueryDataSourceParameters,\n \"start_cursor\" | \"sorts\" | \"filter\"\n> & {\n filter?: FullDataSourceQueryFilter\n}\n\n/**\n * Iterate over every row of a data source, including rows past the per-query\n * result limit that `dataSources.query` enforces on large data sources.\n *\n * A single query (one filter and sort) returns at most a fixed number of rows\n * (10,000 by default). Once that limit is reached, `has_more` becomes `false`\n * and the response carries `request_status.type === \"incomplete\"`. Plain\n * pagination such as {@link iteratePaginatedAPI} stops there and silently\n * misses the rest of the data source.\n *\n * This helper works around the limit by partitioning the data source into\n * created_time windows. It sorts by created_time ascending; whenever a window\n * reaches the limit, it starts a fresh query from the last row's created_time.\n * Each fresh query has a different filter, so it gets its own result budget.\n * Rows that share a boundary timestamp are de-duplicated by id, so every row is\n * yielded exactly once.\n *\n * created_time is used because it never changes. last_edited_time would shift\n * rows between windows as they are edited, causing gaps or duplicates.\n *\n * Throws if a single created_time value holds more rows than the limit, since\n * the window cannot be narrowed by time alone. Add a filter in that case so\n * each window stays under the limit.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const row of iterateAllDataSourceRows(notion, {\n * data_source_id: dataSourceId,\n * })) {\n * // Do something with row.\n * }\n * ```\n *\n * @param client A Notion client instance.\n * @param args Query arguments. `start_cursor` and `sorts` are managed by the\n * helper; `filter` is combined with the created_time window bound.\n */\nexport async function* iterateAllDataSourceRows(\n client: Client,\n args: FullDataSourceQueryArgs\n): AsyncIterableIterator<DataSourceRow> {\n const seenRowIds = new Set<string>()\n let windowStart: string | undefined = undefined\n\n for (;;) {\n let limitReached = false\n let lastCreatedTime: string | undefined = undefined\n let cursor: string | undefined = undefined\n\n do {\n const response = await client.dataSources.query({\n ...args,\n sorts: [{ timestamp: \"created_time\", direction: \"ascending\" }],\n filter: createdTimeLowerBound(args.filter, windowStart),\n start_cursor: cursor,\n })\n for (const row of response.results) {\n // Wiki data sources can return child data-source rows alongside pages.\n // Both carry created_time and either can be the window's boundary row,\n // so advance on either; reading only pages would stall a window made up\n // of data-source rows and throw spuriously.\n if (isFullPageOrDataSource(row)) {\n lastCreatedTime = row.created_time\n }\n if (!seenRowIds.has(row.id)) {\n seenRowIds.add(row.id)\n yield row\n }\n }\n if (response.request_status?.type === \"incomplete\") {\n limitReached = true\n }\n cursor = response.next_cursor ?? undefined\n } while (cursor)\n\n if (!limitReached) {\n return\n }\n if (lastCreatedTime === undefined || lastCreatedTime === windowStart) {\n throw new Error(\n \"iterateAllDataSourceRows cannot make progress: the per-query result \" +\n \"limit was reached but the created_time window could not advance \" +\n `past ${String(lastCreatedTime)}. More rows share this timestamp ` +\n \"than the limit allows. Add a filter to narrow the query.\"\n )\n }\n windowStart = lastCreatedTime\n }\n}\n\n/**\n * Collect every row of a data source into an in-memory array, including rows\n * past the per-query result limit. See {@link iterateAllDataSourceRows} for how\n * the limit is handled.\n *\n * Before using this, check that the full data source fits in memory. For very\n * large data sources, prefer {@link iterateAllDataSourceRows} and process rows\n * as they stream.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const rows = await collectAllDataSourceRows(notion, {\n * data_source_id: dataSourceId,\n * })\n * // Do something with rows.\n * ```\n *\n * @param client A Notion client instance.\n * @param args Query arguments. See {@link iterateAllDataSourceRows}.\n */\nexport async function collectAllDataSourceRows(\n client: Client,\n args: FullDataSourceQueryArgs\n): Promise<DataSourceRow[]> {\n const rows: DataSourceRow[] = []\n for await (const row of iterateAllDataSourceRows(client, args)) {\n rows.push(row)\n }\n return rows\n}\n\n/**\n * Combine a caller-provided filter with the created_time lower bound used to\n * advance the partition window. Returns the filter unchanged for the first\n * window, which has no bound yet.\n */\nfunction createdTimeLowerBound(\n filter: FullDataSourceQueryFilter | undefined,\n windowStart: string | undefined\n): FullDataSourceQueryFilter | undefined {\n if (windowStart === undefined) {\n return filter\n }\n const bound: TimestampFilter = {\n timestamp: \"created_time\",\n created_time: { on_or_after: windowStart },\n }\n if (filter === undefined) {\n return bound\n }\n if (\"and\" in filter) {\n return { and: [...filter.and, bound] }\n }\n return { and: [filter, bound] }\n}\n\ntype ObjectResponse =\n | PageObjectResponse\n | PartialPageObjectResponse\n | DataSourceObjectResponse\n | PartialDataSourceObjectResponse\n | DatabaseObjectResponse\n | PartialDatabaseObjectResponse\n | BlockObjectResponse\n | PartialBlockObjectResponse\n\n/**\n * @returns `true` if `response` is a full `BlockObjectResponse`.\n */\nexport function isFullBlock(\n response: ObjectResponse\n): response is BlockObjectResponse {\n return response.object === \"block\" && \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `PageObjectResponse`.\n */\nexport function isFullPage(\n response: ObjectResponse\n): response is PageObjectResponse {\n return response.object === \"page\" && \"url\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DataSourceObjectResponse`.\n */\nexport function isFullDataSource(\n response: ObjectResponse\n): response is DataSourceObjectResponse {\n return response.object === \"data_source\" && \"title\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DatabaseObjectResponse`.\n */\nexport function isFullDatabase(\n response: ObjectResponse\n): response is DatabaseObjectResponse {\n return response.object === \"database\" && \"title\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DataSourceObjectResponse` or a full\n * `PageObjectResponse`.\n *\n * Can be used on the results of the list response from `queryDataSource` or\n * `search` APIs.\n */\nexport function isFullPageOrDataSource(\n response: ObjectResponse\n): response is DataSourceObjectResponse | PageObjectResponse {\n if (response.object === \"data_source\") {\n return isFullDataSource(response)\n } else {\n return isFullPage(response)\n }\n}\n\n/**\n * @returns `true` if `response` is a full `UserObjectResponse`.\n */\nexport function isFullUser(\n response: UserObjectResponse | PartialUserObjectResponse\n): response is UserObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `CommentObjectResponse`.\n */\nexport function isFullComment(\n response: CommentObjectResponse | PartialCommentObjectResponse\n): response is CommentObjectResponse {\n return \"created_by\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DataSourceViewObjectResponse`.\n */\nexport function isFullView(\n response: DataSourceViewObjectResponse | PartialDataSourceViewObjectResponse\n): response is DataSourceViewObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `richText` is a `TextRichTextItemResponse`.\n */\nexport function isTextRichTextItemResponse(\n richText: RichTextItemResponse\n): richText is RichTextItemResponseCommon & TextRichTextItemResponse {\n return richText.type === \"text\"\n}\n\n/**\n * @returns `true` if `richText` is an `EquationRichTextItemResponse`.\n */\nexport function isEquationRichTextItemResponse(\n richText: RichTextItemResponse\n): richText is RichTextItemResponseCommon & EquationRichTextItemResponse {\n return richText.type === \"equation\"\n}\n\n/**\n * @returns `true` if `richText` is an `MentionRichTextItemResponse`.\n */\nexport function isMentionRichTextItemResponse(\n richText: RichTextItemResponse\n): richText is RichTextItemResponseCommon & MentionRichTextItemResponse {\n return richText.type === \"mention\"\n}\n\n/**\n * Extracts a Notion ID from a Notion URL or returns the input if it's already a valid ID.\n *\n * Prioritizes path IDs over query parameters to avoid extracting view IDs instead of database IDs.\n *\n * @param urlOrId A Notion URL or ID string\n * @returns The extracted UUID in standard format (with hyphens) or null if invalid\n *\n * @example\n * ```typescript\n * // Database URL with view ID - extracts database ID, not view ID\n * extractNotionId('https://notion.so/workspace/DB-abc123def456789012345678901234ab?v=viewid123')\n * // Returns: 'abc123de-f456-7890-1234-5678901234ab' (database ID)\n *\n * // Already formatted UUID\n * extractNotionId('12345678-1234-1234-1234-123456789abc')\n * // Returns: '12345678-1234-1234-1234-123456789abc'\n * ```\n */\nexport function extractNotionId(urlOrId: string): string | null {\n if (!urlOrId || typeof urlOrId !== \"string\") {\n return null\n }\n\n const trimmed = urlOrId.trim()\n\n // Check if it's already a properly formatted UUID\n const uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n if (uuidRegex.test(trimmed)) {\n return trimmed.toLowerCase()\n }\n\n // Check if it's a compact UUID (32 chars, no hyphens)\n const compactUuidRegex = /^[0-9a-f]{32}$/i\n if (compactUuidRegex.test(trimmed)) {\n return formatUuid(trimmed)\n }\n\n // Extract from URL - prioritize path over query parameters\n // This prevents extracting view IDs when database IDs are in the path\n const pathMatch = trimmed.match(/\\/[^/?#]*-([0-9a-f]{32})(?:[/?#]|$)/i)\n if (pathMatch && pathMatch[1]) {\n return formatUuid(pathMatch[1])\n }\n\n // Fallback to query parameters if no path ID found\n const queryMatch = trimmed.match(\n /[?&](?:p|page_id|database_id)=([0-9a-f]{32})/i\n )\n if (queryMatch && queryMatch[1]) {\n return formatUuid(queryMatch[1])\n }\n\n // Last resort: any 32-char hex string in the URL\n const anyMatch = trimmed.match(/([0-9a-f]{32})/i)\n if (anyMatch && anyMatch[1]) {\n return formatUuid(anyMatch[1])\n }\n\n return null\n}\n\n/**\n * Formats a 32-character hex string into a standard UUID format.\n * @param compactId 32-character hex string without hyphens\n * @returns UUID with hyphens in standard format\n */\nfunction formatUuid(compactId: string): string {\n const clean = compactId.toLowerCase()\n return `${clean.slice(0, 8)}-${clean.slice(8, 12)}-${clean.slice(\n 12,\n 16\n )}-${clean.slice(16, 20)}-${clean.slice(20, 32)}`\n}\n\n/**\n * Extracts a database ID from a Notion database URL.\n * Convenience wrapper around `extractNotionId`.\n */\nexport function extractDatabaseId(databaseUrl: string): string | null {\n return extractNotionId(databaseUrl)\n}\n\n/**\n * Extracts a page ID from a Notion page URL.\n * Convenience wrapper around `extractNotionId`.\n */\nexport function extractPageId(pageUrl: string): string | null {\n return extractNotionId(pageUrl)\n}\n\n/**\n * Extracts a block ID from a Notion URL with a block fragment.\n * Looks for #block-<id> or #<id> patterns.\n */\nexport function extractBlockId(urlWithBlock: string): string | null {\n if (!urlWithBlock || typeof urlWithBlock !== \"string\") {\n return null\n }\n\n // Look for block fragment in URL (#block-32chars or just #32chars)\n const blockMatch = urlWithBlock.match(/#(?:block-)?([0-9a-f]{32})/i)\n if (blockMatch && blockMatch[1]) {\n return formatUuid(blockMatch[1])\n }\n\n return null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;AA2DA,kDAaC;AAoBD,kDASC;AA0BD,gEAcC;AAiBD,gEASC;AAqED,4DAmDC;AAuBD,4DASC;AAwCD,kCAIC;AAKD,gCAIC;AAKD,4CAIC;AAKD,wCAIC;AASD,wDAQC;AAKD,gCAIC;AAKD,sCAIC;AAKD,gCAIC;AAKD,gEAIC;AAKD,wEAIC;AAKD,sEAIC;AAqBD,0CA0CC;AAmBD,8CAEC;AAMD,sCAEC;AAMD,wCAYC;AAnhBD;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,SAAS,CAAC,CAAC,mBAAmB,CACxC,MAAoD,EACpD,aAAmB;IAEnB,IAAI,UAAU,GAA8B,aAAa,CAAC,YAAY,CAAA;IACtE,GAAG,CAAC;QACF,MAAM,QAAQ,GAAwB,MAAM,MAAM,CAAC;YACjD,GAAG,aAAa;YAChB,YAAY,EAAE,UAAU;SACzB,CAAC,CAAA;QACF,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAA;QACvB,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAA;IACnC,CAAC,QAAQ,UAAU,EAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAAoD,EACpD,aAAmB;IAEnB,MAAM,OAAO,GAAW,EAAE,CAAA;IAC1B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,mBAAmB,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAUD;;;;;;;;;;;;;;;GAeG;AACI,KAAK,SAAS,CAAC,CAAC,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CAAC,EAAE,CAAA;AACnD,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,OAAO,eAAe,CAAC,WAAW,CAAC,CAAA;AACrC,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,OAAO,eAAe,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,YAAoB;IACjD,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACtD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,mEAAmE;IACnE,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;IACpE,IAAI,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {\n BlockObjectResponse,\n CommentObjectResponse,\n DatabaseObjectResponse,\n DataSourceObjectResponse,\n DataSourceViewObjectResponse,\n EquationRichTextItemResponse,\n GroupFilterOperatorArray,\n ListDataSourceTemplatesResponse,\n MentionRichTextItemResponse,\n PageObjectResponse,\n PartialBlockObjectResponse,\n PartialCommentObjectResponse,\n PartialDatabaseObjectResponse,\n PartialDataSourceObjectResponse,\n PartialDataSourceViewObjectResponse,\n PartialPageObjectResponse,\n PartialUserObjectResponse,\n PropertyFilter,\n QueryDataSourceParameters,\n QueryDataSourceResponse,\n RichTextItemResponse,\n RichTextItemResponseCommon,\n TextRichTextItemResponse,\n TimestampFilter,\n UserObjectResponse,\n} from \"./api-endpoints\"\nimport type Client from \"./Client\"\n\ntype PaginatedArgs = {\n start_cursor?: string | null\n}\n\ntype PaginatedList<T> = {\n object: \"list\"\n results: T[]\n next_cursor: string | null\n has_more: boolean\n}\n\n/**\n * Returns an async iterator over the results of any paginated Notion API.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const block of iteratePaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })) {\n * // Do something with block.\n * }\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function* iteratePaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): AsyncIterableIterator<Item> {\n let nextCursor: string | null | undefined = firstPageArgs.start_cursor\n do {\n const response: PaginatedList<Item> = await listFn({\n ...firstPageArgs,\n start_cursor: nextCursor,\n })\n yield* response.results\n nextCursor = response.next_cursor\n } while (nextCursor)\n}\n\n/**\n * Collect all of the results of paginating an API into an in-memory array.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const blocks = await collectPaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })\n * // Do something with blocks.\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function collectPaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): Promise<Item[]> {\n const results: Item[] = []\n for await (const item of iteratePaginatedAPI(listFn, firstPageArgs)) {\n results.push(item)\n }\n return results\n}\n\ntype DataSourceTemplate = ListDataSourceTemplatesResponse[\"templates\"][number]\n\ntype ListDataSourceTemplatesArgs = PaginatedArgs & {\n data_source_id: string\n name?: string\n page_size?: number\n}\n\n/**\n * Returns an async iterator over data source templates.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const template of iterateDataSourceTemplates(notion, {\n * data_source_id: dataSourceId,\n * })) {\n * console.log(template.name, template.is_default)\n * }\n * ```\n *\n * @param client A Notion client instance.\n * @param args Arguments including the data_source_id and optional start_cursor.\n */\nexport async function* iterateDataSourceTemplates(\n client: Pick<Client, \"dataSources\">,\n args: ListDataSourceTemplatesArgs\n): AsyncIterableIterator<DataSourceTemplate> {\n let nextCursor: string | null | undefined = args.start_cursor\n do {\n const response: ListDataSourceTemplatesResponse =\n await client.dataSources.listTemplates({\n ...args,\n start_cursor: nextCursor,\n })\n yield* response.templates\n nextCursor = response.next_cursor\n } while (nextCursor)\n}\n\n/**\n * Collect all data source templates into an in-memory array.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const templates = await collectDataSourceTemplates(notion, {\n * data_source_id: dataSourceId,\n * })\n * // Do something with templates.\n * ```\n *\n * @param client A Notion client instance.\n * @param args Arguments including the data_source_id and optional start_cursor.\n */\nexport async function collectDataSourceTemplates(\n client: Pick<Client, \"dataSources\">,\n args: ListDataSourceTemplatesArgs\n): Promise<DataSourceTemplate[]> {\n const results: DataSourceTemplate[] = []\n for await (const template of iterateDataSourceTemplates(client, args)) {\n results.push(template)\n }\n return results\n}\n\ntype DataSourceRow = QueryDataSourceResponse[\"results\"][number]\n\n/**\n * A filter the full-query helpers can combine with a created_time window bound.\n *\n * A top-level `or` filter is intentionally excluded: the helpers add a\n * created_time lower bound with `and`, and Notion only supports two levels of\n * filter nesting, so an `or` at the root leaves no room for the bound. Express\n * such queries as an `and` group, or run the helper once per `or` branch and\n * merge the results.\n */\nexport type FullDataSourceQueryFilter =\n | PropertyFilter\n | TimestampFilter\n | { and: GroupFilterOperatorArray }\n\n/**\n * Arguments for the full-query helpers. The same as `dataSources.query`, minus\n * the fields the helper controls: `start_cursor` (pagination is automatic) and\n * `sorts` (the helper sorts by created_time to partition). `filter` is narrowed\n * to {@link FullDataSourceQueryFilter}.\n */\nexport type FullDataSourceQueryArgs = Omit<\n QueryDataSourceParameters,\n \"start_cursor\" | \"sorts\" | \"filter\"\n> & {\n filter?: FullDataSourceQueryFilter\n}\n\n/**\n * Iterate over every row of a data source, including rows past the per-query\n * result limit that `dataSources.query` enforces on large data sources.\n *\n * A single query (one filter and sort) returns at most a fixed number of rows\n * (10,000 by default). Once that limit is reached, `has_more` becomes `false`\n * and the response carries `request_status.type === \"incomplete\"`. Plain\n * pagination such as {@link iteratePaginatedAPI} stops there and silently\n * misses the rest of the data source.\n *\n * This helper works around the limit by partitioning the data source into\n * created_time windows. It sorts by created_time ascending; whenever a window\n * reaches the limit, it starts a fresh query from the last row's created_time.\n * Each fresh query has a different filter, so it gets its own result budget.\n * Rows that share a boundary timestamp are de-duplicated by id, so every row is\n * yielded exactly once.\n *\n * created_time is used because it never changes. last_edited_time would shift\n * rows between windows as they are edited, causing gaps or duplicates.\n *\n * Throws if a single created_time value holds more rows than the limit, since\n * the window cannot be narrowed by time alone. Add a filter in that case so\n * each window stays under the limit.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const row of iterateAllDataSourceRows(notion, {\n * data_source_id: dataSourceId,\n * })) {\n * // Do something with row.\n * }\n * ```\n *\n * @param client A Notion client instance.\n * @param args Query arguments. `start_cursor` and `sorts` are managed by the\n * helper; `filter` is combined with the created_time window bound.\n */\nexport async function* iterateAllDataSourceRows(\n client: Pick<Client, \"dataSources\">,\n args: FullDataSourceQueryArgs\n): AsyncIterableIterator<DataSourceRow> {\n const seenRowIds = new Set<string>()\n let windowStart: string | undefined = undefined\n\n for (;;) {\n let limitReached = false\n let lastCreatedTime: string | undefined = undefined\n let cursor: string | undefined = undefined\n\n do {\n const response = await client.dataSources.query({\n ...args,\n sorts: [{ timestamp: \"created_time\", direction: \"ascending\" }],\n filter: createdTimeLowerBound(args.filter, windowStart),\n start_cursor: cursor,\n })\n for (const row of response.results) {\n // Wiki data sources can return child data-source rows alongside pages.\n // Both carry created_time and either can be the window's boundary row,\n // so advance on either; reading only pages would stall a window made up\n // of data-source rows and throw spuriously.\n if (isFullPageOrDataSource(row)) {\n lastCreatedTime = row.created_time\n }\n if (!seenRowIds.has(row.id)) {\n seenRowIds.add(row.id)\n yield row\n }\n }\n if (response.request_status?.type === \"incomplete\") {\n limitReached = true\n }\n cursor = response.next_cursor ?? undefined\n } while (cursor)\n\n if (!limitReached) {\n return\n }\n if (lastCreatedTime === undefined || lastCreatedTime === windowStart) {\n throw new Error(\n \"iterateAllDataSourceRows cannot make progress: the per-query result \" +\n \"limit was reached but the created_time window could not advance \" +\n `past ${String(lastCreatedTime)}. More rows share this timestamp ` +\n \"than the limit allows. Add a filter to narrow the query.\"\n )\n }\n windowStart = lastCreatedTime\n }\n}\n\n/**\n * Collect every row of a data source into an in-memory array, including rows\n * past the per-query result limit. See {@link iterateAllDataSourceRows} for how\n * the limit is handled.\n *\n * Before using this, check that the full data source fits in memory. For very\n * large data sources, prefer {@link iterateAllDataSourceRows} and process rows\n * as they stream.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const rows = await collectAllDataSourceRows(notion, {\n * data_source_id: dataSourceId,\n * })\n * // Do something with rows.\n * ```\n *\n * @param client A Notion client instance.\n * @param args Query arguments. See {@link iterateAllDataSourceRows}.\n */\nexport async function collectAllDataSourceRows(\n client: Pick<Client, \"dataSources\">,\n args: FullDataSourceQueryArgs\n): Promise<DataSourceRow[]> {\n const rows: DataSourceRow[] = []\n for await (const row of iterateAllDataSourceRows(client, args)) {\n rows.push(row)\n }\n return rows\n}\n\n/**\n * Combine a caller-provided filter with the created_time lower bound used to\n * advance the partition window. Returns the filter unchanged for the first\n * window, which has no bound yet.\n */\nfunction createdTimeLowerBound(\n filter: FullDataSourceQueryFilter | undefined,\n windowStart: string | undefined\n): FullDataSourceQueryFilter | undefined {\n if (windowStart === undefined) {\n return filter\n }\n const bound: TimestampFilter = {\n timestamp: \"created_time\",\n created_time: { on_or_after: windowStart },\n }\n if (filter === undefined) {\n return bound\n }\n if (\"and\" in filter) {\n return { and: [...filter.and, bound] }\n }\n return { and: [filter, bound] }\n}\n\ntype ObjectResponse =\n | PageObjectResponse\n | PartialPageObjectResponse\n | DataSourceObjectResponse\n | PartialDataSourceObjectResponse\n | DatabaseObjectResponse\n | PartialDatabaseObjectResponse\n | BlockObjectResponse\n | PartialBlockObjectResponse\n\n/**\n * @returns `true` if `response` is a full `BlockObjectResponse`.\n */\nexport function isFullBlock(\n response: ObjectResponse\n): response is BlockObjectResponse {\n return response.object === \"block\" && \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `PageObjectResponse`.\n */\nexport function isFullPage(\n response: ObjectResponse\n): response is PageObjectResponse {\n return response.object === \"page\" && \"url\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DataSourceObjectResponse`.\n */\nexport function isFullDataSource(\n response: ObjectResponse\n): response is DataSourceObjectResponse {\n return response.object === \"data_source\" && \"title\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DatabaseObjectResponse`.\n */\nexport function isFullDatabase(\n response: ObjectResponse\n): response is DatabaseObjectResponse {\n return response.object === \"database\" && \"title\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DataSourceObjectResponse` or a full\n * `PageObjectResponse`.\n *\n * Can be used on the results of the list response from `queryDataSource` or\n * `search` APIs.\n */\nexport function isFullPageOrDataSource(\n response: ObjectResponse\n): response is DataSourceObjectResponse | PageObjectResponse {\n if (response.object === \"data_source\") {\n return isFullDataSource(response)\n } else {\n return isFullPage(response)\n }\n}\n\n/**\n * @returns `true` if `response` is a full `UserObjectResponse`.\n */\nexport function isFullUser(\n response: UserObjectResponse | PartialUserObjectResponse\n): response is UserObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `CommentObjectResponse`.\n */\nexport function isFullComment(\n response: CommentObjectResponse | PartialCommentObjectResponse\n): response is CommentObjectResponse {\n return \"created_by\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DataSourceViewObjectResponse`.\n */\nexport function isFullView(\n response: DataSourceViewObjectResponse | PartialDataSourceViewObjectResponse\n): response is DataSourceViewObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `richText` is a `TextRichTextItemResponse`.\n */\nexport function isTextRichTextItemResponse(\n richText: RichTextItemResponse\n): richText is RichTextItemResponseCommon & TextRichTextItemResponse {\n return richText.type === \"text\"\n}\n\n/**\n * @returns `true` if `richText` is an `EquationRichTextItemResponse`.\n */\nexport function isEquationRichTextItemResponse(\n richText: RichTextItemResponse\n): richText is RichTextItemResponseCommon & EquationRichTextItemResponse {\n return richText.type === \"equation\"\n}\n\n/**\n * @returns `true` if `richText` is an `MentionRichTextItemResponse`.\n */\nexport function isMentionRichTextItemResponse(\n richText: RichTextItemResponse\n): richText is RichTextItemResponseCommon & MentionRichTextItemResponse {\n return richText.type === \"mention\"\n}\n\n/**\n * Extracts a Notion ID from a Notion URL or returns the input if it's already a valid ID.\n *\n * Prioritizes path IDs over query parameters to avoid extracting view IDs instead of database IDs.\n *\n * @param urlOrId A Notion URL or ID string\n * @returns The extracted UUID in standard format (with hyphens) or null if invalid\n *\n * @example\n * ```typescript\n * // Database URL with view ID - extracts database ID, not view ID\n * extractNotionId('https://notion.so/workspace/DB-abc123def456789012345678901234ab?v=viewid123')\n * // Returns: 'abc123de-f456-7890-1234-5678901234ab' (database ID)\n *\n * // Already formatted UUID\n * extractNotionId('12345678-1234-1234-1234-123456789abc')\n * // Returns: '12345678-1234-1234-1234-123456789abc'\n * ```\n */\nexport function extractNotionId(urlOrId: string): string | null {\n if (!urlOrId || typeof urlOrId !== \"string\") {\n return null\n }\n\n const trimmed = urlOrId.trim()\n\n // Check if it's already a properly formatted UUID\n const uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n if (uuidRegex.test(trimmed)) {\n return trimmed.toLowerCase()\n }\n\n // Check if it's a compact UUID (32 chars, no hyphens)\n const compactUuidRegex = /^[0-9a-f]{32}$/i\n if (compactUuidRegex.test(trimmed)) {\n return formatUuid(trimmed)\n }\n\n // Extract from URL - prioritize path over query parameters\n // This prevents extracting view IDs when database IDs are in the path\n const pathMatch = trimmed.match(/\\/[^/?#]*-([0-9a-f]{32})(?:[/?#]|$)/i)\n if (pathMatch && pathMatch[1]) {\n return formatUuid(pathMatch[1])\n }\n\n // Fallback to query parameters if no path ID found\n const queryMatch = trimmed.match(\n /[?&](?:p|page_id|database_id)=([0-9a-f]{32})/i\n )\n if (queryMatch && queryMatch[1]) {\n return formatUuid(queryMatch[1])\n }\n\n // Last resort: any 32-char hex string in the URL\n const anyMatch = trimmed.match(/([0-9a-f]{32})/i)\n if (anyMatch && anyMatch[1]) {\n return formatUuid(anyMatch[1])\n }\n\n return null\n}\n\n/**\n * Formats a 32-character hex string into a standard UUID format.\n * @param compactId 32-character hex string without hyphens\n * @returns UUID with hyphens in standard format\n */\nfunction formatUuid(compactId: string): string {\n const clean = compactId.toLowerCase()\n return `${clean.slice(0, 8)}-${clean.slice(8, 12)}-${clean.slice(\n 12,\n 16\n )}-${clean.slice(16, 20)}-${clean.slice(20, 32)}`\n}\n\n/**\n * Extracts a database ID from a Notion database URL.\n * Convenience wrapper around `extractNotionId`.\n */\nexport function extractDatabaseId(databaseUrl: string): string | null {\n return extractNotionId(databaseUrl)\n}\n\n/**\n * Extracts a page ID from a Notion page URL.\n * Convenience wrapper around `extractNotionId`.\n */\nexport function extractPageId(pageUrl: string): string | null {\n return extractNotionId(pageUrl)\n}\n\n/**\n * Extracts a block ID from a Notion URL with a block fragment.\n * Looks for #block-<id> or #<id> patterns.\n */\nexport function extractBlockId(urlWithBlock: string): string | null {\n if (!urlWithBlock || typeof urlWithBlock !== \"string\") {\n return null\n }\n\n // Look for block fragment in URL (#block-32chars or just #32chars)\n const blockMatch = urlWithBlock.match(/#(?:block-)?([0-9a-f]{32})/i)\n if (blockMatch && blockMatch[1]) {\n return formatUuid(blockMatch[1])\n }\n\n return null\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
import type { RichTextItemResponseCommon } from "./api-endpoints";
|
|
10
|
-
export type { AgentBatchParameters, AgentBatchResponse, ApiColor, AppendBlockChildrenParameters, AppendBlockChildrenResponse, AudioBlockObjectResponse, BlockObjectRequest, BlockObjectResponse, BookmarkBlockObjectResponse, BotUserObjectResponse, BreadcrumbBlockObjectResponse, BulletedListItemBlockObjectResponse, ButtonPropertyItemObjectResponse, CalloutBlockObjectResponse, CancelSessionParameters, CancelSessionResponse, CheckboxPropertyItemObjectResponse, ChildDatabaseBlockObjectResponse, ChildPageBlockObjectResponse, CodeBlockObjectResponse, ColumnBlockObjectResponse, ColumnListBlockObjectResponse, CommentObjectResponse, CompleteFileUploadParameters, CompleteFileUploadResponse, CreateCommentParameters, CreateCommentResponse, CreateDatabaseParameters, CreateDatabaseResponse, CreateDataSourceParameters, CreateDataSourceResponse, CreateViewParameters, CreateViewResponse, CreateViewQueryParameters, CreateViewQueryResponse, DashboardRowResponse, DashboardWidgetResponse, CreatedByPropertyItemObjectResponse, CreatedTimePropertyItemObjectResponse, CreateFileUploadParameters, CreateFileUploadResponse, CreatePageParameters, CreatePageResponse, DatabaseObjectResponse, DataSourceObjectResponse, DataSourceViewObjectResponse, DatePropertyItemObjectResponse, DeleteAgentParameters, DeleteAgentResponse, DeleteBlockParameters, DeleteBlockResponse, DeleteCommentParameters, DeleteCommentResponse, DeletedViewQueryResponse, DeleteViewParameters, DeleteViewResponse, DeleteViewQueryParameters, DeleteViewQueryResponse, DividerBlockObjectResponse, EmailPropertyItemObjectResponse, EmbedBlockObjectResponse, EquationBlockObjectResponse, EquationRichTextItemResponse, FileBlockObjectResponse, FilesPropertyItemObjectResponse, FileUploadObjectResponse, FormulaPropertyItemObjectResponse, GetAsyncTaskParameters, GetAsyncTaskResponse, GetAgentParameters, GetAgentResponse, GetBlockParameters, GetBlockResponse, GetCommentParameters, GetCommentResponse, GetDatabaseParameters, GetDatabaseResponse, GetDataSourceParameters, GetDataSourceResponse, GetFileUploadParameters, GetFileUploadResponse, GetInsightsParameters, GetInsightsResponse, GetPageParameters, GetPagePropertyParameters, GetPagePropertyResponse, GetPageResponse, GetSelfParameters, GetSelfResponse, GetUserParameters, GetUserResponse, GetViewParameters, GetViewResponse, GetViewQueryResultsParameters, GetViewQueryResultsResponse, GroupObjectResponse, Heading1BlockObjectResponse, Heading2BlockObjectResponse, Heading3BlockObjectResponse, ImageBlockObjectResponse, LastEditedByPropertyItemObjectResponse, LastEditedTimePropertyItemObjectResponse, LinkPreviewBlockObjectResponse, LinkToPageBlockObjectResponse, ListBlockChildrenParameters, ListBlockChildrenResponse, ListCommentsParameters, ListCommentsResponse, ListCustomEmojisParameters, ListCustomEmojisResponse, CustomEmojiResponse, ListDatabaseViewsParameters, ListDatabaseViewsResponse, ListFileUploadsParameters, ListFileUploadsResponse, ListUsersParameters, ListUsersResponse, MeetingNotesBlockObjectResponse, MentionRichTextItemResponse, MovePageParameters, MovePageResponse, MultiSelectPropertyItemObjectResponse, NumberedListItemBlockObjectResponse, NumberPropertyItemObjectResponse, OauthIntrospectParameters, OauthIntrospectResponse, OauthRevokeParameters, OauthRevokeResponse, OauthTokenParameters, OauthTokenResponse, PageObjectResponse, ParagraphBlockObjectResponse, PartialBlockObjectResponse, PartialCommentObjectResponse, PartialDatabaseObjectResponse, PartialDataSourceObjectResponse, PartialDataSourceViewObjectResponse, PartialPageObjectResponse, PartialUserObjectResponse, PdfBlockObjectResponse, PeoplePropertyItemObjectResponse, PersonUserObjectResponse, PhoneNumberPropertyItemObjectResponse, PropertyItemListResponse, PropertyItemObjectResponse, PublicApiAsyncTaskStatusResultJsonValue, QueryDataSourceParameters, QueryDataSourceResponse, QueryAgentsParameters, QueryAgentsResponse, QuerySessionEventsParameters, QuerySessionEventsResponse, QuerySessionsParameters, QuerySessionsResponse, QuoteBlockObjectResponse, RelationPropertyItemObjectResponse, RetrieveSessionParameters, RetrieveSessionResponse, RichTextItemResponse, RichTextItemResponseCommon, RichTextPropertyItemObjectResponse, RollupPropertyItemObjectResponse, SearchParameters, SearchResponse, SelectPropertyItemObjectResponse, SendFileUploadParameters, SendFileUploadResponse, StatusPropertyItemObjectResponse, SyncedBlockBlockObjectResponse, TableBlockObjectResponse, TableOfContentsBlockObjectResponse, TableRowBlockObjectResponse, TemplateBlockObjectResponse, TextRichTextItemResponse, TitlePropertyItemObjectResponse, ToDoBlockObjectResponse, ToggleBlockObjectResponse, TranscriptionBlockObjectResponse, UniqueIdPropertyItemObjectResponse, UnsupportedBlockObjectResponse, UpdateBlockParameters, UpdateBlockResponse, UpdateAgentCreditLimitParameters, UpdateAgentCreditLimitResponse, UpdateAgentStatusParameters, UpdateAgentStatusResponse, UpdateCommentParameters, UpdateCommentResponse, UpdateDatabaseParameters, UpdateDatabaseResponse, UpdateDataSourceParameters, UpdateDataSourceResponse, UpdatePageParameters, UpdatePageResponse, UpdateSessionParameters, UpdateSessionResponse, UpdateSessionStreamParameters, UpdateSessionStreamResponse, UpdateViewParameters, UpdateViewResponse, UrlPropertyItemObjectResponse, UserObjectResponse, ViewQueryResponse, VerificationPropertyItemObjectResponse, VideoBlockObjectResponse, BaseWebhookPayload, CommentCreatedWebhookPayload, CommentDeletedWebhookPayload, CommentUpdatedWebhookPayload, DataSourceContentUpdatedWebhookPayload, DataSourceCreatedWebhookPayload, DataSourceDeletedWebhookPayload, DataSourceMovedWebhookPayload, DataSourceSchemaUpdatedWebhookPayload, DataSourceUndeletedWebhookPayload, DatabaseContentUpdatedWebhookPayload, DatabaseCreatedWebhookPayload, DatabaseDeletedWebhookPayload, DatabaseMovedWebhookPayload, DatabaseSchemaUpdatedWebhookPayload, DatabaseUndeletedWebhookPayload, FileUploadCompletedWebhookPayload, FileUploadCreatedWebhookPayload, FileUploadExpiredWebhookPayload, FileUploadUploadFailedWebhookPayload, PageContentUpdatedWebhookPayload, PageCreatedWebhookPayload, PageDeletedWebhookPayload, PageLockedWebhookPayload, PageMovedWebhookPayload, PagePropertiesUpdatedWebhookPayload, PageTranscriptionBlockTranscriptDeletedWebhookPayload, PageUndeletedWebhookPayload, PageUnlockedWebhookPayload, ViewCreatedWebhookPayload, ViewDeletedWebhookPayload, ViewUpdatedWebhookPayload, } from "./api-endpoints";
|
|
10
|
+
export type { GetPluginDirectoryParameters, GetPluginDirectoryResponse, GetSkillDirectoryParameters, GetSkillDirectoryResponse, ListSkillsPluginsParameters, ListSkillsPluginsResponse, AgentBatchParameters, AgentBatchResponse, ApiColor, AppendBlockChildrenParameters, AppendBlockChildrenResponse, AudioBlockObjectResponse, BlockObjectRequest, BlockObjectResponse, BookmarkBlockObjectResponse, BotUserObjectResponse, BreadcrumbBlockObjectResponse, BulletedListItemBlockObjectResponse, ButtonPropertyItemObjectResponse, CalloutBlockObjectResponse, CancelSessionParameters, CancelSessionResponse, CheckboxPropertyItemObjectResponse, ChildDatabaseBlockObjectResponse, ChildPageBlockObjectResponse, CodeBlockObjectResponse, ColumnBlockObjectResponse, ColumnListBlockObjectResponse, CommentObjectResponse, CompleteFileUploadParameters, CompleteFileUploadResponse, CreateCommentParameters, CreateCommentResponse, CreateDatabaseParameters, CreateDatabaseResponse, CreateDataSourceParameters, CreateDataSourceResponse, CreateViewParameters, CreateViewResponse, CreateViewQueryParameters, CreateViewQueryResponse, DashboardRowResponse, DashboardWidgetResponse, CreatedByPropertyItemObjectResponse, CreatedTimePropertyItemObjectResponse, CreateFileUploadParameters, CreateFileUploadResponse, CreatePageParameters, CreatePageResponse, DatabaseObjectResponse, DataSourceObjectResponse, DataSourceViewObjectResponse, DatePropertyItemObjectResponse, DeleteAgentParameters, DeleteAgentResponse, DeleteBlockParameters, DeleteBlockResponse, DeleteCommentParameters, DeleteCommentResponse, DeletedViewQueryResponse, DeleteViewParameters, DeleteViewResponse, DeleteViewQueryParameters, DeleteViewQueryResponse, DividerBlockObjectResponse, EmailPropertyItemObjectResponse, EmbedBlockObjectResponse, EquationBlockObjectResponse, EquationRichTextItemResponse, FileBlockObjectResponse, FilesPropertyItemObjectResponse, FileUploadObjectResponse, FormulaPropertyItemObjectResponse, GetAsyncTaskParameters, GetAsyncTaskResponse, GetAgentParameters, GetAgentResponse, GetBlockParameters, GetBlockResponse, GetCommentParameters, GetCommentResponse, GetDatabaseParameters, GetDatabaseResponse, GetDataSourceParameters, GetDataSourceResponse, GetFileUploadParameters, GetFileUploadResponse, GetInsightsParameters, GetInsightsResponse, GetPageParameters, GetPagePropertyParameters, GetPagePropertyResponse, GetPageResponse, GetSelfParameters, GetSelfResponse, GetUserParameters, GetUserResponse, GetViewParameters, GetViewResponse, GetViewQueryResultsParameters, GetViewQueryResultsResponse, GroupObjectResponse, Heading1BlockObjectResponse, Heading2BlockObjectResponse, Heading3BlockObjectResponse, ImageBlockObjectResponse, LastEditedByPropertyItemObjectResponse, LastEditedTimePropertyItemObjectResponse, LinkPreviewBlockObjectResponse, LinkToPageBlockObjectResponse, ListBlockChildrenParameters, ListBlockChildrenResponse, ListCommentsParameters, ListCommentsResponse, ListCustomEmojisParameters, ListCustomEmojisResponse, CustomEmojiResponse, ListDatabaseViewsParameters, ListDatabaseViewsResponse, ListFileUploadsParameters, ListFileUploadsResponse, ListUsersParameters, ListUsersResponse, MeetingNotesBlockObjectResponse, MentionRichTextItemResponse, MovePageParameters, MovePageResponse, MultiSelectPropertyItemObjectResponse, NumberedListItemBlockObjectResponse, NumberPropertyItemObjectResponse, OauthIntrospectParameters, OauthIntrospectResponse, OauthRevokeParameters, OauthRevokeResponse, OauthTokenParameters, OauthTokenResponse, PageObjectResponse, ParagraphBlockObjectResponse, PartialBlockObjectResponse, PartialCommentObjectResponse, PartialDatabaseObjectResponse, PartialDataSourceObjectResponse, PartialDataSourceViewObjectResponse, PartialPageObjectResponse, PartialUserObjectResponse, PdfBlockObjectResponse, PeoplePropertyItemObjectResponse, PersonUserObjectResponse, PhoneNumberPropertyItemObjectResponse, PropertyItemListResponse, PropertyItemObjectResponse, PublicApiAsyncTaskStatusResultJsonValue, QueryDataSourceParameters, QueryDataSourceResponse, QueryAgentsParameters, QueryAgentsResponse, QuerySessionEventsParameters, QuerySessionEventsResponse, QuerySessionsParameters, QuerySessionsResponse, QuoteBlockObjectResponse, RelationPropertyItemObjectResponse, RetrieveSessionParameters, RetrieveSessionResponse, RichTextItemResponse, RichTextItemResponseCommon, RichTextPropertyItemObjectResponse, RollupPropertyItemObjectResponse, SearchParameters, SearchResponse, SelectPropertyItemObjectResponse, SendFileUploadParameters, SendFileUploadResponse, StatusPropertyItemObjectResponse, SyncedBlockBlockObjectResponse, TableBlockObjectResponse, TableOfContentsBlockObjectResponse, TableRowBlockObjectResponse, TemplateBlockObjectResponse, TextRichTextItemResponse, TitlePropertyItemObjectResponse, ToDoBlockObjectResponse, ToggleBlockObjectResponse, TranscriptionBlockObjectResponse, UniqueIdPropertyItemObjectResponse, UnsupportedBlockObjectResponse, UpdateBlockParameters, UpdateBlockResponse, UpdateAgentCreditLimitParameters, UpdateAgentCreditLimitResponse, UpdateAgentStatusParameters, UpdateAgentStatusResponse, UpdateCommentParameters, UpdateCommentResponse, UpdateDatabaseParameters, UpdateDatabaseResponse, UpdateDataSourceParameters, UpdateDataSourceResponse, UpdatePageParameters, UpdatePageResponse, UpdateSessionParameters, UpdateSessionResponse, UpdateSessionStreamParameters, UpdateSessionStreamResponse, UpdateViewParameters, UpdateViewResponse, UrlPropertyItemObjectResponse, UserObjectResponse, ViewQueryResponse, VerificationPropertyItemObjectResponse, VideoBlockObjectResponse, BaseWebhookPayload, CommentCreatedWebhookPayload, CommentDeletedWebhookPayload, CommentUpdatedWebhookPayload, DataSourceContentUpdatedWebhookPayload, DataSourceCreatedWebhookPayload, DataSourceDeletedWebhookPayload, DataSourceMovedWebhookPayload, DataSourceSchemaUpdatedWebhookPayload, DataSourceUndeletedWebhookPayload, DatabaseContentUpdatedWebhookPayload, DatabaseCreatedWebhookPayload, DatabaseDeletedWebhookPayload, DatabaseMovedWebhookPayload, DatabaseSchemaUpdatedWebhookPayload, DatabaseUndeletedWebhookPayload, FileUploadCompletedWebhookPayload, FileUploadCreatedWebhookPayload, FileUploadExpiredWebhookPayload, FileUploadUploadFailedWebhookPayload, PageContentUpdatedWebhookPayload, PageCreatedWebhookPayload, PageDeletedWebhookPayload, PageLockedWebhookPayload, PageMovedWebhookPayload, PagePropertiesUpdatedWebhookPayload, PageTranscriptionBlockTranscriptDeletedWebhookPayload, PageUndeletedWebhookPayload, PageUnlockedWebhookPayload, ViewCreatedWebhookPayload, ViewDeletedWebhookPayload, ViewUpdatedWebhookPayload, } from "./api-endpoints";
|
|
11
11
|
export type AnnotationResponse = RichTextItemResponseCommon["annotations"];
|
|
12
12
|
export { default as Client } from "./Client";
|
|
13
13
|
export { LogLevel, Logger } from "./logging";
|
|
14
|
-
export { NotionErrorCode, APIErrorCode, ClientErrorCode, NotionClientError, APIResponseError, UnknownHTTPResponseError, RequestTimeoutError, InvalidPathParameterError, isNotionClientError, isHTTPResponseError, } from "./errors";
|
|
14
|
+
export { NotionErrorCode, APIErrorCode, ClientErrorCode, NotionClientError, APIResponseError, UnknownHTTPResponseError, RequestTimeoutError, InvalidPathParameterError, BrowserTokenNotAllowedError, isNotionClientError, isHTTPResponseError, } from "./errors";
|
|
15
15
|
export type { RetryOptions } from "./Client";
|
|
16
16
|
export { DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_INITIAL_RETRY_DELAY_MS, DEFAULT_MAX_RETRY_DELAY_MS, MIN_VIEW_COLUMN_WIDTH, } from "./constants";
|
|
17
17
|
export { collectPaginatedAPI, iteratePaginatedAPI, collectDataSourceTemplates, iterateDataSourceTemplates, iterateAllDataSourceRows, collectAllDataSourceRows, isFullBlock, isFullDataSource, isFullDatabase, isFullPage, isFullUser, isFullComment, isFullView, isFullPageOrDataSource, extractNotionId, extractDatabaseId, extractPageId, extractBlockId, } from "./helpers";
|
package/build/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAEjE,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,EACrB,6BAA6B,EAC7B,mCAAmC,EACnC,gCAAgC,EAChC,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,kCAAkC,EAClC,gCAAgC,EAChC,4BAA4B,EAC5B,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,mCAAmC,EACnC,qCAAqC,EACrC,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,8BAA8B,EAC9B,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,+BAA+B,EAC/B,wBAAwB,EACxB,iCAAiC,EACjC,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,gB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B,GAC1B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACvE,YAAY,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAC5D,YAAY,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAC9E,YAAY,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAA"}
|
package/build/src/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.meetingNotesFilterableProperties = exports.signWebhookPayload = exports.verifyWebhookSignature = exports.extractBlockId = exports.extractPageId = exports.extractDatabaseId = exports.extractNotionId = exports.isFullPageOrDataSource = exports.isFullView = exports.isFullComment = exports.isFullUser = exports.isFullPage = exports.isFullDatabase = exports.isFullDataSource = exports.isFullBlock = exports.collectAllDataSourceRows = exports.iterateAllDataSourceRows = exports.iterateDataSourceTemplates = exports.collectDataSourceTemplates = exports.iteratePaginatedAPI = exports.collectPaginatedAPI = exports.MIN_VIEW_COLUMN_WIDTH = exports.DEFAULT_MAX_RETRY_DELAY_MS = exports.DEFAULT_INITIAL_RETRY_DELAY_MS = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_BASE_URL = exports.isHTTPResponseError = exports.isNotionClientError = exports.InvalidPathParameterError = exports.RequestTimeoutError = exports.UnknownHTTPResponseError = exports.APIResponseError = exports.ClientErrorCode = exports.APIErrorCode = exports.LogLevel = exports.Client = void 0;
|
|
11
|
+
exports.meetingNotesFilterableProperties = exports.signWebhookPayload = exports.verifyWebhookSignature = exports.extractBlockId = exports.extractPageId = exports.extractDatabaseId = exports.extractNotionId = exports.isFullPageOrDataSource = exports.isFullView = exports.isFullComment = exports.isFullUser = exports.isFullPage = exports.isFullDatabase = exports.isFullDataSource = exports.isFullBlock = exports.collectAllDataSourceRows = exports.iterateAllDataSourceRows = exports.iterateDataSourceTemplates = exports.collectDataSourceTemplates = exports.iteratePaginatedAPI = exports.collectPaginatedAPI = exports.MIN_VIEW_COLUMN_WIDTH = exports.DEFAULT_MAX_RETRY_DELAY_MS = exports.DEFAULT_INITIAL_RETRY_DELAY_MS = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_BASE_URL = exports.isHTTPResponseError = exports.isNotionClientError = exports.BrowserTokenNotAllowedError = exports.InvalidPathParameterError = exports.RequestTimeoutError = exports.UnknownHTTPResponseError = exports.APIResponseError = exports.ClientErrorCode = exports.APIErrorCode = exports.LogLevel = exports.Client = void 0;
|
|
12
12
|
var Client_1 = require("./Client");
|
|
13
13
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.default; } });
|
|
14
14
|
var logging_1 = require("./logging");
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "APIResponseError", { enumerable: true, get: func
|
|
|
20
20
|
Object.defineProperty(exports, "UnknownHTTPResponseError", { enumerable: true, get: function () { return errors_1.UnknownHTTPResponseError; } });
|
|
21
21
|
Object.defineProperty(exports, "RequestTimeoutError", { enumerable: true, get: function () { return errors_1.RequestTimeoutError; } });
|
|
22
22
|
Object.defineProperty(exports, "InvalidPathParameterError", { enumerable: true, get: function () { return errors_1.InvalidPathParameterError; } });
|
|
23
|
+
Object.defineProperty(exports, "BrowserTokenNotAllowedError", { enumerable: true, get: function () { return errors_1.BrowserTokenNotAllowedError; } });
|
|
23
24
|
// Error helpers
|
|
24
25
|
Object.defineProperty(exports, "isNotionClientError", { enumerable: true, get: function () { return errors_1.isNotionClientError; } });
|
|
25
26
|
Object.defineProperty(exports, "isHTTPResponseError", { enumerable: true, get: function () { return errors_1.isHTTPResponseError; } });
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAqPH,mCAA4C;AAAnC,gGAAA,OAAO,OAAU;AAC1B,qCAA4C;AAAnC,mGAAA,QAAQ,OAAA;AACjB,mCAciB;AAXf,sGAAA,YAAY,OAAA;AACZ,yGAAA,eAAe,OAAA;AAGf,0GAAA,gBAAgB,OAAA;AAChB,kHAAA,wBAAwB,OAAA;AACxB,6GAAA,mBAAmB,OAAA;AACnB,mHAAA,yBAAyB,OAAA;AACzB,gBAAgB;AAChB,6GAAA,mBAAmB,OAAA;AACnB,6GAAA,mBAAmB,OAAA;AAGrB,yCAOoB;AANlB,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AACnB,2HAAA,8BAA8B,OAAA;AAC9B,uHAAA,0BAA0B,OAAA;AAC1B,kHAAA,qBAAqB,OAAA;AAEvB,qCAmBkB;AAlBhB,8GAAA,mBAAmB,OAAA;AACnB,8GAAA,mBAAmB,OAAA;AACnB,qHAAA,0BAA0B,OAAA;AAC1B,qHAAA,0BAA0B,OAAA;AAC1B,mHAAA,wBAAwB,OAAA;AACxB,mHAAA,wBAAwB,OAAA;AACxB,sGAAA,WAAW,OAAA;AACX,2GAAA,gBAAgB,OAAA;AAChB,yGAAA,cAAc,OAAA;AACd,qGAAA,UAAU,OAAA;AACV,qGAAA,UAAU,OAAA;AACV,wGAAA,aAAa,OAAA;AACb,qGAAA,UAAU,OAAA;AACV,iHAAA,sBAAsB,OAAA;AACtB,0GAAA,eAAe,OAAA;AACf,4GAAA,iBAAiB,OAAA;AACjB,wGAAA,aAAa,OAAA;AACb,yGAAA,cAAc,OAAA;AAMhB,uCAAuE;AAA9D,kHAAA,sBAAsB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAWnD,iDAAkE;AAAzD,iIAAA,gCAAgC,OAAA","sourcesContent":["/**\n * index.ts\n *\n * This file is the entry point for the Notion SDK.\n * It exports the Client class and all the API endpoints.\n *\n * @packageDocumentation\n */\n\nimport type { RichTextItemResponseCommon } from \"./api-endpoints\"\n\nexport type {\n AgentBatchParameters,\n AgentBatchResponse,\n ApiColor,\n AppendBlockChildrenParameters,\n AppendBlockChildrenResponse,\n AudioBlockObjectResponse,\n BlockObjectRequest,\n BlockObjectResponse,\n BookmarkBlockObjectResponse,\n BotUserObjectResponse,\n BreadcrumbBlockObjectResponse,\n BulletedListItemBlockObjectResponse,\n ButtonPropertyItemObjectResponse,\n CalloutBlockObjectResponse,\n CancelSessionParameters,\n CancelSessionResponse,\n CheckboxPropertyItemObjectResponse,\n ChildDatabaseBlockObjectResponse,\n ChildPageBlockObjectResponse,\n CodeBlockObjectResponse,\n ColumnBlockObjectResponse,\n ColumnListBlockObjectResponse,\n CommentObjectResponse,\n CompleteFileUploadParameters,\n CompleteFileUploadResponse,\n CreateCommentParameters,\n CreateCommentResponse,\n CreateDatabaseParameters,\n CreateDatabaseResponse,\n CreateDataSourceParameters,\n CreateDataSourceResponse,\n CreateViewParameters,\n CreateViewResponse,\n CreateViewQueryParameters,\n CreateViewQueryResponse,\n DashboardRowResponse,\n DashboardWidgetResponse,\n CreatedByPropertyItemObjectResponse,\n CreatedTimePropertyItemObjectResponse,\n CreateFileUploadParameters,\n CreateFileUploadResponse,\n CreatePageParameters,\n CreatePageResponse,\n DatabaseObjectResponse,\n DataSourceObjectResponse,\n DataSourceViewObjectResponse,\n DatePropertyItemObjectResponse,\n DeleteAgentParameters,\n DeleteAgentResponse,\n DeleteBlockParameters,\n DeleteBlockResponse,\n DeleteCommentParameters,\n DeleteCommentResponse,\n DeletedViewQueryResponse,\n DeleteViewParameters,\n DeleteViewResponse,\n DeleteViewQueryParameters,\n DeleteViewQueryResponse,\n DividerBlockObjectResponse,\n EmailPropertyItemObjectResponse,\n EmbedBlockObjectResponse,\n EquationBlockObjectResponse,\n EquationRichTextItemResponse,\n FileBlockObjectResponse,\n FilesPropertyItemObjectResponse,\n FileUploadObjectResponse,\n FormulaPropertyItemObjectResponse,\n GetAsyncTaskParameters,\n GetAsyncTaskResponse,\n GetAgentParameters,\n GetAgentResponse,\n GetBlockParameters,\n GetBlockResponse,\n GetCommentParameters,\n GetCommentResponse,\n GetDatabaseParameters,\n GetDatabaseResponse,\n GetDataSourceParameters,\n GetDataSourceResponse,\n GetFileUploadParameters,\n GetFileUploadResponse,\n GetInsightsParameters,\n GetInsightsResponse,\n GetPageParameters,\n GetPagePropertyParameters,\n GetPagePropertyResponse,\n GetPageResponse,\n GetSelfParameters,\n GetSelfResponse,\n GetUserParameters,\n GetUserResponse,\n GetViewParameters,\n GetViewResponse,\n GetViewQueryResultsParameters,\n GetViewQueryResultsResponse,\n GroupObjectResponse,\n Heading1BlockObjectResponse,\n Heading2BlockObjectResponse,\n Heading3BlockObjectResponse,\n ImageBlockObjectResponse,\n LastEditedByPropertyItemObjectResponse,\n LastEditedTimePropertyItemObjectResponse,\n LinkPreviewBlockObjectResponse,\n LinkToPageBlockObjectResponse,\n ListBlockChildrenParameters,\n ListBlockChildrenResponse,\n ListCommentsParameters,\n ListCommentsResponse,\n ListCustomEmojisParameters,\n ListCustomEmojisResponse,\n CustomEmojiResponse,\n ListDatabaseViewsParameters,\n ListDatabaseViewsResponse,\n ListFileUploadsParameters,\n ListFileUploadsResponse,\n ListUsersParameters,\n ListUsersResponse,\n MeetingNotesBlockObjectResponse,\n MentionRichTextItemResponse,\n MovePageParameters,\n MovePageResponse,\n MultiSelectPropertyItemObjectResponse,\n NumberedListItemBlockObjectResponse,\n NumberPropertyItemObjectResponse,\n OauthIntrospectParameters,\n OauthIntrospectResponse,\n OauthRevokeParameters,\n OauthRevokeResponse,\n OauthTokenParameters,\n OauthTokenResponse,\n PageObjectResponse,\n ParagraphBlockObjectResponse,\n PartialBlockObjectResponse,\n PartialCommentObjectResponse,\n PartialDatabaseObjectResponse,\n PartialDataSourceObjectResponse,\n PartialDataSourceViewObjectResponse,\n PartialPageObjectResponse,\n PartialUserObjectResponse,\n PdfBlockObjectResponse,\n PeoplePropertyItemObjectResponse,\n PersonUserObjectResponse,\n PhoneNumberPropertyItemObjectResponse,\n PropertyItemListResponse,\n PropertyItemObjectResponse,\n PublicApiAsyncTaskStatusResultJsonValue,\n QueryDataSourceParameters,\n QueryDataSourceResponse,\n QueryAgentsParameters,\n QueryAgentsResponse,\n QuerySessionEventsParameters,\n QuerySessionEventsResponse,\n QuerySessionsParameters,\n QuerySessionsResponse,\n QuoteBlockObjectResponse,\n RelationPropertyItemObjectResponse,\n RetrieveSessionParameters,\n RetrieveSessionResponse,\n RichTextItemResponse,\n RichTextItemResponseCommon,\n RichTextPropertyItemObjectResponse,\n RollupPropertyItemObjectResponse,\n SearchParameters,\n SearchResponse,\n SelectPropertyItemObjectResponse,\n SendFileUploadParameters,\n SendFileUploadResponse,\n StatusPropertyItemObjectResponse,\n SyncedBlockBlockObjectResponse,\n TableBlockObjectResponse,\n TableOfContentsBlockObjectResponse,\n TableRowBlockObjectResponse,\n TemplateBlockObjectResponse,\n TextRichTextItemResponse,\n TitlePropertyItemObjectResponse,\n ToDoBlockObjectResponse,\n ToggleBlockObjectResponse,\n TranscriptionBlockObjectResponse,\n UniqueIdPropertyItemObjectResponse,\n UnsupportedBlockObjectResponse,\n UpdateBlockParameters,\n UpdateBlockResponse,\n UpdateAgentCreditLimitParameters,\n UpdateAgentCreditLimitResponse,\n UpdateAgentStatusParameters,\n UpdateAgentStatusResponse,\n UpdateCommentParameters,\n UpdateCommentResponse,\n UpdateDatabaseParameters,\n UpdateDatabaseResponse,\n UpdateDataSourceParameters,\n UpdateDataSourceResponse,\n UpdatePageParameters,\n UpdatePageResponse,\n UpdateSessionParameters,\n UpdateSessionResponse,\n UpdateSessionStreamParameters,\n UpdateSessionStreamResponse,\n UpdateViewParameters,\n UpdateViewResponse,\n UrlPropertyItemObjectResponse,\n UserObjectResponse,\n ViewQueryResponse,\n VerificationPropertyItemObjectResponse,\n VideoBlockObjectResponse,\n // Webhook payload types\n BaseWebhookPayload,\n CommentCreatedWebhookPayload,\n CommentDeletedWebhookPayload,\n CommentUpdatedWebhookPayload,\n DataSourceContentUpdatedWebhookPayload,\n DataSourceCreatedWebhookPayload,\n DataSourceDeletedWebhookPayload,\n DataSourceMovedWebhookPayload,\n DataSourceSchemaUpdatedWebhookPayload,\n DataSourceUndeletedWebhookPayload,\n DatabaseContentUpdatedWebhookPayload,\n DatabaseCreatedWebhookPayload,\n DatabaseDeletedWebhookPayload,\n DatabaseMovedWebhookPayload,\n DatabaseSchemaUpdatedWebhookPayload,\n DatabaseUndeletedWebhookPayload,\n FileUploadCompletedWebhookPayload,\n FileUploadCreatedWebhookPayload,\n FileUploadExpiredWebhookPayload,\n FileUploadUploadFailedWebhookPayload,\n PageContentUpdatedWebhookPayload,\n PageCreatedWebhookPayload,\n PageDeletedWebhookPayload,\n PageLockedWebhookPayload,\n PageMovedWebhookPayload,\n PagePropertiesUpdatedWebhookPayload,\n PageTranscriptionBlockTranscriptDeletedWebhookPayload,\n PageUndeletedWebhookPayload,\n PageUnlockedWebhookPayload,\n ViewCreatedWebhookPayload,\n ViewDeletedWebhookPayload,\n ViewUpdatedWebhookPayload,\n} from \"./api-endpoints\"\nexport type AnnotationResponse = RichTextItemResponseCommon[\"annotations\"]\nexport { default as Client } from \"./Client\"\nexport { LogLevel, Logger } from \"./logging\"\nexport {\n // Error codes\n NotionErrorCode,\n APIErrorCode,\n ClientErrorCode,\n // Error types\n NotionClientError,\n APIResponseError,\n UnknownHTTPResponseError,\n RequestTimeoutError,\n InvalidPathParameterError,\n // Error helpers\n isNotionClientError,\n isHTTPResponseError,\n} from \"./errors\"\nexport type { RetryOptions } from \"./Client\"\nexport {\n DEFAULT_BASE_URL,\n DEFAULT_TIMEOUT_MS,\n DEFAULT_MAX_RETRIES,\n DEFAULT_INITIAL_RETRY_DELAY_MS,\n DEFAULT_MAX_RETRY_DELAY_MS,\n MIN_VIEW_COLUMN_WIDTH,\n} from \"./constants\"\nexport {\n collectPaginatedAPI,\n iteratePaginatedAPI,\n collectDataSourceTemplates,\n iterateDataSourceTemplates,\n iterateAllDataSourceRows,\n collectAllDataSourceRows,\n isFullBlock,\n isFullDataSource,\n isFullDatabase,\n isFullPage,\n isFullUser,\n isFullComment,\n isFullView,\n isFullPageOrDataSource,\n extractNotionId,\n extractDatabaseId,\n extractPageId,\n extractBlockId,\n} from \"./helpers\"\nexport type {\n FullDataSourceQueryArgs,\n FullDataSourceQueryFilter,\n} from \"./helpers\"\nexport { verifyWebhookSignature, signWebhookPayload } from \"./webhooks\"\nexport type { VerifyWebhookSignatureArgs } from \"./webhooks\"\nexport type { QueryMeetingNotesResponse } from \"./api-endpoints/meeting-notes\"\nexport type {\n QueryMeetingNotesParameters,\n MeetingNotesCombinatorFilter,\n MeetingNotesFilterNode,\n MeetingNotesPropertyFilter,\n MeetingNotesPropertyName,\n MeetingNotesSort,\n} from \"./meeting-notes\"\nexport { meetingNotesFilterableProperties } from \"./meeting-notes\"\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA2PH,mCAA4C;AAAnC,gGAAA,OAAO,OAAU;AAC1B,qCAA4C;AAAnC,mGAAA,QAAQ,OAAA;AACjB,mCAeiB;AAZf,sGAAA,YAAY,OAAA;AACZ,yGAAA,eAAe,OAAA;AAGf,0GAAA,gBAAgB,OAAA;AAChB,kHAAA,wBAAwB,OAAA;AACxB,6GAAA,mBAAmB,OAAA;AACnB,mHAAA,yBAAyB,OAAA;AACzB,qHAAA,2BAA2B,OAAA;AAC3B,gBAAgB;AAChB,6GAAA,mBAAmB,OAAA;AACnB,6GAAA,mBAAmB,OAAA;AAGrB,yCAOoB;AANlB,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AACnB,2HAAA,8BAA8B,OAAA;AAC9B,uHAAA,0BAA0B,OAAA;AAC1B,kHAAA,qBAAqB,OAAA;AAEvB,qCAmBkB;AAlBhB,8GAAA,mBAAmB,OAAA;AACnB,8GAAA,mBAAmB,OAAA;AACnB,qHAAA,0BAA0B,OAAA;AAC1B,qHAAA,0BAA0B,OAAA;AAC1B,mHAAA,wBAAwB,OAAA;AACxB,mHAAA,wBAAwB,OAAA;AACxB,sGAAA,WAAW,OAAA;AACX,2GAAA,gBAAgB,OAAA;AAChB,yGAAA,cAAc,OAAA;AACd,qGAAA,UAAU,OAAA;AACV,qGAAA,UAAU,OAAA;AACV,wGAAA,aAAa,OAAA;AACb,qGAAA,UAAU,OAAA;AACV,iHAAA,sBAAsB,OAAA;AACtB,0GAAA,eAAe,OAAA;AACf,4GAAA,iBAAiB,OAAA;AACjB,wGAAA,aAAa,OAAA;AACb,yGAAA,cAAc,OAAA;AAMhB,uCAAuE;AAA9D,kHAAA,sBAAsB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAWnD,iDAAkE;AAAzD,iIAAA,gCAAgC,OAAA","sourcesContent":["/**\n * index.ts\n *\n * This file is the entry point for the Notion SDK.\n * It exports the Client class and all the API endpoints.\n *\n * @packageDocumentation\n */\n\nimport type { RichTextItemResponseCommon } from \"./api-endpoints\"\n\nexport type {\n GetPluginDirectoryParameters,\n GetPluginDirectoryResponse,\n GetSkillDirectoryParameters,\n GetSkillDirectoryResponse,\n ListSkillsPluginsParameters,\n ListSkillsPluginsResponse,\n AgentBatchParameters,\n AgentBatchResponse,\n ApiColor,\n AppendBlockChildrenParameters,\n AppendBlockChildrenResponse,\n AudioBlockObjectResponse,\n BlockObjectRequest,\n BlockObjectResponse,\n BookmarkBlockObjectResponse,\n BotUserObjectResponse,\n BreadcrumbBlockObjectResponse,\n BulletedListItemBlockObjectResponse,\n ButtonPropertyItemObjectResponse,\n CalloutBlockObjectResponse,\n CancelSessionParameters,\n CancelSessionResponse,\n CheckboxPropertyItemObjectResponse,\n ChildDatabaseBlockObjectResponse,\n ChildPageBlockObjectResponse,\n CodeBlockObjectResponse,\n ColumnBlockObjectResponse,\n ColumnListBlockObjectResponse,\n CommentObjectResponse,\n CompleteFileUploadParameters,\n CompleteFileUploadResponse,\n CreateCommentParameters,\n CreateCommentResponse,\n CreateDatabaseParameters,\n CreateDatabaseResponse,\n CreateDataSourceParameters,\n CreateDataSourceResponse,\n CreateViewParameters,\n CreateViewResponse,\n CreateViewQueryParameters,\n CreateViewQueryResponse,\n DashboardRowResponse,\n DashboardWidgetResponse,\n CreatedByPropertyItemObjectResponse,\n CreatedTimePropertyItemObjectResponse,\n CreateFileUploadParameters,\n CreateFileUploadResponse,\n CreatePageParameters,\n CreatePageResponse,\n DatabaseObjectResponse,\n DataSourceObjectResponse,\n DataSourceViewObjectResponse,\n DatePropertyItemObjectResponse,\n DeleteAgentParameters,\n DeleteAgentResponse,\n DeleteBlockParameters,\n DeleteBlockResponse,\n DeleteCommentParameters,\n DeleteCommentResponse,\n DeletedViewQueryResponse,\n DeleteViewParameters,\n DeleteViewResponse,\n DeleteViewQueryParameters,\n DeleteViewQueryResponse,\n DividerBlockObjectResponse,\n EmailPropertyItemObjectResponse,\n EmbedBlockObjectResponse,\n EquationBlockObjectResponse,\n EquationRichTextItemResponse,\n FileBlockObjectResponse,\n FilesPropertyItemObjectResponse,\n FileUploadObjectResponse,\n FormulaPropertyItemObjectResponse,\n GetAsyncTaskParameters,\n GetAsyncTaskResponse,\n GetAgentParameters,\n GetAgentResponse,\n GetBlockParameters,\n GetBlockResponse,\n GetCommentParameters,\n GetCommentResponse,\n GetDatabaseParameters,\n GetDatabaseResponse,\n GetDataSourceParameters,\n GetDataSourceResponse,\n GetFileUploadParameters,\n GetFileUploadResponse,\n GetInsightsParameters,\n GetInsightsResponse,\n GetPageParameters,\n GetPagePropertyParameters,\n GetPagePropertyResponse,\n GetPageResponse,\n GetSelfParameters,\n GetSelfResponse,\n GetUserParameters,\n GetUserResponse,\n GetViewParameters,\n GetViewResponse,\n GetViewQueryResultsParameters,\n GetViewQueryResultsResponse,\n GroupObjectResponse,\n Heading1BlockObjectResponse,\n Heading2BlockObjectResponse,\n Heading3BlockObjectResponse,\n ImageBlockObjectResponse,\n LastEditedByPropertyItemObjectResponse,\n LastEditedTimePropertyItemObjectResponse,\n LinkPreviewBlockObjectResponse,\n LinkToPageBlockObjectResponse,\n ListBlockChildrenParameters,\n ListBlockChildrenResponse,\n ListCommentsParameters,\n ListCommentsResponse,\n ListCustomEmojisParameters,\n ListCustomEmojisResponse,\n CustomEmojiResponse,\n ListDatabaseViewsParameters,\n ListDatabaseViewsResponse,\n ListFileUploadsParameters,\n ListFileUploadsResponse,\n ListUsersParameters,\n ListUsersResponse,\n MeetingNotesBlockObjectResponse,\n MentionRichTextItemResponse,\n MovePageParameters,\n MovePageResponse,\n MultiSelectPropertyItemObjectResponse,\n NumberedListItemBlockObjectResponse,\n NumberPropertyItemObjectResponse,\n OauthIntrospectParameters,\n OauthIntrospectResponse,\n OauthRevokeParameters,\n OauthRevokeResponse,\n OauthTokenParameters,\n OauthTokenResponse,\n PageObjectResponse,\n ParagraphBlockObjectResponse,\n PartialBlockObjectResponse,\n PartialCommentObjectResponse,\n PartialDatabaseObjectResponse,\n PartialDataSourceObjectResponse,\n PartialDataSourceViewObjectResponse,\n PartialPageObjectResponse,\n PartialUserObjectResponse,\n PdfBlockObjectResponse,\n PeoplePropertyItemObjectResponse,\n PersonUserObjectResponse,\n PhoneNumberPropertyItemObjectResponse,\n PropertyItemListResponse,\n PropertyItemObjectResponse,\n PublicApiAsyncTaskStatusResultJsonValue,\n QueryDataSourceParameters,\n QueryDataSourceResponse,\n QueryAgentsParameters,\n QueryAgentsResponse,\n QuerySessionEventsParameters,\n QuerySessionEventsResponse,\n QuerySessionsParameters,\n QuerySessionsResponse,\n QuoteBlockObjectResponse,\n RelationPropertyItemObjectResponse,\n RetrieveSessionParameters,\n RetrieveSessionResponse,\n RichTextItemResponse,\n RichTextItemResponseCommon,\n RichTextPropertyItemObjectResponse,\n RollupPropertyItemObjectResponse,\n SearchParameters,\n SearchResponse,\n SelectPropertyItemObjectResponse,\n SendFileUploadParameters,\n SendFileUploadResponse,\n StatusPropertyItemObjectResponse,\n SyncedBlockBlockObjectResponse,\n TableBlockObjectResponse,\n TableOfContentsBlockObjectResponse,\n TableRowBlockObjectResponse,\n TemplateBlockObjectResponse,\n TextRichTextItemResponse,\n TitlePropertyItemObjectResponse,\n ToDoBlockObjectResponse,\n ToggleBlockObjectResponse,\n TranscriptionBlockObjectResponse,\n UniqueIdPropertyItemObjectResponse,\n UnsupportedBlockObjectResponse,\n UpdateBlockParameters,\n UpdateBlockResponse,\n UpdateAgentCreditLimitParameters,\n UpdateAgentCreditLimitResponse,\n UpdateAgentStatusParameters,\n UpdateAgentStatusResponse,\n UpdateCommentParameters,\n UpdateCommentResponse,\n UpdateDatabaseParameters,\n UpdateDatabaseResponse,\n UpdateDataSourceParameters,\n UpdateDataSourceResponse,\n UpdatePageParameters,\n UpdatePageResponse,\n UpdateSessionParameters,\n UpdateSessionResponse,\n UpdateSessionStreamParameters,\n UpdateSessionStreamResponse,\n UpdateViewParameters,\n UpdateViewResponse,\n UrlPropertyItemObjectResponse,\n UserObjectResponse,\n ViewQueryResponse,\n VerificationPropertyItemObjectResponse,\n VideoBlockObjectResponse,\n // Webhook payload types\n BaseWebhookPayload,\n CommentCreatedWebhookPayload,\n CommentDeletedWebhookPayload,\n CommentUpdatedWebhookPayload,\n DataSourceContentUpdatedWebhookPayload,\n DataSourceCreatedWebhookPayload,\n DataSourceDeletedWebhookPayload,\n DataSourceMovedWebhookPayload,\n DataSourceSchemaUpdatedWebhookPayload,\n DataSourceUndeletedWebhookPayload,\n DatabaseContentUpdatedWebhookPayload,\n DatabaseCreatedWebhookPayload,\n DatabaseDeletedWebhookPayload,\n DatabaseMovedWebhookPayload,\n DatabaseSchemaUpdatedWebhookPayload,\n DatabaseUndeletedWebhookPayload,\n FileUploadCompletedWebhookPayload,\n FileUploadCreatedWebhookPayload,\n FileUploadExpiredWebhookPayload,\n FileUploadUploadFailedWebhookPayload,\n PageContentUpdatedWebhookPayload,\n PageCreatedWebhookPayload,\n PageDeletedWebhookPayload,\n PageLockedWebhookPayload,\n PageMovedWebhookPayload,\n PagePropertiesUpdatedWebhookPayload,\n PageTranscriptionBlockTranscriptDeletedWebhookPayload,\n PageUndeletedWebhookPayload,\n PageUnlockedWebhookPayload,\n ViewCreatedWebhookPayload,\n ViewDeletedWebhookPayload,\n ViewUpdatedWebhookPayload,\n} from \"./api-endpoints\"\nexport type AnnotationResponse = RichTextItemResponseCommon[\"annotations\"]\nexport { default as Client } from \"./Client\"\nexport { LogLevel, Logger } from \"./logging\"\nexport {\n // Error codes\n NotionErrorCode,\n APIErrorCode,\n ClientErrorCode,\n // Error types\n NotionClientError,\n APIResponseError,\n UnknownHTTPResponseError,\n RequestTimeoutError,\n InvalidPathParameterError,\n BrowserTokenNotAllowedError,\n // Error helpers\n isNotionClientError,\n isHTTPResponseError,\n} from \"./errors\"\nexport type { RetryOptions } from \"./Client\"\nexport {\n DEFAULT_BASE_URL,\n DEFAULT_TIMEOUT_MS,\n DEFAULT_MAX_RETRIES,\n DEFAULT_INITIAL_RETRY_DELAY_MS,\n DEFAULT_MAX_RETRY_DELAY_MS,\n MIN_VIEW_COLUMN_WIDTH,\n} from \"./constants\"\nexport {\n collectPaginatedAPI,\n iteratePaginatedAPI,\n collectDataSourceTemplates,\n iterateDataSourceTemplates,\n iterateAllDataSourceRows,\n collectAllDataSourceRows,\n isFullBlock,\n isFullDataSource,\n isFullDatabase,\n isFullPage,\n isFullUser,\n isFullComment,\n isFullView,\n isFullPageOrDataSource,\n extractNotionId,\n extractDatabaseId,\n extractPageId,\n extractBlockId,\n} from \"./helpers\"\nexport type {\n FullDataSourceQueryArgs,\n FullDataSourceQueryFilter,\n} from \"./helpers\"\nexport { verifyWebhookSignature, signWebhookPayload } from \"./webhooks\"\nexport type { VerifyWebhookSignatureArgs } from \"./webhooks\"\nexport type { QueryMeetingNotesResponse } from \"./api-endpoints/meeting-notes\"\nexport type {\n QueryMeetingNotesParameters,\n MeetingNotesCombinatorFilter,\n MeetingNotesFilterNode,\n MeetingNotesPropertyFilter,\n MeetingNotesPropertyName,\n MeetingNotesSort,\n} from \"./meeting-notes\"\nexport { meetingNotesFilterableProperties } from \"./meeting-notes\"\n"]}
|
package/build/src/webhooks.d.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Helpers for receiving and verifying Notion webhook deliveries.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
7
|
-
*
|
|
8
|
-
* **exactly as it arrived over the wire** — any JSON re-serialization
|
|
9
|
-
* will change the bytes and invalidate the signature.
|
|
4
|
+
* Event signatures use HMAC-SHA256 with the subscription's verification
|
|
5
|
+
* token. The `X-Notion-Signature` header contains `sha256=<hex>`.
|
|
6
|
+
* Pass the raw body as received. Parsing and re-serializing JSON can change
|
|
7
|
+
* its bytes and invalidate the signature.
|
|
10
8
|
*
|
|
11
|
-
* The helpers
|
|
12
|
-
*
|
|
13
|
-
* transparently fall back to `node:crypto`'s `webcrypto.subtle` on older
|
|
14
|
-
* Node.js 18 builds where `globalThis.crypto` is not yet enabled by
|
|
15
|
-
* default. They work without configuration in Node.js, Bun, Deno,
|
|
16
|
-
* Vercel Edge Functions, Cloudflare Workers, and modern browsers.
|
|
9
|
+
* The helpers use `globalThis.crypto.subtle` when available, then fall
|
|
10
|
+
* back to the Web Crypto API in Node's crypto module.
|
|
17
11
|
*/
|
|
18
12
|
export type VerifyWebhookSignatureArgs = {
|
|
19
13
|
/**
|
|
20
|
-
* The raw HTTP request body
|
|
14
|
+
* The raw HTTP request body, before any parsing.
|
|
21
15
|
* Pass a string for text bodies or a Uint8Array/Buffer for binary-safe
|
|
22
16
|
* access. Re-serialized JSON will not verify.
|
|
23
17
|
*/
|
|
@@ -38,16 +32,15 @@ export type VerifyWebhookSignatureArgs = {
|
|
|
38
32
|
* Verify that a webhook delivery came from Notion and has not been
|
|
39
33
|
* tampered with.
|
|
40
34
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* malformed input so the caller can respond with a single 401/403 path.
|
|
35
|
+
* Returns `true` if the signature matches HMAC-SHA256 of the body using
|
|
36
|
+
* the verification token. Returns `false` for a missing or malformed
|
|
37
|
+
* signature. Crypto errors may throw.
|
|
45
38
|
*/
|
|
46
39
|
export declare function verifyWebhookSignature(args: VerifyWebhookSignatureArgs): Promise<boolean>;
|
|
47
40
|
/**
|
|
48
41
|
* Compute the value Notion would send in `X-Notion-Signature` for a
|
|
49
|
-
* given body and verification token.
|
|
50
|
-
*
|
|
42
|
+
* given body and verification token. Use this to test webhook handlers
|
|
43
|
+
* without a live subscription.
|
|
51
44
|
*/
|
|
52
45
|
export declare function signWebhookPayload(args: {
|
|
53
46
|
body: string | Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/webhooks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACpC;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,OAAO,CAAC,CAoBlB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,iBAAiB,EAAE,MAAM,CAAA;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlB"}
|