@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.
Files changed (130) hide show
  1. package/README.md +20 -87
  2. package/dist/api/asyncTasks.api.d.ts +72 -0
  3. package/dist/api/asyncTasks.api.js +70 -0
  4. package/dist/api/base.api.d.ts +15 -4
  5. package/dist/api/base.api.js +20 -8
  6. package/dist/api/blocks.api.d.ts +435 -73
  7. package/dist/api/blocks.api.js +43 -1
  8. package/dist/api/comments.api.d.ts +42 -5
  9. package/dist/api/comments.api.js +45 -1
  10. package/dist/api/customEmojis.api.d.ts +38 -0
  11. package/dist/api/customEmojis.api.js +38 -0
  12. package/dist/api/dataSources.api.d.ts +67 -14
  13. package/dist/api/dataSources.api.js +26 -1
  14. package/dist/api/databases.api.d.ts +47 -11
  15. package/dist/api/databases.api.js +4 -1
  16. package/dist/api/fileUploads.api.d.ts +8 -5
  17. package/dist/api/fileUploads.api.js +11 -7
  18. package/dist/api/index.d.ts +3 -0
  19. package/dist/api/index.js +7 -1
  20. package/dist/api/pages.api.d.ts +144 -10
  21. package/dist/api/pages.api.js +66 -0
  22. package/dist/api/search.api.d.ts +12 -2
  23. package/dist/api/search.api.js +5 -2
  24. package/dist/api/users.api.d.ts +3 -0
  25. package/dist/api/users.api.js +2 -0
  26. package/dist/api/views.api.d.ts +286 -0
  27. package/dist/api/views.api.js +172 -0
  28. package/dist/client.d.ts +17 -17
  29. package/dist/client.js +25 -30
  30. package/dist/errors.d.ts +19 -5
  31. package/dist/errors.js +16 -4
  32. package/dist/helpers/block.helpers.d.ts +49 -5
  33. package/dist/helpers/block.helpers.js +50 -6
  34. package/dist/helpers/file.helpers.d.ts +46 -5
  35. package/dist/helpers/file.helpers.js +36 -8
  36. package/dist/helpers/filter.helpers.d.ts +8 -6
  37. package/dist/helpers/filter.helpers.js +2 -0
  38. package/dist/helpers/index.d.ts +3 -2
  39. package/dist/helpers/index.js +5 -1
  40. package/dist/helpers/pagination.helpers.d.ts +85 -13
  41. package/dist/helpers/pagination.helpers.js +114 -8
  42. package/dist/helpers/parent.helpers.d.ts +5 -3
  43. package/dist/helpers/parent.helpers.js +5 -3
  44. package/dist/helpers/property.helpers.d.ts +31 -0
  45. package/dist/helpers/property.helpers.js +30 -1
  46. package/dist/helpers/richText.helpers.d.ts +10 -5
  47. package/dist/helpers/richText.helpers.js +11 -6
  48. package/dist/helpers/sort.helpers.d.ts +2 -0
  49. package/dist/helpers/sort.helpers.js +2 -0
  50. package/dist/helpers/webhook.helpers.d.ts +54 -0
  51. package/dist/helpers/webhook.helpers.js +83 -0
  52. package/dist/models/asyncTask.model.d.ts +61 -0
  53. package/dist/models/asyncTask.model.js +91 -0
  54. package/dist/models/base.model.d.ts +16 -4
  55. package/dist/models/base.model.js +17 -5
  56. package/dist/models/block.model.d.ts +6 -2
  57. package/dist/models/block.model.js +48 -33
  58. package/dist/models/comment.model.d.ts +4 -2
  59. package/dist/models/comment.model.js +4 -2
  60. package/dist/models/customEmoji.model.d.ts +30 -0
  61. package/dist/models/customEmoji.model.js +44 -0
  62. package/dist/models/dataSource.model.d.ts +7 -5
  63. package/dist/models/dataSource.model.js +5 -3
  64. package/dist/models/database.model.d.ts +13 -5
  65. package/dist/models/database.model.js +15 -5
  66. package/dist/models/fileUpload.model.d.ts +6 -4
  67. package/dist/models/fileUpload.model.js +6 -4
  68. package/dist/models/index.d.ts +3 -0
  69. package/dist/models/index.js +7 -1
  70. package/dist/models/page.model.d.ts +8 -2
  71. package/dist/models/page.model.js +14 -4
  72. package/dist/models/richText.model.d.ts +3 -1
  73. package/dist/models/richText.model.js +3 -1
  74. package/dist/models/user.model.d.ts +4 -2
  75. package/dist/models/user.model.js +4 -2
  76. package/dist/models/view.model.d.ts +81 -0
  77. package/dist/models/view.model.js +121 -0
  78. package/dist/notion.d.ts +32 -8
  79. package/dist/notion.js +25 -4
  80. package/dist/schemas/asyncTask.schema.d.ts +53 -0
  81. package/dist/schemas/asyncTask.schema.js +88 -0
  82. package/dist/schemas/block.schema.d.ts +390 -73
  83. package/dist/schemas/block.schema.js +39 -8
  84. package/dist/schemas/codeLanguages.d.ts +7 -1
  85. package/dist/schemas/codeLanguages.js +4 -1
  86. package/dist/schemas/colors.d.ts +7 -1
  87. package/dist/schemas/colors.js +4 -1
  88. package/dist/schemas/comment.schema.d.ts +28 -5
  89. package/dist/schemas/comment.schema.js +11 -2
  90. package/dist/schemas/customEmoji.schema.d.ts +18 -0
  91. package/dist/schemas/customEmoji.schema.js +50 -0
  92. package/dist/schemas/dataSource.schema.d.ts +84 -10
  93. package/dist/schemas/dataSource.schema.js +31 -6
  94. package/dist/schemas/database.schema.d.ts +51 -7
  95. package/dist/schemas/database.schema.js +10 -3
  96. package/dist/schemas/emoji.schema.d.ts +7 -2
  97. package/dist/schemas/emoji.schema.js +4 -2
  98. package/dist/schemas/file.schema.d.ts +18 -2
  99. package/dist/schemas/file.schema.js +6 -2
  100. package/dist/schemas/fileUpload.schema.d.ts +9 -3
  101. package/dist/schemas/fileUpload.schema.js +5 -2
  102. package/dist/schemas/icon.schema.d.ts +116 -0
  103. package/dist/schemas/icon.schema.js +100 -0
  104. package/dist/schemas/index.d.ts +6 -0
  105. package/dist/schemas/index.js +6 -0
  106. package/dist/schemas/meetingNotesQuery.schema.d.ts +4198 -0
  107. package/dist/schemas/meetingNotesQuery.schema.js +67 -0
  108. package/dist/schemas/page.schema.d.ts +51 -9
  109. package/dist/schemas/page.schema.js +6 -2
  110. package/dist/schemas/pageMarkdown.schema.d.ts +70 -0
  111. package/dist/schemas/pageMarkdown.schema.js +70 -0
  112. package/dist/schemas/pageProperties.schema.d.ts +105 -21
  113. package/dist/schemas/pageProperties.schema.js +8 -6
  114. package/dist/schemas/pagination.schema.d.ts +57 -7
  115. package/dist/schemas/pagination.schema.js +25 -1
  116. package/dist/schemas/parent.schema.d.ts +39 -3
  117. package/dist/schemas/parent.schema.js +17 -5
  118. package/dist/schemas/propertyObjects.schema.d.ts +93 -15
  119. package/dist/schemas/propertyObjects.schema.js +11 -5
  120. package/dist/schemas/richText.schema.d.ts +23 -6
  121. package/dist/schemas/richText.schema.js +7 -4
  122. package/dist/schemas/shared.schema.d.ts +6 -3
  123. package/dist/schemas/shared.schema.js +6 -3
  124. package/dist/schemas/user.schema.d.ts +17 -0
  125. package/dist/schemas/user.schema.js +7 -3
  126. package/dist/schemas/view.schema.d.ts +1111 -0
  127. package/dist/schemas/view.schema.js +134 -0
  128. package/dist/validation.d.ts +11 -4
  129. package/dist/validation.js +11 -4
  130. package/package.json +6 -3
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.viewQueryResponseSchema = exports.viewDeleteResponseSchema = exports.viewSchema = exports.viewConfigurationSchema = exports.VIEW_TYPES = void 0;
37
+ const z = __importStar(require("zod"));
38
+ const parent_schema_1 = require("./parent.schema");
39
+ const page_schema_1 = require("./page.schema");
40
+ const pagination_schema_1 = require("./pagination.schema");
41
+ const shared_schema_1 = require("./shared.schema");
42
+ const user_schema_1 = require("./user.schema");
43
+ /**
44
+ * View object schema.
45
+ *
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.
49
+ *
50
+ * Notion API reference:
51
+ * https://developers.notion.com/guides/data-apis/working-with-views
52
+ *
53
+ * @category Views
54
+ */
55
+ exports.VIEW_TYPES = [
56
+ 'table',
57
+ 'board',
58
+ 'list',
59
+ 'calendar',
60
+ 'timeline',
61
+ 'gallery',
62
+ 'form',
63
+ 'chart',
64
+ 'map',
65
+ 'dashboard',
66
+ ];
67
+ /**
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
77
+ */
78
+ exports.viewConfigurationSchema = z
79
+ .object({
80
+ type: z.enum(exports.VIEW_TYPES),
81
+ })
82
+ .catchall(z.unknown());
83
+ /**
84
+ * @category Views
85
+ */
86
+ exports.viewSchema = z.object({
87
+ object: z.literal('view'),
88
+ id: z.uuid(),
89
+ parent: parent_schema_1.databaseParentSchema,
90
+ data_source_id: z.uuid().nullable(),
91
+ name: z.string().trim(),
92
+ type: z.enum(exports.VIEW_TYPES),
93
+ filter: z.record(z.string(), z.unknown()).nullish(),
94
+ sorts: z.array(z.record(z.string(), z.unknown())).nullish(),
95
+ quick_filters: z.record(z.string(), z.unknown()).nullish(),
96
+ configuration: exports.viewConfigurationSchema.optional(),
97
+ created_time: shared_schema_1.notionDateStringSchema,
98
+ last_edited_time: shared_schema_1.notionDateStringSchema,
99
+ created_by: user_schema_1.userSchema,
100
+ last_edited_by: user_schema_1.userSchema,
101
+ url: z.url(),
102
+ // Widget/dashboard views only.
103
+ dashboard_view_id: z.uuid().optional(),
104
+ });
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
+ */
111
+ exports.viewDeleteResponseSchema = z.object({
112
+ object: z.literal('view'),
113
+ id: z.uuid(),
114
+ parent: parent_schema_1.databaseParentSchema,
115
+ type: z.enum(exports.VIEW_TYPES),
116
+ });
117
+ /**
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
123
+ */
124
+ exports.viewQueryResponseSchema = z.object({
125
+ object: z.literal('view_query'),
126
+ id: z.uuid(),
127
+ view_id: z.uuid(),
128
+ expires_at: shared_schema_1.notionDateStringSchema,
129
+ total_count: z.number(),
130
+ results: z.array(page_schema_1.pageSchema),
131
+ next_cursor: z.string().trim().nullable(),
132
+ has_more: z.boolean(),
133
+ request_status: pagination_schema_1.requestStatusSchema.optional(),
134
+ });
@@ -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.0.2",
3
+ "version": "3.1.1",
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 .",
@@ -68,13 +71,13 @@
68
71
  "@types/node": "^25.2.1",
69
72
  "@vitest/coverage-v8": "^4.0.18",
70
73
  "eslint": "^10.0.0",
71
- "eslint-plugin-zod": "4.8.0",
74
+ "eslint-plugin-zod": "4.9.0",
72
75
  "husky": "^9.1.7",
73
76
  "lint-staged": "^16.2.7",
74
77
  "msw": "2.15.0",
75
78
  "prettier": "^3.8.1",
76
79
  "prettier-plugin-packagejson": "^3.0.0",
77
- "typescript": "^6.0.0",
80
+ "typescript": "^6.0.3",
78
81
  "typescript-eslint": "^8.54.0",
79
82
  "vitest": "^4.0.18"
80
83
  },