@notionhq/custom-blocks-host 0.0.1
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 +204 -0
- package/dist/autoBindProperties.d.ts +21 -0
- package/dist/autoBindProperties.d.ts.map +1 -0
- package/dist/autoBindProperties.js +38 -0
- package/dist/createCustomBlockHost.d.ts +46 -0
- package/dist/createCustomBlockHost.d.ts.map +1 -0
- package/dist/createCustomBlockHost.js +433 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/lifecycle/initErrors.d.ts +13 -0
- package/dist/lifecycle/initErrors.d.ts.map +1 -0
- package/dist/lifecycle/initErrors.js +152 -0
- package/dist/lifecycle/initializationController.d.ts +54 -0
- package/dist/lifecycle/initializationController.d.ts.map +1 -0
- package/dist/lifecycle/initializationController.js +182 -0
- package/dist/lifecycle/protocolVersion.d.ts +2 -0
- package/dist/lifecycle/protocolVersion.d.ts.map +1 -0
- package/dist/lifecycle/protocolVersion.js +3 -0
- package/dist/lifecycle/types.d.ts +28 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/lifecycle/types.js +1 -0
- package/dist/messages/invalidSandboxMessage.d.ts +7 -0
- package/dist/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/messages/invalidSandboxMessage.js +21 -0
- package/dist/messages/types.d.ts +29 -0
- package/dist/messages/types.d.ts.map +1 -0
- package/dist/messages/types.js +1 -0
- package/dist/protocol/contrast.d.ts +4 -0
- package/dist/protocol/contrast.js +3 -0
- package/dist/protocol/dataSources/dataSource.d.ts +731 -0
- package/dist/protocol/dataSources/dataSource.js +37 -0
- package/dist/protocol/dataSources/dataSourcePage.d.ts +72 -0
- package/dist/protocol/dataSources/dataSourcePage.js +12 -0
- package/dist/protocol/dataSources/dataSourceValue.d.ts +66 -0
- package/dist/protocol/dataSources/dataSourceValue.js +14 -0
- package/dist/protocol/dataSources/dateValue.d.ts +157 -0
- package/dist/protocol/dataSources/dateValue.js +59 -0
- package/dist/protocol/dataSources/errors.d.ts +8 -0
- package/dist/protocol/dataSources/errors.js +7 -0
- package/dist/protocol/dataSources/propertySchema.d.ts +197 -0
- package/dist/protocol/dataSources/propertySchema.js +165 -0
- package/dist/protocol/dataSources/recordPointer.d.ts +9 -0
- package/dist/protocol/dataSources/recordPointer.js +8 -0
- package/dist/protocol/errors.d.ts +12 -0
- package/dist/protocol/errors.js +6 -0
- package/dist/protocol/ids.d.ts +31 -0
- package/dist/protocol/ids.js +26 -0
- package/dist/protocol/incomingType.d.ts +9 -0
- package/dist/protocol/incomingType.js +17 -0
- package/dist/protocol/index.d.ts +48 -0
- package/dist/protocol/index.js +48 -0
- package/dist/protocol/manifest.d.ts +60 -0
- package/dist/protocol/manifest.js +32 -0
- package/dist/protocol/messagePayload.d.ts +19 -0
- package/dist/protocol/messagePayload.js +1 -0
- package/dist/protocol/messages/connect.d.ts +47 -0
- package/dist/protocol/messages/connect.js +38 -0
- package/dist/protocol/messages/contrastModeChanged.d.ts +7 -0
- package/dist/protocol/messages/contrastModeChanged.js +7 -0
- package/dist/protocol/messages/createPage.d.ts +200 -0
- package/dist/protocol/messages/createPage.js +52 -0
- package/dist/protocol/messages/createPageResult.d.ts +213 -0
- package/dist/protocol/messages/createPageResult.js +28 -0
- package/dist/protocol/messages/currentUserChanged.d.ts +18 -0
- package/dist/protocol/messages/currentUserChanged.js +9 -0
- package/dist/protocol/messages/dataSourcesChanged.d.ts +157 -0
- package/dist/protocol/messages/dataSourcesChanged.js +13 -0
- package/dist/protocol/messages/getPage.d.ts +218 -0
- package/dist/protocol/messages/getPage.js +33 -0
- package/dist/protocol/messages/getUser.d.ts +44 -0
- package/dist/protocol/messages/getUser.js +32 -0
- package/dist/protocol/messages/hostToSandbox.d.ts +1167 -0
- package/dist/protocol/messages/hostToSandbox.js +34 -0
- package/dist/protocol/messages/init.d.ts +259 -0
- package/dist/protocol/messages/init.js +56 -0
- package/dist/protocol/messages/initResult.d.ts +37 -0
- package/dist/protocol/messages/initResult.js +28 -0
- package/dist/protocol/messages/invalidHostMessage.d.ts +14 -0
- package/dist/protocol/messages/invalidHostMessage.js +13 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +14 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +13 -0
- package/dist/protocol/messages/listUsers.d.ts +52 -0
- package/dist/protocol/messages/listUsers.js +33 -0
- package/dist/protocol/messages/pageChanged.d.ts +27 -0
- package/dist/protocol/messages/pageChanged.js +9 -0
- package/dist/protocol/messages/parentChanged.d.ts +24 -0
- package/dist/protocol/messages/parentChanged.js +9 -0
- package/dist/protocol/messages/queryDataSource.d.ts +985 -0
- package/dist/protocol/messages/queryDataSource.js +123 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +93 -0
- package/dist/protocol/messages/queryDataSourceResult.js +28 -0
- package/dist/protocol/messages/resize.d.ts +11 -0
- package/dist/protocol/messages/resize.js +10 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +744 -0
- package/dist/protocol/messages/sandboxToHost.js +27 -0
- package/dist/protocol/messages/themeChanged.d.ts +10 -0
- package/dist/protocol/messages/themeChanged.js +10 -0
- package/dist/protocol/messages/updatePage.d.ts +180 -0
- package/dist/protocol/messages/updatePage.js +22 -0
- package/dist/protocol/messages/updatePageResult.d.ts +212 -0
- package/dist/protocol/messages/updatePageResult.js +27 -0
- package/dist/protocol/pages/page.d.ts +597 -0
- package/dist/protocol/pages/page.js +212 -0
- package/dist/protocol/parent.d.ts +28 -0
- package/dist/protocol/parent.js +12 -0
- package/dist/protocol/protocolVersion.d.ts +6 -0
- package/dist/protocol/protocolVersion.js +6 -0
- package/dist/protocol/theme.d.ts +3 -0
- package/dist/protocol/theme.js +2 -0
- package/dist/protocol/users/user.d.ts +32 -0
- package/dist/protocol/users/user.js +20 -0
- package/dist/queries/querySubscriptions.d.ts +17 -0
- package/dist/queries/querySubscriptions.d.ts.map +1 -0
- package/dist/queries/querySubscriptions.js +38 -0
- package/dist/queries/types.d.ts +4 -0
- package/dist/queries/types.d.ts.map +1 -0
- package/dist/queries/types.js +1 -0
- package/dist/queries/validateQueryDataSourceFilter.d.ts +5 -0
- package/dist/queries/validateQueryDataSourceFilter.d.ts.map +1 -0
- package/dist/queries/validateQueryDataSourceFilter.js +72 -0
- package/dist/queries/validateQueryDataSourceSorts.d.ts +8 -0
- package/dist/queries/validateQueryDataSourceSorts.d.ts.map +1 -0
- package/dist/queries/validateQueryDataSourceSorts.js +47 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +6 -0
- package/package.json +26 -0
- package/src/autoBindProperties.ts +63 -0
- package/src/createCustomBlockHost.ts +605 -0
- package/src/index.ts +25 -0
- package/src/lifecycle/initErrors.ts +165 -0
- package/src/lifecycle/initializationController.ts +290 -0
- package/src/lifecycle/protocolVersion.ts +3 -0
- package/src/lifecycle/types.ts +40 -0
- package/src/messages/invalidSandboxMessage.ts +35 -0
- package/src/messages/types.ts +80 -0
- package/src/queries/querySubscriptions.ts +57 -0
- package/src/queries/types.ts +10 -0
- package/src/queries/validateQueryDataSourceFilter.ts +101 -0
- package/src/queries/validateQueryDataSourceSorts.ts +69 -0
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionDataSourceIdSchema } from "../ids.js";
|
|
3
|
+
const emptyOperatorSchema = v.union([
|
|
4
|
+
v.object({ is_empty: v.literal(true) }),
|
|
5
|
+
v.object({ is_not_empty: v.literal(true) }),
|
|
6
|
+
]);
|
|
7
|
+
const stringOrStringArraySchema = v.union([v.string(), v.array(v.string())]);
|
|
8
|
+
export const customBlockTextFilterOperatorSchema = v.union([
|
|
9
|
+
v.object({ equals: v.string() }),
|
|
10
|
+
v.object({ does_not_equal: v.string() }),
|
|
11
|
+
v.object({ contains: v.string() }),
|
|
12
|
+
v.object({ does_not_contain: v.string() }),
|
|
13
|
+
v.object({ starts_with: v.string() }),
|
|
14
|
+
v.object({ ends_with: v.string() }),
|
|
15
|
+
emptyOperatorSchema,
|
|
16
|
+
]);
|
|
17
|
+
export const customBlockNumberFilterOperatorSchema = v.union([
|
|
18
|
+
v.object({ equals: v.number() }),
|
|
19
|
+
v.object({ does_not_equal: v.number() }),
|
|
20
|
+
v.object({ greater_than: v.number() }),
|
|
21
|
+
v.object({ less_than: v.number() }),
|
|
22
|
+
v.object({ greater_than_or_equal_to: v.number() }),
|
|
23
|
+
v.object({ less_than_or_equal_to: v.number() }),
|
|
24
|
+
emptyOperatorSchema,
|
|
25
|
+
]);
|
|
26
|
+
export const customBlockCheckboxFilterOperatorSchema = v.union([
|
|
27
|
+
v.object({ equals: v.boolean() }),
|
|
28
|
+
v.object({ does_not_equal: v.boolean() }),
|
|
29
|
+
]);
|
|
30
|
+
export const customBlockOptionFilterOperatorSchema = v.union([
|
|
31
|
+
v.object({ equals: stringOrStringArraySchema }),
|
|
32
|
+
v.object({ does_not_equal: stringOrStringArraySchema }),
|
|
33
|
+
emptyOperatorSchema,
|
|
34
|
+
]);
|
|
35
|
+
export const customBlockContainsFilterOperatorSchema = v.union([
|
|
36
|
+
v.object({ contains: stringOrStringArraySchema }),
|
|
37
|
+
v.object({ contains_all: stringOrStringArraySchema }),
|
|
38
|
+
v.object({ does_not_contain: stringOrStringArraySchema }),
|
|
39
|
+
emptyOperatorSchema,
|
|
40
|
+
]);
|
|
41
|
+
export const customBlockDateFilterOperatorSchema = v.union([
|
|
42
|
+
v.object({ equals: v.string() }),
|
|
43
|
+
v.object({ before: v.string() }),
|
|
44
|
+
v.object({ after: v.string() }),
|
|
45
|
+
v.object({ on_or_before: v.string() }),
|
|
46
|
+
v.object({ on_or_after: v.string() }),
|
|
47
|
+
emptyOperatorSchema,
|
|
48
|
+
]);
|
|
49
|
+
export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
|
|
50
|
+
v.object({
|
|
51
|
+
propertyId: v.string(),
|
|
52
|
+
title: customBlockTextFilterOperatorSchema,
|
|
53
|
+
}),
|
|
54
|
+
v.object({
|
|
55
|
+
propertyId: v.string(),
|
|
56
|
+
rich_text: customBlockTextFilterOperatorSchema,
|
|
57
|
+
}),
|
|
58
|
+
v.object({
|
|
59
|
+
propertyId: v.string(),
|
|
60
|
+
url: customBlockTextFilterOperatorSchema,
|
|
61
|
+
}),
|
|
62
|
+
v.object({
|
|
63
|
+
propertyId: v.string(),
|
|
64
|
+
email: customBlockTextFilterOperatorSchema,
|
|
65
|
+
}),
|
|
66
|
+
v.object({
|
|
67
|
+
propertyId: v.string(),
|
|
68
|
+
phone_number: customBlockTextFilterOperatorSchema,
|
|
69
|
+
}),
|
|
70
|
+
v.object({
|
|
71
|
+
propertyId: v.string(),
|
|
72
|
+
number: customBlockNumberFilterOperatorSchema,
|
|
73
|
+
}),
|
|
74
|
+
v.object({
|
|
75
|
+
propertyId: v.string(),
|
|
76
|
+
checkbox: customBlockCheckboxFilterOperatorSchema,
|
|
77
|
+
}),
|
|
78
|
+
v.object({
|
|
79
|
+
propertyId: v.string(),
|
|
80
|
+
select: customBlockOptionFilterOperatorSchema,
|
|
81
|
+
}),
|
|
82
|
+
v.object({
|
|
83
|
+
propertyId: v.string(),
|
|
84
|
+
multi_select: customBlockContainsFilterOperatorSchema,
|
|
85
|
+
}),
|
|
86
|
+
v.object({
|
|
87
|
+
propertyId: v.string(),
|
|
88
|
+
status: customBlockOptionFilterOperatorSchema,
|
|
89
|
+
}),
|
|
90
|
+
v.object({
|
|
91
|
+
propertyId: v.string(),
|
|
92
|
+
date: customBlockDateFilterOperatorSchema,
|
|
93
|
+
}),
|
|
94
|
+
]);
|
|
95
|
+
export const resolvedCustomBlockDataSourceFilterSchema = v.union([
|
|
96
|
+
resolvedCustomBlockDataSourcePropertyFilterSchema,
|
|
97
|
+
v.object({
|
|
98
|
+
and: v.array(resolvedCustomBlockDataSourcePropertyFilterSchema),
|
|
99
|
+
}),
|
|
100
|
+
]);
|
|
101
|
+
/** Maximum number of sort properties accepted in one data source query. */
|
|
102
|
+
export const CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS = 10;
|
|
103
|
+
export const resolvedCustomBlockDataSourceSortSchema = v.object({
|
|
104
|
+
propertyId: v.string(),
|
|
105
|
+
direction: v.picklist(["ascending", "descending"]),
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Message sent by the sandbox to ask the host for the current rows in a resolved
|
|
109
|
+
* Notion data source.
|
|
110
|
+
*/
|
|
111
|
+
export const queryDataSourceMessageSchema = v.object({
|
|
112
|
+
type: v.literal("queryDataSource"),
|
|
113
|
+
/** Stable for the lifetime of this query subscription. */
|
|
114
|
+
subscriptionId: v.string(),
|
|
115
|
+
/** The raw Notion data source ID to read from. */
|
|
116
|
+
dataSourceId: notionDataSourceIdSchema,
|
|
117
|
+
/** The number of items to return in each subscription update. */
|
|
118
|
+
limit: v.number(),
|
|
119
|
+
/** A sandbox-resolved property filter. */
|
|
120
|
+
filter: v.optional(resolvedCustomBlockDataSourceFilterSchema),
|
|
121
|
+
/** Sandbox-resolved property sorts, in priority order. */
|
|
122
|
+
sorts: v.optional(v.array(resolvedCustomBlockDataSourceSortSchema)),
|
|
123
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
|
+
export declare const customBlockQueryDataSourceErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
+
export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source">;
|
|
5
|
+
export type CustomBlockQueryDataSourceErrorInfo = CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>;
|
|
6
|
+
export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
|
|
7
|
+
readonly code: v.StringSchema<undefined>;
|
|
8
|
+
readonly message: v.StringSchema<undefined>;
|
|
9
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Message sent by the host to update a `queryDataSource` subscription.
|
|
13
|
+
*/
|
|
14
|
+
export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
15
|
+
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
16
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
17
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
18
|
+
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
19
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
20
|
+
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
21
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
22
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
23
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
24
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
25
|
+
readonly value: v.NumberSchema<undefined>;
|
|
26
|
+
readonly time: v.StringSchema<undefined>;
|
|
27
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
28
|
+
}, undefined>, v.ObjectSchema<{
|
|
29
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
30
|
+
}, undefined>], undefined>, undefined>;
|
|
31
|
+
}, undefined>, v.ObjectSchema<{
|
|
32
|
+
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
33
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
34
|
+
readonly end_date: v.StringSchema<undefined>;
|
|
35
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
36
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
37
|
+
readonly value: v.NumberSchema<undefined>;
|
|
38
|
+
readonly time: v.StringSchema<undefined>;
|
|
39
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
40
|
+
}, undefined>, v.ObjectSchema<{
|
|
41
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
42
|
+
}, undefined>], undefined>, undefined>;
|
|
43
|
+
}, undefined>, v.ObjectSchema<{
|
|
44
|
+
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
45
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
46
|
+
readonly start_time: v.StringSchema<undefined>;
|
|
47
|
+
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
48
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
49
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
50
|
+
readonly value: v.NumberSchema<undefined>;
|
|
51
|
+
readonly time: v.StringSchema<undefined>;
|
|
52
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
53
|
+
}, undefined>, v.ObjectSchema<{
|
|
54
|
+
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
55
|
+
readonly value: v.NumberSchema<undefined>;
|
|
56
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
57
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
58
|
+
}, undefined>], undefined>, undefined>;
|
|
59
|
+
}, undefined>, v.ObjectSchema<{
|
|
60
|
+
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
61
|
+
readonly start_date: v.StringSchema<undefined>;
|
|
62
|
+
readonly start_time: v.StringSchema<undefined>;
|
|
63
|
+
readonly end_date: v.StringSchema<undefined>;
|
|
64
|
+
readonly end_time: v.StringSchema<undefined>;
|
|
65
|
+
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
|
+
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
67
|
+
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
68
|
+
readonly value: v.NumberSchema<undefined>;
|
|
69
|
+
readonly time: v.StringSchema<undefined>;
|
|
70
|
+
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
+
}, undefined>, v.ObjectSchema<{
|
|
72
|
+
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
73
|
+
readonly value: v.NumberSchema<undefined>;
|
|
74
|
+
}, undefined>], undefined>, v.ObjectSchema<{
|
|
75
|
+
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
76
|
+
}, undefined>], undefined>, undefined>;
|
|
77
|
+
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
78
|
+
readonly id: v.StringSchema<undefined>;
|
|
79
|
+
readonly table: v.StringSchema<undefined>;
|
|
80
|
+
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
81
|
+
}, undefined>, undefined>;
|
|
82
|
+
readonly hasMore: v.BooleanSchema<undefined>;
|
|
83
|
+
}, undefined>, v.ObjectSchema<{
|
|
84
|
+
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
85
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
86
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
87
|
+
readonly error: v.ObjectSchema<{
|
|
88
|
+
readonly code: v.StringSchema<undefined>;
|
|
89
|
+
readonly message: v.StringSchema<undefined>;
|
|
90
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
91
|
+
}, undefined>;
|
|
92
|
+
}, undefined>], undefined>;
|
|
93
|
+
export type QueryDataSourceResultMessage = v.InferOutput<typeof queryDataSourceResultMessageSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionDataSourcePageBridgeSchema } from "../dataSources/dataSourcePage.js";
|
|
3
|
+
// The schema accepts any string code. The type lists known codes for
|
|
4
|
+
// autocomplete, with an open string fallback for newer senders.
|
|
5
|
+
export const customBlockQueryDataSourceErrorCodeSchema = v.string();
|
|
6
|
+
export const customBlockQueryDataSourceErrorInfoSchema = v.object({
|
|
7
|
+
code: customBlockQueryDataSourceErrorCodeSchema,
|
|
8
|
+
message: v.string(),
|
|
9
|
+
isRetryable: v.boolean(),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Message sent by the host to update a `queryDataSource` subscription.
|
|
13
|
+
*/
|
|
14
|
+
export const queryDataSourceResultMessageSchema = v.variant("status", [
|
|
15
|
+
v.object({
|
|
16
|
+
type: v.literal("queryDataSourceResult"),
|
|
17
|
+
subscriptionId: v.string(),
|
|
18
|
+
status: v.literal("success"),
|
|
19
|
+
items: v.array(notionDataSourcePageBridgeSchema),
|
|
20
|
+
hasMore: v.boolean(),
|
|
21
|
+
}),
|
|
22
|
+
v.object({
|
|
23
|
+
type: v.literal("queryDataSourceResult"),
|
|
24
|
+
subscriptionId: v.string(),
|
|
25
|
+
status: v.literal("error"),
|
|
26
|
+
error: customBlockQueryDataSourceErrorInfoSchema,
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Message sent by the sandbox whenever its measured content height changes, so the host can resize
|
|
4
|
+
* the surrounding iframe to match. The host is free to clamp the value or ignore it. The sandbox
|
|
5
|
+
* always reports the most recent measurement.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resizeMessageSchema: v.ObjectSchema<{
|
|
8
|
+
readonly type: v.LiteralSchema<"resize", undefined>;
|
|
9
|
+
readonly height: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
export type ResizeMessage = v.InferOutput<typeof resizeMessageSchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Message sent by the sandbox whenever its measured content height changes, so the host can resize
|
|
4
|
+
* the surrounding iframe to match. The host is free to clamp the value or ignore it. The sandbox
|
|
5
|
+
* always reports the most recent measurement.
|
|
6
|
+
*/
|
|
7
|
+
export const resizeMessageSchema = v.object({
|
|
8
|
+
type: v.literal("resize"),
|
|
9
|
+
height: v.pipe(v.number(), v.finite(), v.minValue(0)),
|
|
10
|
+
});
|