@notionhq/custom-blocks-host 0.4.1 → 0.4.3
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/dist/browser.js +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.js +4 -4
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts +232 -8
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -1
- package/dist/compatibility/{pageResult.d.ts → pages/pageResult.d.ts} +1 -1
- package/dist/compatibility/pages/pageResult.d.ts.map +1 -0
- package/dist/compatibility/{pageWithNullTextFallbackProperties.d.ts → pages/toPageWithNullTextFallbackProperties.d.ts} +3 -3
- package/dist/compatibility/pages/toPageWithNullTextFallbackProperties.d.ts.map +1 -0
- package/dist/compatibility/{pageWithNullTextFallbackProperties.js → pages/toPageWithNullTextFallbackProperties.js} +1 -1
- package/dist/compatibility/{addMetadataReadSchemasForProtocol3To4.d.ts → protocol3To4/addMetadataReadSchemasForProtocol3To4.d.ts} +96 -90
- package/dist/compatibility/{addMetadataReadSchemasForProtocol3To4.d.ts.map → protocol3To4/addMetadataReadSchemasForProtocol3To4.d.ts.map} +1 -1
- package/dist/compatibility/{addMetadataReadSchemasForProtocol3To4.js → protocol3To4/addMetadataReadSchemasForProtocol3To4.js} +1 -1
- package/dist/compatibility/{normalizePageResultsForProtocol3To5.d.ts → protocol3To5/normalizePageResultsForProtocol3To5.d.ts} +2 -2
- package/dist/compatibility/protocol3To5/normalizePageResultsForProtocol3To5.d.ts.map +1 -0
- package/dist/compatibility/{normalizePageResultsForProtocol3To5.js → protocol3To5/normalizePageResultsForProtocol3To5.js} +3 -2
- package/dist/compatibility/protocol3To5/toDateTimeValueForProtocol3To5.d.ts +9 -0
- package/dist/compatibility/protocol3To5/toDateTimeValueForProtocol3To5.d.ts.map +1 -0
- package/dist/compatibility/protocol3To5/toDateTimeValueForProtocol3To5.js +21 -0
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.d.ts +12 -0
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.d.ts.map +1 -0
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.js +20 -0
- package/dist/compatibility/protocol3To5/toPropertyValueForProtocol3To5.d.ts +10 -0
- package/dist/compatibility/protocol3To5/toPropertyValueForProtocol3To5.d.ts.map +1 -0
- package/dist/compatibility/{pageForProtocol3To5.js → protocol3To5/toPropertyValueForProtocol3To5.js} +25 -95
- package/dist/compatibility/{pageForProtocol3To5.d.ts → protocol3To5/toQueryPageForProtocol3To5.d.ts} +11 -21
- package/dist/compatibility/protocol3To5/toQueryPageForProtocol3To5.d.ts.map +1 -0
- package/dist/compatibility/protocol3To5/toQueryPageForProtocol3To5.js +32 -0
- package/dist/compatibility/{normalizePageResultsForProtocol6.d.ts → protocol6/normalizePageResultsForProtocol6.d.ts} +2 -2
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.d.ts.map +1 -0
- package/dist/compatibility/{normalizePageResultsForProtocol6.js → protocol6/normalizePageResultsForProtocol6.js} +1 -1
- package/dist/context/initialState.d.ts +1809 -0
- package/dist/context/initialState.d.ts.map +1 -0
- package/dist/context/initialState.js +34 -0
- package/dist/context/resize.d.ts +4 -0
- package/dist/context/resize.d.ts.map +1 -0
- package/dist/createCustomBlockHost.d.ts +13 -9
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +37 -24
- package/dist/{autoBindProperties.d.ts → dataSources/bindings/getAutoBoundPropertyIdsByKey.d.ts} +2 -2
- package/dist/dataSources/bindings/getAutoBoundPropertyIdsByKey.d.ts.map +1 -0
- package/dist/{dateValue.d.ts → dataSources/properties/toNotionDateValue.d.ts} +3 -3
- package/dist/dataSources/properties/toNotionDateValue.d.ts.map +1 -0
- package/dist/{queries → dataSources/queries}/querySubscriptions.d.ts +2 -2
- package/dist/dataSources/queries/querySubscriptions.d.ts.map +1 -0
- package/dist/dataSources/types.d.ts +14 -0
- package/dist/dataSources/types.d.ts.map +1 -0
- package/dist/dataSources/validation/validateQueryDataSourceFilter.d.ts +5 -0
- package/dist/dataSources/validation/validateQueryDataSourceFilter.d.ts.map +1 -0
- package/dist/{queries → dataSources/validation}/validateQueryDataSourceFilter.js +2 -2
- package/dist/dataSources/validation/validateQueryDataSourceSorts.d.ts +8 -0
- package/dist/dataSources/validation/validateQueryDataSourceSorts.d.ts.map +1 -0
- package/dist/{queries → dataSources/validation}/validateQueryDataSourceSorts.js +2 -2
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/lifecycle/{initializationController.d.ts → createInitializationController.d.ts} +7 -6
- package/dist/lifecycle/createInitializationController.d.ts.map +1 -0
- package/dist/lifecycle/{initializationController.js → createInitializationController.js} +9 -4
- package/dist/lifecycle/errors/contextUnavailableError.d.ts +3 -0
- package/dist/lifecycle/errors/contextUnavailableError.d.ts.map +1 -0
- package/dist/lifecycle/errors/contextUnavailableError.js +8 -0
- package/dist/lifecycle/errors/initialStateTimeoutError.d.ts +3 -0
- package/dist/lifecycle/errors/initialStateTimeoutError.d.ts.map +1 -0
- package/dist/lifecycle/errors/initialStateTimeoutError.js +8 -0
- package/dist/lifecycle/errors/invalidConnectPayloadError.d.ts +3 -0
- package/dist/lifecycle/errors/invalidConnectPayloadError.d.ts.map +1 -0
- package/dist/lifecycle/errors/invalidConnectPayloadError.js +8 -0
- package/dist/lifecycle/errors/invalidInitResultPayloadError.d.ts +3 -0
- package/dist/lifecycle/errors/invalidInitResultPayloadError.d.ts.map +1 -0
- package/dist/lifecycle/errors/invalidInitResultPayloadError.js +8 -0
- package/dist/lifecycle/errors/invalidLocalPreviewUrlError.d.ts +3 -0
- package/dist/lifecycle/errors/invalidLocalPreviewUrlError.d.ts.map +1 -0
- package/dist/lifecycle/errors/invalidLocalPreviewUrlError.js +7 -0
- package/dist/lifecycle/errors/invalidPropertyBindingError.d.ts +3 -0
- package/dist/lifecycle/errors/invalidPropertyBindingError.d.ts.map +1 -0
- package/dist/lifecycle/errors/invalidPropertyBindingError.js +9 -0
- package/dist/lifecycle/errors/invalidProtocolVersionError.d.ts +5 -0
- package/dist/lifecycle/errors/invalidProtocolVersionError.d.ts.map +1 -0
- package/dist/lifecycle/errors/invalidProtocolVersionError.js +9 -0
- package/dist/lifecycle/errors/missingDataSourceBindingError.d.ts +3 -0
- package/dist/lifecycle/errors/missingDataSourceBindingError.d.ts.map +1 -0
- package/dist/lifecycle/errors/missingDataSourceBindingError.js +8 -0
- package/dist/lifecycle/errors/missingPropertyBindingError.d.ts +3 -0
- package/dist/lifecycle/errors/missingPropertyBindingError.d.ts.map +1 -0
- package/dist/lifecycle/errors/missingPropertyBindingError.js +8 -0
- package/dist/lifecycle/errors/noConnectError.d.ts +8 -0
- package/dist/lifecycle/errors/noConnectError.d.ts.map +1 -0
- package/dist/lifecycle/errors/noConnectError.js +13 -0
- package/dist/lifecycle/errors/noInitResultError.d.ts +3 -0
- package/dist/lifecycle/errors/noInitResultError.d.ts.map +1 -0
- package/dist/lifecycle/errors/noInitResultError.js +8 -0
- package/dist/lifecycle/errors/unknownInitializationError.d.ts +3 -0
- package/dist/lifecycle/errors/unknownInitializationError.d.ts.map +1 -0
- package/dist/lifecycle/errors/unknownInitializationError.js +8 -0
- package/dist/lifecycle/errors/unsupportedProtocolVersionError.d.ts +6 -0
- package/dist/lifecycle/errors/unsupportedProtocolVersionError.d.ts.map +1 -0
- package/dist/lifecycle/errors/unsupportedProtocolVersionError.js +9 -0
- package/dist/lifecycle/isAllowedLocalPreviewUrl.d.ts.map +1 -0
- package/dist/{isAllowedLocalPreviewUrl.js → lifecycle/isAllowedLocalPreviewUrl.js} +1 -1
- package/dist/lifecycle/{protocolVersion.d.ts → isValidBridgeProtocolVersion.d.ts} +1 -1
- package/dist/lifecycle/isValidBridgeProtocolVersion.d.ts.map +1 -0
- package/dist/lifecycle/types.d.ts +16 -1849
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/lifecycle/types.js +1 -41
- package/dist/{lifecycle → manifest}/resolveManifest.d.ts +2 -2
- package/dist/manifest/resolveManifest.d.ts.map +1 -0
- package/dist/manifest/types.d.ts +59 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +10 -0
- package/dist/messages/{sandboxMessageRouter.d.ts → createSandboxMessageRouter.d.ts} +15 -15
- package/dist/messages/createSandboxMessageRouter.d.ts.map +1 -0
- package/dist/messages/{sandboxMessageRouter.js → createSandboxMessageRouter.js} +5 -4
- package/dist/messages/{invalidSandboxMessage.d.ts → getInvalidSandboxMessageResponse.d.ts} +1 -1
- package/dist/messages/getInvalidSandboxMessageResponse.d.ts.map +1 -0
- package/dist/messages/handlers.d.ts +26 -0
- package/dist/messages/handlers.d.ts.map +1 -0
- package/dist/messages/handlers.js +1 -0
- package/dist/messages/logging.d.ts +2 -0
- package/dist/messages/logging.d.ts.map +1 -0
- package/dist/messages/logging.js +1 -0
- package/dist/navigation/parseExternalUrl.d.ts.map +1 -0
- package/dist/navigation/types.d.ts +9 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -0
- package/dist/pages/types.d.ts +20 -0
- package/dist/pages/types.d.ts.map +1 -0
- package/dist/pages/types.js +1 -0
- package/dist/protocol/{messages/updatePage.d.ts → compatibility/protocol3To5/bridgePage.d.ts} +32 -22
- package/dist/protocol/compatibility/protocol3To5/bridgePage.js +21 -0
- package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourcePage.js +1 -1
- package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourceValue.js +2 -2
- package/dist/protocol/context/containingPage.d.ts +31 -0
- package/dist/protocol/context/containingPage.js +18 -0
- package/dist/protocol/{messages → context/messages}/pageChanged.js +1 -1
- package/dist/protocol/{parent.d.ts → context/parent.d.ts} +11 -1
- package/dist/protocol/context/parent.js +31 -0
- package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +164 -0
- package/dist/protocol/dataSources/bridgeDataSourceBinding.js +25 -0
- package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +148 -0
- package/dist/protocol/dataSources/bridgeDataSourceBindings.js +3 -0
- package/dist/protocol/dataSources/collectionPointer.d.ts +7 -0
- package/dist/protocol/dataSources/collectionPointer.js +7 -0
- package/dist/protocol/dataSources/collectionSchema.d.ts +144 -0
- package/dist/protocol/dataSources/collectionSchema.js +12 -0
- package/dist/protocol/dataSources/errors.d.ts +2 -2
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.d.ts +505 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.js +8 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.d.ts +253 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.js +69 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceSort.d.ts +11 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceSort.js +8 -0
- package/dist/protocol/dataSources/filters/checkboxFilterOperator.d.ts +7 -0
- package/dist/protocol/dataSources/filters/checkboxFilterOperator.js +5 -0
- package/dist/protocol/dataSources/filters/containsFilterOperator.d.ts +13 -0
- package/dist/protocol/dataSources/filters/containsFilterOperator.js +9 -0
- package/dist/protocol/dataSources/filters/createdByFilterOperator.d.ts +17 -0
- package/dist/protocol/dataSources/filters/createdByFilterOperator.js +11 -0
- package/dist/protocol/dataSources/filters/dateFilterOperator.d.ts +47 -0
- package/dist/protocol/dataSources/filters/dateFilterOperator.js +73 -0
- package/dist/protocol/dataSources/filters/emptyOperator.d.ts +6 -0
- package/dist/protocol/dataSources/filters/emptyOperator.js +5 -0
- package/dist/protocol/dataSources/filters/numberFilterOperator.d.ts +19 -0
- package/dist/protocol/dataSources/filters/numberFilterOperator.js +11 -0
- package/dist/protocol/dataSources/filters/optionFilterOperator.d.ts +11 -0
- package/dist/protocol/dataSources/filters/optionFilterOperator.js +8 -0
- package/dist/protocol/dataSources/filters/peopleFilterOperator.d.ts +23 -0
- package/dist/protocol/dataSources/filters/peopleFilterOperator.js +11 -0
- package/dist/protocol/dataSources/filters/relationFilterOperator.d.ts +11 -0
- package/dist/protocol/dataSources/filters/relationFilterOperator.js +12 -0
- package/dist/protocol/dataSources/filters/statusFilterOperator.d.ts +15 -0
- package/dist/protocol/dataSources/filters/statusFilterOperator.js +7 -0
- package/dist/protocol/dataSources/filters/statusGroupFilterOperator.d.ts +9 -0
- package/dist/protocol/dataSources/filters/statusGroupFilterOperator.js +18 -0
- package/dist/protocol/dataSources/filters/stringOrStringArray.d.ts +2 -0
- package/dist/protocol/dataSources/filters/stringOrStringArray.js +5 -0
- package/dist/protocol/dataSources/filters/textFilterOperator.d.ts +19 -0
- package/dist/protocol/dataSources/filters/textFilterOperator.js +11 -0
- package/dist/protocol/dataSources/makeBridgeDataSourceBinding.d.ts +6 -0
- package/dist/protocol/dataSources/makeBridgeDataSourceBinding.js +6 -0
- package/dist/protocol/{messages → dataSources/messages}/dataSourcesChanged.d.ts +1 -0
- package/dist/protocol/{messages → dataSources/messages}/dataSourcesChanged.js +2 -2
- package/dist/protocol/{messages/queryDataSourceResult.d.ts → dataSources/messages/queryDataSource.d.ts} +525 -2
- package/dist/protocol/{messages/queryDataSourceResult.js → dataSources/messages/queryDataSource.js} +24 -7
- package/dist/protocol/dataSources/notionDataSource.d.ts +309 -0
- package/dist/protocol/dataSources/notionDataSource.js +38 -0
- package/dist/protocol/dataSources/resolveDataSourceBinding.d.ts +32 -0
- package/dist/protocol/dataSources/resolveDataSourceBinding.js +33 -0
- package/dist/protocol/{messages → handshake}/connect.d.ts +4 -0
- package/dist/protocol/{messages → handshake}/connect.js +2 -2
- package/dist/protocol/{messages → handshake}/init.d.ts +6 -1
- package/dist/protocol/{messages → handshake}/init.js +10 -10
- package/dist/protocol/{messages → handshake}/initResult.d.ts +1 -1
- package/dist/protocol/{messages → handshake}/isInitHandshakeMessage.d.ts +2 -2
- package/dist/protocol/index.d.ts +150 -54
- package/dist/protocol/index.js +73 -54
- package/dist/protocol/manifest/capabilities.d.ts +37 -0
- package/dist/protocol/manifest/capabilities.js +13 -0
- package/dist/protocol/{manifest.d.ts → manifest/manifest.d.ts} +12 -2
- package/dist/protocol/{manifest.js → manifest/manifest.js} +8 -1
- package/dist/protocol/messages/hostToSandbox.d.ts +12 -0
- package/dist/protocol/messages/hostToSandbox.js +15 -15
- package/dist/protocol/messages/messagePayload.d.ts +1 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +232 -8
- package/dist/protocol/messages/sandboxToHost.js +12 -12
- package/dist/protocol/{messages → navigation}/openExternalUrl.d.ts +1 -1
- package/dist/protocol/{messages/createPage.d.ts → pages/bridgePage.d.ts} +67 -65
- package/dist/protocol/pages/bridgePage.js +25 -0
- package/dist/protocol/pages/makeBridgePage.d.ts +4 -0
- package/dist/protocol/pages/makeBridgePage.js +12 -0
- package/dist/protocol/{messages/createPageResult.d.ts → pages/messages/createPage.d.ts} +500 -2
- package/dist/protocol/pages/messages/createPage.js +104 -0
- package/dist/protocol/{messages → pages/messages}/getPage.d.ts +2 -2
- package/dist/protocol/{messages → pages/messages}/getPage.js +5 -4
- package/dist/protocol/{messages → pages/messages}/openPage.d.ts +2 -2
- package/dist/protocol/{messages → pages/messages}/openPage.js +1 -1
- package/dist/protocol/{messages/updatePageResult.d.ts → pages/messages/updatePage.d.ts} +272 -2
- package/dist/protocol/pages/messages/updatePage.js +65 -0
- package/dist/protocol/pages/pageAppearance.d.ts +62 -0
- package/dist/protocol/pages/pageAppearance.js +34 -0
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +433 -0
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.js +4 -0
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +217 -0
- package/dist/protocol/pages/properties/bridgePagePropertyValue.js +144 -0
- package/dist/protocol/pages/properties/dateInput.d.ts +45 -0
- package/dist/protocol/pages/properties/dateInput.js +23 -0
- package/dist/protocol/pages/properties/fileInput.d.ts +16 -0
- package/dist/protocol/pages/properties/fileInput.js +16 -0
- package/dist/protocol/pages/properties/metadataActor.d.ts +6 -0
- package/dist/protocol/pages/properties/metadataActor.js +7 -0
- package/dist/protocol/pages/properties/placeInput.d.ts +10 -0
- package/dist/protocol/pages/properties/placeInput.js +10 -0
- package/dist/protocol/pages/properties/relationInput.d.ts +5 -0
- package/dist/protocol/pages/properties/relationInput.js +2 -0
- package/dist/protocol/pages/properties/richText.d.ts +3 -0
- package/dist/protocol/pages/properties/richText.js +2 -0
- package/dist/protocol/pages/properties/selectOption.d.ts +13 -0
- package/dist/protocol/pages/properties/selectOption.js +16 -0
- package/dist/protocol/pages/properties/userInput.d.ts +10 -0
- package/dist/protocol/pages/properties/userInput.js +13 -0
- package/dist/protocol/users/bridgeUser.d.ts +12 -0
- package/dist/protocol/users/bridgeUser.js +12 -0
- package/dist/protocol/users/{user.d.ts → bridgeUserList.d.ts} +2 -15
- package/dist/protocol/users/bridgeUserList.js +10 -0
- package/dist/protocol/users/makeBridgeUser.d.ts +4 -0
- package/dist/protocol/users/makeBridgeUser.js +11 -0
- package/dist/protocol/{messages → users/messages}/currentUserChanged.js +2 -2
- package/dist/protocol/{messages → users/messages}/getUser.d.ts +2 -2
- package/dist/protocol/{messages → users/messages}/getUser.js +3 -2
- package/dist/protocol/{messages → users/messages}/listUsers.d.ts +2 -2
- package/dist/protocol/{messages → users/messages}/listUsers.js +2 -2
- package/dist/protocol/users/userId.d.ts +3 -0
- package/dist/protocol/users/userId.js +2 -0
- package/dist/protocol/{errors.d.ts → utils/errors.d.ts} +6 -0
- package/dist/protocol/utils/errors.js +11 -0
- package/dist/protocol/utils/nullableStringSchema.d.ts +2 -0
- package/dist/protocol/utils/nullableStringSchema.js +2 -0
- package/dist/users/types.d.ts +9 -0
- package/dist/users/types.d.ts.map +1 -0
- package/dist/users/types.js +1 -0
- package/dist/utils/maybePromise.d.ts +2 -0
- package/dist/utils/maybePromise.d.ts.map +1 -0
- package/dist/utils/maybePromise.js +1 -0
- package/dist/utils/protocolVersion.d.ts.map +1 -0
- package/dist/utils/toNotionPageId.d.ts +3 -0
- package/dist/utils/toNotionPageId.d.ts.map +1 -0
- package/dist/{ids.js → utils/toNotionPageId.js} +1 -1
- package/dist/{utils.d.ts → utils/unreachable.d.ts} +1 -1
- package/dist/utils/unreachable.d.ts.map +1 -0
- package/docs/bridge/protocol.md +20 -5
- package/docs/bridge/versioning.md +2 -2
- package/docs/handlers.md +3 -3
- package/package.json +1 -1
- package/src/compatibility/normalizeHostToSandboxMessage.ts +4 -4
- package/src/compatibility/{pageWithNullTextFallbackProperties.ts → pages/toPageWithNullTextFallbackProperties.ts} +4 -4
- package/src/compatibility/{addMetadataReadSchemasForProtocol3To4.ts → protocol3To4/addMetadataReadSchemasForProtocol3To4.ts} +1 -1
- package/src/compatibility/{normalizePageResultsForProtocol3To5.ts → protocol3To5/normalizePageResultsForProtocol3To5.ts} +4 -6
- package/src/compatibility/protocol3To5/toDateTimeValueForProtocol3To5.ts +25 -0
- package/src/compatibility/protocol3To5/toPageForProtocol3To5.ts +29 -0
- package/src/compatibility/protocol3To5/toPropertyValueForProtocol3To5.ts +102 -0
- package/src/compatibility/protocol3To5/toQueryPageForProtocol3To5.ts +35 -0
- package/src/compatibility/{normalizePageResultsForProtocol6.ts → protocol6/normalizePageResultsForProtocol6.ts} +2 -2
- package/src/context/initialState.ts +65 -0
- package/src/context/resize.ts +4 -0
- package/src/createCustomBlockHost.ts +74 -73
- package/src/{autoBindProperties.ts → dataSources/bindings/getAutoBoundPropertyIdsByKey.ts} +1 -1
- package/src/{dateValue.ts → dataSources/properties/toNotionDateValue.ts} +2 -2
- package/src/{queries → dataSources/queries}/querySubscriptions.ts +2 -2
- package/src/dataSources/types.ts +26 -0
- package/src/{queries → dataSources/validation}/validateQueryDataSourceFilter.ts +11 -13
- package/src/{queries → dataSources/validation}/validateQueryDataSourceSorts.ts +6 -8
- package/src/index.ts +37 -27
- package/src/lifecycle/{initializationController.ts → createInitializationController.ts} +15 -20
- package/src/lifecycle/errors/contextUnavailableError.ts +10 -0
- package/src/lifecycle/errors/initialStateTimeoutError.ts +10 -0
- package/src/lifecycle/errors/invalidConnectPayloadError.ts +10 -0
- package/src/lifecycle/errors/invalidInitResultPayloadError.ts +10 -0
- package/src/lifecycle/errors/invalidLocalPreviewUrlError.ts +10 -0
- package/src/lifecycle/errors/invalidPropertyBindingError.ts +11 -0
- package/src/lifecycle/errors/invalidProtocolVersionError.ts +13 -0
- package/src/lifecycle/errors/missingDataSourceBindingError.ts +10 -0
- package/src/lifecycle/errors/missingPropertyBindingError.ts +10 -0
- package/src/lifecycle/errors/noConnectError.ts +15 -0
- package/src/lifecycle/errors/noInitResultError.ts +10 -0
- package/src/lifecycle/errors/unknownInitializationError.ts +10 -0
- package/src/lifecycle/errors/unsupportedProtocolVersionError.ts +14 -0
- package/src/{isAllowedLocalPreviewUrl.ts → lifecycle/isAllowedLocalPreviewUrl.ts} +1 -1
- package/src/lifecycle/types.ts +17 -103
- package/src/{lifecycle → manifest}/resolveManifest.ts +2 -2
- package/src/manifest/types.ts +28 -0
- package/src/messages/{sandboxMessageRouter.ts → createSandboxMessageRouter.ts} +19 -21
- package/src/messages/handlers.ts +54 -0
- package/src/messages/logging.ts +1 -0
- package/src/navigation/types.ts +20 -0
- package/src/pages/types.ts +55 -0
- package/src/users/types.ts +26 -0
- package/src/utils/maybePromise.ts +1 -0
- package/src/utils/toNotionPageId.ts +7 -0
- package/dist/autoBindProperties.d.ts.map +0 -1
- package/dist/compatibility/normalizePageResultsForProtocol3To5.d.ts.map +0 -1
- package/dist/compatibility/normalizePageResultsForProtocol6.d.ts.map +0 -1
- package/dist/compatibility/pageForProtocol3To5.d.ts.map +0 -1
- package/dist/compatibility/pageResult.d.ts.map +0 -1
- package/dist/compatibility/pageWithNullTextFallbackProperties.d.ts.map +0 -1
- package/dist/dateValue.d.ts.map +0 -1
- package/dist/ids.d.ts +0 -3
- package/dist/ids.d.ts.map +0 -1
- package/dist/isAllowedLocalPreviewUrl.d.ts.map +0 -1
- package/dist/lifecycle/initErrors.d.ts +0 -25
- package/dist/lifecycle/initErrors.d.ts.map +0 -1
- package/dist/lifecycle/initErrors.js +0 -111
- package/dist/lifecycle/initializationController.d.ts.map +0 -1
- package/dist/lifecycle/protocolVersion.d.ts.map +0 -1
- package/dist/lifecycle/resolveManifest.d.ts.map +0 -1
- package/dist/messages/invalidSandboxMessage.d.ts.map +0 -1
- package/dist/messages/parseExternalUrl.d.ts.map +0 -1
- package/dist/messages/sandboxMessageRouter.d.ts.map +0 -1
- package/dist/messages/types.d.ts +0 -65
- package/dist/messages/types.d.ts.map +0 -1
- package/dist/protocol/dataSources/dataSource.d.ts +0 -786
- package/dist/protocol/dataSources/dataSource.js +0 -66
- package/dist/protocol/errors.js +0 -6
- package/dist/protocol/messages/createPage.js +0 -51
- package/dist/protocol/messages/createPageResult.js +0 -43
- package/dist/protocol/messages/queryDataSource.d.ts +0 -1470
- package/dist/protocol/messages/queryDataSource.js +0 -254
- package/dist/protocol/messages/updatePage.js +0 -23
- package/dist/protocol/messages/updatePageResult.js +0 -41
- package/dist/protocol/pages/page.d.ts +0 -1422
- package/dist/protocol/pages/page.js +0 -318
- package/dist/protocol/parent.js +0 -13
- package/dist/protocol/users/user.js +0 -20
- package/dist/protocolVersion.d.ts.map +0 -1
- package/dist/queries/querySubscriptions.d.ts.map +0 -1
- package/dist/queries/types.d.ts +0 -5
- package/dist/queries/types.d.ts.map +0 -1
- package/dist/queries/validateQueryDataSourceFilter.d.ts +0 -5
- package/dist/queries/validateQueryDataSourceFilter.d.ts.map +0 -1
- package/dist/queries/validateQueryDataSourceSorts.d.ts +0 -8
- package/dist/queries/validateQueryDataSourceSorts.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/src/compatibility/pageForProtocol3To5.ts +0 -190
- package/src/ids.ts +0 -9
- package/src/lifecycle/initErrors.ts +0 -131
- package/src/messages/types.ts +0 -171
- package/src/queries/types.ts +0 -11
- /package/dist/compatibility/{pageResult.js → pages/pageResult.js} +0 -0
- /package/dist/{messages/types.js → context/resize.js} +0 -0
- /package/dist/{autoBindProperties.js → dataSources/bindings/getAutoBoundPropertyIdsByKey.js} +0 -0
- /package/dist/{dateValue.js → dataSources/properties/toNotionDateValue.js} +0 -0
- /package/dist/{queries → dataSources/queries}/querySubscriptions.js +0 -0
- /package/dist/{queries → dataSources}/types.js +0 -0
- /package/dist/{isAllowedLocalPreviewUrl.d.ts → lifecycle/isAllowedLocalPreviewUrl.d.ts} +0 -0
- /package/dist/lifecycle/{protocolVersion.js → isValidBridgeProtocolVersion.js} +0 -0
- /package/dist/{lifecycle → manifest}/resolveManifest.js +0 -0
- /package/dist/messages/{invalidSandboxMessage.js → getInvalidSandboxMessageResponse.js} +0 -0
- /package/dist/{messages → navigation}/parseExternalUrl.d.ts +0 -0
- /package/dist/{messages → navigation}/parseExternalUrl.js +0 -0
- /package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourcePage.d.ts +0 -0
- /package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourceValue.d.ts +0 -0
- /package/dist/protocol/{contrast.d.ts → context/contrast.d.ts} +0 -0
- /package/dist/protocol/{contrast.js → context/contrast.js} +0 -0
- /package/dist/protocol/{messages → context/messages}/contrastModeChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/contrastModeChanged.js +0 -0
- /package/dist/protocol/{messages → context/messages}/pageChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/parentChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/parentChanged.js +0 -0
- /package/dist/protocol/{messages → context/messages}/resize.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/resize.js +0 -0
- /package/dist/protocol/{messages → context/messages}/themeChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/themeChanged.js +0 -0
- /package/dist/protocol/{theme.d.ts → context/theme.d.ts} +0 -0
- /package/dist/protocol/{theme.js → context/theme.js} +0 -0
- /package/dist/protocol/{messages → dataSources/messages}/unsubscribeDataSourceQuery.d.ts +0 -0
- /package/dist/protocol/{messages → dataSources/messages}/unsubscribeDataSourceQuery.js +0 -0
- /package/dist/protocol/dataSources/{dateValue.d.ts → properties/dateValue.d.ts} +0 -0
- /package/dist/protocol/dataSources/{dateValue.js → properties/dateValue.js} +0 -0
- /package/dist/protocol/dataSources/{propertySchema.d.ts → properties/propertySchema.d.ts} +0 -0
- /package/dist/protocol/dataSources/{propertySchema.js → properties/propertySchema.js} +0 -0
- /package/dist/protocol/{messages → handshake}/initResult.js +0 -0
- /package/dist/protocol/{messages → handshake}/isInitHandshakeMessage.js +0 -0
- /package/dist/protocol/{messages → navigation}/openExternalUrl.js +0 -0
- /package/dist/protocol/{messages → users/messages}/currentUserChanged.d.ts +0 -0
- /package/dist/protocol/{ids.d.ts → utils/ids.d.ts} +0 -0
- /package/dist/protocol/{ids.js → utils/ids.js} +0 -0
- /package/dist/protocol/{isLocalBlockServerUrl.d.ts → utils/isLocalBlockServerUrl.d.ts} +0 -0
- /package/dist/protocol/{isLocalBlockServerUrl.js → utils/isLocalBlockServerUrl.js} +0 -0
- /package/dist/protocol/{protocolVersion.d.ts → utils/protocolVersion.d.ts} +0 -0
- /package/dist/protocol/{protocolVersion.js → utils/protocolVersion.js} +0 -0
- /package/dist/protocol/{dataSources → utils}/recordPointer.d.ts +0 -0
- /package/dist/protocol/{dataSources → utils}/recordPointer.js +0 -0
- /package/dist/{protocolVersion.d.ts → utils/protocolVersion.d.ts} +0 -0
- /package/dist/{protocolVersion.js → utils/protocolVersion.js} +0 -0
- /package/dist/{utils.js → utils/unreachable.js} +0 -0
- /package/src/compatibility/{pageResult.ts → pages/pageResult.ts} +0 -0
- /package/src/lifecycle/{protocolVersion.ts → isValidBridgeProtocolVersion.ts} +0 -0
- /package/src/messages/{invalidSandboxMessage.ts → getInvalidSandboxMessageResponse.ts} +0 -0
- /package/src/{messages → navigation}/parseExternalUrl.ts +0 -0
- /package/src/{protocolVersion.ts → utils/protocolVersion.ts} +0 -0
- /package/src/{utils.ts → utils/unreachable.ts} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BridgeUser } from "./bridgeUser.js";
|
|
2
|
+
export type MakeBridgeUserArgs = Pick<BridgeUser, "id" | "person"> & Partial<Omit<BridgeUser, "object" | "type" | "id" | "person">>;
|
|
3
|
+
/** Builds the shared person-user payload; callers supply identity and profile data. */
|
|
4
|
+
export declare function makeBridgeUser(args: MakeBridgeUserArgs): BridgeUser;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { bridgeUserSchema } from "./bridgeUser.js";
|
|
3
|
+
/** Builds the shared person-user payload; callers supply identity and profile data. */
|
|
4
|
+
export function makeBridgeUser(args) {
|
|
5
|
+
return v.parse(bridgeUserSchema, {
|
|
6
|
+
...args,
|
|
7
|
+
object: "user",
|
|
8
|
+
type: "person",
|
|
9
|
+
avatar_url: args.avatar_url ?? null,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { bridgeUserSchema } from "../bridgeUser.js";
|
|
3
3
|
/**
|
|
4
4
|
* Sent by the host when the viewing user's profile changes while the block is mounted.
|
|
5
5
|
*/
|
|
6
6
|
export const currentUserChangedMessageSchema = v.object({
|
|
7
7
|
type: v.literal("currentUserChanged"),
|
|
8
|
-
currentUser:
|
|
8
|
+
currentUser: bridgeUserSchema,
|
|
9
9
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "
|
|
2
|
+
import type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockGetUserErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockGetUserErrorCode = CustomBlockErrorCode<"get_user_failed">;
|
|
4
|
+
export type CustomBlockGetUserErrorCode = CustomBlockErrorCode<"get_user_failed" | CustomBlockCapabilityErrorCode>;
|
|
5
5
|
export type CustomBlockGetUserErrorInfo = CustomBlockErrorInfo<CustomBlockGetUserErrorCode>;
|
|
6
6
|
export declare const customBlockGetUserErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { bridgeUserSchema } from "../bridgeUser.js";
|
|
3
|
+
import { notionUserIdSchema } from "../userId.js";
|
|
3
4
|
// The schema accepts any string code. The type lists known codes for
|
|
4
5
|
// autocomplete, with an open string fallback for newer senders.
|
|
5
6
|
export const customBlockGetUserErrorCodeSchema = v.string();
|
|
@@ -21,7 +22,7 @@ export const getUserResultMessageSchema = v.variant("status", [
|
|
|
21
22
|
type: v.literal("getUserResult"),
|
|
22
23
|
requestId: v.string(),
|
|
23
24
|
status: v.literal("success"),
|
|
24
|
-
user:
|
|
25
|
+
user: bridgeUserSchema,
|
|
25
26
|
}),
|
|
26
27
|
v.object({
|
|
27
28
|
type: v.literal("getUserResult"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "
|
|
2
|
+
import type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockListUsersErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<"list_users_failed">;
|
|
4
|
+
export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<"list_users_failed" | CustomBlockCapabilityErrorCode>;
|
|
5
5
|
export type CustomBlockListUsersErrorInfo = CustomBlockErrorInfo<CustomBlockListUsersErrorCode>;
|
|
6
6
|
export declare const customBlockListUsersErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { bridgeUserListSchema } from "../bridgeUserList.js";
|
|
3
3
|
// The schema accepts any string code. The type lists known codes for
|
|
4
4
|
// autocomplete, with an open string fallback for newer senders.
|
|
5
5
|
export const customBlockListUsersErrorCodeSchema = v.string();
|
|
@@ -22,7 +22,7 @@ export const listUsersResultMessageSchema = v.variant("status", [
|
|
|
22
22
|
type: v.literal("listUsersResult"),
|
|
23
23
|
requestId: v.string(),
|
|
24
24
|
status: v.literal("success"),
|
|
25
|
-
list:
|
|
25
|
+
list: bridgeUserListSchema,
|
|
26
26
|
}),
|
|
27
27
|
v.object({
|
|
28
28
|
type: v.literal("listUsersResult"),
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
export type CustomBlockErrorCode<KnownCode extends string> = KnownCode | "unknown_error" | (string & {});
|
|
3
|
+
/**
|
|
4
|
+
* Reserved for a request that needs a capability the block did not declare or
|
|
5
|
+
* the viewer did not grant. No host sends it yet.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CAPABILITY_NOT_GRANTED_ERROR_CODE = "capability_not_granted";
|
|
8
|
+
export type CustomBlockCapabilityErrorCode = typeof CAPABILITY_NOT_GRANTED_ERROR_CODE;
|
|
3
9
|
export type CustomBlockErrorInfo<TCode extends string = string> = {
|
|
4
10
|
code: TCode;
|
|
5
11
|
message: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Reserved for a request that needs a capability the block did not declare or
|
|
4
|
+
* the viewer did not grant. No host sends it yet.
|
|
5
|
+
*/
|
|
6
|
+
export const CAPABILITY_NOT_GRANTED_ERROR_CODE = "capability_not_granted";
|
|
7
|
+
export const customBlockErrorInfoSchema = v.object({
|
|
8
|
+
code: v.string(),
|
|
9
|
+
message: v.string(),
|
|
10
|
+
isRetryable: v.boolean(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BridgeMessagePayload } from "../protocol/messages/messagePayload.js";
|
|
2
|
+
import type { CustomBlockGetUserErrorInfo, getUserMessageSchema, getUserResultMessageSchema } from "../protocol/users/messages/getUser.js";
|
|
3
|
+
import type { CustomBlockListUsersErrorInfo, listUsersMessageSchema, listUsersResultMessageSchema } from "../protocol/users/messages/listUsers.js";
|
|
4
|
+
import type { InferInput } from "valibot";
|
|
5
|
+
export type CustomBlockHostGetUserResult = BridgeMessagePayload<InferInput<typeof getUserResultMessageSchema>, CustomBlockGetUserErrorInfo>;
|
|
6
|
+
export type CustomBlockHostListUsersResult = BridgeMessagePayload<InferInput<typeof listUsersResultMessageSchema>, CustomBlockListUsersErrorInfo>;
|
|
7
|
+
export type GetUserMessageInput = InferInput<typeof getUserMessageSchema>;
|
|
8
|
+
export type ListUsersMessageInput = InferInput<typeof listUsersMessageSchema>;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/users/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,MAAM,4DAA4D,CAAA;AACnE,OAAO,KAAK,EACX,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAC9D,UAAU,CAAC,OAAO,0BAA0B,CAAC,EAC7C,2BAA2B,CAC3B,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG,oBAAoB,CAChE,UAAU,CAAC,OAAO,4BAA4B,CAAC,EAC/C,6BAA6B,CAC7B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybePromise.d.ts","sourceRoot":"","sources":["../../src/utils/maybePromise.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocolVersion.d.ts","sourceRoot":"","sources":["../../src/utils/protocolVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,0CAA0C,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toNotionPageId.d.ts","sourceRoot":"","sources":["../../src/utils/toNotionPageId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAIjF,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAEvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unreachable.d.ts","sourceRoot":"","sources":["../../src/utils/unreachable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAI/C"}
|
package/docs/bridge/protocol.md
CHANGED
|
@@ -107,13 +107,18 @@ for `code`, including unknown codes. TypeScript aliases list known codes for aut
|
|
|
107
107
|
|
|
108
108
|
### Bindings and IDs
|
|
109
109
|
|
|
110
|
-
Hosts send `
|
|
110
|
+
Hosts send `BridgeDataSourceBindings` as `dataSources: { bindings }`, keyed by the semantic data
|
|
111
111
|
source key declared in the manifest. `collectionSchema` contains only actual database properties.
|
|
112
112
|
|
|
113
113
|
Sandbox-to-host object references are raw IDs. The SDK resolves semantic data-source and property
|
|
114
114
|
keys before sending query or page-operation requests. Get and update requests can carry an optional
|
|
115
115
|
resolved `dataSourceId`.
|
|
116
116
|
|
|
117
|
+
A binding with `inaccessible: true` marks a bound data source that the viewer can't read. The host
|
|
118
|
+
omits its pointer, schema, and property mappings. The SDK and host still initialize the block. The
|
|
119
|
+
SDK fails queries and page creation that use the data source with `data_source_inaccessible`,
|
|
120
|
+
without sending a message.
|
|
121
|
+
|
|
117
122
|
### Query requests
|
|
118
123
|
|
|
119
124
|
`queryDataSource` may include a resolved `filter` and an ordered `sorts` list. Each sort contains a
|
|
@@ -160,6 +165,16 @@ filter: {
|
|
|
160
165
|
}
|
|
161
166
|
```
|
|
162
167
|
|
|
168
|
+
## Capabilities
|
|
169
|
+
|
|
170
|
+
`manifest.capabilities` lists `{ capability, resource }` declarations. Both fields are open strings,
|
|
171
|
+
so a newer vocabulary never makes an older receiver reject a manifest. An omitted `capabilities`
|
|
172
|
+
marks a block that predates approval.
|
|
173
|
+
|
|
174
|
+
The `capability_not_granted` error code is reserved for a request that the viewer's grants do not
|
|
175
|
+
cover, with `isRetryable: false`. No adapter sends it yet, and no receiver restricts requests by
|
|
176
|
+
capability. The SDK's capabilities guide documents the vocabulary.
|
|
177
|
+
|
|
163
178
|
## Page context
|
|
164
179
|
|
|
165
180
|
Containing-page context uses `CustomBlockPage`. The `init.page` and `pageChanged.page` fields
|
|
@@ -175,10 +190,10 @@ must carry the same raw property ID in its `id` field.
|
|
|
175
190
|
|
|
176
191
|
## Page responses
|
|
177
192
|
|
|
178
|
-
Host handlers return unified `
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
193
|
+
Host handlers return unified `BridgePage` for queries and page operations. Properties use display
|
|
194
|
+
names as keys and typed values that include their raw property IDs. Only actual schema properties
|
|
195
|
+
are returned. Query results contain `items` and `hasMore`. `bridgePageSchema` defines the page
|
|
196
|
+
fields, including archive state and creation, edit, and visit metadata.
|
|
182
197
|
|
|
183
198
|
Page reads return string values for `unique_id`, `formula`, `rollup`, `button`, `verification`, and
|
|
184
199
|
`location`, preserving each property's type. These properties are read-only. Values use stored text,
|
|
@@ -21,8 +21,8 @@ conversions.
|
|
|
21
21
|
## Protocol export names
|
|
22
22
|
|
|
23
23
|
The `@notionhq/custom-blocks-host/protocol` entrypoint exports wire definitions. Page formats used
|
|
24
|
-
by protocols 3–5 are named `
|
|
25
|
-
with matching `
|
|
24
|
+
by protocols 3–5 are named `BridgePageForProtocol3To5` and `NotionDataSourcePageForProtocol3To5`,
|
|
25
|
+
with matching `bridgePageForProtocol3To5Schema` and `notionDataSourcePageForProtocol3To5Schema`
|
|
26
26
|
validators. Message types and schemas containing `WithProtocol3To5Compatibility` accept both current
|
|
27
27
|
page formats and protocol 3–5 page formats. `UNIFIED_PAGE_PROTOCOL_VERSION` is 6, the minimum
|
|
28
28
|
protocol version that uses unified pages.
|
package/docs/handlers.md
CHANGED
|
@@ -42,11 +42,11 @@ import type {
|
|
|
42
42
|
CustomBlockHostDataSourcesPayload,
|
|
43
43
|
CustomBlockHostHandlers,
|
|
44
44
|
} from "@notionhq/custom-blocks-host"
|
|
45
|
-
import type {
|
|
45
|
+
import type { BridgeCustomBlockManifest, BridgePage } from "@notionhq/custom-blocks-host/protocol"
|
|
46
46
|
|
|
47
47
|
const tasksId = "44444444-4444-4444-8444-444444444444"
|
|
48
48
|
|
|
49
|
-
const manifest:
|
|
49
|
+
const manifest: BridgeCustomBlockManifest = {
|
|
50
50
|
version: 1,
|
|
51
51
|
dataSources: {
|
|
52
52
|
tasks: {
|
|
@@ -109,7 +109,7 @@ const handlers: CustomBlockHostHandlers = {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const items:
|
|
112
|
+
const items: BridgePage[] = [
|
|
113
113
|
{
|
|
114
114
|
object: "page",
|
|
115
115
|
id: "55555555-5555-4555-8555-555555555555",
|
package/package.json
CHANGED
|
@@ -5,10 +5,10 @@ import type {
|
|
|
5
5
|
import {
|
|
6
6
|
TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION,
|
|
7
7
|
UNIFIED_PAGE_PROTOCOL_VERSION,
|
|
8
|
-
} from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
9
|
-
import { addMetadataReadSchemasForProtocol3To4 } from "./addMetadataReadSchemasForProtocol3To4.js"
|
|
10
|
-
import { normalizePageResultsForProtocol3To5 } from "./normalizePageResultsForProtocol3To5.js"
|
|
11
|
-
import { normalizePageResultsForProtocol6 } from "./normalizePageResultsForProtocol6.js"
|
|
8
|
+
} from "@notionhq/custom-blocks-protocol/utils/protocolVersion.js"
|
|
9
|
+
import { addMetadataReadSchemasForProtocol3To4 } from "./protocol3To4/addMetadataReadSchemasForProtocol3To4.js"
|
|
10
|
+
import { normalizePageResultsForProtocol3To5 } from "./protocol3To5/normalizePageResultsForProtocol3To5.js"
|
|
11
|
+
import { normalizePageResultsForProtocol6 } from "./protocol6/normalizePageResultsForProtocol6.js"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Encodes current host messages for the sandbox's declared protocol. Handlers use
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { bridgePageSchema } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
2
2
|
import type { InferOutput } from "valibot"
|
|
3
|
-
import { unreachable } from "
|
|
3
|
+
import { unreachable } from "../../utils/unreachable.js"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared field conversion for receivers that cannot decode text fallback objects.
|
|
@@ -8,8 +8,8 @@ import { unreachable } from "../utils.js"
|
|
|
8
8
|
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 7.
|
|
9
9
|
*/
|
|
10
10
|
export function toPageWithNullTextFallbackProperties(
|
|
11
|
-
page: InferOutput<typeof
|
|
12
|
-
): InferOutput<typeof
|
|
11
|
+
page: InferOutput<typeof bridgePageSchema>,
|
|
12
|
+
): InferOutput<typeof bridgePageSchema> {
|
|
13
13
|
return {
|
|
14
14
|
...page,
|
|
15
15
|
properties: Object.fromEntries(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NOTION_BUILTIN_PROPERTY_SCHEMAS } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
1
|
+
import { NOTION_BUILTIN_PROPERTY_SCHEMAS } from "@notionhq/custom-blocks-protocol/dataSources/properties/propertySchema.js"
|
|
2
2
|
import type { HostToSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { HostToSandboxMessageWithProtocol3To5Compatibility } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./
|
|
6
|
-
import type { SuccessfulPageResult } from "./pageResult.js"
|
|
7
|
-
import { toPageWithNullTextFallbackProperties } from "./pageWithNullTextFallbackProperties.js"
|
|
2
|
+
import type { SuccessfulPageResult } from "../pages/pageResult.js"
|
|
3
|
+
import { toPageWithNullTextFallbackProperties } from "../pages/toPageWithNullTextFallbackProperties.js"
|
|
4
|
+
import { toPageForProtocol3To5 } from "./toPageForProtocol3To5.js"
|
|
5
|
+
import { toQueryPageForProtocol3To5 } from "./toQueryPageForProtocol3To5.js"
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Encodes current pages for protocols 3–5. Query values are flat and ID-keyed.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/compatibility/protocol3To5/dataSourceValue.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a timestamp to the UTC date/time object used by protocol 3–5 queries.
|
|
5
|
+
* Missing or invalid timestamps produce undefined; time is stored to the minute.
|
|
6
|
+
*
|
|
7
|
+
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
8
|
+
*/
|
|
9
|
+
export function toDateTimeValueForProtocol3To5(
|
|
10
|
+
value: string | number | null | undefined,
|
|
11
|
+
): NotionDataSourceValue | undefined {
|
|
12
|
+
if (value === undefined || value === null || value === "") {
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
15
|
+
const date = new Date(value)
|
|
16
|
+
if (!Number.isFinite(date.getTime())) {
|
|
17
|
+
return undefined
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
type: "datetime",
|
|
21
|
+
start_date: date.toISOString().slice(0, 10),
|
|
22
|
+
start_time: date.toISOString().slice(11, 16),
|
|
23
|
+
time_zone: "UTC",
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BridgePageForProtocol3To5 } from "@notionhq/custom-blocks-protocol/compatibility/protocol3To5/bridgePage.js"
|
|
2
|
+
import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts current page data to the page-operation format used by protocols 3–5.
|
|
6
|
+
* Keys property objects by raw ID and omits null properties. Optional icons,
|
|
7
|
+
* covers, timestamps, and URLs use undefined instead of null in this format.
|
|
8
|
+
* Call after clearing property objects unsupported by these protocols.
|
|
9
|
+
*
|
|
10
|
+
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
11
|
+
*/
|
|
12
|
+
export function toPageForProtocol3To5(
|
|
13
|
+
page: BridgePage,
|
|
14
|
+
): BridgePageForProtocol3To5 {
|
|
15
|
+
return {
|
|
16
|
+
...page,
|
|
17
|
+
properties: Object.fromEntries(
|
|
18
|
+
Object.values(page.properties).flatMap(property =>
|
|
19
|
+
property ? [[property.id, property]] : [],
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
icon: page.icon ?? undefined,
|
|
23
|
+
cover: page.cover ?? undefined,
|
|
24
|
+
created_time: page.created_time ?? undefined,
|
|
25
|
+
last_edited_time: page.last_edited_time ?? undefined,
|
|
26
|
+
url: page.url ?? undefined,
|
|
27
|
+
public_url: page.public_url ?? undefined,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/compatibility/protocol3To5/dataSourceValue.js"
|
|
2
|
+
import type { BridgePagePropertyValue } from "@notionhq/custom-blocks-protocol/pages/properties/bridgePagePropertyValue.js"
|
|
3
|
+
import { toNotionDateValue } from "../../dataSources/properties/toNotionDateValue.js"
|
|
4
|
+
import { unreachable } from "../../utils/unreachable.js"
|
|
5
|
+
import { toDateTimeValueForProtocol3To5 } from "./toDateTimeValueForProtocol3To5.js"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Converts a typed page property to the scalar, list, record-reference, or
|
|
9
|
+
* date/time value used by protocol 3–5 query results.
|
|
10
|
+
*
|
|
11
|
+
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
12
|
+
*/
|
|
13
|
+
export function toPropertyValueForProtocol3To5(
|
|
14
|
+
property: BridgePagePropertyValue,
|
|
15
|
+
): NotionDataSourceValue | undefined {
|
|
16
|
+
switch (property.type) {
|
|
17
|
+
case "title":
|
|
18
|
+
return plainText(property.title)
|
|
19
|
+
case "rich_text":
|
|
20
|
+
return plainText(property.rich_text)
|
|
21
|
+
case "number":
|
|
22
|
+
return property.number ?? undefined
|
|
23
|
+
case "checkbox":
|
|
24
|
+
return property.checkbox
|
|
25
|
+
case "url":
|
|
26
|
+
return property.url ?? ""
|
|
27
|
+
case "email":
|
|
28
|
+
return property.email ?? ""
|
|
29
|
+
case "phone_number":
|
|
30
|
+
return property.phone_number ?? ""
|
|
31
|
+
case "select":
|
|
32
|
+
return property.select?.name
|
|
33
|
+
case "status":
|
|
34
|
+
return property.status?.name
|
|
35
|
+
case "multi_select":
|
|
36
|
+
return property.multi_select.flatMap(option => option.name ?? [])
|
|
37
|
+
case "date":
|
|
38
|
+
return property.date ? toNotionDateValue(property.date) : undefined
|
|
39
|
+
case "people":
|
|
40
|
+
return property.people.map(person =>
|
|
41
|
+
person.object === "group"
|
|
42
|
+
? {
|
|
43
|
+
id: person.id,
|
|
44
|
+
table: "space_permission_group",
|
|
45
|
+
spaceId: person.id.split("|")[1],
|
|
46
|
+
}
|
|
47
|
+
: { id: person.id, table: "notion_user" },
|
|
48
|
+
)
|
|
49
|
+
case "relation":
|
|
50
|
+
return property.relation.map(page => ({ id: page.id, table: "block" }))
|
|
51
|
+
case "files":
|
|
52
|
+
return property.files.map(file => file.name).join(",")
|
|
53
|
+
case "unique_id":
|
|
54
|
+
return property.unique_id
|
|
55
|
+
case "button":
|
|
56
|
+
return property.button
|
|
57
|
+
case "formula":
|
|
58
|
+
return property.formula
|
|
59
|
+
case "location":
|
|
60
|
+
return property.location
|
|
61
|
+
case "rollup":
|
|
62
|
+
return property.rollup
|
|
63
|
+
case "verification":
|
|
64
|
+
return property.verification
|
|
65
|
+
case "place":
|
|
66
|
+
return ""
|
|
67
|
+
case "created_time":
|
|
68
|
+
return toDateTimeValueForProtocol3To5(property.created_time)
|
|
69
|
+
case "last_edited_time":
|
|
70
|
+
return toDateTimeValueForProtocol3To5(property.last_edited_time)
|
|
71
|
+
case "last_visited_time":
|
|
72
|
+
return toDateTimeValueForProtocol3To5(property.last_visited_time)
|
|
73
|
+
case "created_by":
|
|
74
|
+
return property.created_by ? [property.created_by] : undefined
|
|
75
|
+
case "last_edited_by":
|
|
76
|
+
return property.last_edited_by ? [property.last_edited_by] : undefined
|
|
77
|
+
default:
|
|
78
|
+
return unreachable(property)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Flattens rich-text items to the string used by protocol 3–5 query values.
|
|
84
|
+
*
|
|
85
|
+
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
86
|
+
*/
|
|
87
|
+
function plainText(items: Record<string, unknown>[]): string {
|
|
88
|
+
return items
|
|
89
|
+
.map(item => {
|
|
90
|
+
if (typeof item.plain_text === "string") {
|
|
91
|
+
return item.plain_text
|
|
92
|
+
}
|
|
93
|
+
const text = item.text
|
|
94
|
+
return text &&
|
|
95
|
+
typeof text === "object" &&
|
|
96
|
+
"content" in text &&
|
|
97
|
+
typeof text.content === "string"
|
|
98
|
+
? text.content
|
|
99
|
+
: ""
|
|
100
|
+
})
|
|
101
|
+
.join("")
|
|
102
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/compatibility/protocol3To5/dataSourceValue.js"
|
|
2
|
+
import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
3
|
+
import { toDateTimeValueForProtocol3To5 } from "./toDateTimeValueForProtocol3To5.js"
|
|
4
|
+
import { toPropertyValueForProtocol3To5 } from "./toPropertyValueForProtocol3To5.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts a current page to a protocol 3–5 query row, keeping its ID and archive
|
|
8
|
+
* flags while flattening typed property objects into raw-ID-keyed values.
|
|
9
|
+
* Copies page creation and edit metadata into the reserved property IDs that
|
|
10
|
+
* these query readers expect.
|
|
11
|
+
*
|
|
12
|
+
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
13
|
+
*/
|
|
14
|
+
export function toQueryPageForProtocol3To5(page: BridgePage) {
|
|
15
|
+
const propertiesById: Record<string, NotionDataSourceValue | undefined> = {}
|
|
16
|
+
for (const property of Object.values(page.properties)) {
|
|
17
|
+
if (property) {
|
|
18
|
+
propertiesById[property.id] = toPropertyValueForProtocol3To5(property)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
id: page.id,
|
|
23
|
+
is_archived: page.is_archived,
|
|
24
|
+
in_trash: page.in_trash,
|
|
25
|
+
// Reserved metadata IDs retain their historical meaning even if an actual
|
|
26
|
+
// property uses the same ID. Binding schemas use the same precedence.
|
|
27
|
+
propertiesById: {
|
|
28
|
+
...propertiesById,
|
|
29
|
+
created_time: toDateTimeValueForProtocol3To5(page.created_time),
|
|
30
|
+
last_edited_time: toDateTimeValueForProtocol3To5(page.last_edited_time),
|
|
31
|
+
created_by: page.created_by ? [page.created_by] : undefined,
|
|
32
|
+
last_edited_by: page.last_edited_by ? [page.last_edited_by] : undefined,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HostToSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
2
|
-
import type { SuccessfulPageResult } from "
|
|
3
|
-
import { toPageWithNullTextFallbackProperties } from "
|
|
2
|
+
import type { SuccessfulPageResult } from "../pages/pageResult.js"
|
|
3
|
+
import { toPageWithNullTextFallbackProperties } from "../pages/toPageWithNullTextFallbackProperties.js"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Encodes protocol 6 pages, whose receivers require null for text fallback properties.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { customBlockPageSchema } from "@notionhq/custom-blocks-protocol/context/containingPage.js"
|
|
2
|
+
import { notionContrastModeSchema } from "@notionhq/custom-blocks-protocol/context/contrast.js"
|
|
3
|
+
import { notionParentSchema } from "@notionhq/custom-blocks-protocol/context/parent.js"
|
|
4
|
+
import { notionThemeSchema } from "@notionhq/custom-blocks-protocol/context/theme.js"
|
|
5
|
+
import { bridgeDataSourceBindingsSchema } from "@notionhq/custom-blocks-protocol/dataSources/bridgeDataSourceBindings.js"
|
|
6
|
+
import type { CustomBlockInitErrorInfo } from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
7
|
+
import { customBlockInitErrorInfoSchema } from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
8
|
+
import type { BridgeCustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest/manifest.js"
|
|
9
|
+
import { manifestSchema } from "@notionhq/custom-blocks-protocol/manifest/manifest.js"
|
|
10
|
+
import { bridgeUserSchema } from "@notionhq/custom-blocks-protocol/users/bridgeUser.js"
|
|
11
|
+
import { notionBlockIdSchema } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
12
|
+
import * as v from "valibot"
|
|
13
|
+
|
|
14
|
+
export const customBlockHostInitialStateSchema = v.object({
|
|
15
|
+
theme: notionThemeSchema,
|
|
16
|
+
/**
|
|
17
|
+
* Defaults to standard for existing host integrations.
|
|
18
|
+
* TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
|
|
19
|
+
*/
|
|
20
|
+
contrastMode: v.optional(notionContrastModeSchema),
|
|
21
|
+
blockId: notionBlockIdSchema,
|
|
22
|
+
parent: notionParentSchema,
|
|
23
|
+
page: customBlockPageSchema,
|
|
24
|
+
manifest: manifestSchema,
|
|
25
|
+
dataSources: v.object({ bindings: bridgeDataSourceBindingsSchema }),
|
|
26
|
+
currentUser: bridgeUserSchema,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
export type CustomBlockHostInitialState = v.InferInput<
|
|
30
|
+
typeof customBlockHostInitialStateSchema
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
export type CustomBlockHostInitialStateResult =
|
|
34
|
+
| {
|
|
35
|
+
status: "success"
|
|
36
|
+
initialState: CustomBlockHostInitialState
|
|
37
|
+
}
|
|
38
|
+
| {
|
|
39
|
+
status: "error"
|
|
40
|
+
error: CustomBlockInitErrorInfo
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const customBlockHostPreparedStateResultSchema = v.variant("status", [
|
|
44
|
+
v.object({
|
|
45
|
+
status: v.literal("success"),
|
|
46
|
+
initialState: v.omit(customBlockHostInitialStateSchema, ["manifest"]),
|
|
47
|
+
}),
|
|
48
|
+
v.object({
|
|
49
|
+
status: v.literal("error"),
|
|
50
|
+
error: customBlockInitErrorInfoSchema,
|
|
51
|
+
}),
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
/** Adapter-owned state or an explicit preparation error. The host adds the manifest to init. */
|
|
55
|
+
export type CustomBlockHostPreparedStateResult =
|
|
56
|
+
| {
|
|
57
|
+
status: "success"
|
|
58
|
+
initialState: Omit<CustomBlockHostInitialState, "manifest">
|
|
59
|
+
}
|
|
60
|
+
| { status: "error"; error: CustomBlockInitErrorInfo }
|
|
61
|
+
|
|
62
|
+
export type CustomBlockHostPrepareInitialState = (args: {
|
|
63
|
+
manifest: BridgeCustomBlockManifest
|
|
64
|
+
signal: AbortSignal
|
|
65
|
+
}) => Promise<CustomBlockHostPreparedStateResult>
|