@visus-io/notion-sdk-ts 2.0.0 → 2.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.
Files changed (206) hide show
  1. package/README.md +66 -921
  2. package/dist/api/base.api.d.ts +161 -0
  3. package/dist/api/base.api.js +228 -0
  4. package/dist/api/blocks.api.d.ts +3867 -4
  5. package/dist/api/blocks.api.js +16 -47
  6. package/dist/api/comments.api.d.ts +259 -4
  7. package/dist/api/comments.api.js +11 -29
  8. package/dist/api/dataSources.api.d.ts +788 -4
  9. package/dist/api/dataSources.api.js +14 -28
  10. package/dist/api/databases.api.d.ts +491 -4
  11. package/dist/api/databases.api.js +20 -45
  12. package/dist/api/fileUploads.api.d.ts +25 -3
  13. package/dist/api/fileUploads.api.js +7 -2
  14. package/dist/api/index.d.ts +0 -1
  15. package/dist/api/index.js +0 -1
  16. package/dist/api/pages.api.d.ts +864 -3
  17. package/dist/api/pages.api.js +14 -28
  18. package/dist/api/search.api.d.ts +0 -1
  19. package/dist/api/search.api.js +5 -11
  20. package/dist/api/users.api.d.ts +40 -4
  21. package/dist/api/users.api.js +12 -35
  22. package/dist/client.d.ts +0 -1
  23. package/dist/client.js +0 -1
  24. package/dist/errors.d.ts +0 -1
  25. package/dist/errors.js +0 -1
  26. package/dist/helpers/block.helpers.d.ts +4 -1
  27. package/dist/helpers/block.helpers.js +11 -1
  28. package/dist/helpers/file.helpers.d.ts +0 -1
  29. package/dist/helpers/file.helpers.js +0 -1
  30. package/dist/helpers/filter.helpers.d.ts +0 -1
  31. package/dist/helpers/filter.helpers.js +0 -1
  32. package/dist/helpers/index.d.ts +0 -1
  33. package/dist/helpers/index.js +0 -1
  34. package/dist/helpers/pagination.helpers.d.ts +0 -1
  35. package/dist/helpers/pagination.helpers.js +0 -1
  36. package/dist/helpers/parent.helpers.d.ts +0 -1
  37. package/dist/helpers/parent.helpers.js +0 -1
  38. package/dist/helpers/property.helpers.d.ts +0 -1
  39. package/dist/helpers/property.helpers.js +0 -1
  40. package/dist/helpers/richText.helpers.d.ts +0 -1
  41. package/dist/helpers/richText.helpers.js +0 -1
  42. package/dist/helpers/sort.helpers.d.ts +0 -1
  43. package/dist/helpers/sort.helpers.js +0 -1
  44. package/dist/index.d.ts +0 -1
  45. package/dist/index.js +0 -1
  46. package/dist/models/base.model.d.ts +2 -3
  47. package/dist/models/base.model.js +0 -1
  48. package/dist/models/block.model.d.ts +0 -1
  49. package/dist/models/block.model.js +0 -1
  50. package/dist/models/comment.model.d.ts +0 -1
  51. package/dist/models/comment.model.js +0 -1
  52. package/dist/models/dataSource.model.d.ts +0 -1
  53. package/dist/models/dataSource.model.js +0 -1
  54. package/dist/models/database.model.d.ts +0 -1
  55. package/dist/models/database.model.js +0 -1
  56. package/dist/models/fileUpload.model.d.ts +0 -1
  57. package/dist/models/fileUpload.model.js +0 -1
  58. package/dist/models/index.d.ts +0 -1
  59. package/dist/models/index.js +0 -1
  60. package/dist/models/page.model.d.ts +0 -1
  61. package/dist/models/page.model.js +0 -1
  62. package/dist/models/richText.model.d.ts +0 -1
  63. package/dist/models/richText.model.js +0 -1
  64. package/dist/models/user.model.d.ts +0 -1
  65. package/dist/models/user.model.js +0 -1
  66. package/dist/notion.d.ts +0 -1
  67. package/dist/notion.js +0 -1
  68. package/dist/schemas/block.schema.d.ts +261 -82
  69. package/dist/schemas/block.schema.js +157 -82
  70. package/dist/schemas/codeLanguages.d.ts +0 -1
  71. package/dist/schemas/codeLanguages.js +0 -1
  72. package/dist/schemas/colors.d.ts +0 -1
  73. package/dist/schemas/colors.js +0 -1
  74. package/dist/schemas/comment.schema.d.ts +9 -10
  75. package/dist/schemas/comment.schema.js +54 -21
  76. package/dist/schemas/dataSource.schema.d.ts +13 -14
  77. package/dist/schemas/dataSource.schema.js +46 -13
  78. package/dist/schemas/database.schema.d.ts +13 -14
  79. package/dist/schemas/database.schema.js +51 -18
  80. package/dist/schemas/emoji.schema.d.ts +1 -2
  81. package/dist/schemas/emoji.schema.js +37 -5
  82. package/dist/schemas/file.schema.d.ts +3 -4
  83. package/dist/schemas/file.schema.js +49 -16
  84. package/dist/schemas/fileUpload.schema.d.ts +3 -4
  85. package/dist/schemas/fileUpload.schema.js +47 -14
  86. package/dist/schemas/index.d.ts +1 -1
  87. package/dist/schemas/index.js +1 -1
  88. package/dist/schemas/page.schema.d.ts +30 -31
  89. package/dist/schemas/page.schema.js +47 -14
  90. package/dist/schemas/pageProperties.schema.d.ts +47 -48
  91. package/dist/schemas/pageProperties.schema.js +162 -129
  92. package/dist/schemas/pagination.schema.d.ts +1 -2
  93. package/dist/schemas/pagination.schema.js +40 -8
  94. package/dist/schemas/parent.schema.d.ts +1 -2
  95. package/dist/schemas/parent.schema.js +51 -19
  96. package/dist/schemas/propertyObjects.schema.d.ts +1 -2
  97. package/dist/schemas/propertyObjects.schema.js +194 -162
  98. package/dist/schemas/richText.schema.d.ts +7 -8
  99. package/dist/schemas/richText.schema.js +95 -57
  100. package/dist/schemas/shared.schema.d.ts +15 -0
  101. package/dist/schemas/shared.schema.js +54 -0
  102. package/dist/schemas/user.schema.d.ts +3 -4
  103. package/dist/schemas/user.schema.js +63 -31
  104. package/dist/validation.d.ts +0 -1
  105. package/dist/validation.js +0 -1
  106. package/package.json +3 -1
  107. package/dist/api/blocks.api.d.ts.map +0 -1
  108. package/dist/api/blocks.api.js.map +0 -1
  109. package/dist/api/comments.api.d.ts.map +0 -1
  110. package/dist/api/comments.api.js.map +0 -1
  111. package/dist/api/dataSources.api.d.ts.map +0 -1
  112. package/dist/api/dataSources.api.js.map +0 -1
  113. package/dist/api/databases.api.d.ts.map +0 -1
  114. package/dist/api/databases.api.js.map +0 -1
  115. package/dist/api/fileUploads.api.d.ts.map +0 -1
  116. package/dist/api/fileUploads.api.js.map +0 -1
  117. package/dist/api/index.d.ts.map +0 -1
  118. package/dist/api/index.js.map +0 -1
  119. package/dist/api/pages.api.d.ts.map +0 -1
  120. package/dist/api/pages.api.js.map +0 -1
  121. package/dist/api/search.api.d.ts.map +0 -1
  122. package/dist/api/search.api.js.map +0 -1
  123. package/dist/api/users.api.d.ts.map +0 -1
  124. package/dist/api/users.api.js.map +0 -1
  125. package/dist/client.d.ts.map +0 -1
  126. package/dist/client.js.map +0 -1
  127. package/dist/errors.d.ts.map +0 -1
  128. package/dist/errors.js.map +0 -1
  129. package/dist/helpers/block.helpers.d.ts.map +0 -1
  130. package/dist/helpers/block.helpers.js.map +0 -1
  131. package/dist/helpers/file.helpers.d.ts.map +0 -1
  132. package/dist/helpers/file.helpers.js.map +0 -1
  133. package/dist/helpers/filter.helpers.d.ts.map +0 -1
  134. package/dist/helpers/filter.helpers.js.map +0 -1
  135. package/dist/helpers/index.d.ts.map +0 -1
  136. package/dist/helpers/index.js.map +0 -1
  137. package/dist/helpers/pagination.helpers.d.ts.map +0 -1
  138. package/dist/helpers/pagination.helpers.js.map +0 -1
  139. package/dist/helpers/parent.helpers.d.ts.map +0 -1
  140. package/dist/helpers/parent.helpers.js.map +0 -1
  141. package/dist/helpers/property.helpers.d.ts.map +0 -1
  142. package/dist/helpers/property.helpers.js.map +0 -1
  143. package/dist/helpers/richText.helpers.d.ts.map +0 -1
  144. package/dist/helpers/richText.helpers.js.map +0 -1
  145. package/dist/helpers/sort.helpers.d.ts.map +0 -1
  146. package/dist/helpers/sort.helpers.js.map +0 -1
  147. package/dist/index.d.ts.map +0 -1
  148. package/dist/index.js.map +0 -1
  149. package/dist/models/base.model.d.ts.map +0 -1
  150. package/dist/models/base.model.js.map +0 -1
  151. package/dist/models/block.model.d.ts.map +0 -1
  152. package/dist/models/block.model.js.map +0 -1
  153. package/dist/models/comment.model.d.ts.map +0 -1
  154. package/dist/models/comment.model.js.map +0 -1
  155. package/dist/models/dataSource.model.d.ts.map +0 -1
  156. package/dist/models/dataSource.model.js.map +0 -1
  157. package/dist/models/database.model.d.ts.map +0 -1
  158. package/dist/models/database.model.js.map +0 -1
  159. package/dist/models/fileUpload.model.d.ts.map +0 -1
  160. package/dist/models/fileUpload.model.js.map +0 -1
  161. package/dist/models/index.d.ts.map +0 -1
  162. package/dist/models/index.js.map +0 -1
  163. package/dist/models/page.model.d.ts.map +0 -1
  164. package/dist/models/page.model.js.map +0 -1
  165. package/dist/models/richText.model.d.ts.map +0 -1
  166. package/dist/models/richText.model.js.map +0 -1
  167. package/dist/models/user.model.d.ts.map +0 -1
  168. package/dist/models/user.model.js.map +0 -1
  169. package/dist/notion.d.ts.map +0 -1
  170. package/dist/notion.js.map +0 -1
  171. package/dist/schemas/block.schema.d.ts.map +0 -1
  172. package/dist/schemas/block.schema.js.map +0 -1
  173. package/dist/schemas/codeLanguages.d.ts.map +0 -1
  174. package/dist/schemas/codeLanguages.js.map +0 -1
  175. package/dist/schemas/colors.d.ts.map +0 -1
  176. package/dist/schemas/colors.js.map +0 -1
  177. package/dist/schemas/comment.schema.d.ts.map +0 -1
  178. package/dist/schemas/comment.schema.js.map +0 -1
  179. package/dist/schemas/dataSource.schema.d.ts.map +0 -1
  180. package/dist/schemas/dataSource.schema.js.map +0 -1
  181. package/dist/schemas/database.schema.d.ts.map +0 -1
  182. package/dist/schemas/database.schema.js.map +0 -1
  183. package/dist/schemas/emoji.schema.d.ts.map +0 -1
  184. package/dist/schemas/emoji.schema.js.map +0 -1
  185. package/dist/schemas/file.schema.d.ts.map +0 -1
  186. package/dist/schemas/file.schema.js.map +0 -1
  187. package/dist/schemas/fileUpload.schema.d.ts.map +0 -1
  188. package/dist/schemas/fileUpload.schema.js.map +0 -1
  189. package/dist/schemas/index.d.ts.map +0 -1
  190. package/dist/schemas/index.js.map +0 -1
  191. package/dist/schemas/page.schema.d.ts.map +0 -1
  192. package/dist/schemas/page.schema.js.map +0 -1
  193. package/dist/schemas/pageProperties.schema.d.ts.map +0 -1
  194. package/dist/schemas/pageProperties.schema.js.map +0 -1
  195. package/dist/schemas/pagination.schema.d.ts.map +0 -1
  196. package/dist/schemas/pagination.schema.js.map +0 -1
  197. package/dist/schemas/parent.schema.d.ts.map +0 -1
  198. package/dist/schemas/parent.schema.js.map +0 -1
  199. package/dist/schemas/propertyObjects.schema.d.ts.map +0 -1
  200. package/dist/schemas/propertyObjects.schema.js.map +0 -1
  201. package/dist/schemas/richText.schema.d.ts.map +0 -1
  202. package/dist/schemas/richText.schema.js.map +0 -1
  203. package/dist/schemas/user.schema.d.ts.map +0 -1
  204. package/dist/schemas/user.schema.js.map +0 -1
  205. package/dist/validation.d.ts.map +0 -1
  206. package/dist/validation.js.map +0 -1
@@ -4,12 +4,19 @@ exports.BlocksAPI = void 0;
4
4
  const schemas_1 = require("../schemas");
5
5
  const models_1 = require("../models");
6
6
  const validation_1 = require("../validation");
7
+ const base_api_1 = require("./base.api");
7
8
  /**
8
9
  * Blocks API client for working with Notion blocks.
9
10
  */
10
- class BlocksAPI {
11
+ class BlocksAPI extends base_api_1.BaseAPI {
11
12
  constructor(client) {
13
+ super(client);
12
14
  this.client = client;
15
+ this.config = {
16
+ schema: schemas_1.blockSchema,
17
+ ModelClass: models_1.Block,
18
+ listType: 'block',
19
+ };
13
20
  /**
14
21
  * Block children operations.
15
22
  */
@@ -24,27 +31,8 @@ class BlocksAPI {
24
31
  * @see https://developers.notion.com/reference/get-block-children
25
32
  */
26
33
  list: async (blockId, params) => {
27
- const query = {};
28
- if (params?.page_size) {
29
- query.page_size = String(params.page_size);
30
- }
31
- if (params?.start_cursor) {
32
- query.start_cursor = params.start_cursor;
33
- }
34
- const response = await this.client.request({
35
- method: 'GET',
36
- path: `/blocks/${blockId}/children`,
37
- query: Object.keys(query).length > 0 ? query : undefined,
38
- });
39
- const listSchema = (0, schemas_1.paginatedListSchema)(schemas_1.blockSchema);
40
- const parsed = listSchema.parse(response);
41
- return {
42
- object: 'list',
43
- results: parsed.results.map((block) => new models_1.Block(block)),
44
- next_cursor: parsed.next_cursor,
45
- has_more: parsed.has_more,
46
- type: 'block',
47
- };
34
+ const query = this.buildPaginationQuery(params);
35
+ return this.listResources(`/blocks/${blockId}/children`, query);
48
36
  },
49
37
  /**
50
38
  * Append children blocks to a parent block.
@@ -82,17 +70,10 @@ class BlocksAPI {
82
70
  * @see https://developers.notion.com/reference/retrieve-a-block
83
71
  */
84
72
  async retrieve(blockId, options) {
85
- const query = {};
86
- if (options?.filter_properties) {
87
- query.filter_properties = options.filter_properties.join(',');
88
- }
89
- const response = await this.client.request({
90
- method: 'GET',
91
- path: `/blocks/${blockId}`,
92
- query: Object.keys(query).length > 0 ? query : undefined,
93
- });
94
- const parsed = schemas_1.blockSchema.parse(response);
95
- return new models_1.Block(parsed);
73
+ const query = {
74
+ ...this.buildFilterPropertiesQuery(options?.filter_properties),
75
+ };
76
+ return this.retrieveResource(`/blocks/${blockId}`, query);
96
77
  }
97
78
  /**
98
79
  * Delete (archive) a block.
@@ -103,12 +84,7 @@ class BlocksAPI {
103
84
  * @see https://developers.notion.com/reference/delete-a-block
104
85
  */
105
86
  async delete(blockId) {
106
- const response = await this.client.request({
107
- method: 'DELETE',
108
- path: `/blocks/${blockId}`,
109
- });
110
- const parsed = schemas_1.blockSchema.parse(response);
111
- return new models_1.Block(parsed);
87
+ return this.deleteResource(`/blocks/${blockId}`);
112
88
  }
113
89
  /**
114
90
  * Update a block's properties.
@@ -120,14 +96,7 @@ class BlocksAPI {
120
96
  * @see https://developers.notion.com/reference/update-a-block
121
97
  */
122
98
  async update(blockId, options) {
123
- const response = await this.client.request({
124
- method: 'PATCH',
125
- path: `/blocks/${blockId}`,
126
- body: options,
127
- });
128
- const parsed = schemas_1.blockSchema.parse(response);
129
- return new models_1.Block(parsed);
99
+ return this.updateResource(`/blocks/${blockId}`, options);
130
100
  }
131
101
  }
132
102
  exports.BlocksAPI = BlocksAPI;
133
- //# sourceMappingURL=blocks.api.js.map
@@ -1,6 +1,7 @@
1
1
  import type { NotionClient } from '../client';
2
- import { type PaginatedList, type PaginationParameters } from '../schemas';
2
+ import { type NotionComment, type PaginatedList, type PaginationParameters } from '../schemas';
3
3
  import { Comment } from '../models';
4
+ import { BaseAPI } from './base.api';
4
5
  /**
5
6
  * Display name for a comment.
6
7
  */
@@ -45,8 +46,263 @@ export interface CreateCommentOptions {
45
46
  /**
46
47
  * Comments API client for working with Notion comments.
47
48
  */
48
- export declare class CommentsAPI {
49
- private readonly client;
49
+ export declare class CommentsAPI extends BaseAPI<NotionComment, Comment> {
50
+ protected readonly client: NotionClient;
51
+ protected config: {
52
+ schema: import("zod").ZodObject<{
53
+ object: import("zod").ZodLiteral<"comment">;
54
+ id: import("zod").ZodUUID;
55
+ parent: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
56
+ type: import("zod").ZodLiteral<"database_id">;
57
+ database_id: import("zod").ZodUUID;
58
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
59
+ type: import("zod").ZodLiteral<"data_source_id">;
60
+ data_source_id: import("zod").ZodUUID;
61
+ database_id: import("zod").ZodUUID;
62
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
63
+ type: import("zod").ZodLiteral<"page_id">;
64
+ page_id: import("zod").ZodUUID;
65
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
66
+ type: import("zod").ZodLiteral<"workspace">;
67
+ workspace: import("zod").ZodLiteral<true>;
68
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
69
+ type: import("zod").ZodLiteral<"block_id">;
70
+ block_id: import("zod").ZodUUID;
71
+ }, import("zod/v4/core").$strip>], "type">;
72
+ discussion_id: import("zod").ZodUUID;
73
+ created_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
74
+ created_by: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
75
+ object: import("zod").ZodLiteral<"user">;
76
+ id: import("zod").ZodUUID;
77
+ type: import("zod").ZodLiteral<"person">;
78
+ name: import("zod").ZodOptional<import("zod").ZodString>;
79
+ avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
80
+ person: import("zod").ZodObject<{
81
+ email: import("zod").ZodEmail;
82
+ }, import("zod/v4/core").$strip>;
83
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
84
+ object: import("zod").ZodLiteral<"user">;
85
+ id: import("zod").ZodUUID;
86
+ type: import("zod").ZodLiteral<"bot">;
87
+ name: import("zod").ZodOptional<import("zod").ZodString>;
88
+ avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
89
+ bot: import("zod").ZodObject<{
90
+ owner: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
91
+ type: import("zod").ZodLiteral<"workspace">;
92
+ workspace: import("zod").ZodLiteral<true>;
93
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
94
+ type: import("zod").ZodLiteral<"user">;
95
+ }, import("zod/v4/core").$strip>], "type">;
96
+ workspace_name: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
97
+ workspace_id: import("zod").ZodOptional<import("zod").ZodString>;
98
+ workspace_limits: import("zod").ZodOptional<import("zod").ZodObject<{
99
+ max_file_upload_size_in_bytes: import("zod").ZodInt;
100
+ }, import("zod/v4/core").$strip>>;
101
+ }, import("zod/v4/core").$strip>;
102
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
103
+ object: import("zod").ZodLiteral<"user">;
104
+ id: import("zod").ZodUUID;
105
+ }, import("zod/v4/core").$strip>]>;
106
+ last_edited_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
107
+ rich_text: import("zod").ZodArray<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
108
+ type: import("zod").ZodLiteral<"text">;
109
+ text: import("zod").ZodObject<{
110
+ content: import("zod").ZodString;
111
+ link: import("zod").ZodNullable<import("zod").ZodObject<{
112
+ url: import("zod").ZodURL;
113
+ }, import("zod/v4/core").$strip>>;
114
+ }, import("zod/v4/core").$strip>;
115
+ annotations: import("zod").ZodObject<{
116
+ bold: import("zod").ZodBoolean;
117
+ italic: import("zod").ZodBoolean;
118
+ strikethrough: import("zod").ZodBoolean;
119
+ underline: import("zod").ZodBoolean;
120
+ code: import("zod").ZodBoolean;
121
+ color: import("zod").ZodEnum<{
122
+ blue: "blue";
123
+ blue_background: "blue_background";
124
+ brown: "brown";
125
+ brown_background: "brown_background";
126
+ default: "default";
127
+ gray: "gray";
128
+ gray_background: "gray_background";
129
+ green: "green";
130
+ green_background: "green_background";
131
+ orange: "orange";
132
+ orange_background: "orange_background";
133
+ pink: "pink";
134
+ pink_background: "pink_background";
135
+ purple: "purple";
136
+ purple_background: "purple_background";
137
+ red: "red";
138
+ red_background: "red_background";
139
+ yellow: "yellow";
140
+ yellow_background: "yellow_background";
141
+ }>;
142
+ }, import("zod/v4/core").$strip>;
143
+ plain_text: import("zod").ZodString;
144
+ href: import("zod").ZodNullable<import("zod").ZodURL>;
145
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
146
+ type: import("zod").ZodLiteral<"mention">;
147
+ mention: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
148
+ type: import("zod").ZodLiteral<"database">;
149
+ database: import("zod").ZodObject<{
150
+ id: import("zod").ZodUUID;
151
+ }, import("zod/v4/core").$strip>;
152
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
153
+ type: import("zod").ZodLiteral<"date">;
154
+ date: import("zod").ZodObject<{
155
+ start: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
156
+ end: import("zod").ZodNullable<import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>>;
157
+ time_zone: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
158
+ }, import("zod/v4/core").$strip>;
159
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
160
+ type: import("zod").ZodLiteral<"link_preview">;
161
+ link_preview: import("zod").ZodObject<{
162
+ url: import("zod").ZodURL;
163
+ }, import("zod/v4/core").$strip>;
164
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
165
+ type: import("zod").ZodLiteral<"page">;
166
+ page: import("zod").ZodObject<{
167
+ id: import("zod").ZodUUID;
168
+ }, import("zod/v4/core").$strip>;
169
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
170
+ type: import("zod").ZodLiteral<"template_mention">;
171
+ template_mention: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
172
+ type: import("zod").ZodLiteral<"template_mention_date">;
173
+ template_mention_date: import("zod").ZodEnum<{
174
+ today: "today";
175
+ now: "now";
176
+ }>;
177
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
178
+ type: import("zod").ZodLiteral<"template_mention_user">;
179
+ template_mention_user: import("zod").ZodLiteral<"me">;
180
+ }, import("zod/v4/core").$strip>], "type">;
181
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
182
+ type: import("zod").ZodLiteral<"user">;
183
+ user: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
184
+ object: import("zod").ZodLiteral<"user">;
185
+ id: import("zod").ZodUUID;
186
+ type: import("zod").ZodLiteral<"person">;
187
+ name: import("zod").ZodOptional<import("zod").ZodString>;
188
+ avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
189
+ person: import("zod").ZodObject<{
190
+ email: import("zod").ZodEmail;
191
+ }, import("zod/v4/core").$strip>;
192
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
193
+ object: import("zod").ZodLiteral<"user">;
194
+ id: import("zod").ZodUUID;
195
+ type: import("zod").ZodLiteral<"bot">;
196
+ name: import("zod").ZodOptional<import("zod").ZodString>;
197
+ avatar_url: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodURL, import("zod").ZodNull]>>;
198
+ bot: import("zod").ZodObject<{
199
+ owner: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
200
+ type: import("zod").ZodLiteral<"workspace">;
201
+ workspace: import("zod").ZodLiteral<true>;
202
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
203
+ type: import("zod").ZodLiteral<"user">;
204
+ }, import("zod/v4/core").$strip>], "type">;
205
+ workspace_name: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
206
+ workspace_id: import("zod").ZodOptional<import("zod").ZodString>;
207
+ workspace_limits: import("zod").ZodOptional<import("zod").ZodObject<{
208
+ max_file_upload_size_in_bytes: import("zod").ZodInt;
209
+ }, import("zod/v4/core").$strip>>;
210
+ }, import("zod/v4/core").$strip>;
211
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
212
+ object: import("zod").ZodLiteral<"user">;
213
+ id: import("zod").ZodUUID;
214
+ }, import("zod/v4/core").$strip>]>;
215
+ }, import("zod/v4/core").$strip>], "type">;
216
+ annotations: import("zod").ZodObject<{
217
+ bold: import("zod").ZodBoolean;
218
+ italic: import("zod").ZodBoolean;
219
+ strikethrough: import("zod").ZodBoolean;
220
+ underline: import("zod").ZodBoolean;
221
+ code: import("zod").ZodBoolean;
222
+ color: import("zod").ZodEnum<{
223
+ blue: "blue";
224
+ blue_background: "blue_background";
225
+ brown: "brown";
226
+ brown_background: "brown_background";
227
+ default: "default";
228
+ gray: "gray";
229
+ gray_background: "gray_background";
230
+ green: "green";
231
+ green_background: "green_background";
232
+ orange: "orange";
233
+ orange_background: "orange_background";
234
+ pink: "pink";
235
+ pink_background: "pink_background";
236
+ purple: "purple";
237
+ purple_background: "purple_background";
238
+ red: "red";
239
+ red_background: "red_background";
240
+ yellow: "yellow";
241
+ yellow_background: "yellow_background";
242
+ }>;
243
+ }, import("zod/v4/core").$strip>;
244
+ plain_text: import("zod").ZodString;
245
+ href: import("zod").ZodNullable<import("zod").ZodURL>;
246
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
247
+ type: import("zod").ZodLiteral<"equation">;
248
+ equation: import("zod").ZodObject<{
249
+ expression: import("zod").ZodString;
250
+ }, import("zod/v4/core").$strip>;
251
+ annotations: import("zod").ZodObject<{
252
+ bold: import("zod").ZodBoolean;
253
+ italic: import("zod").ZodBoolean;
254
+ strikethrough: import("zod").ZodBoolean;
255
+ underline: import("zod").ZodBoolean;
256
+ code: import("zod").ZodBoolean;
257
+ color: import("zod").ZodEnum<{
258
+ blue: "blue";
259
+ blue_background: "blue_background";
260
+ brown: "brown";
261
+ brown_background: "brown_background";
262
+ default: "default";
263
+ gray: "gray";
264
+ gray_background: "gray_background";
265
+ green: "green";
266
+ green_background: "green_background";
267
+ orange: "orange";
268
+ orange_background: "orange_background";
269
+ pink: "pink";
270
+ pink_background: "pink_background";
271
+ purple: "purple";
272
+ purple_background: "purple_background";
273
+ red: "red";
274
+ red_background: "red_background";
275
+ yellow: "yellow";
276
+ yellow_background: "yellow_background";
277
+ }>;
278
+ }, import("zod/v4/core").$strip>;
279
+ plain_text: import("zod").ZodString;
280
+ href: import("zod").ZodNullable<import("zod").ZodURL>;
281
+ }, import("zod/v4/core").$strip>], "type">>;
282
+ attachments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
283
+ category: import("zod").ZodEnum<{
284
+ file: "file";
285
+ audio: "audio";
286
+ image: "image";
287
+ pdf: "pdf";
288
+ video: "video";
289
+ }>;
290
+ file: import("zod").ZodObject<{
291
+ url: import("zod").ZodURL;
292
+ expiry_time: import("zod").ZodUnion<readonly [import("zod").ZodISODateTime, import("zod").ZodISODate]>;
293
+ }, import("zod/v4/core").$strip>;
294
+ }, import("zod/v4/core").$strip>>>;
295
+ display_name: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
296
+ type: import("zod").ZodLiteral<"user">;
297
+ resolved_name: import("zod").ZodString;
298
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
299
+ type: import("zod").ZodLiteral<"custom">;
300
+ resolved_name: import("zod").ZodString;
301
+ }, import("zod/v4/core").$strip>]>>;
302
+ }, import("zod/v4/core").$strip>;
303
+ ModelClass: typeof Comment;
304
+ listType: "comment";
305
+ };
50
306
  constructor(client: NotionClient);
51
307
  /**
52
308
  * Retrieve all comments from a page or block (paginated).
@@ -68,4 +324,3 @@ export declare class CommentsAPI {
68
324
  */
69
325
  create(options: CreateCommentOptions): Promise<Comment>;
70
326
  }
71
- //# sourceMappingURL=comments.api.d.ts.map
@@ -4,12 +4,19 @@ exports.CommentsAPI = void 0;
4
4
  const schemas_1 = require("../schemas");
5
5
  const models_1 = require("../models");
6
6
  const validation_1 = require("../validation");
7
+ const base_api_1 = require("./base.api");
7
8
  /**
8
9
  * Comments API client for working with Notion comments.
9
10
  */
10
- class CommentsAPI {
11
+ class CommentsAPI extends base_api_1.BaseAPI {
11
12
  constructor(client) {
13
+ super(client);
12
14
  this.client = client;
15
+ this.config = {
16
+ schema: schemas_1.commentSchema,
17
+ ModelClass: models_1.Comment,
18
+ listType: 'comment',
19
+ };
13
20
  }
14
21
  /**
15
22
  * Retrieve all comments from a page or block (paginated).
@@ -23,27 +30,9 @@ class CommentsAPI {
23
30
  async list(parentId, params) {
24
31
  const query = {
25
32
  block_id: parentId, // Can be page_id, block_id, or database_id
33
+ ...this.buildPaginationQuery(params),
26
34
  };
27
- if (params?.page_size) {
28
- query.page_size = String(params.page_size);
29
- }
30
- if (params?.start_cursor) {
31
- query.start_cursor = params.start_cursor;
32
- }
33
- const response = await this.client.request({
34
- method: 'GET',
35
- path: '/comments',
36
- query,
37
- });
38
- const listSchema = (0, schemas_1.paginatedListSchema)(schemas_1.commentSchema);
39
- const parsed = listSchema.parse(response);
40
- return {
41
- object: 'list',
42
- results: parsed.results.map((comment) => new models_1.Comment(comment)),
43
- next_cursor: parsed.next_cursor,
44
- has_more: parsed.has_more,
45
- type: 'comment',
46
- };
35
+ return this.listResources('/comments', query);
47
36
  }
48
37
  /**
49
38
  * Create a new comment on a page or block.
@@ -58,14 +47,7 @@ class CommentsAPI {
58
47
  if (options.attachments) {
59
48
  (0, validation_1.validateArrayLength)(options.attachments, validation_1.LIMITS.COMMENT_ATTACHMENTS, 'attachments');
60
49
  }
61
- const response = await this.client.request({
62
- method: 'POST',
63
- path: '/comments',
64
- body: options,
65
- });
66
- const parsed = schemas_1.commentSchema.parse(response);
67
- return new models_1.Comment(parsed);
50
+ return this.createResource('/comments', options);
68
51
  }
69
52
  }
70
53
  exports.CommentsAPI = CommentsAPI;
71
- //# sourceMappingURL=comments.api.js.map