@notionhq/client 5.21.0 → 5.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -10
- package/build/package.json +1 -1
- package/build/src/Client.d.ts +12 -5
- package/build/src/Client.d.ts.map +1 -1
- package/build/src/Client.js +37 -8
- package/build/src/Client.js.map +1 -1
- package/build/src/api-endpoints/async-tasks.d.ts +141 -0
- package/build/src/api-endpoints/async-tasks.d.ts.map +1 -0
- package/build/src/api-endpoints/async-tasks.js +16 -0
- package/build/src/api-endpoints/async-tasks.js.map +1 -0
- package/build/src/api-endpoints/blocks.d.ts +1 -1
- package/build/src/api-endpoints/blocks.d.ts.map +1 -1
- package/build/src/api-endpoints/blocks.js.map +1 -1
- package/build/src/api-endpoints/comments.d.ts +1 -1
- package/build/src/api-endpoints/comments.d.ts.map +1 -1
- package/build/src/api-endpoints/comments.js.map +1 -1
- package/build/src/api-endpoints/common.d.ts +3 -0
- package/build/src/api-endpoints/common.d.ts.map +1 -1
- package/build/src/api-endpoints/common.js.map +1 -1
- package/build/src/api-endpoints/custom-emojis.d.ts +1 -1
- package/build/src/api-endpoints/custom-emojis.d.ts.map +1 -1
- package/build/src/api-endpoints/custom-emojis.js.map +1 -1
- package/build/src/api-endpoints/data-sources.d.ts +2 -2
- 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/file-uploads.d.ts +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 +12 -4
- package/build/src/api-endpoints/pages.d.ts.map +1 -1
- package/build/src/api-endpoints/pages.js +2 -0
- package/build/src/api-endpoints/pages.js.map +1 -1
- package/build/src/api-endpoints/search.d.ts +3 -1
- package/build/src/api-endpoints/search.d.ts.map +1 -1
- package/build/src/api-endpoints/search.js.map +1 -1
- package/build/src/api-endpoints/users.d.ts +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/views.d.ts +2 -2
- package/build/src/api-endpoints/views.d.ts.map +1 -1
- package/build/src/api-endpoints/views.js.map +1 -1
- package/build/src/api-endpoints.d.ts +2 -0
- package/build/src/api-endpoints.d.ts.map +1 -1
- package/build/src/api-endpoints.js +2 -0
- package/build/src/api-endpoints.js.map +1 -1
- package/build/src/errors.d.ts +1 -0
- package/build/src/errors.d.ts.map +1 -1
- package/build/src/errors.js +3 -0
- package/build/src/errors.js.map +1 -1
- package/build/src/helpers.d.ts +84 -1
- package/build/src/helpers.d.ts.map +1 -1
- package/build/src/helpers.js +134 -0
- package/build/src/helpers.js.map +1 -1
- package/build/src/index.d.ts +5 -2
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +6 -1
- package/build/src/index.js.map +1 -1
- package/build/src/webhooks.d.ts +56 -0
- package/build/src/webhooks.d.ts.map +1 -0
- package/build/src/webhooks.js +124 -0
- package/build/src/webhooks.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,15 +134,15 @@ You may also set a custom `logger` to emit logs to a destination other than `std
|
|
|
134
134
|
|
|
135
135
|
The `Client` supports the following options on initialization. These options are all keys in the single constructor parameter.
|
|
136
136
|
|
|
137
|
-
| Option | Default value | Type | Description
|
|
138
|
-
| ----------- | --------------------------- | -------------- |
|
|
139
|
-
| `auth` | `undefined` | `string` | Bearer token for authentication. If left undefined, the `auth` parameter should be set on each request.
|
|
140
|
-
| `logLevel` | `LogLevel.WARN` | `LogLevel` | Verbosity of logs the instance will produce. By default, logs are written to `stdout`.
|
|
141
|
-
| `timeoutMs` | `DEFAULT_TIMEOUT_MS` | `number` | Number of milliseconds to wait before emitting a `RequestTimeoutError`
|
|
142
|
-
| `baseUrl` | `DEFAULT_BASE_URL` | `string` | The root URL for sending API requests. This can be changed to test with a mock server.
|
|
143
|
-
| `logger` | Log to console | `Logger` | A custom logging function. This function is only called when the client emits a log that is equal or greater severity than `logLevel`.
|
|
144
|
-
| `agent` | Default node agent | `http.Agent` | Used to control creation of TCP sockets. A common use is to proxy requests with [`https-proxy-agent`](https://github.com/TooTallNate/node-https-proxy-agent)
|
|
145
|
-
| `retry` | See [constants](#constants) | `RetryOptions` | Configuration for automatic retries on rate limits (429) and server errors (500, 503). See [Automatic retries](#automatic-retries) below.
|
|
137
|
+
| Option | Default value | Type | Description |
|
|
138
|
+
| ----------- | --------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
139
|
+
| `auth` | `undefined` | `string` | Bearer token for authentication. If left undefined, the `auth` parameter should be set on each request. |
|
|
140
|
+
| `logLevel` | `LogLevel.WARN` | `LogLevel` | Verbosity of logs the instance will produce. By default, logs are written to `stdout`. |
|
|
141
|
+
| `timeoutMs` | `DEFAULT_TIMEOUT_MS` | `number` | Number of milliseconds to wait before emitting a `RequestTimeoutError` |
|
|
142
|
+
| `baseUrl` | `DEFAULT_BASE_URL` | `string` | The root URL for sending API requests. This can be changed to test with a mock server. |
|
|
143
|
+
| `logger` | Log to console | `Logger` | A custom logging function. This function is only called when the client emits a log that is equal or greater severity than `logLevel`. |
|
|
144
|
+
| `agent` | Default node agent | `http.Agent` | Used to control creation of TCP sockets. A common use is to proxy requests with [`https-proxy-agent`](https://github.com/TooTallNate/node-https-proxy-agent) |
|
|
145
|
+
| `retry` | See [constants](#constants) | `RetryOptions` | Configuration for automatic retries on rate limits (429), service overloads (529), and server errors (500, 503). See [Automatic retries](#automatic-retries) below. |
|
|
146
146
|
|
|
147
147
|
### Automatic retries
|
|
148
148
|
|
|
@@ -151,10 +151,11 @@ The client automatically retries requests that fail due to rate limiting or tran
|
|
|
151
151
|
**Retryable errors:**
|
|
152
152
|
|
|
153
153
|
- `rate_limited` (HTTP 429) - Too many requests; retried for all HTTP methods
|
|
154
|
+
- `service_overload` (HTTP 529) - Service overloaded; retried for all HTTP methods
|
|
154
155
|
- `internal_server_error` (HTTP 500) - Server error; retried only for GET and DELETE
|
|
155
156
|
- `service_unavailable` (HTTP 503) - Service temporarily unavailable; retried only for GET and DELETE
|
|
156
157
|
|
|
157
|
-
Server errors (500, 503) are only retried for idempotent HTTP methods (GET, DELETE) to avoid duplicate side effects. Rate limits (429) are retried for all methods since the server explicitly asks clients to retry.
|
|
158
|
+
Server errors (500, 503) are only retried for idempotent HTTP methods (GET, DELETE) to avoid duplicate side effects. Rate limits (429) and service overloads (529) are retried for all methods since the server explicitly asks clients to retry.
|
|
158
159
|
|
|
159
160
|
**Retry behavior:**
|
|
160
161
|
|
|
@@ -349,6 +350,79 @@ const blocks = await collectPaginatedAPI(notion.blocks.children.list, {
|
|
|
349
350
|
// Do something with blocks.
|
|
350
351
|
```
|
|
351
352
|
|
|
353
|
+
#### `iterateAllDataSourceRows(client, args)`
|
|
354
|
+
|
|
355
|
+
A single data source query (one filter and sort) returns at most a fixed number
|
|
356
|
+
of rows, 10,000 by default. Once that limit is reached, `has_more` becomes
|
|
357
|
+
`false` and the response carries `request_status.type === "incomplete"`. Plain
|
|
358
|
+
pagination such as `iteratePaginatedAPI` stops there and silently misses the rest
|
|
359
|
+
of a larger data source.
|
|
360
|
+
|
|
361
|
+
This utility reads every row anyway. It partitions the data source into
|
|
362
|
+
`created_time` windows: it sorts by `created_time` ascending, and whenever a
|
|
363
|
+
window hits the limit it starts a fresh query from the last row's timestamp.
|
|
364
|
+
Each fresh query has a different filter, so it gets its own result budget. Rows
|
|
365
|
+
that share a boundary timestamp are de-duplicated by id, so every row is yielded
|
|
366
|
+
exactly once.
|
|
367
|
+
|
|
368
|
+
`created_time` is used because it never changes. `last_edited_time` would shift
|
|
369
|
+
rows between windows as they are edited, causing gaps or duplicates.
|
|
370
|
+
|
|
371
|
+
**Parameters:**
|
|
372
|
+
|
|
373
|
+
- `client`: A Notion client instance.
|
|
374
|
+
- `args`: The same arguments as `dataSources.query`, minus the fields the helper
|
|
375
|
+
controls: `start_cursor` (pagination is automatic) and `sorts` (set to
|
|
376
|
+
`created_time` ascending to partition). `data_source_id` is required. Any
|
|
377
|
+
`filter` you pass is combined with the window bound using `and`.
|
|
378
|
+
|
|
379
|
+
**Returns:**
|
|
380
|
+
|
|
381
|
+
An async iterator over every row in the data source.
|
|
382
|
+
|
|
383
|
+
**Throws:**
|
|
384
|
+
|
|
385
|
+
If a single `created_time` value holds more rows than the limit, the window
|
|
386
|
+
cannot be narrowed by time alone. Pass a `filter` in that case so each window
|
|
387
|
+
stays under the limit.
|
|
388
|
+
|
|
389
|
+
**Example:**
|
|
390
|
+
|
|
391
|
+
```javascript
|
|
392
|
+
for await (const row of iterateAllDataSourceRows(notion, {
|
|
393
|
+
data_source_id: dataSourceId,
|
|
394
|
+
})) {
|
|
395
|
+
// Do something with row.
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### `collectAllDataSourceRows(client, args)`
|
|
400
|
+
|
|
401
|
+
This utility accepts the same arguments as `iterateAllDataSourceRows`, but
|
|
402
|
+
collects the results into an in-memory array.
|
|
403
|
+
|
|
404
|
+
Before using this utility, check that the full data source fits in memory. For
|
|
405
|
+
very large data sources, prefer `iterateAllDataSourceRows` and process rows as
|
|
406
|
+
they stream.
|
|
407
|
+
|
|
408
|
+
**Parameters:**
|
|
409
|
+
|
|
410
|
+
- `client`: A Notion client instance.
|
|
411
|
+
- `args`: The same arguments as `iterateAllDataSourceRows`.
|
|
412
|
+
|
|
413
|
+
**Returns:**
|
|
414
|
+
|
|
415
|
+
An array with every row in the data source.
|
|
416
|
+
|
|
417
|
+
**Example:**
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
const rows = await collectAllDataSourceRows(notion, {
|
|
421
|
+
data_source_id: dataSourceId,
|
|
422
|
+
})
|
|
423
|
+
// Do something with rows.
|
|
424
|
+
```
|
|
425
|
+
|
|
352
426
|
### Custom requests
|
|
353
427
|
|
|
354
428
|
To make requests directly to a Notion API endpoint instead of using the pre-built families of methods, call the `request()` method. For example:
|
|
@@ -377,6 +451,43 @@ The `notion.request<ResponseBody>({...})` method is generic; `ResponseBody` repr
|
|
|
377
451
|
|
|
378
452
|
Another customization you can make is to pass your own `fetch` function to the `Client` constructor. This might be helpful for some execution environments where the default, built-in `fetch` isn't suitable.
|
|
379
453
|
|
|
454
|
+
### Verifying webhook signatures
|
|
455
|
+
|
|
456
|
+
If your integration receives [Notion webhook deliveries](https://developers.notion.com/reference/webhooks), use `verifyWebhookSignature` to confirm each request was sent by Notion and was not tampered with in transit. Notion signs every delivery with HMAC-SHA256 over the raw request body using the subscription's verification token, and places the result in the `X-Notion-Signature` header as `sha256=<hex>`.
|
|
457
|
+
|
|
458
|
+
```ts
|
|
459
|
+
import { verifyWebhookSignature } from "@notionhq/client"
|
|
460
|
+
|
|
461
|
+
// Express example. The body must be read as the raw text/bytes that
|
|
462
|
+
// arrived over the wire — JSON-parsed and re-serialized bodies will not
|
|
463
|
+
// verify, because re-serialization changes whitespace and key order.
|
|
464
|
+
app.post(
|
|
465
|
+
"/notion-webhook",
|
|
466
|
+
express.text({ type: "application/json" }),
|
|
467
|
+
async (req, res) => {
|
|
468
|
+
const ok = await verifyWebhookSignature({
|
|
469
|
+
body: req.body,
|
|
470
|
+
signature: req.header("x-notion-signature"),
|
|
471
|
+
verificationToken: process.env.NOTION_WEBHOOK_VERIFICATION_TOKEN!,
|
|
472
|
+
})
|
|
473
|
+
if (!ok) {
|
|
474
|
+
return res.status(401).send("invalid signature")
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const event = JSON.parse(req.body)
|
|
478
|
+
// …handle the event
|
|
479
|
+
res.status(200).send("ok")
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
The same helper handles the initial verification handshake that Notion sends when you first register a webhook URL — the handshake body (`{ "verification_token": "..." }`) is signed with the same token, so a single code path covers both cases.
|
|
485
|
+
|
|
486
|
+
`signWebhookPayload({ body, verificationToken })` produces the same `sha256=<hex>` header value, which is useful for unit-testing your webhook handler without standing up a real subscription.
|
|
487
|
+
|
|
488
|
+
> [!NOTE]
|
|
489
|
+
> Both helpers are async. They prefer the Web Crypto API (`globalThis.crypto.subtle`) when present and transparently fall back to `node:crypto` on older Node.js 18 builds, so they run unchanged on Node.js, Bun, Deno, Vercel Edge Functions, Cloudflare Workers, and modern browsers.
|
|
490
|
+
|
|
380
491
|
## Examples
|
|
381
492
|
|
|
382
493
|
For sample code and example projects, see [notion-cookbook](https://github.com/makenotion/notion-cookbook/tree/main/examples).
|
package/build/package.json
CHANGED
package/build/src/Client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Agent } from "node:http";
|
|
2
2
|
import { type Logger, LogLevel } from "./logging";
|
|
3
|
-
import { type GetBlockParameters, type GetBlockResponse, type UpdateBlockParameters, type UpdateBlockResponse, type DeleteBlockParameters, type DeleteBlockResponse, type AppendBlockChildrenParameters, type AppendBlockChildrenResponse, type ListBlockChildrenParameters, type ListBlockChildrenResponse, type QueryDataSourceParameters, type QueryDataSourceResponse, type CreateDataSourceParameters, type CreateDataSourceResponse, type UpdateDataSourceParameters, type UpdateDataSourceResponse, type GetDataSourceParameters, type GetDataSourceResponse, type CreatePageParameters, type CreatePageResponse, type GetPageParameters, type GetPageResponse, type UpdatePageParameters, type UpdatePageResponse, type MovePageParameters, type MovePageResponse, type GetPageMarkdownParameters, type GetPageMarkdownResponse, type UpdatePageMarkdownParameters, type UpdatePageMarkdownResponse, type GetUserParameters, type GetUserResponse, type ListUsersParameters, type ListUsersResponse, type SearchParameters, type SearchResponse, type GetSelfParameters, type GetSelfResponse, type GetPagePropertyParameters, type GetPagePropertyResponse, type CreateCommentParameters, type CreateCommentResponse, type ListCommentsParameters, type ListCommentsResponse, type GetCommentParameters, type GetCommentResponse, type UpdateCommentParameters, type UpdateCommentResponse, type DeleteCommentParameters, type DeleteCommentResponse, type OauthTokenResponse, type OauthTokenParameters, type OauthIntrospectResponse, type OauthIntrospectParameters, type OauthRevokeResponse, type OauthRevokeParameters, type CreateFileUploadParameters, type CreateFileUploadResponse, type GetFileUploadResponse, type GetFileUploadParameters, type SendFileUploadParameters, type SendFileUploadResponse, type CompleteFileUploadParameters, type CompleteFileUploadResponse, type ListFileUploadsParameters, type ListFileUploadsResponse, GetDatabaseParameters, GetDatabaseResponse, CreateDatabaseResponse, CreateDatabaseParameters, UpdateDatabaseParameters, UpdateDatabaseResponse, ListDataSourceTemplatesResponse, ListDataSourceTemplatesParameters, type ListDatabaseViewsParameters, type ListDatabaseViewsResponse, type CreateViewParameters, type CreateViewResponse, type GetViewParameters, type GetViewResponse, type UpdateViewParameters, type UpdateViewResponse, type DeleteViewParameters, type DeleteViewResponse, type CreateViewQueryParameters, type CreateViewQueryResponse, type GetViewQueryResultsParameters, type GetViewQueryResultsResponse, type DeleteViewQueryParameters, type DeleteViewQueryResponse, type ListCustomEmojisParameters, type ListCustomEmojisResponse } from "./api-endpoints";
|
|
3
|
+
import { type GetBlockParameters, type GetBlockResponse, type UpdateBlockParameters, type UpdateBlockResponse, type DeleteBlockParameters, type DeleteBlockResponse, type AppendBlockChildrenParameters, type AppendBlockChildrenResponse, type ListBlockChildrenParameters, type ListBlockChildrenResponse, type QueryDataSourceParameters, type QueryDataSourceResponse, type CreateDataSourceParameters, type CreateDataSourceResponse, type UpdateDataSourceParameters, type UpdateDataSourceResponse, type GetDataSourceParameters, type GetDataSourceResponse, type CreatePageParameters, type CreatePageResponse, type GetPageParameters, type GetPageResponse, type UpdatePageParameters, type UpdatePageResponse, type MovePageParameters, type MovePageResponse, type GetPageMarkdownParameters, type GetPageMarkdownResponse, type UpdatePageMarkdownParameters, type UpdatePageMarkdownResponse, type GetUserParameters, type GetUserResponse, type ListUsersParameters, type ListUsersResponse, type SearchParameters, type SearchResponse, type GetSelfParameters, type GetSelfResponse, type GetPagePropertyParameters, type GetPagePropertyResponse, type CreateCommentParameters, type CreateCommentResponse, type ListCommentsParameters, type ListCommentsResponse, type GetCommentParameters, type GetCommentResponse, type UpdateCommentParameters, type UpdateCommentResponse, type DeleteCommentParameters, type DeleteCommentResponse, type OauthTokenResponse, type OauthTokenParameters, type OauthIntrospectResponse, type OauthIntrospectParameters, type OauthRevokeResponse, type OauthRevokeParameters, type CreateFileUploadParameters, type CreateFileUploadResponse, type GetFileUploadResponse, type GetFileUploadParameters, type SendFileUploadParameters, type SendFileUploadResponse, type CompleteFileUploadParameters, type CompleteFileUploadResponse, type ListFileUploadsParameters, type ListFileUploadsResponse, GetDatabaseParameters, GetDatabaseResponse, CreateDatabaseResponse, CreateDatabaseParameters, UpdateDatabaseParameters, UpdateDatabaseResponse, ListDataSourceTemplatesResponse, ListDataSourceTemplatesParameters, type ListDatabaseViewsParameters, type ListDatabaseViewsResponse, type CreateViewParameters, type CreateViewResponse, type GetViewParameters, type GetViewResponse, type UpdateViewParameters, type UpdateViewResponse, type DeleteViewParameters, type DeleteViewResponse, type CreateViewQueryParameters, type CreateViewQueryResponse, type GetViewQueryResultsParameters, type GetViewQueryResultsResponse, type DeleteViewQueryParameters, type DeleteViewQueryResponse, type ListCustomEmojisParameters, type ListCustomEmojisResponse, type GetAsyncTaskParameters, type GetAsyncTaskResponse } from "./api-endpoints";
|
|
4
4
|
import { type QueryMeetingNotesResponse } from "./api-endpoints/meeting-notes";
|
|
5
5
|
import type { QueryMeetingNotesParameters } from "./meeting-notes";
|
|
6
6
|
import type { SupportedFetch } from "./fetch-types";
|
|
@@ -106,9 +106,10 @@ export default class Client {
|
|
|
106
106
|
private extractRequestId;
|
|
107
107
|
/**
|
|
108
108
|
* Determines if an error can be retried based on its error code and method.
|
|
109
|
-
* Rate limits (429) are always retryable since
|
|
110
|
-
* to retry. Server errors (500, 503) are only
|
|
111
|
-
* (GET, DELETE) to avoid duplicate side
|
|
109
|
+
* Rate limits (429) and service overloads (529) are always retryable since
|
|
110
|
+
* the server explicitly asks us to retry. Server errors (500, 503) are only
|
|
111
|
+
* retried for idempotent methods (GET, DELETE) to avoid duplicate side
|
|
112
|
+
* effects.
|
|
112
113
|
*/
|
|
113
114
|
private canRetry;
|
|
114
115
|
/**
|
|
@@ -124,6 +125,12 @@ export default class Client {
|
|
|
124
125
|
*/
|
|
125
126
|
private parseRetryAfterHeader;
|
|
126
127
|
private sleep;
|
|
128
|
+
readonly asyncTasks: {
|
|
129
|
+
/**
|
|
130
|
+
* Retrieve an async task
|
|
131
|
+
*/
|
|
132
|
+
retrieve: (args: WithAuth<GetAsyncTaskParameters>) => Promise<GetAsyncTaskResponse>;
|
|
133
|
+
};
|
|
127
134
|
readonly blocks: {
|
|
128
135
|
/**
|
|
129
136
|
* Retrieve block
|
|
@@ -386,7 +393,7 @@ export default class Client {
|
|
|
386
393
|
private authAsHeaders;
|
|
387
394
|
}
|
|
388
395
|
type Method = "get" | "post" | "patch" | "delete";
|
|
389
|
-
type QueryParams = Record<string, string | number | boolean | string[]> | URLSearchParams;
|
|
396
|
+
type QueryParams = Record<string, string | number | boolean | string[] | null> | URLSearchParams;
|
|
390
397
|
type WithAuth<P> = P & {
|
|
391
398
|
auth?: string;
|
|
392
399
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EACL,KAAK,MAAM,EACX,QAAQ,EAGT,MAAM,WAAW,CAAA;AAmBlB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAErB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAExB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAExB,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAEhC,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAE9B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAE5B,KAAK,0BAA0B,EAC/B,KAAK,wBAA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AC3B,SAAS,EAAE,MAAM,CAAA;YACjB,aAAa,EAAE,MAAM,CAAA;SACtB,KACA,OAAO,CAAC,kBAAkB,CAAC;QAY9B;;WAEG;2BAEK,yBAAyB,GAAG;YAChC,SAAS,EAAE,MAAM,CAAA;YACjB,aAAa,EAAE,MAAM,CAAA;SACtB,KACA,OAAO,CAAC,uBAAuB,CAAC;QAYnC;;WAEG;uBAEK,qBAAqB,GAAG;YAC5B,SAAS,EAAE,MAAM,CAAA;YACjB,aAAa,EAAE,MAAM,CAAA;SACtB,KACA,OAAO,CAAC,mBAAmB,CAAC;MAYhC;IAED;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;;;;OAKG;IACH,OAAO,CAAC,GAAG;IAUX;;;;;;;;OAQG;IACH,OAAO,CAAC,aAAa;CAQtB;AAKD,KAAK,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AACjD,KAAK,WAAW,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,GAC3D,eAAe,CAAA;AAEnB,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
package/build/src/Client.js
CHANGED
|
@@ -19,6 +19,7 @@ const constants_1 = require("./constants");
|
|
|
19
19
|
const api_endpoints_1 = require("./api-endpoints");
|
|
20
20
|
const meeting_notes_1 = require("./api-endpoints/meeting-notes");
|
|
21
21
|
const package_json_1 = require("../package.json");
|
|
22
|
+
const START_CURSOR_PARAM_NAME = "start_cursor";
|
|
22
23
|
class Client {
|
|
23
24
|
constructor(options) {
|
|
24
25
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -37,6 +38,21 @@ class Client {
|
|
|
37
38
|
/*
|
|
38
39
|
* Notion API endpoints
|
|
39
40
|
*/
|
|
41
|
+
this.asyncTasks = {
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve an async task
|
|
44
|
+
*/
|
|
45
|
+
retrieve: (args) => {
|
|
46
|
+
this.warnUnknownParams(args, api_endpoints_1.getAsyncTask);
|
|
47
|
+
return this.request({
|
|
48
|
+
path: api_endpoints_1.getAsyncTask.path(args),
|
|
49
|
+
method: api_endpoints_1.getAsyncTask.method,
|
|
50
|
+
query: (0, utils_1.pick)(args, api_endpoints_1.getAsyncTask.queryParams),
|
|
51
|
+
body: (0, utils_1.pick)(args, api_endpoints_1.getAsyncTask.bodyParams),
|
|
52
|
+
auth: args === null || args === void 0 ? void 0 : args.auth,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
40
56
|
this.blocks = {
|
|
41
57
|
/**
|
|
42
58
|
* Retrieve block
|
|
@@ -749,7 +765,11 @@ class Client {
|
|
|
749
765
|
const url = new URL(`${__classPrivateFieldGet(this, _Client_prefixUrl, "f")}${path}`);
|
|
750
766
|
if (query) {
|
|
751
767
|
for (const [key, value] of Object.entries(query)) {
|
|
752
|
-
|
|
768
|
+
// Skip `null` for the same reason as `undefined`: callers pipe
|
|
769
|
+
// `next_cursor` (which can be `null`) back as `start_cursor`, and a
|
|
770
|
+
// null cursor means "no cursor" — encoding it as the string "null"
|
|
771
|
+
// would send a bogus value to the server.
|
|
772
|
+
if (value !== undefined && value !== null) {
|
|
753
773
|
if (Array.isArray(value)) {
|
|
754
774
|
for (const val of value) {
|
|
755
775
|
url.searchParams.append(key, decodeURIComponent(val));
|
|
@@ -767,10 +787,17 @@ class Client {
|
|
|
767
787
|
* Serializes the request body to JSON string if non-empty.
|
|
768
788
|
*/
|
|
769
789
|
serializeBody(body) {
|
|
770
|
-
if (!body
|
|
790
|
+
if (!body) {
|
|
791
|
+
return undefined;
|
|
792
|
+
}
|
|
793
|
+
const serializedBody = { ...body };
|
|
794
|
+
if (serializedBody[START_CURSOR_PARAM_NAME] === null) {
|
|
795
|
+
delete serializedBody[START_CURSOR_PARAM_NAME];
|
|
796
|
+
}
|
|
797
|
+
if (Object.entries(serializedBody).length === 0) {
|
|
771
798
|
return undefined;
|
|
772
799
|
}
|
|
773
|
-
return JSON.stringify(
|
|
800
|
+
return JSON.stringify(serializedBody);
|
|
774
801
|
}
|
|
775
802
|
/**
|
|
776
803
|
* Builds the request headers including auth and content-type.
|
|
@@ -910,16 +937,18 @@ class Client {
|
|
|
910
937
|
}
|
|
911
938
|
/**
|
|
912
939
|
* Determines if an error can be retried based on its error code and method.
|
|
913
|
-
* Rate limits (429) are always retryable since
|
|
914
|
-
* to retry. Server errors (500, 503) are only
|
|
915
|
-
* (GET, DELETE) to avoid duplicate side
|
|
940
|
+
* Rate limits (429) and service overloads (529) are always retryable since
|
|
941
|
+
* the server explicitly asks us to retry. Server errors (500, 503) are only
|
|
942
|
+
* retried for idempotent methods (GET, DELETE) to avoid duplicate side
|
|
943
|
+
* effects.
|
|
916
944
|
*/
|
|
917
945
|
canRetry(error, method) {
|
|
918
946
|
if (!errors_1.APIResponseError.isAPIResponseError(error)) {
|
|
919
947
|
return false;
|
|
920
948
|
}
|
|
921
|
-
//
|
|
922
|
-
if (error.code === errors_1.APIErrorCode.RateLimited
|
|
949
|
+
// Server says "try again later"; retry these for every HTTP method.
|
|
950
|
+
if (error.code === errors_1.APIErrorCode.RateLimited ||
|
|
951
|
+
error.code === errors_1.APIErrorCode.ServiceOverload) {
|
|
923
952
|
return true;
|
|
924
953
|
}
|
|
925
954
|
// Server errors only retry for idempotent methods
|