@notionhq/custom-blocks-host 0.4.2 → 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} +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 +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} +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 +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 +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 +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 +16 -1
- package/docs/bridge/versioning.md +2 -2
- package/docs/handlers.md +2 -2
- 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 +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/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
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Notion page shapes exchanged over the custom block bridge.
|
|
3
|
-
*
|
|
4
|
-
* These mirror a narrow subset of Notion's public `POST /v1/pages` API, since that's the bridge
|
|
5
|
-
* shape the host delivers for messages like `createPageResult`.
|
|
6
|
-
*/
|
|
7
|
-
import * as v from "valibot";
|
|
8
|
-
import { notionDateReminderSchema, notionDateTimeReminderSchema, notionDisabledReminderSchema, } from "../dataSources/dateValue.js";
|
|
9
|
-
import { notionRecordPointerSchema } from "../dataSources/recordPointer.js";
|
|
10
|
-
import { notionPageIdSchema } from "../ids.js";
|
|
11
|
-
import { notionParentSchema } from "../parent.js";
|
|
12
|
-
/**
|
|
13
|
-
* The custom block's nearest enclosing page ancestor, carried in `init.page` and `pageChanged`.
|
|
14
|
-
*/
|
|
15
|
-
export const customBlockPageSchema = v.variant("type", [
|
|
16
|
-
/** The viewer cannot access the containing page; its ID and parent are not exposed. */
|
|
17
|
-
v.object({ type: v.literal("unavailable") }),
|
|
18
|
-
/** The viewer can access the containing page; includes its ID and parent location. */
|
|
19
|
-
v.object({
|
|
20
|
-
type: v.literal("page"),
|
|
21
|
-
id: notionPageIdSchema,
|
|
22
|
-
/**
|
|
23
|
-
* The containing page's own parent. It lets a block distinguish a freestanding page from a
|
|
24
|
-
* database row without a round trip. Not to be confused with the top-level `parent` runtime
|
|
25
|
-
* value, which is the custom block's own parent.
|
|
26
|
-
*/
|
|
27
|
-
parent: notionParentSchema,
|
|
28
|
-
}),
|
|
29
|
-
]);
|
|
30
|
-
export const notionEmojiIconSchema = v.object({
|
|
31
|
-
type: v.literal("emoji"),
|
|
32
|
-
emoji: v.string(),
|
|
33
|
-
});
|
|
34
|
-
export const notionCustomEmojiIconSchema = v.object({
|
|
35
|
-
type: v.literal("custom_emoji"),
|
|
36
|
-
custom_emoji: v.object({
|
|
37
|
-
id: v.string(),
|
|
38
|
-
name: v.optional(v.string()),
|
|
39
|
-
url: v.optional(v.string()),
|
|
40
|
-
}),
|
|
41
|
-
});
|
|
42
|
-
export const notionExternalFileSchema = v.object({
|
|
43
|
-
type: v.literal("external"),
|
|
44
|
-
external: v.object({ url: v.string() }),
|
|
45
|
-
});
|
|
46
|
-
export const notionHostedFileSchema = v.object({
|
|
47
|
-
type: v.literal("file"),
|
|
48
|
-
file: v.object({
|
|
49
|
-
url: v.string(),
|
|
50
|
-
expiry_time: v.optional(v.string()),
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
export const notionPageIconSchema = v.variant("type", [
|
|
54
|
-
notionEmojiIconSchema,
|
|
55
|
-
notionCustomEmojiIconSchema,
|
|
56
|
-
notionExternalFileSchema,
|
|
57
|
-
notionHostedFileSchema,
|
|
58
|
-
]);
|
|
59
|
-
export const notionPageCoverSchema = v.variant("type", [
|
|
60
|
-
notionExternalFileSchema,
|
|
61
|
-
notionHostedFileSchema,
|
|
62
|
-
]);
|
|
63
|
-
const nullableStringSchema = v.nullable(v.string());
|
|
64
|
-
const notionRichTextItemSchema = v.record(v.string(), v.unknown());
|
|
65
|
-
const notionSelectOptionInputSchema = v.union([
|
|
66
|
-
v.object({
|
|
67
|
-
id: v.string(),
|
|
68
|
-
name: v.optional(v.string()),
|
|
69
|
-
color: v.optional(v.string()),
|
|
70
|
-
description: v.optional(nullableStringSchema),
|
|
71
|
-
}),
|
|
72
|
-
v.object({
|
|
73
|
-
name: v.string(),
|
|
74
|
-
id: v.optional(v.string()),
|
|
75
|
-
color: v.optional(v.string()),
|
|
76
|
-
description: v.optional(nullableStringSchema),
|
|
77
|
-
}),
|
|
78
|
-
]);
|
|
79
|
-
const dateInputEntries = {
|
|
80
|
-
start: v.string(),
|
|
81
|
-
end: v.optional(nullableStringSchema),
|
|
82
|
-
time_zone: v.optional(nullableStringSchema),
|
|
83
|
-
reminder: v.optional(v.union([notionDateTimeReminderSchema, notionDisabledReminderSchema])),
|
|
84
|
-
};
|
|
85
|
-
const notionDateInputSchema = v.union([
|
|
86
|
-
v.object({
|
|
87
|
-
...dateInputEntries,
|
|
88
|
-
start: v.pipe(v.string(), v.includes("T")),
|
|
89
|
-
}),
|
|
90
|
-
v.object({
|
|
91
|
-
...dateInputEntries,
|
|
92
|
-
time_zone: v.string(),
|
|
93
|
-
}),
|
|
94
|
-
v.object({
|
|
95
|
-
...dateInputEntries,
|
|
96
|
-
reminder: v.optional(v.union([notionDateReminderSchema, notionDisabledReminderSchema])),
|
|
97
|
-
}),
|
|
98
|
-
]);
|
|
99
|
-
const notionUserInputSchema = v.union([
|
|
100
|
-
v.object({
|
|
101
|
-
object: v.optional(v.literal("user")),
|
|
102
|
-
id: v.string(),
|
|
103
|
-
}),
|
|
104
|
-
v.object({
|
|
105
|
-
object: v.literal("group"),
|
|
106
|
-
id: v.string(),
|
|
107
|
-
name: v.optional(nullableStringSchema),
|
|
108
|
-
}),
|
|
109
|
-
]);
|
|
110
|
-
const notionRelationInputSchema = v.object({ id: v.string() });
|
|
111
|
-
const notionFileInputSchema = v.union([
|
|
112
|
-
v.object({
|
|
113
|
-
type: v.literal("external"),
|
|
114
|
-
name: v.string(),
|
|
115
|
-
external: v.object({ url: v.string() }),
|
|
116
|
-
}),
|
|
117
|
-
v.object({
|
|
118
|
-
type: v.literal("file"),
|
|
119
|
-
name: v.string(),
|
|
120
|
-
file: v.object({
|
|
121
|
-
url: v.string(),
|
|
122
|
-
expiry_time: v.optional(v.string()),
|
|
123
|
-
}),
|
|
124
|
-
}),
|
|
125
|
-
]);
|
|
126
|
-
const notionPlaceInputSchema = v.object({
|
|
127
|
-
lat: v.number(),
|
|
128
|
-
lon: v.number(),
|
|
129
|
-
name: v.optional(nullableStringSchema),
|
|
130
|
-
address: v.optional(nullableStringSchema),
|
|
131
|
-
aws_place_id: v.optional(nullableStringSchema),
|
|
132
|
-
google_place_id: v.optional(nullableStringSchema),
|
|
133
|
-
});
|
|
134
|
-
const pagePropertyBaseSchema = {
|
|
135
|
-
id: v.string(),
|
|
136
|
-
};
|
|
137
|
-
// TODO(custom-blocks): Make spaceId required for metadataActor
|
|
138
|
-
const metadataActorSchema = v.nullable(v.object({
|
|
139
|
-
...notionRecordPointerSchema.entries,
|
|
140
|
-
table: v.picklist(["notion_user", "bot", "organization_bot"]),
|
|
141
|
-
spaceId: v.optional(v.string()),
|
|
142
|
-
}));
|
|
143
|
-
/**
|
|
144
|
-
* A page property value.
|
|
145
|
-
*/
|
|
146
|
-
export const notionPagePropertyValueSchema = v.variant("type", [
|
|
147
|
-
v.object({
|
|
148
|
-
...pagePropertyBaseSchema,
|
|
149
|
-
type: v.literal("title"),
|
|
150
|
-
title: v.array(notionRichTextItemSchema),
|
|
151
|
-
}),
|
|
152
|
-
v.object({
|
|
153
|
-
...pagePropertyBaseSchema,
|
|
154
|
-
type: v.literal("rich_text"),
|
|
155
|
-
rich_text: v.array(notionRichTextItemSchema),
|
|
156
|
-
}),
|
|
157
|
-
v.object({
|
|
158
|
-
...pagePropertyBaseSchema,
|
|
159
|
-
type: v.literal("number"),
|
|
160
|
-
number: v.nullable(v.number()),
|
|
161
|
-
}),
|
|
162
|
-
v.object({
|
|
163
|
-
...pagePropertyBaseSchema,
|
|
164
|
-
type: v.literal("url"),
|
|
165
|
-
url: nullableStringSchema,
|
|
166
|
-
}),
|
|
167
|
-
v.object({
|
|
168
|
-
...pagePropertyBaseSchema,
|
|
169
|
-
type: v.literal("email"),
|
|
170
|
-
email: nullableStringSchema,
|
|
171
|
-
}),
|
|
172
|
-
v.object({
|
|
173
|
-
...pagePropertyBaseSchema,
|
|
174
|
-
type: v.literal("phone_number"),
|
|
175
|
-
phone_number: nullableStringSchema,
|
|
176
|
-
}),
|
|
177
|
-
v.object({
|
|
178
|
-
...pagePropertyBaseSchema,
|
|
179
|
-
type: v.literal("checkbox"),
|
|
180
|
-
checkbox: v.boolean(),
|
|
181
|
-
}),
|
|
182
|
-
v.object({
|
|
183
|
-
...pagePropertyBaseSchema,
|
|
184
|
-
type: v.literal("select"),
|
|
185
|
-
select: v.nullable(notionSelectOptionInputSchema),
|
|
186
|
-
}),
|
|
187
|
-
v.object({
|
|
188
|
-
...pagePropertyBaseSchema,
|
|
189
|
-
type: v.literal("status"),
|
|
190
|
-
status: v.nullable(notionSelectOptionInputSchema),
|
|
191
|
-
}),
|
|
192
|
-
v.object({
|
|
193
|
-
...pagePropertyBaseSchema,
|
|
194
|
-
type: v.literal("multi_select"),
|
|
195
|
-
multi_select: v.array(notionSelectOptionInputSchema),
|
|
196
|
-
}),
|
|
197
|
-
v.object({
|
|
198
|
-
...pagePropertyBaseSchema,
|
|
199
|
-
type: v.literal("date"),
|
|
200
|
-
date: v.nullable(notionDateInputSchema),
|
|
201
|
-
}),
|
|
202
|
-
v.object({
|
|
203
|
-
...pagePropertyBaseSchema,
|
|
204
|
-
type: v.literal("people"),
|
|
205
|
-
people: v.array(notionUserInputSchema),
|
|
206
|
-
}),
|
|
207
|
-
v.object({
|
|
208
|
-
...pagePropertyBaseSchema,
|
|
209
|
-
type: v.literal("relation"),
|
|
210
|
-
has_more: v.optional(v.boolean()),
|
|
211
|
-
relation: v.array(notionRelationInputSchema),
|
|
212
|
-
}),
|
|
213
|
-
v.object({
|
|
214
|
-
...pagePropertyBaseSchema,
|
|
215
|
-
type: v.literal("files"),
|
|
216
|
-
files: v.array(notionFileInputSchema),
|
|
217
|
-
}),
|
|
218
|
-
v.object({
|
|
219
|
-
...pagePropertyBaseSchema,
|
|
220
|
-
type: v.literal("place"),
|
|
221
|
-
place: v.nullable(notionPlaceInputSchema),
|
|
222
|
-
}),
|
|
223
|
-
v.object({
|
|
224
|
-
...pagePropertyBaseSchema,
|
|
225
|
-
type: v.literal("created_time"),
|
|
226
|
-
created_time: nullableStringSchema,
|
|
227
|
-
}),
|
|
228
|
-
v.object({
|
|
229
|
-
...pagePropertyBaseSchema,
|
|
230
|
-
type: v.literal("last_edited_time"),
|
|
231
|
-
last_edited_time: nullableStringSchema,
|
|
232
|
-
}),
|
|
233
|
-
v.object({
|
|
234
|
-
...pagePropertyBaseSchema,
|
|
235
|
-
type: v.literal("created_by"),
|
|
236
|
-
created_by: metadataActorSchema,
|
|
237
|
-
}),
|
|
238
|
-
v.object({
|
|
239
|
-
...pagePropertyBaseSchema,
|
|
240
|
-
type: v.literal("last_edited_by"),
|
|
241
|
-
last_edited_by: metadataActorSchema,
|
|
242
|
-
}),
|
|
243
|
-
v.object({
|
|
244
|
-
...pagePropertyBaseSchema,
|
|
245
|
-
type: v.literal("last_visited_time"),
|
|
246
|
-
last_visited_time: nullableStringSchema,
|
|
247
|
-
}),
|
|
248
|
-
v.object({
|
|
249
|
-
...pagePropertyBaseSchema,
|
|
250
|
-
type: v.literal("unique_id"),
|
|
251
|
-
unique_id: v.string(),
|
|
252
|
-
}),
|
|
253
|
-
v.object({
|
|
254
|
-
...pagePropertyBaseSchema,
|
|
255
|
-
type: v.literal("button"),
|
|
256
|
-
button: v.string(),
|
|
257
|
-
}),
|
|
258
|
-
v.object({
|
|
259
|
-
...pagePropertyBaseSchema,
|
|
260
|
-
type: v.literal("formula"),
|
|
261
|
-
formula: v.string(),
|
|
262
|
-
}),
|
|
263
|
-
v.object({
|
|
264
|
-
...pagePropertyBaseSchema,
|
|
265
|
-
type: v.literal("location"),
|
|
266
|
-
location: v.string(),
|
|
267
|
-
}),
|
|
268
|
-
v.object({
|
|
269
|
-
...pagePropertyBaseSchema,
|
|
270
|
-
type: v.literal("rollup"),
|
|
271
|
-
rollup: v.string(),
|
|
272
|
-
}),
|
|
273
|
-
v.object({
|
|
274
|
-
...pagePropertyBaseSchema,
|
|
275
|
-
type: v.literal("verification"),
|
|
276
|
-
verification: v.string(),
|
|
277
|
-
}),
|
|
278
|
-
]);
|
|
279
|
-
export const notionPagePropertyWriteMapSchema = v.record(v.string(), notionPagePropertyValueSchema);
|
|
280
|
-
export const notionPagePropertyReadMapSchema = v.record(v.string(), v.nullable(notionPagePropertyValueSchema));
|
|
281
|
-
/**
|
|
282
|
-
* The `Page` object returned in `createPageResult` messages.
|
|
283
|
-
*/
|
|
284
|
-
export const bridgePageSchema = v.object({
|
|
285
|
-
object: v.literal("page"),
|
|
286
|
-
id: notionPageIdSchema,
|
|
287
|
-
parent: notionParentSchema,
|
|
288
|
-
properties: notionPagePropertyReadMapSchema,
|
|
289
|
-
created_by: v.optional(metadataActorSchema, null),
|
|
290
|
-
last_edited_by: v.optional(metadataActorSchema, null),
|
|
291
|
-
last_visited_time: v.optional(v.nullable(v.string()), null),
|
|
292
|
-
created_time: v.optional(v.nullable(v.string()), null),
|
|
293
|
-
last_edited_time: v.optional(v.nullable(v.string()), null),
|
|
294
|
-
icon: v.optional(v.nullable(notionPageIconSchema), null),
|
|
295
|
-
cover: v.optional(v.nullable(notionPageCoverSchema), null),
|
|
296
|
-
url: v.optional(v.nullable(v.string()), null),
|
|
297
|
-
public_url: v.optional(v.nullable(v.string()), null),
|
|
298
|
-
/** Whether the page or an ancestor is archived. */
|
|
299
|
-
is_archived: v.boolean(),
|
|
300
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
301
|
-
in_trash: v.boolean(),
|
|
302
|
-
});
|
|
303
|
-
export const notionPageForProtocol3To5Schema = v.object({
|
|
304
|
-
object: v.literal("page"),
|
|
305
|
-
id: notionPageIdSchema,
|
|
306
|
-
parent: notionParentSchema,
|
|
307
|
-
properties: notionPagePropertyWriteMapSchema,
|
|
308
|
-
created_time: v.optional(v.string()),
|
|
309
|
-
last_edited_time: v.optional(v.string()),
|
|
310
|
-
icon: v.optional(notionPageIconSchema),
|
|
311
|
-
cover: v.optional(notionPageCoverSchema),
|
|
312
|
-
url: v.optional(v.string()),
|
|
313
|
-
public_url: v.optional(v.string()),
|
|
314
|
-
/** Whether the page or an ancestor is archived. */
|
|
315
|
-
is_archived: v.boolean(),
|
|
316
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
317
|
-
in_trash: v.boolean(),
|
|
318
|
-
});
|
package/dist/protocol/parent.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
import { notionAgentIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, } from "./ids.js";
|
|
3
|
-
export const notionParentSchema = v.variant("type", [
|
|
4
|
-
v.object({ type: v.literal("page_id"), page_id: notionPageIdSchema }),
|
|
5
|
-
v.object({
|
|
6
|
-
type: v.literal("data_source_id"),
|
|
7
|
-
data_source_id: notionDataSourceIdSchema,
|
|
8
|
-
}),
|
|
9
|
-
v.object({ type: v.literal("workspace"), workspace: v.literal(true) }),
|
|
10
|
-
v.object({ type: v.literal("block_id"), block_id: notionBlockIdSchema }),
|
|
11
|
-
v.object({ type: v.literal("agent_id"), agent_id: notionAgentIdSchema }),
|
|
12
|
-
v.object({ type: v.literal("unavailable") }),
|
|
13
|
-
]);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const notionUserIdSchema = v.pipe(v.string(), v.brand("NotionUserId"));
|
|
3
|
-
export const notionUserSchema = v.object({
|
|
4
|
-
object: v.literal("user"),
|
|
5
|
-
id: notionUserIdSchema,
|
|
6
|
-
name: v.optional(v.string()),
|
|
7
|
-
avatar_url: v.nullable(v.string()),
|
|
8
|
-
type: v.literal("person"),
|
|
9
|
-
person: v.object({
|
|
10
|
-
email: v.string(),
|
|
11
|
-
}),
|
|
12
|
-
});
|
|
13
|
-
export const notionUserListSchema = v.object({
|
|
14
|
-
object: v.literal("list"),
|
|
15
|
-
results: v.array(notionUserSchema),
|
|
16
|
-
next_cursor: v.nullable(v.string()),
|
|
17
|
-
has_more: v.boolean(),
|
|
18
|
-
type: v.literal("user"),
|
|
19
|
-
user: v.record(v.string(), v.unknown()),
|
|
20
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocolVersion.d.ts","sourceRoot":"","sources":["../src/protocolVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,0CAA0C,IAAI,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"querySubscriptions.d.ts","sourceRoot":"","sources":["../../src/queries/querySubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAE1G,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,sBAAsB,CAAA;IAC/B,KAAK,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAA;CACvC,CAAA;AASD,qBAAa,kBAAkB;IAI7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAH/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4C;IAE7E,YACkB,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,EAC7D;IAEJ,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,sBAAsB,CAYjE;IAED,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAExE;IAED,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAIxC;IAED,OAAO,CAAC,YAAY,EAAE,kBAAkB,GAAG,YAAY,EAAE,GAAG,SAAS,CAmBpE;IAED,MAAM,CACL,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,sBAAsB,GAC3B,YAAY,GAAG,SAAS,CAY1B;IAED,cAAc,SAIb;CACD"}
|
package/dist/queries/types.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BridgeMessagePayload } from "../protocol/messages/messagePayload.js";
|
|
2
|
-
import type { CustomBlockQueryDataSourceErrorInfo, queryDataSourceResultMessageSchema } from "../protocol/messages/queryDataSourceResult.js";
|
|
3
|
-
import type { InferInput } from "valibot";
|
|
4
|
-
export type CustomBlockHostQueryDataSourceResult = BridgeMessagePayload<InferInput<typeof queryDataSourceResultMessageSchema>, CustomBlockQueryDataSourceErrorInfo>;
|
|
5
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/queries/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,mCAAmC,EACnC,kCAAkC,EAClC,MAAM,oEAAoE,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,oCAAoC,GAAG,oBAAoB,CACtE,UAAU,CAAC,OAAO,kCAAkC,CAAC,EACrD,mCAAmC,CACnC,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { NotionCollectionSchema } from "../protocol/dataSources/dataSource.js";
|
|
2
|
-
import type { ResolvedCustomBlockDataSourceFilter } from "../protocol/messages/queryDataSource.js";
|
|
3
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "../protocol/messages/queryDataSourceResult.js";
|
|
4
|
-
export declare function validateQueryDataSourceFilter(filter: ResolvedCustomBlockDataSourceFilter | undefined, collectionSchema: NotionCollectionSchema): CustomBlockQueryDataSourceErrorInfo | undefined;
|
|
5
|
-
//# sourceMappingURL=validateQueryDataSourceFilter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateQueryDataSourceFilter.d.ts","sourceRoot":"","sources":["../../src/queries/validateQueryDataSourceFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAGX,mCAAmC,EAEnC,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAQ7H,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,mCAAmC,GAAG,SAAS,EACvD,gBAAgB,EAAE,sBAAsB,GACtC,mCAAmC,GAAG,SAAS,CAajD"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { NotionCollectionSchema } from "../protocol/dataSources/dataSource.js";
|
|
2
|
-
import { type ResolvedCustomBlockDataSourceSort } from "../protocol/messages/queryDataSource.js";
|
|
3
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "../protocol/messages/queryDataSourceResult.js";
|
|
4
|
-
/**
|
|
5
|
-
* Ensures the sorts of a data source query are valid.
|
|
6
|
-
*/
|
|
7
|
-
export declare function validateQueryDataSourceSorts(sorts: ResolvedCustomBlockDataSourceSort[] | undefined, collectionSchema: NotionCollectionSchema): CustomBlockQueryDataSourceErrorInfo | undefined;
|
|
8
|
-
//# sourceMappingURL=validateQueryDataSourceSorts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateQueryDataSourceSorts.d.ts","sourceRoot":"","sources":["../../src/queries/validateQueryDataSourceSorts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AAExG,OAAO,EAEN,KAAK,iCAAiC,EACtC,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAM7H;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,iCAAiC,EAAE,GAAG,SAAS,EACtD,gBAAgB,EAAE,sBAAsB,GACtC,mCAAmC,GAAG,SAAS,CAyCjD"}
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAI/C"}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
|
|
2
|
-
import type {
|
|
3
|
-
bridgePageSchema,
|
|
4
|
-
NotionPageForProtocol3To5,
|
|
5
|
-
NotionPagePropertyValue,
|
|
6
|
-
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
7
|
-
import type { InferOutput } from "valibot"
|
|
8
|
-
import { toNotionDateValue } from "../dateValue.js"
|
|
9
|
-
import { unreachable } from "../utils.js"
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Converts current page data to the page-operation format used by protocols 3–5.
|
|
13
|
-
* Keys property objects by raw ID and omits null properties. Optional icons,
|
|
14
|
-
* covers, timestamps, and URLs use undefined instead of null in this format.
|
|
15
|
-
* Call after clearing property objects unsupported by these protocols.
|
|
16
|
-
*
|
|
17
|
-
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
18
|
-
*/
|
|
19
|
-
export function toPageForProtocol3To5(
|
|
20
|
-
page: InferOutput<typeof bridgePageSchema>,
|
|
21
|
-
): NotionPageForProtocol3To5 {
|
|
22
|
-
return {
|
|
23
|
-
...page,
|
|
24
|
-
properties: Object.fromEntries(
|
|
25
|
-
Object.values(page.properties).flatMap(property =>
|
|
26
|
-
property ? [[property.id, property]] : [],
|
|
27
|
-
),
|
|
28
|
-
),
|
|
29
|
-
icon: page.icon ?? undefined,
|
|
30
|
-
cover: page.cover ?? undefined,
|
|
31
|
-
created_time: page.created_time ?? undefined,
|
|
32
|
-
last_edited_time: page.last_edited_time ?? undefined,
|
|
33
|
-
url: page.url ?? undefined,
|
|
34
|
-
public_url: page.public_url ?? undefined,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Converts a current page to a protocol 3–5 query row, keeping its ID and archive
|
|
40
|
-
* flags while flattening typed property objects into raw-ID-keyed values.
|
|
41
|
-
* Copies page creation and edit metadata into the reserved property IDs that
|
|
42
|
-
* these query readers expect.
|
|
43
|
-
*
|
|
44
|
-
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
45
|
-
*/
|
|
46
|
-
export function toQueryPageForProtocol3To5(
|
|
47
|
-
page: InferOutput<typeof bridgePageSchema>,
|
|
48
|
-
) {
|
|
49
|
-
const propertiesById: Record<string, NotionDataSourceValue | undefined> = {}
|
|
50
|
-
for (const property of Object.values(page.properties)) {
|
|
51
|
-
if (property) {
|
|
52
|
-
propertiesById[property.id] = toPropertyValueForProtocol3To5(property)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
id: page.id,
|
|
57
|
-
is_archived: page.is_archived,
|
|
58
|
-
in_trash: page.in_trash,
|
|
59
|
-
// Reserved metadata IDs retain their historical meaning even if an actual
|
|
60
|
-
// property uses the same ID. Binding schemas use the same precedence.
|
|
61
|
-
propertiesById: {
|
|
62
|
-
...propertiesById,
|
|
63
|
-
created_time: toDateTimeValueForProtocol3To5(page.created_time),
|
|
64
|
-
last_edited_time: toDateTimeValueForProtocol3To5(page.last_edited_time),
|
|
65
|
-
created_by: page.created_by ? [page.created_by] : undefined,
|
|
66
|
-
last_edited_by: page.last_edited_by ? [page.last_edited_by] : undefined,
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Flattens rich-text items to the string used by protocol 3–5 query values.
|
|
73
|
-
*
|
|
74
|
-
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
75
|
-
*/
|
|
76
|
-
function plainText(items: Record<string, unknown>[]): string {
|
|
77
|
-
return items
|
|
78
|
-
.map(item => {
|
|
79
|
-
if (typeof item.plain_text === "string") {
|
|
80
|
-
return item.plain_text
|
|
81
|
-
}
|
|
82
|
-
const text = item.text
|
|
83
|
-
return text &&
|
|
84
|
-
typeof text === "object" &&
|
|
85
|
-
"content" in text &&
|
|
86
|
-
typeof text.content === "string"
|
|
87
|
-
? text.content
|
|
88
|
-
: ""
|
|
89
|
-
})
|
|
90
|
-
.join("")
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Converts a timestamp to the UTC date/time object used by protocol 3–5 queries.
|
|
95
|
-
* Missing or invalid timestamps produce undefined; time is stored to the minute.
|
|
96
|
-
*
|
|
97
|
-
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
98
|
-
*/
|
|
99
|
-
function toDateTimeValueForProtocol3To5(
|
|
100
|
-
value: string | number | null | undefined,
|
|
101
|
-
): NotionDataSourceValue | undefined {
|
|
102
|
-
if (value === undefined || value === null || value === "") {
|
|
103
|
-
return undefined
|
|
104
|
-
}
|
|
105
|
-
const date = new Date(value)
|
|
106
|
-
if (!Number.isFinite(date.getTime())) {
|
|
107
|
-
return undefined
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
type: "datetime",
|
|
111
|
-
start_date: date.toISOString().slice(0, 10),
|
|
112
|
-
start_time: date.toISOString().slice(11, 16),
|
|
113
|
-
time_zone: "UTC",
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Converts a typed page property to the scalar, list, record-reference, or
|
|
119
|
-
* date/time value used by protocol 3–5 query results.
|
|
120
|
-
*
|
|
121
|
-
* Delete when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION >= 6.
|
|
122
|
-
*/
|
|
123
|
-
function toPropertyValueForProtocol3To5(
|
|
124
|
-
property: NotionPagePropertyValue,
|
|
125
|
-
): NotionDataSourceValue | undefined {
|
|
126
|
-
switch (property.type) {
|
|
127
|
-
case "title":
|
|
128
|
-
return plainText(property.title)
|
|
129
|
-
case "rich_text":
|
|
130
|
-
return plainText(property.rich_text)
|
|
131
|
-
case "number":
|
|
132
|
-
return property.number ?? undefined
|
|
133
|
-
case "checkbox":
|
|
134
|
-
return property.checkbox
|
|
135
|
-
case "url":
|
|
136
|
-
return property.url ?? ""
|
|
137
|
-
case "email":
|
|
138
|
-
return property.email ?? ""
|
|
139
|
-
case "phone_number":
|
|
140
|
-
return property.phone_number ?? ""
|
|
141
|
-
case "select":
|
|
142
|
-
return property.select?.name
|
|
143
|
-
case "status":
|
|
144
|
-
return property.status?.name
|
|
145
|
-
case "multi_select":
|
|
146
|
-
return property.multi_select.flatMap(option => option.name ?? [])
|
|
147
|
-
case "date":
|
|
148
|
-
return property.date ? toNotionDateValue(property.date) : undefined
|
|
149
|
-
case "people":
|
|
150
|
-
return property.people.map(person =>
|
|
151
|
-
person.object === "group"
|
|
152
|
-
? {
|
|
153
|
-
id: person.id,
|
|
154
|
-
table: "space_permission_group",
|
|
155
|
-
spaceId: person.id.split("|")[1],
|
|
156
|
-
}
|
|
157
|
-
: { id: person.id, table: "notion_user" },
|
|
158
|
-
)
|
|
159
|
-
case "relation":
|
|
160
|
-
return property.relation.map(page => ({ id: page.id, table: "block" }))
|
|
161
|
-
case "files":
|
|
162
|
-
return property.files.map(file => file.name).join(",")
|
|
163
|
-
case "unique_id":
|
|
164
|
-
return property.unique_id
|
|
165
|
-
case "button":
|
|
166
|
-
return property.button
|
|
167
|
-
case "formula":
|
|
168
|
-
return property.formula
|
|
169
|
-
case "location":
|
|
170
|
-
return property.location
|
|
171
|
-
case "rollup":
|
|
172
|
-
return property.rollup
|
|
173
|
-
case "verification":
|
|
174
|
-
return property.verification
|
|
175
|
-
case "place":
|
|
176
|
-
return ""
|
|
177
|
-
case "created_time":
|
|
178
|
-
return toDateTimeValueForProtocol3To5(property.created_time)
|
|
179
|
-
case "last_edited_time":
|
|
180
|
-
return toDateTimeValueForProtocol3To5(property.last_edited_time)
|
|
181
|
-
case "last_visited_time":
|
|
182
|
-
return toDateTimeValueForProtocol3To5(property.last_visited_time)
|
|
183
|
-
case "created_by":
|
|
184
|
-
return property.created_by ? [property.created_by] : undefined
|
|
185
|
-
case "last_edited_by":
|
|
186
|
-
return property.last_edited_by ? [property.last_edited_by] : undefined
|
|
187
|
-
default:
|
|
188
|
-
return unreachable(property)
|
|
189
|
-
}
|
|
190
|
-
}
|
package/src/ids.ts
DELETED