@notionhq/custom-blocks 0.0.58
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 +171 -0
- package/README.md +57 -0
- package/bin/cli/attach.js +180 -0
- package/bin/cli/cli.js +248 -0
- package/bin/cli/create.js +106 -0
- package/bin/cli/datasources.js +255 -0
- package/bin/cli/deploy.js +109 -0
- package/bin/cli/ids.js +13 -0
- package/bin/cli/ntn.js +95 -0
- package/bin/cli/pullData.js +76 -0
- package/bin/cli/pullManifest.js +158 -0
- package/bin/cli/target.js +95 -0
- package/bin/src/bridge/dataSources/propertySchema.js +148 -0
- package/bin/src/bridge/manifest.js +40 -0
- package/dist/autoResize.d.ts +4 -0
- package/dist/autoResize.d.ts.map +1 -0
- package/dist/autoResize.js +71 -0
- package/dist/bridge/SandboxBridge.d.ts +92 -0
- package/dist/bridge/SandboxBridge.d.ts.map +1 -0
- package/dist/bridge/SandboxBridge.js +718 -0
- package/dist/bridge/dataSources/dataSource.d.ts +732 -0
- package/dist/bridge/dataSources/dataSource.d.ts.map +1 -0
- package/dist/bridge/dataSources/dataSource.js +37 -0
- package/dist/bridge/dataSources/dataSourcePage.d.ts +118 -0
- package/dist/bridge/dataSources/dataSourcePage.d.ts.map +1 -0
- package/dist/bridge/dataSources/dataSourcePage.js +14 -0
- package/dist/bridge/dataSources/dataSourceValue.d.ts +67 -0
- package/dist/bridge/dataSources/dataSourceValue.d.ts.map +1 -0
- package/dist/bridge/dataSources/dataSourceValue.js +14 -0
- package/dist/bridge/dataSources/dateValue.d.ts +158 -0
- package/dist/bridge/dataSources/dateValue.d.ts.map +1 -0
- package/dist/bridge/dataSources/dateValue.js +59 -0
- package/dist/bridge/dataSources/errors.d.ts +6 -0
- package/dist/bridge/dataSources/errors.d.ts.map +1 -0
- package/dist/bridge/dataSources/errors.js +4 -0
- package/dist/bridge/dataSources/propertySchema.d.ts +191 -0
- package/dist/bridge/dataSources/propertySchema.d.ts.map +1 -0
- package/dist/bridge/dataSources/propertySchema.js +148 -0
- package/dist/bridge/dataSources/recordPointer.d.ts +10 -0
- package/dist/bridge/dataSources/recordPointer.d.ts.map +1 -0
- package/dist/bridge/dataSources/recordPointer.js +8 -0
- package/dist/bridge/dataSources/resolve.d.ts +22 -0
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolve.js +65 -0
- package/dist/bridge/dataSources/resolveProperty.d.ts +41 -0
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolveProperty.js +73 -0
- package/dist/bridge/errors.d.ts +12 -0
- package/dist/bridge/errors.d.ts.map +1 -0
- package/dist/bridge/errors.js +6 -0
- package/dist/bridge/hostState.d.ts +65 -0
- package/dist/bridge/hostState.d.ts.map +1 -0
- package/dist/bridge/hostState.js +65 -0
- package/dist/bridge/ids.d.ts +39 -0
- package/dist/bridge/ids.d.ts.map +1 -0
- package/dist/bridge/ids.js +5 -0
- package/dist/bridge/incomingType.d.ts +10 -0
- package/dist/bridge/incomingType.d.ts.map +1 -0
- package/dist/bridge/incomingType.js +17 -0
- package/dist/bridge/loadManifest.d.ts +25 -0
- package/dist/bridge/loadManifest.d.ts.map +1 -0
- package/dist/bridge/loadManifest.js +68 -0
- package/dist/bridge/manifest.d.ts +66 -0
- package/dist/bridge/manifest.d.ts.map +1 -0
- package/dist/bridge/manifest.js +40 -0
- package/dist/bridge/messages/createPage.d.ts +225 -0
- package/dist/bridge/messages/createPage.d.ts.map +1 -0
- package/dist/bridge/messages/createPage.js +46 -0
- package/dist/bridge/messages/createPageResult.d.ts +211 -0
- package/dist/bridge/messages/createPageResult.d.ts.map +1 -0
- package/dist/bridge/messages/createPageResult.js +28 -0
- package/dist/bridge/messages/currentUserChanged.d.ts +19 -0
- package/dist/bridge/messages/currentUserChanged.d.ts.map +1 -0
- package/dist/bridge/messages/currentUserChanged.js +9 -0
- package/dist/bridge/messages/dataSourcesChanged.d.ts +158 -0
- package/dist/bridge/messages/dataSourcesChanged.d.ts.map +1 -0
- package/dist/bridge/messages/dataSourcesChanged.js +13 -0
- package/dist/bridge/messages/getPage.d.ts +216 -0
- package/dist/bridge/messages/getPage.d.ts.map +1 -0
- package/dist/bridge/messages/getPage.js +33 -0
- package/dist/bridge/messages/getUser.d.ts +45 -0
- package/dist/bridge/messages/getUser.d.ts.map +1 -0
- package/dist/bridge/messages/getUser.js +32 -0
- package/dist/bridge/messages/hostToSandbox.d.ts +1089 -0
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -0
- package/dist/bridge/messages/hostToSandbox.js +32 -0
- package/dist/bridge/messages/init.d.ts +209 -0
- package/dist/bridge/messages/init.d.ts.map +1 -0
- package/dist/bridge/messages/init.js +47 -0
- package/dist/bridge/messages/invalidHostMessage.d.ts +15 -0
- package/dist/bridge/messages/invalidHostMessage.d.ts.map +1 -0
- package/dist/bridge/messages/invalidHostMessage.js +13 -0
- package/dist/bridge/messages/invalidSandboxMessage.d.ts +15 -0
- package/dist/bridge/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/bridge/messages/invalidSandboxMessage.js +13 -0
- package/dist/bridge/messages/listUsers.d.ts +53 -0
- package/dist/bridge/messages/listUsers.d.ts.map +1 -0
- package/dist/bridge/messages/listUsers.js +33 -0
- package/dist/bridge/messages/pageChanged.d.ts +12 -0
- package/dist/bridge/messages/pageChanged.d.ts.map +1 -0
- package/dist/bridge/messages/pageChanged.js +9 -0
- package/dist/bridge/messages/parentChanged.d.ts +22 -0
- package/dist/bridge/messages/parentChanged.d.ts.map +1 -0
- package/dist/bridge/messages/parentChanged.js +9 -0
- package/dist/bridge/messages/queryDataSource.d.ts +20 -0
- package/dist/bridge/messages/queryDataSource.d.ts.map +1 -0
- package/dist/bridge/messages/queryDataSource.js +19 -0
- package/dist/bridge/messages/queryDataSourceResult.d.ts +90 -0
- package/dist/bridge/messages/queryDataSourceResult.d.ts.map +1 -0
- package/dist/bridge/messages/queryDataSourceResult.js +21 -0
- package/dist/bridge/messages/ready.d.ts +45 -0
- package/dist/bridge/messages/ready.d.ts.map +1 -0
- package/dist/bridge/messages/ready.js +37 -0
- package/dist/bridge/messages/resize.d.ts +12 -0
- package/dist/bridge/messages/resize.d.ts.map +1 -0
- package/dist/bridge/messages/resize.js +10 -0
- package/dist/bridge/messages/sandboxToHost.d.ts +410 -0
- package/dist/bridge/messages/sandboxToHost.d.ts.map +1 -0
- package/dist/bridge/messages/sandboxToHost.js +25 -0
- package/dist/bridge/messages/themeChanged.d.ts +11 -0
- package/dist/bridge/messages/themeChanged.d.ts.map +1 -0
- package/dist/bridge/messages/themeChanged.js +10 -0
- package/dist/bridge/messages/updatePage.d.ts +171 -0
- package/dist/bridge/messages/updatePage.d.ts.map +1 -0
- package/dist/bridge/messages/updatePage.js +15 -0
- package/dist/bridge/messages/updatePageResult.d.ts +210 -0
- package/dist/bridge/messages/updatePageResult.d.ts.map +1 -0
- package/dist/bridge/messages/updatePageResult.js +27 -0
- package/dist/bridge/pages/page.d.ts +600 -0
- package/dist/bridge/pages/page.d.ts.map +1 -0
- package/dist/bridge/pages/page.js +217 -0
- package/dist/bridge/parent.d.ts +25 -0
- package/dist/bridge/parent.d.ts.map +1 -0
- package/dist/bridge/parent.js +11 -0
- package/dist/bridge/pendingRequests.d.ts +14 -0
- package/dist/bridge/pendingRequests.d.ts.map +1 -0
- package/dist/bridge/pendingRequests.js +27 -0
- package/dist/bridge/sandboxClient.d.ts +63 -0
- package/dist/bridge/sandboxClient.d.ts.map +1 -0
- package/dist/bridge/sandboxClient.js +92 -0
- package/dist/bridge/theme.d.ts +4 -0
- package/dist/bridge/theme.d.ts.map +1 -0
- package/dist/bridge/theme.js +2 -0
- package/dist/bridge/users/user.d.ts +36 -0
- package/dist/bridge/users/user.d.ts.map +1 -0
- package/dist/bridge/users/user.js +19 -0
- package/dist/customBlock.d.ts +36 -0
- package/dist/customBlock.d.ts.map +1 -0
- package/dist/customBlock.js +65 -0
- package/dist/host/createCustomBlockHost.d.ts +34 -0
- package/dist/host/createCustomBlockHost.d.ts.map +1 -0
- package/dist/host/createCustomBlockHost.js +278 -0
- package/dist/host/lifecycle/initErrors.d.ts +10 -0
- package/dist/host/lifecycle/initErrors.d.ts.map +1 -0
- package/dist/host/lifecycle/initErrors.js +123 -0
- package/dist/host/lifecycle/ready.d.ts +8 -0
- package/dist/host/lifecycle/ready.d.ts.map +1 -0
- package/dist/host/lifecycle/ready.js +24 -0
- package/dist/host/lifecycle/types.d.ts +24 -0
- package/dist/host/lifecycle/types.d.ts.map +1 -0
- package/dist/host/lifecycle/types.js +1 -0
- package/dist/host/messages/invalidSandboxMessage.d.ts +7 -0
- package/dist/host/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/host/messages/invalidSandboxMessage.js +24 -0
- package/dist/host/messages/types.d.ts +60 -0
- package/dist/host/messages/types.d.ts.map +1 -0
- package/dist/host/messages/types.js +1 -0
- package/dist/host/queries/querySubscriptions.d.ts +20 -0
- package/dist/host/queries/querySubscriptions.d.ts.map +1 -0
- package/dist/host/queries/querySubscriptions.js +29 -0
- package/dist/host/queries/types.d.ts +9 -0
- package/dist/host/queries/types.d.ts.map +1 -0
- package/dist/host/queries/types.js +1 -0
- package/dist/host.d.ts +73 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +42 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/init.d.ts +53 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +87 -0
- package/dist/react/DebugMessageLog.d.ts +2 -0
- package/dist/react/DebugMessageLog.d.ts.map +1 -0
- package/dist/react/DebugMessageLog.js +22 -0
- package/dist/react/NotionCustomBlock.css +110 -0
- package/dist/react/NotionCustomBlock.d.ts +50 -0
- package/dist/react/NotionCustomBlock.d.ts.map +1 -0
- package/dist/react/NotionCustomBlock.js +81 -0
- package/dist/react/index.d.ts +14 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +13 -0
- package/dist/react/standalonePreview.d.ts +2 -0
- package/dist/react/standalonePreview.d.ts.map +1 -0
- package/dist/react/standalonePreview.js +26 -0
- package/dist/react/useCustomBlockAutoResize.d.ts +30 -0
- package/dist/react/useCustomBlockAutoResize.d.ts.map +1 -0
- package/dist/react/useCustomBlockAutoResize.js +35 -0
- package/dist/react/useCustomBlockInit.d.ts +43 -0
- package/dist/react/useCustomBlockInit.d.ts.map +1 -0
- package/dist/react/useCustomBlockInit.js +60 -0
- package/dist/react/useDataSource.d.ts +13 -0
- package/dist/react/useDataSource.d.ts.map +1 -0
- package/dist/react/useDataSource.js +37 -0
- package/dist/react/useHostState.d.ts +2 -0
- package/dist/react/useHostState.d.ts.map +1 -0
- package/dist/react/useHostState.js +5 -0
- package/dist/react/useRuntimeState.d.ts +66 -0
- package/dist/react/useRuntimeState.d.ts.map +1 -0
- package/dist/react/useRuntimeState.js +73 -0
- package/dist/types.d.ts +154 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/docs/block-location.md +83 -0
- package/docs/data-sources.md +186 -0
- package/docs/lifecycle.md +172 -0
- package/docs/manifest.md +42 -0
- package/docs/pages.md +143 -0
- package/docs/users.md +92 -0
- package/package.json +69 -0
- package/src/autoResize.ts +84 -0
- package/src/bridge/SandboxBridge.ts +921 -0
- package/src/bridge/dataSources/dataSource.ts +63 -0
- package/src/bridge/dataSources/dataSourcePage.ts +71 -0
- package/src/bridge/dataSources/dataSourceValue.ts +19 -0
- package/src/bridge/dataSources/dateValue.ts +96 -0
- package/src/bridge/dataSources/errors.ts +14 -0
- package/src/bridge/dataSources/propertySchema.ts +186 -0
- package/src/bridge/dataSources/recordPointer.ts +13 -0
- package/src/bridge/dataSources/resolve.ts +99 -0
- package/src/bridge/dataSources/resolveProperty.ts +130 -0
- package/src/bridge/errors.ts +13 -0
- package/src/bridge/hostState.ts +154 -0
- package/src/bridge/ids.ts +58 -0
- package/src/bridge/incomingType.ts +19 -0
- package/src/bridge/loadManifest.ts +89 -0
- package/src/bridge/manifest.ts +53 -0
- package/src/bridge/messages/createPage.ts +67 -0
- package/src/bridge/messages/createPageResult.ts +52 -0
- package/src/bridge/messages/currentUserChanged.ts +14 -0
- package/src/bridge/messages/dataSourcesChanged.ts +18 -0
- package/src/bridge/messages/getPage.ts +52 -0
- package/src/bridge/messages/getUser.ts +48 -0
- package/src/bridge/messages/hostToSandbox.ts +37 -0
- package/src/bridge/messages/init.ts +81 -0
- package/src/bridge/messages/invalidHostMessage.ts +16 -0
- package/src/bridge/messages/invalidSandboxMessage.ts +18 -0
- package/src/bridge/messages/listUsers.ts +49 -0
- package/src/bridge/messages/pageChanged.ts +12 -0
- package/src/bridge/messages/parentChanged.ts +14 -0
- package/src/bridge/messages/queryDataSource.ts +24 -0
- package/src/bridge/messages/queryDataSourceResult.ts +38 -0
- package/src/bridge/messages/ready.ts +41 -0
- package/src/bridge/messages/resize.ts +13 -0
- package/src/bridge/messages/sandboxToHost.ts +30 -0
- package/src/bridge/messages/themeChanged.ts +15 -0
- package/src/bridge/messages/updatePage.ts +22 -0
- package/src/bridge/messages/updatePageResult.ts +49 -0
- package/src/bridge/pages/page.ts +281 -0
- package/src/bridge/parent.ts +27 -0
- package/src/bridge/pendingRequests.ts +28 -0
- package/src/bridge/sandboxClient.ts +137 -0
- package/src/bridge/theme.ts +5 -0
- package/src/bridge/users/user.ts +31 -0
- package/src/css.d.ts +1 -0
- package/src/customBlock.ts +102 -0
- package/src/host/createCustomBlockHost.ts +392 -0
- package/src/host/lifecycle/initErrors.ts +132 -0
- package/src/host/lifecycle/ready.ts +36 -0
- package/src/host/lifecycle/types.ts +28 -0
- package/src/host/messages/invalidSandboxMessage.ts +38 -0
- package/src/host/messages/types.ts +67 -0
- package/src/host/queries/querySubscriptions.ts +52 -0
- package/src/host/queries/types.ts +16 -0
- package/src/host.ts +167 -0
- package/src/index.ts +115 -0
- package/src/init.ts +143 -0
- package/src/react/DebugMessageLog.tsx +30 -0
- package/src/react/NotionCustomBlock.css +110 -0
- package/src/react/NotionCustomBlock.tsx +151 -0
- package/src/react/index.ts +28 -0
- package/src/react/standalonePreview.ts +28 -0
- package/src/react/useCustomBlockAutoResize.ts +46 -0
- package/src/react/useCustomBlockInit.ts +91 -0
- package/src/react/useDataSource.ts +47 -0
- package/src/react/useHostState.ts +9 -0
- package/src/react/useRuntimeState.ts +85 -0
- package/src/types.ts +175 -0
- package/src/utils.ts +13 -0
- package/src/version.ts +8 -0
- package/vite-plugin/index.d.ts +46 -0
- package/vite-plugin/index.js +115 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Hex-token identifiers for Notion's named colors. Mirrors the public API's
|
|
4
|
+
* `select.options[].color` enum
|
|
5
|
+
* (https://developers.notion.com/reference/property-object#select).
|
|
6
|
+
*/
|
|
7
|
+
export declare const notionPropertyColorSchema: v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>;
|
|
8
|
+
export type NotionPropertyColor = v.InferOutput<typeof notionPropertyColorSchema>;
|
|
9
|
+
export declare const notionPropertyOptionSchema: v.ObjectSchema<{
|
|
10
|
+
readonly id: v.StringSchema<undefined>;
|
|
11
|
+
readonly name: v.StringSchema<undefined>;
|
|
12
|
+
readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
|
|
13
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
14
|
+
}, undefined>;
|
|
15
|
+
export type NotionPropertyOption = v.InferOutput<typeof notionPropertyOptionSchema>;
|
|
16
|
+
export declare const notionStatusGroupSchema: v.ObjectSchema<{
|
|
17
|
+
readonly id: v.StringSchema<undefined>;
|
|
18
|
+
readonly name: v.StringSchema<undefined>;
|
|
19
|
+
readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
|
|
20
|
+
readonly option_ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
export type NotionStatusGroup = v.InferOutput<typeof notionStatusGroupSchema>;
|
|
23
|
+
export declare const notionDualPropertySchema: v.ObjectSchema<{
|
|
24
|
+
readonly synced_property_id: v.StringSchema<undefined>;
|
|
25
|
+
readonly synced_property_name: v.StringSchema<undefined>;
|
|
26
|
+
}, undefined>;
|
|
27
|
+
export type NotionDualProperty = v.InferOutput<typeof notionDualPropertySchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Every Notion property type the bridge speaks, in a single readable list.
|
|
30
|
+
* Mirrors the Notion public API
|
|
31
|
+
* [property object](https://developers.notion.com/reference/property-object)
|
|
32
|
+
* type field. Internal-only types (`button`, `verification`,
|
|
33
|
+
* `last_visited_time`, `location`) and the four built-ins (`created_time`,
|
|
34
|
+
* `last_edited_time`, `created_by`, `last_edited_by`) are included under their
|
|
35
|
+
* bridge-native names.
|
|
36
|
+
*/
|
|
37
|
+
export declare const NOTION_PROPERTY_TYPES: 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"];
|
|
38
|
+
export declare const notionPropertyTypeSchema: 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
|
+
/**
|
|
40
|
+
* String literal union of every supported Notion property type. Same set as
|
|
41
|
+
* the discriminator in `NotionPropertySchema` — split out so the manifest
|
|
42
|
+
* can declare expected property types without dragging in the per-type
|
|
43
|
+
* payload shapes.
|
|
44
|
+
*/
|
|
45
|
+
export type NotionPropertyType = v.InferOutput<typeof notionPropertyTypeSchema>;
|
|
46
|
+
/**
|
|
47
|
+
* Per-property schema as exposed by the host over the custom-block bridge.
|
|
48
|
+
* The `type` discriminator must be one of {@link NOTION_PROPERTY_TYPES}.
|
|
49
|
+
*/
|
|
50
|
+
export declare const notionPropertySchemaSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
51
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
52
|
+
readonly name: v.StringSchema<undefined>;
|
|
53
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
54
|
+
}, undefined>, v.ObjectSchema<{
|
|
55
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
56
|
+
readonly name: v.StringSchema<undefined>;
|
|
57
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
58
|
+
}, undefined>, v.ObjectSchema<{
|
|
59
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
60
|
+
readonly name: v.StringSchema<undefined>;
|
|
61
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
62
|
+
}, undefined>, v.ObjectSchema<{
|
|
63
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
64
|
+
readonly name: v.StringSchema<undefined>;
|
|
65
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
|
+
}, undefined>, v.ObjectSchema<{
|
|
67
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
68
|
+
readonly name: v.StringSchema<undefined>;
|
|
69
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
70
|
+
}, undefined>, v.ObjectSchema<{
|
|
71
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
72
|
+
readonly name: v.StringSchema<undefined>;
|
|
73
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
74
|
+
}, undefined>, v.ObjectSchema<{
|
|
75
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
76
|
+
readonly name: v.StringSchema<undefined>;
|
|
77
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
78
|
+
}, undefined>, v.ObjectSchema<{
|
|
79
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
80
|
+
readonly options: v.ArraySchema<v.ObjectSchema<{
|
|
81
|
+
readonly id: v.StringSchema<undefined>;
|
|
82
|
+
readonly name: v.StringSchema<undefined>;
|
|
83
|
+
readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
|
|
84
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
}, undefined>, undefined>;
|
|
86
|
+
readonly name: v.StringSchema<undefined>;
|
|
87
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
88
|
+
}, undefined>, v.ObjectSchema<{
|
|
89
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
90
|
+
readonly options: v.ArraySchema<v.ObjectSchema<{
|
|
91
|
+
readonly id: v.StringSchema<undefined>;
|
|
92
|
+
readonly name: v.StringSchema<undefined>;
|
|
93
|
+
readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
|
|
94
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
95
|
+
}, undefined>, undefined>;
|
|
96
|
+
readonly name: v.StringSchema<undefined>;
|
|
97
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
98
|
+
}, undefined>, v.ObjectSchema<{
|
|
99
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
100
|
+
readonly options: v.ArraySchema<v.ObjectSchema<{
|
|
101
|
+
readonly id: v.StringSchema<undefined>;
|
|
102
|
+
readonly name: v.StringSchema<undefined>;
|
|
103
|
+
readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
|
|
104
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
105
|
+
}, undefined>, undefined>;
|
|
106
|
+
readonly groups: v.ArraySchema<v.ObjectSchema<{
|
|
107
|
+
readonly id: v.StringSchema<undefined>;
|
|
108
|
+
readonly name: v.StringSchema<undefined>;
|
|
109
|
+
readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
|
|
110
|
+
readonly option_ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
111
|
+
}, undefined>, undefined>;
|
|
112
|
+
readonly name: v.StringSchema<undefined>;
|
|
113
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
114
|
+
}, undefined>, v.ObjectSchema<{
|
|
115
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
116
|
+
readonly name: v.StringSchema<undefined>;
|
|
117
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
118
|
+
}, undefined>, v.ObjectSchema<{
|
|
119
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
120
|
+
readonly name: v.StringSchema<undefined>;
|
|
121
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
122
|
+
}, undefined>, v.ObjectSchema<{
|
|
123
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
124
|
+
readonly name: v.StringSchema<undefined>;
|
|
125
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
126
|
+
}, undefined>, v.ObjectSchema<{
|
|
127
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
128
|
+
readonly name: v.StringSchema<undefined>;
|
|
129
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
130
|
+
}, undefined>, v.ObjectSchema<{
|
|
131
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
132
|
+
readonly data_source_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
133
|
+
readonly dual_property: v.OptionalSchema<v.ObjectSchema<{
|
|
134
|
+
readonly synced_property_id: v.StringSchema<undefined>;
|
|
135
|
+
readonly synced_property_name: v.StringSchema<undefined>;
|
|
136
|
+
}, undefined>, undefined>;
|
|
137
|
+
readonly name: v.StringSchema<undefined>;
|
|
138
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
139
|
+
}, undefined>, v.ObjectSchema<{
|
|
140
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
141
|
+
readonly name: v.StringSchema<undefined>;
|
|
142
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
143
|
+
}, undefined>, v.ObjectSchema<{
|
|
144
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
145
|
+
readonly name: v.StringSchema<undefined>;
|
|
146
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
147
|
+
}, undefined>, v.ObjectSchema<{
|
|
148
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
149
|
+
readonly name: v.StringSchema<undefined>;
|
|
150
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
151
|
+
}, undefined>, v.ObjectSchema<{
|
|
152
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
153
|
+
readonly name: v.StringSchema<undefined>;
|
|
154
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
155
|
+
}, undefined>, v.ObjectSchema<{
|
|
156
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
157
|
+
readonly name: v.StringSchema<undefined>;
|
|
158
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
159
|
+
}, undefined>, v.ObjectSchema<{
|
|
160
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
161
|
+
readonly name: v.StringSchema<undefined>;
|
|
162
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
163
|
+
}, undefined>, v.ObjectSchema<{
|
|
164
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
165
|
+
readonly name: v.StringSchema<undefined>;
|
|
166
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
167
|
+
}, undefined>, v.ObjectSchema<{
|
|
168
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
169
|
+
readonly name: v.StringSchema<undefined>;
|
|
170
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
171
|
+
}, undefined>, v.ObjectSchema<{
|
|
172
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
173
|
+
readonly name: v.StringSchema<undefined>;
|
|
174
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
175
|
+
}, undefined>, v.ObjectSchema<{
|
|
176
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
177
|
+
readonly name: v.StringSchema<undefined>;
|
|
178
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
179
|
+
}, undefined>, v.ObjectSchema<{
|
|
180
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
181
|
+
readonly name: v.StringSchema<undefined>;
|
|
182
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
183
|
+
}, undefined>], undefined>;
|
|
184
|
+
export type NotionPropertySchema = v.InferOutput<typeof notionPropertySchemaSchema>;
|
|
185
|
+
/**
|
|
186
|
+
* The four synthetic built-in property IDs the host always includes in every
|
|
187
|
+
* data source's `propertySchemasById` and every row's `propertiesById`.
|
|
188
|
+
*/
|
|
189
|
+
export declare const NOTION_BUILTIN_PROPERTY_IDS: readonly ["created_time", "last_edited_time", "created_by", "last_edited_by"];
|
|
190
|
+
export type NotionBuiltinPropertyId = (typeof NOTION_BUILTIN_PROPERTY_IDS)[number];
|
|
191
|
+
//# sourceMappingURL=propertySchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertySchema.d.ts","sourceRoot":"","sources":["../../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/dataSources/propertySchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,iUAqBpC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAC9C,OAAO,yBAAyB,CAChC,CAAA;AAED,eAAO,MAAM,0BAA0B;;;;;aAKrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA;AAED,eAAO,MAAM,uBAAuB;;;;;aAKlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE7E,eAAO,MAAM,wBAAwB;;;aAGnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAO/E;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,4UA2BxB,CAAA;AAEV,eAAO,MAAM,wBAAwB,yWAAoC,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAiDrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,+EAK9B,CAAA;AAEV,MAAM,MAAM,uBAAuB,GAClC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Hex-token identifiers for Notion's named colors. Mirrors the public API's
|
|
4
|
+
* `select.options[].color` enum
|
|
5
|
+
* (https://developers.notion.com/reference/property-object#select).
|
|
6
|
+
*/
|
|
7
|
+
export const notionPropertyColorSchema = v.picklist([
|
|
8
|
+
"default",
|
|
9
|
+
"gray",
|
|
10
|
+
"brown",
|
|
11
|
+
"orange",
|
|
12
|
+
"yellow",
|
|
13
|
+
"green",
|
|
14
|
+
"blue",
|
|
15
|
+
"purple",
|
|
16
|
+
"pink",
|
|
17
|
+
"red",
|
|
18
|
+
"gray_background",
|
|
19
|
+
"brown_background",
|
|
20
|
+
"orange_background",
|
|
21
|
+
"yellow_background",
|
|
22
|
+
"green_background",
|
|
23
|
+
"blue_background",
|
|
24
|
+
"purple_background",
|
|
25
|
+
"pink_background",
|
|
26
|
+
"red_background",
|
|
27
|
+
"default_background",
|
|
28
|
+
]);
|
|
29
|
+
export const notionPropertyOptionSchema = v.object({
|
|
30
|
+
id: v.string(),
|
|
31
|
+
name: v.string(),
|
|
32
|
+
color: v.optional(notionPropertyColorSchema),
|
|
33
|
+
description: v.optional(v.string()),
|
|
34
|
+
});
|
|
35
|
+
export const notionStatusGroupSchema = v.object({
|
|
36
|
+
id: v.string(),
|
|
37
|
+
name: v.string(),
|
|
38
|
+
color: v.optional(notionPropertyColorSchema),
|
|
39
|
+
option_ids: v.array(v.string()),
|
|
40
|
+
});
|
|
41
|
+
export const notionDualPropertySchema = v.object({
|
|
42
|
+
synced_property_id: v.string(),
|
|
43
|
+
synced_property_name: v.string(),
|
|
44
|
+
});
|
|
45
|
+
const baseProp = v.object({
|
|
46
|
+
name: v.string(),
|
|
47
|
+
description: v.optional(v.string()),
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Every Notion property type the bridge speaks, in a single readable list.
|
|
51
|
+
* Mirrors the Notion public API
|
|
52
|
+
* [property object](https://developers.notion.com/reference/property-object)
|
|
53
|
+
* type field. Internal-only types (`button`, `verification`,
|
|
54
|
+
* `last_visited_time`, `location`) and the four built-ins (`created_time`,
|
|
55
|
+
* `last_edited_time`, `created_by`, `last_edited_by`) are included under their
|
|
56
|
+
* bridge-native names.
|
|
57
|
+
*/
|
|
58
|
+
export const NOTION_PROPERTY_TYPES = [
|
|
59
|
+
"title",
|
|
60
|
+
"rich_text",
|
|
61
|
+
"number",
|
|
62
|
+
"checkbox",
|
|
63
|
+
"url",
|
|
64
|
+
"email",
|
|
65
|
+
"phone_number",
|
|
66
|
+
"select",
|
|
67
|
+
"multi_select",
|
|
68
|
+
"status",
|
|
69
|
+
"date",
|
|
70
|
+
"people",
|
|
71
|
+
"files",
|
|
72
|
+
"unique_id",
|
|
73
|
+
"relation",
|
|
74
|
+
"place",
|
|
75
|
+
"formula",
|
|
76
|
+
"rollup",
|
|
77
|
+
"button",
|
|
78
|
+
"verification",
|
|
79
|
+
"last_visited_time",
|
|
80
|
+
"location",
|
|
81
|
+
"created_time",
|
|
82
|
+
"last_edited_time",
|
|
83
|
+
"created_by",
|
|
84
|
+
"last_edited_by",
|
|
85
|
+
];
|
|
86
|
+
export const notionPropertyTypeSchema = v.picklist(NOTION_PROPERTY_TYPES);
|
|
87
|
+
/**
|
|
88
|
+
* Per-property schema as exposed by the host over the custom-block bridge.
|
|
89
|
+
* The `type` discriminator must be one of {@link NOTION_PROPERTY_TYPES}.
|
|
90
|
+
*/
|
|
91
|
+
export const notionPropertySchemaSchema = v.variant("type", [
|
|
92
|
+
v.object({ ...baseProp.entries, type: v.literal("title") }),
|
|
93
|
+
v.object({ ...baseProp.entries, type: v.literal("rich_text") }),
|
|
94
|
+
v.object({ ...baseProp.entries, type: v.literal("number") }),
|
|
95
|
+
v.object({ ...baseProp.entries, type: v.literal("checkbox") }),
|
|
96
|
+
v.object({ ...baseProp.entries, type: v.literal("url") }),
|
|
97
|
+
v.object({ ...baseProp.entries, type: v.literal("email") }),
|
|
98
|
+
v.object({ ...baseProp.entries, type: v.literal("phone_number") }),
|
|
99
|
+
v.object({
|
|
100
|
+
...baseProp.entries,
|
|
101
|
+
type: v.literal("select"),
|
|
102
|
+
options: v.array(notionPropertyOptionSchema),
|
|
103
|
+
}),
|
|
104
|
+
v.object({
|
|
105
|
+
...baseProp.entries,
|
|
106
|
+
type: v.literal("multi_select"),
|
|
107
|
+
options: v.array(notionPropertyOptionSchema),
|
|
108
|
+
}),
|
|
109
|
+
v.object({
|
|
110
|
+
...baseProp.entries,
|
|
111
|
+
type: v.literal("status"),
|
|
112
|
+
options: v.array(notionPropertyOptionSchema),
|
|
113
|
+
groups: v.array(notionStatusGroupSchema),
|
|
114
|
+
}),
|
|
115
|
+
v.object({ ...baseProp.entries, type: v.literal("date") }),
|
|
116
|
+
v.object({ ...baseProp.entries, type: v.literal("people") }),
|
|
117
|
+
v.object({ ...baseProp.entries, type: v.literal("files") }),
|
|
118
|
+
v.object({ ...baseProp.entries, type: v.literal("unique_id") }),
|
|
119
|
+
v.object({
|
|
120
|
+
...baseProp.entries,
|
|
121
|
+
type: v.literal("relation"),
|
|
122
|
+
data_source_id: v.optional(v.string()),
|
|
123
|
+
dual_property: v.optional(notionDualPropertySchema),
|
|
124
|
+
}),
|
|
125
|
+
v.object({ ...baseProp.entries, type: v.literal("place") }),
|
|
126
|
+
v.object({ ...baseProp.entries, type: v.literal("formula") }),
|
|
127
|
+
v.object({ ...baseProp.entries, type: v.literal("rollup") }),
|
|
128
|
+
// Internal-only types passed through under their bridge-native names.
|
|
129
|
+
v.object({ ...baseProp.entries, type: v.literal("button") }),
|
|
130
|
+
v.object({ ...baseProp.entries, type: v.literal("verification") }),
|
|
131
|
+
v.object({ ...baseProp.entries, type: v.literal("last_visited_time") }),
|
|
132
|
+
v.object({ ...baseProp.entries, type: v.literal("location") }),
|
|
133
|
+
// Synthetic built-ins. The host always emits one of each per data source.
|
|
134
|
+
v.object({ ...baseProp.entries, type: v.literal("created_time") }),
|
|
135
|
+
v.object({ ...baseProp.entries, type: v.literal("last_edited_time") }),
|
|
136
|
+
v.object({ ...baseProp.entries, type: v.literal("created_by") }),
|
|
137
|
+
v.object({ ...baseProp.entries, type: v.literal("last_edited_by") }),
|
|
138
|
+
]);
|
|
139
|
+
/**
|
|
140
|
+
* The four synthetic built-in property IDs the host always includes in every
|
|
141
|
+
* data source's `propertySchemasById` and every row's `propertiesById`.
|
|
142
|
+
*/
|
|
143
|
+
export const NOTION_BUILTIN_PROPERTY_IDS = [
|
|
144
|
+
"created_time",
|
|
145
|
+
"last_edited_time",
|
|
146
|
+
"created_by",
|
|
147
|
+
"last_edited_by",
|
|
148
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* A pointer to a record in a database.
|
|
4
|
+
*/
|
|
5
|
+
export declare const notionRecordPointerSchema: v.ObjectSchema<{
|
|
6
|
+
readonly id: v.StringSchema<undefined>;
|
|
7
|
+
readonly table: v.StringSchema<undefined>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
export type NotionRecordPointer = v.InferOutput<typeof notionRecordPointerSchema>;
|
|
10
|
+
//# sourceMappingURL=recordPointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordPointer.d.ts","sourceRoot":"","sources":["../../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/dataSources/recordPointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;aAGpC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAC9C,OAAO,yBAAyB,CAChC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CustomBlockManifest } from "../manifest.js";
|
|
2
|
+
import type { NotionDataSource, NotionDataSourceBindings } from "./dataSource.js";
|
|
3
|
+
import type { NotionPropertySchema } from "./propertySchema.js";
|
|
4
|
+
type ResolveDataSourcesArgs = {
|
|
5
|
+
manifest: CustomBlockManifest | null;
|
|
6
|
+
dataSourceBindings: NotionDataSourceBindings;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Builds the public {@link NotionDataSource} list the SDK exposes to consumers.
|
|
10
|
+
*
|
|
11
|
+
* Combines the host-supplied bindings (collection pointers + schemas) with the
|
|
12
|
+
* manifest's declared data-source keys. When the manifest names a property
|
|
13
|
+
* that isn't in `propertyIdsByKey`, falls back to {@link findPropertyIdByManifestProperty}
|
|
14
|
+
* so renames in Notion still resolve as long as the schema name matches.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveDataSources(args: ResolveDataSourcesArgs): NotionDataSource[];
|
|
17
|
+
export declare function findPropertyIdByManifestProperty(propertySchemasById: Record<string, NotionPropertySchema>, manifestProperty: {
|
|
18
|
+
key: string;
|
|
19
|
+
type: NotionPropertySchema["type"];
|
|
20
|
+
}): string | undefined;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/dataSources/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,EACX,gBAAgB,EAChB,wBAAwB,EACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,KAAK,sBAAsB,GAAG;IAC7B,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACpC,kBAAkB,EAAE,wBAAwB,CAAA;CAC5C,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,sBAAsB,GAC1B,gBAAgB,EAAE,CA+CpB;AAED,wBAAgB,gCAAgC,CAC/C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACzD,gBAAgB,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAA;CAAE,GACnE,MAAM,GAAG,SAAS,CAoBpB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the public {@link NotionDataSource} list the SDK exposes to consumers.
|
|
3
|
+
*
|
|
4
|
+
* Combines the host-supplied bindings (collection pointers + schemas) with the
|
|
5
|
+
* manifest's declared data-source keys. When the manifest names a property
|
|
6
|
+
* that isn't in `propertyIdsByKey`, falls back to {@link findPropertyIdByManifestProperty}
|
|
7
|
+
* so renames in Notion still resolve as long as the schema name matches.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveDataSources(args) {
|
|
10
|
+
if (args.manifest === null) {
|
|
11
|
+
return Object.entries(args.dataSourceBindings).map(([key, binding]) => ({
|
|
12
|
+
key,
|
|
13
|
+
collectionPointer: binding.collectionPointer,
|
|
14
|
+
collectionSchema: binding.collectionSchema,
|
|
15
|
+
propertyIdsByKey: { ...(binding.propertyIdsByKey ?? {}) },
|
|
16
|
+
propertySchemasById: binding.collectionSchema?.propertiesById ?? {},
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
return Object.entries(args.manifest.dataSources).map(([key, manifestDataSource]) => {
|
|
20
|
+
const binding = args.dataSourceBindings[key];
|
|
21
|
+
const propertySchemasById = binding?.collectionSchema?.propertiesById ?? {};
|
|
22
|
+
const bindingPropertyIdsByKey = binding?.propertyIdsByKey ?? {};
|
|
23
|
+
const propertyIdsByKey = {};
|
|
24
|
+
const manifestProperties = Object.entries(manifestDataSource.properties ?? {});
|
|
25
|
+
for (const [propertyKey, manifestProperty] of manifestProperties) {
|
|
26
|
+
const propertyId = propertyKey in bindingPropertyIdsByKey
|
|
27
|
+
? bindingPropertyIdsByKey[propertyKey]
|
|
28
|
+
: findPropertyIdByManifestProperty(propertySchemasById, {
|
|
29
|
+
key: propertyKey,
|
|
30
|
+
type: manifestProperty.type,
|
|
31
|
+
});
|
|
32
|
+
const propertySchema = propertyId === undefined ? undefined : propertySchemasById[propertyId];
|
|
33
|
+
propertyIdsByKey[propertyKey] =
|
|
34
|
+
propertySchema?.type === manifestProperty.type
|
|
35
|
+
? propertyId
|
|
36
|
+
: undefined;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
key,
|
|
40
|
+
collectionPointer: binding?.collectionPointer,
|
|
41
|
+
collectionSchema: binding?.collectionSchema,
|
|
42
|
+
propertyIdsByKey,
|
|
43
|
+
propertySchemasById,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function findPropertyIdByManifestProperty(propertySchemasById, manifestProperty) {
|
|
48
|
+
// `ManifestProperty.name` is display copy for setup UI. Binding fallback is based
|
|
49
|
+
// on the stable semantic key so copy changes don't affect property resolution.
|
|
50
|
+
const propertySchemaForKey = propertySchemasById[manifestProperty.key];
|
|
51
|
+
if (propertySchemaForKey?.type === manifestProperty.type) {
|
|
52
|
+
return manifestProperty.key;
|
|
53
|
+
}
|
|
54
|
+
const normalizedKey = normalizePropertyName(manifestProperty.key);
|
|
55
|
+
for (const [propertyId, propertySchema] of Object.entries(propertySchemasById)) {
|
|
56
|
+
if (propertySchema.type === manifestProperty.type &&
|
|
57
|
+
normalizePropertyName(propertySchema.name) === normalizedKey) {
|
|
58
|
+
return propertyId;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
function normalizePropertyName(value) {
|
|
64
|
+
return value.trim().toLowerCase();
|
|
65
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { CustomBlockErrorInfo } from "../errors";
|
|
3
|
+
import type { NotionPagePropertyInputMap, NotionPagePropertyWriteMap } from "../pages/page.js";
|
|
4
|
+
import type { NotionDataSource } from "./dataSource.js";
|
|
5
|
+
export declare const customBlockPropertyErrorCodeSchema: v.StringSchema<undefined>;
|
|
6
|
+
export type CustomBlockPropertyErrorCode = "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | (string & {});
|
|
7
|
+
export type CustomBlockPropertyErrorInfo = CustomBlockErrorInfo<CustomBlockPropertyErrorCode>;
|
|
8
|
+
export type PropertyWriteMapResolutionResult = {
|
|
9
|
+
status: "success";
|
|
10
|
+
properties: NotionPagePropertyWriteMap;
|
|
11
|
+
} | {
|
|
12
|
+
status: "error";
|
|
13
|
+
error: CustomBlockPropertyErrorInfo;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a public SDK property write map into the ID-keyed bridge shape.
|
|
17
|
+
*
|
|
18
|
+
* Identifiers in `properties` may be raw property IDs or data-source property keys; the latter
|
|
19
|
+
* are looked up in the `dataSource`'s `propertyIdsByKey`. Each value is re-parsed through
|
|
20
|
+
* `notionPagePropertyValueSchema` with its `id` rewritten to the resolved property ID.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolvePropertyWriteMapForDataSource(args: {
|
|
23
|
+
dataSource: NotionDataSource | undefined;
|
|
24
|
+
properties: NotionPagePropertyInputMap;
|
|
25
|
+
operationName: string;
|
|
26
|
+
}): PropertyWriteMapResolutionResult;
|
|
27
|
+
/**
|
|
28
|
+
* Treats matching data-source keys as aliases for property IDs; all other identifiers are raw IDs.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolvePropertyIdentifierForDataSource(args: {
|
|
31
|
+
dataSource: NotionDataSource | undefined;
|
|
32
|
+
identifier: string;
|
|
33
|
+
operationName: string;
|
|
34
|
+
}): {
|
|
35
|
+
status: "success";
|
|
36
|
+
propertyId: string;
|
|
37
|
+
} | {
|
|
38
|
+
status: "error";
|
|
39
|
+
error: CustomBlockPropertyErrorInfo;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=resolveProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProperty.d.ts","sourceRoot":"","sources":["../../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/dataSources/resolveProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,KAAK,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,eAAO,MAAM,kCAAkC,2BAAa,CAAA;AAE5D,MAAM,MAAM,4BAA4B,GACrC,mBAAmB,GACnB,sBAAsB,GACtB,oBAAoB,GACpB,wBAAwB,GACxB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,4BAA4B,GACvC,oBAAoB,CAAC,4BAA4B,CAAC,CAAA;AAEnD,MAAM,MAAM,gCAAgC,GACzC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,0BAA0B,CAAA;CAAE,GAC7D;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,4BAA4B,CAAA;CAAE,CAAA;AAS3D;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAAC,IAAI,EAAE;IAC1D,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACxC,UAAU,EAAE,0BAA0B,CAAA;IACtC,aAAa,EAAE,MAAM,CAAA;CACrB,GAAG,gCAAgC,CAwDnC;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,IAAI,EAAE;IAC5D,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACxC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACrB,GACE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,4BAA4B,CAAA;CAAE,CAiB1D"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionPagePropertyValueSchema } from "../pages/page.js";
|
|
3
|
+
// The schema accepts any string code. The type lists known codes for
|
|
4
|
+
// autocomplete, with an open string fallback for newer senders.
|
|
5
|
+
export const customBlockPropertyErrorCodeSchema = v.string();
|
|
6
|
+
function makePropertyError(code, message) {
|
|
7
|
+
return { code, message, isRetryable: false };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a public SDK property write map into the ID-keyed bridge shape.
|
|
11
|
+
*
|
|
12
|
+
* Identifiers in `properties` may be raw property IDs or data-source property keys; the latter
|
|
13
|
+
* are looked up in the `dataSource`'s `propertyIdsByKey`. Each value is re-parsed through
|
|
14
|
+
* `notionPagePropertyValueSchema` with its `id` rewritten to the resolved property ID.
|
|
15
|
+
*/
|
|
16
|
+
export function resolvePropertyWriteMapForDataSource(args) {
|
|
17
|
+
const { dataSource, properties, operationName } = args;
|
|
18
|
+
const resolvedProperties = {};
|
|
19
|
+
for (const [identifier, value] of Object.entries(properties)) {
|
|
20
|
+
const propertyIdResult = resolvePropertyIdentifierForDataSource({
|
|
21
|
+
dataSource,
|
|
22
|
+
identifier,
|
|
23
|
+
operationName,
|
|
24
|
+
});
|
|
25
|
+
if (propertyIdResult.status === "error") {
|
|
26
|
+
return propertyIdResult;
|
|
27
|
+
}
|
|
28
|
+
const propertyId = propertyIdResult.propertyId;
|
|
29
|
+
if (value.id !== undefined &&
|
|
30
|
+
value.id !== identifier &&
|
|
31
|
+
value.id !== propertyId) {
|
|
32
|
+
return {
|
|
33
|
+
status: "error",
|
|
34
|
+
error: makePropertyError("property_id_mismatch", `Property ${identifier} resolved to ${propertyId} but value id was ${value.id}.`),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (resolvedProperties[propertyId] !== undefined) {
|
|
38
|
+
return {
|
|
39
|
+
status: "error",
|
|
40
|
+
error: makePropertyError("duplicate_property", `Cannot set property ${propertyId} more than once.`),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const parsedValue = v.safeParse(notionPagePropertyValueSchema, {
|
|
44
|
+
...value,
|
|
45
|
+
id: propertyId,
|
|
46
|
+
});
|
|
47
|
+
if (!parsedValue.success) {
|
|
48
|
+
return {
|
|
49
|
+
status: "error",
|
|
50
|
+
error: makePropertyError("invalid_property_value", `Invalid value for property ${identifier}.`),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
resolvedProperties[propertyId] = parsedValue.output;
|
|
54
|
+
}
|
|
55
|
+
return { status: "success", properties: resolvedProperties };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Treats matching data-source keys as aliases for property IDs; all other identifiers are raw IDs.
|
|
59
|
+
*/
|
|
60
|
+
export function resolvePropertyIdentifierForDataSource(args) {
|
|
61
|
+
const { dataSource, identifier, operationName } = args;
|
|
62
|
+
if (dataSource !== undefined && identifier in dataSource.propertyIdsByKey) {
|
|
63
|
+
const propertyId = dataSource.propertyIdsByKey[identifier];
|
|
64
|
+
if (propertyId === undefined) {
|
|
65
|
+
return {
|
|
66
|
+
status: "error",
|
|
67
|
+
error: makePropertyError("unmapped_property", `${operationName} cannot resolve property key "${identifier}" because it is not bound to a Notion property.`),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return { status: "success", propertyId };
|
|
71
|
+
}
|
|
72
|
+
return { status: "success", propertyId: identifier };
|
|
73
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export type CustomBlockErrorInfo<TCode extends string = string> = {
|
|
3
|
+
code: TCode;
|
|
4
|
+
message: string;
|
|
5
|
+
isRetryable: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const customBlockErrorInfoSchema: v.ObjectSchema<{
|
|
8
|
+
readonly code: v.StringSchema<undefined>;
|
|
9
|
+
readonly message: v.StringSchema<undefined>;
|
|
10
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
11
|
+
}, undefined>;
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI;IACjE,IAAI,EAAE,KAAK,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,0BAA0B;;;;aAIrC,CAAA"}
|