@haustle/notion-orm 0.0.46 → 0.0.47
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 +35 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,22 +13,17 @@ A lightweight TypeScript [Notion API](https://developers.notion.com/) wrapper th
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
|
|
17
|
-
# or: pnpm add / yarn add / bun add @haustle/notion-orm
|
|
16
|
+
bun add @haustle/notion-orm
|
|
18
17
|
```
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
**Config file:** use `**notion.config.js`** or `**notion.config.mjs**` if you run the CLI with plain Node. `**notion.config.ts**` is supported when your runtime can load TypeScript (for example Bun or a project using a TS loader); otherwise compile the config or use JavaScript.
|
|
23
|
-
|
|
24
|
-
Generated database and agent modules live in your app's local `**./notion/**` folder after `notion sync`; import those relative files directly if you need a generated factory outside the `NotionORM` wrapper.
|
|
19
|
+
(You can use npm, npx, pnpm, or yarn for the same flows—they work fine as well.)
|
|
25
20
|
|
|
26
21
|
# Quick start
|
|
27
22
|
|
|
28
23
|
Initialize config from your project root (recommended):
|
|
29
24
|
|
|
30
25
|
```bash
|
|
31
|
-
|
|
26
|
+
bunx notion init
|
|
32
27
|
```
|
|
33
28
|
|
|
34
29
|
Generated config shape:
|
|
@@ -58,15 +53,15 @@ export default NotionConfig;
|
|
|
58
53
|
Add new database to track and generate static types (ex. how to find ID [here](https://developers.notion.com/guides/data-apis/working-with-databases#adding-pages-to-a-database) )
|
|
59
54
|
|
|
60
55
|
```bash
|
|
61
|
-
|
|
56
|
+
bunx notion add <database-id>
|
|
62
57
|
```
|
|
63
58
|
|
|
64
|
-
### Adding
|
|
59
|
+
### Adding Custom Agents
|
|
65
60
|
|
|
66
|
-
Agent support requires the [Notion Agents SDK](https://github.com/makenotion/notion-agents-sdk-js), which is **currently in alpha** and not
|
|
61
|
+
Agent support requires the [Notion Agents SDK](https://github.com/makenotion/notion-agents-sdk-js), which is **currently in alpha** and not yet installable with `bun add`. Because of this, a one-command setup handles the entire download-and-install flow for you:
|
|
67
62
|
|
|
68
63
|
```bash
|
|
69
|
-
|
|
64
|
+
bunx notion setup-agents-sdk
|
|
70
65
|
```
|
|
71
66
|
|
|
72
67
|
**What this does:**
|
|
@@ -80,11 +75,11 @@ After setup, run `notion sync` to generate agent types. Agents linked to your in
|
|
|
80
75
|
**Updating:** When the upstream SDK receives changes, rerun the same command. It pulls the latest from the cached clone, rebuilds, and reinstalls:
|
|
81
76
|
|
|
82
77
|
```bash
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
bunx notion setup-agents-sdk
|
|
79
|
+
bunx notion sync
|
|
85
80
|
```
|
|
86
81
|
|
|
87
|
-
If you have not run the setup command, `notion sync` will skip agent generation and only produce database types. Once the SDK is published
|
|
82
|
+
If you have not run the setup command, `notion sync` will skip agent generation and only produce database types. Once the SDK is published and installable with `bun add`, this step will no longer be necessary.
|
|
88
83
|
|
|
89
84
|
Learn more about [Custom Agents](https://www.notion.com/help/custom-agents) in the Notion documentation.
|
|
90
85
|
|
|
@@ -93,10 +88,33 @@ Learn more about [Custom Agents](https://www.notion.com/help/custom-agents) in t
|
|
|
93
88
|
Fetch/refresh database schemas. If the agents SDK is installed, also syncs custom agents.
|
|
94
89
|
|
|
95
90
|
```bash
|
|
96
|
-
|
|
91
|
+
bunx notion sync
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
# Implementation
|
|
95
|
+
|
|
96
|
+
### Client setup
|
|
97
|
+
|
|
98
|
+
Create a single ORM instance with your Notion integration key. Import from the generated `**notion/**` folder (directory specifier → `index`):
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { NotionORM } from "./notion/";
|
|
102
|
+
|
|
103
|
+
const notion = new NotionORM({
|
|
104
|
+
auth: process.env.NOTION_KEY!,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const db = notion.databases.yourDatabaseName; // DatabaseClient
|
|
108
|
+
const agent = notion.agents.yourAgentName; // AgentClient
|
|
97
109
|
```
|
|
98
110
|
|
|
99
|
-
|
|
111
|
+
Generated database and agent names are camelCased and exposed on an instance of `NotionORM`.
|
|
112
|
+
|
|
113
|
+
- Use `notion.databases.<camelCaseDatabaseName>` for typed CRUD + query operations (`findMany`, `findFirst`, `findUnique`, `create`, `update`, `delete`, and more).
|
|
114
|
+
- Use `notion.agents.<camelCaseAgentName>` for `chat()`, `chatStream()`, thread helpers, and history APIs.
|
|
115
|
+
- For full method signatures and response shapes, see [API Reference](#api-reference).
|
|
116
|
+
|
|
117
|
+
# Basic examples
|
|
100
118
|
|
|
101
119
|
### Create page in a database
|
|
102
120
|
|
|
@@ -160,29 +178,6 @@ const thread = await notion.agents.helpBot.chatStream({
|
|
|
160
178
|
|
|
161
179
|
```
|
|
162
180
|
|
|
163
|
-
# Implementation
|
|
164
|
-
|
|
165
|
-
### Client setup
|
|
166
|
-
|
|
167
|
-
Create a single ORM instance with your Notion integration key. Import from the generated `**notion/**` folder (directory specifier → `index`):
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
import { NotionORM } from "./notion/";
|
|
171
|
-
|
|
172
|
-
const notion = new NotionORM({
|
|
173
|
-
auth: process.env.NOTION_KEY!,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const db = notion.databases.yourDatabaseName; // DatabaseClient
|
|
177
|
-
const agent = notion.agents.yourAgentName; // AgentClient
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Generated database and agent names are camelCased and exposed on an instance of `NotionORM`.
|
|
181
|
-
|
|
182
|
-
- Use `notion.databases.<camelCaseDatabaseName>` for typed CRUD + query operations (`findMany`, `findFirst`, `findUnique`, `create`, `update`, `delete`, and more).
|
|
183
|
-
- Use `notion.agents.<camelCaseAgentName>` for `chat()`, `chatStream()`, thread helpers, and history APIs.
|
|
184
|
-
- For full method signatures and response shapes, see [API Reference](#api-reference).
|
|
185
|
-
|
|
186
181
|
# Available database operations
|
|
187
182
|
|
|
188
183
|
## Adding
|