@notionhq/custom-blocks-host 0.4.1 → 0.4.2
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/compatibility/pageForProtocol3To5.d.ts +3 -3
- package/dist/compatibility/pageForProtocol3To5.d.ts.map +1 -1
- package/dist/compatibility/pageWithNullTextFallbackProperties.d.ts +2 -2
- package/dist/compatibility/pageWithNullTextFallbackProperties.d.ts.map +1 -1
- package/dist/protocol/messages/createPageResult.js +3 -3
- package/dist/protocol/messages/getPage.js +3 -3
- package/dist/protocol/messages/queryDataSourceResult.js +3 -6
- package/dist/protocol/messages/updatePageResult.js +3 -3
- package/dist/protocol/pages/page.d.ts +2 -2
- package/dist/protocol/pages/page.js +1 -1
- package/docs/bridge/protocol.md +4 -4
- package/docs/handlers.md +2 -2
- package/package.json +1 -1
- package/src/compatibility/pageForProtocol3To5.ts +3 -3
- package/src/compatibility/pageWithNullTextFallbackProperties.ts +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { bridgePageSchema, NotionPageForProtocol3To5 } from "../protocol/pages/page.js";
|
|
2
2
|
import type { InferOutput } from "valibot";
|
|
3
3
|
/**
|
|
4
4
|
* Converts current page data to the page-operation format used by protocols 3–5.
|
|
@@ -8,7 +8,7 @@ import type { InferOutput } from "valibot";
|
|
|
8
8
|
*
|
|
9
9
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
10
10
|
*/
|
|
11
|
-
export declare function toPageForProtocol3To5(page: InferOutput<typeof
|
|
11
|
+
export declare function toPageForProtocol3To5(page: InferOutput<typeof bridgePageSchema>): NotionPageForProtocol3To5;
|
|
12
12
|
/**
|
|
13
13
|
* Converts a current page to a protocol 3–5 query row, keeping its ID and archive
|
|
14
14
|
* flags while flattening typed property objects into raw-ID-keyed values.
|
|
@@ -17,7 +17,7 @@ export declare function toPageForProtocol3To5(page: InferOutput<typeof notionPag
|
|
|
17
17
|
*
|
|
18
18
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
19
19
|
*/
|
|
20
|
-
export declare function toQueryPageForProtocol3To5(page: InferOutput<typeof
|
|
20
|
+
export declare function toQueryPageForProtocol3To5(page: InferOutput<typeof bridgePageSchema>): {
|
|
21
21
|
id: string & import("valibot").Brand<"NotionPageId">;
|
|
22
22
|
is_archived: boolean;
|
|
23
23
|
in_trash: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageForProtocol3To5.d.ts","sourceRoot":"","sources":["../../src/compatibility/pageForProtocol3To5.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,yBAAyB,EAEzB,
|
|
1
|
+
{"version":3,"file":"pageForProtocol3To5.d.ts","sourceRoot":"","sources":["../../src/compatibility/pageForProtocol3To5.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAChB,yBAAyB,EAEzB,MAAM,gDAAgD,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAI1C;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,WAAW,CAAC,OAAO,gBAAgB,CAAC,GACxC,yBAAyB,CAe3B;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,WAAW,CAAC,OAAO,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsB1C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { bridgePageSchema } from "../protocol/pages/page.js";
|
|
2
2
|
import type { InferOutput } from "valibot";
|
|
3
3
|
/**
|
|
4
4
|
* Shared field conversion for receivers that cannot decode text fallback objects.
|
|
5
5
|
*
|
|
6
6
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 7.
|
|
7
7
|
*/
|
|
8
|
-
export declare function toPageWithNullTextFallbackProperties(page: InferOutput<typeof
|
|
8
|
+
export declare function toPageWithNullTextFallbackProperties(page: InferOutput<typeof bridgePageSchema>): InferOutput<typeof bridgePageSchema>;
|
|
9
9
|
//# sourceMappingURL=pageWithNullTextFallbackProperties.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageWithNullTextFallbackProperties.d.ts","sourceRoot":"","sources":["../../src/compatibility/pageWithNullTextFallbackProperties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pageWithNullTextFallbackProperties.d.ts","sourceRoot":"","sources":["../../src/compatibility/pageWithNullTextFallbackProperties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAA;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;GAIG;AACH,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,WAAW,CAAC,OAAO,gBAAgB,CAAC,GACxC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAyCtC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { bridgePageSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
|
|
3
3
|
// The schema accepts any string code. The type lists known codes for
|
|
4
4
|
// autocomplete, with an open string fallback for newer senders.
|
|
5
5
|
export const customBlockCreatePageErrorCodeSchema = v.string();
|
|
@@ -17,7 +17,7 @@ export const createPageResultMessageSchema = v.variant("status", [
|
|
|
17
17
|
requestId: v.string(),
|
|
18
18
|
status: v.literal("success"),
|
|
19
19
|
/** The newly created page. */
|
|
20
|
-
page:
|
|
20
|
+
page: bridgePageSchema,
|
|
21
21
|
}),
|
|
22
22
|
v.object({
|
|
23
23
|
type: v.literal("createPageResult"),
|
|
@@ -32,7 +32,7 @@ export const createPageResultMessageWithProtocol3To5CompatibilitySchema = v.vari
|
|
|
32
32
|
requestId: v.string(),
|
|
33
33
|
status: v.literal("success"),
|
|
34
34
|
/** The newly created page. */
|
|
35
|
-
page: v.union([
|
|
35
|
+
page: v.union([bridgePageSchema, notionPageForProtocol3To5Schema]),
|
|
36
36
|
}),
|
|
37
37
|
v.object({
|
|
38
38
|
type: v.literal("createPageResult"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
|
|
3
|
-
import {
|
|
3
|
+
import { bridgePageSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
|
|
4
4
|
// The schema accepts any string code. The type lists known codes for
|
|
5
5
|
// autocomplete, with an open string fallback for newer senders.
|
|
6
6
|
export const customBlockGetPageErrorCodeSchema = v.string();
|
|
@@ -23,7 +23,7 @@ export const getPageResultMessageSchema = v.variant("status", [
|
|
|
23
23
|
type: v.literal("getPageResult"),
|
|
24
24
|
requestId: v.string(),
|
|
25
25
|
status: v.literal("success"),
|
|
26
|
-
page:
|
|
26
|
+
page: bridgePageSchema,
|
|
27
27
|
}),
|
|
28
28
|
v.object({
|
|
29
29
|
type: v.literal("getPageResult"),
|
|
@@ -37,7 +37,7 @@ export const getPageResultMessageWithProtocol3To5CompatibilitySchema = v.variant
|
|
|
37
37
|
type: v.literal("getPageResult"),
|
|
38
38
|
requestId: v.string(),
|
|
39
39
|
status: v.literal("success"),
|
|
40
|
-
page: v.union([
|
|
40
|
+
page: v.union([bridgePageSchema, notionPageForProtocol3To5Schema]),
|
|
41
41
|
}),
|
|
42
42
|
v.object({
|
|
43
43
|
type: v.literal("getPageResult"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionDataSourcePageForProtocol3To5Schema } from "../dataSources/dataSourcePage.js";
|
|
3
|
-
import {
|
|
3
|
+
import { bridgePageSchema } from "../pages/page.js";
|
|
4
4
|
// The schema accepts any string code. The type lists known codes for
|
|
5
5
|
// autocomplete, with an open string fallback for newer senders.
|
|
6
6
|
export const customBlockQueryDataSourceErrorCodeSchema = v.string();
|
|
@@ -17,7 +17,7 @@ export const queryDataSourceResultMessageSchema = v.variant("status", [
|
|
|
17
17
|
type: v.literal("queryDataSourceResult"),
|
|
18
18
|
subscriptionId: v.string(),
|
|
19
19
|
status: v.literal("success"),
|
|
20
|
-
items: v.array(
|
|
20
|
+
items: v.array(bridgePageSchema),
|
|
21
21
|
hasMore: v.boolean(),
|
|
22
22
|
}),
|
|
23
23
|
v.object({
|
|
@@ -32,10 +32,7 @@ export const queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = v
|
|
|
32
32
|
type: v.literal("queryDataSourceResult"),
|
|
33
33
|
subscriptionId: v.string(),
|
|
34
34
|
status: v.literal("success"),
|
|
35
|
-
items: v.array(v.union([
|
|
36
|
-
notionPageDataSchema,
|
|
37
|
-
notionDataSourcePageForProtocol3To5Schema,
|
|
38
|
-
])),
|
|
35
|
+
items: v.array(v.union([bridgePageSchema, notionDataSourcePageForProtocol3To5Schema])),
|
|
39
36
|
hasMore: v.boolean(),
|
|
40
37
|
}),
|
|
41
38
|
v.object({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { bridgePageSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
|
|
3
3
|
// The schema accepts any string code. The type lists known codes for
|
|
4
4
|
// autocomplete, with an open string fallback for newer senders.
|
|
5
5
|
export const customBlockUpdatePageErrorCodeSchema = v.string();
|
|
@@ -16,7 +16,7 @@ export const updatePageResultMessageSchema = v.variant("status", [
|
|
|
16
16
|
type: v.literal("updatePageResult"),
|
|
17
17
|
requestId: v.string(),
|
|
18
18
|
status: v.literal("success"),
|
|
19
|
-
page:
|
|
19
|
+
page: bridgePageSchema,
|
|
20
20
|
}),
|
|
21
21
|
v.object({
|
|
22
22
|
type: v.literal("updatePageResult"),
|
|
@@ -30,7 +30,7 @@ export const updatePageResultMessageWithProtocol3To5CompatibilitySchema = v.vari
|
|
|
30
30
|
type: v.literal("updatePageResult"),
|
|
31
31
|
requestId: v.string(),
|
|
32
32
|
status: v.literal("success"),
|
|
33
|
-
page: v.union([
|
|
33
|
+
page: v.union([bridgePageSchema, notionPageForProtocol3To5Schema]),
|
|
34
34
|
}),
|
|
35
35
|
v.object({
|
|
36
36
|
type: v.literal("updatePageResult"),
|
|
@@ -848,7 +848,7 @@ export type NotionPagePropertyWriteMap = v.InferInput<typeof notionPagePropertyW
|
|
|
848
848
|
/**
|
|
849
849
|
* The `Page` object returned in `createPageResult` messages.
|
|
850
850
|
*/
|
|
851
|
-
export declare const
|
|
851
|
+
export declare const bridgePageSchema: v.ObjectSchema<{
|
|
852
852
|
readonly object: v.LiteralSchema<"page", undefined>;
|
|
853
853
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
854
854
|
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -1138,7 +1138,7 @@ export declare const notionPageDataSchema: v.ObjectSchema<{
|
|
|
1138
1138
|
/** Whether the page or an ancestor is in Trash. */
|
|
1139
1139
|
readonly in_trash: v.BooleanSchema<undefined>;
|
|
1140
1140
|
}, undefined>;
|
|
1141
|
-
export type
|
|
1141
|
+
export type BridgePage = v.InferInput<typeof bridgePageSchema>;
|
|
1142
1142
|
export declare const notionPageForProtocol3To5Schema: v.ObjectSchema<{
|
|
1143
1143
|
readonly object: v.LiteralSchema<"page", undefined>;
|
|
1144
1144
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
@@ -281,7 +281,7 @@ export const notionPagePropertyReadMapSchema = v.record(v.string(), v.nullable(n
|
|
|
281
281
|
/**
|
|
282
282
|
* The `Page` object returned in `createPageResult` messages.
|
|
283
283
|
*/
|
|
284
|
-
export const
|
|
284
|
+
export const bridgePageSchema = v.object({
|
|
285
285
|
object: v.literal("page"),
|
|
286
286
|
id: notionPageIdSchema,
|
|
287
287
|
parent: notionParentSchema,
|
package/docs/bridge/protocol.md
CHANGED
|
@@ -175,10 +175,10 @@ must carry the same raw property ID in its `id` field.
|
|
|
175
175
|
|
|
176
176
|
## Page responses
|
|
177
177
|
|
|
178
|
-
Host handlers return unified `
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
Host handlers return unified `BridgePage` for queries and page operations. Properties use display
|
|
179
|
+
names as keys and typed values that include their raw property IDs. Only actual schema properties
|
|
180
|
+
are returned. Query results contain `items` and `hasMore`. `bridgePageSchema` defines the page
|
|
181
|
+
fields, including archive state and creation, edit, and visit metadata.
|
|
182
182
|
|
|
183
183
|
Page reads return string values for `unique_id`, `formula`, `rollup`, `button`, `verification`, and
|
|
184
184
|
`location`, preserving each property's type. These properties are read-only. Values use stored text,
|
package/docs/handlers.md
CHANGED
|
@@ -42,7 +42,7 @@ import type {
|
|
|
42
42
|
CustomBlockHostDataSourcesPayload,
|
|
43
43
|
CustomBlockHostHandlers,
|
|
44
44
|
} from "@notionhq/custom-blocks-host"
|
|
45
|
-
import type { CustomBlockManifest,
|
|
45
|
+
import type { CustomBlockManifest, BridgePage } from "@notionhq/custom-blocks-host/protocol"
|
|
46
46
|
|
|
47
47
|
const tasksId = "44444444-4444-4444-8444-444444444444"
|
|
48
48
|
|
|
@@ -109,7 +109,7 @@ const handlers: CustomBlockHostHandlers = {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const items:
|
|
112
|
+
const items: BridgePage[] = [
|
|
113
113
|
{
|
|
114
114
|
object: "page",
|
|
115
115
|
id: "55555555-5555-4555-8555-555555555555",
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
|
|
2
2
|
import type {
|
|
3
|
+
bridgePageSchema,
|
|
3
4
|
NotionPageForProtocol3To5,
|
|
4
5
|
NotionPagePropertyValue,
|
|
5
|
-
notionPageDataSchema,
|
|
6
6
|
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
7
7
|
import type { InferOutput } from "valibot"
|
|
8
8
|
import { toNotionDateValue } from "../dateValue.js"
|
|
@@ -17,7 +17,7 @@ import { unreachable } from "../utils.js"
|
|
|
17
17
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
18
18
|
*/
|
|
19
19
|
export function toPageForProtocol3To5(
|
|
20
|
-
page: InferOutput<typeof
|
|
20
|
+
page: InferOutput<typeof bridgePageSchema>,
|
|
21
21
|
): NotionPageForProtocol3To5 {
|
|
22
22
|
return {
|
|
23
23
|
...page,
|
|
@@ -44,7 +44,7 @@ export function toPageForProtocol3To5(
|
|
|
44
44
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
45
45
|
*/
|
|
46
46
|
export function toQueryPageForProtocol3To5(
|
|
47
|
-
page: InferOutput<typeof
|
|
47
|
+
page: InferOutput<typeof bridgePageSchema>,
|
|
48
48
|
) {
|
|
49
49
|
const propertiesById: Record<string, NotionDataSourceValue | undefined> = {}
|
|
50
50
|
for (const property of Object.values(page.properties)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { bridgePageSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
2
2
|
import type { InferOutput } from "valibot"
|
|
3
3
|
import { unreachable } from "../utils.js"
|
|
4
4
|
|
|
@@ -8,8 +8,8 @@ import { unreachable } from "../utils.js"
|
|
|
8
8
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 7.
|
|
9
9
|
*/
|
|
10
10
|
export function toPageWithNullTextFallbackProperties(
|
|
11
|
-
page: InferOutput<typeof
|
|
12
|
-
): InferOutput<typeof
|
|
11
|
+
page: InferOutput<typeof bridgePageSchema>,
|
|
12
|
+
): InferOutput<typeof bridgePageSchema> {
|
|
13
13
|
return {
|
|
14
14
|
...page,
|
|
15
15
|
properties: Object.fromEntries(
|