@visus-io/notion-sdk-ts 3.1.0 → 3.2.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 (122) hide show
  1. package/README.md +20 -88
  2. package/dist/api/asyncTasks.api.d.ts +5 -3
  3. package/dist/api/asyncTasks.api.js +5 -3
  4. package/dist/api/base.api.d.ts +15 -4
  5. package/dist/api/base.api.js +19 -8
  6. package/dist/api/blocks.api.d.ts +2 -0
  7. package/dist/api/blocks.api.js +5 -2
  8. package/dist/api/comments.api.d.ts +2 -0
  9. package/dist/api/comments.api.js +2 -0
  10. package/dist/api/customEmojis.api.d.ts +2 -0
  11. package/dist/api/customEmojis.api.js +2 -0
  12. package/dist/api/dataSources.api.d.ts +10 -3
  13. package/dist/api/dataSources.api.js +4 -1
  14. package/dist/api/databases.api.d.ts +21 -8
  15. package/dist/api/databases.api.js +8 -4
  16. package/dist/api/fileUploads.api.d.ts +7 -4
  17. package/dist/api/fileUploads.api.js +11 -7
  18. package/dist/api/pages.api.d.ts +8 -3
  19. package/dist/api/pages.api.js +5 -3
  20. package/dist/api/search.api.d.ts +4 -2
  21. package/dist/api/search.api.js +5 -2
  22. package/dist/api/users.api.d.ts +2 -0
  23. package/dist/api/users.api.js +2 -0
  24. package/dist/api/views.api.d.ts +15 -13
  25. package/dist/api/views.api.js +10 -7
  26. package/dist/client.d.ts +17 -17
  27. package/dist/client.js +22 -27
  28. package/dist/errors.d.ts +21 -4
  29. package/dist/errors.js +17 -4
  30. package/dist/helpers/block.helpers.d.ts +22 -15
  31. package/dist/helpers/block.helpers.js +14 -12
  32. package/dist/helpers/file.helpers.d.ts +12 -6
  33. package/dist/helpers/file.helpers.js +12 -6
  34. package/dist/helpers/filter.helpers.d.ts +2 -0
  35. package/dist/helpers/filter.helpers.js +2 -0
  36. package/dist/helpers/pagination.helpers.d.ts +52 -36
  37. package/dist/helpers/pagination.helpers.js +49 -29
  38. package/dist/helpers/parent.helpers.d.ts +5 -3
  39. package/dist/helpers/parent.helpers.js +5 -3
  40. package/dist/helpers/property.helpers.d.ts +2 -0
  41. package/dist/helpers/property.helpers.js +3 -1
  42. package/dist/helpers/richText.helpers.d.ts +10 -5
  43. package/dist/helpers/richText.helpers.js +11 -6
  44. package/dist/helpers/sort.helpers.d.ts +2 -0
  45. package/dist/helpers/sort.helpers.js +2 -0
  46. package/dist/helpers/webhook.helpers.d.ts +14 -12
  47. package/dist/helpers/webhook.helpers.js +17 -15
  48. package/dist/models/asyncTask.model.d.ts +8 -6
  49. package/dist/models/asyncTask.model.js +8 -6
  50. package/dist/models/base.model.d.ts +16 -4
  51. package/dist/models/base.model.js +17 -5
  52. package/dist/models/block.model.d.ts +6 -2
  53. package/dist/models/block.model.js +48 -36
  54. package/dist/models/comment.model.d.ts +4 -2
  55. package/dist/models/comment.model.js +4 -2
  56. package/dist/models/customEmoji.model.d.ts +7 -5
  57. package/dist/models/customEmoji.model.js +7 -5
  58. package/dist/models/dataSource.model.d.ts +10 -3
  59. package/dist/models/dataSource.model.js +11 -2
  60. package/dist/models/database.model.d.ts +11 -3
  61. package/dist/models/database.model.js +14 -4
  62. package/dist/models/fileUpload.model.d.ts +6 -4
  63. package/dist/models/fileUpload.model.js +6 -4
  64. package/dist/models/page.model.d.ts +6 -2
  65. package/dist/models/page.model.js +8 -4
  66. package/dist/models/richText.model.d.ts +3 -1
  67. package/dist/models/richText.model.js +3 -1
  68. package/dist/models/user.model.d.ts +9 -2
  69. package/dist/models/user.model.js +14 -2
  70. package/dist/models/view.model.d.ts +9 -7
  71. package/dist/models/view.model.js +9 -7
  72. package/dist/notion.d.ts +6 -1
  73. package/dist/notion.js +6 -1
  74. package/dist/schemas/asyncTask.schema.d.ts +11 -0
  75. package/dist/schemas/asyncTask.schema.js +5 -0
  76. package/dist/schemas/block.schema.d.ts +12 -1
  77. package/dist/schemas/block.schema.js +6 -1
  78. package/dist/schemas/codeLanguages.d.ts +7 -1
  79. package/dist/schemas/codeLanguages.js +4 -1
  80. package/dist/schemas/colors.d.ts +7 -1
  81. package/dist/schemas/colors.js +4 -1
  82. package/dist/schemas/comment.schema.d.ts +20 -2
  83. package/dist/schemas/comment.schema.js +11 -2
  84. package/dist/schemas/customEmoji.schema.d.ts +5 -0
  85. package/dist/schemas/customEmoji.schema.js +2 -0
  86. package/dist/schemas/dataSource.schema.d.ts +24 -3
  87. package/dist/schemas/dataSource.schema.js +15 -5
  88. package/dist/schemas/database.schema.d.ts +31 -1
  89. package/dist/schemas/database.schema.js +18 -2
  90. package/dist/schemas/emoji.schema.d.ts +7 -2
  91. package/dist/schemas/emoji.schema.js +4 -2
  92. package/dist/schemas/file.schema.d.ts +18 -2
  93. package/dist/schemas/file.schema.js +6 -2
  94. package/dist/schemas/fileUpload.schema.d.ts +8 -2
  95. package/dist/schemas/fileUpload.schema.js +5 -2
  96. package/dist/schemas/icon.schema.d.ts +28 -4
  97. package/dist/schemas/icon.schema.js +16 -4
  98. package/dist/schemas/meetingNotesQuery.schema.d.ts +13 -2
  99. package/dist/schemas/meetingNotesQuery.schema.js +7 -2
  100. package/dist/schemas/page.schema.d.ts +8 -0
  101. package/dist/schemas/page.schema.js +2 -0
  102. package/dist/schemas/pageMarkdown.schema.d.ts +15 -4
  103. package/dist/schemas/pageMarkdown.schema.js +9 -4
  104. package/dist/schemas/pageProperties.schema.d.ts +81 -3
  105. package/dist/schemas/pageProperties.schema.js +7 -3
  106. package/dist/schemas/pagination.schema.d.ts +33 -10
  107. package/dist/schemas/pagination.schema.js +12 -5
  108. package/dist/schemas/parent.schema.d.ts +29 -2
  109. package/dist/schemas/parent.schema.js +8 -2
  110. package/dist/schemas/propertyObjects.schema.d.ts +81 -3
  111. package/dist/schemas/propertyObjects.schema.js +11 -5
  112. package/dist/schemas/richText.schema.d.ts +15 -0
  113. package/dist/schemas/richText.schema.js +6 -3
  114. package/dist/schemas/shared.schema.d.ts +6 -3
  115. package/dist/schemas/shared.schema.js +6 -3
  116. package/dist/schemas/user.schema.d.ts +15 -0
  117. package/dist/schemas/user.schema.js +5 -2
  118. package/dist/schemas/view.schema.d.ts +46 -9
  119. package/dist/schemas/view.schema.js +28 -9
  120. package/dist/validation.d.ts +11 -4
  121. package/dist/validation.js +11 -4
  122. package/package.json +20 -16
@@ -37,6 +37,9 @@ declare const partialUserSchema: z.ZodObject<{
37
37
  object: z.ZodLiteral<"user">;
38
38
  id: z.ZodUUID;
39
39
  }, z.core.$strip>;
40
+ /**
41
+ * @category Users
42
+ */
40
43
  export declare const userSchema: z.ZodUnion<readonly [z.ZodObject<{
41
44
  object: z.ZodLiteral<"user">;
42
45
  id: z.ZodUUID;
@@ -70,8 +73,20 @@ export declare const userSchema: z.ZodUnion<readonly [z.ZodObject<{
70
73
  object: z.ZodLiteral<"user">;
71
74
  id: z.ZodUUID;
72
75
  }, z.core.$strip>]>;
76
+ /**
77
+ * @category Users
78
+ */
73
79
  export type NotionUser = z.infer<typeof userSchema>;
80
+ /**
81
+ * @category Users
82
+ */
74
83
  export type PersonUser = z.infer<typeof personUserSchema>;
84
+ /**
85
+ * @category Users
86
+ */
75
87
  export type BotUser = z.infer<typeof botUserSchema>;
88
+ /**
89
+ * @category Users
90
+ */
76
91
  export type PartialUser = z.infer<typeof partialUserSchema>;
77
92
  export {};
@@ -38,8 +38,8 @@ const z = __importStar(require("zod"));
38
38
  /**
39
39
  * Notion user object schemas.
40
40
  *
41
- * Users can be people, bots, or partial user objects (just id and object type).
42
- * Used throughout the API for created_by and last_edited_by fields.
41
+ * Users can be people, bots, or partial user objects (only id and object type).
42
+ * The created_by and last_edited_by fields use this schema throughout the API.
43
43
  *
44
44
  * Notion API reference:
45
45
  * https://developers.notion.com/reference/user
@@ -89,4 +89,7 @@ const partialUserSchema = z.object({
89
89
  object: z.literal('user'),
90
90
  id: z.uuid(),
91
91
  });
92
+ /**
93
+ * @category Users
94
+ */
92
95
  exports.userSchema = z.union([personUserSchema, botUserSchema, partialUserSchema]);
@@ -2,19 +2,30 @@ import * as z from 'zod';
2
2
  /**
3
3
  * View object schema.
4
4
  *
5
- * Views control how a database/data source's rows are displayed (table, board,
6
- * calendar, etc.). As of API version 2025-09-03, views have their own endpoints.
5
+ * A view controls how a database or data source displays its rows, for example as a
6
+ * table, board, or calendar. As of API version 2025-09-03, views have their own
7
+ * endpoints.
7
8
  *
8
9
  * Notion API reference:
9
10
  * https://developers.notion.com/guides/data-apis/working-with-views
11
+ *
12
+ * @category Views
10
13
  */
11
14
  export declare const VIEW_TYPES: readonly ["table", "board", "list", "calendar", "timeline", "gallery", "form", "chart", "map", "dashboard"];
15
+ /**
16
+ * @category Views
17
+ */
12
18
  export type ViewType = (typeof VIEW_TYPES)[number];
13
19
  /**
14
- * Per-layout view configuration. Exact per-type fields (e.g. table column order, board
15
- * group-by property) haven't been confirmed against a live response, so this is kept
16
- * permissive -- tagged on `type`, with all other fields passed through unmodeled -- so
17
- * unknown fields round-trip instead of being stripped or rejected.
20
+ * Configuration for a single view layout.
21
+ *
22
+ * Notion has not confirmed the exact fields for each view type against a live
23
+ * response. Examples include the table column order and the board group-by
24
+ * property. This schema stays permissive. It tags the object by its `type`
25
+ * field and passes all other fields through without validation. As a result,
26
+ * unknown fields round-trip unchanged instead of the schema rejecting them.
27
+ *
28
+ * @category Views
18
29
  */
19
30
  export declare const viewConfigurationSchema: z.ZodObject<{
20
31
  type: z.ZodEnum<{
@@ -30,7 +41,13 @@ export declare const viewConfigurationSchema: z.ZodObject<{
30
41
  dashboard: "dashboard";
31
42
  }>;
32
43
  }, z.core.$catchall<z.ZodUnknown>>;
44
+ /**
45
+ * @category Views
46
+ */
33
47
  export type ViewConfiguration = z.infer<typeof viewConfigurationSchema>;
48
+ /**
49
+ * @category Views
50
+ */
34
51
  export declare const viewSchema: z.ZodObject<{
35
52
  object: z.ZodLiteral<"view">;
36
53
  id: z.ZodUUID;
@@ -140,8 +157,16 @@ export declare const viewSchema: z.ZodObject<{
140
157
  url: z.ZodURL;
141
158
  dashboard_view_id: z.ZodOptional<z.ZodUUID>;
142
159
  }, z.core.$strip>;
160
+ /**
161
+ * @category Views
162
+ */
143
163
  export type NotionView = z.infer<typeof viewSchema>;
144
- /** Delete-a-view returns a partial object: only object/id/parent/type. */
164
+ /**
165
+ * Notion's delete-view response includes only `object`, `id`, `parent`, and `type`.
166
+ * It omits the rest of the view shape.
167
+ *
168
+ * @category Views
169
+ */
145
170
  export declare const viewDeleteResponseSchema: z.ZodObject<{
146
171
  object: z.ZodLiteral<"view">;
147
172
  id: z.ZodUUID;
@@ -162,10 +187,16 @@ export declare const viewDeleteResponseSchema: z.ZodObject<{
162
187
  dashboard: "dashboard";
163
188
  }>;
164
189
  }, z.core.$strip>;
190
+ /**
191
+ * @category Views
192
+ */
165
193
  export type ViewDeleteResult = z.infer<typeof viewDeleteResponseSchema>;
166
194
  /**
167
- * View query response schema. Non-standard pagination shape: `object: "view_query"`,
168
- * plus `expires_at`/`total_count`; queries expire roughly 15 minutes after creation.
195
+ * View query response schema. This response has a non-standard pagination shape:
196
+ * `object: "view_query"`, plus `expires_at` and `total_count`. Queries expire
197
+ * about 15 minutes after creation.
198
+ *
199
+ * @category Views
169
200
  */
170
201
  export declare const viewQueryResponseSchema: z.ZodObject<{
171
202
  object: z.ZodLiteral<"view_query">;
@@ -404,6 +435,9 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
404
435
  }, z.core.$strip>, z.ZodObject<{
405
436
  type: z.ZodLiteral<"string">;
406
437
  string: z.ZodNullable<z.ZodString>;
438
+ }, z.core.$strip>, z.ZodObject<{
439
+ type: z.ZodLiteral<"unsupported">;
440
+ unsupported: z.ZodObject<{}, z.core.$strip>;
407
441
  }, z.core.$strip>], "type">;
408
442
  }, z.core.$strip>, z.ZodObject<{
409
443
  id: z.ZodString;
@@ -1074,4 +1108,7 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
1074
1108
  }>;
1075
1109
  }, z.core.$strip>>;
1076
1110
  }, z.core.$strip>;
1111
+ /**
1112
+ * @category Views
1113
+ */
1077
1114
  export type ViewQueryResponse = z.infer<typeof viewQueryResponseSchema>;
@@ -43,11 +43,14 @@ const user_schema_1 = require("./user.schema");
43
43
  /**
44
44
  * View object schema.
45
45
  *
46
- * Views control how a database/data source's rows are displayed (table, board,
47
- * calendar, etc.). As of API version 2025-09-03, views have their own endpoints.
46
+ * A view controls how a database or data source displays its rows, for example as a
47
+ * table, board, or calendar. As of API version 2025-09-03, views have their own
48
+ * endpoints.
48
49
  *
49
50
  * Notion API reference:
50
51
  * https://developers.notion.com/guides/data-apis/working-with-views
52
+ *
53
+ * @category Views
51
54
  */
52
55
  exports.VIEW_TYPES = [
53
56
  'table',
@@ -62,16 +65,24 @@ exports.VIEW_TYPES = [
62
65
  'dashboard',
63
66
  ];
64
67
  /**
65
- * Per-layout view configuration. Exact per-type fields (e.g. table column order, board
66
- * group-by property) haven't been confirmed against a live response, so this is kept
67
- * permissive -- tagged on `type`, with all other fields passed through unmodeled -- so
68
- * unknown fields round-trip instead of being stripped or rejected.
68
+ * Configuration for a single view layout.
69
+ *
70
+ * Notion has not confirmed the exact fields for each view type against a live
71
+ * response. Examples include the table column order and the board group-by
72
+ * property. This schema stays permissive. It tags the object by its `type`
73
+ * field and passes all other fields through without validation. As a result,
74
+ * unknown fields round-trip unchanged instead of the schema rejecting them.
75
+ *
76
+ * @category Views
69
77
  */
70
78
  exports.viewConfigurationSchema = z
71
79
  .object({
72
80
  type: z.enum(exports.VIEW_TYPES),
73
81
  })
74
82
  .catchall(z.unknown());
83
+ /**
84
+ * @category Views
85
+ */
75
86
  exports.viewSchema = z.object({
76
87
  object: z.literal('view'),
77
88
  id: z.uuid(),
@@ -91,7 +102,12 @@ exports.viewSchema = z.object({
91
102
  // Widget/dashboard views only.
92
103
  dashboard_view_id: z.uuid().optional(),
93
104
  });
94
- /** Delete-a-view returns a partial object: only object/id/parent/type. */
105
+ /**
106
+ * Notion's delete-view response includes only `object`, `id`, `parent`, and `type`.
107
+ * It omits the rest of the view shape.
108
+ *
109
+ * @category Views
110
+ */
95
111
  exports.viewDeleteResponseSchema = z.object({
96
112
  object: z.literal('view'),
97
113
  id: z.uuid(),
@@ -99,8 +115,11 @@ exports.viewDeleteResponseSchema = z.object({
99
115
  type: z.enum(exports.VIEW_TYPES),
100
116
  });
101
117
  /**
102
- * View query response schema. Non-standard pagination shape: `object: "view_query"`,
103
- * plus `expires_at`/`total_count`; queries expire roughly 15 minutes after creation.
118
+ * View query response schema. This response has a non-standard pagination shape:
119
+ * `object: "view_query"`, plus `expires_at` and `total_count`. Queries expire
120
+ * about 15 minutes after creation.
121
+ *
122
+ * @category Views
104
123
  */
105
124
  exports.viewQueryResponseSchema = z.object({
106
125
  object: z.literal('view_query'),
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Notion API request size limits.
2
+ * Maximum sizes the Notion API allows in a request.
3
3
  *
4
4
  * @see https://developers.notion.com/reference/request-limits#size-limits
5
+ *
6
+ * @category Client & Core
5
7
  */
6
8
  export declare const LIMITS: {
7
9
  /** Maximum characters in a single rich text `text.content` field. */
@@ -34,9 +36,10 @@ export declare const LIMITS: {
34
36
  /**
35
37
  * Thrown when a value exceeds a Notion API size limit.
36
38
  *
37
- * This error is raised client-side *before* the request is sent, giving
38
- * callers an early, actionable error message instead of a generic 400 from
39
- * the API.
39
+ * The SDK throws this error before it sends the request. This gives you an
40
+ * early, actionable message instead of a generic 400 response from the API.
41
+ *
42
+ * @category Errors
40
43
  */
41
44
  export declare class NotionValidationError extends Error {
42
45
  constructor(message: string);
@@ -45,11 +48,15 @@ export declare class NotionValidationError extends Error {
45
48
  * Assert that a string does not exceed `maxLength` characters.
46
49
  *
47
50
  * @throws {NotionValidationError}
51
+ *
52
+ * @category Client & Core
48
53
  */
49
54
  export declare function validateStringLength(value: string, maxLength: number, label: string): void;
50
55
  /**
51
56
  * Assert that an array does not exceed `maxLength` elements.
52
57
  *
53
58
  * @throws {NotionValidationError}
59
+ *
60
+ * @category Client & Core
54
61
  */
55
62
  export declare function validateArrayLength(array: unknown[], maxLength: number, label: string): void;
@@ -4,9 +4,11 @@ exports.NotionValidationError = exports.LIMITS = void 0;
4
4
  exports.validateStringLength = validateStringLength;
5
5
  exports.validateArrayLength = validateArrayLength;
6
6
  /**
7
- * Notion API request size limits.
7
+ * Maximum sizes the Notion API allows in a request.
8
8
  *
9
9
  * @see https://developers.notion.com/reference/request-limits#size-limits
10
+ *
11
+ * @category Client & Core
10
12
  */
11
13
  exports.LIMITS = {
12
14
  /** Maximum characters in a single rich text `text.content` field. */
@@ -39,9 +41,10 @@ exports.LIMITS = {
39
41
  /**
40
42
  * Thrown when a value exceeds a Notion API size limit.
41
43
  *
42
- * This error is raised client-side *before* the request is sent, giving
43
- * callers an early, actionable error message instead of a generic 400 from
44
- * the API.
44
+ * The SDK throws this error before it sends the request. This gives you an
45
+ * early, actionable message instead of a generic 400 response from the API.
46
+ *
47
+ * @category Errors
45
48
  */
46
49
  class NotionValidationError extends Error {
47
50
  constructor(message) {
@@ -60,6 +63,8 @@ exports.NotionValidationError = NotionValidationError;
60
63
  * Assert that a string does not exceed `maxLength` characters.
61
64
  *
62
65
  * @throws {NotionValidationError}
66
+ *
67
+ * @category Client & Core
63
68
  */
64
69
  function validateStringLength(value, maxLength, label) {
65
70
  if (value.length > maxLength) {
@@ -73,6 +78,8 @@ function validateStringLength(value, maxLength, label) {
73
78
  * Assert that an array does not exceed `maxLength` elements.
74
79
  *
75
80
  * @throws {NotionValidationError}
81
+ *
82
+ * @category Client & Core
76
83
  */
77
84
  function validateArrayLength(array, maxLength, label) {
78
85
  if (array.length > maxLength) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visus-io/notion-sdk-ts",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK for the Notion API",
6
6
  "keywords": [
@@ -38,6 +38,9 @@
38
38
  ],
39
39
  "scripts": {
40
40
  "build": "tsc -p tsconfig.build.json",
41
+ "docs:build": "cd docs && bun run build",
42
+ "docs:dev": "cd docs && bun run dev",
43
+ "docs:install": "cd docs && bun install",
41
44
  "format": "prettier --write .",
42
45
  "format:check": "prettier --check .",
43
46
  "lint": "eslint .",
@@ -60,26 +63,27 @@
60
63
  ]
61
64
  },
62
65
  "dependencies": {
63
- "zod": "^4.3.6"
66
+ "zod": "^4.4.3"
64
67
  },
65
68
  "devDependencies": {
66
- "@commitlint/cli": "^21.0.0",
67
- "@commitlint/config-conventional": "^21.0.0",
68
- "@types/node": "^25.2.1",
69
- "@vitest/coverage-v8": "^4.0.18",
70
- "eslint": "^10.0.0",
71
- "eslint-plugin-zod": "4.9.0",
69
+ "@commitlint/cli": "^21.2.2",
70
+ "@commitlint/config-conventional": "^21.2.2",
71
+ "@types/bun": "^1.4.0",
72
+ "@types/node": "^25.9.5",
73
+ "@vitest/coverage-v8": "^4.1.11",
74
+ "eslint": "^10.9.0",
75
+ "eslint-plugin-zod": "4.12.0",
72
76
  "husky": "^9.1.7",
73
- "lint-staged": "^16.2.7",
77
+ "lint-staged": "^16.4.0",
74
78
  "msw": "2.15.0",
75
- "prettier": "^3.8.1",
76
- "prettier-plugin-packagejson": "^3.0.0",
77
- "typescript": "^6.0.0",
78
- "typescript-eslint": "^8.54.0",
79
- "vitest": "^4.0.18"
79
+ "prettier": "^3.9.6",
80
+ "prettier-plugin-packagejson": "^3.0.2",
81
+ "typescript": "^6.0.3",
82
+ "typescript-eslint": "^8.67.0",
83
+ "vitest": "^4.1.11"
80
84
  },
81
85
  "engines": {
82
- "bun": ">=1.3.10",
83
- "node": ">=18.0.0"
86
+ "bun": ">=1.4.0",
87
+ "node": ">=22.0.0"
84
88
  }
85
89
  }