@notionhq/custom-blocks 0.0.76 → 0.0.78
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/HOST.md +68 -37
- package/bin/src/bridge/manifest.js +3 -3
- package/dist/bridge/SandboxBridge.d.ts +6 -12
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +123 -71
- package/dist/bridge/dataSources/resolve.d.ts +3 -4
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolve.js +2 -12
- package/dist/bridge/hostState.d.ts +3 -2
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/loadManifest.d.ts +4 -4
- package/dist/bridge/loadManifest.d.ts.map +1 -1
- package/dist/bridge/loadManifest.js +2 -2
- package/dist/bridge/manifest.d.ts +3 -3
- package/dist/bridge/manifest.js +3 -3
- package/dist/bridge/messages/{ready.d.ts → connect.d.ts} +13 -11
- package/dist/bridge/messages/connect.d.ts.map +1 -0
- package/dist/bridge/messages/{ready.js → connect.js} +14 -13
- package/dist/bridge/messages/hostToSandbox.d.ts +24 -79
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
- package/dist/bridge/messages/hostToSandbox.js +2 -3
- package/dist/bridge/messages/init.d.ts +35 -6
- package/dist/bridge/messages/init.d.ts.map +1 -1
- package/dist/bridge/messages/init.js +8 -4
- package/dist/bridge/messages/initResult.d.ts +29 -0
- package/dist/bridge/messages/initResult.d.ts.map +1 -0
- package/dist/bridge/messages/initResult.js +25 -0
- package/dist/bridge/messages/queryDataSource.d.ts +3 -7
- package/dist/bridge/messages/queryDataSource.d.ts.map +1 -1
- package/dist/bridge/messages/queryDataSource.js +3 -7
- package/dist/bridge/messages/queryDataSourceResult.d.ts +4 -240
- package/dist/bridge/messages/queryDataSourceResult.d.ts.map +1 -1
- package/dist/bridge/messages/queryDataSourceResult.js +4 -22
- package/dist/bridge/messages/sandboxToHost.d.ts +21 -7
- package/dist/bridge/messages/sandboxToHost.d.ts.map +1 -1
- package/dist/bridge/messages/sandboxToHost.js +4 -2
- package/dist/bridge/sandboxClient.d.ts +2 -4
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/bridge/sandboxClient.js +2 -5
- package/dist/customBlock.d.ts +1 -1
- package/dist/customBlock.d.ts.map +1 -1
- package/dist/customBlock.js +1 -1
- package/dist/host/createCustomBlockHost.d.ts +6 -3
- package/dist/host/createCustomBlockHost.d.ts.map +1 -1
- package/dist/host/createCustomBlockHost.js +227 -58
- package/dist/host/lifecycle/initErrors.d.ts +1 -1
- package/dist/host/lifecycle/initErrors.d.ts.map +1 -1
- package/dist/host/lifecycle/initErrors.js +25 -7
- package/dist/host/lifecycle/types.d.ts +6 -4
- package/dist/host/lifecycle/types.d.ts.map +1 -1
- package/dist/host/messages/invalidSandboxMessage.js +0 -3
- package/dist/host/queries/querySubscriptions.d.ts +10 -10
- package/dist/host/queries/querySubscriptions.d.ts.map +1 -1
- package/dist/host/queries/querySubscriptions.js +35 -19
- package/dist/host/queries/types.d.ts +5 -4
- package/dist/host/queries/types.d.ts.map +1 -1
- package/dist/host.d.ts +5 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/init.d.ts +7 -7
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +70 -50
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/standalonePreview.d.ts.map +1 -1
- package/dist/react/standalonePreview.js +2 -0
- package/dist/react/useCustomBlockInit.d.ts +5 -6
- package/dist/react/useCustomBlockInit.d.ts.map +1 -1
- package/dist/react/useCustomBlockInit.js +3 -19
- package/dist/react/useRuntimeState.d.ts +4 -3
- package/dist/react/useRuntimeState.d.ts.map +1 -1
- package/dist/react/useRuntimeState.js +3 -2
- package/dist/version.js +1 -1
- package/docs/data-sources.md +7 -5
- package/docs/errors.md +5 -1
- package/docs/lifecycle.md +19 -31
- package/docs/manifest.md +1 -1
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +151 -77
- package/src/bridge/dataSources/resolve.ts +3 -14
- package/src/bridge/hostState.ts +3 -2
- package/src/bridge/loadManifest.ts +6 -6
- package/src/bridge/manifest.ts +3 -3
- package/src/bridge/messages/{ready.ts → connect.ts} +15 -14
- package/src/bridge/messages/hostToSandbox.ts +2 -6
- package/src/bridge/messages/init.ts +24 -10
- package/src/bridge/messages/initResult.ts +37 -0
- package/src/bridge/messages/queryDataSource.ts +3 -7
- package/src/bridge/messages/queryDataSourceResult.ts +4 -24
- package/src/bridge/messages/sandboxToHost.ts +4 -2
- package/src/bridge/sandboxClient.ts +3 -8
- package/src/customBlock.ts +2 -2
- package/src/host/createCustomBlockHost.ts +269 -64
- package/src/host/lifecycle/initErrors.ts +25 -7
- package/src/host/lifecycle/types.ts +13 -4
- package/src/host/messages/invalidSandboxMessage.ts +0 -3
- package/src/host/queries/querySubscriptions.ts +58 -39
- package/src/host/queries/types.ts +10 -11
- package/src/host.ts +13 -2
- package/src/index.ts +3 -1
- package/src/init.ts +73 -60
- package/src/react/index.ts +0 -1
- package/src/react/standalonePreview.ts +2 -0
- package/src/react/useCustomBlockInit.ts +6 -27
- package/src/react/useRuntimeState.ts +4 -3
- package/dist/bridge/messages/ready.d.ts.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { manifestSchema } from "../manifest.js";
|
|
3
|
-
const
|
|
4
|
-
type: v.literal("
|
|
3
|
+
const connectMessageCommonEntries = {
|
|
4
|
+
type: v.literal("connect"),
|
|
5
|
+
initializationId: v.string(),
|
|
5
6
|
/**
|
|
6
7
|
* Used to ensure that the host and client are using the same version of the bridge protocol. A
|
|
7
8
|
* single host needs to support multiple custom blocks built with different versions of the bridge
|
|
@@ -9,35 +10,35 @@ const readyMessageCommonEntries = {
|
|
|
9
10
|
*/
|
|
10
11
|
bridgeProtocolVersion: v.number(),
|
|
11
12
|
/**
|
|
12
|
-
* Semver version of the SDK package that sent this
|
|
13
|
+
* Semver version of the SDK package that sent this connect message. Should only be used for
|
|
13
14
|
* analytics purposes. Business logic should compare against `bridgeProtocolVersion` instead.
|
|
14
15
|
*/
|
|
15
16
|
sdkVersion: v.string(),
|
|
16
17
|
};
|
|
17
18
|
// TODO(custom-blocks): Replace with `customBlockErrorInfoSchema` which makes `isRetryable` required
|
|
18
19
|
// once min supported bridge protocol version is bumped to 3.
|
|
19
|
-
const
|
|
20
|
+
const connectErrorSchema = v.object({
|
|
20
21
|
code: v.string(),
|
|
21
22
|
message: v.string(),
|
|
22
23
|
isRetryable: v.optional(v.boolean(), false),
|
|
23
24
|
});
|
|
24
25
|
/**
|
|
25
|
-
* First message the sandbox sends after mount
|
|
26
|
-
*
|
|
26
|
+
* First message the sandbox sends after mount. It identifies the sandbox and starts the bridge
|
|
27
|
+
* initialization exchange. The host echoes `initializationId` in its `init` response.
|
|
27
28
|
*/
|
|
28
|
-
export const
|
|
29
|
+
export const connectMessageSchema = v.variant("status", [
|
|
29
30
|
v.object({
|
|
30
31
|
status: v.literal("success"),
|
|
31
32
|
/**
|
|
32
|
-
* The data sources and settings the custom block expects
|
|
33
|
-
*
|
|
33
|
+
* The data sources and settings the custom block expects. Hosts may omit
|
|
34
|
+
* this when they already have an authoritative manifest.
|
|
34
35
|
*/
|
|
35
|
-
manifest: v.
|
|
36
|
-
...
|
|
36
|
+
manifest: v.optional(manifestSchema),
|
|
37
|
+
...connectMessageCommonEntries,
|
|
37
38
|
}),
|
|
38
39
|
v.object({
|
|
39
40
|
status: v.literal("error"),
|
|
40
|
-
error:
|
|
41
|
-
...
|
|
41
|
+
error: connectErrorSchema,
|
|
42
|
+
...connectMessageCommonEntries,
|
|
42
43
|
}),
|
|
43
44
|
]);
|
|
@@ -4,6 +4,7 @@ import * as v from "valibot";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.VariantSchema<"status", [v.ObjectSchema<{
|
|
6
6
|
readonly type: v.LiteralSchema<"init", undefined>;
|
|
7
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
7
8
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
8
9
|
readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
|
|
9
10
|
readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
@@ -42,6 +43,25 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
42
43
|
readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
43
44
|
}, undefined>], undefined>;
|
|
44
45
|
}, undefined>;
|
|
46
|
+
readonly manifest: v.ObjectSchema<{
|
|
47
|
+
readonly version: v.LiteralSchema<1, undefined>;
|
|
48
|
+
readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
49
|
+
readonly name: v.StringSchema<undefined>;
|
|
50
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
51
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
52
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
53
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
54
|
+
}, undefined>, v.ObjectSchema<{
|
|
55
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
56
|
+
readonly url: v.StringSchema<undefined>;
|
|
57
|
+
}, undefined>], undefined>, undefined>;
|
|
58
|
+
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
59
|
+
readonly name: v.StringSchema<undefined>;
|
|
60
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
62
|
+
}, undefined>, undefined>, {}>;
|
|
63
|
+
}, undefined>, undefined>;
|
|
64
|
+
}, undefined>;
|
|
45
65
|
readonly dataSources: v.ObjectSchema<{
|
|
46
66
|
readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
47
67
|
readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -201,6 +221,7 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
201
221
|
}, undefined>;
|
|
202
222
|
}, undefined>, v.ObjectSchema<{
|
|
203
223
|
readonly type: v.LiteralSchema<"init", undefined>;
|
|
224
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
204
225
|
readonly status: v.LiteralSchema<"error", undefined>;
|
|
205
226
|
readonly error: v.ObjectSchema<{
|
|
206
227
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -412,8 +433,7 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
412
433
|
}, undefined>;
|
|
413
434
|
}, undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
414
435
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
415
|
-
readonly
|
|
416
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
436
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
417
437
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
418
438
|
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
419
439
|
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
@@ -482,89 +502,14 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
482
502
|
readonly hasMore: v.BooleanSchema<undefined>;
|
|
483
503
|
}, undefined>, v.ObjectSchema<{
|
|
484
504
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
485
|
-
readonly
|
|
486
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
505
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
487
506
|
readonly status: v.LiteralSchema<"error", undefined>;
|
|
488
507
|
readonly error: v.ObjectSchema<{
|
|
489
508
|
readonly code: v.StringSchema<undefined>;
|
|
490
509
|
readonly message: v.StringSchema<undefined>;
|
|
491
510
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
492
511
|
}, undefined>;
|
|
493
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
494
|
-
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
495
|
-
readonly requestId: v.StringSchema<undefined>;
|
|
496
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
497
|
-
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
498
|
-
readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
499
|
-
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<{
|
|
500
|
-
readonly type: v.LiteralSchema<"date", undefined>;
|
|
501
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
502
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
503
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
504
|
-
readonly value: v.NumberSchema<undefined>;
|
|
505
|
-
readonly time: v.StringSchema<undefined>;
|
|
506
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
507
|
-
}, undefined>, v.ObjectSchema<{
|
|
508
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
509
|
-
}, undefined>], undefined>, undefined>;
|
|
510
|
-
}, undefined>, v.ObjectSchema<{
|
|
511
|
-
readonly type: v.LiteralSchema<"daterange", undefined>;
|
|
512
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
513
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
514
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
515
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
516
|
-
readonly value: v.NumberSchema<undefined>;
|
|
517
|
-
readonly time: v.StringSchema<undefined>;
|
|
518
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
519
|
-
}, undefined>, v.ObjectSchema<{
|
|
520
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
521
|
-
}, undefined>], undefined>, undefined>;
|
|
522
|
-
}, undefined>, v.ObjectSchema<{
|
|
523
|
-
readonly type: v.LiteralSchema<"datetime", undefined>;
|
|
524
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
525
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
526
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
527
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
528
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
529
|
-
readonly value: v.NumberSchema<undefined>;
|
|
530
|
-
readonly time: v.StringSchema<undefined>;
|
|
531
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
532
|
-
}, undefined>, v.ObjectSchema<{
|
|
533
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
534
|
-
readonly value: v.NumberSchema<undefined>;
|
|
535
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
536
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
537
|
-
}, undefined>], undefined>, undefined>;
|
|
538
|
-
}, undefined>, v.ObjectSchema<{
|
|
539
|
-
readonly type: v.LiteralSchema<"datetimerange", undefined>;
|
|
540
|
-
readonly start_date: v.StringSchema<undefined>;
|
|
541
|
-
readonly start_time: v.StringSchema<undefined>;
|
|
542
|
-
readonly end_date: v.StringSchema<undefined>;
|
|
543
|
-
readonly end_time: v.StringSchema<undefined>;
|
|
544
|
-
readonly time_zone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
545
|
-
readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
|
|
546
|
-
readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
|
|
547
|
-
readonly value: v.NumberSchema<undefined>;
|
|
548
|
-
readonly time: v.StringSchema<undefined>;
|
|
549
|
-
readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
550
|
-
}, undefined>, v.ObjectSchema<{
|
|
551
|
-
readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
|
|
552
|
-
readonly value: v.NumberSchema<undefined>;
|
|
553
|
-
}, undefined>], undefined>, v.ObjectSchema<{
|
|
554
|
-
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
555
|
-
}, undefined>], undefined>, undefined>;
|
|
556
|
-
}, undefined>], undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ArraySchema<v.ObjectSchema<{
|
|
557
|
-
readonly id: v.StringSchema<undefined>;
|
|
558
|
-
readonly table: v.StringSchema<undefined>;
|
|
559
|
-
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
560
|
-
}, undefined>, undefined>;
|
|
561
|
-
readonly hasMore: v.BooleanSchema<undefined>;
|
|
562
|
-
readonly error: v.OptionalSchema<v.ObjectSchema<{
|
|
563
|
-
readonly code: v.StringSchema<undefined>;
|
|
564
|
-
readonly message: v.StringSchema<undefined>;
|
|
565
|
-
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
566
|
-
}, undefined>, undefined>;
|
|
567
|
-
}, undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
512
|
+
}, undefined>], undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
568
513
|
readonly type: v.LiteralSchema<"createPageResult", undefined>;
|
|
569
514
|
readonly requestId: v.StringSchema<undefined>;
|
|
570
515
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostToSandbox.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/hostToSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"hostToSandbox.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/hostToSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAe5B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAcrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
|
|
@@ -9,7 +9,7 @@ import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js";
|
|
|
9
9
|
import { listUsersResultMessageSchema } from "./listUsers.js";
|
|
10
10
|
import { pageChangedMessageSchema } from "./pageChanged.js";
|
|
11
11
|
import { parentChangedMessageSchema } from "./parentChanged.js";
|
|
12
|
-
import {
|
|
12
|
+
import { queryDataSourceResultMessageSchema } from "./queryDataSourceResult.js";
|
|
13
13
|
import { themeChangedMessageSchema } from "./themeChanged.js";
|
|
14
14
|
import { updatePageResultMessageSchema } from "./updatePageResult.js";
|
|
15
15
|
/**
|
|
@@ -22,8 +22,7 @@ export const hostToSandboxMessageSchema = v.variant("type", [
|
|
|
22
22
|
pageChangedMessageSchema,
|
|
23
23
|
currentUserChangedMessageSchema,
|
|
24
24
|
dataSourcesChangedMessageSchema,
|
|
25
|
-
|
|
26
|
-
legacyQueryDataSourceResultMessageSchema,
|
|
25
|
+
queryDataSourceResultMessageSchema,
|
|
27
26
|
createPageResultMessageSchema,
|
|
28
27
|
getPageResultMessageSchema,
|
|
29
28
|
getUserResultMessageSchema,
|
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
|
+
import type { CustomBlockInitResultErrorCode } from "./initResult.js";
|
|
3
4
|
export declare const customBlockInitErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockInitErrorCode = CustomBlockErrorCode<"
|
|
5
|
+
export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_protocol_version" | "unsupported_protocol_version" | "context_unavailable" | "current_user_unavailable" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
|
|
5
6
|
export type CustomBlockInitErrorInfo = CustomBlockErrorInfo<CustomBlockInitErrorCode>;
|
|
7
|
+
/**
|
|
8
|
+
* Every initialization failure visible to block code. This combines errors
|
|
9
|
+
* received in `init`, errors the sandbox reports in `initResult`, and failures
|
|
10
|
+
* detected locally while running `initCustomBlock()`.
|
|
11
|
+
*/
|
|
12
|
+
export type CustomBlockInitializationErrorCode = CustomBlockInitErrorCode | CustomBlockInitResultErrorCode | CustomBlockErrorCode<"not_in_iframe" | "init_timeout">;
|
|
13
|
+
export type CustomBlockInitializationErrorInfo = CustomBlockErrorInfo<CustomBlockInitializationErrorCode>;
|
|
6
14
|
export declare const customBlockInitErrorInfoSchema: v.ObjectSchema<{
|
|
7
15
|
readonly code: v.StringSchema<undefined>;
|
|
8
16
|
readonly message: v.StringSchema<undefined>;
|
|
9
17
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
10
18
|
}, undefined>;
|
|
11
|
-
export declare class
|
|
12
|
-
constructor(error:
|
|
13
|
-
code:
|
|
19
|
+
export declare class CustomBlockInitializationError extends Error implements CustomBlockErrorInfo {
|
|
20
|
+
constructor(error: CustomBlockInitializationErrorInfo);
|
|
21
|
+
code: CustomBlockInitializationErrorCode;
|
|
14
22
|
isRetryable: boolean;
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* Initialization message sent by the host to the sandbox exactly once, in response to the
|
|
18
|
-
* sandbox's `
|
|
19
|
-
*
|
|
26
|
+
* sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
|
|
27
|
+
* successful initialization, live updates flow through narrower messages.
|
|
20
28
|
*/
|
|
21
29
|
export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
22
30
|
readonly type: v.LiteralSchema<"init", undefined>;
|
|
31
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
23
32
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
24
33
|
readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
|
|
25
34
|
readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
@@ -58,6 +67,25 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
|
|
|
58
67
|
readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
59
68
|
}, undefined>], undefined>;
|
|
60
69
|
}, undefined>;
|
|
70
|
+
readonly manifest: v.ObjectSchema<{
|
|
71
|
+
readonly version: v.LiteralSchema<1, undefined>;
|
|
72
|
+
readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
73
|
+
readonly name: v.StringSchema<undefined>;
|
|
74
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
75
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
76
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
77
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
78
|
+
}, undefined>, v.ObjectSchema<{
|
|
79
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
80
|
+
readonly url: v.StringSchema<undefined>;
|
|
81
|
+
}, undefined>], undefined>, undefined>;
|
|
82
|
+
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
83
|
+
readonly name: v.StringSchema<undefined>;
|
|
84
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
86
|
+
}, undefined>, undefined>, {}>;
|
|
87
|
+
}, undefined>, undefined>;
|
|
88
|
+
}, undefined>;
|
|
61
89
|
readonly dataSources: v.ObjectSchema<{
|
|
62
90
|
readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
63
91
|
readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -217,6 +245,7 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
|
|
|
217
245
|
}, undefined>;
|
|
218
246
|
}, undefined>, v.ObjectSchema<{
|
|
219
247
|
readonly type: v.LiteralSchema<"init", undefined>;
|
|
248
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
220
249
|
readonly status: v.LiteralSchema<"error", undefined>;
|
|
221
250
|
readonly error: v.ObjectSchema<{
|
|
222
251
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAO9E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAA;AAIrE,eAAO,MAAM,8BAA8B,2BAAa,CAAA;AAExD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CACxD,sBAAsB,GACtB,kBAAkB,GAClB,0BAA0B,GAC1B,8BAA8B,GAC9B,qBAAqB,GACrB,0BAA0B,GAC1B,6BAA6B,GAC7B,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,CAC5B,CAAA;AAED,MAAM,MAAM,wBAAwB,GACnC,oBAAoB,CAAC,wBAAwB,CAAC,CAAA;AAE/C;;;;GAIG;AACH,MAAM,MAAM,kCAAkC,GAC3C,wBAAwB,GACxB,8BAA8B,GAC9B,oBAAoB,CAAC,eAAe,GAAG,cAAc,CAAC,CAAA;AAEzD,MAAM,MAAM,kCAAkC,GAC7C,oBAAoB,CAAC,kCAAkC,CAAC,CAAA;AAEzD,eAAO,MAAM,8BAA8B;;;;aAIzC,CAAA;AAEF,qBAAa,8BACZ,SAAQ,KACR,YAAW,oBAAoB;gBAEnB,KAAK,EAAE,kCAAkC;IAOrD,IAAI,EAAE,kCAAkC,CAAA;IACxC,WAAW,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAqB5B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionDataSourceBindingsSchema } from "../dataSources/dataSource.js";
|
|
3
3
|
import { notionBlockIdSchema } from "../ids.js";
|
|
4
|
+
import { manifestSchema } from "../manifest.js";
|
|
4
5
|
import { customBlockPageSchema } from "../pages/page.js";
|
|
5
6
|
import { notionParentSchema } from "../parent.js";
|
|
6
7
|
import { notionThemeSchema } from "../theme.js";
|
|
@@ -13,27 +14,29 @@ export const customBlockInitErrorInfoSchema = v.object({
|
|
|
13
14
|
message: v.string(),
|
|
14
15
|
isRetryable: v.boolean(),
|
|
15
16
|
});
|
|
16
|
-
export class
|
|
17
|
+
export class CustomBlockInitializationError extends Error {
|
|
17
18
|
constructor(error) {
|
|
18
19
|
super(error.message);
|
|
19
|
-
this.name = "
|
|
20
|
+
this.name = "CustomBlockInitializationError";
|
|
20
21
|
this.code = error.code;
|
|
21
22
|
this.isRetryable = error.isRetryable;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Initialization message sent by the host to the sandbox exactly once, in response to the
|
|
26
|
-
* sandbox's `
|
|
27
|
-
*
|
|
27
|
+
* sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
|
|
28
|
+
* successful initialization, live updates flow through narrower messages.
|
|
28
29
|
*/
|
|
29
30
|
export const initMessageSchema = v.variant("status", [
|
|
30
31
|
v.object({
|
|
31
32
|
type: v.literal("init"),
|
|
33
|
+
initializationId: v.string(),
|
|
32
34
|
status: v.literal("success"),
|
|
33
35
|
theme: notionThemeSchema,
|
|
34
36
|
blockId: notionBlockIdSchema,
|
|
35
37
|
parent: notionParentSchema,
|
|
36
38
|
page: customBlockPageSchema,
|
|
39
|
+
manifest: manifestSchema,
|
|
37
40
|
dataSources: v.object({
|
|
38
41
|
bindings: notionDataSourceBindingsSchema,
|
|
39
42
|
}),
|
|
@@ -41,6 +44,7 @@ export const initMessageSchema = v.variant("status", [
|
|
|
41
44
|
}),
|
|
42
45
|
v.object({
|
|
43
46
|
type: v.literal("init"),
|
|
47
|
+
initializationId: v.string(),
|
|
44
48
|
status: v.literal("error"),
|
|
45
49
|
error: customBlockInitErrorInfoSchema,
|
|
46
50
|
}),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
|
+
export declare const customBlockInitResultErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
+
export type CustomBlockInitResultErrorCode = CustomBlockErrorCode<"invalid_init_bindings">;
|
|
5
|
+
export type CustomBlockInitResultErrorInfo = CustomBlockErrorInfo<CustomBlockInitResultErrorCode>;
|
|
6
|
+
export declare const customBlockInitResultErrorInfoSchema: v.ObjectSchema<{
|
|
7
|
+
readonly code: v.StringSchema<undefined>;
|
|
8
|
+
readonly message: v.StringSchema<undefined>;
|
|
9
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Acknowledges whether the sandbox successfully applied the host's `init` response.
|
|
13
|
+
*/
|
|
14
|
+
export declare const initResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
15
|
+
readonly type: v.LiteralSchema<"initResult", undefined>;
|
|
16
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
17
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
18
|
+
}, undefined>, v.ObjectSchema<{
|
|
19
|
+
readonly type: v.LiteralSchema<"initResult", undefined>;
|
|
20
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
21
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
22
|
+
readonly error: v.ObjectSchema<{
|
|
23
|
+
readonly code: v.StringSchema<undefined>;
|
|
24
|
+
readonly message: v.StringSchema<undefined>;
|
|
25
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
26
|
+
}, undefined>;
|
|
27
|
+
}, undefined>], undefined>;
|
|
28
|
+
export type InitResultMessage = v.InferOutput<typeof initResultMessageSchema>;
|
|
29
|
+
//# sourceMappingURL=initResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initResult.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/initResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAI9E,eAAO,MAAM,oCAAoC,2BAAa,CAAA;AAE9D,MAAM,MAAM,8BAA8B,GACzC,oBAAoB,CAAC,uBAAuB,CAAC,CAAA;AAE9C,MAAM,MAAM,8BAA8B,GACzC,oBAAoB,CAAC,8BAA8B,CAAC,CAAA;AAErD,eAAO,MAAM,oCAAoC;;;;aAI/C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;0BAYlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
// The schema accepts any string code. The type lists known codes for
|
|
3
|
+
// autocomplete, with an open string fallback for newer senders.
|
|
4
|
+
export const customBlockInitResultErrorCodeSchema = v.string();
|
|
5
|
+
export const customBlockInitResultErrorInfoSchema = v.object({
|
|
6
|
+
code: customBlockInitResultErrorCodeSchema,
|
|
7
|
+
message: v.string(),
|
|
8
|
+
isRetryable: v.boolean(),
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Acknowledges whether the sandbox successfully applied the host's `init` response.
|
|
12
|
+
*/
|
|
13
|
+
export const initResultMessageSchema = v.variant("status", [
|
|
14
|
+
v.object({
|
|
15
|
+
type: v.literal("initResult"),
|
|
16
|
+
initializationId: v.string(),
|
|
17
|
+
status: v.literal("success"),
|
|
18
|
+
}),
|
|
19
|
+
v.object({
|
|
20
|
+
type: v.literal("initResult"),
|
|
21
|
+
initializationId: v.string(),
|
|
22
|
+
status: v.literal("error"),
|
|
23
|
+
error: customBlockInitResultErrorInfoSchema,
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
@@ -5,15 +5,11 @@ import * as v from "valibot";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
7
7
|
readonly type: v.LiteralSchema<"queryDataSource", undefined>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* The stable snapshot ID that identifies the SDK result slot to update. This is stable for the
|
|
11
|
-
* lifetime of the subscription.
|
|
12
|
-
*/
|
|
13
|
-
readonly snapshotId: v.StringSchema<undefined>;
|
|
8
|
+
/** Stable for the lifetime of this query subscription. */
|
|
9
|
+
readonly subscriptionId: v.StringSchema<undefined>;
|
|
14
10
|
/** The raw Notion data source ID to read from. */
|
|
15
11
|
readonly dataSourceId: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
16
|
-
/** The number of items to return in
|
|
12
|
+
/** The number of items to return in each subscription update. */
|
|
17
13
|
readonly limit: v.NumberSchema<undefined>;
|
|
18
14
|
}, undefined>;
|
|
19
15
|
export type QueryDataSourceMessage = v.InferOutput<typeof queryDataSourceMessageSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryDataSource.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/queryDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B;;;GAGG;AACH,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"queryDataSource.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/queryDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;IAExC,0DAA0D;;IAE1D,kDAAkD;;IAElD,iEAAiE;;aAEhE,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,WAAW,CACjD,OAAO,4BAA4B,CACnC,CAAA"}
|
|
@@ -6,14 +6,10 @@ import { notionDataSourceIdSchema } from "../ids.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export const queryDataSourceMessageSchema = v.object({
|
|
8
8
|
type: v.literal("queryDataSource"),
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* The stable snapshot ID that identifies the SDK result slot to update. This is stable for the
|
|
12
|
-
* lifetime of the subscription.
|
|
13
|
-
*/
|
|
14
|
-
snapshotId: v.string(),
|
|
9
|
+
/** Stable for the lifetime of this query subscription. */
|
|
10
|
+
subscriptionId: v.string(),
|
|
15
11
|
/** The raw Notion data source ID to read from. */
|
|
16
12
|
dataSourceId: notionDataSourceIdSchema,
|
|
17
|
-
/** The number of items to return in
|
|
13
|
+
/** The number of items to return in each subscription update. */
|
|
18
14
|
limit: v.number(),
|
|
19
15
|
});
|