Skip to content

Commit 4652357

Browse files
authored
fix(wasm): adjust page children blocks order for Notion FDW (#415)
1 parent 622a137 commit 4652357

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

docs/catalog/notion.md

+41-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The Notion Wrapper is a WebAssembly(Wasm) foreign data wrapper which allows you
1717

1818
| Version | Wasm Package URL | Checksum |
1919
| ------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
20+
| 0.1.1 | `https://github.com/supabase/wrappers/releases/download/wasm_notion_fdw_v0.1.1/notion_fdw.wasm` | `tbd` |
2021
| 0.1.0 | `https://github.com/supabase/wrappers/releases/download/wasm_notion_fdw_v0.1.0/notion_fdw.wasm` | `e017263d1fc3427cc1df8071d1182cdc9e2f00363344dddb8c195c5d398a2099` |
2122

2223
## Preparation
@@ -55,6 +56,42 @@ values (
5556
returning key_id;
5657
```
5758

59+
### Connecting to Notion
60+
61+
We need to provide Postgres with the credentials to access Notion and any additional options. We can do this using the `create server` command:
62+
63+
=== "With Vault"
64+
65+
```sql
66+
create server notion_server
67+
foreign data wrapper wasm_wrapper
68+
options (
69+
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_notion_fdw_v0.1.1/notion_fdw.wasm',
70+
fdw_package_name 'supabase:notion-fdw',
71+
fdw_package_version '0.1.1',
72+
fdw_package_checksum 'tbd',
73+
api_url 'https://api.notion.com/v1', -- optional
74+
api_key_id '<key_ID>' -- The Key ID from above.
75+
);
76+
```
77+
78+
=== "Without Vault"
79+
80+
```sql
81+
create server cal_server
82+
foreign data wrapper wasm_wrapper
83+
options (
84+
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_notion_fdw_v0.1.1/notion_fdw.wasm',
85+
fdw_package_name 'supabase:notion-fdw',
86+
fdw_package_version '0.1.1',
87+
fdw_package_checksum 'tbd',
88+
api_url 'https://api.notion.com/v1', -- optional
89+
api_key 'secret_xxxx...' -- Notion API key
90+
);
91+
```
92+
93+
Note the `fdw_package_*` options are required, which specify the Wasm package metadata. You can get the available package version list from [above](#available-versions).
94+
5895
### Create a schema
5996

6097
We recommend creating a schema to hold all the foreign tables:
@@ -91,7 +128,7 @@ Ref: [Notion API docs](https://developers.notion.com/reference/intro)
91128

92129
| Object | Select | Insert | Update | Delete | Truncate |
93130
| ------ | :----: | :----: | :----: | :----: | :------: |
94-
| Block | | | | | |
131+
| Block ||||||
95132

96133
#### Usage
97134

@@ -130,7 +167,7 @@ Ref: [Notion API docs](https://developers.notion.com/reference/intro)
130167

131168
| Object | Select | Insert | Update | Delete | Truncate |
132169
| ------ | :----: | :----: | :----: | :----: | :------: |
133-
| Page | | | | | |
170+
| Page ||||||
134171

135172
#### Usage
136173

@@ -164,7 +201,7 @@ Ref: [Notion API docs](https://developers.notion.com/reference/intro)
164201

165202
| Object | Select | Insert | Update | Delete | Truncate |
166203
| -------- | :----: | :----: | :----: | :----: | :------: |
167-
| Database | | | | | |
204+
| Database ||||||
168205

169206
#### Usage
170207

@@ -198,7 +235,7 @@ Ref: [Notion API docs](https://developers.notion.com/reference/intro)
198235

199236
| Object | Select | Insert | Update | Delete | Truncate |
200237
| ------ | :----: | :----: | :----: | :----: | :------: |
201-
| User | | | | | |
238+
| User ||||||
202239

203240
#### Usage
204241

wasm-wrappers/fdw/notion_fdw/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ impl NotionFdw {
296296
let children = self.make_request("block", Some(block_id), ctx)?;
297297

298298
for child in children.iter() {
299+
ret.push(child.clone());
300+
299301
let has_children = child
300302
.pointer("/has_children")
301303
.and_then(|v| v.as_bool())
@@ -308,8 +310,6 @@ impl NotionFdw {
308310
}
309311
}
310312

311-
ret.extend(children);
312-
313313
Ok(ret)
314314
}
315315

0 commit comments

Comments
 (0)