@notionhq/custom-blocks-dev-shell 0.4.4 → 0.6.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 +92 -27
- package/data/customers.json +10 -20
- package/data/meetings.json +71 -103
- package/data/projects.json +55 -51
- package/data/tasks.json +78 -66
- package/dist/assets/index-BCrnMfUh.js +12 -0
- package/dist/index.html +1 -1
- package/dist-cli/cli/published-cli.js +2438 -579
- package/docs/bindings.md +54 -26
- package/docs/data-sources.md +63 -20
- package/package.json +1 -1
- package/dist/assets/index-B1RObNc_.js +0 -12
package/docs/bindings.md
CHANGED
|
@@ -5,7 +5,7 @@ launcher flags or in **Bindings → Data access**.
|
|
|
5
5
|
|
|
6
6
|
Each data source selects its file in this order:
|
|
7
7
|
|
|
8
|
-
1. The explicit `--bind` selection.
|
|
8
|
+
1. The explicit `--bind-data-source` selection.
|
|
9
9
|
2. `data/worker_<dataSourceKey>.json`, if it exists.
|
|
10
10
|
3. `data/<dataSourceKey>.json`, if it exists.
|
|
11
11
|
4. If neither file exists, the data source stays unbound.
|
|
@@ -15,20 +15,20 @@ choices.
|
|
|
15
15
|
|
|
16
16
|
## Choose sample data
|
|
17
17
|
|
|
18
|
-
Use `--bind <capabilityKey>.<dataSourceKey>=<sampleDataFileName>` to choose a source:
|
|
18
|
+
Use `--bind-data-source <capabilityKey>.<dataSourceKey>=<sampleDataFileName>` to choose a source:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
ntn workers customblocks dev -- --bind task-board.tasks=sample_tasks.json
|
|
21
|
+
ntn workers customblocks dev -- --bind-data-source task-board.tasks=sample_tasks.json
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
This connects the `tasks` data source on `task-board` to `data/sample_tasks.json`. Use a filename
|
|
25
25
|
from `data/`, including `.json`.
|
|
26
26
|
|
|
27
|
-
Repeat `--bind` for additional data sources. Sources without an override keep their
|
|
28
|
-
running `custom-blocks-dev-shell` directly, omit the forwarding `--` separator.
|
|
27
|
+
Repeat `--bind-data-source` for additional data sources. Sources without an override keep their
|
|
28
|
+
defaults. When running `custom-blocks-dev-shell` directly, omit the forwarding `--` separator.
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
Unknown, ambiguous, or repeated targets stop startup, as do missing files. Malformed files appear as
|
|
31
|
+
errors in the shell.
|
|
32
32
|
|
|
33
33
|
## Choose property mappings
|
|
34
34
|
|
|
@@ -37,7 +37,7 @@ property must map to a specific property in your sample data:
|
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
ntn workers customblocks dev -- \
|
|
40
|
-
--bind task-board.tasks=sample_tasks.json \
|
|
40
|
+
--bind-data-source task-board.tasks=sample_tasks.json \
|
|
41
41
|
--bind-property task-board.tasks.title=task_name \
|
|
42
42
|
--bind-property task-board.tasks.status=workflow_status
|
|
43
43
|
```
|
|
@@ -47,14 +47,37 @@ property maps to `schema.task_name`, and its `status` property maps to `schema.w
|
|
|
47
47
|
source property key is a key in the sample file's `schema`, not its display name.
|
|
48
48
|
|
|
49
49
|
Repeat `--bind-property` for each property you want to set. Explicit mappings override automatic
|
|
50
|
-
matches. Properties without an override keep automatic matching. You can omit `--bind`
|
|
51
|
-
already selects a file by its default filename. Flag order does not affect source
|
|
50
|
+
matches. Properties without an override keep automatic matching. You can omit `--bind-data-source`
|
|
51
|
+
when the slot already selects a file by its default filename. Flag order does not affect source
|
|
52
|
+
selection.
|
|
52
53
|
|
|
53
54
|
An unknown or ambiguous target, duplicate property target, missing source, missing source property,
|
|
54
55
|
or property type mismatch stops startup. Other properties can remain unmapped until you connect them
|
|
55
56
|
in **Bindings → Data access**. If the data source file cannot load, its property mappings remain
|
|
56
57
|
unvalidated until you fix and save the file.
|
|
57
58
|
|
|
59
|
+
## Preselect a page
|
|
60
|
+
|
|
61
|
+
Use `--bind-page <capabilityKey>.<pageKey>=<pageId>` to preselect a sample page for a declared slot:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
ntn workers customblocks dev --json -- --bind-page task-board.brief=launch-plan
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`brief` is the key under `pages` in the block manifest. `launch-plan` is a row `id` from a loaded
|
|
68
|
+
sample file. The launcher checks that the slot and row exist. Repeat the flag for different slots.
|
|
69
|
+
|
|
70
|
+
If a block key or page key contains an equals sign, write it as `\=` and quote the argument so the
|
|
71
|
+
shell preserves the backslash. Use `\\` for a literal backslash in either key.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
ntn workers customblocks dev --json -- --bind-page 'task-board.brief\=primary=launch-plan'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Bindings → Page access** starts with the selected row. With Protocol 14,
|
|
78
|
+
`NotionPage.fromKey("brief").get()` reads that row. Reload the shell to restore the CLI selection.
|
|
79
|
+
See [startup JSON](../README.md#startup-details-for-automation) for binding statuses.
|
|
80
|
+
|
|
58
81
|
## Binding errors
|
|
59
82
|
|
|
60
83
|
The launcher stops on the first binding failure. Binding syntax and mapping errors end with
|
|
@@ -66,20 +89,25 @@ Cannot bind task-board.tasks.title: source property "score" has type "number", e
|
|
|
66
89
|
|
|
67
90
|
The codes identify the cause:
|
|
68
91
|
|
|
69
|
-
| Code
|
|
70
|
-
|
|
|
71
|
-
| `
|
|
72
|
-
| `invalid_property_binding_syntax`
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `sample_file_not_found`
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
92
|
+
| Code | Cause |
|
|
93
|
+
| -------------------------------------- | ----------------------------------------------------------------------------- |
|
|
94
|
+
| `invalid_data_source_binding_syntax` | A `--bind-data-source` value does not follow the required syntax. |
|
|
95
|
+
| `invalid_property_binding_syntax` | A `--bind-property` value does not follow the required syntax. |
|
|
96
|
+
| `unknown_data_source_binding_target` | No block and data source slot match the `--bind-data-source` target. |
|
|
97
|
+
| `ambiguous_data_source_binding_target` | More than one block and slot match the `--bind-data-source` target. |
|
|
98
|
+
| `duplicate_data_source_binding_target` | A full `--bind-data-source` target appears more than once. |
|
|
99
|
+
| `sample_file_not_found` | The file selected by `--bind-data-source` does not exist in `data/`. |
|
|
100
|
+
| `invalid_page_binding_syntax` | A `--bind-page` value does not follow the required syntax. |
|
|
101
|
+
| `unknown_page_binding_target` | No declared block and page slot match the target. |
|
|
102
|
+
| `ambiguous_page_binding_target` | More than one declared block and page slot match the target. |
|
|
103
|
+
| `duplicate_page_binding_target` | A full `--bind-page` target appears more than once. |
|
|
104
|
+
| `sample_page_not_found` | No loaded sample row has the selected ID. |
|
|
105
|
+
| `unknown_property_binding_target` | No declared property matches the `--bind-property` target. |
|
|
106
|
+
| `ambiguous_property_binding_target` | More than one declared property matches the target. |
|
|
107
|
+
| `duplicate_property_binding_target` | A full `--bind-property` target appears more than once. |
|
|
108
|
+
| `property_binding_source_missing` | A property override has neither an explicit source nor a default source file. |
|
|
109
|
+
| `source_property_not_found` | The selected source's `schema` has no entry for the requested property key. |
|
|
110
|
+
| `property_type_mismatch` | The source property type differs from the block property's declared type. |
|
|
83
111
|
|
|
84
112
|
Repeating a full target fails even when both values are identical. The same property key in
|
|
85
113
|
different slots or blocks is allowed. Multiple declared properties can share a source property when
|
|
@@ -92,8 +120,8 @@ properties. Changes apply as you make them. See the [sample data format](data-so
|
|
|
92
120
|
define a source.
|
|
93
121
|
|
|
94
122
|
**Page access** appears when the manifest declares at least one page slot. Select a page from your
|
|
95
|
-
loaded sample data to apply the selection immediately.
|
|
96
|
-
|
|
123
|
+
loaded sample data to apply the selection immediately. Clear the selection to unbind the key. On
|
|
124
|
+
Protocol 14, a read by an unbound or undeclared key returns `page_unavailable`.
|
|
97
125
|
|
|
98
126
|
A property maps automatically only when exactly one source property matches its key or name and has
|
|
99
127
|
the same type. If no property matches, or several properties match, the property stays unmapped.
|
package/docs/data-sources.md
CHANGED
|
@@ -34,7 +34,7 @@ For example, `data/tasks.json`:
|
|
|
34
34
|
"id": "tasks-1",
|
|
35
35
|
"title": "Ship the block",
|
|
36
36
|
"status": "Not started",
|
|
37
|
-
"dueDate": { "
|
|
37
|
+
"dueDate": { "start": "2026-08-01" },
|
|
38
38
|
"done": false
|
|
39
39
|
}
|
|
40
40
|
]
|
|
@@ -56,16 +56,16 @@ For example, `data/tasks.json`:
|
|
|
56
56
|
|
|
57
57
|
Value shapes by property type:
|
|
58
58
|
|
|
59
|
-
| Type | Value
|
|
60
|
-
| ------------------------------------------------------------------------ |
|
|
61
|
-
| `title`, `rich_text`, `select`, `status`, `url`, `email`, `phone_number` | string
|
|
62
|
-
| `multi_select` | array of strings
|
|
63
|
-
| `number` | number
|
|
64
|
-
| `checkbox` | boolean
|
|
65
|
-
| `date` | `{ "
|
|
66
|
-
| `people` | array of `{ "id": "...", "table": "notion_user" }` pointers
|
|
67
|
-
| `relation` | array of `{ "id": "...", "table": "block" }` pointers
|
|
68
|
-
| `files` | Array of named external links and unavailable placeholders.
|
|
59
|
+
| Type | Value |
|
|
60
|
+
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
61
|
+
| `title`, `rich_text`, `select`, `status`, `url`, `email`, `phone_number` | string |
|
|
62
|
+
| `multi_select` | array of strings |
|
|
63
|
+
| `number` | number |
|
|
64
|
+
| `checkbox` | boolean |
|
|
65
|
+
| `date` | `{ "start": "2026-08-01" }` for an all-day date. Add `end` for a range and use ISO timestamps with an optional `timeZone` for timed dates. |
|
|
66
|
+
| `people` | array of `{ "id": "...", "table": "notion_user" }` pointers |
|
|
67
|
+
| `relation` | array of `{ "id": "...", "table": "block" }` pointers |
|
|
68
|
+
| `files` | Array of named external links and unavailable placeholders. |
|
|
69
69
|
|
|
70
70
|
People properties use user IDs, not page IDs from a directory data source.
|
|
71
71
|
|
|
@@ -89,6 +89,46 @@ Reads preserve entry order. The sample data contains links and labels, so loadin
|
|
|
89
89
|
fetch the linked content. A placeholder's name is optional. The shell skips malformed entries and
|
|
90
90
|
treats missing cells and older text values as empty arrays.
|
|
91
91
|
|
|
92
|
+
## Relations between sample files
|
|
93
|
+
|
|
94
|
+
Use `targetFile` to link a relation property to another sample file. Use the filename in `data/`,
|
|
95
|
+
including `.json`. To link tasks to projects, add this property to the Tasks schema.
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"project_link": { "name": "Linked project", "type": "relation", "targetFile": "projects.json" }
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Set `project_link` on a task row to `[{ "id": "project-1", "table": "block" }]` to link to the row
|
|
104
|
+
with ID `project-1` in `projects.json`. Bind each file to its own data source key. The relation
|
|
105
|
+
definition gives the key for `projects.json`. If the target file is missing or has no binding, the
|
|
106
|
+
relation target is `unresolved` and the row still contains the linked page ID.
|
|
107
|
+
|
|
108
|
+
The built-in Tasks and Meetings samples link to Projects. Projects links to Customers. Use **Add all
|
|
109
|
+
missing** to copy these samples into your project, then select the files in **Bindings**.
|
|
110
|
+
|
|
111
|
+
## Date values
|
|
112
|
+
|
|
113
|
+
Date, Created time, and Last edited time cells accept an ISO date or timestamp string, or an object
|
|
114
|
+
with a required `start` and optional `end`, `timeZone`, and `reminder`. Use `YYYY-MM-DD` for all-day
|
|
115
|
+
dates and add a time to create a timed date.
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"dueDate": { "start": "2026-08-01" },
|
|
120
|
+
"releaseWindow": { "start": "2026-08-01", "end": "2026-08-03" },
|
|
121
|
+
"appointment": {
|
|
122
|
+
"start": "2026-08-01T09:00",
|
|
123
|
+
"end": "2026-08-01T10:00",
|
|
124
|
+
"timeZone": "America/Los_Angeles"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
For a timed value, an explicit offset such as `-07:00` on the timestamp takes precedence over
|
|
130
|
+
`timeZone`. If you supply neither, the dev shell uses UTC.
|
|
131
|
+
|
|
92
132
|
## Validation
|
|
93
133
|
|
|
94
134
|
Files are validated independently at startup and after edits. Errors name the file and problem, for
|
|
@@ -97,17 +137,15 @@ filename without `.json` is the source identity used by bindings and source pick
|
|
|
97
137
|
changes its identity.
|
|
98
138
|
|
|
99
139
|
Duplicate page IDs make every file containing that ID unavailable until the collision is fixed. The
|
|
100
|
-
error names the ID and conflicting files. Other files remain available.
|
|
140
|
+
error names the ID and conflicting files. Other files remain available. The launcher also reserves
|
|
141
|
+
Current page’s ID. A sample file with a row that uses that ID is unavailable until you change the
|
|
142
|
+
row ID.
|
|
101
143
|
|
|
102
144
|
## Querying
|
|
103
145
|
|
|
104
146
|
The shell applies filters, then ordered sorts, then the query limit. The SDK resolves semantic
|
|
105
147
|
property keys to property IDs before it sends the query. Empty values stay last in both directions.
|
|
106
|
-
|
|
107
|
-
named zone, and an explicit offset in `start_time` wins.
|
|
108
|
-
|
|
109
|
-
Date, Created time, and Last edited time values accept ISO timestamp strings or the sample `date`
|
|
110
|
-
shapes above.
|
|
148
|
+
All-day dates sort using UTC.
|
|
111
149
|
|
|
112
150
|
People, Created by, and Last edited by sorts use record IDs as mock display names. People sorts
|
|
113
151
|
preserve pointer order and remove duplicates. Groups use their composite group and workspace IDs.
|
|
@@ -142,15 +180,20 @@ ntn workers customblocks sample <url-or-data-source-id> \
|
|
|
142
180
|
--out data/worker_tasks.json --row-only
|
|
143
181
|
```
|
|
144
182
|
|
|
145
|
-
Run the dev shell once to create the generated file, then sample your data.
|
|
146
|
-
the schema and
|
|
183
|
+
Run the dev shell once to create the generated file, then sample your data. The sample command reads
|
|
184
|
+
the schema and rows through the Notion API and writes a local JSON file. The dev shell converter
|
|
185
|
+
preserves date and timestamp strings, including seconds and offsets, and writes a supplied time zone
|
|
186
|
+
as `timeZone`.
|
|
187
|
+
|
|
188
|
+
`--row-only` preserves the schema and appends rows with new IDs. Add `--overwrite` to replace all
|
|
189
|
+
rows in the target file while keeping its schema.
|
|
147
190
|
|
|
148
191
|
Imported Files cells keep external links in order. Notion-hosted files and pending uploads become
|
|
149
192
|
unavailable placeholders, with a name when supplied. The sample JSON does not store temporary file
|
|
150
193
|
URLs.
|
|
151
194
|
|
|
152
195
|
Sampled property keys must match the generated schema. If they differ, sample into a separate file
|
|
153
|
-
and select it with [`--bind`](bindings.md#choose-sample-data).
|
|
196
|
+
and select it with [`--bind-data-source`](bindings.md#choose-sample-data).
|
|
154
197
|
|
|
155
198
|
The shell loads sampled data automatically.
|
|
156
199
|
|