@notionhq/custom-blocks 0.2.22 β 0.2.24
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/bridge/dataSources/query.d.ts.map +1 -1
- package/dist/bridge/dataSources/query.js +10 -1
- package/dist/bridge/dataSources/resolveProperty.d.ts +3 -3
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolveProperty.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/protocol/manifest.d.ts +10 -3
- package/dist/protocol/manifest.js +5 -1
- package/dist/protocol/messages/connect.d.ts +9 -2
- package/dist/protocol/messages/createPage.d.ts +28 -0
- package/dist/protocol/messages/createPage.js +2 -2
- package/dist/protocol/messages/createPageResult.d.ts +28 -0
- package/dist/protocol/messages/getPage.d.ts +28 -0
- package/dist/protocol/messages/hostToSandbox.d.ts +93 -2
- package/dist/protocol/messages/init.d.ts +9 -2
- package/dist/protocol/messages/queryDataSource.d.ts +41 -0
- package/dist/protocol/messages/queryDataSource.js +13 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +79 -2
- package/dist/protocol/messages/updatePage.d.ts +28 -0
- package/dist/protocol/messages/updatePage.js +2 -2
- package/dist/protocol/messages/updatePageResult.d.ts +28 -0
- package/dist/protocol/pages/page.d.ts +89 -2
- package/dist/protocol/pages/page.js +33 -2
- package/dist/types.d.ts +6 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/data-sources.md +46 -30
- package/docs/errors.md +1 -2
- package/docs/lifecycle.md +1 -1
- package/docs/pages.md +10 -11
- package/package.json +1 -1
- package/src/bridge/dataSources/query.ts +13 -0
- package/src/bridge/dataSources/resolveProperty.ts +4 -4
- package/src/index.ts +1 -0
- package/src/types.ts +7 -2
package/docs/lifecycle.md
CHANGED
|
@@ -30,7 +30,7 @@ The initialization promise resolves after the SDK applies the host state. Await
|
|
|
30
30
|
code that reads initialized state. The SDK sends `initResult` after the initial render.
|
|
31
31
|
|
|
32
32
|
- The SDK waits for the host to respond with `init` or `init.error`, without an SDK-local timeout.
|
|
33
|
-
Host-owned timeout errors such as `
|
|
33
|
+
Host-owned timeout errors such as `initial_state_timeout` reject the promise with
|
|
34
34
|
`CustomBlockInitializationError`.
|
|
35
35
|
- If a matching `init` is malformed, the SDK sends `initResult.error` with code
|
|
36
36
|
`invalid_init_payload` and rejects with the same structured error.
|
package/docs/pages.md
CHANGED
|
@@ -193,8 +193,7 @@ Do **not** send `{ type: "file_upload", file_upload: { id } }`; the host will re
|
|
|
193
193
|
This table shows property support for custom blocks running in Notion.
|
|
194
194
|
|
|
195
195
|
- **Read value** shows `page.properties` in responses from `pages.get`, `pages.create`, and
|
|
196
|
-
`pages.update`.
|
|
197
|
-
from `page.properties`.
|
|
196
|
+
`pages.update`. Unsupported property types are omitted from `page.properties`.
|
|
198
197
|
- **Create** covers property writes through `pages.create`.
|
|
199
198
|
- **Update** covers property writes through `pages.update`.
|
|
200
199
|
|
|
@@ -228,12 +227,12 @@ and a property in its schema.
|
|
|
228
227
|
| `rollup` | π΄ Unavailable | π΄ Unavailable | π΄ Unavailable |
|
|
229
228
|
| `button` | π΄ Unavailable | π΄ Unavailable | π΄ Unavailable |
|
|
230
229
|
| `verification` | π΄ Unavailable | π΄ Unavailable | π΄ Unavailable |
|
|
231
|
-
| `last_visited_time` |
|
|
230
|
+
| `last_visited_time` | π‘ Current viewerβs ISO timestamp | π΄ Unavailable | π΄ Unavailable |
|
|
232
231
|
| `location` | π΄ Unavailable | π΄ Unavailable | π΄ Unavailable |
|
|
233
|
-
| `created_time` |
|
|
234
|
-
| `last_edited_time` |
|
|
235
|
-
| `created_by` |
|
|
236
|
-
| `last_edited_by` |
|
|
232
|
+
| `created_time` | π’ ISO timestamp in UTC | π΄ Unavailable | π΄ Unavailable |
|
|
233
|
+
| `last_edited_time` | π’ ISO timestamp in UTC | π΄ Unavailable | π΄ Unavailable |
|
|
234
|
+
| `created_by` | π’ Actor record pointer | π΄ Unavailable | π΄ Unavailable |
|
|
235
|
+
| `last_edited_by` | π’ Actor record pointer | π΄ Unavailable | π΄ Unavailable |
|
|
237
236
|
|
|
238
237
|
### Notes
|
|
239
238
|
|
|
@@ -248,10 +247,9 @@ and a property in its schema.
|
|
|
248
247
|
source. Create/update responses include link items only. File writes accept `external` URLs and
|
|
249
248
|
existing `file` URLs and store them as links. Upload references (`file_upload`) are unsupported.
|
|
250
249
|
- Relation writes replace the value and reject `has_more: true`.
|
|
251
|
-
- `created_time` and `last_edited_time`
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
formula, rollup, unique ID, or the other omitted types.
|
|
250
|
+
- Top-level `created_time` and `last_edited_time` remain available independently of schema
|
|
251
|
+
properties.
|
|
252
|
+
- Formula, rollup, unique ID, and other omitted types do not return structured page values.
|
|
255
253
|
|
|
256
254
|
For flattened query values, filters, and sorts, see
|
|
257
255
|
[Data source property support](./data-sources.md#property-support).
|
|
@@ -269,6 +267,7 @@ For flattened query values, filters, and sorts, see
|
|
|
269
267
|
`pages.update` (may omit `id` for `create`).
|
|
270
268
|
- `NotionPagePropertyInputMap` β input map for `pages.create` (keys can be raw property IDs, or
|
|
271
269
|
semantic keys when creating into a mapped data source).
|
|
270
|
+
- `NotionPagePropertyReadMap`: maps property IDs to returned property values.
|
|
272
271
|
- `NotionPagePropertyWriteMap` β input map for `pages.update` (raw property IDs only).
|
|
273
272
|
- `NotionCreatePagePosition` β `start` / `end` / `before` / `after` insertion variants.
|
|
274
273
|
- `OpenPageMode` β `"side_peek"` / `"center_peek"`.
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
customBlockNumberFilterOperatorSchema,
|
|
12
12
|
customBlockOptionFilterOperatorSchema,
|
|
13
13
|
customBlockPeopleFilterOperatorSchema,
|
|
14
|
+
customBlockRelationFilterOperatorSchema,
|
|
14
15
|
customBlockRelativeDateValueSchema,
|
|
15
16
|
customBlockStatusFilterOperatorSchema,
|
|
16
17
|
customBlockTextFilterOperatorSchema,
|
|
@@ -479,6 +480,18 @@ function resolvePropertyFilterBranch(args: {
|
|
|
479
480
|
return resolveDatePropertyFilter(args.propertyId, args.value)
|
|
480
481
|
case "created_by":
|
|
481
482
|
return resolveCreatedByPropertyFilter(args.propertyId, args.value)
|
|
483
|
+
case "relation": {
|
|
484
|
+
const parsed = v.safeParse(
|
|
485
|
+
customBlockRelationFilterOperatorSchema,
|
|
486
|
+
args.value,
|
|
487
|
+
)
|
|
488
|
+
return parsed.success
|
|
489
|
+
? {
|
|
490
|
+
status: "ok",
|
|
491
|
+
filter: { propertyId: args.propertyId, relation: parsed.output },
|
|
492
|
+
}
|
|
493
|
+
: invalidOperator("relation")
|
|
494
|
+
}
|
|
482
495
|
case "people":
|
|
483
496
|
return resolvePeoplePropertyFilter(args.propertyId, args.value)
|
|
484
497
|
default:
|
|
@@ -3,13 +3,13 @@ import type {
|
|
|
3
3
|
CustomBlockPropertyErrorCode,
|
|
4
4
|
CustomBlockPropertyErrorInfo,
|
|
5
5
|
} from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
|
|
6
|
-
import type {
|
|
6
|
+
import type { CreatePageMessage } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
7
7
|
import { notionPagePropertyValueSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
8
8
|
import * as v from "valibot"
|
|
9
9
|
import type { NotionPagePropertyInputMap } from "../../types.js"
|
|
10
10
|
|
|
11
11
|
export type PropertyWriteMapResolutionResult =
|
|
12
|
-
| { status: "success"; properties:
|
|
12
|
+
| { status: "success"; properties: CreatePageMessage["properties"] }
|
|
13
13
|
| { status: "error"; error: CustomBlockPropertyErrorInfo }
|
|
14
14
|
|
|
15
15
|
function makePropertyError(
|
|
@@ -24,7 +24,7 @@ function makePropertyError(
|
|
|
24
24
|
*
|
|
25
25
|
* Identifiers in `properties` may be raw property IDs or data source property keys; the latter
|
|
26
26
|
* are looked up in the `dataSource`'s `propertyIdsByKey`. Each value is re-parsed through
|
|
27
|
-
*
|
|
27
|
+
* the page property value schema with its `id` rewritten to the resolved property ID.
|
|
28
28
|
*/
|
|
29
29
|
export function resolvePropertyWriteMapForDataSource(args: {
|
|
30
30
|
dataSource: NotionDataSource | undefined
|
|
@@ -33,7 +33,7 @@ export function resolvePropertyWriteMapForDataSource(args: {
|
|
|
33
33
|
}): PropertyWriteMapResolutionResult {
|
|
34
34
|
const { dataSource, properties, operationName } = args
|
|
35
35
|
|
|
36
|
-
const resolvedProperties:
|
|
36
|
+
const resolvedProperties: CreatePageMessage["properties"] = {}
|
|
37
37
|
for (const [identifier, value] of Object.entries(properties)) {
|
|
38
38
|
const propertyIdResult = resolvePropertyIdentifierForDataSource({
|
|
39
39
|
dataSource,
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -39,6 +39,7 @@ import type {
|
|
|
39
39
|
CustomBlockOptionFilterOperator,
|
|
40
40
|
CustomBlockPeopleFilterOperator,
|
|
41
41
|
CustomBlockPersonFilterValue,
|
|
42
|
+
CustomBlockRelationFilterOperator,
|
|
42
43
|
CustomBlockStatusFilterOperator,
|
|
43
44
|
CustomBlockTextFilterOperator,
|
|
44
45
|
} from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
@@ -51,7 +52,7 @@ import type {
|
|
|
51
52
|
import type {
|
|
52
53
|
NotionPageCover,
|
|
53
54
|
NotionPageIcon,
|
|
54
|
-
|
|
55
|
+
NotionPagePropertyWriteMap,
|
|
55
56
|
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
56
57
|
|
|
57
58
|
import type { ExclusiveUnion } from "./typeUtils.js"
|
|
@@ -82,7 +83,7 @@ export type {
|
|
|
82
83
|
* from the map key before sending the bridge message.
|
|
83
84
|
*/
|
|
84
85
|
export type NotionPagePropertyInputValue =
|
|
85
|
-
|
|
86
|
+
NotionPagePropertyWriteMap[string] extends infer PropertyValue
|
|
86
87
|
? PropertyValue extends { id: string }
|
|
87
88
|
? Omit<PropertyValue, "id"> & { id?: string }
|
|
88
89
|
: never
|
|
@@ -152,6 +153,9 @@ export type NotionDataSourcePersonFilterValue = CustomBlockPersonFilterValue
|
|
|
152
153
|
export type NotionDataSourcePeopleFilterOperator =
|
|
153
154
|
ExclusiveUnion<CustomBlockPeopleFilterOperator>
|
|
154
155
|
|
|
156
|
+
export type NotionDataSourceRelationFilterOperator =
|
|
157
|
+
ExclusiveUnion<CustomBlockRelationFilterOperator>
|
|
158
|
+
|
|
155
159
|
export type NotionDataSourcePropertyAddress =
|
|
156
160
|
| { key: string; propertyId?: never }
|
|
157
161
|
| { propertyId: string; key?: never }
|
|
@@ -170,6 +174,7 @@ export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress &
|
|
|
170
174
|
| { status: NotionDataSourceStatusFilterOperator }
|
|
171
175
|
| { date: NotionDataSourceDateFilterOperator }
|
|
172
176
|
| { people: NotionDataSourcePeopleFilterOperator }
|
|
177
|
+
| { relation: NotionDataSourceRelationFilterOperator }
|
|
173
178
|
| { created_by: NotionDataSourceCreatedByFilterOperator }
|
|
174
179
|
>
|
|
175
180
|
|