@notionhq/custom-blocks-dev-shell 0.1.114 → 0.1.115

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.
Files changed (131) hide show
  1. package/README.md +27 -14
  2. package/bin/cli.js +3 -1
  3. package/dist/assets/index-DXzPwq_J.js +11 -0
  4. package/dist/index.html +1 -1
  5. package/dist-cli/cli/binding-cli-flags.js +33 -0
  6. package/dist-cli/cli/binding-errors.js +15 -0
  7. package/dist-cli/{build-block-registry.js → cli/build-block-registry.js} +2 -0
  8. package/dist-cli/{convert-values.js → cli/convert-values.js} +5 -5
  9. package/dist-cli/{convert.js → cli/convert.js} +3 -3
  10. package/dist-cli/cli/data-source-files.js +6 -0
  11. package/dist-cli/{data-sources.js → cli/data-sources.js} +12 -65
  12. package/dist-cli/{dev-shell-launcher.js → cli/dev-shell-launcher.js} +23 -10
  13. package/dist-cli/{errors.js → cli/errors.js} +5 -1
  14. package/dist-cli/cli/launcher-bindings.js +144 -0
  15. package/dist-cli/{published-cli.js → cli/published-cli.js} +2 -2
  16. package/dist-cli/{worker-manifest.js → cli/worker-manifest.js} +18 -1
  17. package/dist-cli/protocol/contrast.d.ts +4 -0
  18. package/dist-cli/protocol/contrast.js +3 -0
  19. package/dist-cli/protocol/dataSources/dataSource.d.ts +786 -0
  20. package/dist-cli/protocol/dataSources/dataSource.js +66 -0
  21. package/dist-cli/protocol/dataSources/dataSourcePage.d.ts +74 -0
  22. package/dist-cli/protocol/dataSources/dataSourcePage.js +15 -0
  23. package/dist-cli/protocol/dataSources/dataSourceValue.d.ts +66 -0
  24. package/dist-cli/protocol/dataSources/dataSourceValue.js +14 -0
  25. package/dist-cli/protocol/dataSources/dateValue.d.ts +157 -0
  26. package/dist-cli/protocol/dataSources/dateValue.js +61 -0
  27. package/dist-cli/protocol/dataSources/errors.d.ts +8 -0
  28. package/dist-cli/protocol/dataSources/errors.js +7 -0
  29. package/dist-cli/protocol/dataSources/propertySchema.d.ts +200 -0
  30. package/dist-cli/protocol/dataSources/propertySchema.js +174 -0
  31. package/dist-cli/protocol/dataSources/recordPointer.d.ts +9 -0
  32. package/dist-cli/protocol/dataSources/recordPointer.js +8 -0
  33. package/dist-cli/protocol/dataSources/sortDirection.d.ts +3 -0
  34. package/dist-cli/protocol/dataSources/sortDirection.js +2 -0
  35. package/dist-cli/protocol/errors.d.ts +12 -0
  36. package/dist-cli/protocol/errors.js +6 -0
  37. package/dist-cli/protocol/ids.d.ts +31 -0
  38. package/dist-cli/protocol/ids.js +26 -0
  39. package/dist-cli/protocol/index.d.ts +53 -0
  40. package/dist-cli/protocol/index.js +53 -0
  41. package/dist-cli/protocol/manifest.d.ts +67 -0
  42. package/dist-cli/protocol/manifest.js +36 -0
  43. package/dist-cli/protocol/messages/connect.d.ts +54 -0
  44. package/dist-cli/protocol/messages/connect.js +39 -0
  45. package/dist-cli/protocol/messages/contrastModeChanged.d.ts +7 -0
  46. package/dist-cli/protocol/messages/contrastModeChanged.js +7 -0
  47. package/dist-cli/protocol/messages/createPage.d.ts +290 -0
  48. package/dist-cli/protocol/messages/createPage.js +51 -0
  49. package/dist-cli/protocol/messages/createPageResult.d.ts +897 -0
  50. package/dist-cli/protocol/messages/createPageResult.js +43 -0
  51. package/dist-cli/protocol/messages/currentUserChanged.d.ts +18 -0
  52. package/dist-cli/protocol/messages/currentUserChanged.js +9 -0
  53. package/dist-cli/protocol/messages/dataSourcesChanged.d.ts +157 -0
  54. package/dist-cli/protocol/messages/dataSourcesChanged.js +13 -0
  55. package/dist-cli/protocol/messages/getPage.d.ts +902 -0
  56. package/dist-cli/protocol/messages/getPage.js +48 -0
  57. package/dist-cli/protocol/messages/getUser.d.ts +44 -0
  58. package/dist-cli/protocol/messages/getUser.js +32 -0
  59. package/dist-cli/protocol/messages/hostToSandbox.d.ts +4385 -0
  60. package/dist-cli/protocol/messages/hostToSandbox.js +48 -0
  61. package/dist-cli/protocol/messages/incomingType.d.ts +9 -0
  62. package/dist-cli/protocol/messages/incomingType.js +17 -0
  63. package/dist-cli/protocol/messages/init.d.ts +273 -0
  64. package/dist-cli/protocol/messages/init.js +57 -0
  65. package/dist-cli/protocol/messages/initResult.d.ts +37 -0
  66. package/dist-cli/protocol/messages/initResult.js +29 -0
  67. package/dist-cli/protocol/messages/invalidHostMessage.d.ts +14 -0
  68. package/dist-cli/protocol/messages/invalidHostMessage.js +13 -0
  69. package/dist-cli/protocol/messages/invalidSandboxMessage.d.ts +14 -0
  70. package/dist-cli/protocol/messages/invalidSandboxMessage.js +13 -0
  71. package/dist-cli/protocol/messages/isInitHandshakeMessage.d.ts +4 -0
  72. package/dist-cli/protocol/messages/isInitHandshakeMessage.js +11 -0
  73. package/dist-cli/protocol/messages/listUsers.d.ts +52 -0
  74. package/dist-cli/protocol/messages/listUsers.js +33 -0
  75. package/dist-cli/protocol/messages/messagePayload.d.ts +19 -0
  76. package/dist-cli/protocol/messages/messagePayload.js +1 -0
  77. package/dist-cli/protocol/messages/openExternalUrl.d.ts +32 -0
  78. package/dist-cli/protocol/messages/openExternalUrl.js +26 -0
  79. package/dist-cli/protocol/messages/openPage.d.ts +38 -0
  80. package/dist-cli/protocol/messages/openPage.js +34 -0
  81. package/dist-cli/protocol/messages/pageChanged.d.ts +32 -0
  82. package/dist-cli/protocol/messages/pageChanged.js +9 -0
  83. package/dist-cli/protocol/messages/parentChanged.d.ts +26 -0
  84. package/dist-cli/protocol/messages/parentChanged.js +9 -0
  85. package/dist-cli/protocol/messages/queryDataSource.d.ts +1446 -0
  86. package/dist-cli/protocol/messages/queryDataSource.js +252 -0
  87. package/dist-cli/protocol/messages/queryDataSourceResult.d.ts +686 -0
  88. package/dist-cli/protocol/messages/queryDataSourceResult.js +44 -0
  89. package/dist-cli/protocol/messages/resize.d.ts +11 -0
  90. package/dist-cli/protocol/messages/resize.js +10 -0
  91. package/dist-cli/protocol/messages/sandboxToHost.d.ts +1091 -0
  92. package/dist-cli/protocol/messages/sandboxToHost.js +33 -0
  93. package/dist-cli/protocol/messages/themeChanged.d.ts +10 -0
  94. package/dist-cli/protocol/messages/themeChanged.js +10 -0
  95. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.d.ts +10 -0
  96. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.js +9 -0
  97. package/dist-cli/protocol/messages/updatePage.d.ts +271 -0
  98. package/dist-cli/protocol/messages/updatePage.js +23 -0
  99. package/dist-cli/protocol/messages/updatePageResult.d.ts +895 -0
  100. package/dist-cli/protocol/messages/updatePageResult.js +41 -0
  101. package/dist-cli/protocol/pages/page.d.ts +1422 -0
  102. package/dist-cli/protocol/pages/page.js +318 -0
  103. package/dist-cli/protocol/parent.d.ts +32 -0
  104. package/dist-cli/protocol/parent.js +13 -0
  105. package/dist-cli/protocol/protocolVersion.d.ts +8 -0
  106. package/dist-cli/protocol/protocolVersion.js +11 -0
  107. package/dist-cli/protocol/theme.d.ts +3 -0
  108. package/dist-cli/protocol/theme.js +2 -0
  109. package/dist-cli/protocol/users/user.d.ts +32 -0
  110. package/dist-cli/protocol/users/user.js +20 -0
  111. package/dist-cli/shared/block-registry.js +28 -0
  112. package/dist-cli/shared/data-source.js +22 -0
  113. package/dist-cli/shared/runtime-config.js +10 -0
  114. package/dist-cli/shared/sample-data-source.js +12 -0
  115. package/docs/bindings.md +79 -27
  116. package/package.json +5 -26
  117. package/dist/assets/index-F02ZboyS.js +0 -11
  118. package/dist-cli/date-value.js +0 -46
  119. package/dist-cli/resolve-bindings.js +0 -39
  120. package/dist-cli/source-bindings.js +0 -17
  121. /package/dist-cli/{block-csp.js → cli/block-csp.js} +0 -0
  122. /package/dist-cli/{dev-shell-run.js → cli/dev-shell-run.js} +0 -0
  123. /package/dist-cli/{materialize.js → cli/materialize.js} +0 -0
  124. /package/dist-cli/{ports.js → cli/ports.js} +0 -0
  125. /package/dist-cli/{prebuilt.js → cli/prebuilt.js} +0 -0
  126. /package/dist-cli/{runtime-error-client.js → cli/runtime-error-client.js} +0 -0
  127. /package/dist-cli/{serve-ui.js → cli/serve-ui.js} +0 -0
  128. /package/dist-cli/{shared-server.js → cli/shared-server.js} +0 -0
  129. /package/dist-cli/{utils.js → cli/utils.js} +0 -0
  130. /package/dist-cli/{vite-block-server.js → cli/vite-block-server.js} +0 -0
  131. /package/dist-cli/{vite-middleware.js → cli/vite-middleware.js} +0 -0
@@ -0,0 +1,67 @@
1
+ import * as v from "valibot";
2
+ /**
3
+ * Decorative icon attached to a manifest data source. Mirrors the
4
+ * `emoji` / `external` icon variants the public Notion API uses, so the host
5
+ * can render a recognizable affordance next to the slot in setup UI.
6
+ */
7
+ export declare const manifestIconSchema: v.VariantSchema<"type", [v.ObjectSchema<{
8
+ readonly type: v.LiteralSchema<"emoji", undefined>;
9
+ readonly emoji: v.StringSchema<undefined>;
10
+ }, undefined>, v.ObjectSchema<{
11
+ readonly type: v.LiteralSchema<"external", undefined>;
12
+ readonly url: v.StringSchema<undefined>;
13
+ }, undefined>], undefined>;
14
+ export type ManifestIcon = v.InferOutput<typeof manifestIconSchema>;
15
+ export declare const manifestPropertySchema: v.ObjectSchema<{
16
+ readonly name: v.StringSchema<undefined>;
17
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
18
+ 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>;
19
+ }, undefined>;
20
+ export type ManifestProperty = v.InferOutput<typeof manifestPropertySchema>;
21
+ export declare const manifestDataSourceSchema: v.ObjectSchema<{
22
+ readonly name: v.StringSchema<undefined>;
23
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
24
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
25
+ readonly type: v.LiteralSchema<"emoji", undefined>;
26
+ readonly emoji: v.StringSchema<undefined>;
27
+ }, undefined>, v.ObjectSchema<{
28
+ readonly type: v.LiteralSchema<"external", undefined>;
29
+ readonly url: v.StringSchema<undefined>;
30
+ }, undefined>], undefined>, undefined>;
31
+ readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
32
+ readonly name: v.StringSchema<undefined>;
33
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
34
+ 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>;
35
+ }, undefined>, undefined>, {}>;
36
+ }, undefined>;
37
+ export type ManifestDataSource = v.InferOutput<typeof manifestDataSourceSchema>;
38
+ export declare const manifestSchema: v.ObjectSchema<{
39
+ readonly version: v.LiteralSchema<1, undefined>;
40
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
41
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
42
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
43
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
44
+ readonly type: v.LiteralSchema<"emoji", undefined>;
45
+ readonly emoji: v.StringSchema<undefined>;
46
+ }, undefined>, undefined>;
47
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
48
+ readonly name: v.StringSchema<undefined>;
49
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
50
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
51
+ readonly type: v.LiteralSchema<"emoji", undefined>;
52
+ readonly emoji: v.StringSchema<undefined>;
53
+ }, undefined>, v.ObjectSchema<{
54
+ readonly type: v.LiteralSchema<"external", undefined>;
55
+ readonly url: v.StringSchema<undefined>;
56
+ }, undefined>], undefined>, undefined>;
57
+ readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
58
+ readonly name: v.StringSchema<undefined>;
59
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
60
+ 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>;
61
+ }, undefined>, undefined>, {}>;
62
+ }, undefined>, undefined>, {}>;
63
+ }, undefined>;
64
+ /**
65
+ * Manifest describing a custom block and its required data sources.
66
+ */
67
+ export type CustomBlockManifest = v.InferOutput<typeof manifestSchema>;
@@ -0,0 +1,36 @@
1
+ import * as v from "valibot";
2
+ import { notionPropertyTypeSchema } from "./dataSources/propertySchema.js";
3
+ /**
4
+ * Decorative icon attached to a manifest data source. Mirrors the
5
+ * `emoji` / `external` icon variants the public Notion API uses, so the host
6
+ * can render a recognizable affordance next to the slot in setup UI.
7
+ */
8
+ export const manifestIconSchema = v.variant("type", [
9
+ v.object({
10
+ type: v.literal("emoji"),
11
+ emoji: v.string(),
12
+ }),
13
+ v.object({
14
+ type: v.literal("external"),
15
+ url: v.string(),
16
+ }),
17
+ ]);
18
+ export const manifestPropertySchema = v.object({
19
+ name: v.string(),
20
+ description: v.optional(v.string()),
21
+ type: notionPropertyTypeSchema,
22
+ });
23
+ export const manifestDataSourceSchema = v.object({
24
+ name: v.string(),
25
+ description: v.optional(v.string()),
26
+ icon: v.optional(manifestIconSchema),
27
+ properties: v.optional(v.record(v.string(), manifestPropertySchema), {}),
28
+ });
29
+ export const manifestSchema = v.object({
30
+ version: v.literal(1),
31
+ name: v.optional(v.string()),
32
+ description: v.optional(v.string()),
33
+ slashCommand: v.optional(v.string()),
34
+ icon: v.optional(v.object({ type: v.literal("emoji"), emoji: v.string() })),
35
+ dataSources: v.optional(v.record(v.string(), manifestDataSourceSchema), {}),
36
+ });
@@ -0,0 +1,54 @@
1
+ import * as v from "valibot";
2
+ /**
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
+ */
6
+ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
7
+ readonly type: v.LiteralSchema<"connect", undefined>;
8
+ readonly initializationId: v.StringSchema<undefined>;
9
+ readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
10
+ readonly sdkVersion: v.StringSchema<undefined>;
11
+ readonly status: v.LiteralSchema<"success", undefined>;
12
+ /**
13
+ * The data sources and settings the custom block expects. Hosts may omit
14
+ * this when they already have an authoritative manifest.
15
+ */
16
+ readonly manifest: v.OptionalSchema<v.ObjectSchema<{
17
+ readonly version: v.LiteralSchema<1, undefined>;
18
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
19
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
20
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
21
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
22
+ readonly type: v.LiteralSchema<"emoji", undefined>;
23
+ readonly emoji: v.StringSchema<undefined>;
24
+ }, undefined>, undefined>;
25
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
26
+ readonly name: v.StringSchema<undefined>;
27
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
28
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
29
+ readonly type: v.LiteralSchema<"emoji", undefined>;
30
+ readonly emoji: v.StringSchema<undefined>;
31
+ }, undefined>, v.ObjectSchema<{
32
+ readonly type: v.LiteralSchema<"external", undefined>;
33
+ readonly url: v.StringSchema<undefined>;
34
+ }, undefined>], undefined>, undefined>;
35
+ readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
36
+ readonly name: v.StringSchema<undefined>;
37
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
38
+ 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>;
39
+ }, undefined>, undefined>, {}>;
40
+ }, undefined>, undefined>, {}>;
41
+ }, undefined>, undefined>;
42
+ }, undefined>, v.ObjectSchema<{
43
+ readonly type: v.LiteralSchema<"connect", undefined>;
44
+ readonly initializationId: v.StringSchema<undefined>;
45
+ readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
46
+ readonly sdkVersion: v.StringSchema<undefined>;
47
+ readonly status: v.LiteralSchema<"error", undefined>;
48
+ readonly error: v.ObjectSchema<{
49
+ readonly code: v.StringSchema<undefined>;
50
+ readonly message: v.StringSchema<undefined>;
51
+ readonly isRetryable: v.BooleanSchema<undefined>;
52
+ }, undefined>;
53
+ }, undefined>], undefined>;
54
+ export type ConnectMessage = v.InferOutput<typeof connectMessageSchema>;
@@ -0,0 +1,39 @@
1
+ import * as v from "valibot";
2
+ import { customBlockErrorInfoSchema } from "../errors.js";
3
+ import { manifestSchema } from "../manifest.js";
4
+ const connectMessageCommonEntries = {
5
+ type: v.literal("connect"),
6
+ initializationId: v.string(),
7
+ /**
8
+ * The bridge protocol version this sandbox uses to communicate with its host.
9
+ * Hosts control which versions they support and can support multiple versions
10
+ * at the same time. Support for older versions is eventually removed, so blocks
11
+ * may need to update their SDK to continue working.
12
+ */
13
+ bridgeProtocolVersion: v.number(),
14
+ /**
15
+ * Semver version of the SDK package that sent this connect message. Should only be used for
16
+ * analytics purposes. Business logic should compare against `bridgeProtocolVersion` instead.
17
+ */
18
+ sdkVersion: v.string(),
19
+ };
20
+ /**
21
+ * First message the sandbox sends after mount. It identifies the sandbox and starts the bridge
22
+ * initialization exchange. The host echoes `initializationId` in its `init` response.
23
+ */
24
+ export const connectMessageSchema = v.variant("status", [
25
+ v.object({
26
+ status: v.literal("success"),
27
+ /**
28
+ * The data sources and settings the custom block expects. Hosts may omit
29
+ * this when they already have an authoritative manifest.
30
+ */
31
+ manifest: v.optional(manifestSchema),
32
+ ...connectMessageCommonEntries,
33
+ }),
34
+ v.object({
35
+ status: v.literal("error"),
36
+ error: customBlockErrorInfoSchema,
37
+ ...connectMessageCommonEntries,
38
+ }),
39
+ ]);
@@ -0,0 +1,7 @@
1
+ import * as v from "valibot";
2
+ /** Message sent by the host when contrast changes after initialization. */
3
+ export declare const contrastModeChangedMessageSchema: v.ObjectSchema<{
4
+ readonly type: v.LiteralSchema<"contrastModeChanged", undefined>;
5
+ readonly contrastMode: v.PicklistSchema<["standard", "high"], undefined>;
6
+ }, undefined>;
7
+ export type ContrastModeChangedMessage = v.InferOutput<typeof contrastModeChangedMessageSchema>;
@@ -0,0 +1,7 @@
1
+ import * as v from "valibot";
2
+ import { notionContrastModeSchema } from "../contrast.js";
3
+ /** Message sent by the host when contrast changes after initialization. */
4
+ export const contrastModeChangedMessageSchema = v.object({
5
+ type: v.literal("contrastModeChanged"),
6
+ contrastMode: notionContrastModeSchema,
7
+ });
@@ -0,0 +1,290 @@
1
+ import * as v from "valibot";
2
+ /**
3
+ * Describes where the newly created page should be inserted.
4
+ * - `start` / `end` (default): prepend / append to the request's `parent`
5
+ * page's children.
6
+ * - `before` / `after`: insert as a sibling of the anchor block identified by
7
+ * `blockId`, using the anchor's own structural parent. The anchor can be
8
+ * nested anywhere below the page (inside a toggle, column, callout, etc.).
9
+ */
10
+ export declare const notionCreatePagePositionSchema: v.VariantSchema<"type", [v.ObjectSchema<{
11
+ readonly type: v.LiteralSchema<"start", undefined>;
12
+ }, undefined>, v.ObjectSchema<{
13
+ readonly type: v.LiteralSchema<"end", undefined>;
14
+ }, undefined>, v.ObjectSchema<{
15
+ readonly type: v.LiteralSchema<"before", undefined>;
16
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
17
+ }, undefined>, v.ObjectSchema<{
18
+ readonly type: v.LiteralSchema<"after", undefined>;
19
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
20
+ }, undefined>], undefined>;
21
+ export type NotionCreatePagePosition = v.InferOutput<typeof notionCreatePagePositionSchema>;
22
+ /**
23
+ * Parent accepted by the outbound `createPage` bridge message.
24
+ *
25
+ * Mirrors Notion's public API `POST /v1/pages` parent shape: `page_id` for a page-parented child,
26
+ * `data_source_id` for a database row. `data_source_id` is the internal collection ID.
27
+ *
28
+ * The SDK additionally accepts a higher-level `data_source_key` variant that resolves to
29
+ * `data_source_id` locally, using the `dataSources` mapping.
30
+ */
31
+ export declare const createPageParentSchema: v.VariantSchema<"type", [v.ObjectSchema<{
32
+ readonly type: v.LiteralSchema<"page_id", undefined>;
33
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
34
+ }, undefined>, v.ObjectSchema<{
35
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
36
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
37
+ }, undefined>], undefined>;
38
+ export type CreatePageMessageParent = v.InferOutput<typeof createPageParentSchema>;
39
+ /**
40
+ * The sandbox sends this message to ask the host to create a page.
41
+ * The payload mirrors Notion's public `POST /v1/pages` API.
42
+ */
43
+ export declare const createPageMessageSchema: v.ObjectSchema<{
44
+ readonly type: v.LiteralSchema<"createPage", undefined>;
45
+ readonly requestId: v.StringSchema<undefined>;
46
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
47
+ readonly type: v.LiteralSchema<"page_id", undefined>;
48
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
49
+ }, undefined>, v.ObjectSchema<{
50
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
51
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
52
+ }, undefined>], undefined>;
53
+ /**
54
+ * Property values, keyed by raw property IDs from Notion.
55
+ *
56
+ * Each value must carry the same raw property ID in its `id` field.
57
+ * To create a page with manifest-defined property keys, call `pages.create`. The SDK resolves
58
+ * those keys before it sends this message.
59
+ */
60
+ readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
61
+ readonly id: v.StringSchema<undefined>;
62
+ readonly type: v.LiteralSchema<"title", undefined>;
63
+ readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
64
+ }, undefined>, v.ObjectSchema<{
65
+ readonly id: v.StringSchema<undefined>;
66
+ readonly type: v.LiteralSchema<"rich_text", undefined>;
67
+ readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
68
+ }, undefined>, v.ObjectSchema<{
69
+ readonly id: v.StringSchema<undefined>;
70
+ readonly type: v.LiteralSchema<"number", undefined>;
71
+ readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
72
+ }, undefined>, v.ObjectSchema<{
73
+ readonly id: v.StringSchema<undefined>;
74
+ readonly type: v.LiteralSchema<"url", undefined>;
75
+ readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
76
+ }, undefined>, v.ObjectSchema<{
77
+ readonly id: v.StringSchema<undefined>;
78
+ readonly type: v.LiteralSchema<"email", undefined>;
79
+ readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
80
+ }, undefined>, v.ObjectSchema<{
81
+ readonly id: v.StringSchema<undefined>;
82
+ readonly type: v.LiteralSchema<"phone_number", undefined>;
83
+ readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
84
+ }, undefined>, v.ObjectSchema<{
85
+ readonly id: v.StringSchema<undefined>;
86
+ readonly type: v.LiteralSchema<"checkbox", undefined>;
87
+ readonly checkbox: v.BooleanSchema<undefined>;
88
+ }, undefined>, v.ObjectSchema<{
89
+ readonly id: v.StringSchema<undefined>;
90
+ readonly type: v.LiteralSchema<"select", undefined>;
91
+ readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
92
+ readonly id: v.StringSchema<undefined>;
93
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
94
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
95
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
96
+ }, undefined>, v.ObjectSchema<{
97
+ readonly name: v.StringSchema<undefined>;
98
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
99
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
100
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
101
+ }, undefined>], undefined>, undefined>;
102
+ }, undefined>, v.ObjectSchema<{
103
+ readonly id: v.StringSchema<undefined>;
104
+ readonly type: v.LiteralSchema<"status", undefined>;
105
+ readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
106
+ readonly id: v.StringSchema<undefined>;
107
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
108
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
109
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
110
+ }, undefined>, v.ObjectSchema<{
111
+ readonly name: v.StringSchema<undefined>;
112
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
113
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
114
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
115
+ }, undefined>], undefined>, undefined>;
116
+ }, undefined>, v.ObjectSchema<{
117
+ readonly id: v.StringSchema<undefined>;
118
+ readonly type: v.LiteralSchema<"multi_select", undefined>;
119
+ readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
120
+ readonly id: v.StringSchema<undefined>;
121
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
122
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
123
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
124
+ }, undefined>, v.ObjectSchema<{
125
+ readonly name: v.StringSchema<undefined>;
126
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
127
+ readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
128
+ readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
129
+ }, undefined>], undefined>, undefined>;
130
+ }, undefined>, v.ObjectSchema<{
131
+ readonly id: v.StringSchema<undefined>;
132
+ readonly type: v.LiteralSchema<"date", undefined>;
133
+ readonly date: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
134
+ readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
135
+ readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
136
+ readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
137
+ readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
138
+ readonly value: v.NumberSchema<undefined>;
139
+ readonly time: v.StringSchema<undefined>;
140
+ readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
141
+ }, undefined>, v.ObjectSchema<{
142
+ readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
143
+ readonly value: v.NumberSchema<undefined>;
144
+ }, undefined>], undefined>, v.ObjectSchema<{
145
+ readonly unit: v.LiteralSchema<"none", undefined>;
146
+ }, undefined>], undefined>, undefined>;
147
+ readonly start: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IncludesAction<string, "T", undefined>]>;
148
+ }, undefined>, v.ObjectSchema<{
149
+ readonly start: v.StringSchema<undefined>;
150
+ readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
151
+ readonly reminder: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
152
+ readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
153
+ readonly value: v.NumberSchema<undefined>;
154
+ readonly time: v.StringSchema<undefined>;
155
+ readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
156
+ }, undefined>, v.ObjectSchema<{
157
+ readonly unit: v.PicklistSchema<["hour", "minute"], undefined>;
158
+ readonly value: v.NumberSchema<undefined>;
159
+ }, undefined>], undefined>, v.ObjectSchema<{
160
+ readonly unit: v.LiteralSchema<"none", undefined>;
161
+ }, undefined>], undefined>, undefined>;
162
+ readonly time_zone: v.StringSchema<undefined>;
163
+ }, undefined>, v.ObjectSchema<{
164
+ readonly start: v.StringSchema<undefined>;
165
+ readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
166
+ readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
167
+ readonly reminder: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
168
+ readonly unit: v.PicklistSchema<["year", "month", "week", "day"], undefined>;
169
+ readonly value: v.NumberSchema<undefined>;
170
+ readonly time: v.StringSchema<undefined>;
171
+ readonly defaultTimeZone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
172
+ }, undefined>, v.ObjectSchema<{
173
+ readonly unit: v.LiteralSchema<"none", undefined>;
174
+ }, undefined>], undefined>, undefined>;
175
+ }, undefined>], undefined>, undefined>;
176
+ }, undefined>, v.ObjectSchema<{
177
+ readonly id: v.StringSchema<undefined>;
178
+ readonly type: v.LiteralSchema<"people", undefined>;
179
+ readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
180
+ readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
181
+ readonly id: v.StringSchema<undefined>;
182
+ }, undefined>, v.ObjectSchema<{
183
+ readonly object: v.LiteralSchema<"group", undefined>;
184
+ readonly id: v.StringSchema<undefined>;
185
+ readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
186
+ }, undefined>], undefined>, undefined>;
187
+ }, undefined>, v.ObjectSchema<{
188
+ readonly id: v.StringSchema<undefined>;
189
+ readonly type: v.LiteralSchema<"relation", undefined>;
190
+ readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
191
+ readonly relation: v.ArraySchema<v.ObjectSchema<{
192
+ readonly id: v.StringSchema<undefined>;
193
+ }, undefined>, undefined>;
194
+ }, undefined>, v.ObjectSchema<{
195
+ readonly id: v.StringSchema<undefined>;
196
+ readonly type: v.LiteralSchema<"files", undefined>;
197
+ readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
198
+ readonly type: v.LiteralSchema<"external", undefined>;
199
+ readonly name: v.StringSchema<undefined>;
200
+ readonly external: v.ObjectSchema<{
201
+ readonly url: v.StringSchema<undefined>;
202
+ }, undefined>;
203
+ }, undefined>, v.ObjectSchema<{
204
+ readonly type: v.LiteralSchema<"file", undefined>;
205
+ readonly name: v.StringSchema<undefined>;
206
+ readonly file: v.ObjectSchema<{
207
+ readonly url: v.StringSchema<undefined>;
208
+ readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
209
+ }, undefined>;
210
+ }, undefined>], undefined>, undefined>;
211
+ }, undefined>, v.ObjectSchema<{
212
+ readonly id: v.StringSchema<undefined>;
213
+ readonly type: v.LiteralSchema<"place", undefined>;
214
+ readonly place: v.NullableSchema<v.ObjectSchema<{
215
+ readonly lat: v.NumberSchema<undefined>;
216
+ readonly lon: v.NumberSchema<undefined>;
217
+ readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
218
+ readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
219
+ readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
220
+ readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
221
+ }, undefined>, undefined>;
222
+ }, undefined>, v.ObjectSchema<{
223
+ readonly id: v.StringSchema<undefined>;
224
+ readonly type: v.LiteralSchema<"created_time", undefined>;
225
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
226
+ }, undefined>, v.ObjectSchema<{
227
+ readonly id: v.StringSchema<undefined>;
228
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
229
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
230
+ }, undefined>, v.ObjectSchema<{
231
+ readonly id: v.StringSchema<undefined>;
232
+ readonly type: v.LiteralSchema<"created_by", undefined>;
233
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
234
+ readonly id: v.StringSchema<undefined>;
235
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
236
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
237
+ }, undefined>, undefined>;
238
+ }, undefined>, v.ObjectSchema<{
239
+ readonly id: v.StringSchema<undefined>;
240
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
241
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
242
+ readonly id: v.StringSchema<undefined>;
243
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
244
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
245
+ }, undefined>, undefined>;
246
+ }, undefined>, v.ObjectSchema<{
247
+ readonly id: v.StringSchema<undefined>;
248
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
249
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
250
+ }, undefined>, v.ObjectSchema<{
251
+ readonly id: v.StringSchema<undefined>;
252
+ readonly type: v.LiteralSchema<"unique_id", undefined>;
253
+ readonly unique_id: v.StringSchema<undefined>;
254
+ }, undefined>, v.ObjectSchema<{
255
+ readonly id: v.StringSchema<undefined>;
256
+ readonly type: v.LiteralSchema<"button", undefined>;
257
+ readonly button: v.StringSchema<undefined>;
258
+ }, undefined>, v.ObjectSchema<{
259
+ readonly id: v.StringSchema<undefined>;
260
+ readonly type: v.LiteralSchema<"formula", undefined>;
261
+ readonly formula: v.StringSchema<undefined>;
262
+ }, undefined>, v.ObjectSchema<{
263
+ readonly id: v.StringSchema<undefined>;
264
+ readonly type: v.LiteralSchema<"location", undefined>;
265
+ readonly location: v.StringSchema<undefined>;
266
+ }, undefined>, v.ObjectSchema<{
267
+ readonly id: v.StringSchema<undefined>;
268
+ readonly type: v.LiteralSchema<"rollup", undefined>;
269
+ readonly rollup: v.StringSchema<undefined>;
270
+ }, undefined>, v.ObjectSchema<{
271
+ readonly id: v.StringSchema<undefined>;
272
+ readonly type: v.LiteralSchema<"verification", undefined>;
273
+ readonly verification: v.StringSchema<undefined>;
274
+ }, undefined>], undefined>, undefined>;
275
+ readonly position: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
276
+ readonly type: v.LiteralSchema<"start", undefined>;
277
+ }, undefined>, v.ObjectSchema<{
278
+ readonly type: v.LiteralSchema<"end", undefined>;
279
+ }, undefined>, v.ObjectSchema<{
280
+ readonly type: v.LiteralSchema<"before", undefined>;
281
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
282
+ }, undefined>, v.ObjectSchema<{
283
+ readonly type: v.LiteralSchema<"after", undefined>;
284
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
285
+ }, undefined>], undefined>, undefined>;
286
+ }, undefined>;
287
+ /**
288
+ * The sandbox sends this message to create a page.
289
+ */
290
+ export type CreatePageMessage = v.InferOutput<typeof createPageMessageSchema>;
@@ -0,0 +1,51 @@
1
+ import * as v from "valibot";
2
+ import { notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, } from "../ids.js";
3
+ import { notionPagePropertyWriteMapSchema } from "../pages/page.js";
4
+ /**
5
+ * Describes where the newly created page should be inserted.
6
+ * - `start` / `end` (default): prepend / append to the request's `parent`
7
+ * page's children.
8
+ * - `before` / `after`: insert as a sibling of the anchor block identified by
9
+ * `blockId`, using the anchor's own structural parent. The anchor can be
10
+ * nested anywhere below the page (inside a toggle, column, callout, etc.).
11
+ */
12
+ export const notionCreatePagePositionSchema = v.variant("type", [
13
+ v.object({ type: v.literal("start") }),
14
+ v.object({ type: v.literal("end") }),
15
+ v.object({ type: v.literal("before"), blockId: notionBlockIdSchema }),
16
+ v.object({ type: v.literal("after"), blockId: notionBlockIdSchema }),
17
+ ]);
18
+ /**
19
+ * Parent accepted by the outbound `createPage` bridge message.
20
+ *
21
+ * Mirrors Notion's public API `POST /v1/pages` parent shape: `page_id` for a page-parented child,
22
+ * `data_source_id` for a database row. `data_source_id` is the internal collection ID.
23
+ *
24
+ * The SDK additionally accepts a higher-level `data_source_key` variant that resolves to
25
+ * `data_source_id` locally, using the `dataSources` mapping.
26
+ */
27
+ export const createPageParentSchema = v.variant("type", [
28
+ v.object({ type: v.literal("page_id"), page_id: notionPageIdSchema }),
29
+ v.object({
30
+ type: v.literal("data_source_id"),
31
+ data_source_id: notionDataSourceIdSchema,
32
+ }),
33
+ ]);
34
+ /**
35
+ * The sandbox sends this message to ask the host to create a page.
36
+ * The payload mirrors Notion's public `POST /v1/pages` API.
37
+ */
38
+ export const createPageMessageSchema = v.object({
39
+ type: v.literal("createPage"),
40
+ requestId: v.string(),
41
+ parent: createPageParentSchema,
42
+ /**
43
+ * Property values, keyed by raw property IDs from Notion.
44
+ *
45
+ * Each value must carry the same raw property ID in its `id` field.
46
+ * To create a page with manifest-defined property keys, call `pages.create`. The SDK resolves
47
+ * those keys before it sends this message.
48
+ */
49
+ properties: notionPagePropertyWriteMapSchema,
50
+ position: v.optional(notionCreatePagePositionSchema),
51
+ });