@notionhq/custom-blocks-dev-shell 0.1.73 → 0.1.74

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 CHANGED
@@ -1,8 +1,7 @@
1
1
  # Custom blocks dev shell
2
2
 
3
- The dev shell runs custom blocks in a local mock Notion host. It provides sample
4
- data that blocks can use. It builds the worker and previews its custom blocks. Use it before
5
- `ntn workers deploy`.
3
+ The dev shell runs custom blocks in a local mock Notion host. It provides sample data that blocks
4
+ can use. It builds the worker and previews its custom blocks. Use it before `ntn workers deploy`.
6
5
 
7
6
  ## Usage
8
7
 
@@ -12,11 +11,10 @@ Run this command from your worker project:
12
11
  ntn workers customblocks dev
13
12
  ```
14
13
 
15
- Open the shell URL printed by the command. Blocks hot reload when their source
16
- files change. Each run uses one port for the shell and all blocks. The default is
17
- `9873`. If that port is occupied, the launcher selects the next available port.
18
- You can start multiple runs without choosing a port for each run. Stopping one
19
- run leaves the others active.
14
+ Open the shell URL printed by the command. Blocks hot reload when their source files change. Each
15
+ run uses one port for the shell and all blocks. The default is `9873`. If that port is occupied, the
16
+ launcher selects the next available port. You can start multiple runs without choosing a port for
17
+ each run. Stopping one run leaves the others active.
20
18
 
21
19
  The shell and blocks keep separate browser origins through localhost subdomains:
22
20
 
@@ -24,42 +22,38 @@ The shell and blocks keep separate browser origins through localhost subdomains:
24
22
  - `http://chart.localhost:9873`: chart block
25
23
  - `http://table.localhost:9873`: table block
26
24
 
27
- Block capability keys, such as `"chart"` in `worker.customBlock("chart")`, become
28
- lowercase hostname labels. Unsupported characters become hyphens. The launcher
29
- shortens long labels and adds numeric suffixes when keys conflict.
25
+ Block capability keys, such as `"chart"` in `worker.customBlock("chart")`, become lowercase hostname
26
+ labels. Unsupported characters become hyphens. The launcher shortens long labels and adds numeric
27
+ suffixes when keys conflict.
30
28
 
31
- Chrome and Firefox resolve these localhost subdomains without setup. Older macOS
32
- Safari versions may need hostname setup. macOS 26 Tahoe fixed this resolution
33
- ([WebKit issue](https://bugs.webkit.org/show_bug.cgi?id=160504)). The launcher does
34
- not change hostnames on your system or install certificates.
29
+ Chrome and Firefox resolve these localhost subdomains without setup. Older macOS Safari versions may
30
+ need hostname setup. macOS 26 Tahoe fixed this resolution
31
+ ([WebKit issue](https://bugs.webkit.org/show_bug.cgi?id=160504)). The launcher does not change
32
+ hostnames on your system or install certificates.
35
33
 
36
- Install `@notionhq/custom-blocks-dev-shell` in the worker's `devDependencies`
37
- to pin its version. This also makes the reference docs available in
38
- `node_modules`. If you do not install it, the CLI fetches the latest version
39
- each time.
34
+ Install `@notionhq/custom-blocks-dev-shell` in the worker's `devDependencies` to pin its version.
35
+ This also makes the reference docs available in `node_modules`. If you do not install it, the CLI
36
+ fetches the latest version each time.
40
37
 
41
38
  ### Error surface
42
39
 
43
- The preview shows an error surface when a block cannot initialize or an
44
- uncaught runtime error prevents it from rendering. Use `Copy` to copy the
45
- error details or `Retry` to restart the preview.
40
+ The preview shows an error surface when a block cannot initialize or an uncaught runtime error
41
+ prevents it from rendering. Use `Copy` to copy the error details or `Retry` to restart the preview.
46
42
 
47
43
  ### Options
48
44
 
49
45
  - `[path]`: Select a worker directory instead of using the current directory.
50
- - `--port <port>`: Require this port for the whole run. If occupied, the command
51
- fails with an explanation. Omit this option to enable automatic fallback.
52
- - `-- --bind <capabilityKey>.<dataSourceKey>=<sampleDataFileName>`: Choose sample data.
53
- Repeat for multiple slots. The `--` is required for forwarding through `ntn`.
54
- See [bindings](./docs/bindings.md) for an example.
46
+ - `--port <port>`: Require this port for the whole run. If occupied, the command fails with an
47
+ explanation. Omit this option to enable automatic fallback.
48
+ - `-- --bind <capabilityKey>.<dataSourceKey>=<sampleDataFileName>`: Choose sample data. Repeat for
49
+ multiple slots. The `--` is required for forwarding through `ntn`. See
50
+ [bindings](./docs/bindings.md) for an example.
55
51
 
56
52
  ## Documentation
57
53
 
58
54
  These docs ship with the package and are available from `node_modules`:
59
55
 
60
- - [`docs/bindings.md`](./docs/bindings.md): Connect blocks to data sources.
61
- The page covers automatic mapping, compatibility, initialization, and live
62
- rebinding.
63
- - [`docs/data-sources.md`](./docs/data-sources.md): Define local data sources
64
- in `data/*.json`. The page covers value shapes, validation, and files
65
- generated from worker schemas.
56
+ - [`docs/bindings.md`](./docs/bindings.md): Connect blocks to data sources. The page covers
57
+ automatic mapping, compatibility, initialization, and live rebinding.
58
+ - [`docs/data-sources.md`](./docs/data-sources.md): Define local data sources in `data/*.json`. The
59
+ page covers value shapes, validation, and files generated from worker schemas.
package/docs/bindings.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # Dev shell bindings
2
2
 
3
- The dev shell previews your worker's custom blocks with local data from
4
- `data/*.json`. Each data source selects its file in this order:
3
+ The dev shell previews your worker's custom blocks with local data from `data/*.json`. Each data
4
+ source selects its file in this order:
5
5
 
6
6
  1. The explicit `--bind` selection.
7
7
  2. `data/worker_<dataSourceKey>.json`, if it exists.
8
8
  3. `data/<dataSourceKey>.json`, if it exists.
9
- 4. Otherwise, it stays unbound. The shell starts, but the block cannot initialize
10
- until you connect the source in **Data**.
9
+ 4. Otherwise, it stays unbound. The shell starts, but the block cannot initialize until you connect
10
+ the source in **Data**.
11
11
 
12
- An invalid explicit selection stops startup instead of falling back to another
13
- file. An empty file still takes precedence over later choices.
12
+ An invalid explicit selection stops startup instead of falling back to another file. An empty file
13
+ still takes precedence over later choices.
14
14
 
15
15
  ## Choose sample data
16
16
 
@@ -20,48 +20,43 @@ Use `--bind <capabilityKey>.<dataSourceKey>=<sampleDataFileName>` to choose a so
20
20
  ntn workers customblocks dev -- --bind task-board.tasks=sample_tasks.json
21
21
  ```
22
22
 
23
- This connects the `tasks` data source on `task-board` to `data/sample_tasks.json`.
24
- Use a filename from `data/`, including `.json`.
23
+ This connects the `tasks` data source on `task-board` to `data/sample_tasks.json`. Use a filename
24
+ from `data/`, including `.json`.
25
25
 
26
- Repeat `--bind` for additional data sources. Sources without an override keep
27
- their defaults. When running `custom-blocks-dev-shell` directly, omit the `--`
28
- separator.
26
+ Repeat `--bind` for additional data sources. Sources without an override keep their defaults. When
27
+ running `custom-blocks-dev-shell` directly, omit the `--` separator.
29
28
 
30
- An unknown target, duplicate target, or missing file stops startup.
31
- Invalid JSON or an invalid source file also stops startup.
29
+ An unknown target, duplicate target, or missing file stops startup. Invalid JSON or an invalid
30
+ source file also stops startup.
32
31
 
33
- The browser maps compatible properties automatically. Incomplete mappings do
34
- not stop the shell. Open **Data** to finish connecting the block.
35
- Empty rows are valid.
32
+ The browser maps compatible properties automatically. Incomplete mappings do not stop the shell.
33
+ Open **Data** to finish connecting the block. Empty rows are valid.
36
34
 
37
35
  ## Connecting data
38
36
 
39
- **Data** in the toolbar opens the bindings modal: one section
40
- per slot from the block's `worker.customBlock({ dataSources })` declaration,
41
- each with a source picker and a per-property mapping. The sources on offer
42
- are the ones in your worker's `data/*.json`
43
- (format: [`data-sources.md`](./data-sources.md)). The modal shows each slot
44
- and its property mappings.
37
+ **Data** in the toolbar opens the bindings modal: one section per slot from the block's
38
+ `worker.customBlock({ dataSources })` declaration, each with a source picker and a per-property
39
+ mapping. The sources on offer are the ones in your worker's `data/*.json` (format:
40
+ [`data-sources.md`](./data-sources.md)). The modal shows each slot and its property mappings.
45
41
 
46
- Properties map automatically when there is a unique source property with a
47
- matching key or name and the same type. Use the property pickers to adjust
48
- mappings. Selecting a different source resets its property mappings.
42
+ Properties map automatically when there is a unique source property with a matching key or name and
43
+ the same type. Use the property pickers to adjust mappings. Selecting a different source resets its
44
+ property mappings.
49
45
 
50
46
  ## Initialization & binding edits
51
47
 
52
- Once every slot is bound and every property mapped, the block initializes and
53
- renders. Saving binding changes restarts the block with the updated data.
54
- If initialization fails, fix the bindings and save.
48
+ Once every slot is bound and every property mapped, the block initializes and renders. Saving
49
+ binding changes restarts the block with the updated data. If initialization fails, fix the bindings
50
+ and save.
55
51
 
56
- Bindings last for the page load, per block: refresh the shell and every block
57
- returns to its CLI selection or filename default.
52
+ Bindings last for the page load, per block: refresh the shell and every block returns to its CLI
53
+ selection or filename default.
58
54
 
59
- The shell reads `data/*.json` once at spin-up. To pick up file edits,
60
- restart the dev-shell command; a browser refresh is not enough.
55
+ The shell reads `data/*.json` once at spin-up. To pick up file edits, restart the dev-shell command;
56
+ a browser refresh is not enough.
61
57
 
62
58
  ## Data view
63
59
 
64
- Click a data source in the sidebar to inspect its schema and rows, read-only.
65
- The shell shows exactly the sources in `data/`, nothing else. Sources
66
- bound to the selected block carry a green **Bound** pill; the pill follows
67
- the block selection, so switching blocks updates it.
60
+ Click a data source in the sidebar to inspect its schema and rows, read-only. The shell shows
61
+ exactly the sources in `data/`, nothing else. Sources bound to the selected block carry a green
62
+ **Bound** pill; the pill follows the block selection, so switching blocks updates it.
@@ -1,11 +1,10 @@
1
1
  # Dev-shell data sources
2
2
 
3
- Data sources come in kinds, marked by their `type`, and all live in the
4
- worker's `data/*.json` — one source per file, read at spin-up. The shell
5
- supports the following types today:
3
+ Data sources come in kinds, marked by their `type`, and all live in the worker's `data/*.json` — one
4
+ source per file, read at spin-up. The shell supports the following types today:
6
5
 
7
- - `worker` — hand-authored JSON files. This is how you give your blocks data,
8
- and what this document describes.
6
+ - `worker` — hand-authored JSON files. This is how you give your blocks data, and what this document
7
+ describes.
9
8
  - `manual` — sources a user creates themselves in the shell.
10
9
  - `built-in` — sources we provide.
11
10
 
@@ -36,18 +35,17 @@ For example, `data/tasks.json`:
36
35
  }
37
36
  ```
38
37
 
39
- - `type` — the source's kind. Hand-authored files declare `"worker"` (the
40
- default); the pre-built sources the shell adds carry `"built-in"`.
41
- - `name` — the label shown in the shell sidebar. If omitted, it defaults to
42
- the filename without `.json`.
38
+ - `type` — the source's kind. Hand-authored files declare `"worker"` (the default); the pre-built
39
+ sources the shell adds carry `"built-in"`.
40
+ - `name` — the label shown in the shell sidebar. If omitted, it defaults to the filename without
41
+ `.json`.
43
42
  - `icon` — optional emoji shown alongside the name.
44
- - `schema` — maps each property key to `{ name, type }`. If omitted, it defaults
45
- to `{}`. Use the same property keys and
46
- types the block declares. Types: `title`, `rich_text`, `number`, `select`,
47
- `multi_select`, `status`, `date`, `checkbox`, `url`, `email`,
48
- `phone_number`, `people`, `files`, `relation`.
49
- - `rows` — the source records. If omitted, it defaults to `[]`. Each row needs
50
- a unique string `id`. Store property values under their schema keys.
43
+ - `schema` — maps each property key to `{ name, type }`. If omitted, it defaults to `{}`. Use the
44
+ same property keys and types the block declares. Types: `title`, `rich_text`, `number`, `select`,
45
+ `multi_select`, `status`, `date`, `checkbox`, `url`, `email`, `phone_number`, `people`, `files`,
46
+ `relation`.
47
+ - `rows` — the source records. If omitted, it defaults to `[]`. Each row needs a unique string `id`.
48
+ Store property values under their schema keys.
51
49
 
52
50
  Value shapes by property type:
53
51
 
@@ -64,34 +62,32 @@ Value shapes by property type:
64
62
 
65
63
  ## Validation
66
64
 
67
- Files are validated at spin-up, before they reach the shell UI. A malformed
68
- file fails the run with the file and problem named, e.g.
69
- `data/tasks.json: rows.0.id: Invalid key: Expected "id" but received undefined`.
70
- The filename without `.json` is the source identity used by bindings and
71
- source pickers. Renaming a file changes its identity.
65
+ Files are validated at spin-up, before they reach the shell UI. A malformed file fails the run with
66
+ the file and problem named, e.g.
67
+ `data/tasks.json: rows.0.id: Invalid key: Expected "id" but received undefined`. The filename
68
+ without `.json` is the source identity used by bindings and source pickers. Renaming a file changes
69
+ its identity.
72
70
 
73
71
  ## Querying
74
72
 
75
- The shell applies filters, then ordered sorts, then the query limit. The SDK
76
- resolves semantic property keys to property IDs before it sends the query.
77
- Empty values stay last in both directions.
78
- Date-only and zone-less datetime values sort using UTC. Datetime values with a
79
- `time_zone` use that named zone, and an explicit offset in `start_time` wins.
73
+ The shell applies filters, then ordered sorts, then the query limit. The SDK resolves semantic
74
+ property keys to property IDs before it sends the query. Empty values stay last in both directions.
75
+ Date-only and zone-less datetime values sort using UTC. Datetime values with a `time_zone` use that
76
+ named zone, and an explicit offset in `start_time` wins.
80
77
 
81
78
  ## Materialization
82
79
 
83
- You don't have to write these files from scratch. At spin-up the shell
84
- materializes a file for every data source the worker declares — both
85
- `worker.database(...)` entries and inline `worker.customBlock({ dataSources })`
86
- schemas — that doesn't already have one: `data/worker_<key>.json`, the declared
87
- schema with empty `rows`, mirroring a managed database before any sync.
80
+ You don't have to write these files from scratch. At spin-up the shell materializes a file for every
81
+ data source the worker declares — both `worker.database(...)` entries and inline
82
+ `worker.customBlock({ dataSources })` schemas — that doesn't already have one:
83
+ `data/worker_<key>.json`, the declared schema with empty `rows`, mirroring a managed database before
84
+ any sync.
88
85
 
89
- - The `worker_` prefix on the filename namespaces generated files
90
- away from ones you author yourself, so both coexist; the display `name`
91
- stays as declared, so the sidebar shows the clean name.
92
- - Files are only ever written when absent: fill in `rows` freely and your
93
- edits survive restarts. Delete a generated file to regenerate it from the
94
- schema.
86
+ - The `worker_` prefix on the filename namespaces generated files away from ones you author
87
+ yourself, so both coexist; the display `name` stays as declared, so the sidebar shows the clean
88
+ name.
89
+ - Files are only ever written when absent: fill in `rows` freely and your edits survive restarts.
90
+ Delete a generated file to regenerate it from the schema.
95
91
 
96
92
  The shell shows exactly the sources in `data/`, nothing else.
97
93
 
@@ -104,11 +100,10 @@ ntn workers customblocks sample <url-or-data-source-id> \
104
100
  --out data/worker_tasks.json --row-only
105
101
  ```
106
102
 
107
- Run the dev shell once to create the generated file, then stop it before sampling.
108
- `--row-only` preserves the schema and appends rows with new IDs. Add `--overwrite`
109
- to replace existing rows.
103
+ Run the dev shell once to create the generated file, then stop it before sampling. `--row-only`
104
+ preserves the schema and appends rows with new IDs. Add `--overwrite` to replace existing rows.
110
105
 
111
- Sampled property keys must match the generated schema. If they differ, sample
112
- into a separate file and select it with [`--bind`](./bindings.md#choose-sample-data).
106
+ Sampled property keys must match the generated schema. If they differ, sample into a separate file
107
+ and select it with [`--bind`](./bindings.md#choose-sample-data).
113
108
 
114
109
  Restart the dev shell after sampling to load the updated data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-dev-shell",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "description": "Local preview shell for Notion custom block workers.",
5
5
  "license": "MIT",
6
6
  "type": "module",