@notionhq/custom-blocks 0.0.77 → 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 +60 -33
- package/bin/src/bridge/manifest.js +3 -3
- package/dist/bridge/SandboxBridge.d.ts +7 -12
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +109 -38
- 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 +2 -0
- 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 +21 -0
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
- 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/sandboxToHost.d.ts +20 -5
- 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 +202 -38
- 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.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 +137 -43
- package/src/bridge/dataSources/resolve.ts +3 -14
- package/src/bridge/hostState.ts +2 -0
- 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/init.ts +24 -10
- package/src/bridge/messages/initResult.ts +37 -0
- 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 +242 -42
- 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.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadManifest.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/loadManifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,eAAe,CAAA;AAIxE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"loadManifest.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/loadManifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,eAAe,CAAA;AAIxE,MAAM,MAAM,2BAA2B,GACpC,sBAAsB,GACtB,kBAAkB,GAClB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,uBAAuB,GAClC,oBAAoB,CAAC,2BAA2B,CAAC,CAAA;AAElD,MAAM,MAAM,kBAAkB,GAC3B;IACA,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;CAChB,GACD;IACA,QAAQ,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,uBAAuB,CAAA;CAC7B,CAAA;AAEJ;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAkEhE"}
|
|
@@ -6,7 +6,7 @@ const MANIFEST_URL = "custom_blocks.json";
|
|
|
6
6
|
* A missing manifest means the block has no declared data requirements.
|
|
7
7
|
* Other failures return a structured error so the host can reject the manifest.
|
|
8
8
|
* The SDK validates the manifest locally for author feedback; the host still
|
|
9
|
-
* validates the
|
|
9
|
+
* validates the connect message as the iframe trust boundary.
|
|
10
10
|
*/
|
|
11
11
|
export async function loadManifest() {
|
|
12
12
|
if (typeof fetch !== "function") {
|
|
@@ -28,7 +28,7 @@ export async function loadManifest() {
|
|
|
28
28
|
manifest: null,
|
|
29
29
|
// Consider this retryable because it may have just been a network issue. Because `init`
|
|
30
30
|
// errors are considered terminal, the host should "retry" by reloading the iframe and
|
|
31
|
-
// sending another `
|
|
31
|
+
// sending another `connect` message.
|
|
32
32
|
error: { code: "manifest_unavailable", message, isRetryable: true },
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
3
|
* User-authored manifest declaring the data sources the custom block expects.
|
|
4
|
-
* Lives at `custom_blocks.json` in the project root
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Lives at `custom_blocks.json` in the project root. The sandbox may send it in
|
|
5
|
+
* `connect`, and the host returns the authoritative manifest in `init`. The
|
|
6
|
+
* `notionCustomBlock` Vite plugin from
|
|
7
7
|
* `@notionhq/custom-blocks/vite` wires the JSON file into the dev server and
|
|
8
8
|
* the build output.
|
|
9
9
|
*/
|
package/dist/bridge/manifest.js
CHANGED
|
@@ -2,9 +2,9 @@ import * as v from "valibot";
|
|
|
2
2
|
import { notionPropertyTypeSchema } from "./dataSources/propertySchema.js";
|
|
3
3
|
/**
|
|
4
4
|
* User-authored manifest declaring the data sources the custom block expects.
|
|
5
|
-
* Lives at `custom_blocks.json` in the project root
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Lives at `custom_blocks.json` in the project root. The sandbox may send it in
|
|
6
|
+
* `connect`, and the host returns the authoritative manifest in `init`. The
|
|
7
|
+
* `notionCustomBlock` Vite plugin from
|
|
8
8
|
* `@notionhq/custom-blocks/vite` wires the JSON file into the dev server and
|
|
9
9
|
* the build output.
|
|
10
10
|
*/
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* First message the sandbox sends after mount
|
|
4
|
-
*
|
|
3
|
+
* First message the sandbox sends after mount. It identifies the sandbox and starts the bridge
|
|
4
|
+
* initialization exchange. The host echoes `initializationId` in its `init` response.
|
|
5
5
|
*/
|
|
6
|
-
export declare const
|
|
7
|
-
readonly type: v.LiteralSchema<"
|
|
6
|
+
export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
7
|
+
readonly type: v.LiteralSchema<"connect", undefined>;
|
|
8
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
8
9
|
readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
|
|
9
10
|
readonly sdkVersion: v.StringSchema<undefined>;
|
|
10
11
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
11
12
|
/**
|
|
12
|
-
* The data sources and settings the custom block expects
|
|
13
|
-
*
|
|
13
|
+
* The data sources and settings the custom block expects. Hosts may omit
|
|
14
|
+
* this when they already have an authoritative manifest.
|
|
14
15
|
*/
|
|
15
|
-
readonly manifest: v.
|
|
16
|
+
readonly manifest: v.OptionalSchema<v.ObjectSchema<{
|
|
16
17
|
readonly version: v.LiteralSchema<1, undefined>;
|
|
17
18
|
readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
18
19
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -30,9 +31,10 @@ export declare const readyMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
|
30
31
|
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>;
|
|
31
32
|
}, undefined>, undefined>, {}>;
|
|
32
33
|
}, undefined>, undefined>;
|
|
33
|
-
}, undefined>,
|
|
34
|
+
}, undefined>, undefined>;
|
|
34
35
|
}, undefined>, v.ObjectSchema<{
|
|
35
|
-
readonly type: v.LiteralSchema<"
|
|
36
|
+
readonly type: v.LiteralSchema<"connect", undefined>;
|
|
37
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
36
38
|
readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
|
|
37
39
|
readonly sdkVersion: v.StringSchema<undefined>;
|
|
38
40
|
readonly status: v.LiteralSchema<"error", undefined>;
|
|
@@ -42,5 +44,5 @@ export declare const readyMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
|
42
44
|
readonly isRetryable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
43
45
|
}, undefined>;
|
|
44
46
|
}, undefined>], undefined>;
|
|
45
|
-
export type
|
|
46
|
-
//# sourceMappingURL=
|
|
47
|
+
export type ConnectMessage = v.InferOutput<typeof connectMessageSchema>;
|
|
48
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AA2B5B;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;IAG/B;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BASH,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -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>;
|
|
@@ -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;AAe5B;;GAEG;AACH,eAAO,MAAM,0BAA0B
|
|
1
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAcrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
|
|
@@ -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
|
+
]);
|
|
@@ -3,12 +3,13 @@ import * as v from "valibot";
|
|
|
3
3
|
* Union of every message the sandbox is allowed to send the host. Useful for hosts to validate
|
|
4
4
|
* inbound traffic from sandboxes without re-implementing validation logic.
|
|
5
5
|
*/
|
|
6
|
-
export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.
|
|
7
|
-
readonly type: v.LiteralSchema<"
|
|
6
|
+
export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.VariantSchema<"status", [v.ObjectSchema<{
|
|
7
|
+
readonly type: v.LiteralSchema<"connect", undefined>;
|
|
8
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
8
9
|
readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
|
|
9
10
|
readonly sdkVersion: v.StringSchema<undefined>;
|
|
10
11
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
11
|
-
readonly manifest: v.
|
|
12
|
+
readonly manifest: v.OptionalSchema<v.ObjectSchema<{
|
|
12
13
|
readonly version: v.LiteralSchema<1, undefined>;
|
|
13
14
|
readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
14
15
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -26,9 +27,10 @@ export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.UnionSchema<[v
|
|
|
26
27
|
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>;
|
|
27
28
|
}, undefined>, undefined>, {}>;
|
|
28
29
|
}, undefined>, undefined>;
|
|
29
|
-
}, undefined>,
|
|
30
|
+
}, undefined>, undefined>;
|
|
30
31
|
}, undefined>, v.ObjectSchema<{
|
|
31
|
-
readonly type: v.LiteralSchema<"
|
|
32
|
+
readonly type: v.LiteralSchema<"connect", undefined>;
|
|
33
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
32
34
|
readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
|
|
33
35
|
readonly sdkVersion: v.StringSchema<undefined>;
|
|
34
36
|
readonly status: v.LiteralSchema<"error", undefined>;
|
|
@@ -37,6 +39,19 @@ export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.UnionSchema<[v
|
|
|
37
39
|
readonly message: v.StringSchema<undefined>;
|
|
38
40
|
readonly isRetryable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
39
41
|
}, undefined>;
|
|
42
|
+
}, undefined>], undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
43
|
+
readonly type: v.LiteralSchema<"initResult", undefined>;
|
|
44
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
45
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
46
|
+
}, undefined>, v.ObjectSchema<{
|
|
47
|
+
readonly type: v.LiteralSchema<"initResult", undefined>;
|
|
48
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
49
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
50
|
+
readonly error: v.ObjectSchema<{
|
|
51
|
+
readonly code: v.StringSchema<undefined>;
|
|
52
|
+
readonly message: v.StringSchema<undefined>;
|
|
53
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
54
|
+
}, undefined>;
|
|
40
55
|
}, undefined>], undefined>, v.ObjectSchema<{
|
|
41
56
|
readonly type: v.LiteralSchema<"queryDataSource", undefined>;
|
|
42
57
|
readonly subscriptionId: v.StringSchema<undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAY5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAWrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
import { connectMessageSchema } from "./connect.js";
|
|
2
3
|
import { createPageMessageSchema } from "./createPage.js";
|
|
3
4
|
import { getPageMessageSchema } from "./getPage.js";
|
|
4
5
|
import { getUserMessageSchema } from "./getUser.js";
|
|
6
|
+
import { initResultMessageSchema } from "./initResult.js";
|
|
5
7
|
import { invalidHostMessageSchema } from "./invalidHostMessage.js";
|
|
6
8
|
import { listUsersMessageSchema } from "./listUsers.js";
|
|
7
9
|
import { queryDataSourceMessageSchema } from "./queryDataSource.js";
|
|
8
|
-
import { readyMessageSchema } from "./ready.js";
|
|
9
10
|
import { resizeMessageSchema } from "./resize.js";
|
|
10
11
|
import { updatePageMessageSchema } from "./updatePage.js";
|
|
11
12
|
/**
|
|
@@ -13,7 +14,8 @@ import { updatePageMessageSchema } from "./updatePage.js";
|
|
|
13
14
|
* inbound traffic from sandboxes without re-implementing validation logic.
|
|
14
15
|
*/
|
|
15
16
|
export const sandboxToHostMessageSchema = v.union([
|
|
16
|
-
|
|
17
|
+
connectMessageSchema,
|
|
18
|
+
initResultMessageSchema,
|
|
17
19
|
queryDataSourceMessageSchema,
|
|
18
20
|
createPageMessageSchema,
|
|
19
21
|
getPageMessageSchema,
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { CreatePageInput, CreatePageResult, GetPageResult, GetUserResult, ListUsersInput, ListUsersResult, NotionPageId, NotionUserId, UpdatePageInput, UpdatePageResult, UseDataSourceOptions } from "../types.js";
|
|
2
2
|
import { type CustomBlockHostState, type DataSourceQueryView } from "./hostState.js";
|
|
3
3
|
import type { ManifestLoadResult } from "./loadManifest.js";
|
|
4
|
-
import type { CustomBlockManifest } from "./manifest.js";
|
|
5
4
|
import type { InitMessage } from "./messages/init.js";
|
|
6
5
|
import { type MessageLogEntry } from "./SandboxBridge.js";
|
|
7
6
|
export type { MessageLogEntry };
|
|
8
7
|
export declare const customBlockHost: {
|
|
9
|
-
|
|
10
|
-
awaitInit: (signal?: AbortSignal) => Promise<
|
|
8
|
+
sendConnect: (manifestResult: ManifestLoadResult) => void;
|
|
9
|
+
awaitInit: (signal?: AbortSignal) => Promise<void>;
|
|
11
10
|
subscribe: (listener: () => void) => () => boolean;
|
|
12
11
|
getState: () => CustomBlockHostState;
|
|
13
|
-
getManifest: () => CustomBlockManifest | null;
|
|
14
12
|
/**
|
|
15
13
|
* Apply an `init` payload directly, bypassing the postMessage handshake for
|
|
16
14
|
* standalone preview state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,E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from "./h
|
|
|
2
2
|
import { SandboxBridge } from "./SandboxBridge.js";
|
|
3
3
|
const bridge = new SandboxBridge();
|
|
4
4
|
export const customBlockHost = {
|
|
5
|
-
|
|
6
|
-
bridge.
|
|
5
|
+
sendConnect: (manifestResult) => {
|
|
6
|
+
bridge.sendConnect(manifestResult);
|
|
7
7
|
},
|
|
8
8
|
awaitInit: (signal) => {
|
|
9
9
|
return bridge.awaitInit(signal);
|
|
@@ -14,9 +14,6 @@ export const customBlockHost = {
|
|
|
14
14
|
getState: () => {
|
|
15
15
|
return bridge.getHostState();
|
|
16
16
|
},
|
|
17
|
-
getManifest: () => {
|
|
18
|
-
return bridge.getManifest();
|
|
19
|
-
},
|
|
20
17
|
/**
|
|
21
18
|
* Apply an `init` payload directly, bypassing the postMessage handshake for
|
|
22
19
|
* standalone preview state.
|
package/dist/customBlock.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const customBlock: {
|
|
|
30
30
|
getBlockId(): NotionBlockId;
|
|
31
31
|
getParent(): NotionParent;
|
|
32
32
|
getPage(): CustomBlockPage;
|
|
33
|
-
getManifest(): CustomBlockManifest
|
|
33
|
+
getManifest(): CustomBlockManifest;
|
|
34
34
|
autoResize: typeof autoResize;
|
|
35
35
|
};
|
|
36
36
|
//# sourceMappingURL=customBlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customBlock.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/customBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAK1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAA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AAM,wBAAwB,CAAA;AAExD,MAAM,MAAM,gBAAgB,GACzB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC/C;IACA,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAC9B,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW;wBACH,MAAM,IAAI,GAAG,MAAM,IAAI;gBAI/B,gBAAgB;sBAIV,UAAU;gBAIhB,WAAW;kBAIT,aAAa;iBAId,YAAY;eAId,eAAe;mBAIX,mBAAmB;;CAKlC,CAAA"}
|
package/dist/customBlock.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import type { NotionDataSourceId } from "../bridge/ids.js";
|
|
2
2
|
import type { HostToSandboxMessage } from "../bridge/messages/hostToSandbox.js";
|
|
3
|
+
import type { InitResultMessage } from "../bridge/messages/initResult.js";
|
|
3
4
|
import type { CustomBlockPage } from "../bridge/pages/page.js";
|
|
4
5
|
import type { NotionParent } from "../bridge/parent.js";
|
|
5
6
|
import type { NotionTheme } from "../bridge/theme.js";
|
|
6
7
|
import type { NotionUser } from "../bridge/users/user.js";
|
|
7
|
-
import type { CustomBlockHostDataSourcesPayload, CustomBlockHostInitialState
|
|
8
|
+
import type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostInitialState } from "./lifecycle/types.js";
|
|
8
9
|
import type { CustomBlockHostHandlers, CustomBlockHostLogDirection } from "./messages/types.js";
|
|
9
10
|
import type { CustomBlockHostQueryDataSourceResult } from "./queries/types.js";
|
|
10
11
|
export type CustomBlockHostOptions = {
|
|
11
12
|
iframe: HTMLIFrameElement;
|
|
12
13
|
targetOrigin?: string;
|
|
13
14
|
minBridgeProtocolVersion?: number;
|
|
14
|
-
|
|
15
|
+
noConnectTimeoutMs?: number;
|
|
16
|
+
noInitResultTimeoutMs?: number;
|
|
15
17
|
initialState: CustomBlockHostInitialState;
|
|
16
18
|
handlers: CustomBlockHostHandlers;
|
|
17
|
-
|
|
19
|
+
onConnect?: (message: ConnectSuccessMessage) => void;
|
|
20
|
+
onInitResult?: (message: InitResultMessage) => void;
|
|
18
21
|
onLog?: (direction: CustomBlockHostLogDirection, payload: unknown) => void;
|
|
19
22
|
};
|
|
20
23
|
export type CustomBlockHostHandle = {
|