@notionhq/custom-blocks 0.3.3 → 0.3.4
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/LICENSE +21 -0
- package/README.md +11 -11
- package/dist/bridge/SandboxBridge.d.ts +0 -2
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +5 -8
- package/dist/bridge/SandboxInitialization.d.ts +1 -3
- package/dist/bridge/SandboxInitialization.d.ts.map +1 -1
- package/dist/bridge/SandboxInitialization.js +13 -15
- package/dist/bridge/appearance.d.ts +2 -10
- package/dist/bridge/appearance.d.ts.map +1 -1
- package/dist/bridge/appearance.js +2 -10
- package/dist/bridge/dataSources/query.d.ts +1 -2
- package/dist/bridge/dataSources/query.d.ts.map +1 -1
- package/dist/bridge/dataSources/query.js +15 -398
- package/dist/bridge/dataSources/queryFilter.d.ts +10 -0
- package/dist/bridge/dataSources/queryFilter.d.ts.map +1 -0
- package/dist/bridge/dataSources/queryFilter.js +123 -0
- package/dist/bridge/dataSources/resolvePropertyAddress.d.ts +10 -0
- package/dist/bridge/dataSources/resolvePropertyAddress.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolvePropertyAddress.js +55 -0
- package/dist/bridge/dataSources/resolveSorts.d.ts +10 -0
- package/dist/bridge/dataSources/resolveSorts.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolveSorts.js +80 -0
- package/dist/bridge/hostState.d.ts +3 -7
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/hostState.js +0 -24
- package/dist/bridge/page.d.ts +3 -3
- package/dist/bridge/page.d.ts.map +1 -1
- package/dist/bridge/page.js +2 -2
- package/dist/bridge/readLocalManifest.d.ts +23 -0
- package/dist/bridge/readLocalManifest.d.ts.map +1 -0
- package/dist/bridge/readLocalManifest.js +46 -0
- package/dist/bridge/sandboxClient.d.ts +0 -2
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/bridge/sandboxClient.js +50 -27
- package/dist/protocol/dataSources/dataSourcePage.d.ts +3 -4
- package/dist/protocol/dataSources/dataSourcePage.js +2 -3
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/isLocalBlockServerUrl.d.ts +2 -0
- package/dist/protocol/isLocalBlockServerUrl.js +9 -0
- package/dist/protocol/messages/connect.d.ts +2 -2
- package/dist/protocol/messages/connect.js +2 -2
- package/dist/protocol/messages/createPage.d.ts +1 -1
- package/dist/protocol/messages/createPage.js +1 -1
- package/dist/protocol/messages/createPageResult.d.ts +3 -3
- package/dist/protocol/messages/createPageResult.js +4 -4
- package/dist/protocol/messages/getPage.d.ts +2 -2
- package/dist/protocol/messages/getPage.js +4 -4
- package/dist/protocol/messages/hostToSandbox.d.ts +3 -3
- package/dist/protocol/messages/hostToSandbox.js +10 -10
- package/dist/protocol/messages/init.d.ts +1 -1
- package/dist/protocol/messages/queryDataSource.d.ts +24 -0
- package/dist/protocol/messages/queryDataSource.js +2 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +3 -3
- package/dist/protocol/messages/queryDataSourceResult.js +5 -5
- package/dist/protocol/messages/sandboxToHost.d.ts +8 -0
- package/dist/protocol/messages/updatePageResult.d.ts +3 -3
- package/dist/protocol/messages/updatePageResult.js +4 -4
- package/dist/protocol/pages/page.d.ts +4 -4
- package/dist/protocol/pages/page.js +2 -2
- package/dist/protocol/parent.d.ts +1 -1
- package/dist/protocol/protocolVersion.d.ts +2 -2
- package/dist/protocol/protocolVersion.js +2 -2
- package/dist/react/useDataSource.d.ts +2 -2
- package/dist/react/useDataSource.js +2 -2
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/block-location.md +6 -4
- package/docs/bridge-interceptors.md +4 -0
- package/docs/build-tools.md +5 -2
- package/docs/data-sources.md +21 -17
- package/docs/deployment.md +16 -11
- package/docs/errors.md +11 -1
- package/docs/lifecycle.md +10 -3
- package/docs/pages.md +7 -3
- package/docs/users.md +4 -4
- package/package.json +3 -2
- package/src/bridge/SandboxBridge.ts +5 -10
- package/src/bridge/SandboxInitialization.ts +14 -20
- package/src/bridge/appearance.ts +2 -10
- package/src/bridge/dataSources/query.ts +17 -530
- package/src/bridge/dataSources/queryFilter.ts +181 -0
- package/src/bridge/dataSources/resolvePropertyAddress.ts +62 -0
- package/src/bridge/dataSources/resolveSorts.ts +107 -0
- package/src/bridge/hostState.ts +3 -43
- package/src/bridge/page.ts +4 -4
- package/src/bridge/readLocalManifest.ts +60 -0
- package/src/bridge/sandboxClient.ts +63 -41
- package/src/react/useDataSource.ts +2 -2
- package/src/types.ts +5 -5
- package/dist/bridge/loadManifest.d.ts +0 -21
- package/dist/bridge/loadManifest.d.ts.map +0 -1
- package/dist/bridge/loadManifest.js +0 -85
- package/src/bridge/loadManifest.ts +0 -114
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { contrastModeChangedMessageSchema } from "./contrastModeChanged.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createPageResultMessageSchema, createPageResultMessageWithProtocol3To5CompatibilitySchema, } from "./createPageResult.js";
|
|
4
4
|
import { currentUserChangedMessageSchema } from "./currentUserChanged.js";
|
|
5
5
|
import { dataSourcesChangedMessageSchema } from "./dataSourcesChanged.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getPageResultMessageSchema, getPageResultMessageWithProtocol3To5CompatibilitySchema, } from "./getPage.js";
|
|
7
7
|
import { getUserResultMessageSchema } from "./getUser.js";
|
|
8
8
|
import { initMessageSchema } from "./init.js";
|
|
9
9
|
import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js";
|
|
@@ -12,9 +12,9 @@ import { openExternalUrlResultMessageSchema } from "./openExternalUrl.js";
|
|
|
12
12
|
import { openPageResultMessageSchema } from "./openPage.js";
|
|
13
13
|
import { pageChangedMessageSchema } from "./pageChanged.js";
|
|
14
14
|
import { parentChangedMessageSchema } from "./parentChanged.js";
|
|
15
|
-
import {
|
|
15
|
+
import { queryDataSourceResultMessageSchema, queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema, } from "./queryDataSourceResult.js";
|
|
16
16
|
import { themeChangedMessageSchema } from "./themeChanged.js";
|
|
17
|
-
import {
|
|
17
|
+
import { updatePageResultMessageSchema, updatePageResultMessageWithProtocol3To5CompatibilitySchema, } from "./updatePageResult.js";
|
|
18
18
|
const baseHostToSandboxMessageSchema = v.variant("type", [
|
|
19
19
|
initMessageSchema,
|
|
20
20
|
themeChangedMessageSchema,
|
|
@@ -37,12 +37,12 @@ export const hostToSandboxMessageSchema = v.variant("type", [
|
|
|
37
37
|
updatePageResultMessageSchema,
|
|
38
38
|
]);
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Host messages accepting both current page shapes and protocol 3–5 page shapes.
|
|
41
41
|
*/
|
|
42
|
-
export const
|
|
42
|
+
export const hostToSandboxMessageWithProtocol3To5CompatibilitySchema = v.variant("type", [
|
|
43
43
|
...baseHostToSandboxMessageSchema.options,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
45
|
+
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
46
|
+
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
47
|
+
updatePageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
48
48
|
]);
|
|
@@ -2,7 +2,7 @@ import * as v from "valibot";
|
|
|
2
2
|
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
3
|
import type { CustomBlockInitResultErrorCode } from "./initResult.js";
|
|
4
4
|
export declare const customBlockInitErrorCodeSchema: v.StringSchema<undefined>;
|
|
5
|
-
export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "init_timeout" | "context_unavailable" | "current_user_unavailable" | "initial_state_timeout" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
|
|
5
|
+
export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_local_preview_url" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "init_timeout" | "context_unavailable" | "current_user_unavailable" | "initial_state_timeout" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
|
|
6
6
|
export type CustomBlockInitErrorInfo = CustomBlockErrorInfo<CustomBlockInitErrorCode>;
|
|
7
7
|
/**
|
|
8
8
|
* Every initialization failure visible to block code. This combines errors
|
|
@@ -3,6 +3,10 @@ export declare const customBlockRelationFilterOperatorSchema: v.UnionSchema<[v.S
|
|
|
3
3
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
4
4
|
}, undefined>, v.StrictObjectSchema<{
|
|
5
5
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
6
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
7
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
8
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
9
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
6
10
|
}, undefined>], undefined>;
|
|
7
11
|
export type CustomBlockRelationFilterOperator = v.InferOutput<typeof customBlockRelationFilterOperatorSchema>;
|
|
8
12
|
declare const customBlockPersonFilterValueSchema: v.StrictObjectSchema<{
|
|
@@ -180,6 +184,10 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
|
|
|
180
184
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
181
185
|
}, undefined>, v.StrictObjectSchema<{
|
|
182
186
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
187
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
188
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
189
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
190
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
183
191
|
}, undefined>], undefined>;
|
|
184
192
|
}, undefined>, v.StrictObjectSchema<{
|
|
185
193
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -428,6 +436,10 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
|
|
|
428
436
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
429
437
|
}, undefined>, v.StrictObjectSchema<{
|
|
430
438
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
439
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
440
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
441
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
442
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
431
443
|
}, undefined>], undefined>;
|
|
432
444
|
}, undefined>, v.StrictObjectSchema<{
|
|
433
445
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -675,6 +687,10 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
|
|
|
675
687
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
676
688
|
}, undefined>, v.StrictObjectSchema<{
|
|
677
689
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
690
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
691
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
692
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
693
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
678
694
|
}, undefined>], undefined>;
|
|
679
695
|
}, undefined>, v.StrictObjectSchema<{
|
|
680
696
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -947,6 +963,10 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
947
963
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
948
964
|
}, undefined>, v.StrictObjectSchema<{
|
|
949
965
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
966
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
967
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
968
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
969
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
950
970
|
}, undefined>], undefined>;
|
|
951
971
|
}, undefined>, v.StrictObjectSchema<{
|
|
952
972
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -1194,6 +1214,10 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
1194
1214
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
1195
1215
|
}, undefined>, v.StrictObjectSchema<{
|
|
1196
1216
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
1217
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
1218
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
1219
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
1220
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
1197
1221
|
}, undefined>], undefined>;
|
|
1198
1222
|
}, undefined>, v.StrictObjectSchema<{
|
|
1199
1223
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -8,6 +8,8 @@ const relationPageIdSchema = v.pipe(notionPageIdSchema, v.regex(/^(?:[0-9a-f]{32
|
|
|
8
8
|
export const customBlockRelationFilterOperatorSchema = v.union([
|
|
9
9
|
v.strictObject({ contains: relationPageIdSchema }),
|
|
10
10
|
v.strictObject({ does_not_contain: relationPageIdSchema }),
|
|
11
|
+
v.strictObject({ is_empty: v.literal(true) }),
|
|
12
|
+
v.strictObject({ is_not_empty: v.literal(true) }),
|
|
11
13
|
]);
|
|
12
14
|
const emptyOperatorSchema = v.union([
|
|
13
15
|
v.strictObject({ is_empty: v.literal(true) }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
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" | "data_source_schema_unavailable">;
|
|
4
|
+
export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "data_source_query_invalid_limit" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_schema_unavailable">;
|
|
5
5
|
export type CustomBlockQueryDataSourceErrorInfo = CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>;
|
|
6
6
|
export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -314,7 +314,7 @@ export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status
|
|
|
314
314
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
315
315
|
}, undefined>;
|
|
316
316
|
}, undefined>], undefined>;
|
|
317
|
-
export declare const
|
|
317
|
+
export declare const queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
318
318
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
319
319
|
readonly subscriptionId: v.StringSchema<undefined>;
|
|
320
320
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
@@ -683,4 +683,4 @@ export declare const queryDataSourceResultMessageLegacySchema: v.VariantSchema<"
|
|
|
683
683
|
}, undefined>;
|
|
684
684
|
}, undefined>], undefined>;
|
|
685
685
|
export type QueryDataSourceResultMessage = v.InferOutput<typeof queryDataSourceResultMessageSchema>;
|
|
686
|
-
export type
|
|
686
|
+
export type QueryDataSourceResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { notionDataSourcePageForProtocol3To5Schema } from "../dataSources/dataSourcePage.js";
|
|
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({
|
|
@@ -27,12 +27,12 @@ export const queryDataSourceResultMessageSchema = v.variant("status", [
|
|
|
27
27
|
error: customBlockQueryDataSourceErrorInfoSchema,
|
|
28
28
|
}),
|
|
29
29
|
]);
|
|
30
|
-
export const
|
|
30
|
+
export const queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
|
|
31
31
|
v.object({
|
|
32
32
|
type: v.literal("queryDataSourceResult"),
|
|
33
33
|
subscriptionId: v.string(),
|
|
34
34
|
status: v.literal("success"),
|
|
35
|
-
items: v.array(v.union([
|
|
35
|
+
items: v.array(v.union([bridgePageSchema, notionDataSourcePageForProtocol3To5Schema])),
|
|
36
36
|
hasMore: v.boolean(),
|
|
37
37
|
}),
|
|
38
38
|
v.object({
|
|
@@ -71,6 +71,10 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
71
71
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
72
72
|
}, undefined>, v.StrictObjectSchema<{
|
|
73
73
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
74
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
75
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
76
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
77
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
74
78
|
}, undefined>], undefined>;
|
|
75
79
|
}, undefined>, v.StrictObjectSchema<{
|
|
76
80
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -318,6 +322,10 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
318
322
|
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
319
323
|
}, undefined>, v.StrictObjectSchema<{
|
|
320
324
|
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
325
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
326
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
327
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
328
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
321
329
|
}, undefined>], undefined>;
|
|
322
330
|
}, undefined>, v.StrictObjectSchema<{
|
|
323
331
|
readonly propertyId: v.StringSchema<undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
3
|
export declare const customBlockUpdatePageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<"update_page_failed" | "invalid_page_update" | "page_unavailable" | "
|
|
4
|
+
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<"update_page_failed" | "invalid_page_update" | "page_unavailable" | "data_source_access_failed" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value">;
|
|
5
5
|
export type CustomBlockUpdatePageErrorInfo = CustomBlockErrorInfo<CustomBlockUpdatePageErrorCode>;
|
|
6
6
|
export declare const customBlockUpdatePageErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -313,7 +313,7 @@ export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
313
313
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
314
314
|
}, undefined>;
|
|
315
315
|
}, undefined>], undefined>;
|
|
316
|
-
export declare const
|
|
316
|
+
export declare const updatePageResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
317
317
|
readonly type: v.LiteralSchema<"updatePageResult", undefined>;
|
|
318
318
|
readonly requestId: v.StringSchema<undefined>;
|
|
319
319
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
@@ -892,4 +892,4 @@ export declare const updatePageResultMessageLegacySchema: v.VariantSchema<"statu
|
|
|
892
892
|
}, undefined>;
|
|
893
893
|
}, undefined>], undefined>;
|
|
894
894
|
export type UpdatePageResultMessage = v.InferOutput<typeof updatePageResultMessageSchema>;
|
|
895
|
-
export type
|
|
895
|
+
export type UpdatePageResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof updatePageResultMessageWithProtocol3To5CompatibilitySchema>;
|
|
@@ -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"),
|
|
@@ -25,12 +25,12 @@ export const updatePageResultMessageSchema = v.variant("status", [
|
|
|
25
25
|
error: customBlockUpdatePageErrorInfoSchema,
|
|
26
26
|
}),
|
|
27
27
|
]);
|
|
28
|
-
export const
|
|
28
|
+
export const updatePageResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
|
|
29
29
|
v.object({
|
|
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,8 +1138,8 @@ 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
|
|
1142
|
-
export declare const
|
|
1141
|
+
export type BridgePage = v.InferInput<typeof bridgePageSchema>;
|
|
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">]>;
|
|
1145
1145
|
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -1418,5 +1418,5 @@ export declare const legacyNotionPageSchema: v.ObjectSchema<{
|
|
|
1418
1418
|
/** Whether the page or an ancestor is in Trash. */
|
|
1419
1419
|
readonly in_trash: v.BooleanSchema<undefined>;
|
|
1420
1420
|
}, undefined>;
|
|
1421
|
-
export type
|
|
1421
|
+
export type NotionPageForProtocol3To5 = v.InferOutput<typeof notionPageForProtocol3To5Schema>;
|
|
1422
1422
|
export {};
|
|
@@ -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,
|
|
@@ -300,7 +300,7 @@ export const notionPageDataSchema = v.object({
|
|
|
300
300
|
/** Whether the page or an ancestor is in Trash. */
|
|
301
301
|
in_trash: v.boolean(),
|
|
302
302
|
});
|
|
303
|
-
export const
|
|
303
|
+
export const notionPageForProtocol3To5Schema = v.object({
|
|
304
304
|
object: v.literal("page"),
|
|
305
305
|
id: notionPageIdSchema,
|
|
306
306
|
parent: notionParentSchema,
|
|
@@ -23,7 +23,7 @@ export declare const notionParentSchema: v.VariantSchema<"type", [v.ObjectSchema
|
|
|
23
23
|
* Uses Notion public API parent names, plus an unavailable state:
|
|
24
24
|
* - `page_id` — parented directly under a page.
|
|
25
25
|
* - `block_id` — parented under a non-page container block (toggle, column, callout, ...).
|
|
26
|
-
* - `data_source_id` — parented under a
|
|
26
|
+
* - `data_source_id` — parented under a data source.
|
|
27
27
|
* - `workspace` — top-level / team-rooted.
|
|
28
28
|
* - `agent_id` — owned by an agent, such as an agent instruction page or its blocks.
|
|
29
29
|
* - `unavailable` — the viewer cannot access the parent resource. Neither its ID nor its kind
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export declare const LATEST_BRIDGE_PROTOCOL_VERSION =
|
|
7
|
-
export declare const
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 8;
|
|
7
|
+
export declare const UNIFIED_PAGE_PROTOCOL_VERSION = 6;
|
|
8
8
|
export declare const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export const LATEST_BRIDGE_PROTOCOL_VERSION =
|
|
6
|
+
export const LATEST_BRIDGE_PROTOCOL_VERSION = 8;
|
|
7
7
|
// Protocol 6 introduces unified pages with name-keyed property objects.
|
|
8
8
|
// Keep this cutoff fixed when the latest protocol version increases.
|
|
9
|
-
export const
|
|
9
|
+
export const UNIFIED_PAGE_PROTOCOL_VERSION = 6;
|
|
10
10
|
// Protocol 7 adds typed text fallbacks for previously unsupported page properties.
|
|
11
11
|
export const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
|
|
@@ -3,8 +3,8 @@ import type { UseDataSourceOptions, UseDataSourceResult } from "../types.js";
|
|
|
3
3
|
* Reads from the data source mapped to the given semantic `key`.
|
|
4
4
|
*
|
|
5
5
|
* @param key - The semantic data source key the block is wired to (e.g. `"people"`).
|
|
6
|
-
* @param options - Optional live snapshot options.
|
|
7
|
-
*
|
|
6
|
+
* @param options - Optional live snapshot options. The host enforces the maximum row
|
|
7
|
+
* limit. `sorts` are applied in array order.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* const { items, propertyIdsByKey, isLoading, hasMore, error } = useDataSource("default", { limit: 25 })
|
|
@@ -12,8 +12,8 @@ const EMPTY_DATA_SOURCE_RESULT = {
|
|
|
12
12
|
* Reads from the data source mapped to the given semantic `key`.
|
|
13
13
|
*
|
|
14
14
|
* @param key - The semantic data source key the block is wired to (e.g. `"people"`).
|
|
15
|
-
* @param options - Optional live snapshot options.
|
|
16
|
-
*
|
|
15
|
+
* @param options - Optional live snapshot options. The host enforces the maximum row
|
|
16
|
+
* limit. `sorts` are applied in array order.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* const { items, propertyIdsByKey, isLoading, hasMore, error } = useDataSource("default", { limit: 25 })
|
package/dist/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { CustomBlockOpenPageErrorInfo, OpenPageMode, OpenPageResultMessage
|
|
|
11
11
|
import type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockRelationFilterOperator, CustomBlockStatusFilterOperator, CustomBlockTextFilterOperator } from "./protocol/messages/queryDataSource.js";
|
|
12
12
|
import type { CustomBlockQueryDataSourceErrorInfo } from "./protocol/messages/queryDataSourceResult.js";
|
|
13
13
|
import type { CustomBlockUpdatePageErrorInfo } from "./protocol/messages/updatePageResult.js";
|
|
14
|
-
import type { NotionPageCover, NotionPageIcon, NotionPagePropertyValue, NotionPagePropertyWriteMap
|
|
14
|
+
import type { bridgePageSchema, NotionPageCover, NotionPageIcon, NotionPagePropertyValue, NotionPagePropertyWriteMap } from "./protocol/pages/page.js";
|
|
15
15
|
import type { InferOutput } from "valibot";
|
|
16
16
|
import type { ExclusiveUnion } from "./typeUtils.js";
|
|
17
17
|
export type { CustomBlockErrorInfo } from "./protocol/errors.js";
|
|
@@ -33,7 +33,7 @@ export type NotionPagePropertyInputValue = Exclude<NotionPagePropertyWriteMap[st
|
|
|
33
33
|
export type NotionPagePropertyInputMap = {
|
|
34
34
|
[propertyIdOrKey: string]: NotionPagePropertyInputValue;
|
|
35
35
|
};
|
|
36
|
-
export type NotionPage = InferOutput<typeof
|
|
36
|
+
export type NotionPage = InferOutput<typeof bridgePageSchema> & {
|
|
37
37
|
dataSourceKey: string | null;
|
|
38
38
|
getPropertyById: (propertyId: string) => NotionPagePropertyValue | null;
|
|
39
39
|
getPropertyByKey: (propertyKey: string) => NotionPagePropertyValue | null;
|
|
@@ -161,9 +161,9 @@ export type UseDataSourceOptions = DataSourceQueryOptions;
|
|
|
161
161
|
* parent shape; see https://developers.notion.com/reference/data-source.
|
|
162
162
|
*
|
|
163
163
|
* - `page_id`: Create a child page under the given Notion page.
|
|
164
|
-
* - `data_source_id`: Create a row inside the given Notion data source
|
|
165
|
-
*
|
|
166
|
-
*
|
|
164
|
+
* - `data_source_id`: Create a row inside the given Notion data source. The public API's
|
|
165
|
+
* `data_source_id` is the same UUID as the `collectionPointer.id` exposed in `dataSources`,
|
|
166
|
+
* so either value works here.
|
|
167
167
|
* - `data_source_key`: Create a row inside the data source that the custom block was configured with
|
|
168
168
|
* under this semantic key. The SDK resolves the key to a `data_source_id` locally before
|
|
169
169
|
* sending the request to the host.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+DAA+D,CAAA;AACxG,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,6BAA6B,EAC7B,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,mCAAmC,EACnC,4BAA4B,EAC5B,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EACX,4BAA4B,EAC5B,YAAY,E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B,EACrB,4BAA4B,CAC5B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CACvD,4BAA4B,EAC5B,mCAAmC,CACnC,CAAA;AAED,MAAM,MAAM,gBAAgB,GACzB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACvC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,8BAA8B,CAAA;CAAE,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;AAExE,MAAM,MAAM,eAAe,GAAG,oBAAoB,CACjD,sBAAsB,EACtB,6BAA6B,CAC7B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,CAAA"}
|
package/dist/version.js
CHANGED
package/docs/block-location.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Block location and appearance
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Host context includes the block's location, current user, manifest, theme, and contrast mode. These
|
|
4
|
+
APIs let your block respond to its context and match Notion's appearance. This reference covers
|
|
5
|
+
getters for current values, subscriptions for initial values and later changes, and React hooks for
|
|
6
|
+
components.
|
|
5
7
|
|
|
6
8
|
## API overview
|
|
7
9
|
|
|
@@ -51,7 +53,7 @@ console.log(customBlock.getTheme()) // Read the current theme once.
|
|
|
51
53
|
## Current user
|
|
52
54
|
|
|
53
55
|
Use `getCurrentUser()`, `subscribeToCurrentUser()`, and `useCurrentUser()` to access the viewing
|
|
54
|
-
user's `NotionUser`. See [users](
|
|
56
|
+
user's `NotionUser`. See [users](users.md#reading-the-current-user) for profile fields and user
|
|
55
57
|
APIs.
|
|
56
58
|
|
|
57
59
|
## Custom block ID
|
|
@@ -171,5 +173,5 @@ Use `getManifest()`, `subscribeToManifest()`, and `useManifest()` to access the
|
|
|
171
173
|
`CustomBlockManifest`. The manifest stays fixed for the lifetime of the running block, so each
|
|
172
174
|
subscription delivers it once. You can register before initialization without an error.
|
|
173
175
|
|
|
174
|
-
See [data sources](
|
|
176
|
+
See [data sources](data-sources.md) for manifest details and `subscribeToDataSource()` for query
|
|
175
177
|
snapshots.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Bridge message interceptors
|
|
2
2
|
|
|
3
|
+
Bridge message interceptors inspect outgoing SDK requests or supply responses without a host round
|
|
4
|
+
trip. This reference describes registration, response matching, and cleanup for controlled bridge
|
|
5
|
+
integrations.
|
|
6
|
+
|
|
3
7
|
Import `registerMessageInterceptor` from `@notionhq/custom-blocks/bridge` to inspect or replace SDK
|
|
4
8
|
messages sent to the host. The function accepts a `MessageInterceptor` and returns a function that
|
|
5
9
|
removes it.
|
package/docs/build-tools.md
CHANGED
|
@@ -13,8 +13,8 @@ import { build, upload } from "@notionhq/custom-blocks/bundle"
|
|
|
13
13
|
|
|
14
14
|
`build(args: BuildArgs)` returns a `Promise<BuildOutput>`. By default, it imports the worker bundle
|
|
15
15
|
at `dist/index.js` and reads its custom block capabilities. With `manifest`, it reads an Apps SDK
|
|
16
|
-
capability manifest from a JSON file instead.
|
|
17
|
-
block
|
|
16
|
+
capability manifest from a JSON file instead. That file contains a `capabilities` array. Each custom
|
|
17
|
+
block capability contains its block manifest in `config.manifest`.
|
|
18
18
|
|
|
19
19
|
`BuildArgs` contains these fields:
|
|
20
20
|
|
|
@@ -34,6 +34,9 @@ The equivalent CLI command is `notion-custom-blocks build --out <dir>`. It accep
|
|
|
34
34
|
`--manifest` with the same path rules. `printBuildOutput` writes a `BuildOutput` as single-line JSON
|
|
35
35
|
between `<__notion_custom_block__>` and `</__notion_custom_block__>`.
|
|
36
36
|
|
|
37
|
+
For dependency placement, see
|
|
38
|
+
[Browser and server dependencies](deployment.md#browser-and-server-dependencies).
|
|
39
|
+
|
|
37
40
|
## Upload bundles
|
|
38
41
|
|
|
39
42
|
`upload(targets: UploadsInput)` returns a `Promise<UploadOutput>`. `UploadsInput` maps block keys to
|