@visus-io/notion-sdk-ts 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/api/asyncTasks.api.d.ts +70 -0
- package/dist/api/asyncTasks.api.js +68 -0
- package/dist/api/base.api.d.ts +7 -16
- package/dist/api/base.api.js +6 -21
- package/dist/api/blocks.api.d.ts +433 -73
- package/dist/api/blocks.api.js +39 -0
- package/dist/api/comments.api.d.ts +40 -5
- package/dist/api/comments.api.js +43 -1
- package/dist/api/customEmojis.api.d.ts +36 -0
- package/dist/api/customEmojis.api.js +36 -0
- package/dist/api/dataSources.api.d.ts +70 -12
- package/dist/api/dataSources.api.js +29 -5
- package/dist/api/databases.api.d.ts +40 -6
- package/dist/api/databases.api.js +2 -1
- package/dist/api/fileUploads.api.d.ts +7 -1
- package/dist/api/fileUploads.api.js +16 -1
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +7 -1
- package/dist/api/pages.api.d.ts +142 -10
- package/dist/api/pages.api.js +64 -0
- package/dist/api/search.api.d.ts +10 -2
- package/dist/api/users.api.d.ts +1 -0
- package/dist/api/views.api.d.ts +284 -0
- package/dist/api/views.api.js +169 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +10 -4
- package/dist/errors.d.ts +5 -1
- package/dist/errors.js +6 -0
- package/dist/helpers/block.helpers.d.ts +38 -1
- package/dist/helpers/block.helpers.js +45 -3
- package/dist/helpers/file.helpers.d.ts +36 -1
- package/dist/helpers/file.helpers.js +26 -4
- package/dist/helpers/filter.helpers.d.ts +6 -6
- package/dist/helpers/index.d.ts +3 -2
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/pagination.helpers.d.ts +56 -0
- package/dist/helpers/pagination.helpers.js +86 -0
- package/dist/helpers/property.helpers.d.ts +29 -0
- package/dist/helpers/property.helpers.js +27 -0
- package/dist/helpers/webhook.helpers.d.ts +52 -0
- package/dist/helpers/webhook.helpers.js +81 -0
- package/dist/models/asyncTask.model.d.ts +59 -0
- package/dist/models/asyncTask.model.js +89 -0
- package/dist/models/block.model.js +4 -1
- package/dist/models/customEmoji.model.d.ts +28 -0
- package/dist/models/customEmoji.model.js +42 -0
- package/dist/models/dataSource.model.d.ts +3 -3
- package/dist/models/dataSource.model.js +1 -1
- package/dist/models/database.model.d.ts +7 -3
- package/dist/models/database.model.js +7 -1
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +7 -1
- package/dist/models/page.model.d.ts +2 -0
- package/dist/models/page.model.js +6 -0
- package/dist/models/view.model.d.ts +79 -0
- package/dist/models/view.model.js +119 -0
- package/dist/notion.d.ts +26 -7
- package/dist/notion.js +19 -3
- package/dist/schemas/asyncTask.schema.d.ts +42 -0
- package/dist/schemas/asyncTask.schema.js +83 -0
- package/dist/schemas/block.schema.d.ts +378 -72
- package/dist/schemas/block.schema.js +33 -7
- package/dist/schemas/comment.schema.d.ts +8 -3
- package/dist/schemas/customEmoji.schema.d.ts +13 -0
- package/dist/schemas/customEmoji.schema.js +48 -0
- package/dist/schemas/dataSource.schema.d.ts +68 -10
- package/dist/schemas/dataSource.schema.js +22 -4
- package/dist/schemas/database.schema.d.ts +38 -6
- package/dist/schemas/database.schema.js +3 -2
- package/dist/schemas/fileUpload.schema.d.ts +1 -1
- package/dist/schemas/icon.schema.d.ts +92 -0
- package/dist/schemas/icon.schema.js +88 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/index.js +6 -0
- package/dist/schemas/meetingNotesQuery.schema.d.ts +4187 -0
- package/dist/schemas/meetingNotesQuery.schema.js +62 -0
- package/dist/schemas/page.schema.d.ts +46 -9
- package/dist/schemas/page.schema.js +4 -2
- package/dist/schemas/pageMarkdown.schema.d.ts +59 -0
- package/dist/schemas/pageMarkdown.schema.js +65 -0
- package/dist/schemas/pageProperties.schema.d.ts +30 -18
- package/dist/schemas/pageProperties.schema.js +2 -3
- package/dist/schemas/pagination.schema.d.ts +30 -3
- package/dist/schemas/pagination.schema.js +18 -1
- package/dist/schemas/parent.schema.d.ts +10 -1
- package/dist/schemas/parent.schema.js +9 -3
- package/dist/schemas/propertyObjects.schema.d.ts +12 -12
- package/dist/schemas/richText.schema.d.ts +8 -6
- package/dist/schemas/richText.schema.js +1 -1
- package/dist/schemas/user.schema.d.ts +2 -0
- package/dist/schemas/user.schema.js +2 -1
- package/dist/schemas/view.schema.d.ts +1077 -0
- package/dist/schemas/view.schema.js +115 -0
- package/package.json +4 -3
package/dist/notion.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NotionClientOptions } from './client';
|
|
2
|
-
import { BlocksAPI, CommentsAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, PagesAPI, SearchAPI, UsersAPI } from './api';
|
|
2
|
+
import { AsyncTasksAPI, BlocksAPI, CommentsAPI, CustomEmojisAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, PagesAPI, SearchAPI, UsersAPI, ViewsAPI } from './api';
|
|
3
3
|
/**
|
|
4
4
|
* Main Notion SDK class.
|
|
5
5
|
*
|
|
@@ -32,25 +32,44 @@ import { BlocksAPI, CommentsAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, P
|
|
|
32
32
|
* await notion.comments.create({ parent: { page_id: 'page-id' }, rich_text: [...] });
|
|
33
33
|
*
|
|
34
34
|
* const fileUpload = await notion.fileUploads.uploadFile('image.png', buffer, 'image/png');
|
|
35
|
+
*
|
|
36
|
+
* const views = await notion.views.list({ data_source_id: 'data-source-id' });
|
|
37
|
+
* const queryResult = await notion.views.queries.create(views.results[0].id);
|
|
38
|
+
*
|
|
39
|
+
* const markdown = await notion.pages.getMarkdown('page-id');
|
|
40
|
+
* const task = await notion.pages.updateMarkdown('page-id', {
|
|
41
|
+
* type: 'replace_content',
|
|
42
|
+
* new_str: 'Updated content',
|
|
43
|
+
* allow_async: true,
|
|
44
|
+
* });
|
|
45
|
+
* await notion.asyncTasks.poll(task.id);
|
|
46
|
+
*
|
|
47
|
+
* const emojis = await notion.customEmojis.list();
|
|
35
48
|
* ```
|
|
36
49
|
*/
|
|
37
50
|
export declare class Notion {
|
|
38
51
|
private readonly client;
|
|
39
|
-
/**
|
|
40
|
-
readonly
|
|
52
|
+
/** Async Tasks API for polling long-running Notion operations */
|
|
53
|
+
readonly asyncTasks: AsyncTasksAPI;
|
|
41
54
|
/** Blocks API for working with Notion blocks */
|
|
42
55
|
readonly blocks: BlocksAPI;
|
|
56
|
+
/** Comments API for working with Notion comments */
|
|
57
|
+
readonly comments: CommentsAPI;
|
|
58
|
+
/** Custom Emojis API for listing workspace custom emojis */
|
|
59
|
+
readonly customEmojis: CustomEmojisAPI;
|
|
43
60
|
/** Databases API for working with Notion databases */
|
|
44
61
|
readonly databases: DatabasesAPI;
|
|
45
62
|
/** Data Sources API for working with Notion data sources */
|
|
46
63
|
readonly dataSources: DataSourcesAPI;
|
|
64
|
+
/** FileUploads API for uploading files to Notion */
|
|
65
|
+
readonly fileUploads: FileUploadsAPI;
|
|
66
|
+
/** Pages API for working with Notion pages */
|
|
67
|
+
readonly pages: PagesAPI;
|
|
47
68
|
/** Search API for searching across the workspace */
|
|
48
69
|
readonly search: SearchAPI;
|
|
49
70
|
/** Users API for working with Notion users */
|
|
50
71
|
readonly users: UsersAPI;
|
|
51
|
-
/**
|
|
52
|
-
readonly
|
|
53
|
-
/** FileUploads API for uploading files to Notion */
|
|
54
|
-
readonly fileUploads: FileUploadsAPI;
|
|
72
|
+
/** Views API for working with Notion database/data source views */
|
|
73
|
+
readonly views: ViewsAPI;
|
|
55
74
|
constructor(options: NotionClientOptions);
|
|
56
75
|
}
|
package/dist/notion.js
CHANGED
|
@@ -35,19 +35,35 @@ const api_1 = require("./api");
|
|
|
35
35
|
* await notion.comments.create({ parent: { page_id: 'page-id' }, rich_text: [...] });
|
|
36
36
|
*
|
|
37
37
|
* const fileUpload = await notion.fileUploads.uploadFile('image.png', buffer, 'image/png');
|
|
38
|
+
*
|
|
39
|
+
* const views = await notion.views.list({ data_source_id: 'data-source-id' });
|
|
40
|
+
* const queryResult = await notion.views.queries.create(views.results[0].id);
|
|
41
|
+
*
|
|
42
|
+
* const markdown = await notion.pages.getMarkdown('page-id');
|
|
43
|
+
* const task = await notion.pages.updateMarkdown('page-id', {
|
|
44
|
+
* type: 'replace_content',
|
|
45
|
+
* new_str: 'Updated content',
|
|
46
|
+
* allow_async: true,
|
|
47
|
+
* });
|
|
48
|
+
* await notion.asyncTasks.poll(task.id);
|
|
49
|
+
*
|
|
50
|
+
* const emojis = await notion.customEmojis.list();
|
|
38
51
|
* ```
|
|
39
52
|
*/
|
|
40
53
|
class Notion {
|
|
41
54
|
constructor(options) {
|
|
42
55
|
this.client = new client_1.NotionClient(options);
|
|
43
|
-
this.
|
|
56
|
+
this.asyncTasks = new api_1.AsyncTasksAPI(this.client);
|
|
44
57
|
this.blocks = new api_1.BlocksAPI(this.client);
|
|
58
|
+
this.comments = new api_1.CommentsAPI(this.client);
|
|
59
|
+
this.customEmojis = new api_1.CustomEmojisAPI(this.client);
|
|
45
60
|
this.databases = new api_1.DatabasesAPI(this.client);
|
|
46
61
|
this.dataSources = new api_1.DataSourcesAPI(this.client);
|
|
62
|
+
this.fileUploads = new api_1.FileUploadsAPI(this.client);
|
|
63
|
+
this.pages = new api_1.PagesAPI(this.client);
|
|
47
64
|
this.search = new api_1.SearchAPI(this.client);
|
|
48
65
|
this.users = new api_1.UsersAPI(this.client);
|
|
49
|
-
this.
|
|
50
|
-
this.fileUploads = new api_1.FileUploadsAPI(this.client);
|
|
66
|
+
this.views = new api_1.ViewsAPI(this.client);
|
|
51
67
|
}
|
|
52
68
|
}
|
|
53
69
|
exports.Notion = Notion;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Async task object schema.
|
|
4
|
+
*
|
|
5
|
+
* Long-running operations (e.g. markdown writes with `allow_async: true`) return an
|
|
6
|
+
* async task handle instead of completing synchronously. Poll `GET /v1/async_tasks/{id}`
|
|
7
|
+
* until the task reaches a terminal status.
|
|
8
|
+
*
|
|
9
|
+
* Notion API reference:
|
|
10
|
+
* https://developers.notion.com/reference/retrieve-async-task
|
|
11
|
+
*/
|
|
12
|
+
export declare const ASYNC_TASK_STATUSES: readonly ["queued", "running", "retrying", "succeeded", "failed"];
|
|
13
|
+
export type AsyncTaskStatus = (typeof ASYNC_TASK_STATUSES)[number];
|
|
14
|
+
export declare const asyncTaskSchema: z.ZodObject<{
|
|
15
|
+
object: z.ZodLiteral<"async_task">;
|
|
16
|
+
id: z.ZodUUID;
|
|
17
|
+
status: z.ZodEnum<{
|
|
18
|
+
queued: "queued";
|
|
19
|
+
running: "running";
|
|
20
|
+
retrying: "retrying";
|
|
21
|
+
succeeded: "succeeded";
|
|
22
|
+
failed: "failed";
|
|
23
|
+
}>;
|
|
24
|
+
status_url: z.ZodURL;
|
|
25
|
+
created_time: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>;
|
|
26
|
+
operation: z.ZodObject<{
|
|
27
|
+
surface: z.ZodEnum<{
|
|
28
|
+
rest: "rest";
|
|
29
|
+
mcp: "mcp";
|
|
30
|
+
}>;
|
|
31
|
+
name: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
poll_after_seconds: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
35
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
object: z.ZodLiteral<"error">;
|
|
37
|
+
status: z.ZodNumber;
|
|
38
|
+
code: z.ZodString;
|
|
39
|
+
message: z.ZodString;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type NotionAsyncTask = z.infer<typeof asyncTaskSchema>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.asyncTaskSchema = exports.ASYNC_TASK_STATUSES = void 0;
|
|
37
|
+
const z = __importStar(require("zod"));
|
|
38
|
+
const shared_schema_1 = require("./shared.schema");
|
|
39
|
+
/**
|
|
40
|
+
* Async task object schema.
|
|
41
|
+
*
|
|
42
|
+
* Long-running operations (e.g. markdown writes with `allow_async: true`) return an
|
|
43
|
+
* async task handle instead of completing synchronously. Poll `GET /v1/async_tasks/{id}`
|
|
44
|
+
* until the task reaches a terminal status.
|
|
45
|
+
*
|
|
46
|
+
* Notion API reference:
|
|
47
|
+
* https://developers.notion.com/reference/retrieve-async-task
|
|
48
|
+
*/
|
|
49
|
+
exports.ASYNC_TASK_STATUSES = [
|
|
50
|
+
'queued',
|
|
51
|
+
'running',
|
|
52
|
+
'retrying',
|
|
53
|
+
'succeeded',
|
|
54
|
+
'failed',
|
|
55
|
+
];
|
|
56
|
+
const asyncTaskOperationSchema = z.object({
|
|
57
|
+
surface: z.enum(['rest', 'mcp']),
|
|
58
|
+
name: z.string().trim(),
|
|
59
|
+
});
|
|
60
|
+
// Loosely-typed error shape (status/code/message/object), matching NotionErrorResponse's
|
|
61
|
+
// fields; kept as z.string() for `code` rather than the closed NotionErrorCode union since
|
|
62
|
+
// async-task errors aren't guaranteed to be limited to that set.
|
|
63
|
+
const asyncTaskErrorSchema = z.object({
|
|
64
|
+
object: z.literal('error'),
|
|
65
|
+
status: z.number(),
|
|
66
|
+
code: z.string().trim(),
|
|
67
|
+
message: z.string().trim(),
|
|
68
|
+
});
|
|
69
|
+
exports.asyncTaskSchema = z.object({
|
|
70
|
+
object: z.literal('async_task'),
|
|
71
|
+
id: z.uuid(),
|
|
72
|
+
status: z.enum(exports.ASYNC_TASK_STATUSES),
|
|
73
|
+
status_url: z.url(),
|
|
74
|
+
created_time: shared_schema_1.notionDateStringSchema,
|
|
75
|
+
operation: asyncTaskOperationSchema,
|
|
76
|
+
poll_after_seconds: z.number().optional(),
|
|
77
|
+
// Present only when status === 'succeeded'. Shape is operation-dependent (e.g. a
|
|
78
|
+
// PageMarkdown object for markdown writes), so it's kept as z.unknown() rather than
|
|
79
|
+
// guessed/narrowed.
|
|
80
|
+
result: z.unknown().optional(),
|
|
81
|
+
// Present only when status === 'failed'.
|
|
82
|
+
error: asyncTaskErrorSchema.optional(),
|
|
83
|
+
});
|