@notionhq/custom-blocks-dev-shell 0.1.89 → 0.1.90

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/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Workers local shell</title>
7
- <script type="module" crossorigin src="/assets/index-BFm3afub.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-BEmDkyVk.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-B6v5FUFk.css">
9
9
  </head>
10
10
  <body>
@@ -14,6 +14,13 @@ const DEV_SHELL_DATA_SOURCE_TYPES = [
14
14
  "manual",
15
15
  "syncedFromProd",
16
16
  ];
17
+ const DEV_SHELL_STATUS_GROUP_NAMES = [
18
+ "To-do",
19
+ "In progress",
20
+ "Complete",
21
+ "Current",
22
+ "Future",
23
+ ];
17
24
  // Local copy of the SDK's NOTION_PROPERTY_TYPES: the compiled CLI runs under
18
25
  // plain node, which can't import the SDK's published TS source at runtime.
19
26
  // The `satisfies` below plus the type-only import keep the two lists locked
@@ -48,6 +55,8 @@ export const NOTION_PROPERTY_TYPES = [
48
55
  ];
49
56
  const _allPropertyTypesListed = true;
50
57
  void _allPropertyTypesListed;
58
+ const _allStatusGroupNamesListed = true;
59
+ void _allStatusGroupNamesListed;
51
60
  export function readDataSources(dataDir) {
52
61
  if (!existsSync(dataDir)) {
53
62
  return [];
@@ -58,14 +67,27 @@ export function readDataSources(dataDir) {
58
67
  .sort((left, right) => left.name.localeCompare(right.name));
59
68
  }
60
69
  const nonEmptyString = v.pipe(v.string(), v.nonEmpty());
70
+ const statusOptionsSchema = v.array(v.object({
71
+ id: nonEmptyString,
72
+ name: nonEmptyString,
73
+ }));
74
+ const statusGroupsSchema = v.array(v.object({
75
+ id: nonEmptyString,
76
+ name: v.picklist(DEV_SHELL_STATUS_GROUP_NAMES),
77
+ option_ids: v.array(nonEmptyString),
78
+ }));
79
+ const sourcePropertySchema = v.object({
80
+ name: v.optional(v.string()),
81
+ description: v.optional(v.string()),
82
+ type: v.picklist(NOTION_PROPERTY_TYPES),
83
+ options: v.optional(statusOptionsSchema),
84
+ groups: v.optional(statusGroupsSchema),
85
+ });
61
86
  export const sourceFileSchema = v.object({
62
87
  type: v.optional(v.picklist(DEV_SHELL_DATA_SOURCE_TYPES), "worker"),
63
88
  name: v.optional(nonEmptyString),
64
89
  icon: v.optional(v.string()),
65
- schema: v.optional(v.record(v.string(), v.object({
66
- name: v.optional(v.string()),
67
- type: v.picklist(NOTION_PROPERTY_TYPES),
68
- })), {}),
90
+ schema: v.optional(v.record(v.string(), sourcePropertySchema), {}),
69
91
  rows: v.optional(v.array(v.looseObject({ id: nonEmptyString })), []),
70
92
  });
71
93
  /**
@@ -90,6 +112,24 @@ function readSource(file) {
90
112
  const path = v.getDotPath(issue);
91
113
  throw new Error(`${file}: ${path ? `${path}: ` : ""}${issue.message}`);
92
114
  }
115
+ for (const [propertyKey, property] of Object.entries(result.output.schema)) {
116
+ if (property.options !== undefined &&
117
+ property.type !== "select" &&
118
+ property.type !== "multi_select" &&
119
+ property.type !== "status") {
120
+ throw new Error(`${file}: schema.${propertyKey}: options require a Select, Multi-select, or Status property`);
121
+ }
122
+ if (property.groups !== undefined && property.type !== "status") {
123
+ throw new Error(`${file}: schema.${propertyKey}: groups require a Status property`);
124
+ }
125
+ const optionIds = new Set((property.options ?? []).map(option => option.id));
126
+ const missingOptionId = (property.groups ?? [])
127
+ .flatMap(group => group.option_ids)
128
+ .find(optionId => !optionIds.has(optionId));
129
+ if (missingOptionId !== undefined) {
130
+ throw new Error(`${file}: schema.${propertyKey}: group references unknown option ID "${missingOptionId}"`);
131
+ }
132
+ }
93
133
  const { type, icon, schema, rows } = result.output;
94
134
  const filename = basename(file, ".json");
95
135
  return {
@@ -100,8 +140,28 @@ function readSource(file) {
100
140
  ...(icon !== undefined ? { icon } : {}),
101
141
  schema: Object.fromEntries(Object.entries(schema).map(([propertyKey, property]) => [
102
142
  propertyKey,
103
- { name: property.name ?? propertyKey, type: property.type },
143
+ toNotionPropertySchema(propertyKey, property),
104
144
  ])),
105
145
  rows,
106
146
  };
107
147
  }
148
+ function toNotionPropertySchema(propertyKey, property) {
149
+ const base = {
150
+ name: property.name ?? propertyKey,
151
+ ...(property.description !== undefined
152
+ ? { description: property.description }
153
+ : {}),
154
+ };
155
+ if (property.type === "select" || property.type === "multi_select") {
156
+ return { ...base, type: property.type, options: property.options ?? [] };
157
+ }
158
+ if (property.type === "status") {
159
+ return {
160
+ ...base,
161
+ type: "status",
162
+ options: property.options ?? [],
163
+ groups: property.groups ?? [],
164
+ };
165
+ }
166
+ return { ...base, type: property.type };
167
+ }
@@ -19,7 +19,12 @@ For example, `data/tasks.json`:
19
19
  "icon": "✅",
20
20
  "schema": {
21
21
  "title": { "name": "Title", "type": "title" },
22
- "status": { "name": "Status", "type": "select" },
22
+ "status": {
23
+ "name": "Status",
24
+ "type": "status",
25
+ "options": [{ "id": "todo", "name": "Not started" }],
26
+ "groups": [{ "id": "todo-group", "name": "To-do", "option_ids": ["todo"] }]
27
+ },
23
28
  "dueDate": { "name": "Due date", "type": "date" },
24
29
  "done": { "name": "Done", "type": "checkbox" }
25
30
  },
@@ -27,7 +32,7 @@ For example, `data/tasks.json`:
27
32
  {
28
33
  "id": "tasks-1",
29
34
  "title": "Ship the block",
30
- "status": "In progress",
35
+ "status": "Not started",
31
36
  "dueDate": { "type": "date", "start_date": "2026-08-01" },
32
37
  "done": false
33
38
  }
@@ -40,10 +45,10 @@ For example, `data/tasks.json`:
40
45
  - `name` — the label shown in the shell sidebar. If omitted, it defaults to the filename without
41
46
  `.json`.
42
47
  - `icon` — optional emoji shown alongside the name.
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`.
48
+ - `schema` — maps each property key to its runtime property schema. If omitted, it defaults to `{}`.
49
+ Use the same property keys and types the block declares. Status properties can include `options`
50
+ and `groups`. Types: `title`, `rich_text`, `number`, `select`, `multi_select`, `status`, `date`,
51
+ `checkbox`, `url`, `email`, `phone_number`, `people`, `files`, `relation`.
47
52
  - `rows` — the source records. If omitted, it defaults to `[]`. Each row needs a unique string `id`.
48
53
  Store property values under their schema keys.
49
54
 
@@ -75,6 +80,9 @@ property keys to property IDs before it sends the query. Empty values stay last
75
80
  Date-only and zone-less datetime values sort using UTC. Datetime values with a `time_zone` use that
76
81
  named zone, and an explicit offset in `start_time` wins.
77
82
 
83
+ Status group filters use each Status property's `options` and `groups`. Group `option_ids` must
84
+ reference option IDs from the same property.
85
+
78
86
  ## Materialization
79
87
 
80
88
  You don't have to write these files from scratch. At spin-up the shell materializes a file for every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-dev-shell",
3
- "version": "0.1.89",
3
+ "version": "0.1.90",
4
4
  "description": "Local preview shell for Notion custom block workers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,8 +34,8 @@
34
34
  "typescript": "^7.0.2",
35
35
  "vite": "^8.2.2",
36
36
  "vitest": "^5.0.0",
37
- "@notionhq/custom-blocks-protocol": "0.1.0",
38
- "@notionhq/custom-blocks-host": "0.2.3"
37
+ "@notionhq/custom-blocks-host": "0.2.4",
38
+ "@notionhq/custom-blocks-protocol": "0.1.0"
39
39
  },
40
40
  "scripts": {
41
41
  "dev": "vite",