@visus-io/notion-sdk-ts 3.0.2 → 3.1.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 +20 -87
- package/dist/api/asyncTasks.api.d.ts +72 -0
- package/dist/api/asyncTasks.api.js +70 -0
- package/dist/api/base.api.d.ts +15 -4
- package/dist/api/base.api.js +20 -8
- package/dist/api/blocks.api.d.ts +435 -73
- package/dist/api/blocks.api.js +43 -1
- package/dist/api/comments.api.d.ts +42 -5
- package/dist/api/comments.api.js +45 -1
- package/dist/api/customEmojis.api.d.ts +38 -0
- package/dist/api/customEmojis.api.js +38 -0
- package/dist/api/dataSources.api.d.ts +67 -14
- package/dist/api/dataSources.api.js +26 -1
- package/dist/api/databases.api.d.ts +47 -11
- package/dist/api/databases.api.js +4 -1
- package/dist/api/fileUploads.api.d.ts +8 -5
- package/dist/api/fileUploads.api.js +11 -7
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +7 -1
- package/dist/api/pages.api.d.ts +144 -10
- package/dist/api/pages.api.js +66 -0
- package/dist/api/search.api.d.ts +12 -2
- package/dist/api/search.api.js +5 -2
- package/dist/api/users.api.d.ts +3 -0
- package/dist/api/users.api.js +2 -0
- package/dist/api/views.api.d.ts +286 -0
- package/dist/api/views.api.js +172 -0
- package/dist/client.d.ts +17 -17
- package/dist/client.js +25 -30
- package/dist/errors.d.ts +19 -5
- package/dist/errors.js +16 -4
- package/dist/helpers/block.helpers.d.ts +49 -5
- package/dist/helpers/block.helpers.js +50 -6
- package/dist/helpers/file.helpers.d.ts +46 -5
- package/dist/helpers/file.helpers.js +36 -8
- package/dist/helpers/filter.helpers.d.ts +8 -6
- package/dist/helpers/filter.helpers.js +2 -0
- package/dist/helpers/index.d.ts +3 -2
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/pagination.helpers.d.ts +85 -13
- package/dist/helpers/pagination.helpers.js +114 -8
- package/dist/helpers/parent.helpers.d.ts +5 -3
- package/dist/helpers/parent.helpers.js +5 -3
- package/dist/helpers/property.helpers.d.ts +31 -0
- package/dist/helpers/property.helpers.js +30 -1
- package/dist/helpers/richText.helpers.d.ts +10 -5
- package/dist/helpers/richText.helpers.js +11 -6
- package/dist/helpers/sort.helpers.d.ts +2 -0
- package/dist/helpers/sort.helpers.js +2 -0
- package/dist/helpers/webhook.helpers.d.ts +54 -0
- package/dist/helpers/webhook.helpers.js +83 -0
- package/dist/models/asyncTask.model.d.ts +61 -0
- package/dist/models/asyncTask.model.js +91 -0
- package/dist/models/base.model.d.ts +16 -4
- package/dist/models/base.model.js +17 -5
- package/dist/models/block.model.d.ts +6 -2
- package/dist/models/block.model.js +48 -33
- package/dist/models/comment.model.d.ts +4 -2
- package/dist/models/comment.model.js +4 -2
- package/dist/models/customEmoji.model.d.ts +30 -0
- package/dist/models/customEmoji.model.js +44 -0
- package/dist/models/dataSource.model.d.ts +7 -5
- package/dist/models/dataSource.model.js +5 -3
- package/dist/models/database.model.d.ts +13 -5
- package/dist/models/database.model.js +15 -5
- package/dist/models/fileUpload.model.d.ts +6 -4
- package/dist/models/fileUpload.model.js +6 -4
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +7 -1
- package/dist/models/page.model.d.ts +8 -2
- package/dist/models/page.model.js +14 -4
- package/dist/models/richText.model.d.ts +3 -1
- package/dist/models/richText.model.js +3 -1
- package/dist/models/user.model.d.ts +4 -2
- package/dist/models/user.model.js +4 -2
- package/dist/models/view.model.d.ts +81 -0
- package/dist/models/view.model.js +121 -0
- package/dist/notion.d.ts +32 -8
- package/dist/notion.js +25 -4
- package/dist/schemas/asyncTask.schema.d.ts +53 -0
- package/dist/schemas/asyncTask.schema.js +88 -0
- package/dist/schemas/block.schema.d.ts +390 -73
- package/dist/schemas/block.schema.js +39 -8
- package/dist/schemas/codeLanguages.d.ts +7 -1
- package/dist/schemas/codeLanguages.js +4 -1
- package/dist/schemas/colors.d.ts +7 -1
- package/dist/schemas/colors.js +4 -1
- package/dist/schemas/comment.schema.d.ts +28 -5
- package/dist/schemas/comment.schema.js +11 -2
- package/dist/schemas/customEmoji.schema.d.ts +18 -0
- package/dist/schemas/customEmoji.schema.js +50 -0
- package/dist/schemas/dataSource.schema.d.ts +84 -10
- package/dist/schemas/dataSource.schema.js +31 -6
- package/dist/schemas/database.schema.d.ts +51 -7
- package/dist/schemas/database.schema.js +10 -3
- package/dist/schemas/emoji.schema.d.ts +7 -2
- package/dist/schemas/emoji.schema.js +4 -2
- package/dist/schemas/file.schema.d.ts +18 -2
- package/dist/schemas/file.schema.js +6 -2
- package/dist/schemas/fileUpload.schema.d.ts +9 -3
- package/dist/schemas/fileUpload.schema.js +5 -2
- package/dist/schemas/icon.schema.d.ts +116 -0
- package/dist/schemas/icon.schema.js +100 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/index.js +6 -0
- package/dist/schemas/meetingNotesQuery.schema.d.ts +4198 -0
- package/dist/schemas/meetingNotesQuery.schema.js +67 -0
- package/dist/schemas/page.schema.d.ts +51 -9
- package/dist/schemas/page.schema.js +6 -2
- package/dist/schemas/pageMarkdown.schema.d.ts +70 -0
- package/dist/schemas/pageMarkdown.schema.js +70 -0
- package/dist/schemas/pageProperties.schema.d.ts +105 -21
- package/dist/schemas/pageProperties.schema.js +8 -6
- package/dist/schemas/pagination.schema.d.ts +57 -7
- package/dist/schemas/pagination.schema.js +25 -1
- package/dist/schemas/parent.schema.d.ts +39 -3
- package/dist/schemas/parent.schema.js +17 -5
- package/dist/schemas/propertyObjects.schema.d.ts +93 -15
- package/dist/schemas/propertyObjects.schema.js +11 -5
- package/dist/schemas/richText.schema.d.ts +23 -6
- package/dist/schemas/richText.schema.js +7 -4
- package/dist/schemas/shared.schema.d.ts +6 -3
- package/dist/schemas/shared.schema.js +6 -3
- package/dist/schemas/user.schema.d.ts +17 -0
- package/dist/schemas/user.schema.js +7 -3
- package/dist/schemas/view.schema.d.ts +1111 -0
- package/dist/schemas/view.schema.js +134 -0
- package/dist/validation.d.ts +11 -4
- package/dist/validation.js +11 -4
- package/package.json +6 -3
package/dist/api/blocks.api.js
CHANGED
|
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BlocksAPI = void 0;
|
|
4
4
|
const schemas_1 = require("../schemas");
|
|
5
5
|
const models_1 = require("../models");
|
|
6
|
+
const base_model_1 = require("../models/base.model");
|
|
6
7
|
const validation_1 = require("../validation");
|
|
7
8
|
const base_api_1 = require("./base.api");
|
|
8
9
|
/**
|
|
9
10
|
* Blocks API client for working with Notion blocks.
|
|
11
|
+
*
|
|
12
|
+
* @category Blocks
|
|
10
13
|
*/
|
|
11
14
|
class BlocksAPI extends base_api_1.BaseAPI {
|
|
12
15
|
constructor(client) {
|
|
@@ -53,12 +56,51 @@ class BlocksAPI extends base_api_1.BaseAPI {
|
|
|
53
56
|
const listSchema = (0, schemas_1.paginatedListSchema)(schemas_1.blockSchema);
|
|
54
57
|
const parsed = listSchema.parse(response);
|
|
55
58
|
return {
|
|
56
|
-
results: parsed.results.map((block) => new models_1.Block(block)),
|
|
59
|
+
results: parsed.results.map((block) => new models_1.Block(block, base_model_1.TRUSTED)),
|
|
57
60
|
next_cursor: parsed.next_cursor,
|
|
58
61
|
has_more: parsed.has_more,
|
|
59
62
|
};
|
|
60
63
|
},
|
|
61
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Meeting-notes query operations.
|
|
67
|
+
*/
|
|
68
|
+
this.meetingNotes = {
|
|
69
|
+
/**
|
|
70
|
+
* Query meeting-notes blocks across the workspace.
|
|
71
|
+
*
|
|
72
|
+
* @param options - Filter, sort, and limit options
|
|
73
|
+
* @returns Matching meeting-notes blocks
|
|
74
|
+
*
|
|
75
|
+
* @see https://developers.notion.com/reference/query-meeting-notes
|
|
76
|
+
*/
|
|
77
|
+
query: async (options) => {
|
|
78
|
+
if (options?.sort) {
|
|
79
|
+
(0, validation_1.validateArrayLength)(options.sort, validation_1.LIMITS.ARRAY_ELEMENTS, 'sort');
|
|
80
|
+
}
|
|
81
|
+
const body = {};
|
|
82
|
+
if (options?.filter) {
|
|
83
|
+
body.filter = options.filter;
|
|
84
|
+
}
|
|
85
|
+
if (options?.sort) {
|
|
86
|
+
body.sort = options.sort;
|
|
87
|
+
}
|
|
88
|
+
if (options?.limit) {
|
|
89
|
+
body.limit = options.limit;
|
|
90
|
+
}
|
|
91
|
+
const response = await this.client.request({
|
|
92
|
+
method: 'POST',
|
|
93
|
+
path: '/blocks/meeting_notes/query',
|
|
94
|
+
body: Object.keys(body).length > 0 ? body : undefined,
|
|
95
|
+
});
|
|
96
|
+
const parsed = schemas_1.meetingNotesQueryResponseSchema.parse(response);
|
|
97
|
+
return {
|
|
98
|
+
results: parsed.results.map((b) => new models_1.Block(b, base_model_1.TRUSTED)),
|
|
99
|
+
hasMore: parsed.has_more,
|
|
100
|
+
requestStatus: parsed.request_status,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
};
|
|
62
104
|
}
|
|
63
105
|
/**
|
|
64
106
|
* Retrieve a block by ID.
|
|
@@ -36,15 +36,28 @@ export interface CreateCommentOptions {
|
|
|
36
36
|
};
|
|
37
37
|
/** Optional discussion thread ID to add the comment to */
|
|
38
38
|
discussion_id?: string;
|
|
39
|
-
/** The comment content as rich text array (max 100 items) */
|
|
40
|
-
rich_text
|
|
39
|
+
/** The comment content as rich text array (max 100 items). Exactly one of `rich_text`/`markdown` must be provided. */
|
|
40
|
+
rich_text?: unknown[];
|
|
41
|
+
/** The comment content as a markdown string (inline formatting only). Exactly one of `rich_text`/`markdown` must be provided. */
|
|
42
|
+
markdown?: string;
|
|
41
43
|
/** File attachments (max 3 allowed) */
|
|
42
44
|
attachments?: CommentAttachment[];
|
|
43
45
|
/** Custom display name for the comment */
|
|
44
46
|
display_name?: CommentDisplayName;
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for updating a comment.
|
|
50
|
+
*/
|
|
51
|
+
export interface UpdateCommentOptions {
|
|
52
|
+
/** The comment content as rich text array (max 100 items). Exactly one of `rich_text`/`markdown` must be provided. */
|
|
53
|
+
rich_text?: unknown[];
|
|
54
|
+
/** The comment content as a markdown string (inline formatting only). Exactly one of `rich_text`/`markdown` must be provided. */
|
|
55
|
+
markdown?: string;
|
|
56
|
+
}
|
|
46
57
|
/**
|
|
47
58
|
* Comments API client for working with Notion comments.
|
|
59
|
+
*
|
|
60
|
+
* @category Comments
|
|
48
61
|
*/
|
|
49
62
|
export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
50
63
|
protected readonly client: NotionClient;
|
|
@@ -68,6 +81,9 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
68
81
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
69
82
|
type: import("zod").ZodLiteral<"block_id">;
|
|
70
83
|
block_id: import("zod").ZodUUID;
|
|
84
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
85
|
+
type: import("zod").ZodLiteral<"agent_id">;
|
|
86
|
+
agent_id: import("zod").ZodUUID;
|
|
71
87
|
}, import("zod/v4/core").$strip>], "type">;
|
|
72
88
|
discussion_id: import("zod").ZodUUID;
|
|
73
89
|
created_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
|
|
@@ -79,6 +95,7 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
79
95
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
80
96
|
person: import("zod").ZodObject<{
|
|
81
97
|
email: import("zod").ZodEmail;
|
|
98
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
82
99
|
}, import("zod/v4/core").$strip>;
|
|
83
100
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
84
101
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -119,11 +136,11 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
119
136
|
underline: import("zod").ZodBoolean;
|
|
120
137
|
code: import("zod").ZodBoolean;
|
|
121
138
|
color: import("zod").ZodEnum<{
|
|
139
|
+
default: "default";
|
|
122
140
|
blue: "blue";
|
|
123
141
|
blue_background: "blue_background";
|
|
124
142
|
brown: "brown";
|
|
125
143
|
brown_background: "brown_background";
|
|
126
|
-
default: "default";
|
|
127
144
|
gray: "gray";
|
|
128
145
|
gray_background: "gray_background";
|
|
129
146
|
green: "green";
|
|
@@ -188,6 +205,7 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
188
205
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
189
206
|
person: import("zod").ZodObject<{
|
|
190
207
|
email: import("zod").ZodEmail;
|
|
208
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
191
209
|
}, import("zod/v4/core").$strip>;
|
|
192
210
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
193
211
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -220,11 +238,11 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
220
238
|
underline: import("zod").ZodBoolean;
|
|
221
239
|
code: import("zod").ZodBoolean;
|
|
222
240
|
color: import("zod").ZodEnum<{
|
|
241
|
+
default: "default";
|
|
223
242
|
blue: "blue";
|
|
224
243
|
blue_background: "blue_background";
|
|
225
244
|
brown: "brown";
|
|
226
245
|
brown_background: "brown_background";
|
|
227
|
-
default: "default";
|
|
228
246
|
gray: "gray";
|
|
229
247
|
gray_background: "gray_background";
|
|
230
248
|
green: "green";
|
|
@@ -255,11 +273,11 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
255
273
|
underline: import("zod").ZodBoolean;
|
|
256
274
|
code: import("zod").ZodBoolean;
|
|
257
275
|
color: import("zod").ZodEnum<{
|
|
276
|
+
default: "default";
|
|
258
277
|
blue: "blue";
|
|
259
278
|
blue_background: "blue_background";
|
|
260
279
|
brown: "brown";
|
|
261
280
|
brown_background: "brown_background";
|
|
262
|
-
default: "default";
|
|
263
281
|
gray: "gray";
|
|
264
282
|
gray_background: "gray_background";
|
|
265
283
|
green: "green";
|
|
@@ -323,4 +341,23 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
323
341
|
* @see https://developers.notion.com/reference/create-a-comment
|
|
324
342
|
*/
|
|
325
343
|
create(options: CreateCommentOptions): Promise<Comment>;
|
|
344
|
+
/**
|
|
345
|
+
* Update an existing comment's content.
|
|
346
|
+
*
|
|
347
|
+
* @param commentId - The ID of the comment to update
|
|
348
|
+
* @param options - The updated comment content (`rich_text` or `markdown`)
|
|
349
|
+
* @returns The updated comment wrapped in a Comment model
|
|
350
|
+
*
|
|
351
|
+
* @see https://developers.notion.com/reference/update-a-comment
|
|
352
|
+
*/
|
|
353
|
+
update(commentId: string, options: UpdateCommentOptions): Promise<Comment>;
|
|
354
|
+
/**
|
|
355
|
+
* Delete a comment. A connection can only delete comments it created.
|
|
356
|
+
*
|
|
357
|
+
* @param commentId - The ID of the comment to delete
|
|
358
|
+
* @returns The deleted comment wrapped in a Comment model
|
|
359
|
+
*
|
|
360
|
+
* @see https://developers.notion.com/reference/delete-a-comment
|
|
361
|
+
*/
|
|
362
|
+
delete(commentId: string): Promise<Comment>;
|
|
326
363
|
}
|
package/dist/api/comments.api.js
CHANGED
|
@@ -5,8 +5,22 @@ const schemas_1 = require("../schemas");
|
|
|
5
5
|
const models_1 = require("../models");
|
|
6
6
|
const validation_1 = require("../validation");
|
|
7
7
|
const base_api_1 = require("./base.api");
|
|
8
|
+
/**
|
|
9
|
+
* Assert that exactly one of `rich_text`/`markdown` is provided for a comment body.
|
|
10
|
+
*
|
|
11
|
+
* @throws {NotionValidationError}
|
|
12
|
+
*/
|
|
13
|
+
function validateCommentContent(options) {
|
|
14
|
+
const hasRichText = options.rich_text !== undefined;
|
|
15
|
+
const hasMarkdown = options.markdown !== undefined;
|
|
16
|
+
if (hasRichText === hasMarkdown) {
|
|
17
|
+
throw new validation_1.NotionValidationError('Exactly one of rich_text or markdown must be provided');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
/**
|
|
9
21
|
* Comments API client for working with Notion comments.
|
|
22
|
+
*
|
|
23
|
+
* @category Comments
|
|
10
24
|
*/
|
|
11
25
|
class CommentsAPI extends base_api_1.BaseAPI {
|
|
12
26
|
constructor(client) {
|
|
@@ -43,11 +57,41 @@ class CommentsAPI extends base_api_1.BaseAPI {
|
|
|
43
57
|
* @see https://developers.notion.com/reference/create-a-comment
|
|
44
58
|
*/
|
|
45
59
|
async create(options) {
|
|
46
|
-
(
|
|
60
|
+
validateCommentContent(options);
|
|
61
|
+
if (options.rich_text) {
|
|
62
|
+
(0, validation_1.validateArrayLength)(options.rich_text, validation_1.LIMITS.ARRAY_ELEMENTS, 'rich_text');
|
|
63
|
+
}
|
|
47
64
|
if (options.attachments) {
|
|
48
65
|
(0, validation_1.validateArrayLength)(options.attachments, validation_1.LIMITS.COMMENT_ATTACHMENTS, 'attachments');
|
|
49
66
|
}
|
|
50
67
|
return this.createResource('/comments', options);
|
|
51
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Update an existing comment's content.
|
|
71
|
+
*
|
|
72
|
+
* @param commentId - The ID of the comment to update
|
|
73
|
+
* @param options - The updated comment content (`rich_text` or `markdown`)
|
|
74
|
+
* @returns The updated comment wrapped in a Comment model
|
|
75
|
+
*
|
|
76
|
+
* @see https://developers.notion.com/reference/update-a-comment
|
|
77
|
+
*/
|
|
78
|
+
async update(commentId, options) {
|
|
79
|
+
validateCommentContent(options);
|
|
80
|
+
if (options.rich_text) {
|
|
81
|
+
(0, validation_1.validateArrayLength)(options.rich_text, validation_1.LIMITS.ARRAY_ELEMENTS, 'rich_text');
|
|
82
|
+
}
|
|
83
|
+
return this.updateResource(`/comments/${commentId}`, options);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Delete a comment. A connection can only delete comments it created.
|
|
87
|
+
*
|
|
88
|
+
* @param commentId - The ID of the comment to delete
|
|
89
|
+
* @returns The deleted comment wrapped in a Comment model
|
|
90
|
+
*
|
|
91
|
+
* @see https://developers.notion.com/reference/delete-a-comment
|
|
92
|
+
*/
|
|
93
|
+
async delete(commentId) {
|
|
94
|
+
return this.deleteResource(`/comments/${commentId}`);
|
|
95
|
+
}
|
|
52
96
|
}
|
|
53
97
|
exports.CommentsAPI = CommentsAPI;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { NotionClient } from '../client';
|
|
2
|
+
import { type NotionCustomEmoji, type PaginatedList, type PaginationParameters } from '../schemas';
|
|
3
|
+
import { CustomEmoji } from '../models';
|
|
4
|
+
import { BaseAPI } from './base.api';
|
|
5
|
+
/**
|
|
6
|
+
* Options for listing custom emojis.
|
|
7
|
+
*/
|
|
8
|
+
export interface ListCustomEmojisOptions extends PaginationParameters {
|
|
9
|
+
/** Filter custom emojis by exact name match */
|
|
10
|
+
name?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Custom Emojis API client for working with Notion workspace custom emojis.
|
|
14
|
+
*
|
|
15
|
+
* @category Custom Emoji & Icons
|
|
16
|
+
*/
|
|
17
|
+
export declare class CustomEmojisAPI extends BaseAPI<NotionCustomEmoji, CustomEmoji> {
|
|
18
|
+
protected readonly client: NotionClient;
|
|
19
|
+
protected config: {
|
|
20
|
+
schema: import("zod").ZodObject<{
|
|
21
|
+
id: import("zod").ZodUUID;
|
|
22
|
+
name: import("zod").ZodString;
|
|
23
|
+
url: import("zod").ZodURL;
|
|
24
|
+
}, import("zod/v4/core").$strip>;
|
|
25
|
+
ModelClass: typeof CustomEmoji;
|
|
26
|
+
listType: "custom_emoji";
|
|
27
|
+
};
|
|
28
|
+
constructor(client: NotionClient);
|
|
29
|
+
/**
|
|
30
|
+
* List the custom emojis available in the workspace (paginated).
|
|
31
|
+
*
|
|
32
|
+
* @param options - Options for filtering by name and paginating results
|
|
33
|
+
* @returns Paginated list of custom emojis
|
|
34
|
+
*
|
|
35
|
+
* @see https://developers.notion.com/reference/list-custom-emojis
|
|
36
|
+
*/
|
|
37
|
+
list(options?: ListCustomEmojisOptions): Promise<PaginatedList<CustomEmoji>>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomEmojisAPI = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const base_api_1 = require("./base.api");
|
|
7
|
+
/**
|
|
8
|
+
* Custom Emojis API client for working with Notion workspace custom emojis.
|
|
9
|
+
*
|
|
10
|
+
* @category Custom Emoji & Icons
|
|
11
|
+
*/
|
|
12
|
+
class CustomEmojisAPI extends base_api_1.BaseAPI {
|
|
13
|
+
constructor(client) {
|
|
14
|
+
super(client);
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.config = {
|
|
17
|
+
schema: schemas_1.customEmojiSchema,
|
|
18
|
+
ModelClass: models_1.CustomEmoji,
|
|
19
|
+
listType: 'custom_emoji',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* List the custom emojis available in the workspace (paginated).
|
|
24
|
+
*
|
|
25
|
+
* @param options - Options for filtering by name and paginating results
|
|
26
|
+
* @returns Paginated list of custom emojis
|
|
27
|
+
*
|
|
28
|
+
* @see https://developers.notion.com/reference/list-custom-emojis
|
|
29
|
+
*/
|
|
30
|
+
async list(options) {
|
|
31
|
+
const query = {
|
|
32
|
+
...(options?.name ? { name: options.name } : {}),
|
|
33
|
+
...this.buildPaginationQuery(options),
|
|
34
|
+
};
|
|
35
|
+
return this.listResources('/custom_emojis', query);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.CustomEmojisAPI = CustomEmojisAPI;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NotionClient } from '../client';
|
|
2
|
-
import { type NotionDataSource, type PaginatedList, type PaginationParameters } from '../schemas';
|
|
2
|
+
import { type DataSourceTemplateList, type NotionDataSource, type PaginatedList, type PaginationParameters } from '../schemas';
|
|
3
3
|
import { DataSource, Page } from '../models';
|
|
4
4
|
import { BaseAPI } from './base.api';
|
|
5
5
|
/**
|
|
@@ -43,9 +43,16 @@ export interface RetrieveDataSourceOptions {
|
|
|
43
43
|
/** Filter properties to include in the response */
|
|
44
44
|
filter_properties?: string[];
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for listing a data source's templates.
|
|
48
|
+
*/
|
|
49
|
+
export interface ListDataSourceTemplatesOptions extends PaginationParameters {
|
|
50
|
+
/** Filter templates by name (case-insensitive substring match) */
|
|
51
|
+
name?: string;
|
|
52
|
+
}
|
|
46
53
|
/**
|
|
47
54
|
* Filter condition for data source queries.
|
|
48
|
-
* This is
|
|
55
|
+
* This type is simplified. The Notion API supports many more filter types.
|
|
49
56
|
* See: https://developers.notion.com/reference/filter-data-source-entries
|
|
50
57
|
*/
|
|
51
58
|
export type DataSourceFilter = Record<string, unknown>;
|
|
@@ -82,8 +89,8 @@ export interface QueryDataSourceOptions extends PaginationParameters {
|
|
|
82
89
|
/**
|
|
83
90
|
* Whether to return only trashed pages (true) or only non-trashed pages (false).
|
|
84
91
|
*
|
|
85
|
-
* @deprecated Use `is_archived` instead.
|
|
86
|
-
* `is_archived
|
|
92
|
+
* @deprecated Use `is_archived` instead. This field is an alias that forwards
|
|
93
|
+
* into `is_archived`. If you provide both fields, `is_archived` takes precedence.
|
|
87
94
|
*/
|
|
88
95
|
in_trash?: boolean;
|
|
89
96
|
}
|
|
@@ -92,6 +99,8 @@ export interface QueryDataSourceOptions extends PaginationParameters {
|
|
|
92
99
|
*
|
|
93
100
|
* Data sources are individual tables of data that live under a Notion database.
|
|
94
101
|
* As of API version 2025-09-03, data sources have their own API endpoints.
|
|
102
|
+
*
|
|
103
|
+
* @category Databases & Data Sources
|
|
95
104
|
*/
|
|
96
105
|
export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource> {
|
|
97
106
|
protected readonly client: NotionClient;
|
|
@@ -165,9 +174,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
165
174
|
id: import("zod").ZodString;
|
|
166
175
|
name: import("zod").ZodString;
|
|
167
176
|
color: import("zod").ZodEnum<{
|
|
177
|
+
default: "default";
|
|
168
178
|
blue: "blue";
|
|
169
179
|
brown: "brown";
|
|
170
|
-
default: "default";
|
|
171
180
|
gray: "gray";
|
|
172
181
|
green: "green";
|
|
173
182
|
orange: "orange";
|
|
@@ -309,9 +318,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
309
318
|
id: import("zod").ZodString;
|
|
310
319
|
name: import("zod").ZodString;
|
|
311
320
|
color: import("zod").ZodEnum<{
|
|
321
|
+
default: "default";
|
|
312
322
|
blue: "blue";
|
|
313
323
|
brown: "brown";
|
|
314
|
-
default: "default";
|
|
315
324
|
gray: "gray";
|
|
316
325
|
green: "green";
|
|
317
326
|
orange: "orange";
|
|
@@ -332,9 +341,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
332
341
|
id: import("zod").ZodString;
|
|
333
342
|
name: import("zod").ZodString;
|
|
334
343
|
color: import("zod").ZodEnum<{
|
|
344
|
+
default: "default";
|
|
335
345
|
blue: "blue";
|
|
336
346
|
brown: "brown";
|
|
337
|
-
default: "default";
|
|
338
347
|
gray: "gray";
|
|
339
348
|
green: "green";
|
|
340
349
|
orange: "orange";
|
|
@@ -348,9 +357,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
348
357
|
id: import("zod").ZodString;
|
|
349
358
|
name: import("zod").ZodString;
|
|
350
359
|
color: import("zod").ZodEnum<{
|
|
360
|
+
default: "default";
|
|
351
361
|
blue: "blue";
|
|
352
362
|
brown: "brown";
|
|
353
|
-
default: "default";
|
|
354
363
|
gray: "gray";
|
|
355
364
|
green: "green";
|
|
356
365
|
orange: "orange";
|
|
@@ -399,6 +408,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
399
408
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
400
409
|
type: import("zod").ZodLiteral<"block_id">;
|
|
401
410
|
block_id: import("zod").ZodUUID;
|
|
411
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
412
|
+
type: import("zod").ZodLiteral<"agent_id">;
|
|
413
|
+
agent_id: import("zod").ZodUUID;
|
|
402
414
|
}, import("zod/v4/core").$strip>], "type">;
|
|
403
415
|
database_parent: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
404
416
|
type: import("zod").ZodLiteral<"database_id">;
|
|
@@ -416,6 +428,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
416
428
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
417
429
|
type: import("zod").ZodLiteral<"block_id">;
|
|
418
430
|
block_id: import("zod").ZodUUID;
|
|
431
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
432
|
+
type: import("zod").ZodLiteral<"agent_id">;
|
|
433
|
+
agent_id: import("zod").ZodUUID;
|
|
419
434
|
}, import("zod/v4/core").$strip>], "type">;
|
|
420
435
|
created_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
|
|
421
436
|
created_by: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
@@ -426,6 +441,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
426
441
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
427
442
|
person: import("zod").ZodObject<{
|
|
428
443
|
email: import("zod").ZodEmail;
|
|
444
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
429
445
|
}, import("zod/v4/core").$strip>;
|
|
430
446
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
431
447
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -459,6 +475,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
459
475
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
460
476
|
person: import("zod").ZodObject<{
|
|
461
477
|
email: import("zod").ZodEmail;
|
|
478
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
462
479
|
}, import("zod/v4/core").$strip>;
|
|
463
480
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
464
481
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -498,11 +515,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
498
515
|
underline: import("zod").ZodBoolean;
|
|
499
516
|
code: import("zod").ZodBoolean;
|
|
500
517
|
color: import("zod").ZodEnum<{
|
|
518
|
+
default: "default";
|
|
501
519
|
blue: "blue";
|
|
502
520
|
blue_background: "blue_background";
|
|
503
521
|
brown: "brown";
|
|
504
522
|
brown_background: "brown_background";
|
|
505
|
-
default: "default";
|
|
506
523
|
gray: "gray";
|
|
507
524
|
gray_background: "gray_background";
|
|
508
525
|
green: "green";
|
|
@@ -567,6 +584,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
567
584
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
568
585
|
person: import("zod").ZodObject<{
|
|
569
586
|
email: import("zod").ZodEmail;
|
|
587
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
570
588
|
}, import("zod/v4/core").$strip>;
|
|
571
589
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
572
590
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -599,11 +617,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
599
617
|
underline: import("zod").ZodBoolean;
|
|
600
618
|
code: import("zod").ZodBoolean;
|
|
601
619
|
color: import("zod").ZodEnum<{
|
|
620
|
+
default: "default";
|
|
602
621
|
blue: "blue";
|
|
603
622
|
blue_background: "blue_background";
|
|
604
623
|
brown: "brown";
|
|
605
624
|
brown_background: "brown_background";
|
|
606
|
-
default: "default";
|
|
607
625
|
gray: "gray";
|
|
608
626
|
gray_background: "gray_background";
|
|
609
627
|
green: "green";
|
|
@@ -634,11 +652,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
634
652
|
underline: import("zod").ZodBoolean;
|
|
635
653
|
code: import("zod").ZodBoolean;
|
|
636
654
|
color: import("zod").ZodEnum<{
|
|
655
|
+
default: "default";
|
|
637
656
|
blue: "blue";
|
|
638
657
|
blue_background: "blue_background";
|
|
639
658
|
brown: "brown";
|
|
640
659
|
brown_background: "brown_background";
|
|
641
|
-
default: "default";
|
|
642
660
|
gray: "gray";
|
|
643
661
|
gray_background: "gray_background";
|
|
644
662
|
green: "green";
|
|
@@ -673,11 +691,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
673
691
|
underline: import("zod").ZodBoolean;
|
|
674
692
|
code: import("zod").ZodBoolean;
|
|
675
693
|
color: import("zod").ZodEnum<{
|
|
694
|
+
default: "default";
|
|
676
695
|
blue: "blue";
|
|
677
696
|
blue_background: "blue_background";
|
|
678
697
|
brown: "brown";
|
|
679
698
|
brown_background: "brown_background";
|
|
680
|
-
default: "default";
|
|
681
699
|
gray: "gray";
|
|
682
700
|
gray_background: "gray_background";
|
|
683
701
|
green: "green";
|
|
@@ -742,6 +760,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
742
760
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
743
761
|
person: import("zod").ZodObject<{
|
|
744
762
|
email: import("zod").ZodEmail;
|
|
763
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
745
764
|
}, import("zod/v4/core").$strip>;
|
|
746
765
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
747
766
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -774,11 +793,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
774
793
|
underline: import("zod").ZodBoolean;
|
|
775
794
|
code: import("zod").ZodBoolean;
|
|
776
795
|
color: import("zod").ZodEnum<{
|
|
796
|
+
default: "default";
|
|
777
797
|
blue: "blue";
|
|
778
798
|
blue_background: "blue_background";
|
|
779
799
|
brown: "brown";
|
|
780
800
|
brown_background: "brown_background";
|
|
781
|
-
default: "default";
|
|
782
801
|
gray: "gray";
|
|
783
802
|
gray_background: "gray_background";
|
|
784
803
|
green: "green";
|
|
@@ -809,11 +828,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
809
828
|
underline: import("zod").ZodBoolean;
|
|
810
829
|
code: import("zod").ZodBoolean;
|
|
811
830
|
color: import("zod").ZodEnum<{
|
|
831
|
+
default: "default";
|
|
812
832
|
blue: "blue";
|
|
813
833
|
blue_background: "blue_background";
|
|
814
834
|
brown: "brown";
|
|
815
835
|
brown_background: "brown_background";
|
|
816
|
-
default: "default";
|
|
817
836
|
gray: "gray";
|
|
818
837
|
gray_background: "gray_background";
|
|
819
838
|
green: "green";
|
|
@@ -852,6 +871,30 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
852
871
|
}, import("zod/v4/core").$strip>], "type">, import("zod").ZodObject<{
|
|
853
872
|
type: import("zod").ZodLiteral<"emoji">;
|
|
854
873
|
emoji: import("zod").ZodString;
|
|
874
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
875
|
+
type: import("zod").ZodLiteral<"icon">;
|
|
876
|
+
icon: import("zod").ZodObject<{
|
|
877
|
+
name: import("zod").ZodString;
|
|
878
|
+
color: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
879
|
+
blue: "blue";
|
|
880
|
+
brown: "brown";
|
|
881
|
+
gray: "gray";
|
|
882
|
+
green: "green";
|
|
883
|
+
orange: "orange";
|
|
884
|
+
pink: "pink";
|
|
885
|
+
purple: "purple";
|
|
886
|
+
red: "red";
|
|
887
|
+
yellow: "yellow";
|
|
888
|
+
lightgray: "lightgray";
|
|
889
|
+
}>>;
|
|
890
|
+
}, import("zod/v4/core").$strip>;
|
|
891
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
892
|
+
type: import("zod").ZodLiteral<"custom_emoji">;
|
|
893
|
+
custom_emoji: import("zod").ZodObject<{
|
|
894
|
+
id: import("zod").ZodUUID;
|
|
895
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
896
|
+
url: import("zod").ZodOptional<import("zod").ZodURL>;
|
|
897
|
+
}, import("zod/v4/core").$strip>;
|
|
855
898
|
}, import("zod/v4/core").$strip>]>>;
|
|
856
899
|
cover: import("zod").ZodNullable<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
857
900
|
type: import("zod").ZodLiteral<"file">;
|
|
@@ -889,6 +932,16 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
889
932
|
* @see https://developers.notion.com/reference/retrieve-a-data-source
|
|
890
933
|
*/
|
|
891
934
|
retrieve(dataSourceId: string, options?: RetrieveDataSourceOptions): Promise<DataSource>;
|
|
935
|
+
/**
|
|
936
|
+
* List the templates available for a data source.
|
|
937
|
+
*
|
|
938
|
+
* @param dataSourceId - The ID of the data source
|
|
939
|
+
* @param options - Options for filtering by name and paginating results
|
|
940
|
+
* @returns The list of templates, along with pagination metadata
|
|
941
|
+
*
|
|
942
|
+
* @see https://developers.notion.com/reference/list-data-source-templates
|
|
943
|
+
*/
|
|
944
|
+
listTemplates(dataSourceId: string, options?: ListDataSourceTemplatesOptions): Promise<DataSourceTemplateList>;
|
|
892
945
|
/**
|
|
893
946
|
* Query a data source with optional filters and sorts.
|
|
894
947
|
* Returns pages that match the query.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataSourcesAPI = void 0;
|
|
4
4
|
const schemas_1 = require("../schemas");
|
|
5
5
|
const models_1 = require("../models");
|
|
6
|
+
const base_model_1 = require("../models/base.model");
|
|
6
7
|
const validation_1 = require("../validation");
|
|
7
8
|
const base_api_1 = require("./base.api");
|
|
8
9
|
/**
|
|
@@ -10,6 +11,8 @@ const base_api_1 = require("./base.api");
|
|
|
10
11
|
*
|
|
11
12
|
* Data sources are individual tables of data that live under a Notion database.
|
|
12
13
|
* As of API version 2025-09-03, data sources have their own API endpoints.
|
|
14
|
+
*
|
|
15
|
+
* @category Databases & Data Sources
|
|
13
16
|
*/
|
|
14
17
|
class DataSourcesAPI extends base_api_1.BaseAPI {
|
|
15
18
|
constructor(client) {
|
|
@@ -36,6 +39,27 @@ class DataSourcesAPI extends base_api_1.BaseAPI {
|
|
|
36
39
|
};
|
|
37
40
|
return this.retrieveResource(`/data_sources/${dataSourceId}`, query);
|
|
38
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* List the templates available for a data source.
|
|
44
|
+
*
|
|
45
|
+
* @param dataSourceId - The ID of the data source
|
|
46
|
+
* @param options - Options for filtering by name and paginating results
|
|
47
|
+
* @returns The list of templates, along with pagination metadata
|
|
48
|
+
*
|
|
49
|
+
* @see https://developers.notion.com/reference/list-data-source-templates
|
|
50
|
+
*/
|
|
51
|
+
async listTemplates(dataSourceId, options) {
|
|
52
|
+
const query = {
|
|
53
|
+
...(options?.name ? { name: options.name } : {}),
|
|
54
|
+
...this.buildPaginationQuery(options),
|
|
55
|
+
};
|
|
56
|
+
const response = await this.client.request({
|
|
57
|
+
method: 'GET',
|
|
58
|
+
path: `/data_sources/${dataSourceId}/templates`,
|
|
59
|
+
query: Object.keys(query).length > 0 ? query : undefined,
|
|
60
|
+
});
|
|
61
|
+
return schemas_1.dataSourceTemplateListSchema.parse(response);
|
|
62
|
+
}
|
|
39
63
|
/**
|
|
40
64
|
* Query a data source with optional filters and sorts.
|
|
41
65
|
* Returns pages that match the query.
|
|
@@ -82,10 +106,11 @@ class DataSourcesAPI extends base_api_1.BaseAPI {
|
|
|
82
106
|
const parsed = listSchema.parse(response);
|
|
83
107
|
return {
|
|
84
108
|
object: 'list',
|
|
85
|
-
results: parsed.results.map((page) => new models_1.Page(page)),
|
|
109
|
+
results: parsed.results.map((page) => new models_1.Page(page, base_model_1.TRUSTED)),
|
|
86
110
|
next_cursor: parsed.next_cursor,
|
|
87
111
|
has_more: parsed.has_more,
|
|
88
112
|
type: 'page',
|
|
113
|
+
request_status: parsed.request_status,
|
|
89
114
|
};
|
|
90
115
|
}
|
|
91
116
|
/**
|