@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/api/blocks.api.js
CHANGED
|
@@ -59,6 +59,45 @@ class BlocksAPI extends base_api_1.BaseAPI {
|
|
|
59
59
|
};
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Meeting-notes query operations.
|
|
64
|
+
*/
|
|
65
|
+
this.meetingNotes = {
|
|
66
|
+
/**
|
|
67
|
+
* Query meeting-notes blocks across the workspace.
|
|
68
|
+
*
|
|
69
|
+
* @param options - Filter, sort, and limit options
|
|
70
|
+
* @returns Matching meeting-notes blocks
|
|
71
|
+
*
|
|
72
|
+
* @see https://developers.notion.com/reference/query-meeting-notes
|
|
73
|
+
*/
|
|
74
|
+
query: async (options) => {
|
|
75
|
+
if (options?.sort) {
|
|
76
|
+
(0, validation_1.validateArrayLength)(options.sort, validation_1.LIMITS.ARRAY_ELEMENTS, 'sort');
|
|
77
|
+
}
|
|
78
|
+
const body = {};
|
|
79
|
+
if (options?.filter) {
|
|
80
|
+
body.filter = options.filter;
|
|
81
|
+
}
|
|
82
|
+
if (options?.sort) {
|
|
83
|
+
body.sort = options.sort;
|
|
84
|
+
}
|
|
85
|
+
if (options?.limit) {
|
|
86
|
+
body.limit = options.limit;
|
|
87
|
+
}
|
|
88
|
+
const response = await this.client.request({
|
|
89
|
+
method: 'POST',
|
|
90
|
+
path: '/blocks/meeting_notes/query',
|
|
91
|
+
body: Object.keys(body).length > 0 ? body : undefined,
|
|
92
|
+
});
|
|
93
|
+
const parsed = schemas_1.meetingNotesQueryResponseSchema.parse(response);
|
|
94
|
+
return {
|
|
95
|
+
results: parsed.results.map((b) => new models_1.Block(b)),
|
|
96
|
+
hasMore: parsed.has_more,
|
|
97
|
+
requestStatus: parsed.request_status,
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
};
|
|
62
101
|
}
|
|
63
102
|
/**
|
|
64
103
|
* Retrieve a block by ID.
|
|
@@ -36,13 +36,24 @@ 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.
|
|
48
59
|
*/
|
|
@@ -68,6 +79,9 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
68
79
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
69
80
|
type: import("zod").ZodLiteral<"block_id">;
|
|
70
81
|
block_id: import("zod").ZodUUID;
|
|
82
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
83
|
+
type: import("zod").ZodLiteral<"agent_id">;
|
|
84
|
+
agent_id: import("zod").ZodUUID;
|
|
71
85
|
}, import("zod/v4/core").$strip>], "type">;
|
|
72
86
|
discussion_id: import("zod").ZodUUID;
|
|
73
87
|
created_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
|
|
@@ -79,6 +93,7 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
79
93
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
80
94
|
person: import("zod").ZodObject<{
|
|
81
95
|
email: import("zod").ZodEmail;
|
|
96
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
82
97
|
}, import("zod/v4/core").$strip>;
|
|
83
98
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
84
99
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -119,11 +134,11 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
119
134
|
underline: import("zod").ZodBoolean;
|
|
120
135
|
code: import("zod").ZodBoolean;
|
|
121
136
|
color: import("zod").ZodEnum<{
|
|
137
|
+
default: "default";
|
|
122
138
|
blue: "blue";
|
|
123
139
|
blue_background: "blue_background";
|
|
124
140
|
brown: "brown";
|
|
125
141
|
brown_background: "brown_background";
|
|
126
|
-
default: "default";
|
|
127
142
|
gray: "gray";
|
|
128
143
|
gray_background: "gray_background";
|
|
129
144
|
green: "green";
|
|
@@ -188,6 +203,7 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
188
203
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
189
204
|
person: import("zod").ZodObject<{
|
|
190
205
|
email: import("zod").ZodEmail;
|
|
206
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
191
207
|
}, import("zod/v4/core").$strip>;
|
|
192
208
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
193
209
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -220,11 +236,11 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
220
236
|
underline: import("zod").ZodBoolean;
|
|
221
237
|
code: import("zod").ZodBoolean;
|
|
222
238
|
color: import("zod").ZodEnum<{
|
|
239
|
+
default: "default";
|
|
223
240
|
blue: "blue";
|
|
224
241
|
blue_background: "blue_background";
|
|
225
242
|
brown: "brown";
|
|
226
243
|
brown_background: "brown_background";
|
|
227
|
-
default: "default";
|
|
228
244
|
gray: "gray";
|
|
229
245
|
gray_background: "gray_background";
|
|
230
246
|
green: "green";
|
|
@@ -255,11 +271,11 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
255
271
|
underline: import("zod").ZodBoolean;
|
|
256
272
|
code: import("zod").ZodBoolean;
|
|
257
273
|
color: import("zod").ZodEnum<{
|
|
274
|
+
default: "default";
|
|
258
275
|
blue: "blue";
|
|
259
276
|
blue_background: "blue_background";
|
|
260
277
|
brown: "brown";
|
|
261
278
|
brown_background: "brown_background";
|
|
262
|
-
default: "default";
|
|
263
279
|
gray: "gray";
|
|
264
280
|
gray_background: "gray_background";
|
|
265
281
|
green: "green";
|
|
@@ -323,4 +339,23 @@ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
|
|
|
323
339
|
* @see https://developers.notion.com/reference/create-a-comment
|
|
324
340
|
*/
|
|
325
341
|
create(options: CreateCommentOptions): Promise<Comment>;
|
|
342
|
+
/**
|
|
343
|
+
* Update an existing comment's content.
|
|
344
|
+
*
|
|
345
|
+
* @param commentId - The ID of the comment to update
|
|
346
|
+
* @param options - The updated comment content (`rich_text` or `markdown`)
|
|
347
|
+
* @returns The updated comment wrapped in a Comment model
|
|
348
|
+
*
|
|
349
|
+
* @see https://developers.notion.com/reference/update-a-comment
|
|
350
|
+
*/
|
|
351
|
+
update(commentId: string, options: UpdateCommentOptions): Promise<Comment>;
|
|
352
|
+
/**
|
|
353
|
+
* Delete a comment. A connection can only delete comments it created.
|
|
354
|
+
*
|
|
355
|
+
* @param commentId - The ID of the comment to delete
|
|
356
|
+
* @returns The deleted comment wrapped in a Comment model
|
|
357
|
+
*
|
|
358
|
+
* @see https://developers.notion.com/reference/delete-a-comment
|
|
359
|
+
*/
|
|
360
|
+
delete(commentId: string): Promise<Comment>;
|
|
326
361
|
}
|
package/dist/api/comments.api.js
CHANGED
|
@@ -5,6 +5,18 @@ 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.
|
|
10
22
|
*/
|
|
@@ -43,11 +55,41 @@ class CommentsAPI extends base_api_1.BaseAPI {
|
|
|
43
55
|
* @see https://developers.notion.com/reference/create-a-comment
|
|
44
56
|
*/
|
|
45
57
|
async create(options) {
|
|
46
|
-
(
|
|
58
|
+
validateCommentContent(options);
|
|
59
|
+
if (options.rich_text) {
|
|
60
|
+
(0, validation_1.validateArrayLength)(options.rich_text, validation_1.LIMITS.ARRAY_ELEMENTS, 'rich_text');
|
|
61
|
+
}
|
|
47
62
|
if (options.attachments) {
|
|
48
63
|
(0, validation_1.validateArrayLength)(options.attachments, validation_1.LIMITS.COMMENT_ATTACHMENTS, 'attachments');
|
|
49
64
|
}
|
|
50
65
|
return this.createResource('/comments', options);
|
|
51
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Update an existing comment's content.
|
|
69
|
+
*
|
|
70
|
+
* @param commentId - The ID of the comment to update
|
|
71
|
+
* @param options - The updated comment content (`rich_text` or `markdown`)
|
|
72
|
+
* @returns The updated comment wrapped in a Comment model
|
|
73
|
+
*
|
|
74
|
+
* @see https://developers.notion.com/reference/update-a-comment
|
|
75
|
+
*/
|
|
76
|
+
async update(commentId, options) {
|
|
77
|
+
validateCommentContent(options);
|
|
78
|
+
if (options.rich_text) {
|
|
79
|
+
(0, validation_1.validateArrayLength)(options.rich_text, validation_1.LIMITS.ARRAY_ELEMENTS, 'rich_text');
|
|
80
|
+
}
|
|
81
|
+
return this.updateResource(`/comments/${commentId}`, options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Delete a comment. A connection can only delete comments it created.
|
|
85
|
+
*
|
|
86
|
+
* @param commentId - The ID of the comment to delete
|
|
87
|
+
* @returns The deleted comment wrapped in a Comment model
|
|
88
|
+
*
|
|
89
|
+
* @see https://developers.notion.com/reference/delete-a-comment
|
|
90
|
+
*/
|
|
91
|
+
async delete(commentId) {
|
|
92
|
+
return this.deleteResource(`/comments/${commentId}`);
|
|
93
|
+
}
|
|
52
94
|
}
|
|
53
95
|
exports.CommentsAPI = CommentsAPI;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
export declare class CustomEmojisAPI extends BaseAPI<NotionCustomEmoji, CustomEmoji> {
|
|
16
|
+
protected readonly client: NotionClient;
|
|
17
|
+
protected config: {
|
|
18
|
+
schema: import("zod").ZodObject<{
|
|
19
|
+
id: import("zod").ZodUUID;
|
|
20
|
+
name: import("zod").ZodString;
|
|
21
|
+
url: import("zod").ZodURL;
|
|
22
|
+
}, import("zod/v4/core").$strip>;
|
|
23
|
+
ModelClass: typeof CustomEmoji;
|
|
24
|
+
listType: "custom_emoji";
|
|
25
|
+
};
|
|
26
|
+
constructor(client: NotionClient);
|
|
27
|
+
/**
|
|
28
|
+
* List the custom emojis available in the workspace (paginated).
|
|
29
|
+
*
|
|
30
|
+
* @param options - Options for filtering by name and paginating results
|
|
31
|
+
* @returns Paginated list of custom emojis
|
|
32
|
+
*
|
|
33
|
+
* @see https://developers.notion.com/reference/list-custom-emojis
|
|
34
|
+
*/
|
|
35
|
+
list(options?: ListCustomEmojisOptions): Promise<PaginatedList<CustomEmoji>>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
class CustomEmojisAPI extends base_api_1.BaseAPI {
|
|
11
|
+
constructor(client) {
|
|
12
|
+
super(client);
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.config = {
|
|
15
|
+
schema: schemas_1.customEmojiSchema,
|
|
16
|
+
ModelClass: models_1.CustomEmoji,
|
|
17
|
+
listType: 'custom_emoji',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* List the custom emojis available in the workspace (paginated).
|
|
22
|
+
*
|
|
23
|
+
* @param options - Options for filtering by name and paginating results
|
|
24
|
+
* @returns Paginated list of custom emojis
|
|
25
|
+
*
|
|
26
|
+
* @see https://developers.notion.com/reference/list-custom-emojis
|
|
27
|
+
*/
|
|
28
|
+
async list(options) {
|
|
29
|
+
const query = {
|
|
30
|
+
...(options?.name ? { name: options.name } : {}),
|
|
31
|
+
...this.buildPaginationQuery(options),
|
|
32
|
+
};
|
|
33
|
+
return this.listResources('/custom_emojis', query);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
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,6 +43,13 @@ 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
55
|
* This is a simplified type - the actual Notion API supports many filter types.
|
|
@@ -77,7 +84,14 @@ export interface QueryDataSourceOptions extends PaginationParameters {
|
|
|
77
84
|
filter_properties?: string[];
|
|
78
85
|
/** Filter by result type (for wikis) */
|
|
79
86
|
result_type?: 'page' | 'data_source';
|
|
80
|
-
/**
|
|
87
|
+
/** Whether to return only archived pages (true) or only non-archived pages (false, default) */
|
|
88
|
+
is_archived?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether to return only trashed pages (true) or only non-trashed pages (false).
|
|
91
|
+
*
|
|
92
|
+
* @deprecated Use `is_archived` instead. Kept as an alias forwarded into
|
|
93
|
+
* `is_archived`; if both are provided, `is_archived` takes precedence.
|
|
94
|
+
*/
|
|
81
95
|
in_trash?: boolean;
|
|
82
96
|
}
|
|
83
97
|
/**
|
|
@@ -158,9 +172,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
158
172
|
id: import("zod").ZodString;
|
|
159
173
|
name: import("zod").ZodString;
|
|
160
174
|
color: import("zod").ZodEnum<{
|
|
175
|
+
default: "default";
|
|
161
176
|
blue: "blue";
|
|
162
177
|
brown: "brown";
|
|
163
|
-
default: "default";
|
|
164
178
|
gray: "gray";
|
|
165
179
|
green: "green";
|
|
166
180
|
orange: "orange";
|
|
@@ -302,9 +316,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
302
316
|
id: import("zod").ZodString;
|
|
303
317
|
name: import("zod").ZodString;
|
|
304
318
|
color: import("zod").ZodEnum<{
|
|
319
|
+
default: "default";
|
|
305
320
|
blue: "blue";
|
|
306
321
|
brown: "brown";
|
|
307
|
-
default: "default";
|
|
308
322
|
gray: "gray";
|
|
309
323
|
green: "green";
|
|
310
324
|
orange: "orange";
|
|
@@ -325,9 +339,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
325
339
|
id: import("zod").ZodString;
|
|
326
340
|
name: import("zod").ZodString;
|
|
327
341
|
color: import("zod").ZodEnum<{
|
|
342
|
+
default: "default";
|
|
328
343
|
blue: "blue";
|
|
329
344
|
brown: "brown";
|
|
330
|
-
default: "default";
|
|
331
345
|
gray: "gray";
|
|
332
346
|
green: "green";
|
|
333
347
|
orange: "orange";
|
|
@@ -341,9 +355,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
341
355
|
id: import("zod").ZodString;
|
|
342
356
|
name: import("zod").ZodString;
|
|
343
357
|
color: import("zod").ZodEnum<{
|
|
358
|
+
default: "default";
|
|
344
359
|
blue: "blue";
|
|
345
360
|
brown: "brown";
|
|
346
|
-
default: "default";
|
|
347
361
|
gray: "gray";
|
|
348
362
|
green: "green";
|
|
349
363
|
orange: "orange";
|
|
@@ -392,6 +406,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
392
406
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
393
407
|
type: import("zod").ZodLiteral<"block_id">;
|
|
394
408
|
block_id: import("zod").ZodUUID;
|
|
409
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
410
|
+
type: import("zod").ZodLiteral<"agent_id">;
|
|
411
|
+
agent_id: import("zod").ZodUUID;
|
|
395
412
|
}, import("zod/v4/core").$strip>], "type">;
|
|
396
413
|
database_parent: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
397
414
|
type: import("zod").ZodLiteral<"database_id">;
|
|
@@ -409,6 +426,9 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
409
426
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
410
427
|
type: import("zod").ZodLiteral<"block_id">;
|
|
411
428
|
block_id: import("zod").ZodUUID;
|
|
429
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
430
|
+
type: import("zod").ZodLiteral<"agent_id">;
|
|
431
|
+
agent_id: import("zod").ZodUUID;
|
|
412
432
|
}, import("zod/v4/core").$strip>], "type">;
|
|
413
433
|
created_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
|
|
414
434
|
created_by: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
@@ -419,6 +439,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
419
439
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
420
440
|
person: import("zod").ZodObject<{
|
|
421
441
|
email: import("zod").ZodEmail;
|
|
442
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
422
443
|
}, import("zod/v4/core").$strip>;
|
|
423
444
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
424
445
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -452,6 +473,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
452
473
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
453
474
|
person: import("zod").ZodObject<{
|
|
454
475
|
email: import("zod").ZodEmail;
|
|
476
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
455
477
|
}, import("zod/v4/core").$strip>;
|
|
456
478
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
457
479
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -491,11 +513,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
491
513
|
underline: import("zod").ZodBoolean;
|
|
492
514
|
code: import("zod").ZodBoolean;
|
|
493
515
|
color: import("zod").ZodEnum<{
|
|
516
|
+
default: "default";
|
|
494
517
|
blue: "blue";
|
|
495
518
|
blue_background: "blue_background";
|
|
496
519
|
brown: "brown";
|
|
497
520
|
brown_background: "brown_background";
|
|
498
|
-
default: "default";
|
|
499
521
|
gray: "gray";
|
|
500
522
|
gray_background: "gray_background";
|
|
501
523
|
green: "green";
|
|
@@ -560,6 +582,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
560
582
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
561
583
|
person: import("zod").ZodObject<{
|
|
562
584
|
email: import("zod").ZodEmail;
|
|
585
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
563
586
|
}, import("zod/v4/core").$strip>;
|
|
564
587
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
565
588
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -592,11 +615,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
592
615
|
underline: import("zod").ZodBoolean;
|
|
593
616
|
code: import("zod").ZodBoolean;
|
|
594
617
|
color: import("zod").ZodEnum<{
|
|
618
|
+
default: "default";
|
|
595
619
|
blue: "blue";
|
|
596
620
|
blue_background: "blue_background";
|
|
597
621
|
brown: "brown";
|
|
598
622
|
brown_background: "brown_background";
|
|
599
|
-
default: "default";
|
|
600
623
|
gray: "gray";
|
|
601
624
|
gray_background: "gray_background";
|
|
602
625
|
green: "green";
|
|
@@ -627,11 +650,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
627
650
|
underline: import("zod").ZodBoolean;
|
|
628
651
|
code: import("zod").ZodBoolean;
|
|
629
652
|
color: import("zod").ZodEnum<{
|
|
653
|
+
default: "default";
|
|
630
654
|
blue: "blue";
|
|
631
655
|
blue_background: "blue_background";
|
|
632
656
|
brown: "brown";
|
|
633
657
|
brown_background: "brown_background";
|
|
634
|
-
default: "default";
|
|
635
658
|
gray: "gray";
|
|
636
659
|
gray_background: "gray_background";
|
|
637
660
|
green: "green";
|
|
@@ -666,11 +689,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
666
689
|
underline: import("zod").ZodBoolean;
|
|
667
690
|
code: import("zod").ZodBoolean;
|
|
668
691
|
color: import("zod").ZodEnum<{
|
|
692
|
+
default: "default";
|
|
669
693
|
blue: "blue";
|
|
670
694
|
blue_background: "blue_background";
|
|
671
695
|
brown: "brown";
|
|
672
696
|
brown_background: "brown_background";
|
|
673
|
-
default: "default";
|
|
674
697
|
gray: "gray";
|
|
675
698
|
gray_background: "gray_background";
|
|
676
699
|
green: "green";
|
|
@@ -735,6 +758,7 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
735
758
|
avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
|
|
736
759
|
person: import("zod").ZodObject<{
|
|
737
760
|
email: import("zod").ZodEmail;
|
|
761
|
+
email_verified: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
738
762
|
}, import("zod/v4/core").$strip>;
|
|
739
763
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
740
764
|
object: import("zod").ZodLiteral<"user">;
|
|
@@ -767,11 +791,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
767
791
|
underline: import("zod").ZodBoolean;
|
|
768
792
|
code: import("zod").ZodBoolean;
|
|
769
793
|
color: import("zod").ZodEnum<{
|
|
794
|
+
default: "default";
|
|
770
795
|
blue: "blue";
|
|
771
796
|
blue_background: "blue_background";
|
|
772
797
|
brown: "brown";
|
|
773
798
|
brown_background: "brown_background";
|
|
774
|
-
default: "default";
|
|
775
799
|
gray: "gray";
|
|
776
800
|
gray_background: "gray_background";
|
|
777
801
|
green: "green";
|
|
@@ -802,11 +826,11 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
802
826
|
underline: import("zod").ZodBoolean;
|
|
803
827
|
code: import("zod").ZodBoolean;
|
|
804
828
|
color: import("zod").ZodEnum<{
|
|
829
|
+
default: "default";
|
|
805
830
|
blue: "blue";
|
|
806
831
|
blue_background: "blue_background";
|
|
807
832
|
brown: "brown";
|
|
808
833
|
brown_background: "brown_background";
|
|
809
|
-
default: "default";
|
|
810
834
|
gray: "gray";
|
|
811
835
|
gray_background: "gray_background";
|
|
812
836
|
green: "green";
|
|
@@ -845,6 +869,30 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
845
869
|
}, import("zod/v4/core").$strip>], "type">, import("zod").ZodObject<{
|
|
846
870
|
type: import("zod").ZodLiteral<"emoji">;
|
|
847
871
|
emoji: import("zod").ZodString;
|
|
872
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
873
|
+
type: import("zod").ZodLiteral<"icon">;
|
|
874
|
+
icon: import("zod").ZodObject<{
|
|
875
|
+
name: import("zod").ZodString;
|
|
876
|
+
color: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
877
|
+
blue: "blue";
|
|
878
|
+
brown: "brown";
|
|
879
|
+
gray: "gray";
|
|
880
|
+
green: "green";
|
|
881
|
+
orange: "orange";
|
|
882
|
+
pink: "pink";
|
|
883
|
+
purple: "purple";
|
|
884
|
+
red: "red";
|
|
885
|
+
yellow: "yellow";
|
|
886
|
+
lightgray: "lightgray";
|
|
887
|
+
}>>;
|
|
888
|
+
}, import("zod/v4/core").$strip>;
|
|
889
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
890
|
+
type: import("zod").ZodLiteral<"custom_emoji">;
|
|
891
|
+
custom_emoji: import("zod").ZodObject<{
|
|
892
|
+
id: import("zod").ZodUUID;
|
|
893
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
894
|
+
url: import("zod").ZodOptional<import("zod").ZodURL>;
|
|
895
|
+
}, import("zod/v4/core").$strip>;
|
|
848
896
|
}, import("zod/v4/core").$strip>]>>;
|
|
849
897
|
cover: import("zod").ZodNullable<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
850
898
|
type: import("zod").ZodLiteral<"file">;
|
|
@@ -882,6 +930,16 @@ export declare class DataSourcesAPI extends BaseAPI<NotionDataSource, DataSource
|
|
|
882
930
|
* @see https://developers.notion.com/reference/retrieve-a-data-source
|
|
883
931
|
*/
|
|
884
932
|
retrieve(dataSourceId: string, options?: RetrieveDataSourceOptions): Promise<DataSource>;
|
|
933
|
+
/**
|
|
934
|
+
* List the templates available for a data source.
|
|
935
|
+
*
|
|
936
|
+
* @param dataSourceId - The ID of the data source
|
|
937
|
+
* @param options - Options for filtering by name and paginating results
|
|
938
|
+
* @returns The list of templates, along with pagination metadata
|
|
939
|
+
*
|
|
940
|
+
* @see https://developers.notion.com/reference/list-data-source-templates
|
|
941
|
+
*/
|
|
942
|
+
listTemplates(dataSourceId: string, options?: ListDataSourceTemplatesOptions): Promise<DataSourceTemplateList>;
|
|
885
943
|
/**
|
|
886
944
|
* Query a data source with optional filters and sorts.
|
|
887
945
|
* Returns pages that match the query.
|
|
@@ -36,6 +36,27 @@ class DataSourcesAPI extends base_api_1.BaseAPI {
|
|
|
36
36
|
};
|
|
37
37
|
return this.retrieveResource(`/data_sources/${dataSourceId}`, query);
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* List the templates available for a data source.
|
|
41
|
+
*
|
|
42
|
+
* @param dataSourceId - The ID of the data source
|
|
43
|
+
* @param options - Options for filtering by name and paginating results
|
|
44
|
+
* @returns The list of templates, along with pagination metadata
|
|
45
|
+
*
|
|
46
|
+
* @see https://developers.notion.com/reference/list-data-source-templates
|
|
47
|
+
*/
|
|
48
|
+
async listTemplates(dataSourceId, options) {
|
|
49
|
+
const query = {
|
|
50
|
+
...(options?.name ? { name: options.name } : {}),
|
|
51
|
+
...this.buildPaginationQuery(options),
|
|
52
|
+
};
|
|
53
|
+
const response = await this.client.request({
|
|
54
|
+
method: 'GET',
|
|
55
|
+
path: `/data_sources/${dataSourceId}/templates`,
|
|
56
|
+
query: Object.keys(query).length > 0 ? query : undefined,
|
|
57
|
+
});
|
|
58
|
+
return schemas_1.dataSourceTemplateListSchema.parse(response);
|
|
59
|
+
}
|
|
39
60
|
/**
|
|
40
61
|
* Query a data source with optional filters and sorts.
|
|
41
62
|
* Returns pages that match the query.
|
|
@@ -61,19 +82,21 @@ class DataSourcesAPI extends base_api_1.BaseAPI {
|
|
|
61
82
|
if (options?.start_cursor) {
|
|
62
83
|
body.start_cursor = options.start_cursor;
|
|
63
84
|
}
|
|
64
|
-
if (options?.
|
|
65
|
-
(
|
|
66
|
-
body.filter_properties = options.filter_properties;
|
|
85
|
+
if (options?.in_trash !== undefined && options?.is_archived === undefined) {
|
|
86
|
+
console.warn('[notion-sdk-ts] QueryDataSourceOptions.in_trash is deprecated, use is_archived instead.');
|
|
67
87
|
}
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
const isArchived = options?.is_archived ?? options?.in_trash;
|
|
89
|
+
if (isArchived !== undefined) {
|
|
90
|
+
body.is_archived = isArchived;
|
|
70
91
|
}
|
|
71
92
|
if (options?.result_type) {
|
|
72
93
|
body.result_type = options.result_type;
|
|
73
94
|
}
|
|
95
|
+
const query = this.buildFilterPropertiesQuery(options?.filter_properties);
|
|
74
96
|
const response = await this.client.request({
|
|
75
97
|
method: 'POST',
|
|
76
98
|
path: `/data_sources/${dataSourceId}/query`,
|
|
99
|
+
query: Object.keys(query).length > 0 ? query : undefined,
|
|
77
100
|
body: Object.keys(body).length > 0 ? body : undefined,
|
|
78
101
|
});
|
|
79
102
|
const listSchema = (0, schemas_1.paginatedListSchema)(schemas_1.pageSchema);
|
|
@@ -84,6 +107,7 @@ class DataSourcesAPI extends base_api_1.BaseAPI {
|
|
|
84
107
|
next_cursor: parsed.next_cursor,
|
|
85
108
|
has_more: parsed.has_more,
|
|
86
109
|
type: 'page',
|
|
110
|
+
request_status: parsed.request_status,
|
|
87
111
|
};
|
|
88
112
|
}
|
|
89
113
|
/**
|