@infograb/notion-cli 5.9.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.
- package/LICENSE +21 -0
- package/README.md +1386 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +14 -0
- package/bin/run.cmd +3 -0
- package/dist/base-command.d.ts +73 -0
- package/dist/base-command.js +179 -0
- package/dist/base-flags.d.ts +14 -0
- package/dist/base-flags.js +59 -0
- package/dist/cache.d.ts +84 -0
- package/dist/cache.js +351 -0
- package/dist/commands/batch/retrieve.d.ts +43 -0
- package/dist/commands/batch/retrieve.js +265 -0
- package/dist/commands/block/append.d.ts +42 -0
- package/dist/commands/block/append.js +219 -0
- package/dist/commands/block/delete.d.ts +30 -0
- package/dist/commands/block/delete.js +94 -0
- package/dist/commands/block/retrieve/children.d.ts +31 -0
- package/dist/commands/block/retrieve/children.js +174 -0
- package/dist/commands/block/retrieve.d.ts +30 -0
- package/dist/commands/block/retrieve.js +98 -0
- package/dist/commands/block/update.d.ts +45 -0
- package/dist/commands/block/update.js +241 -0
- package/dist/commands/cache/info.d.ts +19 -0
- package/dist/commands/cache/info.js +145 -0
- package/dist/commands/config/set-token.d.ts +30 -0
- package/dist/commands/config/set-token.js +201 -0
- package/dist/commands/db/create.d.ts +31 -0
- package/dist/commands/db/create.js +124 -0
- package/dist/commands/db/query.d.ts +41 -0
- package/dist/commands/db/query.js +355 -0
- package/dist/commands/db/retrieve.d.ts +33 -0
- package/dist/commands/db/retrieve.js +134 -0
- package/dist/commands/db/schema.d.ts +32 -0
- package/dist/commands/db/schema.js +308 -0
- package/dist/commands/db/update.d.ts +31 -0
- package/dist/commands/db/update.js +117 -0
- package/dist/commands/doctor.d.ts +50 -0
- package/dist/commands/doctor.js +420 -0
- package/dist/commands/init.d.ts +57 -0
- package/dist/commands/init.js +471 -0
- package/dist/commands/list.d.ts +29 -0
- package/dist/commands/list.js +184 -0
- package/dist/commands/page/create.d.ts +33 -0
- package/dist/commands/page/create.js +240 -0
- package/dist/commands/page/retrieve/property_item.d.ts +24 -0
- package/dist/commands/page/retrieve/property_item.js +72 -0
- package/dist/commands/page/retrieve.d.ts +36 -0
- package/dist/commands/page/retrieve.js +244 -0
- package/dist/commands/page/update.d.ts +34 -0
- package/dist/commands/page/update.js +184 -0
- package/dist/commands/search.d.ts +40 -0
- package/dist/commands/search.js +348 -0
- package/dist/commands/sync.d.ts +24 -0
- package/dist/commands/sync.js +183 -0
- package/dist/commands/user/list.d.ts +27 -0
- package/dist/commands/user/list.js +99 -0
- package/dist/commands/user/retrieve/bot.d.ts +28 -0
- package/dist/commands/user/retrieve/bot.js +96 -0
- package/dist/commands/user/retrieve.d.ts +30 -0
- package/dist/commands/user/retrieve.js +103 -0
- package/dist/commands/whoami.d.ts +19 -0
- package/dist/commands/whoami.js +175 -0
- package/dist/deduplication.d.ts +41 -0
- package/dist/deduplication.js +71 -0
- package/dist/envelope.d.ts +169 -0
- package/dist/envelope.js +257 -0
- package/dist/errors/enhanced-errors.d.ts +168 -0
- package/dist/errors/enhanced-errors.js +570 -0
- package/dist/errors/index.d.ts +18 -0
- package/dist/errors/index.js +33 -0
- package/dist/examples/cache-retry-examples.d.ts +64 -0
- package/dist/examples/cache-retry-examples.js +375 -0
- package/dist/helper.d.ts +102 -0
- package/dist/helper.js +885 -0
- package/dist/http-agent.d.ts +38 -0
- package/dist/http-agent.js +60 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/interface.d.ts +4 -0
- package/dist/interface.js +2 -0
- package/dist/notion.d.ts +144 -0
- package/dist/notion.js +547 -0
- package/dist/retry.d.ts +72 -0
- package/dist/retry.js +381 -0
- package/dist/utils/disk-cache.d.ts +80 -0
- package/dist/utils/disk-cache.js +291 -0
- package/dist/utils/markdown-to-blocks.d.ts +19 -0
- package/dist/utils/markdown-to-blocks.js +259 -0
- package/dist/utils/notion-resolver.d.ts +48 -0
- package/dist/utils/notion-resolver.js +262 -0
- package/dist/utils/notion-url-parser.d.ts +46 -0
- package/dist/utils/notion-url-parser.js +111 -0
- package/dist/utils/property-expander.d.ts +45 -0
- package/dist/utils/property-expander.js +323 -0
- package/dist/utils/schema-examples.d.ts +40 -0
- package/dist/utils/schema-examples.js +359 -0
- package/dist/utils/schema-extractor.d.ts +65 -0
- package/dist/utils/schema-extractor.js +235 -0
- package/dist/utils/table-formatter.d.ts +36 -0
- package/dist/utils/table-formatter.js +122 -0
- package/dist/utils/terminal-banner.d.ts +24 -0
- package/dist/utils/terminal-banner.js +34 -0
- package/dist/utils/token-validator.d.ts +55 -0
- package/dist/utils/token-validator.js +85 -0
- package/dist/utils/update-notifier.d.ts +26 -0
- package/dist/utils/update-notifier.js +54 -0
- package/dist/utils/workspace-cache.d.ts +58 -0
- package/dist/utils/workspace-cache.js +185 -0
- package/oclif.manifest.json +4497 -0
- package/package.json +115 -0
- package/scripts/banner.js +38 -0
- package/scripts/postinstall.js +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,1386 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<pre>
|
|
3
|
+
███╗ ██╗ ██████╗ ████████╗██╗ ██████╗ ███╗ ██╗ ██████╗██╗ ██╗
|
|
4
|
+
████╗ ██║██╔═══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║ ██╔════╝██║ ██║
|
|
5
|
+
██╔██╗ ██║██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║ ██║
|
|
6
|
+
██║╚██╗██║██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██║ ██║
|
|
7
|
+
██║ ╚████║╚██████╔╝ ██║ ██║╚██████╔╝██║ ╚████║ ╚██████╗███████╗██║
|
|
8
|
+
╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═╝
|
|
9
|
+
</pre>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/infograb/notion-cli/actions/workflows/ci.yml">
|
|
13
|
+
<img src="https://github.com/infograb/notion-cli/actions/workflows/ci.yml/badge.svg" alt="CI/CD Pipeline">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://codecov.io/gh/infograb/notion-cli">
|
|
16
|
+
<img src="https://codecov.io/gh/infograb/notion-cli/branch/main/graph/badge.svg" alt="Code Coverage">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@infograb/notion-cli">
|
|
19
|
+
<img src="https://img.shields.io/npm/v/@infograb/notion-cli.svg" alt="npm version">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://nodejs.org">
|
|
22
|
+
<img src="https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg" alt="Node.js Version">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://github.com/infograb/notion-cli/blob/main/LICENSE">
|
|
25
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
**IMPORTANT NOTICE:**
|
|
31
|
+
|
|
32
|
+
This is an independent, unofficial command-line tool for working with Notion's API.
|
|
33
|
+
This project is not affiliated with, endorsed by, or sponsored by Notion Labs, Inc.
|
|
34
|
+
"Notion" is a registered trademark of Notion Labs, Inc.
|
|
35
|
+
|
|
36
|
+
> Notion CLI for AI Agents & Automation (v5.9.0 with 5-Phase Performance Optimization)
|
|
37
|
+
|
|
38
|
+
A powerful command-line interface for Notion's API, optimized for AI coding assistants and automation scripts. Now with comprehensive performance optimizations delivering 1.5-2x improvement for batch operations.
|
|
39
|
+
|
|
40
|
+
**Key Features:**
|
|
41
|
+
|
|
42
|
+
- 🚀 **Fast & Direct**: Native API integration with intelligent caching
|
|
43
|
+
- 🤖 **AI-First Design**: JSON output mode, structured errors, exit codes
|
|
44
|
+
- ⚡ **Non-Interactive**: Perfect for scripts and automation
|
|
45
|
+
- 📊 **Flexible Output**: JSON, CSV, YAML, or raw API responses
|
|
46
|
+
- ✅ **Latest API**: Notion API v5.2.1 with data sources support
|
|
47
|
+
- 🔄 **Enhanced Reliability**: Automatic retry with exponential backoff
|
|
48
|
+
- ⚡ **High Performance**: 5-phase optimization (1.5-2x improvement)
|
|
49
|
+
- Request deduplication, parallel operations, disk cache, keep-alive, compression
|
|
50
|
+
- 🔍 **Schema Discovery**: AI-friendly database schema extraction
|
|
51
|
+
- 🗄️ **Workspace Caching**: Fast database lookups without API calls
|
|
52
|
+
- 🧠 **Smart ID Resolution**: Automatic database_id → data_source_id conversion
|
|
53
|
+
- 🔒 **Secure**: 0 production vulnerabilities
|
|
54
|
+
|
|
55
|
+
## What's New in v5.6.0
|
|
56
|
+
|
|
57
|
+
**Improved First-Time Experience & Enhanced Security** 🎉
|
|
58
|
+
|
|
59
|
+
### 1. Interactive Setup Wizard
|
|
60
|
+
|
|
61
|
+
- **NEW `notion-cli init` command** - Guided first-time setup in 3 easy steps
|
|
62
|
+
- **Token configuration** - Clear instructions for getting and setting your API token
|
|
63
|
+
- **Connection testing** - Verify API access before proceeding
|
|
64
|
+
- **Workspace sync** - Optional local caching for faster operations
|
|
65
|
+
- **Supports `--json`** - Automation-friendly for CI/CD environments
|
|
66
|
+
|
|
67
|
+
### 2. Health Check & Diagnostics
|
|
68
|
+
|
|
69
|
+
- **NEW `notion-cli doctor` command** - Comprehensive health checks (aliases: `diagnose`, `healthcheck`)
|
|
70
|
+
- **7 diagnostic checks** - Node version, token config, API connection, workspace access, cache status, dependencies, file permissions
|
|
71
|
+
- **Color-coded output** - Clear pass/fail indicators with actionable recommendations
|
|
72
|
+
- **JSON support** - Monitor system health programmatically
|
|
73
|
+
- **Perfect for troubleshooting** - Quickly identify and fix issues
|
|
74
|
+
|
|
75
|
+
### 3. Enhanced Error Handling
|
|
76
|
+
|
|
77
|
+
- **Token validator** - Early validation before API calls (500x faster error feedback)
|
|
78
|
+
- **Platform-specific help** - Tailored instructions for Windows (CMD/PowerShell) and Unix/Mac
|
|
79
|
+
- **Actionable messages** - Clear next steps instead of cryptic API errors
|
|
80
|
+
- **Prevents confusion** - No more "unauthorized" errors on first run
|
|
81
|
+
|
|
82
|
+
### 4. Post-Install Experience
|
|
83
|
+
|
|
84
|
+
- **Welcome message** - Friendly introduction after installation
|
|
85
|
+
- **Clear next steps** - Guides new users to run `notion-cli init`
|
|
86
|
+
- **Respects `--silent`** - Honors npm's silent flag for automation
|
|
87
|
+
|
|
88
|
+
### 5. Progress Indicators
|
|
89
|
+
|
|
90
|
+
- **Real-time feedback** - `sync` command shows progress during execution
|
|
91
|
+
- **Execution timing** - See how long operations take
|
|
92
|
+
- **Enhanced summaries** - Rich metadata about cache state and recommendations
|
|
93
|
+
|
|
94
|
+
### 6. Security Improvements
|
|
95
|
+
|
|
96
|
+
- **0 production vulnerabilities** - Fixed all 16 security issues
|
|
97
|
+
- **Removed vulnerable dependency** - Replaced @tryfabric/martian with custom markdown converter
|
|
98
|
+
- **Zero-dependency parser** - No external security risks from markdown processing
|
|
99
|
+
- **CVE fixes** - Addressed XSS, prototype pollution, and ReDoS vulnerabilities
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 🚀 Performance Optimizations (v5.9.0)
|
|
104
|
+
|
|
105
|
+
**5-Phase Performance Enhancement** delivering **1.5-2x overall improvement** for batch operations and repeated data access.
|
|
106
|
+
|
|
107
|
+
### Overview
|
|
108
|
+
|
|
109
|
+
Version 5.9.0 introduces comprehensive performance optimizations across five key areas:
|
|
110
|
+
|
|
111
|
+
| Optimization | Best Case | Typical Case | When It Helps |
|
|
112
|
+
| ------------------------- | ------------------ | ------------------ | -------------------------------- |
|
|
113
|
+
| **Request Deduplication** | 30-50% fewer calls | 5-15% fewer calls | Concurrent duplicate requests |
|
|
114
|
+
| **Parallel Operations** | 80% faster | 60-70% faster | Batch deletions, bulk retrievals |
|
|
115
|
+
| **Persistent Disk Cache** | 60% better hits | 20-30% better hits | Repeated CLI sessions |
|
|
116
|
+
| **HTTP Keep-Alive** | 20% faster | 5-10% faster | Multi-request operations |
|
|
117
|
+
| **Response Compression** | 70% less bandwidth | Varies | Large JSON responses |
|
|
118
|
+
|
|
119
|
+
### Phase 1: Request Deduplication
|
|
120
|
+
|
|
121
|
+
Automatically prevents duplicate concurrent API calls using promise memoization.
|
|
122
|
+
|
|
123
|
+
**How it works:**
|
|
124
|
+
|
|
125
|
+
- Multiple concurrent requests for the same resource share a single API call
|
|
126
|
+
- In-flight request tracking with automatic cleanup
|
|
127
|
+
- Statistics tracking for monitoring effectiveness
|
|
128
|
+
|
|
129
|
+
**When it helps:**
|
|
130
|
+
|
|
131
|
+
- ✅ Parallel execution of commands that fetch the same data
|
|
132
|
+
- ✅ Applications making concurrent duplicate requests
|
|
133
|
+
- ❌ Sequential CLI commands (typical usage)
|
|
134
|
+
|
|
135
|
+
**Configuration:**
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Enable/disable (default: true)
|
|
139
|
+
NOTION_CLI_DEDUP_ENABLED=true
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Example:**
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Without deduplication: 3 API calls
|
|
146
|
+
# With deduplication: 1 API call (3 requests share result)
|
|
147
|
+
notion-cli page:retrieve PAGE_ID &
|
|
148
|
+
notion-cli page:retrieve PAGE_ID &
|
|
149
|
+
notion-cli page:retrieve PAGE_ID &
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Phase 2: Parallel Operations
|
|
153
|
+
|
|
154
|
+
Executes bulk operations concurrently with configurable concurrency limits.
|
|
155
|
+
|
|
156
|
+
**How it works:**
|
|
157
|
+
|
|
158
|
+
- Block deletions run in parallel (default: 5 concurrent)
|
|
159
|
+
- Child block fetching runs in parallel (default: 10 concurrent)
|
|
160
|
+
- Batch processing with retry logic and error handling
|
|
161
|
+
- Respects Notion API rate limits (3 req/sec per integration)
|
|
162
|
+
|
|
163
|
+
**When it helps:**
|
|
164
|
+
|
|
165
|
+
- ✅ `page:update` with many existing blocks
|
|
166
|
+
- ✅ Recursive page retrieval with many children
|
|
167
|
+
- ✅ Batch operations on multiple resources
|
|
168
|
+
- ❌ Single block operations
|
|
169
|
+
|
|
170
|
+
**Configuration:**
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Block deletion concurrency (default: 5)
|
|
174
|
+
NOTION_CLI_DELETE_CONCURRENCY=5
|
|
175
|
+
|
|
176
|
+
# Child fetching concurrency (default: 10)
|
|
177
|
+
NOTION_CLI_CHILDREN_CONCURRENCY=10
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Example:**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Sequential: 10 blocks × 100ms = 1000ms
|
|
184
|
+
# Parallel (5 concurrent): ~200ms (5x faster)
|
|
185
|
+
notion-cli page:update PAGE_ID --file content.md
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Performance test results:**
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
✓ Should be significantly faster than sequential execution (607ms)
|
|
192
|
+
Sequential: 500ms | Parallel: ~100ms | Speedup: 5x
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Phase 3: Persistent Disk Cache
|
|
196
|
+
|
|
197
|
+
Maintains cache across CLI invocations for improved hit rates.
|
|
198
|
+
|
|
199
|
+
**How it works:**
|
|
200
|
+
|
|
201
|
+
- Cache stored in `~/.notion-cli/cache/` directory
|
|
202
|
+
- Automatic TTL-based expiration
|
|
203
|
+
- LRU eviction when max size reached (default: 100MB)
|
|
204
|
+
- Atomic writes prevent corruption
|
|
205
|
+
- SHA-256 key hashing for safe filenames
|
|
206
|
+
|
|
207
|
+
**When it helps:**
|
|
208
|
+
|
|
209
|
+
- ✅ Running the same query multiple times
|
|
210
|
+
- ✅ Repeated `db:query` on same database
|
|
211
|
+
- ✅ Schema lookups across sessions
|
|
212
|
+
- ❌ Always-fresh data requirements
|
|
213
|
+
- ❌ Single-use queries
|
|
214
|
+
|
|
215
|
+
**Configuration:**
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Enable/disable (default: true)
|
|
219
|
+
NOTION_CLI_DISK_CACHE_ENABLED=true
|
|
220
|
+
|
|
221
|
+
# Max cache size in bytes (default: 100MB)
|
|
222
|
+
NOTION_CLI_DISK_CACHE_MAX_SIZE=104857600
|
|
223
|
+
|
|
224
|
+
# Sync interval in ms (default: 5s)
|
|
225
|
+
NOTION_CLI_DISK_CACHE_SYNC_INTERVAL=5000
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Example:**
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# First run: API call + disk write
|
|
232
|
+
notion-cli db:query DB_ID # 250ms
|
|
233
|
+
|
|
234
|
+
# Subsequent runs: Disk cache hit
|
|
235
|
+
notion-cli db:query DB_ID # 50ms (5x faster)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Phase 4: HTTP Keep-Alive & Connection Pooling
|
|
239
|
+
|
|
240
|
+
Reuses HTTPS connections to eliminate TLS handshake overhead.
|
|
241
|
+
|
|
242
|
+
**How it works:**
|
|
243
|
+
|
|
244
|
+
- Connection pool with configurable size (default: 10 free sockets)
|
|
245
|
+
- Keep-alive timeout: 60 seconds
|
|
246
|
+
- Max concurrent connections: 50
|
|
247
|
+
- Automatic cleanup on command exit
|
|
248
|
+
|
|
249
|
+
**When it helps:**
|
|
250
|
+
|
|
251
|
+
- ✅ Multi-request operations (e.g., batch queries)
|
|
252
|
+
- ✅ Long-running scripts
|
|
253
|
+
- ✅ Repeated API calls in quick succession
|
|
254
|
+
- ❌ Single request per session
|
|
255
|
+
- ⚠️ **Note**: Effectiveness depends on Notion SDK's HTTP client implementation
|
|
256
|
+
|
|
257
|
+
**Configuration:**
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Enable/disable (default: true)
|
|
261
|
+
NOTION_CLI_HTTP_KEEP_ALIVE=true
|
|
262
|
+
|
|
263
|
+
# Keep-alive timeout in ms (default: 60s)
|
|
264
|
+
NOTION_CLI_HTTP_KEEP_ALIVE_MS=60000
|
|
265
|
+
|
|
266
|
+
# Max concurrent connections (default: 50)
|
|
267
|
+
NOTION_CLI_HTTP_MAX_SOCKETS=50
|
|
268
|
+
|
|
269
|
+
# Connection pool size (default: 10)
|
|
270
|
+
NOTION_CLI_HTTP_MAX_FREE_SOCKETS=10
|
|
271
|
+
|
|
272
|
+
# Request timeout in ms (default: 30s)
|
|
273
|
+
NOTION_CLI_HTTP_TIMEOUT=30000
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Performance impact:**
|
|
277
|
+
|
|
278
|
+
- TLS handshake typically adds 50-100ms per connection
|
|
279
|
+
- With keep-alive: 1 handshake for multiple requests
|
|
280
|
+
- Savings: 5-10% typical, 10-20% best case
|
|
281
|
+
|
|
282
|
+
### Phase 5: Response Compression
|
|
283
|
+
|
|
284
|
+
Enables gzip, deflate, and brotli compression for API responses.
|
|
285
|
+
|
|
286
|
+
**How it works:**
|
|
287
|
+
|
|
288
|
+
- Adds `Accept-Encoding: gzip, deflate, br` header to requests
|
|
289
|
+
- Server decides whether to compress responses
|
|
290
|
+
- Client automatically decompresses (transparent)
|
|
291
|
+
|
|
292
|
+
**When it helps:**
|
|
293
|
+
|
|
294
|
+
- ✅ Large JSON responses (>10KB)
|
|
295
|
+
- ✅ Slow network connections
|
|
296
|
+
- ✅ Bandwidth-constrained environments
|
|
297
|
+
- ❌ Small responses (<1KB)
|
|
298
|
+
- ⚠️ **Note**: Notion API may already compress responses by default
|
|
299
|
+
|
|
300
|
+
**Configuration:**
|
|
301
|
+
|
|
302
|
+
- Always enabled, no configuration needed
|
|
303
|
+
|
|
304
|
+
**Compression ratios:**
|
|
305
|
+
|
|
306
|
+
- JSON typically compresses 60-70%
|
|
307
|
+
- Actual performance impact varies (likely already compressed)
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
### Combined Performance Impact
|
|
312
|
+
|
|
313
|
+
**Real-world scenarios:**
|
|
314
|
+
|
|
315
|
+
**Scenario 1: Batch Operations**
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
# Update 5 pages in parallel with cached schemas
|
|
319
|
+
# Expected improvement: 2-2.5x faster
|
|
320
|
+
notion-cli batch:update --input pages.json
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**Scenario 2: Repeated Queries**
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Run same query multiple times
|
|
327
|
+
# First run: 300ms | Subsequent runs: 50ms (6x faster via disk cache)
|
|
328
|
+
notion-cli db:query DB_ID --filter '{"status": "active"}'
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Scenario 3: Typical CLI Usage**
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# Sequential commands on unique data
|
|
335
|
+
# Expected improvement: 1.2-1.5x (disk cache + compression)
|
|
336
|
+
notion-cli page:retrieve PAGE_ID
|
|
337
|
+
notion-cli db:query DB_ID
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Configuration Best Practices
|
|
341
|
+
|
|
342
|
+
**Development (fast iteration):**
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
NOTION_CLI_CACHE_TTL=30000 # 30s cache
|
|
346
|
+
NOTION_CLI_DISK_CACHE_ENABLED=true # Keep disk cache
|
|
347
|
+
NOTION_CLI_DELETE_CONCURRENCY=3 # Conservative
|
|
348
|
+
DEBUG=true # See optimization activity
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Production (balanced performance):**
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
NOTION_CLI_CACHE_TTL=300000 # 5min cache
|
|
355
|
+
NOTION_CLI_DISK_CACHE_MAX_SIZE=104857600 # 100MB
|
|
356
|
+
NOTION_CLI_DELETE_CONCURRENCY=5 # Default
|
|
357
|
+
NOTION_CLI_CHILDREN_CONCURRENCY=10 # Default
|
|
358
|
+
NOTION_CLI_HTTP_KEEP_ALIVE=true # Enabled
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Batch Processing (maximum throughput):**
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
NOTION_CLI_DELETE_CONCURRENCY=10 # Higher concurrency
|
|
365
|
+
NOTION_CLI_CHILDREN_CONCURRENCY=20 # Higher concurrency
|
|
366
|
+
NOTION_CLI_HTTP_MAX_SOCKETS=50 # More connections
|
|
367
|
+
NOTION_CLI_DISK_CACHE_ENABLED=true # Cache results
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Memory-Constrained (minimal footprint):**
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
NOTION_CLI_CACHE_MAX_SIZE=100 # Small memory cache
|
|
374
|
+
NOTION_CLI_DISK_CACHE_MAX_SIZE=10485760 # 10MB disk cache
|
|
375
|
+
NOTION_CLI_HTTP_MAX_FREE_SOCKETS=2 # Fewer pooled connections
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Monitoring Performance
|
|
379
|
+
|
|
380
|
+
**Check optimization statistics:**
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# View cache statistics
|
|
384
|
+
notion-cli doctor --json | jq '.checks[] | select(.name | contains("cache"))'
|
|
385
|
+
|
|
386
|
+
# Enable verbose logging to see:
|
|
387
|
+
# - Cache hits/misses
|
|
388
|
+
# - Deduplication hits
|
|
389
|
+
# - Disk cache activity
|
|
390
|
+
DEBUG=true notion-cli db:query DB_ID
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Expected verbose output:**
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
Cache MISS: dataSource:abc123
|
|
397
|
+
Dedup MISS: dataSource:abc123
|
|
398
|
+
[API Call] GET /v1/databases/abc123
|
|
399
|
+
Cache SET: dataSource:abc123 (TTL: 600000ms)
|
|
400
|
+
Disk cache WRITE: dataSource:abc123
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Performance Testing
|
|
404
|
+
|
|
405
|
+
All optimizations are thoroughly tested with 121 comprehensive tests:
|
|
406
|
+
|
|
407
|
+
- ✅ 22 deduplication tests (94.73% coverage)
|
|
408
|
+
- ✅ 21 parallel operations tests (timing benchmarks included)
|
|
409
|
+
- ✅ 34 disk cache tests (83.59% coverage)
|
|
410
|
+
- ✅ 26 HTTP agent tests (78.94% coverage)
|
|
411
|
+
- ✅ 18 compression tests
|
|
412
|
+
|
|
413
|
+
See [CHANGELOG.md](./CHANGELOG.md) for detailed implementation notes and [test directory](./test) for test suites.
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
### Earlier Features (v5.4.0)
|
|
418
|
+
|
|
419
|
+
**7 Major AI Agent Usability Features** (Issue #4)
|
|
420
|
+
|
|
421
|
+
### 1. Simple Properties Mode
|
|
422
|
+
|
|
423
|
+
- **NEW `--simple-properties` (`-S`) flag** - Use flat JSON instead of complex nested structures
|
|
424
|
+
- **70% complexity reduction** - `{"Name": "Task", "Status": "Done"}` vs verbose Notion format
|
|
425
|
+
- **13 property types supported** - title, rich_text, number, checkbox, select, multi_select, status, date, url, email, phone, people, files, relation
|
|
426
|
+
- **Case-insensitive matching** - Property names and select values work regardless of case
|
|
427
|
+
- **Relative dates** - Use `"today"`, `"tomorrow"`, `"+7 days"`, `"+2 weeks"`, etc.
|
|
428
|
+
- **Smart validation** - Helpful error messages with suggestions
|
|
429
|
+
|
|
430
|
+
[📖 Simple Properties Guide](./docs/SIMPLE_PROPERTIES.md) | [⚡ Quick Reference](./AI_AGENT_QUICK_REFERENCE.md)
|
|
431
|
+
|
|
432
|
+
### 2. JSON Envelope Standardization
|
|
433
|
+
|
|
434
|
+
- **Consistent response format** - All commands return `{success, data, metadata}`
|
|
435
|
+
- **Standardized exit codes** - 0 = success, 1 = API error, 2 = CLI error
|
|
436
|
+
- **Predictable parsing** - AI agents can reliably extract data
|
|
437
|
+
|
|
438
|
+
[📖 Envelope Documentation](./docs/ENVELOPE_INDEX.md)
|
|
439
|
+
|
|
440
|
+
### 3. Health Check Command
|
|
441
|
+
|
|
442
|
+
- **NEW `whoami` command** - Verify connectivity before operations (aliases: `test`, `health`)
|
|
443
|
+
- **Reports** - Bot info, workspace access, cache status, API latency
|
|
444
|
+
- **Error diagnostics** - Comprehensive troubleshooting suggestions
|
|
445
|
+
|
|
446
|
+
### 4. Schema Examples
|
|
447
|
+
|
|
448
|
+
- **NEW `--with-examples` flag** - Get copy-pastable property payloads
|
|
449
|
+
- **Works with `db schema`** - Shows example values for each property type
|
|
450
|
+
- **Groups properties** - Separates writable vs read-only
|
|
451
|
+
|
|
452
|
+
### 5. Verbose Logging
|
|
453
|
+
|
|
454
|
+
- **NEW `--verbose` (`-v`) flag** - Debug mode for troubleshooting
|
|
455
|
+
- **Shows** - Cache hits/misses, retry attempts, API latency
|
|
456
|
+
- **Helps AI agents** - Understand what's happening behind the scenes
|
|
457
|
+
|
|
458
|
+
[📖 Verbose Logging Guide](./docs/VERBOSE_LOGGING.md)
|
|
459
|
+
|
|
460
|
+
### 6. Filter Simplification
|
|
461
|
+
|
|
462
|
+
- **Improved filter syntax** - Easier database query filters
|
|
463
|
+
- **Better validation** - Clear error messages for invalid filters
|
|
464
|
+
|
|
465
|
+
[📖 Filter Guide](./docs/FILTER_GUIDE.md)
|
|
466
|
+
|
|
467
|
+
### 7. Output Format Enhancements
|
|
468
|
+
|
|
469
|
+
- **NEW `--compact-json`** - Minified single-line JSON output
|
|
470
|
+
- **NEW `--pretty`** - Enhanced table formatting
|
|
471
|
+
- **NEW `--markdown`** - Markdown table output
|
|
472
|
+
|
|
473
|
+
[📊 Output Formats Guide](./OUTPUT_FORMATS.md)
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
### Earlier Features (v5.2-5.3)
|
|
478
|
+
|
|
479
|
+
**Smart ID Resolution** - Automatic `database_id` ↔ `data_source_id` conversion • [Guide](./docs/smart-id-resolution.md)
|
|
480
|
+
|
|
481
|
+
**Workspace Caching** - `sync` and `list` commands for local database cache
|
|
482
|
+
|
|
483
|
+
**Schema Discovery** - `db schema` command for AI-parseable schemas • [AI Agent Cookbook](./docs/AI-AGENT-COOKBOOK.md)
|
|
484
|
+
|
|
485
|
+
**Enhanced Reliability** - Exponential backoff retry + circuit breaker • [Details](./ENHANCEMENTS.md)
|
|
486
|
+
|
|
487
|
+
**Performance** - In-memory caching (up to 100x faster for repeated reads)
|
|
488
|
+
|
|
489
|
+
## Quick Start
|
|
490
|
+
|
|
491
|
+
### Installation
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
# From npm (recommended)
|
|
495
|
+
npm install -g @infograb/notion-cli
|
|
496
|
+
|
|
497
|
+
# Or from source
|
|
498
|
+
npm install -g infograb/notion-cli
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**Note**: Windows users installing from source should use the local clone method due to symlink limitations:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
git clone https://github.com/infograb/notion-cli
|
|
505
|
+
cd notion-cli
|
|
506
|
+
npm install
|
|
507
|
+
npm run build
|
|
508
|
+
npm link
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Updating
|
|
512
|
+
|
|
513
|
+
To update to the latest version:
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
# Update to latest version
|
|
517
|
+
npm update -g @infograb/notion-cli
|
|
518
|
+
|
|
519
|
+
# Or reinstall for a specific version
|
|
520
|
+
npm install -g @infograb/notion-cli@latest
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
Check your current version:
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
notion-cli --version
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
**Update Notifications:**
|
|
530
|
+
|
|
531
|
+
- The CLI automatically checks for updates once per day
|
|
532
|
+
- You'll see a notification when a new version is available
|
|
533
|
+
- Updates are never applied automatically - you stay in control
|
|
534
|
+
- To disable notifications: `export NO_UPDATE_NOTIFIER=1`
|
|
535
|
+
|
|
536
|
+
Check for new releases at:
|
|
537
|
+
|
|
538
|
+
- [npm package page](https://www.npmjs.com/package/@infograb/notion-cli)
|
|
539
|
+
- [GitHub releases](https://github.com/infograb/notion-cli/releases)
|
|
540
|
+
|
|
541
|
+
### First-Time Setup
|
|
542
|
+
|
|
543
|
+
The easiest way to get started:
|
|
544
|
+
|
|
545
|
+
```bash
|
|
546
|
+
# Run the interactive setup wizard
|
|
547
|
+
notion-cli init
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
This will guide you through:
|
|
551
|
+
|
|
552
|
+
1. 🔑 Setting your Notion API token
|
|
553
|
+
2. ✅ Testing the connection
|
|
554
|
+
3. 🔄 Syncing your workspace
|
|
555
|
+
|
|
556
|
+
**Manual Configuration (Optional):**
|
|
557
|
+
|
|
558
|
+
If you prefer to set up manually:
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
# Set your token
|
|
562
|
+
export NOTION_TOKEN="secret_your_token_here"
|
|
563
|
+
|
|
564
|
+
# Test the connection
|
|
565
|
+
notion-cli whoami
|
|
566
|
+
|
|
567
|
+
# Sync your workspace
|
|
568
|
+
notion-cli sync
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### Common Commands
|
|
572
|
+
|
|
573
|
+
**List your databases:**
|
|
574
|
+
|
|
575
|
+
```bash
|
|
576
|
+
notion-cli list --json
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
**Discover database schema:**
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# Get schema with examples for easy copy-paste
|
|
583
|
+
notion-cli db schema <DATA_SOURCE_ID> --with-examples --json
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**Create a page** (using simple properties):
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
notion-cli page create -d <DATA_SOURCE_ID> -S --properties '{
|
|
590
|
+
"Name": "My Task",
|
|
591
|
+
"Status": "In Progress",
|
|
592
|
+
"Priority": 5,
|
|
593
|
+
"Due Date": "tomorrow"
|
|
594
|
+
}'
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
**All commands support** `--json` for machine-readable responses.
|
|
598
|
+
|
|
599
|
+
**Get your API token**: https://developers.notion.com/docs/create-a-notion-integration
|
|
600
|
+
|
|
601
|
+
## Key Features for AI Agents
|
|
602
|
+
|
|
603
|
+
### Simple Properties - 70% Less Complexity
|
|
604
|
+
|
|
605
|
+
Create and update Notion pages with flat JSON instead of complex nested structures:
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
# ❌ OLD WAY: Complex nested structure (error-prone)
|
|
609
|
+
notion-cli page create -d DB_ID --properties '{
|
|
610
|
+
"Name": {
|
|
611
|
+
"title": [{"text": {"content": "Task"}}]
|
|
612
|
+
},
|
|
613
|
+
"Status": {
|
|
614
|
+
"select": {"name": "In Progress"}
|
|
615
|
+
},
|
|
616
|
+
"Priority": {
|
|
617
|
+
"number": 5
|
|
618
|
+
},
|
|
619
|
+
"Tags": {
|
|
620
|
+
"multi_select": [
|
|
621
|
+
{"name": "urgent"},
|
|
622
|
+
{"name": "bug"}
|
|
623
|
+
]
|
|
624
|
+
}
|
|
625
|
+
}'
|
|
626
|
+
|
|
627
|
+
# ✅ NEW WAY: Simple properties with -S flag
|
|
628
|
+
notion-cli page create -d DB_ID -S --properties '{
|
|
629
|
+
"Name": "Task",
|
|
630
|
+
"Status": "In Progress",
|
|
631
|
+
"Priority": 5,
|
|
632
|
+
"Tags": ["urgent", "bug"],
|
|
633
|
+
"Due Date": "tomorrow"
|
|
634
|
+
}'
|
|
635
|
+
|
|
636
|
+
# Update is just as easy
|
|
637
|
+
notion-cli page update PAGE_ID -S --properties '{
|
|
638
|
+
"Status": "Done",
|
|
639
|
+
"Completed": true
|
|
640
|
+
}'
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
**Features:**
|
|
644
|
+
|
|
645
|
+
- 🔤 **Case-insensitive** - Property names and select values work regardless of case
|
|
646
|
+
- 📅 **Relative dates** - Use `"today"`, `"tomorrow"`, `"+7 days"`, `"+2 weeks"`
|
|
647
|
+
- ✅ **Smart validation** - Clear error messages with valid options listed
|
|
648
|
+
- 🎯 **13 property types** - title, rich_text, number, checkbox, select, multi_select, status, date, url, email, phone, people, files, relation
|
|
649
|
+
|
|
650
|
+
[📖 Simple Properties Guide](./docs/SIMPLE_PROPERTIES.md) | [⚡ Quick Reference](./AI_AGENT_QUICK_REFERENCE.md)
|
|
651
|
+
|
|
652
|
+
### Smart Database ID Resolution
|
|
653
|
+
|
|
654
|
+
No need to worry about `database_id` vs `data_source_id` confusion anymore! The CLI automatically detects and converts between them:
|
|
655
|
+
|
|
656
|
+
```bash
|
|
657
|
+
# Both work! Use whichever ID you have
|
|
658
|
+
notion-cli db retrieve 1fb79d4c71bb8032b722c82305b63a00 # database_id
|
|
659
|
+
notion-cli db retrieve 2gc80e5d82cc9043c833d93416c74b11 # data_source_id
|
|
660
|
+
|
|
661
|
+
# When conversion happens, you'll see:
|
|
662
|
+
# Info: Resolved database_id to data_source_id
|
|
663
|
+
# database_id: 1fb79d4c71bb8032b722c82305b63a00
|
|
664
|
+
# data_source_id: 2gc80e5d82cc9043c833d93416c74b11
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
[📖 Learn more about Smart ID Resolution](./docs/smart-id-resolution.md)
|
|
668
|
+
|
|
669
|
+
### JSON Mode - Perfect for AI Processing
|
|
670
|
+
|
|
671
|
+
Every command supports `--json` for structured, parseable output:
|
|
672
|
+
|
|
673
|
+
```bash
|
|
674
|
+
# Get structured data
|
|
675
|
+
notion-cli db query <ID> --json | jq '.data.results[].properties'
|
|
676
|
+
|
|
677
|
+
# Error responses are also JSON
|
|
678
|
+
notion-cli db retrieve invalid-id --json
|
|
679
|
+
# {
|
|
680
|
+
# "success": false,
|
|
681
|
+
# "error": {
|
|
682
|
+
# "code": "NOT_FOUND",
|
|
683
|
+
# "message": "Database not found"
|
|
684
|
+
# }
|
|
685
|
+
# }
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
### Schema Discovery - Know Your Data Structure
|
|
689
|
+
|
|
690
|
+
Extract complete database schemas in AI-friendly formats:
|
|
691
|
+
|
|
692
|
+
```bash
|
|
693
|
+
# Get full schema
|
|
694
|
+
notion-cli db schema <DATA_SOURCE_ID> --json
|
|
695
|
+
|
|
696
|
+
# Output:
|
|
697
|
+
# {
|
|
698
|
+
# "database_id": "...",
|
|
699
|
+
# "title": "Tasks",
|
|
700
|
+
# "properties": {
|
|
701
|
+
# "Name": { "type": "title", "required": true },
|
|
702
|
+
# "Status": {
|
|
703
|
+
# "type": "select",
|
|
704
|
+
# "options": ["Not Started", "In Progress", "Done"]
|
|
705
|
+
# }
|
|
706
|
+
# }
|
|
707
|
+
# }
|
|
708
|
+
|
|
709
|
+
# Filter to specific properties
|
|
710
|
+
notion-cli db schema <ID> --properties Status,Priority --yaml
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
### Workspace Caching - Zero API Calls for Lookups
|
|
714
|
+
|
|
715
|
+
Cache your entire workspace locally for instant database lookups:
|
|
716
|
+
|
|
717
|
+
```bash
|
|
718
|
+
# One-time sync
|
|
719
|
+
notion-cli sync
|
|
720
|
+
|
|
721
|
+
# Now use database names instead of IDs
|
|
722
|
+
notion-cli db query "Tasks Database" --json
|
|
723
|
+
|
|
724
|
+
# Browse all cached databases
|
|
725
|
+
notion-cli list --json
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
### Cache Management - AI-Friendly Metadata
|
|
729
|
+
|
|
730
|
+
AI agents need to know when data is fresh. Get machine-readable cache metadata:
|
|
731
|
+
|
|
732
|
+
```bash
|
|
733
|
+
# Check cache status and TTLs
|
|
734
|
+
notion-cli cache:info --json
|
|
735
|
+
|
|
736
|
+
# Sample output:
|
|
737
|
+
# {
|
|
738
|
+
# "success": true,
|
|
739
|
+
# "data": {
|
|
740
|
+
# "in_memory": {
|
|
741
|
+
# "enabled": true,
|
|
742
|
+
# "stats": { "hits": 42, "misses": 8, "hit_rate": 84.0 },
|
|
743
|
+
# "ttls_ms": {
|
|
744
|
+
# "data_source": 600000, // 10 minutes
|
|
745
|
+
# "page": 60000, // 1 minute
|
|
746
|
+
# "user": 3600000, // 1 hour
|
|
747
|
+
# "block": 30000 // 30 seconds
|
|
748
|
+
# }
|
|
749
|
+
# },
|
|
750
|
+
# "workspace": {
|
|
751
|
+
# "last_sync": "2025-10-23T14:30:00.000Z",
|
|
752
|
+
# "cache_age_hours": 2.5,
|
|
753
|
+
# "is_stale": false,
|
|
754
|
+
# "databases_cached": 15
|
|
755
|
+
# },
|
|
756
|
+
# "recommendations": {
|
|
757
|
+
# "sync_interval_hours": 24,
|
|
758
|
+
# "next_sync": "2025-10-24T14:30:00.000Z",
|
|
759
|
+
# "action_needed": "Cache is fresh"
|
|
760
|
+
# }
|
|
761
|
+
# }
|
|
762
|
+
# }
|
|
763
|
+
|
|
764
|
+
# List databases with cache age metadata
|
|
765
|
+
notion-cli list --json
|
|
766
|
+
|
|
767
|
+
# Sync with comprehensive metadata
|
|
768
|
+
notion-cli sync --json
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
**Cache TTLs:**
|
|
772
|
+
|
|
773
|
+
- **Workspace cache**: Persists until next `sync` (recommended: every 24 hours)
|
|
774
|
+
- **In-memory cache**:
|
|
775
|
+
- Data sources: 10 minutes (schemas rarely change)
|
|
776
|
+
- Pages: 1 minute (frequently updated)
|
|
777
|
+
- Users: 1 hour (very stable)
|
|
778
|
+
- Blocks: 30 seconds (most dynamic)
|
|
779
|
+
|
|
780
|
+
**AI Agent Best Practices:**
|
|
781
|
+
|
|
782
|
+
1. Run `cache:info --json` to check freshness before bulk operations
|
|
783
|
+
2. Parse `is_stale` flag to decide whether to re-sync
|
|
784
|
+
3. Use `cache_age_hours` for smart caching decisions
|
|
785
|
+
4. Respect TTL metadata when planning repeated reads
|
|
786
|
+
|
|
787
|
+
### Exit Codes - Script-Friendly
|
|
788
|
+
|
|
789
|
+
```bash
|
|
790
|
+
notion-cli db retrieve <ID> --json
|
|
791
|
+
if [ $? -eq 0 ]; then
|
|
792
|
+
echo "Success!"
|
|
793
|
+
else
|
|
794
|
+
echo "Failed!"
|
|
795
|
+
fi
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
- `0` = Success
|
|
799
|
+
- `1` = Notion API error
|
|
800
|
+
- `2` = CLI error (invalid flags, etc.)
|
|
801
|
+
|
|
802
|
+
## Core Commands
|
|
803
|
+
|
|
804
|
+
### Setup & Diagnostics
|
|
805
|
+
|
|
806
|
+
```bash
|
|
807
|
+
# First-time setup wizard
|
|
808
|
+
notion-cli init
|
|
809
|
+
|
|
810
|
+
# Health check and diagnostics
|
|
811
|
+
notion-cli doctor
|
|
812
|
+
|
|
813
|
+
# Test connectivity
|
|
814
|
+
notion-cli whoami
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
### Database Commands
|
|
818
|
+
|
|
819
|
+
```bash
|
|
820
|
+
# Retrieve database metadata (works with any ID type!)
|
|
821
|
+
notion-cli db retrieve <DATABASE_ID>
|
|
822
|
+
notion-cli db retrieve <DATA_SOURCE_ID>
|
|
823
|
+
notion-cli db retrieve "Tasks"
|
|
824
|
+
|
|
825
|
+
# Query database with filters
|
|
826
|
+
notion-cli db query <ID> --json
|
|
827
|
+
|
|
828
|
+
# Update database properties
|
|
829
|
+
notion-cli db update <ID> --title "New Title"
|
|
830
|
+
|
|
831
|
+
# Create new database
|
|
832
|
+
notion-cli db create \
|
|
833
|
+
--parent-page <PAGE_ID> \
|
|
834
|
+
--title "My Database" \
|
|
835
|
+
--properties '{"Name": {"type": "title"}}'
|
|
836
|
+
|
|
837
|
+
# Extract schema
|
|
838
|
+
notion-cli db schema <ID> --json
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
### Page Commands
|
|
842
|
+
|
|
843
|
+
```bash
|
|
844
|
+
# Create page in database
|
|
845
|
+
notion-cli page create \
|
|
846
|
+
--database-id <ID> \
|
|
847
|
+
--properties '{"Name": {"title": [{"text": {"content": "Task"}}]}}'
|
|
848
|
+
|
|
849
|
+
# Retrieve page
|
|
850
|
+
notion-cli page retrieve <PAGE_ID> --json
|
|
851
|
+
|
|
852
|
+
# Update page properties
|
|
853
|
+
notion-cli page update <PAGE_ID> \
|
|
854
|
+
--properties '{"Status": {"select": {"name": "Done"}}}'
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
### Block Commands
|
|
858
|
+
|
|
859
|
+
```bash
|
|
860
|
+
# Retrieve block
|
|
861
|
+
notion-cli block retrieve <BLOCK_ID>
|
|
862
|
+
|
|
863
|
+
# Append children to block
|
|
864
|
+
notion-cli block append <BLOCK_ID> \
|
|
865
|
+
--children '[{"object": "block", "type": "paragraph", ...}]'
|
|
866
|
+
|
|
867
|
+
# Update block
|
|
868
|
+
notion-cli block update <BLOCK_ID> --content "Updated text"
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
### User Commands
|
|
872
|
+
|
|
873
|
+
```bash
|
|
874
|
+
# List all users
|
|
875
|
+
notion-cli user list --json
|
|
876
|
+
|
|
877
|
+
# Retrieve user
|
|
878
|
+
notion-cli user retrieve <USER_ID>
|
|
879
|
+
|
|
880
|
+
# Get bot user info
|
|
881
|
+
notion-cli user retrieve bot
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
### Search Command
|
|
885
|
+
|
|
886
|
+
```bash
|
|
887
|
+
# Search workspace
|
|
888
|
+
notion-cli search "project" --json
|
|
889
|
+
|
|
890
|
+
# Search with filters
|
|
891
|
+
notion-cli search "docs" --filter page
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
### Workspace Commands
|
|
895
|
+
|
|
896
|
+
```bash
|
|
897
|
+
# Sync workspace (cache all databases)
|
|
898
|
+
notion-cli sync
|
|
899
|
+
|
|
900
|
+
# List cached databases
|
|
901
|
+
notion-cli list --json
|
|
902
|
+
|
|
903
|
+
# Check cache status
|
|
904
|
+
notion-cli cache:info --json
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
# Configure token
|
|
908
|
+
notion-cli config set-token
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
## Database Query Filtering
|
|
912
|
+
|
|
913
|
+
Filter database queries with three powerful options optimized for AI agents and automation:
|
|
914
|
+
|
|
915
|
+
### JSON Filter (Primary Method - Recommended for AI)
|
|
916
|
+
|
|
917
|
+
Use `--filter` with JSON objects matching Notion's filter API format:
|
|
918
|
+
|
|
919
|
+
```bash
|
|
920
|
+
# Filter by select property
|
|
921
|
+
notion-cli db query <ID> \
|
|
922
|
+
--filter '{"property": "Status", "select": {"equals": "Done"}}' \
|
|
923
|
+
--json
|
|
924
|
+
|
|
925
|
+
# Complex AND filter
|
|
926
|
+
notion-cli db query <ID> \
|
|
927
|
+
--filter '{"and": [{"property": "Status", "select": {"equals": "Done"}}, {"property": "Priority", "number": {"greater_than": 5}}]}' \
|
|
928
|
+
--json
|
|
929
|
+
|
|
930
|
+
# OR filter for multiple conditions
|
|
931
|
+
notion-cli db query <ID> \
|
|
932
|
+
--filter '{"or": [{"property": "Tags", "multi_select": {"contains": "urgent"}}, {"property": "Tags", "multi_select": {"contains": "bug"}}]}' \
|
|
933
|
+
--json
|
|
934
|
+
|
|
935
|
+
# Date filter
|
|
936
|
+
notion-cli db query <ID> \
|
|
937
|
+
--filter '{"property": "Due Date", "date": {"on_or_before": "2025-12-31"}}' \
|
|
938
|
+
--json
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
### Text Search (Human Convenience)
|
|
942
|
+
|
|
943
|
+
Use `--search` for simple text matching across common properties:
|
|
944
|
+
|
|
945
|
+
```bash
|
|
946
|
+
# Quick text search (searches Name, Title, Description)
|
|
947
|
+
notion-cli db query <ID> --search "urgent" --json
|
|
948
|
+
|
|
949
|
+
# Case-sensitive matching
|
|
950
|
+
notion-cli db query <ID> --search "Project Alpha" --json
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
### File Filter (Complex Queries)
|
|
954
|
+
|
|
955
|
+
Use `--file-filter` to load complex filters from JSON files:
|
|
956
|
+
|
|
957
|
+
```bash
|
|
958
|
+
# Create filter file
|
|
959
|
+
cat > high-priority-filter.json << 'EOF'
|
|
960
|
+
{
|
|
961
|
+
"and": [
|
|
962
|
+
{"property": "Status", "select": {"equals": "In Progress"}},
|
|
963
|
+
{"property": "Priority", "number": {"greater_than_or_equal_to": 8}},
|
|
964
|
+
{"property": "Assigned To", "people": {"is_not_empty": true}}
|
|
965
|
+
]
|
|
966
|
+
}
|
|
967
|
+
EOF
|
|
968
|
+
|
|
969
|
+
# Use filter file
|
|
970
|
+
notion-cli db query <ID> --file-filter ./high-priority-filter.json --json
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
### Common Filter Examples
|
|
974
|
+
|
|
975
|
+
**Find completed high-priority tasks:**
|
|
976
|
+
|
|
977
|
+
```bash
|
|
978
|
+
notion-cli db query <ID> \
|
|
979
|
+
--filter '{"and": [{"property": "Status", "select": {"equals": "Done"}}, {"property": "Priority", "number": {"greater_than": 7}}]}' \
|
|
980
|
+
--json
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
**Find items due this week:**
|
|
984
|
+
|
|
985
|
+
```bash
|
|
986
|
+
notion-cli db query <ID> \
|
|
987
|
+
--filter '{"property": "Due Date", "date": {"next_week": {}}}' \
|
|
988
|
+
--json
|
|
989
|
+
```
|
|
990
|
+
|
|
991
|
+
**Find unassigned tasks:**
|
|
992
|
+
|
|
993
|
+
```bash
|
|
994
|
+
notion-cli db query <ID> \
|
|
995
|
+
--filter '{"property": "Assigned To", "people": {"is_empty": true}}' \
|
|
996
|
+
--json
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
**Find items without attachments:**
|
|
1000
|
+
|
|
1001
|
+
```bash
|
|
1002
|
+
notion-cli db query <ID> \
|
|
1003
|
+
--filter '{"property": "Attachments", "files": {"is_empty": true}}' \
|
|
1004
|
+
--json
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
[📖 Full Filter Guide with Examples](./docs/FILTER_GUIDE.md)
|
|
1008
|
+
|
|
1009
|
+
## Output Formats
|
|
1010
|
+
|
|
1011
|
+
All commands support multiple output formats:
|
|
1012
|
+
|
|
1013
|
+
```bash
|
|
1014
|
+
# JSON (default for --json flag)
|
|
1015
|
+
notion-cli db query <ID> --json
|
|
1016
|
+
|
|
1017
|
+
# Compact JSON (single-line)
|
|
1018
|
+
notion-cli db query <ID> --compact-json
|
|
1019
|
+
|
|
1020
|
+
# Markdown table
|
|
1021
|
+
notion-cli db query <ID> --markdown
|
|
1022
|
+
|
|
1023
|
+
# Pretty table (with borders)
|
|
1024
|
+
notion-cli db query <ID> --pretty
|
|
1025
|
+
|
|
1026
|
+
# Raw API response
|
|
1027
|
+
notion-cli db query <ID> --raw
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
[📊 Full Output Formats Guide](./OUTPUT_FORMATS.md)
|
|
1031
|
+
|
|
1032
|
+
## Environment Variables
|
|
1033
|
+
|
|
1034
|
+
### Authentication
|
|
1035
|
+
|
|
1036
|
+
```bash
|
|
1037
|
+
NOTION_TOKEN=secret_your_token_here
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
### Retry Configuration
|
|
1041
|
+
|
|
1042
|
+
```bash
|
|
1043
|
+
NOTION_RETRY_MAX_ATTEMPTS=3 # Max retry attempts (default: 3)
|
|
1044
|
+
NOTION_RETRY_INITIAL_DELAY=1000 # Initial delay in ms (default: 1000)
|
|
1045
|
+
NOTION_RETRY_MAX_DELAY=30000 # Max delay in ms (default: 30000)
|
|
1046
|
+
NOTION_RETRY_TIMEOUT=60000 # Request timeout in ms (default: 60000)
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
### Circuit Breaker
|
|
1050
|
+
|
|
1051
|
+
```bash
|
|
1052
|
+
NOTION_CB_FAILURE_THRESHOLD=5 # Failures before opening (default: 5)
|
|
1053
|
+
NOTION_CB_SUCCESS_THRESHOLD=2 # Successes to close (default: 2)
|
|
1054
|
+
NOTION_CB_TIMEOUT=60000 # Reset timeout in ms (default: 60000)
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
### Caching
|
|
1058
|
+
|
|
1059
|
+
```bash
|
|
1060
|
+
NOTION_CACHE_DISABLED=true # Disable all caching
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
### Debug Mode
|
|
1064
|
+
|
|
1065
|
+
```bash
|
|
1066
|
+
DEBUG=notion-cli:* # Enable debug logging
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
### Verbose Logging
|
|
1070
|
+
|
|
1071
|
+
```bash
|
|
1072
|
+
# Enable structured event logging to stderr
|
|
1073
|
+
NOTION_CLI_VERBOSE=true # Logs retry events, cache stats to stderr
|
|
1074
|
+
NOTION_CLI_DEBUG=true # Enables DEBUG + VERBOSE modes
|
|
1075
|
+
```
|
|
1076
|
+
|
|
1077
|
+
**Verbose Mode** provides machine-readable JSON events to stderr for observability:
|
|
1078
|
+
|
|
1079
|
+
- Retry events (rate limits, backoff delays, exhaustion)
|
|
1080
|
+
- Cache events (hits, misses, evictions)
|
|
1081
|
+
- Circuit breaker state changes
|
|
1082
|
+
- Never pollutes stdout JSON output
|
|
1083
|
+
|
|
1084
|
+
```bash
|
|
1085
|
+
# Enable verbose logging for debugging
|
|
1086
|
+
notion-cli db query <ID> --json --verbose 2>debug.log
|
|
1087
|
+
|
|
1088
|
+
# View retry events
|
|
1089
|
+
cat debug.log | jq 'select(.event == "retry")'
|
|
1090
|
+
|
|
1091
|
+
# Monitor rate limiting
|
|
1092
|
+
notion-cli db query <ID> --verbose 2>&1 >/dev/null | jq 'select(.reason == "RATE_LIMITED")'
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
[📖 Full Verbose Logging Guide](./docs/VERBOSE_LOGGING.md)
|
|
1096
|
+
|
|
1097
|
+
## Real-World Examples
|
|
1098
|
+
|
|
1099
|
+
### Automated Task Management
|
|
1100
|
+
|
|
1101
|
+
```bash
|
|
1102
|
+
#!/bin/bash
|
|
1103
|
+
# Create and track a task
|
|
1104
|
+
|
|
1105
|
+
# Create task
|
|
1106
|
+
TASK_ID=$(notion-cli page create \
|
|
1107
|
+
--database-id <TASKS_DB_ID> \
|
|
1108
|
+
--properties '{
|
|
1109
|
+
"Name": {"title": [{"text": {"content": "Review PR"}}]},
|
|
1110
|
+
"Status": {"select": {"name": "In Progress"}}
|
|
1111
|
+
}' \
|
|
1112
|
+
--json | jq -r '.data.id')
|
|
1113
|
+
|
|
1114
|
+
# Do work...
|
|
1115
|
+
echo "Working on task: $TASK_ID"
|
|
1116
|
+
|
|
1117
|
+
# Mark complete
|
|
1118
|
+
notion-cli page update $TASK_ID \
|
|
1119
|
+
--properties '{"Status": {"select": {"name": "Done"}}}' \
|
|
1120
|
+
--json
|
|
1121
|
+
```
|
|
1122
|
+
|
|
1123
|
+
### Database Schema Migration
|
|
1124
|
+
|
|
1125
|
+
```bash
|
|
1126
|
+
#!/bin/bash
|
|
1127
|
+
# Export schema from one database, import to another
|
|
1128
|
+
|
|
1129
|
+
# Extract source schema
|
|
1130
|
+
notion-cli db schema $SOURCE_DB --json > schema.json
|
|
1131
|
+
|
|
1132
|
+
# Parse and create new database
|
|
1133
|
+
notion-cli db create \
|
|
1134
|
+
--parent-page $TARGET_PAGE \
|
|
1135
|
+
--title "Migrated Database" \
|
|
1136
|
+
--properties "$(jq '.properties' schema.json)" \
|
|
1137
|
+
--json
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
### Daily Sync Script
|
|
1141
|
+
|
|
1142
|
+
```bash
|
|
1143
|
+
#!/bin/bash
|
|
1144
|
+
# Sync workspace and generate report
|
|
1145
|
+
|
|
1146
|
+
# Refresh cache
|
|
1147
|
+
notion-cli sync
|
|
1148
|
+
|
|
1149
|
+
# List all databases with stats
|
|
1150
|
+
notion-cli list --json > databases.json
|
|
1151
|
+
|
|
1152
|
+
# Generate markdown report
|
|
1153
|
+
echo "# Database Report - $(date)" > report.md
|
|
1154
|
+
jq -r '.[] | "- **\(.title)** (\(.page_count) pages)"' databases.json >> report.md
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
## Performance Tips
|
|
1158
|
+
|
|
1159
|
+
1. **Use caching**: Run `notion-cli sync` before heavy operations
|
|
1160
|
+
2. **Batch operations**: Combine multiple updates when possible
|
|
1161
|
+
3. **Use --json**: Faster parsing than pretty output
|
|
1162
|
+
4. **Filter early**: Use query filters to reduce data transfer
|
|
1163
|
+
5. **Cache results**: Store query results for repeated access
|
|
1164
|
+
|
|
1165
|
+
## Troubleshooting
|
|
1166
|
+
|
|
1167
|
+
### Setup Issues
|
|
1168
|
+
|
|
1169
|
+
**Problem**: Not sure if everything is configured correctly
|
|
1170
|
+
|
|
1171
|
+
**Solution**: Run the health check command
|
|
1172
|
+
|
|
1173
|
+
```bash
|
|
1174
|
+
notion-cli doctor
|
|
1175
|
+
# Shows 7 diagnostic checks with clear pass/fail indicators
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
### "Database not found" Error
|
|
1179
|
+
|
|
1180
|
+
**Problem**: You're using a `database_id` instead of `data_source_id`
|
|
1181
|
+
|
|
1182
|
+
**Solution**: The CLI now auto-resolves this! But if it fails:
|
|
1183
|
+
|
|
1184
|
+
```bash
|
|
1185
|
+
# Get the correct data_source_id
|
|
1186
|
+
notion-cli page retrieve <PAGE_ID> --raw | jq '.parent.data_source_id'
|
|
1187
|
+
```
|
|
1188
|
+
|
|
1189
|
+
### Rate Limiting
|
|
1190
|
+
|
|
1191
|
+
**Problem**: Getting 429 errors
|
|
1192
|
+
|
|
1193
|
+
**Solution**: The CLI handles this automatically with retry logic. To adjust:
|
|
1194
|
+
|
|
1195
|
+
```bash
|
|
1196
|
+
export NOTION_RETRY_MAX_ATTEMPTS=5
|
|
1197
|
+
export NOTION_RETRY_MAX_DELAY=60000
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
### Slow Queries
|
|
1201
|
+
|
|
1202
|
+
**Problem**: Database queries taking too long
|
|
1203
|
+
|
|
1204
|
+
**Solution**:
|
|
1205
|
+
|
|
1206
|
+
1. Use filters to reduce data: `--filter '{"property": "Status", "select": {"equals": "Active"}}'`
|
|
1207
|
+
2. Enable caching: `notion-cli sync`
|
|
1208
|
+
3. Use `--compact-json` for faster output
|
|
1209
|
+
|
|
1210
|
+
### Authentication Errors
|
|
1211
|
+
|
|
1212
|
+
**Problem**: 401 Unauthorized or token errors
|
|
1213
|
+
|
|
1214
|
+
**Solution**:
|
|
1215
|
+
|
|
1216
|
+
```bash
|
|
1217
|
+
# Run the setup wizard
|
|
1218
|
+
notion-cli init
|
|
1219
|
+
|
|
1220
|
+
# Or verify token is set
|
|
1221
|
+
echo $NOTION_TOKEN
|
|
1222
|
+
|
|
1223
|
+
# Or manually configure token
|
|
1224
|
+
notion-cli config set-token
|
|
1225
|
+
|
|
1226
|
+
# Check integration has access
|
|
1227
|
+
# Visit: https://www.notion.so/my-integrations
|
|
1228
|
+
```
|
|
1229
|
+
|
|
1230
|
+
## Development
|
|
1231
|
+
|
|
1232
|
+
### Prerequisites
|
|
1233
|
+
|
|
1234
|
+
- Node.js >= 22.0.0
|
|
1235
|
+
- npm >= 8.0.0
|
|
1236
|
+
- Git
|
|
1237
|
+
|
|
1238
|
+
### Setup
|
|
1239
|
+
|
|
1240
|
+
```bash
|
|
1241
|
+
# Clone repository
|
|
1242
|
+
git clone https://github.com/infograb/notion-cli
|
|
1243
|
+
cd notion-cli
|
|
1244
|
+
|
|
1245
|
+
# Install dependencies
|
|
1246
|
+
npm install
|
|
1247
|
+
|
|
1248
|
+
# Build TypeScript
|
|
1249
|
+
npm run build
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
### Development Workflow
|
|
1253
|
+
|
|
1254
|
+
```bash
|
|
1255
|
+
# Build the project
|
|
1256
|
+
npm run build
|
|
1257
|
+
|
|
1258
|
+
# Run tests
|
|
1259
|
+
npm test
|
|
1260
|
+
|
|
1261
|
+
# Run linter
|
|
1262
|
+
npm run lint
|
|
1263
|
+
|
|
1264
|
+
# Auto-fix linting issues
|
|
1265
|
+
npm run lint -- --fix
|
|
1266
|
+
|
|
1267
|
+
# Link for local development (test CLI globally)
|
|
1268
|
+
npm link
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
### Project Structure
|
|
1272
|
+
|
|
1273
|
+
```
|
|
1274
|
+
notion-cli/
|
|
1275
|
+
├── src/ # TypeScript source files
|
|
1276
|
+
│ ├── commands/ # CLI command implementations
|
|
1277
|
+
│ ├── utils/ # Utility functions
|
|
1278
|
+
│ ├── base-command.ts # Base command class
|
|
1279
|
+
│ ├── base-flags.ts # Reusable flag definitions
|
|
1280
|
+
│ ├── envelope.ts # JSON envelope formatting
|
|
1281
|
+
│ ├── notion.ts # Notion API client wrapper
|
|
1282
|
+
│ └── cache.ts # In-memory caching layer
|
|
1283
|
+
├── test/ # Test files (mocha + chai)
|
|
1284
|
+
├── dist/ # Compiled JavaScript (generated)
|
|
1285
|
+
├── docs/ # Documentation
|
|
1286
|
+
└── package.json # Project configuration
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
### Testing
|
|
1290
|
+
|
|
1291
|
+
```bash
|
|
1292
|
+
# Run all tests
|
|
1293
|
+
npm test
|
|
1294
|
+
|
|
1295
|
+
# Run tests with verbose output
|
|
1296
|
+
npm test -- --reporter spec
|
|
1297
|
+
|
|
1298
|
+
# Run specific test file
|
|
1299
|
+
npm test -- test/commands/db/query.test.ts
|
|
1300
|
+
```
|
|
1301
|
+
|
|
1302
|
+
### Code Quality
|
|
1303
|
+
|
|
1304
|
+
This project uses:
|
|
1305
|
+
|
|
1306
|
+
- **TypeScript** for type safety
|
|
1307
|
+
- **ESLint v9** for code linting (flat config)
|
|
1308
|
+
- **Prettier** for code formatting
|
|
1309
|
+
- **Mocha + Chai** for testing
|
|
1310
|
+
|
|
1311
|
+
### Building and Publishing
|
|
1312
|
+
|
|
1313
|
+
```bash
|
|
1314
|
+
# Build for production
|
|
1315
|
+
npm run build
|
|
1316
|
+
|
|
1317
|
+
# Create package tarball (for testing)
|
|
1318
|
+
npm pack
|
|
1319
|
+
|
|
1320
|
+
# Publish to npm (maintainers only)
|
|
1321
|
+
npm publish
|
|
1322
|
+
```
|
|
1323
|
+
|
|
1324
|
+
### Contributing
|
|
1325
|
+
|
|
1326
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
|
|
1327
|
+
|
|
1328
|
+
- Code style and conventions
|
|
1329
|
+
- Test requirements
|
|
1330
|
+
- Pull request process
|
|
1331
|
+
- Commit message format
|
|
1332
|
+
|
|
1333
|
+
## Legal & Compliance
|
|
1334
|
+
|
|
1335
|
+
### Trademark Notice
|
|
1336
|
+
|
|
1337
|
+
"Notion" is a registered trademark of Notion Labs, Inc. This project is an independent,
|
|
1338
|
+
unofficial tool and is not affiliated with, endorsed by, or sponsored by Notion Labs, Inc.
|
|
1339
|
+
|
|
1340
|
+
### License
|
|
1341
|
+
|
|
1342
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
1343
|
+
|
|
1344
|
+
### Third-Party Licenses
|
|
1345
|
+
|
|
1346
|
+
This project uses various open-source dependencies. See [NOTICE](NOTICE) for complete
|
|
1347
|
+
third-party license information.
|
|
1348
|
+
|
|
1349
|
+
## Contributing
|
|
1350
|
+
|
|
1351
|
+
Contributions welcome! Please:
|
|
1352
|
+
|
|
1353
|
+
1. Fork the repository
|
|
1354
|
+
2. Create a feature branch
|
|
1355
|
+
3. Add tests for new features
|
|
1356
|
+
4. Submit a pull request
|
|
1357
|
+
|
|
1358
|
+
## API Version
|
|
1359
|
+
|
|
1360
|
+
This CLI uses **Notion API v5.2.1** with full support for:
|
|
1361
|
+
|
|
1362
|
+
- Data sources (new database API)
|
|
1363
|
+
- Enhanced properties
|
|
1364
|
+
- Improved pagination
|
|
1365
|
+
- Better error handling
|
|
1366
|
+
|
|
1367
|
+
## License
|
|
1368
|
+
|
|
1369
|
+
MIT License - see [LICENSE](LICENSE) file
|
|
1370
|
+
|
|
1371
|
+
## Support
|
|
1372
|
+
|
|
1373
|
+
- **Documentation**: Full guides in `/docs` folder
|
|
1374
|
+
- **Issues**: Report bugs on GitHub Issues
|
|
1375
|
+
- **Discussions**: Ask questions in GitHub Discussions
|
|
1376
|
+
- **Examples**: See `/examples` folder for sample scripts
|
|
1377
|
+
|
|
1378
|
+
## Related Projects
|
|
1379
|
+
|
|
1380
|
+
- **Notion API**: https://developers.notion.com
|
|
1381
|
+
- **@notionhq/client**: Official Notion SDK
|
|
1382
|
+
- **notion-md**: Markdown converter for Notion
|
|
1383
|
+
|
|
1384
|
+
---
|
|
1385
|
+
|
|
1386
|
+
**Built for AI agents, optimized for automation, powered by Notion API v5.2.1**
|