@notionhq/custom-blocks 0.3.5 → 0.5.0
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/README.md +2 -2
- package/dist/bridge/SandboxBridge.d.ts +4 -39
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +36 -142
- package/dist/bridge/requests.d.ts +35 -0
- package/dist/bridge/requests.d.ts.map +1 -0
- package/dist/bridge/requests.js +97 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -1
- package/dist/dataSources/bridge/resolveDataSourceQuery.js +18 -4
- package/dist/dataSources/bridge/resolveDataSources.js +4 -4
- package/dist/dataSources/createDataSourcePage.d.ts.map +1 -1
- package/dist/dataSources/createDataSourcePage.js +5 -1
- package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -1
- package/dist/dataSources/filters/resolveFilter.js +13 -3
- package/dist/dataSources/filters/types.d.ts +9 -3
- package/dist/dataSources/filters/types.d.ts.map +1 -1
- package/dist/dataSources/properties/resolvePropertyAddress.js +1 -1
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.js +1 -1
- package/dist/dataSources/resolvePageDataSource.js +2 -2
- package/dist/dataSources/subscribeToDataSource.d.ts +1 -4
- package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -1
- package/dist/dataSources/subscribeToDataSource.js +2 -3
- package/dist/dataSources/types.d.ts +2 -0
- package/dist/dataSources/types.d.ts.map +1 -1
- package/dist/files/files.d.ts +2 -0
- package/dist/files/files.d.ts.map +1 -0
- package/dist/files/files.js +1 -0
- package/dist/files/icons.d.ts +2 -0
- package/dist/files/icons.d.ts.map +1 -0
- package/dist/files/icons.js +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/initialization/getInitBindingError.js +2 -2
- package/dist/manifest/types.d.ts +5 -4
- package/dist/manifest/types.d.ts.map +1 -1
- package/dist/navigation/openExternalUrl.d.ts.map +1 -1
- package/dist/navigation/openExternalUrl.js +2 -1
- package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -1
- package/dist/pages/bridge/getPageForDataSource.js +3 -2
- package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -1
- package/dist/pages/bridge/sendCreatePageRequest.js +2 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +14 -2
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.js +0 -1
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.js +0 -8
- package/dist/pages/bridge/updatePage.d.ts.map +1 -1
- package/dist/pages/bridge/updatePage.js +20 -5
- package/dist/pages/createPage.d.ts.map +1 -1
- package/dist/pages/createPage.js +5 -1
- package/dist/pages/openPage.d.ts.map +1 -1
- package/dist/pages/openPage.js +2 -1
- package/dist/pages/properties/getPropertyByKey.js +2 -2
- package/dist/pages/types.d.ts +10 -14
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.d.ts +530 -0
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.js +25 -0
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +12 -11
- package/dist/protocol/compatibility/protocol3To5/bridgePage.js +3 -3
- package/dist/protocol/context/containingPage.d.ts +3 -0
- package/dist/protocol/context/messages/pageChanged.d.ts +3 -0
- package/dist/protocol/context/messages/parentChanged.d.ts +3 -0
- package/dist/protocol/context/parent.d.ts +5 -0
- package/dist/protocol/context/parent.js +6 -1
- package/dist/protocol/dataSources/bridgeArchiveStatus.d.ts +3 -0
- package/dist/protocol/dataSources/bridgeArchiveStatus.js +6 -0
- package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +3 -11
- package/dist/protocol/dataSources/bridgeDataSourceBinding.js +5 -5
- package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +2 -10
- package/dist/protocol/dataSources/{collectionPointer.d.ts → dataSourcePointer.d.ts} +2 -2
- package/dist/protocol/dataSources/{collectionPointer.js → dataSourcePointer.js} +1 -1
- package/dist/protocol/dataSources/{collectionSchema.d.ts → dataSourceSchema.d.ts} +2 -10
- package/dist/protocol/dataSources/{collectionSchema.js → dataSourceSchema.js} +1 -1
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.d.ts +1458 -12
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.d.ts +729 -6
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.js +14 -2
- package/dist/protocol/dataSources/filters/peopleFilterOperator.d.ts +3 -3
- package/dist/protocol/dataSources/filters/peopleFilterOperator.js +1 -1
- package/dist/protocol/dataSources/filters/timestampFilterOperator.d.ts +354 -0
- package/dist/protocol/dataSources/filters/timestampFilterOperator.js +4 -0
- package/dist/protocol/dataSources/messages/dataSourcesChanged.d.ts +2 -10
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +1485 -38
- package/dist/protocol/dataSources/messages/queryDataSource.js +2 -0
- package/dist/protocol/dataSources/notionDataSource.d.ts +3 -19
- package/dist/protocol/dataSources/notionDataSource.js +5 -5
- package/dist/protocol/dataSources/properties/propertySchema.d.ts +4 -13
- package/dist/protocol/dataSources/properties/propertySchema.js +2 -6
- package/dist/protocol/dataSources/resolveDataSourceBinding.d.ts +4 -4
- package/dist/protocol/dataSources/resolveDataSourceBinding.js +2 -2
- package/dist/protocol/files.d.ts +32 -0
- package/dist/protocol/files.js +17 -0
- package/dist/protocol/handshake/connect.d.ts +15 -4
- package/dist/protocol/handshake/init.d.ts +23 -14
- package/dist/protocol/icons.d.ts +32 -0
- package/dist/protocol/icons.js +39 -0
- package/dist/protocol/index.d.ts +25 -19
- package/dist/protocol/index.js +15 -9
- package/dist/protocol/manifest/grants.d.ts +48 -0
- package/dist/protocol/manifest/grants.js +19 -0
- package/dist/protocol/manifest/manifest.d.ts +39 -16
- package/dist/protocol/manifest/manifest.js +17 -11
- package/dist/protocol/messages/hostToSandbox.d.ts +196 -177
- package/dist/protocol/messages/invalidHostMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidHostMessage.js +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +2 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +1571 -50
- package/dist/protocol/navigation/openExternalUrl.d.ts +2 -2
- package/dist/protocol/pages/bridgePage.d.ts +12 -12
- package/dist/protocol/pages/bridgePage.js +3 -4
- package/dist/protocol/pages/makeBridgePage.d.ts +3 -1
- package/dist/protocol/pages/messages/createPage.d.ts +645 -62
- package/dist/protocol/pages/messages/createPage.js +27 -13
- package/dist/protocol/pages/messages/getPage.d.ts +38 -37
- package/dist/protocol/pages/messages/openPage.d.ts +2 -2
- package/dist/protocol/pages/messages/updatePage.d.ts +47 -48
- package/dist/protocol/pages/messages/updatePage.js +3 -3
- package/dist/protocol/pages/pageAppearance.d.ts +9 -28
- package/dist/protocol/pages/pageAppearance.js +11 -31
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +4 -20
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +2 -10
- package/dist/protocol/pages/properties/bridgePagePropertyValue.js +2 -12
- package/dist/protocol/users/makeBridgeUser.d.ts +3 -1
- package/dist/protocol/users/messages/getUser.d.ts +2 -2
- package/dist/protocol/users/messages/listUsers.d.ts +2 -2
- package/dist/protocol/utils/errors.d.ts +6 -4
- package/dist/protocol/utils/errors.js +3 -3
- package/dist/protocol/utils/ids.d.ts +2 -0
- package/dist/protocol/utils/ids.js +1 -0
- package/dist/protocol/utils/protocolVersion.d.ts +3 -1
- package/dist/protocol/utils/protocolVersion.js +5 -1
- package/dist/protocol/utils/readRequestId.d.ts +2 -0
- package/dist/protocol/utils/readRequestId.js +7 -0
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +1 -15
- package/dist/users/getUser.d.ts.map +1 -1
- package/dist/users/getUser.js +2 -1
- package/dist/users/listUsers.d.ts.map +1 -1
- package/dist/users/listUsers.js +4 -2
- package/dist/utils/version.js +1 -1
- package/docs/data-sources.md +85 -83
- package/docs/deployment.md +4 -5
- package/docs/errors.md +47 -5
- package/docs/grants.md +127 -0
- package/docs/pages.md +105 -56
- package/docs/users.md +2 -2
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +44 -243
- package/src/bridge/requests.ts +138 -0
- package/src/dataSources/bridge/resolveDataSourceQuery.ts +24 -4
- package/src/dataSources/bridge/resolveDataSources.ts +4 -4
- package/src/dataSources/createDataSourcePage.ts +5 -1
- package/src/dataSources/filters/resolveFilter.ts +12 -3
- package/src/dataSources/filters/types.ts +7 -4
- package/src/dataSources/properties/resolvePropertyAddress.ts +1 -1
- package/src/dataSources/properties/resolvePropertyWriteMapForDataSource.ts +1 -1
- package/src/dataSources/resolvePageDataSource.ts +2 -2
- package/src/dataSources/subscribeToDataSource.ts +7 -19
- package/src/dataSources/types.ts +3 -0
- package/src/files/files.ts +5 -0
- package/src/files/icons.ts +9 -0
- package/src/index.ts +10 -11
- package/src/initialization/getInitBindingError.ts +2 -2
- package/src/manifest/types.ts +10 -4
- package/src/navigation/openExternalUrl.ts +5 -1
- package/src/pages/bridge/getPageForDataSource.ts +6 -2
- package/src/pages/bridge/sendCreatePageRequest.ts +5 -1
- package/src/pages/bridge/toNotionPageFieldsFromBridgePage.ts +0 -1
- package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +0 -8
- package/src/pages/bridge/updatePage.ts +29 -9
- package/src/pages/createPage.ts +5 -1
- package/src/pages/openPage.ts +5 -1
- package/src/pages/properties/getPropertyByKey.ts +2 -2
- package/src/pages/types.ts +14 -16
- package/src/react/NotionCustomBlock.tsx +1 -16
- package/src/users/getUser.ts +5 -1
- package/src/users/listUsers.ts +9 -4
- package/dist/bridge/pendingRequests.d.ts +0 -14
- package/dist/bridge/pendingRequests.d.ts.map +0 -1
- package/dist/bridge/pendingRequests.js +0 -28
- package/dist/protocol/dataSources/filters/createdByFilterOperator.d.ts +0 -17
- package/dist/protocol/dataSources/filters/createdByFilterOperator.js +0 -11
- package/dist/protocol/manifest/capabilities.d.ts +0 -37
- package/dist/protocol/manifest/capabilities.js +0 -13
- package/dist/protocol/pages/properties/fileInput.d.ts +0 -16
- package/dist/protocol/pages/properties/fileInput.js +0 -16
- package/dist/react/DebugMessageLog.d.ts +0 -2
- package/dist/react/DebugMessageLog.d.ts.map +0 -1
- package/dist/react/DebugMessageLog.js +0 -23
- package/docs/capabilities.md +0 -111
- package/src/bridge/pendingRequests.ts +0 -28
- package/src/react/DebugMessageLog.tsx +0 -34
package/dist/protocol/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { bridgePageForProtocol3To5Schema } from "./compatibility/protocol3To5/bridgePage.js";
|
|
3
3
|
export { notionDataSourcePageForProtocol3To5Schema } from "./compatibility/protocol3To5/dataSourcePage.js";
|
|
4
4
|
export { notionDataSourceValueSchema } from "./compatibility/protocol3To5/dataSourceValue.js";
|
|
5
|
+
export { bridgeDataSourceBindingsForProtocol3To10Schema, dataSourceBindingsMessageForProtocol3To10Schema, } from "./compatibility/protocol3To10/dataSourceBindings.js";
|
|
5
6
|
export { customBlockPageSchema } from "./context/containingPage.js";
|
|
6
7
|
export { DEFAULT_CONTRAST_MODE, notionContrastModeSchema, } from "./context/contrast.js";
|
|
7
8
|
export { contrastModeChangedMessageSchema } from "./context/messages/contrastModeChanged.js";
|
|
@@ -11,16 +12,17 @@ export { resizeMessageSchema } from "./context/messages/resize.js";
|
|
|
11
12
|
export { themeChangedMessageSchema } from "./context/messages/themeChanged.js";
|
|
12
13
|
export { dataSourceParentSchema, notionParentSchema, pageParentSchema, } from "./context/parent.js";
|
|
13
14
|
export { notionThemeSchema } from "./context/theme.js";
|
|
15
|
+
export { bridgeArchiveStatusSchema } from "./dataSources/bridgeArchiveStatus.js";
|
|
14
16
|
export { bridgeDataSourceBindingSchema } from "./dataSources/bridgeDataSourceBinding.js";
|
|
15
17
|
export { bridgeDataSourceBindingsSchema } from "./dataSources/bridgeDataSourceBindings.js";
|
|
16
|
-
export {
|
|
18
|
+
export { dataSourcePointerValidator } from "./dataSources/dataSourcePointer.js";
|
|
19
|
+
export { notionDataSourceSchemaValidator } from "./dataSources/dataSourceSchema.js";
|
|
17
20
|
export { customBlockDataSourceResolutionErrorCodeSchema, customBlockPropertyErrorCodeSchema, } from "./dataSources/errors.js";
|
|
18
21
|
export { bridgeDataSourceFilterSchema } from "./dataSources/filters/bridgeDataSourceFilter.js";
|
|
19
22
|
export { bridgeDataSourceFilterConditionSchema } from "./dataSources/filters/bridgeDataSourceFilterCondition.js";
|
|
20
23
|
export { bridgeDataSourceSortSchema, CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS, } from "./dataSources/filters/bridgeDataSourceSort.js";
|
|
21
24
|
export { customBlockCheckboxFilterOperatorSchema } from "./dataSources/filters/checkboxFilterOperator.js";
|
|
22
25
|
export { customBlockContainsFilterOperatorSchema } from "./dataSources/filters/containsFilterOperator.js";
|
|
23
|
-
export { customBlockCreatedByFilterOperatorSchema } from "./dataSources/filters/createdByFilterOperator.js";
|
|
24
26
|
export { customBlockDateFilterOperatorSchema, customBlockRelativeDateValueSchema, } from "./dataSources/filters/dateFilterOperator.js";
|
|
25
27
|
export { customBlockNumberFilterOperatorSchema } from "./dataSources/filters/numberFilterOperator.js";
|
|
26
28
|
export { customBlockOptionFilterOperatorSchema } from "./dataSources/filters/optionFilterOperator.js";
|
|
@@ -29,6 +31,7 @@ export { customBlockRelationFilterOperatorSchema } from "./dataSources/filters/r
|
|
|
29
31
|
export { customBlockStatusFilterOperatorSchema } from "./dataSources/filters/statusFilterOperator.js";
|
|
30
32
|
export { customBlockStatusGroupFilterOperatorSchema, customBlockStatusGroupNameSchema, } from "./dataSources/filters/statusGroupFilterOperator.js";
|
|
31
33
|
export { customBlockTextFilterOperatorSchema } from "./dataSources/filters/textFilterOperator.js";
|
|
34
|
+
export { customBlockTimestampFilterOperatorSchema } from "./dataSources/filters/timestampFilterOperator.js";
|
|
32
35
|
export { makeBridgeDataSourceBinding } from "./dataSources/makeBridgeDataSourceBinding.js";
|
|
33
36
|
export { dataSourcesChangedMessageSchema } from "./dataSources/messages/dataSourcesChanged.js";
|
|
34
37
|
export { customBlockQueryDataSourceErrorCodeSchema, customBlockQueryDataSourceErrorInfoSchema, queryDataSourceMessageSchema, queryDataSourceResultMessageSchema, queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema, } from "./dataSources/messages/queryDataSource.js";
|
|
@@ -38,12 +41,14 @@ export { notionDateRangeSchema, notionDateReminderSchema, notionDateSchema, noti
|
|
|
38
41
|
export { CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES, NOTION_BUILTIN_PROPERTY_IDS, NOTION_BUILTIN_PROPERTY_SCHEMAS, NOTION_PROPERTY_TYPES, notionDualPropertySchema, notionPropertyColorSchema, notionPropertyOptionSchema, notionPropertySchemaSchema, notionPropertyTypeSchema, notionStatusGroupSchema, } from "./dataSources/properties/propertySchema.js";
|
|
39
42
|
export { resolveDataSourceBinding } from "./dataSources/resolveDataSourceBinding.js";
|
|
40
43
|
export { notionSortDirectionSchema } from "./dataSources/sortDirection.js";
|
|
44
|
+
export * from "./files.js";
|
|
41
45
|
export { connectMessageSchema } from "./handshake/connect.js";
|
|
42
46
|
export { CustomBlockInitializationError, customBlockInitErrorCodeSchema, customBlockInitErrorInfoSchema, initMessageSchema, } from "./handshake/init.js";
|
|
43
47
|
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./handshake/initResult.js";
|
|
44
48
|
export { isInitHandshakeMessage } from "./handshake/isInitHandshakeMessage.js";
|
|
45
|
-
export
|
|
46
|
-
export {
|
|
49
|
+
export * from "./icons.js";
|
|
50
|
+
export { customBlockGrantSchema } from "./manifest/grants.js";
|
|
51
|
+
export { bridgeManifestDataSourceSchema, bridgeManifestIconSchema, bridgeManifestPropertySchema, manifestPageSchema, manifestSchema, } from "./manifest/manifest.js";
|
|
47
52
|
export { hostToSandboxMessageSchema, hostToSandboxMessageWithProtocol3To5CompatibilitySchema, } from "./messages/hostToSandbox.js";
|
|
48
53
|
export { readIncomingType } from "./messages/incomingType.js";
|
|
49
54
|
export { invalidHostMessageSchema } from "./messages/invalidHostMessage.js";
|
|
@@ -52,11 +57,11 @@ export { sandboxToHostMessageSchema } from "./messages/sandboxToHost.js";
|
|
|
52
57
|
export { customBlockOpenExternalUrlErrorCodeSchema, customBlockOpenExternalUrlErrorInfoSchema, openExternalUrlMessageSchema, openExternalUrlResultMessageSchema, } from "./navigation/openExternalUrl.js";
|
|
53
58
|
export { bridgePageSchema } from "./pages/bridgePage.js";
|
|
54
59
|
export { makeBridgePage } from "./pages/makeBridgePage.js";
|
|
55
|
-
export { createPageMessageSchema, createPageParentSchema, createPageResultMessageSchema, createPageResultMessageWithProtocol3To5CompatibilitySchema, customBlockCreatePageErrorCodeSchema, customBlockCreatePageErrorInfoSchema, notionCreatePagePositionSchema, } from "./pages/messages/createPage.js";
|
|
60
|
+
export { createPageArgsSchema, createPageMessageSchema, createPageParentSchema, createPageResultMessageSchema, createPageResultMessageWithProtocol3To5CompatibilitySchema, customBlockCreatePageErrorCodeSchema, customBlockCreatePageErrorInfoSchema, notionCreatePagePositionSchema, } from "./pages/messages/createPage.js";
|
|
56
61
|
export { customBlockGetPageErrorCodeSchema, customBlockGetPageErrorInfoSchema, getPageMessageSchema, getPageResultMessageSchema, getPageResultMessageWithProtocol3To5CompatibilitySchema, } from "./pages/messages/getPage.js";
|
|
57
62
|
export { customBlockOpenPageErrorCodeSchema, customBlockOpenPageErrorInfoSchema, openPageMessageSchema, openPageModeSchema, openPageResultMessageSchema, } from "./pages/messages/openPage.js";
|
|
58
63
|
export { customBlockUpdatePageErrorCodeSchema, customBlockUpdatePageErrorInfoSchema, updatePageMessageSchema, updatePageResultMessageSchema, updatePageResultMessageWithProtocol3To5CompatibilitySchema, } from "./pages/messages/updatePage.js";
|
|
59
|
-
export {
|
|
64
|
+
export { bridgePageCoverSchema, bridgePageIconSchema, } from "./pages/pageAppearance.js";
|
|
60
65
|
export { bridgePagePropertyReadMapSchema, bridgePagePropertyWriteMapSchema, } from "./pages/properties/bridgePagePropertyMaps.js";
|
|
61
66
|
export { bridgePagePropertyValueSchema } from "./pages/properties/bridgePagePropertyValue.js";
|
|
62
67
|
export { bridgeUserSchema } from "./users/bridgeUser.js";
|
|
@@ -66,8 +71,9 @@ export { currentUserChangedMessageSchema } from "./users/messages/currentUserCha
|
|
|
66
71
|
export { customBlockGetUserErrorCodeSchema, customBlockGetUserErrorInfoSchema, getUserMessageSchema, getUserResultMessageSchema, } from "./users/messages/getUser.js";
|
|
67
72
|
export { customBlockListUsersErrorCodeSchema, customBlockListUsersErrorInfoSchema, listUsersMessageSchema, listUsersResultMessageSchema, } from "./users/messages/listUsers.js";
|
|
68
73
|
export { notionUserIdSchema } from "./users/userId.js";
|
|
69
|
-
export {
|
|
70
|
-
export { notionAgentIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, notionSpaceIdSchema, } from "./utils/ids.js";
|
|
74
|
+
export { customBlockErrorInfoSchema, NOT_GRANTED_ERROR_CODE, } from "./utils/errors.js";
|
|
75
|
+
export { notionAgentIdSchema, notionAppInstallationIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, notionSpaceIdSchema, } from "./utils/ids.js";
|
|
71
76
|
export { isLocalBlockServerUrl } from "./utils/isLocalBlockServerUrl.js";
|
|
72
|
-
export { LATEST_BRIDGE_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
77
|
+
export { DATA_SOURCE_NAMING_PROTOCOL_VERSION, LATEST_BRIDGE_PROTOCOL_VERSION, NATIVE_ICON_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
78
|
+
export { readRequestId } from "./utils/readRequestId.js";
|
|
73
79
|
export { notionRecordPointerSchema } from "./utils/recordPointer.js";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* One entry in the block manifest's `grants`: what the block needs to do
|
|
4
|
+
* (`action`) and what it acts on (`resource`). Viewers approve declared
|
|
5
|
+
* entries before the block loads.
|
|
6
|
+
*
|
|
7
|
+
* `resource` is one resource or a non-empty array of them. An array applies
|
|
8
|
+
* the action to each element. A resource string is never split, so
|
|
9
|
+
* `"data_source:tasks,projects"` names one key.
|
|
10
|
+
*
|
|
11
|
+
* Names are open strings so a newer vocabulary never makes an older host or SDK
|
|
12
|
+
* reject a manifest. Notion stores each array element as its own entry at
|
|
13
|
+
* deploy, so the manifest a deployed block receives in `init` has string
|
|
14
|
+
* resources only.
|
|
15
|
+
*/
|
|
16
|
+
export declare const customBlockGrantSchema: v.ObjectSchema<{
|
|
17
|
+
readonly action: v.StringSchema<undefined>;
|
|
18
|
+
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
19
|
+
}, undefined>;
|
|
20
|
+
export type CustomBlockGrant = v.InferOutput<typeof customBlockGrantSchema>;
|
|
21
|
+
/**
|
|
22
|
+
* Grant actions that hosts recognize. `user` is shorthand for `user.read`
|
|
23
|
+
* and `user.read_email` on the same resource. `page` is shorthand for
|
|
24
|
+
* `page.read`, `page.insert`, `page.update`, and `page.archive` on the same
|
|
25
|
+
* resource. `page.trash` is reserved for a future Trash call and is not
|
|
26
|
+
* accepted yet.
|
|
27
|
+
*/
|
|
28
|
+
export type CustomBlockGrantAction = "user" | "user.read" | "user.read_email" | "page" | "page.read" | "page.insert" | "page.update" | "page.archive" | "network.fetch";
|
|
29
|
+
/**
|
|
30
|
+
* Resource names that hosts recognize. User actions take `current_user`
|
|
31
|
+
* or `workspace` (every member of the workspace). Page actions take
|
|
32
|
+
* `workspace` (every page the viewer can access), `containing_page`,
|
|
33
|
+
* `data_source:<key>`, or `data_source` (every declared data source).
|
|
34
|
+
* `private` is reserved for a future `page.insert` into the viewer's Private
|
|
35
|
+
* section and is not accepted yet. `network.fetch` takes a bare HTTPS origin.
|
|
36
|
+
*/
|
|
37
|
+
export type CustomBlockGrantResourceName = "current_user" | "workspace" | "containing_page" | "data_source" | CustomBlockDataSourceResourceName | CustomBlockOriginResourceName;
|
|
38
|
+
/**
|
|
39
|
+
* The data source bound to one key of the manifest's `dataSources`, such as
|
|
40
|
+
* `data_source:tasks`. The key must match a declared data source exactly.
|
|
41
|
+
*/
|
|
42
|
+
export type CustomBlockDataSourceResourceName = `data_source:${string}`;
|
|
43
|
+
/**
|
|
44
|
+
* An HTTPS origin the block loads content from and connects to, such as
|
|
45
|
+
* `https://api.example.com`. `https://*.example.com` covers subdomains. Hosts
|
|
46
|
+
* allow only origins that are also on the workspace's network allowlist.
|
|
47
|
+
*/
|
|
48
|
+
export type CustomBlockOriginResourceName = `https://${string}`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* One entry in the block manifest's `grants`: what the block needs to do
|
|
4
|
+
* (`action`) and what it acts on (`resource`). Viewers approve declared
|
|
5
|
+
* entries before the block loads.
|
|
6
|
+
*
|
|
7
|
+
* `resource` is one resource or a non-empty array of them. An array applies
|
|
8
|
+
* the action to each element. A resource string is never split, so
|
|
9
|
+
* `"data_source:tasks,projects"` names one key.
|
|
10
|
+
*
|
|
11
|
+
* Names are open strings so a newer vocabulary never makes an older host or SDK
|
|
12
|
+
* reject a manifest. Notion stores each array element as its own entry at
|
|
13
|
+
* deploy, so the manifest a deployed block receives in `init` has string
|
|
14
|
+
* resources only.
|
|
15
|
+
*/
|
|
16
|
+
export const customBlockGrantSchema = v.object({
|
|
17
|
+
action: v.string(),
|
|
18
|
+
resource: v.union([v.string(), v.pipe(v.array(v.string()), v.minLength(1))]),
|
|
19
|
+
});
|
|
@@ -4,21 +4,33 @@ import * as v from "valibot";
|
|
|
4
4
|
* `emoji` / `external` icon variants the public Notion API uses, so the host
|
|
5
5
|
* can render a recognizable affordance next to the slot in setup UI.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const bridgeManifestIconSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
8
8
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
9
9
|
readonly emoji: v.StringSchema<undefined>;
|
|
10
10
|
}, undefined>, v.ObjectSchema<{
|
|
11
11
|
readonly type: v.LiteralSchema<"external", undefined>;
|
|
12
12
|
readonly url: v.StringSchema<undefined>;
|
|
13
13
|
}, undefined>], undefined>;
|
|
14
|
-
export type
|
|
15
|
-
export declare const
|
|
14
|
+
export type BridgeManifestIcon = v.InferOutput<typeof bridgeManifestIconSchema>;
|
|
15
|
+
export declare const bridgeManifestPropertySchema: v.ObjectSchema<{
|
|
16
16
|
readonly name: v.StringSchema<undefined>;
|
|
17
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", "
|
|
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", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
19
19
|
}, undefined>;
|
|
20
|
-
export type
|
|
21
|
-
export declare const
|
|
20
|
+
export type BridgeManifestProperty = v.InferOutput<typeof bridgeManifestPropertySchema>;
|
|
21
|
+
export declare const manifestPageSchema: 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
|
+
}, undefined>;
|
|
32
|
+
export type ManifestPage = v.InferOutput<typeof manifestPageSchema>;
|
|
33
|
+
export declare const bridgeManifestDataSourceSchema: v.ObjectSchema<{
|
|
22
34
|
readonly name: v.StringSchema<undefined>;
|
|
23
35
|
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
24
36
|
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -31,10 +43,10 @@ export declare const manifestDataSourceSchema: v.ObjectSchema<{
|
|
|
31
43
|
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
32
44
|
readonly name: v.StringSchema<undefined>;
|
|
33
45
|
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", "
|
|
46
|
+
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", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
35
47
|
}, undefined>, undefined>, {}>;
|
|
36
48
|
}, undefined>;
|
|
37
|
-
export type
|
|
49
|
+
export type BridgeManifestDataSource = v.InferOutput<typeof bridgeManifestDataSourceSchema>;
|
|
38
50
|
export declare const manifestSchema: v.ObjectSchema<{
|
|
39
51
|
readonly version: v.LiteralSchema<1, undefined>;
|
|
40
52
|
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -57,21 +69,32 @@ export declare const manifestSchema: v.ObjectSchema<{
|
|
|
57
69
|
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
58
70
|
readonly name: v.StringSchema<undefined>;
|
|
59
71
|
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", "
|
|
72
|
+
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", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
61
73
|
}, undefined>, undefined>, {}>;
|
|
62
74
|
}, undefined>, undefined>, {}>;
|
|
75
|
+
readonly pages: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
76
|
+
readonly name: v.StringSchema<undefined>;
|
|
77
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
78
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
79
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
80
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
81
|
+
}, undefined>, v.ObjectSchema<{
|
|
82
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
83
|
+
readonly url: v.StringSchema<undefined>;
|
|
84
|
+
}, undefined>], undefined>, undefined>;
|
|
85
|
+
}, undefined>, undefined>, undefined>;
|
|
63
86
|
/**
|
|
64
|
-
*
|
|
65
|
-
* approval, so hosts do not ask the viewer. An empty array declares
|
|
66
|
-
*
|
|
87
|
+
* Grants the block needs. Omitted means the block predates viewer
|
|
88
|
+
* approval, so hosts do not ask the viewer. An empty array declares
|
|
89
|
+
* nothing.
|
|
67
90
|
*/
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
readonly resource: v.StringSchema<undefined>;
|
|
91
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
92
|
+
readonly action: v.StringSchema<undefined>;
|
|
93
|
+
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
71
94
|
}, undefined>, undefined>, undefined>;
|
|
72
95
|
}, undefined>;
|
|
73
96
|
/**
|
|
74
97
|
* Manifest describing a custom block, its required data sources, and its
|
|
75
|
-
*
|
|
98
|
+
* grants.
|
|
76
99
|
*/
|
|
77
100
|
export type BridgeCustomBlockManifest = v.InferOutput<typeof manifestSchema>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionPropertyTypeSchema } from "../dataSources/properties/propertySchema.js";
|
|
3
|
-
import {
|
|
3
|
+
import { customBlockGrantSchema } from "./grants.js";
|
|
4
4
|
/**
|
|
5
5
|
* Decorative icon attached to a manifest data source. Mirrors the
|
|
6
6
|
* `emoji` / `external` icon variants the public Notion API uses, so the host
|
|
7
7
|
* can render a recognizable affordance next to the slot in setup UI.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const bridgeManifestIconSchema = v.variant("type", [
|
|
10
10
|
v.object({
|
|
11
11
|
type: v.literal("emoji"),
|
|
12
12
|
emoji: v.string(),
|
|
@@ -16,16 +16,21 @@ export const manifestIconSchema = v.variant("type", [
|
|
|
16
16
|
url: v.string(),
|
|
17
17
|
}),
|
|
18
18
|
]);
|
|
19
|
-
export const
|
|
19
|
+
export const bridgeManifestPropertySchema = v.object({
|
|
20
20
|
name: v.string(),
|
|
21
21
|
description: v.optional(v.string()),
|
|
22
22
|
type: notionPropertyTypeSchema,
|
|
23
23
|
});
|
|
24
|
-
export const
|
|
24
|
+
export const manifestPageSchema = v.object({
|
|
25
25
|
name: v.string(),
|
|
26
26
|
description: v.optional(v.string()),
|
|
27
|
-
icon: v.optional(
|
|
28
|
-
|
|
27
|
+
icon: v.optional(bridgeManifestIconSchema),
|
|
28
|
+
});
|
|
29
|
+
export const bridgeManifestDataSourceSchema = v.object({
|
|
30
|
+
name: v.string(),
|
|
31
|
+
description: v.optional(v.string()),
|
|
32
|
+
icon: v.optional(bridgeManifestIconSchema),
|
|
33
|
+
properties: v.optional(v.record(v.string(), bridgeManifestPropertySchema), {}),
|
|
29
34
|
});
|
|
30
35
|
export const manifestSchema = v.object({
|
|
31
36
|
version: v.literal(1),
|
|
@@ -33,11 +38,12 @@ export const manifestSchema = v.object({
|
|
|
33
38
|
description: v.optional(v.string()),
|
|
34
39
|
slashCommand: v.optional(v.string()),
|
|
35
40
|
icon: v.optional(v.object({ type: v.literal("emoji"), emoji: v.string() })),
|
|
36
|
-
dataSources: v.optional(v.record(v.string(),
|
|
41
|
+
dataSources: v.optional(v.record(v.string(), bridgeManifestDataSourceSchema), {}),
|
|
42
|
+
pages: v.optional(v.record(v.string(), manifestPageSchema)),
|
|
37
43
|
/**
|
|
38
|
-
*
|
|
39
|
-
* approval, so hosts do not ask the viewer. An empty array declares
|
|
40
|
-
*
|
|
44
|
+
* Grants the block needs. Omitted means the block predates viewer
|
|
45
|
+
* approval, so hosts do not ask the viewer. An empty array declares
|
|
46
|
+
* nothing.
|
|
41
47
|
*/
|
|
42
|
-
|
|
48
|
+
grants: v.optional(v.array(customBlockGrantSchema)),
|
|
43
49
|
});
|