Skip to content

Commit d5a9687

Browse files
author
Jonas Saabel
committed
refactor: standardize datasource terminology and restructure packages
- Renamed query-related classes for consistency with Notion API 2025-09-03: * DatabaseQueryBuilder → DataSourceQueryBuilder * databaseQuery() → dataSourceQuery() * DatabaseQueryRequest → DataSourceQueryRequest * DatabaseQueryResponse → DataSourceQueryResponse * DatabaseFilter → DataSourceFilter * DatabaseSort → DataSourceSort - Separated package structure: * models/databases/ - Database container objects * models/datasources/ - Data source (table) objects and queries - Updated all docstrings to use "data source" terminology - Updated all imports across codebase automatically via IntelliJ refactoring Rationale: In Notion API 2025-09-03, "database" refers to containers (like folders) while "data source" refers to the actual tables you query. This refactoring aligns our code with the API's terminology.
1 parent a633693 commit d5a9687

32 files changed

+735
-293
lines changed

QUICKSTART.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Quick Start Guide
22

3-
> **⚠️ WORK IN PROGRESS**: This documentation is being actively developed and may be incomplete or subject to change.
4-
53
Get started with the Kotlin Notion Client in under 5 minutes.
64

75
## Prerequisites

docs/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Documentation Index
22

3-
> **⚠️ WORK IN PROGRESS**: This documentation is being actively developed and may be incomplete or subject to change.
4-
53
## API Guides
64

75
### Core APIs

docs/data-sources.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Data Sources API
22

3-
> **⚠️ WORK IN PROGRESS**: This documentation is being actively developed and may be incomplete or subject to change.
4-
53
> **📝 Example Validation**: ✅ All examples verified - validated against live Notion API (see `src/test/kotlin/examples/DataSourcesExamples.kt`)
64
75
## Overview
@@ -153,22 +151,21 @@ val updated = notion.dataSources.update("data-source-id") {
153151

154152
## Understanding Data Sources vs. Databases
155153

156-
**In older API versions (pre-2025-09-03)**:
157-
- You would query a "database" to get pages
158-
- You would add pages to a "database"
159-
160-
**In 2025-09-03**:
161-
- **Databases** are containers (like folders)
162-
- **Data sources** are the tables inside those containers
163-
- You query **data sources** to get pages
154+
**Important terminology in the 2025-09-03 API**:
155+
- **Databases** are containers (like folders) that hold data sources
156+
- **Data sources** are the actual tables with properties and rows
157+
- You query **data sources** to get pages (not databases)
164158
- You add pages to **data sources** (using `dataSourceId` as parent)
165159

166160
```kotlin
167-
// ❌ This was the old way:
168-
// notion.databases.query("database-id")
169-
170-
// ✅ This is the new way:
161+
// ✅ Query a data source (table)
171162
notion.dataSources.query("data-source-id")
163+
164+
// ✅ Create a page in a data source
165+
notion.pages.create {
166+
parent.dataSource("data-source-id")
167+
// ...
168+
}
172169
```
173170

174171
## Common Patterns

docs/databases.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Databases API
22

3-
> **⚠️ WORK IN PROGRESS**: This documentation is being actively developed and may be incomplete or subject to change.
4-
53
> **📝 Example Validation**: ✅ All examples verified - validated against live Notion API (see `src/test/kotlin/examples/DatabasesExamples.kt`)
64
75
## Overview
@@ -386,51 +384,6 @@ parent.block("block-id")
386384
parent.workspace()
387385
```
388386

389-
## Migration from Pre-2025-09-03
390-
391-
If you're migrating from an older API version:
392-
393-
**Old way (2022-06-28)**:
394-
```kotlin
395-
// Create database
396-
val db = notion.databases.create {
397-
parent.page("...")
398-
title("...")
399-
properties { /* schema here */ }
400-
}
401-
402-
// Query it directly
403-
val pages = notion.databases.query(db.id) {}
404-
405-
// Create page in it
406-
notion.pages.create {
407-
parent.database(db.id) // database_id
408-
// ...
409-
}
410-
```
411-
412-
**New way (2025-09-03)**:
413-
```kotlin
414-
// Create database (similar but uses initialDataSource)
415-
val db = notion.databases.create {
416-
parent.page("...")
417-
title("...")
418-
properties { /* schema here */ } // Wrapped as initialDataSource
419-
}
420-
421-
// Get data source ID first
422-
val dataSourceId = db.dataSources.first().id
423-
424-
// Query the data source
425-
val pages = notion.dataSources.query(dataSourceId) {}
426-
427-
// Create page in data source
428-
notion.pages.create {
429-
parent.dataSource(dataSourceId) // data_source_id
430-
// ...
431-
}
432-
```
433-
434387
## Related APIs
435388

436389
- **[Data Sources](data-sources.md)** - The tables within database containers (query, update schema)

docs/pages.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Pages API
22

3-
> **⚠️ WORK IN PROGRESS**: This documentation is being actively developed and may be incomplete or subject to change.
4-
53
> **📝 Example Validation**: ✅ All examples verified - validated against live Notion API (see `src/test/kotlin/examples/PagesExamples.kt`)
64
75
## Overview

docs/pagination.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ val pages = notion.dataSources.query(dataSourceId) { /* query builder */ }
144144
// Flow (item-level) - returns Flow<Page>
145145
notion.dataSources.queryAsFlow(dataSourceId) { /* query builder */ }
146146

147-
// Flow (page-level) - returns Flow<DatabaseQueryResponse>
147+
// Flow (page-level) - returns Flow<DataSourceQueryResponse>
148148
notion.dataSources.queryPagedFlow(dataSourceId) { /* query builder */ }
149149
```
150150

docs/rich-text-dsl.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Rich Text DSL
22

3-
> **⚠️ WORK IN PROGRESS**: This documentation is being actively developed and may be incomplete or subject to change.
4-
53
## Overview
64

75
The Rich Text DSL provides an intuitive Kotlin builder for creating formatted text with annotations, mentions, links, and equations.

docs/search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ suspend fun search(query: String): SearchResponse
1919
## Quick Start
2020

2121
```kotlin
22-
val notion = NotionClient(NotionConfig(apiToken = "your_token"))
22+
val notion = NotionClient("your_token")
2323

2424
// Simple text search
2525
val results = notion.search.search("meeting notes")

docs/users.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ enum class UserType {
4949
Always available, doesn't require special capabilities:
5050

5151
```kotlin
52-
val notion = NotionClient(NotionConfig(apiToken = "your-secret-token"))
52+
val notion = NotionClient("your-secret-token")
5353

5454
val botUser = notion.users.getCurrentUser()
5555
println("Bot name: ${botUser.name}")
@@ -151,7 +151,7 @@ when (user.type) {
151151

152152
```kotlin
153153
suspend fun initializeNotionClient(token: String): NotionClient {
154-
val client = NotionClient(NotionConfig(apiToken = token))
154+
val client = NotionClient(token)
155155

156156
try {
157157
val botUser = client.users.getCurrentUser()

0 commit comments

Comments
 (0)