@notionhq/custom-blocks-dev-shell 0.4.3 → 0.5.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 CHANGED
@@ -46,6 +46,9 @@ Install `@notionhq/custom-blocks-dev-shell` in the worker's `devDependencies` to
46
46
  This also makes the reference docs available in `node_modules`. If you do not install it, the CLI
47
47
  fetches the latest version each time.
48
48
 
49
+ Local previews require a Custom Blocks SDK that supports bridge protocol 12 or newer. Upgrade the
50
+ block's SDK if the preview reports an unsupported protocol version.
51
+
49
52
  ### Preview and workspace
50
53
 
51
54
  **Layout** previews the block on a page, in a database view, or as a full page. In **Block** layout,
@@ -67,47 +70,104 @@ ntn workers customblocks dev -- --json
67
70
  npx @notionhq/custom-blocks-dev-shell --json
68
71
  ```
69
72
 
70
- After the shell and block servers start, the launcher emits one JSON line. Logs and errors go to
71
- stderr. Example output, formatted for readability:
73
+ The launcher reports the startup outcome as one JSON line on stdout. Logs and human-readable errors
74
+ go to stderr. Example `ready` record, formatted for readability:
72
75
 
73
76
  ```json
74
77
  {
75
78
  "event": "ready",
79
+ "version": 1,
76
80
  "shellUrl": "http://localhost:9875",
77
81
  "workerDir": "/absolute/path/to/worker",
78
- "devShellVersion": "0.1.115",
82
+ "devShellVersion": "0.4.4",
83
+ "workerManifestPath": ".dev-shell/run-a1b2c3/worker_manifest.json",
79
84
  "customBlocks": [
80
85
  {
81
86
  "key": "task-board",
82
87
  "url": "http://task-board.localhost:9875/",
83
- "manifest": {
84
- "version": 1,
85
- "dataSources": {}
86
- },
87
- "sampleFilesByDataSource": {}
88
+ "bindings": {
89
+ "dataSources": {
90
+ "tasks": {
91
+ "status": "complete",
92
+ "sampleFile": "data/worker_tasks.json",
93
+ "propertyIdsByKey": { "title": "task_name" }
94
+ }
95
+ },
96
+ "pages": {
97
+ "brief": { "status": "unsupported" }
98
+ }
99
+ }
88
100
  }
89
101
  ]
90
102
  }
91
103
  ```
92
104
 
93
- URLs use the selected port and remain valid for the run. `workerDir` is absolute, and
94
- `devShellVersion` identifies the running package version. Each block includes its capability key,
95
- declared manifest, and selected sample files.
96
-
97
- `sampleFilesByDataSource` includes automatic selections and `--bind` overrides, with paths relative
98
- to `workerDir`. Slots without a selected file are omitted. The record is a startup snapshot, not a
99
- description of current browser property mappings. Later edits do not emit another record.
105
+ URLs use the selected port and remain valid for the run. `version` identifies the startup JSON
106
+ format, and `devShellVersion` identifies the running package version. Resolve `workerManifestPath`
107
+ and `sampleFile` relative to the absolute `workerDir`.
108
+
109
+ `workerManifestPath` points to the extracted worker manifest. The file can omit defaults the shell
110
+ applies, such as an empty `dataSources` map. Look up a block's capability key in `capabilities` to
111
+ find its `config.manifest`. Read the file during the run. The shell removes it when the run ends.
112
+
113
+ `bindings.dataSources` is keyed by the block's declared data source slots. It includes automatic
114
+ selections, `--bind-data-source` and `--bind-property` overrides, and unbound slots.
115
+ `bindings.pages` reports each declared page slot as `unsupported` because the preview does not
116
+ receive named page bindings. The `pages` field is omitted for blocks without page slots. Use
117
+ **Bindings → Page access** to inspect page selections for a block that declares page slots.
118
+
119
+ | Status | Meaning | Additional fields |
120
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
121
+ | `data_source_binding_missing` | The slot has no selected sample file. | |
122
+ | `data_source_load_failed` | The selected sample file failed to load or disappeared after `--bind-data-source` validation. | `sampleFile` and `message`. |
123
+ | `incomplete_property_bindings` | The sample file loaded, but at least one required property lacks a compatible binding. | `sampleFile`, `propertyIdsByKey`, and `propertyIssues`. |
124
+ | `complete` | The sample file loaded and every required property has a compatible binding. The file may have zero rows. | `sampleFile` and `propertyIdsByKey`. |
125
+
126
+ `propertyIdsByKey` maps declared property keys to the sample schema keys the shell selected. Each
127
+ entry in `propertyIssues` includes the declared `propertyKey` and its `expectedType`.
128
+
129
+ | Issue type | Meaning | Additional fields |
130
+ | ---------------------------- | ------------------------------------------------------------------------ | ------------------------------------- |
131
+ | `property_binding_missing` | No sample property matches the declared key or display name. | |
132
+ | `ambiguous_property_binding` | More than one compatible sample property matches by key or display name. | `candidateSampleKeys`. |
133
+ | `sample_key_not_found` | The explicitly selected sample key is absent from the sample schema. | `sampleKey`. |
134
+ | `property_type_mismatch` | The explicit selection or every automatic match has the wrong type. | `bindingMode` and `sampleProperties`. |
135
+
136
+ For `property_type_mismatch`, `bindingMode` is `explicit` for a `--bind-property` selection and
137
+ `automatic` for automatic matching. Each entry in `sampleProperties` includes `sampleKey` and
138
+ `actualType`. An explicit mismatch lists the selected property. An automatic mismatch lists all
139
+ properties that matched by key or display name.
140
+
141
+ Loaded sources include `errors` when sample values are invalid. Each error identifies the sample
142
+ column in `propertyId` and the affected rows in `rowIds`. A mapped column with values of the wrong
143
+ type reports `invalid_property_value` and includes `expectedType`. An unmapped column with an
144
+ unsupported value reports `unsupported_property_value`. The binding status still describes whether
145
+ the required properties have compatible mappings.
146
+
147
+ The record describes the initial bindings. Later edits in the shell do not emit another record.
100
148
 
101
149
  Read the record without waiting for process exit. `ready` confirms that the shell and every block
102
150
  URL returned HTTP 2xx. It does not confirm block rendering, data access, or complete bindings. The
103
- checks allow 10 seconds after server setup. On timeout, stderr names the URLs that did not respond
104
- successfully, and the process exits nonzero without a ready record.
151
+ checks allow 10 seconds after server setup.
152
+
153
+ If the launcher encounters an error before `ready`, it emits a `startup_failed` record and exits
154
+ nonzero. The record includes `version` and `error` with a machine-readable `code` and a
155
+ human-readable `message`.
156
+
157
+ | Code | Meaning |
158
+ | --------------------------- | --------------------------------------------------------------------------------------------------- |
159
+ | `invalid_arguments` | The launcher could not parse the command line arguments. |
160
+ | `preview_readiness_timeout` | One or more preview URLs did not return HTTP 2xx before the deadline. The message lists those URLs. |
161
+ | `startup_error` | The launcher encountered another startup error, such as a failed worker build. |
162
+
163
+ Invalid `--bind-data-source` and `--bind-property` values use the
164
+ [binding error codes](docs/bindings.md#binding-errors).
105
165
 
106
166
  ### Options
107
167
 
108
168
  ```bash
109
169
  ntn workers customblocks dev -- \
110
- --bind task-board.tasks=sample_tasks.json \
170
+ --bind-data-source task-board.tasks=sample_tasks.json \
111
171
  --bind-property task-board.tasks.title=task_name
112
172
  ```
113
173
 
@@ -119,8 +179,8 @@ The `--` separator is required to forward options through `ntn`. Omit it when ru
119
179
  [startup details for automation](#startup-details-for-automation).
120
180
  - `--port <port>`: Require this port for the whole run. If occupied, the command fails with an
121
181
  explanation. Omit this option to enable automatic fallback.
122
- - `--bind <capabilityKey>.<dataSourceKey>=<sampleDataFileName>`: Choose sample data. Repeat for
123
- multiple slots.
182
+ - `--bind-data-source <capabilityKey>.<dataSourceKey>=<sampleDataFileName>`: Choose sample data.
183
+ Repeat for multiple slots.
124
184
  - `--bind-property <capabilityKey>.<dataSourceKey>.<propertyKey>=<sourcePropertyKey>`: Map a block
125
185
  property to a sample schema property. Repeat for multiple properties. Explicit mappings override
126
186
  automatic matches.
@@ -142,9 +202,9 @@ Block responses enforce a production-like content security policy (CSP) and send
142
202
 
143
203
  - **Blocked features:** Native form submission, browser workers, `<object>`, `<embed>`, web app
144
204
  manifests, and `<base>`.
145
- - **Scripts and styles:** Bundled scripts, inline scripts, and inline styles work. Scripts loaded
146
- from a CDN at runtime are blocked. WebAssembly compilation is allowed; JavaScript string
147
- evaluation remains blocked.
205
+ - **Scripts and styles:** Bundled scripts and inline styles work. The dev shell blocks scripts that
206
+ remain inline after Vite processes the HTML, scripts from external origins, and JavaScript string
207
+ evaluation. WebAssembly compilation is allowed.
148
208
  - **Media and fonts:** Notion-hosted media and Google Fonts use the same exceptions as production.
149
209
  - **External access:** Network requests and nested frames can use HTTPS origins declared in the
150
210
  block's `network.fetch` grants. Browser CORS checks still apply.
@@ -79,8 +79,7 @@
79
79
  "website": "https://example.com/organizations/westfield-learning-center",
80
80
  "email": "westfield-learning-center@example.com",
81
81
  "last_contacted": {
82
- "type": "date",
83
- "start_date": "2026-11-13"
82
+ "start": "2026-11-13"
84
83
  }
85
84
  },
86
85
  {
@@ -98,8 +97,7 @@
98
97
  "website": "https://example.com/organizations/fieldwork-press",
99
98
  "email": "fieldwork-press@example.com",
100
99
  "last_contacted": {
101
- "type": "date",
102
- "start_date": "2026-11-12"
100
+ "start": "2026-11-12"
103
101
  }
104
102
  },
105
103
  {
@@ -117,8 +115,7 @@
117
115
  "website": "https://example.com/organizations/riverside-workshop",
118
116
  "email": "riverside-workshop@example.com",
119
117
  "last_contacted": {
120
- "type": "date",
121
- "start_date": "2026-11-10"
118
+ "start": "2026-11-10"
122
119
  }
123
120
  },
124
121
  {
@@ -150,8 +147,7 @@
150
147
  "needs": "Keep reading room terminals connected when a network link fails. Staff need a clear way to identify the failed connection.",
151
148
  "website": "https://example.com/organizations/county-records-office",
152
149
  "last_contacted": {
153
- "type": "date",
154
- "start_date": "2026-11-16"
150
+ "start": "2026-11-16"
155
151
  }
156
152
  },
157
153
  {
@@ -169,8 +165,7 @@
169
165
  "website": "https://example.com/organizations/evening-computing-school",
170
166
  "email": "evening-computing-school@example.com",
171
167
  "last_contacted": {
172
- "type": "date",
173
- "start_date": "2026-11-09"
168
+ "start": "2026-11-09"
174
169
  }
175
170
  },
176
171
  {
@@ -188,8 +183,7 @@
188
183
  "website": "https://example.com/organizations/local-history-museum",
189
184
  "email": "local-history-museum@example.com",
190
185
  "last_contacted": {
191
- "type": "date",
192
- "start_date": "2026-11-11"
186
+ "start": "2026-11-11"
193
187
  }
194
188
  },
195
189
  {
@@ -216,8 +210,7 @@
216
210
  "website": "https://example.com/organizations/workshop-cooperative",
217
211
  "email": "workshop-cooperative@example.com",
218
212
  "last_contacted": {
219
- "type": "date",
220
- "start_date": "2026-11-18"
213
+ "start": "2026-11-18"
221
214
  }
222
215
  },
223
216
  {
@@ -234,8 +227,7 @@
234
227
  "needs": "Recover locally saved interview notes after an interrupted session. Keep the original recording references with the restored draft.",
235
228
  "website": "https://example.com/organizations/community-history-archive",
236
229
  "last_contacted": {
237
- "type": "date",
238
- "start_date": "2026-11-18"
230
+ "start": "2026-11-18"
239
231
  }
240
232
  },
241
233
  {
@@ -253,8 +245,7 @@
253
245
  "website": "https://example.com/organizations/parkside-arts-center",
254
246
  "email": "parkside-arts-center@example.com",
255
247
  "last_contacted": {
256
- "type": "date",
257
- "start_date": "2026-11-19"
248
+ "start": "2026-11-19"
258
249
  }
259
250
  },
260
251
  {
@@ -277,8 +268,7 @@
277
268
  "owner": [],
278
269
  "value": 0,
279
270
  "last_contacted": {
280
- "type": "date",
281
- "start_date": "2026-10-14"
271
+ "start": "2026-10-14"
282
272
  },
283
273
  "needs": ""
284
274
  }
@@ -55,12 +55,9 @@
55
55
  "id": "meeting-1",
56
56
  "name": "Import format review",
57
57
  "when": {
58
- "type": "datetimerange",
59
- "start_date": "2026-11-05",
60
- "start_time": "10:00",
61
- "end_date": "2026-11-05",
62
- "end_time": "10:45",
63
- "time_zone": "America/Los_Angeles"
58
+ "start": "2026-11-05T10:00",
59
+ "end": "2026-11-05T10:45",
60
+ "timeZone": "America/Los_Angeles"
64
61
  },
65
62
  "attendees": [
66
63
  {
@@ -85,12 +82,9 @@
85
82
  "id": "meeting-2",
86
83
  "name": "Compiler error message review",
87
84
  "when": {
88
- "type": "datetimerange",
89
- "start_date": "2026-11-09",
90
- "start_time": "14:00",
91
- "end_date": "2026-11-09",
92
- "end_time": "14:30",
93
- "time_zone": "America/Los_Angeles"
85
+ "start": "2026-11-09T14:00",
86
+ "end": "2026-11-09T14:30",
87
+ "timeZone": "America/Los_Angeles"
94
88
  },
95
89
  "attendees": [
96
90
  {
@@ -110,12 +104,9 @@
110
104
  "id": "meeting-3",
111
105
  "name": "Shared editor pilot review",
112
106
  "when": {
113
- "type": "datetimerange",
114
- "start_date": "2026-11-12",
115
- "start_time": "11:00",
116
- "end_date": "2026-11-12",
117
- "end_time": "11:45",
118
- "time_zone": "America/Los_Angeles"
107
+ "start": "2026-11-12T11:00",
108
+ "end": "2026-11-12T11:45",
109
+ "timeZone": "America/Los_Angeles"
119
110
  },
120
111
  "attendees": [
121
112
  {
@@ -135,12 +126,9 @@
135
126
  "id": "meeting-4",
136
127
  "name": "Classroom workspace handoff",
137
128
  "when": {
138
- "type": "datetimerange",
139
- "start_date": "2026-11-13",
140
- "start_time": "09:30",
141
- "end_date": "2026-11-13",
142
- "end_time": "10:00",
143
- "time_zone": "America/Los_Angeles"
129
+ "start": "2026-11-13T09:30",
130
+ "end": "2026-11-13T10:00",
131
+ "timeZone": "America/Los_Angeles"
144
132
  },
145
133
  "attendees": [
146
134
  {
@@ -161,12 +149,9 @@
161
149
  "id": "meeting-5",
162
150
  "name": "Museum display replacement",
163
151
  "when": {
164
- "type": "datetimerange",
165
- "start_date": "2026-11-16",
166
- "start_time": "13:00",
167
- "end_date": "2026-11-16",
168
- "end_time": "13:30",
169
- "time_zone": "America/Los_Angeles"
152
+ "start": "2026-11-16T13:00",
153
+ "end": "2026-11-16T13:30",
154
+ "timeZone": "America/Los_Angeles"
170
155
  },
171
156
  "attendees": [
172
157
  {
@@ -182,12 +167,9 @@
182
167
  "id": "meeting-6",
183
168
  "name": "Network recovery test planning",
184
169
  "when": {
185
- "type": "datetimerange",
186
- "start_date": "2026-11-19",
187
- "start_time": "10:30",
188
- "end_date": "2026-11-19",
189
- "end_time": "11:15",
190
- "time_zone": "America/Los_Angeles"
170
+ "start": "2026-11-19T10:30",
171
+ "end": "2026-11-19T11:15",
172
+ "timeZone": "America/Los_Angeles"
191
173
  },
192
174
  "attendees": [
193
175
  {
@@ -215,12 +197,9 @@
215
197
  "id": "meeting-7",
216
198
  "name": "Drawing controls feedback",
217
199
  "when": {
218
- "type": "datetimerange",
219
- "start_date": "2026-11-23",
220
- "start_time": "15:00",
221
- "end_date": "2026-11-23",
222
- "end_time": "16:00",
223
- "time_zone": "America/Los_Angeles"
200
+ "start": "2026-11-23T15:00",
201
+ "end": "2026-11-23T16:00",
202
+ "timeZone": "America/Los_Angeles"
224
203
  },
225
204
  "attendees": [
226
205
  {
@@ -245,12 +224,9 @@
245
224
  "id": "meeting-8",
246
225
  "name": "File recovery handoff",
247
226
  "when": {
248
- "type": "datetimerange",
249
- "start_date": "2026-11-18",
250
- "start_time": "11:00",
251
- "end_date": "2026-11-18",
252
- "end_time": "11:30",
253
- "time_zone": "America/Los_Angeles"
227
+ "start": "2026-11-18T11:00",
228
+ "end": "2026-11-18T11:30",
229
+ "timeZone": "America/Los_Angeles"
254
230
  },
255
231
  "attendees": [
256
232
  {
@@ -270,12 +246,9 @@
270
246
  "id": "meeting-9",
271
247
  "name": "Library intake",
272
248
  "when": {
273
- "type": "datetimerange",
274
- "start_date": "2026-11-24",
275
- "start_time": "14:00",
276
- "end_date": "2026-11-24",
277
- "end_time": "14:45",
278
- "time_zone": "America/Los_Angeles"
249
+ "start": "2026-11-24T14:00",
250
+ "end": "2026-11-24T14:45",
251
+ "timeZone": "America/Los_Angeles"
279
252
  },
280
253
  "attendees": [
281
254
  {
@@ -290,12 +263,9 @@
290
263
  "id": "meeting-10",
291
264
  "name": "Archive search relevance review",
292
265
  "when": {
293
- "type": "datetimerange",
294
- "start_date": "2026-11-25",
295
- "start_time": "10:00",
296
- "end_date": "2026-11-25",
297
- "end_time": "10:45",
298
- "time_zone": "America/Los_Angeles"
266
+ "start": "2026-11-25T10:00",
267
+ "end": "2026-11-25T10:45",
268
+ "timeZone": "America/Los_Angeles"
299
269
  },
300
270
  "attendees": [
301
271
  {
@@ -316,12 +286,9 @@
316
286
  "id": "meeting-11",
317
287
  "name": "Web publishing scope",
318
288
  "when": {
319
- "type": "datetimerange",
320
- "start_date": "2026-12-01",
321
- "start_time": "13:30",
322
- "end_date": "2026-12-01",
323
- "end_time": "14:15",
324
- "time_zone": "America/Los_Angeles"
289
+ "start": "2026-12-01T13:30",
290
+ "end": "2026-12-01T14:15",
291
+ "timeZone": "America/Los_Angeles"
325
292
  },
326
293
  "attendees": [
327
294
  {
@@ -345,12 +312,9 @@
345
312
  "id": "meeting-12",
346
313
  "name": "Field computer hardware review",
347
314
  "when": {
348
- "type": "datetimerange",
349
- "start_date": "2026-12-03",
350
- "start_time": "09:00",
351
- "end_date": "2026-12-03",
352
- "end_time": "09:30",
353
- "time_zone": "America/Los_Angeles"
315
+ "start": "2026-12-03T09:00",
316
+ "end": "2026-12-03T09:30",
317
+ "timeZone": "America/Los_Angeles"
354
318
  },
355
319
  "attendees": [
356
320
  {
@@ -374,12 +338,9 @@
374
338
  "id": "meeting-13",
375
339
  "name": "Shared editor working session",
376
340
  "when": {
377
- "type": "datetimerange",
378
- "start_date": "2026-11-20",
379
- "start_time": "09:00",
380
- "end_date": "2026-11-20",
381
- "end_time": "10:30",
382
- "time_zone": "America/Los_Angeles"
341
+ "start": "2026-11-20T09:00",
342
+ "end": "2026-11-20T10:30",
343
+ "timeZone": "America/Los_Angeles"
383
344
  },
384
345
  "attendees": [
385
346
  {
@@ -411,12 +372,9 @@
411
372
  "id": "meeting-14",
412
373
  "name": "Editor pilot feedback",
413
374
  "when": {
414
- "type": "datetimerange",
415
- "start_date": "2026-12-01",
416
- "start_time": "11:00",
417
- "end_date": "2026-12-01",
418
- "end_time": "11:30",
419
- "time_zone": "America/Los_Angeles"
375
+ "start": "2026-12-01T11:00",
376
+ "end": "2026-12-01T11:30",
377
+ "timeZone": "America/Los_Angeles"
420
378
  },
421
379
  "attendees": [
422
380
  {
@@ -435,12 +393,9 @@
435
393
  "id": "meeting-15",
436
394
  "name": "Compiler documentation review",
437
395
  "when": {
438
- "type": "datetimerange",
439
- "start_date": "2026-12-03",
440
- "start_time": "14:00",
441
- "end_date": "2026-12-03",
442
- "end_time": "14:30",
443
- "time_zone": "America/Los_Angeles"
396
+ "start": "2026-12-03T14:00",
397
+ "end": "2026-12-03T14:30",
398
+ "timeZone": "America/Los_Angeles"
444
399
  },
445
400
  "attendees": [
446
401
  {
@@ -464,12 +419,9 @@
464
419
  "id": "meeting-16",
465
420
  "name": "Weekly planning",
466
421
  "when": {
467
- "type": "datetimerange",
468
- "start_date": "2026-11-30",
469
- "start_time": "09:30",
470
- "end_date": "2026-11-30",
471
- "end_time": "10:00",
472
- "time_zone": "America/Los_Angeles"
422
+ "start": "2026-11-30T09:30",
423
+ "end": "2026-11-30T10:00",
424
+ "timeZone": "America/Los_Angeles"
473
425
  },
474
426
  "attendees": [
475
427
  {
@@ -504,12 +456,9 @@
504
456
  "id": "meeting-17",
505
457
  "name": "Print shop discovery call",
506
458
  "when": {
507
- "type": "datetimerange",
508
- "start_date": "2026-12-04",
509
- "start_time": "13:00",
510
- "end_date": "2026-12-04",
511
- "end_time": "13:30",
512
- "time_zone": "America/Los_Angeles"
459
+ "start": "2026-12-04T13:00",
460
+ "end": "2026-12-04T13:30",
461
+ "timeZone": "America/Los_Angeles"
513
462
  },
514
463
  "attendees": [],
515
464
  "type": "Customer interview",