@relayfile/adapter-notion 0.1.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/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @relayfile/adapter-notion
2
+
3
+ Relayfile adapter for Notion. It ingests databases, pages, blocks, markdown content, and comments into the relayfile VFS and supports writeback for page properties, markdown content, comments, and page creation inside databases.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npm install
9
+ npm test
10
+ npm run build
11
+ ```
12
+
13
+ ```ts
14
+ import { RelayFileClient } from '@relayfile/sdk';
15
+ import { NotionAdapter } from '@relayfile/adapter-notion';
16
+
17
+ const relay = new RelayFileClient({
18
+ baseUrl: process.env.RELAYFILE_BASE_URL ?? 'https://api.relayfile.com',
19
+ token: process.env.RELAYFILE_TOKEN ?? '',
20
+ });
21
+
22
+ const adapter = new NotionAdapter(relay, undefined, {
23
+ token: process.env.NOTION_TOKEN ?? '',
24
+ databaseIds: ['database-id'],
25
+ pageIds: ['page-id'],
26
+ });
27
+
28
+ await adapter.bulkIngest('workspace-id');
29
+ ```
30
+
31
+ Create a Notion internal integration in the Notion developer dashboard, grant it access to the target databases/pages, and use the integration token as `NOTION_TOKEN`.
32
+
33
+ ## VFS Layout
34
+
35
+ ```text
36
+ /notion/databases/{database_id}/metadata.json
37
+ /notion/databases/{database_id}/pages/{page_id}.json
38
+ /notion/databases/{database_id}/pages/{page_id}/content.md
39
+ /notion/databases/{database_id}/pages/{page_id}/blocks/{block_id}.json
40
+ /notion/databases/{database_id}/pages/{page_id}/comments.json
41
+ /notion/pages/{page_id}.json
42
+ /notion/pages/{page_id}/content.md
43
+ /notion/pages/{page_id}/comments.json
44
+ ```
45
+
46
+ ## Supported Property Types
47
+
48
+ Writeable property serializers are included for:
49
+
50
+ - `title`
51
+ - `rich_text`
52
+ - `number`
53
+ - `select`
54
+ - `multi_select`
55
+ - `status`
56
+ - `date`
57
+ - `people`
58
+ - `files`
59
+ - `checkbox`
60
+ - `url`
61
+ - `email`
62
+ - `phone_number`
63
+ - `relation`
64
+
65
+ Read-only Notion properties such as `formula`, `rollup`, `created_time`, and `last_edited_time` are preserved in ingested JSON but rejected during writeback.
66
+
67
+ ## Markdown Content Support
68
+
69
+ The adapter uses the Notion markdown content endpoints when enabled and falls back to rendering block trees when those endpoints are unavailable. Notion’s current markdown endpoints are `GET /v1/pages/{page_id}/markdown` and `PATCH /v1/pages/{page_id}/markdown`, and the adapter defaults those calls to `Notion-Version: 2026-03-11`.
70
+
71
+ Classic database/page/block APIs still default to `Notion-Version: 2022-06-28` because that version preserves the legacy database schema and `POST /v1/databases/{id}/query` behavior this package targets. Override either version through `apiVersion` and `markdownApiVersion` if your workspace needs a different combination.
72
+
73
+ ## Poll-Based Sync
74
+
75
+ Notion webhooks are not broadly available across all plans, so the adapter includes poll-based sync helpers:
76
+
77
+ - Database pages are queried with `last_edited_time > cursor`.
78
+ - Standalone pages are scanned through `POST /v1/search`, sorted by `last_edited_time`.
79
+ - The sync cursor is an ISO timestamp watermark.
80
+
81
+ ## Writeback
82
+
83
+ - Editing `*.json` page files maps to `PATCH /v1/pages/{page_id}`.
84
+ - Editing `content.md` maps to `PATCH /v1/pages/{page_id}/markdown`.
85
+ - Editing `comments.json` creates a new comment with `POST /v1/comments`.
86
+ - Writing to `/notion/databases/{database_id}/pages` creates a new page with `POST /v1/pages`.
@@ -0,0 +1,73 @@
1
+ provider: notion
2
+ root: /notion
3
+ paths:
4
+ - pattern: /notion/databases/{database_id}/metadata.json
5
+ object_type: database
6
+ source:
7
+ method: GET
8
+ endpoint: /v1/databases/{database_id}
9
+ - pattern: /notion/databases/{database_id}/pages/{page_id}.json
10
+ object_type: page
11
+ source:
12
+ method: GET
13
+ endpoint: /v1/pages/{page_id}
14
+ writeback:
15
+ method: PATCH
16
+ endpoint: /v1/pages/{page_id}
17
+ - pattern: /notion/databases/{database_id}/pages/{page_id}/content.md
18
+ object_type: page_content
19
+ source:
20
+ method: GET
21
+ endpoint: /v1/pages/{page_id}/markdown
22
+ notion_version: 2026-03-11
23
+ writeback:
24
+ method: PATCH
25
+ endpoint: /v1/pages/{page_id}/markdown
26
+ notion_version: 2026-03-11
27
+ - pattern: /notion/databases/{database_id}/pages/{page_id}/blocks/{block_id}.json
28
+ object_type: block
29
+ source:
30
+ method: GET
31
+ endpoint: /v1/blocks/{block_id}
32
+ - pattern: /notion/databases/{database_id}/pages/{page_id}/comments.json
33
+ object_type: comment
34
+ source:
35
+ method: GET
36
+ endpoint: /v1/comments?block_id={page_id}
37
+ writeback:
38
+ method: POST
39
+ endpoint: /v1/comments
40
+ - pattern: /notion/pages/{page_id}.json
41
+ object_type: page
42
+ source:
43
+ method: GET
44
+ endpoint: /v1/pages/{page_id}
45
+ writeback:
46
+ method: PATCH
47
+ endpoint: /v1/pages/{page_id}
48
+ - pattern: /notion/pages/{page_id}/content.md
49
+ object_type: page_content
50
+ source:
51
+ method: GET
52
+ endpoint: /v1/pages/{page_id}/markdown
53
+ notion_version: 2026-03-11
54
+ writeback:
55
+ method: PATCH
56
+ endpoint: /v1/pages/{page_id}/markdown
57
+ notion_version: 2026-03-11
58
+ - pattern: /notion/pages/{page_id}/comments.json
59
+ object_type: comment
60
+ source:
61
+ method: GET
62
+ endpoint: /v1/comments?block_id={page_id}
63
+ writeback:
64
+ method: POST
65
+ endpoint: /v1/comments
66
+ collections:
67
+ - pattern: /notion/databases/{database_id}/pages
68
+ writeback:
69
+ method: POST
70
+ endpoint: /v1/pages
71
+ body:
72
+ parent:
73
+ database_id: '{database_id}'
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@relayfile/adapter-notion",
3
+ "version": "0.1.0",
4
+ "description": "Notion adapter for relayfile \u2014 maps Notion databases, pages, blocks, and comments to relayfile VFS paths",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "notion.mapping.yaml"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "test": "node --import tsx --test 'src/__tests__/*.test.ts'",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "dependencies": {
25
+ "@agent-relay/sdk": "^3.2.22",
26
+ "@relayfile/sdk": "^0.1.6"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.4.0"
30
+ },
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "license": "MIT",
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/AgentWorkforce/relayfile-adapters",
41
+ "directory": "packages/notion"
42
+ }
43
+ }