@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.
- package/README.md +66 -23
- package/dist/api/base.api.d.ts +1 -1
- package/dist/api/blocks.api.d.ts +266 -87
- package/dist/api/comments.api.d.ts +7 -7
- package/dist/api/dataSources.api.d.ts +28 -31
- package/dist/api/dataSources.api.js +18 -19
- package/dist/api/databases.api.d.ts +27 -22
- package/dist/api/databases.api.js +18 -8
- package/dist/api/fileUploads.api.d.ts +2 -2
- package/dist/api/pages.api.d.ts +43 -38
- package/dist/api/pages.api.js +18 -8
- package/dist/api/users.api.d.ts +1 -1
- package/dist/client.d.ts +5 -3
- package/dist/client.js +7 -3
- package/dist/helpers/block.helpers.d.ts +4 -0
- package/dist/helpers/block.helpers.js +11 -0
- package/dist/helpers/parent.helpers.d.ts +2 -2
- package/dist/helpers/parent.helpers.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/models/base.model.d.ts +2 -2
- package/dist/models/block.model.d.ts +0 -1
- package/dist/models/block.model.js +0 -3
- package/dist/models/dataSource.model.d.ts +0 -4
- package/dist/models/dataSource.model.js +0 -6
- package/dist/models/database.model.d.ts +0 -4
- package/dist/models/database.model.js +0 -6
- package/dist/models/page.model.d.ts +0 -1
- package/dist/models/page.model.js +0 -3
- package/dist/schemas/block.schema.d.ts +275 -82
- package/dist/schemas/block.schema.js +165 -82
- package/dist/schemas/comment.schema.d.ts +9 -9
- package/dist/schemas/comment.schema.js +54 -20
- package/dist/schemas/dataSource.schema.d.ts +13 -14
- package/dist/schemas/dataSource.schema.js +46 -14
- package/dist/schemas/database.schema.d.ts +13 -14
- package/dist/schemas/database.schema.js +50 -17
- package/dist/schemas/emoji.schema.d.ts +1 -1
- package/dist/schemas/emoji.schema.js +37 -4
- package/dist/schemas/file.schema.d.ts +3 -3
- package/dist/schemas/file.schema.js +49 -15
- package/dist/schemas/fileUpload.schema.d.ts +3 -3
- package/dist/schemas/fileUpload.schema.js +47 -13
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/page.schema.d.ts +30 -31
- package/dist/schemas/page.schema.js +46 -13
- package/dist/schemas/pageProperties.schema.d.ts +47 -47
- package/dist/schemas/pageProperties.schema.js +162 -128
- package/dist/schemas/pagination.schema.d.ts +1 -1
- package/dist/schemas/pagination.schema.js +40 -7
- package/dist/schemas/parent.schema.d.ts +1 -1
- package/dist/schemas/parent.schema.js +51 -18
- package/dist/schemas/propertyObjects.schema.d.ts +1 -1
- package/dist/schemas/propertyObjects.schema.js +194 -161
- package/dist/schemas/richText.schema.d.ts +7 -7
- package/dist/schemas/richText.schema.js +95 -56
- package/dist/schemas/shared.schema.d.ts +15 -0
- package/dist/schemas/shared.schema.js +54 -0
- package/dist/schemas/user.schema.d.ts +3 -3
- package/dist/schemas/user.schema.js +63 -30
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# @visus-io/notion-sdk-ts
|
|
2
2
|
|
|
3
3
|
[](https://github.com/visus-io/notion-sdk-ts/actions/workflows/ci.yaml)
|
|
4
|
-
|
|
5
|
-
[](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
|
|
4
|
+
[](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
|
|
5
|
+
[](https://sonarcloud.io/summary/overall?id=visus%3Anotion-sdk-ts)
|
|
7
6
|
|
|
8
7
|
[](https://www.npmjs.com/package/@visus-io/notion-sdk-ts)
|
|
9
8
|

|
|
10
|
-

|
|
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
|
|
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
|
|
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
|
|
111
|
-
- **Database updates
|
|
112
|
-
- **Page creation
|
|
113
|
-
- **Search API
|
|
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
|
-
|
|
140
|
-
|
|
174
|
+
curl -fsSL https://bun.sh/install | bash
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Development Commands
|
|
141
178
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
179
|
+
```bash
|
|
180
|
+
bun install # Install dependencies
|
|
181
|
+
bun run build # Compile TypeScript
|
|
145
182
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
package/dist/api/base.api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NotionClient } from '../client';
|
|
2
2
|
import type { PaginatedList, PaginatedListType, PaginationParameters } from '../schemas';
|
|
3
|
-
import type
|
|
3
|
+
import type * as z from 'zod';
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for API resource operations, including paths, schemas, and model classes.
|
|
6
6
|
*
|