@visus-io/notion-sdk-ts 2.0.1 → 3.0.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 (62) hide show
  1. package/README.md +66 -23
  2. package/dist/api/base.api.d.ts +1 -1
  3. package/dist/api/blocks.api.d.ts +266 -87
  4. package/dist/api/comments.api.d.ts +7 -7
  5. package/dist/api/dataSources.api.d.ts +28 -31
  6. package/dist/api/dataSources.api.js +18 -19
  7. package/dist/api/databases.api.d.ts +27 -22
  8. package/dist/api/databases.api.js +18 -8
  9. package/dist/api/fileUploads.api.d.ts +2 -2
  10. package/dist/api/pages.api.d.ts +43 -38
  11. package/dist/api/pages.api.js +18 -8
  12. package/dist/api/users.api.d.ts +1 -1
  13. package/dist/client.d.ts +5 -3
  14. package/dist/client.js +7 -3
  15. package/dist/helpers/block.helpers.d.ts +4 -0
  16. package/dist/helpers/block.helpers.js +11 -0
  17. package/dist/helpers/parent.helpers.d.ts +2 -2
  18. package/dist/helpers/parent.helpers.js +2 -2
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +3 -1
  21. package/dist/models/base.model.d.ts +2 -2
  22. package/dist/models/block.model.d.ts +0 -1
  23. package/dist/models/block.model.js +0 -3
  24. package/dist/models/dataSource.model.d.ts +0 -4
  25. package/dist/models/dataSource.model.js +0 -6
  26. package/dist/models/database.model.d.ts +0 -4
  27. package/dist/models/database.model.js +0 -6
  28. package/dist/models/page.model.d.ts +0 -1
  29. package/dist/models/page.model.js +0 -3
  30. package/dist/schemas/block.schema.d.ts +275 -82
  31. package/dist/schemas/block.schema.js +165 -82
  32. package/dist/schemas/comment.schema.d.ts +9 -9
  33. package/dist/schemas/comment.schema.js +54 -20
  34. package/dist/schemas/dataSource.schema.d.ts +13 -14
  35. package/dist/schemas/dataSource.schema.js +46 -14
  36. package/dist/schemas/database.schema.d.ts +13 -14
  37. package/dist/schemas/database.schema.js +50 -17
  38. package/dist/schemas/emoji.schema.d.ts +1 -1
  39. package/dist/schemas/emoji.schema.js +37 -4
  40. package/dist/schemas/file.schema.d.ts +3 -3
  41. package/dist/schemas/file.schema.js +49 -15
  42. package/dist/schemas/fileUpload.schema.d.ts +3 -3
  43. package/dist/schemas/fileUpload.schema.js +47 -13
  44. package/dist/schemas/index.d.ts +1 -0
  45. package/dist/schemas/index.js +1 -0
  46. package/dist/schemas/page.schema.d.ts +30 -31
  47. package/dist/schemas/page.schema.js +46 -13
  48. package/dist/schemas/pageProperties.schema.d.ts +47 -47
  49. package/dist/schemas/pageProperties.schema.js +162 -128
  50. package/dist/schemas/pagination.schema.d.ts +1 -1
  51. package/dist/schemas/pagination.schema.js +40 -7
  52. package/dist/schemas/parent.schema.d.ts +1 -1
  53. package/dist/schemas/parent.schema.js +51 -18
  54. package/dist/schemas/propertyObjects.schema.d.ts +1 -1
  55. package/dist/schemas/propertyObjects.schema.js +194 -161
  56. package/dist/schemas/richText.schema.d.ts +7 -7
  57. package/dist/schemas/richText.schema.js +95 -56
  58. package/dist/schemas/shared.schema.d.ts +15 -0
  59. package/dist/schemas/shared.schema.js +54 -0
  60. package/dist/schemas/user.schema.d.ts +3 -3
  61. package/dist/schemas/user.schema.js +63 -30
  62. package/package.json +7 -5
package/README.md CHANGED
@@ -1,13 +1,12 @@
1
1
  # @visus-io/notion-sdk-ts
2
2
 
3
3
  [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/visus-io/notion-sdk-ts/ci.yml?style=for-the-badge&logo=github)](https://github.com/visus-io/notion-sdk-ts/actions/workflows/ci.yaml)
4
-
5
- [![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/visus%3Anotion-sdk-ts?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarcloud&logoColor=white)](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
6
- [![Sonar Coverage](https://img.shields.io/sonar/coverage/visus%3Anotion-sdk-ts?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonarcloud&logoColor=white)](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
4
+ [![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/visus%3Anotion-sdk-ts?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonar&logoColor=white)](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
5
+ [![Sonar Coverage](https://img.shields.io/sonar/coverage/visus%3Anotion-sdk-ts?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonar&logoColor=white)](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
7
6
 
8
7
  [![NPM Version](https://img.shields.io/npm/v/%40visus-io%2Fnotion-sdk-ts?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@visus-io/notion-sdk-ts)
9
8
  ![NPM Downloads](https://img.shields.io/npm/dm/%40visus-io%2Fnotion-sdk-ts?style=for-the-badge&logo=npm)
10
- ![GitHub](https://img.shields.io/github/license/visus-io/notion-sdk-ts?style=for-the-badge)
9
+ ![Static Badge](https://img.shields.io/badge/license-mit-green?style=for-the-badge)
11
10
 
12
11
  A type-safe TypeScript SDK for the Notion API with Zod validation, OOP models, and ergonomic helpers.
13
12
 
@@ -26,9 +25,11 @@ A type-safe TypeScript SDK for the Notion API with Zod validation, OOP models, a
26
25
 
27
26
  ```bash
28
27
  npm install @visus-io/notion-sdk-ts
28
+ # or
29
+ bun add @visus-io/notion-sdk-ts
29
30
  ```
30
31
 
31
- **Requirements:** Node.js 18+ (uses native `fetch`)
32
+ **Requirements:** Node.js 18+ or Bun 1.3.10+ (uses native `fetch`)
32
33
 
33
34
  ## Quick Start
34
35
 
@@ -80,7 +81,7 @@ Comprehensive documentation is available in the [**GitHub Wiki**](https://github
80
81
  ### Getting Started
81
82
 
82
83
  - [**Getting Started**](https://github.com/visus-io/notion-sdk-ts/wiki/Getting-Started) - Installation, quick start, and basic configuration
83
- - [**Migration Guide**](https://github.com/visus-io/notion-sdk-ts/wiki/Migration-Guide) - Migrating to API version 2025-09-03
84
+ - [**Migration Guide**](https://github.com/visus-io/notion-sdk-ts/wiki/Migration-Guide) - Migrating between API versions
84
85
  - [**Common Use Cases**](https://github.com/visus-io/notion-sdk-ts/wiki/Common-Use-Cases) - Practical examples and workflows
85
86
 
86
87
  ### Core Concepts
@@ -103,25 +104,53 @@ Comprehensive documentation is available in the [**GitHub Wiki**](https://github
103
104
 
104
105
  ## Migration Notice
105
106
 
106
- **This SDK now defaults to Notion API version `2025-09-03`** (previously `2022-06-28`). This version introduces breaking changes for multi-source database support.
107
+ **This SDK now targets Notion API version `2026-03-11`** (upgraded from `2025-09-03` in v3.x; originally `2022-06-28` in v1.x). The API version is fixed it cannot be overridden via client options.
108
+
109
+ ### Key Changes (v3.x — 2026-03-11)
110
+
111
+ - **`archived` → `in_trash`**: Field renamed across all schemas, models, and API request bodies
112
+ - **`after` → `position` object**: `blocks.children.append()` now accepts a typed `position` union
113
+ - **`transcription` → `meeting_notes`**: Block type and helper renamed
114
+ - **`notionVersion` removed**: Use the exported `NOTION_VERSION` constant to inspect the target version
115
+
116
+ ### Quick Migration Example (v2.x → v3.x)
117
+
118
+ ```typescript
119
+ // OLD (v2.x / 2025-09-03)
120
+ console.log(page.archived);
121
+ await notion.blocks.children.append('page-id', {
122
+ children: [block.paragraph('text')],
123
+ after: 'block-id',
124
+ });
125
+ block.transcription('Transcription text');
126
+
127
+ // NEW (v3.x / 2026-03-11)
128
+ import { NOTION_VERSION } from '@visus-io/notion-sdk-ts';
129
+ console.log(page.inTrash);
130
+ await notion.blocks.children.append('page-id', {
131
+ children: [block.paragraph('text')],
132
+ position: { type: 'after_block', after_block: { id: 'block-id' } },
133
+ });
134
+ block.meetingNotes('Meeting notes text');
135
+ ```
107
136
 
108
- ### Key Changes
137
+ ### Key Changes (v2.x — 2025-09-03)
109
138
 
110
- - **Database creation:** Properties moved to `initial_data_source.properties`
111
- - **Database updates:** Use Data Sources API for property changes
112
- - **Page creation:** Requires both data source ID and database ID
113
- - **Search API:** Returns `DataSource` objects instead of `Database`
139
+ - **Database creation**: Properties moved to `initial_data_source.properties`
140
+ - **Database updates**: Use Data Sources API for property changes
141
+ - **Page creation**: Requires both data source ID and database ID
142
+ - **Search API**: Returns `DataSource` objects instead of `Database`
114
143
 
115
- ### Quick Migration Example
144
+ ### Quick Migration Example (v1.x → v2.x)
116
145
 
117
146
  ```typescript
118
- // OLD (2022-06-28)
147
+ // OLD (v1.x / 2022-06-28)
119
148
  await notion.pages.create({
120
149
  parent: parent.database('database-id'),
121
150
  properties: { Name: prop.title('Task') },
122
151
  });
123
152
 
124
- // NEW (2025-09-03)
153
+ // NEW (v2.x / 2025-09-03)
125
154
  const db = await notion.databases.retrieve('database-id');
126
155
  const dataSourceId = db.dataSources[0].id;
127
156
 
@@ -135,19 +164,33 @@ See the [**Migration Guide**](https://github.com/visus-io/notion-sdk-ts/wiki/Mig
135
164
 
136
165
  ## Development
137
166
 
167
+ This project uses [Bun](https://bun.sh) as its package manager for faster dependency installation and script execution.
168
+
169
+ ### Prerequisites
170
+
171
+ Install Bun if you haven't already:
172
+
138
173
  ```bash
139
- npm install # Install dependencies
140
- npm run build # Compile TypeScript
174
+ curl -fsSL https://bun.sh/install | bash
175
+ ```
176
+
177
+ ### Development Commands
141
178
 
142
- npm test # Run tests
143
- npm run test:watch # Watch mode
144
- npm run test:coverage # Coverage report
179
+ ```bash
180
+ bun install # Install dependencies
181
+ bun run build # Compile TypeScript
145
182
 
146
- npm run lint # ESLint
147
- npm run lint:fix # Auto-fix
148
- npm run format # Prettier
183
+ bun run test # Run tests
184
+ bun run test:watch # Watch mode
185
+ bun run test:coverage # Coverage report
186
+
187
+ bun run lint # ESLint
188
+ bun run lint:fix # Auto-fix
189
+ bun run format # Prettier
149
190
  ```
150
191
 
192
+ > **Note:** While this project uses Bun for development, the published package works with both Node.js 18+ and Bun 1.3.10+.
193
+
151
194
  See [**Development & Contributing**](https://github.com/visus-io/notion-sdk-ts/wiki/Development) for more details.
152
195
 
153
196
  ## Links
@@ -1,6 +1,6 @@
1
1
  import type { NotionClient } from '../client';
2
2
  import type { PaginatedList, PaginatedListType, PaginationParameters } from '../schemas';
3
- import type { z } from 'zod';
3
+ import type * as z from 'zod';
4
4
  /**
5
5
  * Configuration for API resource operations, including paths, schemas, and model classes.
6
6
  *