@notionhq/custom-blocks-host 0.4.2 → 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 +4 -0
- 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} +2 -2
- 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 +1801 -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 +28 -13
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +46 -28
- 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 +18 -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 +16 -8
- 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 +55 -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 +27 -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/messages/result.d.ts +12 -0
- package/dist/messages/result.d.ts.map +1 -0
- package/dist/messages/result.js +1 -0
- package/dist/navigation/parseExternalUrl.d.ts.map +1 -0
- package/dist/navigation/types.d.ts +7 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -0
- package/dist/pages/types.d.ts +18 -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} +22 -2
- 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 +6 -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 +4 -3
- 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/{messages/updatePageResult.js → pages/messages/updatePage.js} +26 -2
- 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 +6 -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 +15 -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 +16 -1
- package/docs/bridge/versioning.md +2 -2
- package/docs/handlers.md +16 -8
- package/docs/lifecycle.md +14 -0
- package/package.json +1 -1
- package/src/compatibility/normalizeHostToSandboxMessage.ts +4 -4
- package/src/compatibility/{pageWithNullTextFallbackProperties.ts → pages/toPageWithNullTextFallbackProperties.ts} +2 -2
- 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 +56 -0
- package/src/context/resize.ts +4 -0
- package/src/createCustomBlockHost.ts +108 -88
- 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 +23 -0
- package/src/{queries → dataSources/validation}/validateQueryDataSourceFilter.ts +11 -13
- package/src/{queries → dataSources/validation}/validateQueryDataSourceSorts.ts +6 -8
- package/src/index.ts +39 -30
- 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 +46 -0
- package/src/messages/logging.ts +1 -0
- package/src/messages/result.ts +11 -0
- package/src/navigation/types.ts +10 -0
- package/src/pages/types.ts +22 -0
- package/src/users/types.ts +17 -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/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,56 @@
|
|
|
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 { customBlockInitErrorInfoSchema } from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
7
|
+
import type { BridgeCustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest/manifest.js"
|
|
8
|
+
import { manifestSchema } from "@notionhq/custom-blocks-protocol/manifest/manifest.js"
|
|
9
|
+
import { bridgeUserSchema } from "@notionhq/custom-blocks-protocol/users/bridgeUser.js"
|
|
10
|
+
import { notionBlockIdSchema } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
11
|
+
import * as v from "valibot"
|
|
12
|
+
import type { CustomBlockHostResult } from "../messages/result.js"
|
|
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 = CustomBlockHostResult<{
|
|
34
|
+
initialState: CustomBlockHostInitialState
|
|
35
|
+
}>
|
|
36
|
+
|
|
37
|
+
export const customBlockHostPreparedStateResultSchema = v.variant("status", [
|
|
38
|
+
v.object({
|
|
39
|
+
status: v.literal("success"),
|
|
40
|
+
initialState: v.omit(customBlockHostInitialStateSchema, ["manifest"]),
|
|
41
|
+
}),
|
|
42
|
+
v.object({
|
|
43
|
+
status: v.literal("error"),
|
|
44
|
+
error: customBlockInitErrorInfoSchema,
|
|
45
|
+
}),
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
/** Adapter-owned state or an explicit preparation error. The host adds the manifest to init. */
|
|
49
|
+
export type CustomBlockHostPreparedStateResult = CustomBlockHostResult<{
|
|
50
|
+
initialState: Omit<CustomBlockHostInitialState, "manifest">
|
|
51
|
+
}>
|
|
52
|
+
|
|
53
|
+
export type CustomBlockHostPrepareInitialState = (args: {
|
|
54
|
+
manifest: BridgeCustomBlockManifest
|
|
55
|
+
signal: AbortSignal
|
|
56
|
+
}) => Promise<CustomBlockHostPreparedStateResult>
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { customBlockPageSchema } from "@notionhq/custom-blocks-protocol/context/containingPage.js"
|
|
2
|
+
import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/context/contrast.js"
|
|
3
|
+
import type { notionParentSchema } from "@notionhq/custom-blocks-protocol/context/parent.js"
|
|
4
|
+
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/context/theme.js"
|
|
5
|
+
import { bridgeDataSourceBindingsSchema } from "@notionhq/custom-blocks-protocol/dataSources/bridgeDataSourceBindings.js"
|
|
6
|
+
import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/collectionSchema.js"
|
|
7
|
+
import type {
|
|
8
|
+
CustomBlockQueryDataSourceErrorInfo,
|
|
9
|
+
QueryDataSourceMessage,
|
|
10
|
+
queryDataSourceResultMessageSchema,
|
|
11
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
12
|
+
import { resolveDataSourceBinding } from "@notionhq/custom-blocks-protocol/dataSources/resolveDataSourceBinding.js"
|
|
13
|
+
import type { CustomBlockInitErrorInfo } from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
11
14
|
import {
|
|
12
|
-
type CustomBlockInitErrorInfo,
|
|
13
15
|
CustomBlockInitializationError,
|
|
14
16
|
initMessageSchema,
|
|
15
|
-
} from "@notionhq/custom-blocks-protocol/
|
|
17
|
+
} from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
18
|
+
import type { BridgeCustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest/manifest.js"
|
|
19
|
+
import type { HostToSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
20
|
+
import { hostToSandboxMessageSchema } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
16
21
|
import type { InvalidSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/invalidSandboxMessage.js"
|
|
22
|
+
import type { SandboxToHostMessage } from "@notionhq/custom-blocks-protocol/messages/sandboxToHost.js"
|
|
17
23
|
import type {
|
|
18
24
|
OpenExternalUrlMessage,
|
|
19
25
|
OpenExternalUrlResultMessage,
|
|
20
|
-
} from "@notionhq/custom-blocks-protocol/
|
|
21
|
-
import type {
|
|
22
|
-
import type {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from "@notionhq/custom-blocks-protocol/
|
|
26
|
-
import type { SandboxToHostMessage } from "@notionhq/custom-blocks-protocol/messages/sandboxToHost.js"
|
|
27
|
-
import type { customBlockPageSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
28
|
-
import type { notionParentSchema } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
29
|
-
import { LATEST_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
30
|
-
import type { notionThemeSchema } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
31
|
-
import type { notionUserSchema } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
26
|
+
} from "@notionhq/custom-blocks-protocol/navigation/openExternalUrl.js"
|
|
27
|
+
import type { BridgeUser } from "@notionhq/custom-blocks-protocol/users/bridgeUser.js"
|
|
28
|
+
import type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/utils/errors.js"
|
|
29
|
+
import type { NotionDataSourceId } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
30
|
+
import { notionDataSourceIdSchema } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
31
|
+
import { LATEST_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/utils/protocolVersion.js"
|
|
32
32
|
import type { InferInput } from "valibot"
|
|
33
33
|
import * as v from "valibot"
|
|
34
34
|
import { normalizeHostToSandboxMessage } from "./compatibility/normalizeHostToSandboxMessage.js"
|
|
35
|
-
import { isAllowedLocalPreviewUrl } from "./isAllowedLocalPreviewUrl.js"
|
|
36
|
-
import {
|
|
37
|
-
contextUnavailableError,
|
|
38
|
-
invalidLocalPreviewUrlError,
|
|
39
|
-
invalidPropertyBindingError,
|
|
40
|
-
missingDataSourceBindingError,
|
|
41
|
-
missingPropertyBindingError,
|
|
42
|
-
unknownInitializationError,
|
|
43
|
-
} from "./lifecycle/initErrors.js"
|
|
44
|
-
import { createInitializationController } from "./lifecycle/initializationController.js"
|
|
45
|
-
import { resolveManifest } from "./lifecycle/resolveManifest.js"
|
|
46
35
|
import type {
|
|
47
|
-
CustomBlockHostDataSourcesPayload,
|
|
48
36
|
CustomBlockHostInitialState,
|
|
49
37
|
CustomBlockHostInitialStateResult,
|
|
50
|
-
CustomBlockHostManifestResult,
|
|
51
|
-
CustomBlockHostNormalizedDataSourcesPayload,
|
|
52
|
-
CustomBlockHostNormalizedManifestResult,
|
|
53
38
|
CustomBlockHostPrepareInitialState,
|
|
54
|
-
|
|
55
|
-
CustomBlockManifestSource,
|
|
56
|
-
} from "./lifecycle/types.js"
|
|
39
|
+
} from "./context/initialState.js"
|
|
57
40
|
import {
|
|
58
41
|
customBlockHostInitialStateSchema,
|
|
59
|
-
customBlockHostManifestResultSchema,
|
|
60
42
|
customBlockHostPreparedStateResultSchema,
|
|
61
|
-
} from "./
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
43
|
+
} from "./context/initialState.js"
|
|
44
|
+
import type { QuerySubscriptionToken } from "./dataSources/queries/querySubscriptions.js"
|
|
45
|
+
import { QuerySubscriptions } from "./dataSources/queries/querySubscriptions.js"
|
|
46
|
+
import type {
|
|
47
|
+
CustomBlockHostDataSourcesPayload,
|
|
48
|
+
CustomBlockHostNormalizedDataSourcesPayload,
|
|
49
|
+
CustomBlockHostQueryDataSourceResult,
|
|
50
|
+
} from "./dataSources/types.js"
|
|
51
|
+
import { validateQueryDataSourceFilter } from "./dataSources/validation/validateQueryDataSourceFilter.js"
|
|
52
|
+
import { validateQueryDataSourceSorts } from "./dataSources/validation/validateQueryDataSourceSorts.js"
|
|
53
|
+
import { createInitializationController } from "./lifecycle/createInitializationController.js"
|
|
54
|
+
import { contextUnavailableError } from "./lifecycle/errors/contextUnavailableError.js"
|
|
55
|
+
import { invalidLocalPreviewUrlError } from "./lifecycle/errors/invalidLocalPreviewUrlError.js"
|
|
56
|
+
import { invalidPropertyBindingError } from "./lifecycle/errors/invalidPropertyBindingError.js"
|
|
57
|
+
import { missingDataSourceBindingError } from "./lifecycle/errors/missingDataSourceBindingError.js"
|
|
58
|
+
import { missingPropertyBindingError } from "./lifecycle/errors/missingPropertyBindingError.js"
|
|
59
|
+
import { unknownInitializationError } from "./lifecycle/errors/unknownInitializationError.js"
|
|
60
|
+
import { isAllowedLocalPreviewUrl } from "./lifecycle/isAllowedLocalPreviewUrl.js"
|
|
64
61
|
import type {
|
|
65
62
|
CustomBlockHostFailure,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} from "./
|
|
69
|
-
import {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} from "./
|
|
74
|
-
import
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
63
|
+
CustomBlockHostStatus,
|
|
64
|
+
} from "./lifecycle/types.js"
|
|
65
|
+
import { resolveManifest } from "./manifest/resolveManifest.js"
|
|
66
|
+
import type {
|
|
67
|
+
CustomBlockHostManifestResult,
|
|
68
|
+
CustomBlockHostNormalizedManifestResult,
|
|
69
|
+
CustomBlockManifestSource,
|
|
70
|
+
} from "./manifest/types.js"
|
|
71
|
+
import { customBlockHostManifestResultSchema } from "./manifest/types.js"
|
|
72
|
+
import { createSandboxMessageRouter } from "./messages/createSandboxMessageRouter.js"
|
|
73
|
+
import type { CustomBlockHostHandlers } from "./messages/handlers.js"
|
|
74
|
+
import type { CustomBlockHostLogDirection } from "./messages/logging.js"
|
|
75
|
+
import { parseExternalUrl } from "./navigation/parseExternalUrl.js"
|
|
76
|
+
import { MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION } from "./utils/protocolVersion.js"
|
|
77
|
+
import { unreachable } from "./utils/unreachable.js"
|
|
78
78
|
|
|
79
79
|
// Bridge protocol version that introduced page: { type: "unavailable" }.
|
|
80
80
|
// Earlier SDKs cannot represent this context, so the host reports context_unavailable.
|
|
@@ -113,19 +113,33 @@ export type CustomBlockHostOptions = {
|
|
|
113
113
|
initialStateTimeoutMs?: number
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/** Reports local acceptance, not sandbox delivery or initialization success. */
|
|
117
|
+
export type CustomBlockHostSetDataSourcesResult =
|
|
118
|
+
| { status: "success" }
|
|
119
|
+
| {
|
|
120
|
+
status: "error"
|
|
121
|
+
error: CustomBlockErrorInfo<
|
|
122
|
+
| "missing_data_source_binding"
|
|
123
|
+
| "missing_property_binding"
|
|
124
|
+
| "invalid_property_binding"
|
|
125
|
+
>
|
|
126
|
+
}
|
|
127
|
+
|
|
116
128
|
export type CustomBlockHostHandle = {
|
|
117
129
|
stop: () => void
|
|
118
|
-
setTheme: (theme:
|
|
119
|
-
setContrastMode: (
|
|
120
|
-
contrastMode: InferInput<typeof notionContrastModeSchema>,
|
|
121
|
-
) => void
|
|
130
|
+
setTheme: (theme: NotionTheme) => void
|
|
131
|
+
setContrastMode: (contrastMode: NotionContrastMode) => void
|
|
122
132
|
setParent: (parent: InferInput<typeof notionParentSchema>) => void
|
|
123
133
|
setPage: (page: InferInput<typeof customBlockPageSchema>) => void
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Reports synchronous local acceptance, not sandbox delivery or initialization success.
|
|
136
|
+
* Malformed bindings can throw during schema parsing.
|
|
137
|
+
*/
|
|
138
|
+
setDataSources: (
|
|
139
|
+
dataSources: CustomBlockHostDataSourcesPayload,
|
|
140
|
+
) => CustomBlockHostSetDataSourcesResult
|
|
141
|
+
setCurrentUser: (currentUser: BridgeUser) => void
|
|
142
|
+
refreshQuery: (args: { dataSourceId: string }) => void
|
|
129
143
|
}
|
|
130
144
|
|
|
131
145
|
/**
|
|
@@ -168,7 +182,7 @@ export function createCustomBlockHost(
|
|
|
168
182
|
let pendingState: HostStateUpdates = {}
|
|
169
183
|
let hasPreparedInitialState = false
|
|
170
184
|
const preparationController = new AbortController()
|
|
171
|
-
let manifest:
|
|
185
|
+
let manifest: BridgeCustomBlockManifest | undefined
|
|
172
186
|
let activeDataSources: CustomBlockHostNormalizedDataSourcesPayload | undefined
|
|
173
187
|
let sandboxBridgeProtocolVersion = LATEST_BRIDGE_PROTOCOL_VERSION
|
|
174
188
|
const querySubscriptions = new QuerySubscriptions(subscriptionId => {
|
|
@@ -545,7 +559,7 @@ export function createCustomBlockHost(
|
|
|
545
559
|
}
|
|
546
560
|
|
|
547
561
|
async function prepare(
|
|
548
|
-
connectManifest:
|
|
562
|
+
connectManifest: BridgeCustomBlockManifest | undefined,
|
|
549
563
|
): Promise<CustomBlockHostInitialStateResult> {
|
|
550
564
|
preparationController.signal.throwIfAborted()
|
|
551
565
|
const manifestResult = await resolveManifest({
|
|
@@ -669,23 +683,27 @@ export function createCustomBlockHost(
|
|
|
669
683
|
const normalizedDataSources: CustomBlockHostNormalizedDataSourcesPayload =
|
|
670
684
|
{
|
|
671
685
|
bindings: v.parse(
|
|
672
|
-
|
|
686
|
+
bridgeDataSourceBindingsSchema,
|
|
673
687
|
dataSources.bindings,
|
|
674
688
|
),
|
|
675
689
|
}
|
|
676
|
-
|
|
677
|
-
initializationController.hasConnectedSandbox &&
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
) {
|
|
690
|
+
const bindingError =
|
|
691
|
+
initializationController.hasConnectedSandbox && manifest !== undefined
|
|
692
|
+
? getBindingError(manifest, normalizedDataSources)
|
|
693
|
+
: undefined
|
|
694
|
+
if (bindingError !== undefined) {
|
|
681
695
|
emit("warn", {
|
|
682
696
|
message: "Ignored invalid data source bindings update",
|
|
683
697
|
payload: normalizedDataSources,
|
|
684
698
|
})
|
|
685
|
-
return
|
|
699
|
+
return {
|
|
700
|
+
status: "error",
|
|
701
|
+
error: bindingError,
|
|
702
|
+
}
|
|
686
703
|
}
|
|
687
704
|
activeDataSources = normalizedDataSources
|
|
688
705
|
updateHostState({ dataSources: normalizedDataSources })
|
|
706
|
+
return { status: "success" }
|
|
689
707
|
},
|
|
690
708
|
refreshQuery({ dataSourceId }) {
|
|
691
709
|
if (initializationController.status !== "initialized") {
|
|
@@ -742,30 +760,32 @@ function getCollectionSchema(
|
|
|
742
760
|
}
|
|
743
761
|
|
|
744
762
|
function getBindingError(
|
|
745
|
-
manifest:
|
|
763
|
+
manifest: BridgeCustomBlockManifest,
|
|
746
764
|
dataSources: CustomBlockHostDataSourcesPayload,
|
|
747
|
-
)
|
|
765
|
+
) {
|
|
748
766
|
for (const [dataSourceKey, manifestDataSource] of Object.entries(
|
|
749
767
|
manifest.dataSources,
|
|
750
768
|
)) {
|
|
751
769
|
const binding = dataSources.bindings[dataSourceKey]
|
|
770
|
+
if (binding?.inaccessible === true) {
|
|
771
|
+
continue
|
|
772
|
+
}
|
|
773
|
+
const resolvedBinding = resolveDataSourceBinding({
|
|
774
|
+
manifestDataSource,
|
|
775
|
+
collectionSchema: binding?.collectionSchema,
|
|
776
|
+
propertyIdsByKey: binding?.propertyIdsByKey,
|
|
777
|
+
})
|
|
752
778
|
if (
|
|
753
779
|
binding?.collectionPointer === undefined ||
|
|
754
|
-
|
|
780
|
+
resolvedBinding.status === "missing_schema"
|
|
755
781
|
) {
|
|
756
782
|
return missingDataSourceBindingError()
|
|
757
783
|
}
|
|
758
|
-
for (const
|
|
759
|
-
|
|
760
|
-
)) {
|
|
761
|
-
const propertyId = binding.propertyIdsByKey?.[propertyKey]
|
|
762
|
-
if (propertyId === undefined) {
|
|
784
|
+
for (const property of resolvedBinding.properties) {
|
|
785
|
+
if (property.status === "missing") {
|
|
763
786
|
return missingPropertyBindingError()
|
|
764
787
|
}
|
|
765
|
-
if (
|
|
766
|
-
binding.collectionSchema.propertiesById[propertyId]?.type !==
|
|
767
|
-
manifestProperty.type
|
|
768
|
-
) {
|
|
788
|
+
if (property.status !== "mapped") {
|
|
769
789
|
return invalidPropertyBindingError()
|
|
770
790
|
}
|
|
771
791
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NotionPropertyType } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
1
|
+
import type { NotionPropertyType } from "@notionhq/custom-blocks-protocol/dataSources/properties/propertySchema.js"
|
|
2
2
|
|
|
3
3
|
export type AutoBindableProperty = {
|
|
4
4
|
name: string
|
|
@@ -3,8 +3,8 @@ import type {
|
|
|
3
3
|
NotionDateRange,
|
|
4
4
|
NotionDateTime,
|
|
5
5
|
NotionDateTimeRange,
|
|
6
|
-
} from "@notionhq/custom-blocks-protocol/dataSources/dateValue.js"
|
|
7
|
-
import type { NotionDateInput } from "@notionhq/custom-blocks-protocol/pages/
|
|
6
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/properties/dateValue.js"
|
|
7
|
+
import type { NotionDateInput } from "@notionhq/custom-blocks-protocol/pages/properties/dateInput.js"
|
|
8
8
|
|
|
9
9
|
export type CustomBlockDateValue =
|
|
10
10
|
| NotionDate
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
2
|
+
import type { NotionDataSourceId } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
3
3
|
|
|
4
4
|
export type QueryRefresh = {
|
|
5
5
|
message: QueryDataSourceMessage
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { bridgeDataSourceBindingsSchema } from "@notionhq/custom-blocks-protocol/dataSources/bridgeDataSourceBindings.js"
|
|
2
|
+
import type { queryDataSourceMessageSchema } from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
3
|
+
import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
4
|
+
import type * as v from "valibot"
|
|
5
|
+
import type { InferInput } from "valibot"
|
|
6
|
+
import type { CustomBlockHostResult } from "../messages/result.js"
|
|
7
|
+
|
|
8
|
+
export type QueryDataSourceMessageInput = InferInput<
|
|
9
|
+
typeof queryDataSourceMessageSchema
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
export type CustomBlockHostDataSourcesPayload = {
|
|
13
|
+
bindings: v.InferInput<typeof bridgeDataSourceBindingsSchema>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type CustomBlockHostNormalizedDataSourcesPayload = {
|
|
17
|
+
bindings: v.InferOutput<typeof bridgeDataSourceBindingsSchema>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type CustomBlockHostQueryDataSourceResult = CustomBlockHostResult<{
|
|
21
|
+
items: BridgePage[]
|
|
22
|
+
hasMore: boolean
|
|
23
|
+
}>
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
8
|
-
import { customBlockRelationFilterOperatorSchema } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
9
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
1
|
+
import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/collectionSchema.js"
|
|
2
|
+
import type { BridgeDataSourceFilter } from "@notionhq/custom-blocks-protocol/dataSources/filters/bridgeDataSourceFilter.js"
|
|
3
|
+
import type { BridgeDataSourceFilterCondition } from "@notionhq/custom-blocks-protocol/dataSources/filters/bridgeDataSourceFilterCondition.js"
|
|
4
|
+
import type { CustomBlockContainsFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/containsFilterOperator.js"
|
|
5
|
+
import type { CustomBlockOptionFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/optionFilterOperator.js"
|
|
6
|
+
import { customBlockRelationFilterOperatorSchema } from "@notionhq/custom-blocks-protocol/dataSources/filters/relationFilterOperator.js"
|
|
7
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
10
8
|
import { is } from "valibot"
|
|
11
|
-
import { unreachable } from "
|
|
9
|
+
import { unreachable } from "../../utils/unreachable.js"
|
|
12
10
|
|
|
13
11
|
type OptionFilterOperator =
|
|
14
12
|
| CustomBlockOptionFilterOperator
|
|
15
13
|
| CustomBlockContainsFilterOperator
|
|
16
14
|
|
|
17
15
|
export function validateQueryDataSourceFilter(
|
|
18
|
-
filter:
|
|
16
|
+
filter: BridgeDataSourceFilter | undefined,
|
|
19
17
|
collectionSchema: NotionCollectionSchema,
|
|
20
18
|
): CustomBlockQueryDataSourceErrorInfo | undefined {
|
|
21
19
|
if (filter === undefined) {
|
|
@@ -33,7 +31,7 @@ export function validateQueryDataSourceFilter(
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
function validatePropertyFilter(
|
|
36
|
-
filter:
|
|
34
|
+
filter: BridgeDataSourceFilterCondition,
|
|
37
35
|
collectionSchema: NotionCollectionSchema,
|
|
38
36
|
): CustomBlockQueryDataSourceErrorInfo | undefined {
|
|
39
37
|
if (!Object.hasOwn(collectionSchema.propertiesById, filter.propertyId)) {
|
|
@@ -109,7 +107,7 @@ function validatePropertyFilter(
|
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
function getOptionFilter(filter:
|
|
110
|
+
function getOptionFilter(filter: BridgeDataSourceFilterCondition):
|
|
113
111
|
| {
|
|
114
112
|
propertyType: "select" | "multi_select" | "status"
|
|
115
113
|
operator: OptionFilterOperator
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
7
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
1
|
+
import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/collectionSchema.js"
|
|
2
|
+
import type { BridgeDataSourceSort } from "@notionhq/custom-blocks-protocol/dataSources/filters/bridgeDataSourceSort.js"
|
|
3
|
+
import { CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS } from "@notionhq/custom-blocks-protocol/dataSources/filters/bridgeDataSourceSort.js"
|
|
4
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
5
|
+
import { CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES } from "@notionhq/custom-blocks-protocol/dataSources/properties/propertySchema.js"
|
|
8
6
|
|
|
9
7
|
const supportedDataSourceSortPropertyTypes = new Set<string>(
|
|
10
8
|
CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES,
|
|
@@ -14,7 +12,7 @@ const supportedDataSourceSortPropertyTypes = new Set<string>(
|
|
|
14
12
|
* Ensures the sorts of a data source query are valid.
|
|
15
13
|
*/
|
|
16
14
|
export function validateQueryDataSourceSorts(
|
|
17
|
-
sorts:
|
|
15
|
+
sorts: BridgeDataSourceSort[] | undefined,
|
|
18
16
|
collectionSchema: NotionCollectionSchema,
|
|
19
17
|
): CustomBlockQueryDataSourceErrorInfo | undefined {
|
|
20
18
|
if (sorts === undefined) {
|
package/src/index.ts
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export type {
|
|
2
|
+
CustomBlockHostInitialState,
|
|
3
|
+
CustomBlockHostInitialStateResult,
|
|
4
|
+
CustomBlockHostPreparedStateResult,
|
|
5
|
+
CustomBlockHostPrepareInitialState,
|
|
6
|
+
} from "./context/initialState.js"
|
|
7
|
+
export type { ResizeMessageInput } from "./context/resize.js"
|
|
5
8
|
export {
|
|
6
9
|
type CustomBlockHostHandle,
|
|
7
10
|
type CustomBlockHostOptions,
|
|
11
|
+
type CustomBlockHostSetDataSourcesResult,
|
|
8
12
|
createCustomBlockHost,
|
|
9
13
|
} from "./createCustomBlockHost.js"
|
|
14
|
+
export {
|
|
15
|
+
type AutoBindableProperty,
|
|
16
|
+
getAutoBoundPropertyIdsByKey,
|
|
17
|
+
} from "./dataSources/bindings/getAutoBoundPropertyIdsByKey.js"
|
|
10
18
|
export {
|
|
11
19
|
type CustomBlockDateValue,
|
|
12
20
|
InvalidNotionDateError,
|
|
13
21
|
toNotionDateValue,
|
|
14
|
-
} from "./
|
|
15
|
-
export { toNotionPageId } from "./ids.js"
|
|
16
|
-
export { isAllowedLocalPreviewUrl } from "./isAllowedLocalPreviewUrl.js"
|
|
22
|
+
} from "./dataSources/properties/toNotionDateValue.js"
|
|
17
23
|
export type {
|
|
18
24
|
CustomBlockHostDataSourcesPayload,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
CustomBlockHostQueryDataSourceResult,
|
|
26
|
+
QueryDataSourceMessageInput,
|
|
27
|
+
} from "./dataSources/types.js"
|
|
28
|
+
export { isAllowedLocalPreviewUrl } from "./lifecycle/isAllowedLocalPreviewUrl.js"
|
|
29
|
+
export type {
|
|
30
|
+
CustomBlockHostFailure,
|
|
24
31
|
CustomBlockHostStatus,
|
|
25
|
-
CustomBlockManifestSource,
|
|
26
32
|
} from "./lifecycle/types.js"
|
|
27
33
|
export type {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
CustomBlockHostLogDirection,
|
|
34
|
+
CustomBlockHostManifestResult,
|
|
35
|
+
CustomBlockManifestSource,
|
|
36
|
+
} from "./manifest/types.js"
|
|
37
|
+
export type { CustomBlockHostHandlers } from "./messages/handlers.js"
|
|
38
|
+
export type { CustomBlockHostLogDirection } from "./messages/logging.js"
|
|
39
|
+
export type { CustomBlockHostResult } from "./messages/result.js"
|
|
40
|
+
export type {
|
|
36
41
|
CustomBlockHostNavigationContext,
|
|
37
|
-
|
|
42
|
+
OpenExternalUrlMessageInput,
|
|
43
|
+
} from "./navigation/types.js"
|
|
44
|
+
export type {
|
|
45
|
+
CreatePageMessageInput,
|
|
38
46
|
CustomBlockHostOpenPageResult,
|
|
39
|
-
|
|
47
|
+
CustomBlockHostPageResult,
|
|
40
48
|
GetPageMessageInput,
|
|
41
|
-
GetUserMessageInput,
|
|
42
|
-
ListUsersMessageInput,
|
|
43
|
-
OpenExternalUrlMessageInput,
|
|
44
49
|
OpenPageMessageInput,
|
|
45
|
-
QueryDataSourceMessageInput,
|
|
46
|
-
ResizeMessageInput,
|
|
47
50
|
UpdatePageMessageInput,
|
|
48
|
-
} from "./
|
|
49
|
-
export type {
|
|
51
|
+
} from "./pages/types.js"
|
|
52
|
+
export type {
|
|
53
|
+
CustomBlockHostUserListResult,
|
|
54
|
+
CustomBlockHostUserResult,
|
|
55
|
+
GetUserMessageInput,
|
|
56
|
+
ListUsersMessageInput,
|
|
57
|
+
} from "./users/types.js"
|
|
58
|
+
export { toNotionPageId } from "./utils/toNotionPageId.js"
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import { DEFAULT_CONTRAST_MODE } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
-
import type { ConnectMessage } from "@notionhq/custom-blocks-protocol/
|
|
1
|
+
import { DEFAULT_CONTRAST_MODE } from "@notionhq/custom-blocks-protocol/context/contrast.js"
|
|
2
|
+
import type { ConnectMessage } from "@notionhq/custom-blocks-protocol/handshake/connect.js"
|
|
3
3
|
import type {
|
|
4
4
|
CustomBlockInitErrorInfo,
|
|
5
5
|
initMessageSchema,
|
|
6
|
-
} from "@notionhq/custom-blocks-protocol/
|
|
7
|
-
import type { InitResultMessage } from "@notionhq/custom-blocks-protocol/
|
|
6
|
+
} from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
7
|
+
import type { InitResultMessage } from "@notionhq/custom-blocks-protocol/handshake/initResult.js"
|
|
8
8
|
import type { InferInput } from "valibot"
|
|
9
|
-
import type {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "./
|
|
19
|
-
import {
|
|
20
|
-
import type {
|
|
21
|
-
CustomBlockHostInitialStateResult,
|
|
22
|
-
CustomBlockManifestSource,
|
|
23
|
-
InitStatus,
|
|
24
|
-
} from "./types.js"
|
|
9
|
+
import type { CustomBlockHostInitialStateResult } from "../context/initialState.js"
|
|
10
|
+
import type { CustomBlockManifestSource } from "../manifest/types.js"
|
|
11
|
+
import { unreachable } from "../utils/unreachable.js"
|
|
12
|
+
import { initialStateTimeoutError } from "./errors/initialStateTimeoutError.js"
|
|
13
|
+
import { invalidProtocolVersionError } from "./errors/invalidProtocolVersionError.js"
|
|
14
|
+
import { noConnectError } from "./errors/noConnectError.js"
|
|
15
|
+
import { noInitResultError } from "./errors/noInitResultError.js"
|
|
16
|
+
import { unknownInitializationError } from "./errors/unknownInitializationError.js"
|
|
17
|
+
import { unsupportedProtocolVersionError } from "./errors/unsupportedProtocolVersionError.js"
|
|
18
|
+
import { isValidBridgeProtocolVersion } from "./isValidBridgeProtocolVersion.js"
|
|
19
|
+
import type { CustomBlockHostFailure, InitStatus } from "./types.js"
|
|
25
20
|
|
|
26
21
|
const DEFAULT_NO_CONNECT_TIMEOUT_MS = 5_000
|
|
27
22
|
const DEFAULT_INITIAL_STATE_TIMEOUT_MS = 5_000
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/utils/errors.js"
|
|
2
|
+
|
|
3
|
+
export function contextUnavailableError(): CustomBlockErrorInfo<"context_unavailable"> {
|
|
4
|
+
return {
|
|
5
|
+
code: "context_unavailable",
|
|
6
|
+
message: "Host page context is unavailable.",
|
|
7
|
+
// Page context may become available before a fresh initialization attempt.
|
|
8
|
+
isRetryable: true,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/utils/errors.js"
|
|
2
|
+
|
|
3
|
+
export function initialStateTimeoutError(): CustomBlockErrorInfo<"initial_state_timeout"> {
|
|
4
|
+
return {
|
|
5
|
+
code: "initial_state_timeout",
|
|
6
|
+
message: "Host did not prepare initial state before the timeout.",
|
|
7
|
+
// A fresh attempt may finish loading host dependencies before the timeout.
|
|
8
|
+
isRetryable: true,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/utils/errors.js"
|
|
2
|
+
|
|
3
|
+
export function invalidConnectPayloadError(): CustomBlockErrorInfo<"invalid_connect_payload"> {
|
|
4
|
+
return {
|
|
5
|
+
code: "invalid_connect_payload",
|
|
6
|
+
message: "Sandbox sent an invalid connect message.",
|
|
7
|
+
// The sandbox must be updated to send a valid connect message.
|
|
8
|
+
isRetryable: false,
|
|
9
|
+
}
|
|
10
|
+
}
|