@notionhq/custom-blocks 0.3.3 → 0.3.5
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/LICENSE +21 -0
- package/README.md +13 -11
- package/dist/bridge/SandboxBridge.d.ts +28 -509
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +89 -689
- package/dist/bridge/getBridge.d.ts +3 -0
- package/dist/bridge/getBridge.d.ts.map +1 -0
- package/dist/bridge/getBridge.js +8 -0
- package/dist/bridge/{SandboxInitialization.d.ts → initialization/SandboxInitialization.d.ts} +6 -9
- package/dist/bridge/initialization/SandboxInitialization.d.ts.map +1 -0
- package/dist/bridge/{SandboxInitialization.js → initialization/SandboxInitialization.js} +18 -26
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +2 -2
- package/dist/context/applyContextMessage.d.ts +6 -0
- package/dist/context/applyContextMessage.d.ts.map +1 -0
- package/dist/context/applyContextMessage.js +35 -0
- package/dist/context/backgroundColors.d.ts +7 -0
- package/dist/context/backgroundColors.d.ts.map +1 -0
- package/dist/context/backgroundColors.js +6 -0
- package/dist/context/getBlockId.d.ts +7 -0
- package/dist/context/getBlockId.d.ts.map +1 -0
- package/dist/context/getBlockId.js +8 -0
- package/dist/context/getContrastMode.d.ts +7 -0
- package/dist/context/getContrastMode.d.ts.map +1 -0
- package/dist/context/getContrastMode.js +8 -0
- package/dist/context/getInitializedHostState.d.ts +3 -0
- package/dist/context/getInitializedHostState.d.ts.map +1 -0
- package/dist/context/getInitializedHostState.js +8 -0
- package/dist/context/getPage.d.ts +7 -0
- package/dist/context/getPage.d.ts.map +1 -0
- package/dist/context/getPage.js +8 -0
- package/dist/context/getParent.d.ts +7 -0
- package/dist/context/getParent.d.ts.map +1 -0
- package/dist/context/getParent.js +8 -0
- package/dist/context/getTheme.d.ts +7 -0
- package/dist/context/getTheme.d.ts.map +1 -0
- package/dist/context/getTheme.js +8 -0
- package/dist/context/hostState.d.ts +15 -0
- package/dist/context/hostState.d.ts.map +1 -0
- package/dist/context/index.d.ts +42 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +41 -0
- package/dist/context/react/useBlockId.d.ts +11 -0
- package/dist/context/react/useBlockId.d.ts.map +1 -0
- package/dist/context/react/useBlockId.js +14 -0
- package/dist/context/react/useContrastMode.d.ts +11 -0
- package/dist/context/react/useContrastMode.d.ts.map +1 -0
- package/dist/context/react/useContrastMode.js +14 -0
- package/dist/context/react/usePage.d.ts +12 -0
- package/dist/context/react/usePage.d.ts.map +1 -0
- package/dist/context/react/usePage.js +15 -0
- package/dist/context/react/useParent.d.ts +12 -0
- package/dist/context/react/useParent.d.ts.map +1 -0
- package/dist/context/react/useParent.js +15 -0
- package/dist/context/react/useTheme.d.ts +11 -0
- package/dist/context/react/useTheme.d.ts.map +1 -0
- package/dist/context/react/useTheme.js +14 -0
- package/dist/context/subscribeToBlockId.d.ts +8 -0
- package/dist/context/subscribeToBlockId.d.ts.map +1 -0
- package/dist/context/subscribeToBlockId.js +8 -0
- package/dist/context/subscribeToContext.d.ts +12 -0
- package/dist/context/subscribeToContext.d.ts.map +1 -0
- package/dist/context/subscribeToContext.js +35 -0
- package/dist/context/subscribeToContrastMode.d.ts +8 -0
- package/dist/context/subscribeToContrastMode.d.ts.map +1 -0
- package/dist/context/subscribeToContrastMode.js +8 -0
- package/dist/context/subscribeToPage.d.ts +8 -0
- package/dist/context/subscribeToPage.d.ts.map +1 -0
- package/dist/context/subscribeToPage.js +8 -0
- package/dist/context/subscribeToParent.d.ts +8 -0
- package/dist/context/subscribeToParent.d.ts.map +1 -0
- package/dist/context/subscribeToParent.js +8 -0
- package/dist/context/subscribeToTheme.d.ts +8 -0
- package/dist/context/subscribeToTheme.d.ts.map +1 -0
- package/dist/context/subscribeToTheme.js +8 -0
- package/dist/context/syncDocumentAppearance.d.ts +14 -0
- package/dist/context/syncDocumentAppearance.d.ts.map +1 -0
- package/dist/context/syncDocumentAppearance.js +22 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.d.ts +4 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.d.ts.map +1 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.js +17 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts +17 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.js +188 -0
- package/dist/dataSources/bridge/resolveDataSources.d.ts +15 -0
- package/dist/dataSources/bridge/resolveDataSources.d.ts.map +1 -0
- package/dist/{bridge/dataSources/resolve.js → dataSources/bridge/resolveDataSources.js} +10 -11
- package/dist/dataSources/bridge/resolveSorts.d.ts +10 -0
- package/dist/dataSources/bridge/resolveSorts.d.ts.map +1 -0
- package/dist/dataSources/bridge/resolveSorts.js +80 -0
- package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.d.ts +16 -0
- package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.d.ts.map +1 -0
- package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.js +19 -0
- package/dist/dataSources/createDataSourcePage.d.ts +4 -0
- package/dist/dataSources/createDataSourcePage.d.ts.map +1 -0
- package/dist/dataSources/createDataSourcePage.js +40 -0
- package/dist/dataSources/dataSourceInaccessibleError.d.ts +4 -0
- package/dist/dataSources/dataSourceInaccessibleError.d.ts.map +1 -0
- package/dist/dataSources/dataSourceInaccessibleError.js +9 -0
- package/dist/dataSources/filters/resolveFilter.d.ts +10 -0
- package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -0
- package/dist/dataSources/filters/resolveFilter.js +127 -0
- package/dist/dataSources/filters/types.d.ts +66 -0
- package/dist/dataSources/filters/types.d.ts.map +1 -0
- package/dist/dataSources/getDataSourcePage.d.ts +4 -0
- package/dist/dataSources/getDataSourcePage.d.ts.map +1 -0
- package/dist/dataSources/getDataSourcePage.js +18 -0
- package/dist/dataSources/index.d.ts +9 -0
- package/dist/dataSources/index.d.ts.map +1 -0
- package/dist/dataSources/index.js +8 -0
- package/dist/dataSources/properties/resolvePropertyAddress.d.ts +10 -0
- package/dist/dataSources/properties/resolvePropertyAddress.d.ts.map +1 -0
- package/dist/dataSources/properties/resolvePropertyAddress.js +55 -0
- package/dist/{bridge/dataSources/resolveProperty.d.ts → dataSources/properties/resolvePropertyWriteMapForDataSource.d.ts} +4 -4
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.d.ts.map +1 -0
- package/dist/{bridge/dataSources/resolveProperty.js → dataSources/properties/resolvePropertyWriteMapForDataSource.js} +2 -2
- package/dist/dataSources/queryDataSource.d.ts +3 -0
- package/dist/dataSources/queryDataSource.d.ts.map +1 -0
- package/dist/dataSources/queryDataSource.js +56 -0
- package/dist/{react → dataSources/react}/useDataSource.d.ts +2 -2
- package/dist/dataSources/react/useDataSource.d.ts.map +1 -0
- package/dist/{react → dataSources/react}/useDataSource.js +4 -4
- package/dist/dataSources/resolvePageDataSource.d.ts +16 -0
- package/dist/dataSources/resolvePageDataSource.d.ts.map +1 -0
- package/dist/dataSources/resolvePageDataSource.js +43 -0
- package/dist/{bridge/dataSources/subscribe.d.ts → dataSources/subscribeToDataSource.d.ts} +3 -3
- package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -0
- package/dist/dataSources/subscribeToDataSource.js +109 -0
- package/dist/dataSources/types.d.ts +47 -0
- package/dist/dataSources/types.d.ts.map +1 -0
- package/dist/dataSources/types.js +1 -0
- package/dist/index.d.ts +38 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/initialization/NotInIframeError.d.ts +12 -0
- package/dist/initialization/NotInIframeError.d.ts.map +1 -0
- package/dist/{initTypes.js → initialization/NotInIframeError.js} +3 -3
- package/dist/initialization/getInitBindingError.d.ts +5 -0
- package/dist/initialization/getInitBindingError.d.ts.map +1 -0
- package/dist/initialization/getInitBindingError.js +26 -0
- package/dist/{init.d.ts → initialization/initCustomBlock.d.ts} +2 -3
- package/dist/initialization/initCustomBlock.d.ts.map +1 -0
- package/dist/{init.js → initialization/initCustomBlock.js} +2 -3
- package/dist/{react → initialization/react}/useCustomBlockInit.d.ts +2 -2
- package/dist/initialization/react/useCustomBlockInit.d.ts.map +1 -0
- package/dist/{react → initialization/react}/useCustomBlockInit.js +1 -1
- package/dist/initialization/resolveInitialState.d.ts +13 -0
- package/dist/initialization/resolveInitialState.d.ts.map +1 -0
- package/dist/initialization/resolveInitialState.js +28 -0
- package/dist/initialization/types.d.ts +20 -0
- package/dist/initialization/types.d.ts.map +1 -0
- package/dist/initialization/types.js +1 -0
- package/dist/layout/autoResize.d.ts.map +1 -0
- package/dist/{autoResize.js → layout/autoResize.js} +2 -2
- package/dist/layout/getInitialContentHeight.d.ts +2 -0
- package/dist/layout/getInitialContentHeight.d.ts.map +1 -0
- package/dist/layout/getInitialContentHeight.js +10 -0
- package/dist/layout/postResize.d.ts +2 -0
- package/dist/layout/postResize.d.ts.map +1 -0
- package/dist/layout/postResize.js +12 -0
- package/dist/manifest/getManifest.d.ts +7 -0
- package/dist/manifest/getManifest.d.ts.map +1 -0
- package/dist/manifest/getManifest.js +8 -0
- package/dist/manifest/react/useManifest.d.ts +15 -0
- package/dist/manifest/react/useManifest.d.ts.map +1 -0
- package/dist/manifest/react/useManifest.js +18 -0
- package/dist/manifest/readLocalManifest.d.ts +23 -0
- package/dist/manifest/readLocalManifest.d.ts.map +1 -0
- package/dist/manifest/readLocalManifest.js +46 -0
- package/dist/manifest/subscribeToManifest.d.ts +8 -0
- package/dist/manifest/subscribeToManifest.d.ts.map +1 -0
- package/dist/manifest/subscribeToManifest.js +8 -0
- package/dist/manifest/types.d.ts +6 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +1 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +4 -0
- package/dist/navigation/openExternalUrl.d.ts +4 -0
- package/dist/navigation/openExternalUrl.d.ts.map +1 -0
- package/dist/navigation/openExternalUrl.js +5 -0
- package/dist/navigation/types.d.ts +4 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -0
- package/dist/pages/bridge/buildCreatePageRequest.d.ts +16 -0
- package/dist/pages/bridge/buildCreatePageRequest.d.ts.map +1 -0
- package/dist/pages/bridge/buildCreatePageRequest.js +38 -0
- package/dist/pages/bridge/getPageForDataSource.d.ts +9 -0
- package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -0
- package/dist/pages/bridge/getPageForDataSource.js +13 -0
- package/dist/pages/bridge/makeUpdatePageByKey.d.ts +8 -0
- package/dist/pages/bridge/makeUpdatePageByKey.d.ts.map +1 -0
- package/dist/{bridge/page.js → pages/bridge/makeUpdatePageByKey.js} +0 -12
- package/dist/pages/bridge/resolveCreatePageDestination.d.ts +24 -0
- package/dist/pages/bridge/resolveCreatePageDestination.d.ts.map +1 -0
- package/dist/pages/bridge/resolveCreatePageDestination.js +45 -0
- package/dist/pages/bridge/sendCreatePageRequest.d.ts +11 -0
- package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -0
- package/dist/pages/bridge/sendCreatePageRequest.js +12 -0
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +77 -0
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +1 -0
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.js +25 -0
- package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts +11 -0
- package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts.map +1 -0
- package/dist/pages/bridge/toNotionPageFromBridgePage.js +12 -0
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts +4 -0
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -0
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.js +92 -0
- package/dist/pages/bridge/updateNotionPageFromBridgePage.d.ts +4 -0
- package/dist/pages/bridge/updateNotionPageFromBridgePage.d.ts.map +1 -0
- package/dist/pages/bridge/updateNotionPageFromBridgePage.js +4 -0
- package/dist/pages/bridge/updatePage.d.ts +12 -0
- package/dist/pages/bridge/updatePage.d.ts.map +1 -0
- package/dist/pages/bridge/updatePage.js +60 -0
- package/dist/pages/createPage.d.ts +3 -0
- package/dist/pages/createPage.d.ts.map +1 -0
- package/dist/pages/createPage.js +27 -0
- package/dist/pages/getPage.d.ts +7 -0
- package/dist/pages/getPage.d.ts.map +1 -0
- package/dist/pages/getPage.js +11 -0
- package/dist/pages/index.d.ts +9 -0
- package/dist/pages/index.d.ts.map +1 -0
- package/dist/pages/index.js +8 -0
- package/dist/pages/makeNotionPage.d.ts +11 -0
- package/dist/pages/makeNotionPage.d.ts.map +1 -0
- package/dist/pages/makeNotionPage.js +34 -0
- package/dist/pages/openPage.d.ts +7 -0
- package/dist/pages/openPage.d.ts.map +1 -0
- package/dist/pages/openPage.js +7 -0
- package/dist/pages/parent.d.ts +7 -0
- package/dist/pages/parent.d.ts.map +1 -0
- package/dist/pages/parent.js +1 -0
- package/dist/pages/properties/getPropertyById.d.ts +6 -0
- package/dist/pages/properties/getPropertyById.d.ts.map +1 -0
- package/dist/pages/properties/getPropertyById.js +3 -0
- package/dist/pages/properties/getPropertyByKey.d.ts +9 -0
- package/dist/pages/properties/getPropertyByKey.d.ts.map +1 -0
- package/dist/pages/properties/getPropertyByKey.js +16 -0
- package/dist/pages/types.d.ts +208 -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.d.ts +3 -4
- package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourcePage.js +3 -4
- 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} +527 -4
- package/dist/protocol/dataSources/messages/queryDataSource.js +64 -0
- 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 +6 -2
- package/dist/protocol/{messages → handshake}/connect.js +4 -4
- package/dist/protocol/{messages → handshake}/init.d.ts +7 -2
- 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 -53
- package/dist/protocol/index.js +73 -53
- 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 +15 -3
- package/dist/protocol/messages/hostToSandbox.js +21 -21
- package/dist/protocol/messages/messagePayload.d.ts +1 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +240 -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} +502 -4
- package/dist/protocol/pages/messages/createPage.js +104 -0
- package/dist/protocol/{messages → pages/messages}/getPage.d.ts +4 -4
- package/dist/protocol/{messages → pages/messages}/getPage.js +6 -5
- 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} +274 -4
- package/dist/protocol/pages/messages/updatePage.js +65 -0
- package/dist/protocol/pages/pageAppearance.d.ts +62 -0
- package/dist/protocol/pages/pageAppearance.js +34 -0
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +433 -0
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.js +4 -0
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +217 -0
- package/dist/protocol/pages/properties/bridgePagePropertyValue.js +144 -0
- package/dist/protocol/pages/properties/dateInput.d.ts +45 -0
- package/dist/protocol/pages/properties/dateInput.js +23 -0
- package/dist/protocol/pages/properties/fileInput.d.ts +16 -0
- package/dist/protocol/pages/properties/fileInput.js +16 -0
- package/dist/protocol/pages/properties/metadataActor.d.ts +6 -0
- package/dist/protocol/pages/properties/metadataActor.js +7 -0
- package/dist/protocol/pages/properties/placeInput.d.ts +10 -0
- package/dist/protocol/pages/properties/placeInput.js +10 -0
- package/dist/protocol/pages/properties/relationInput.d.ts +5 -0
- package/dist/protocol/pages/properties/relationInput.js +2 -0
- package/dist/protocol/pages/properties/richText.d.ts +3 -0
- package/dist/protocol/pages/properties/richText.js +2 -0
- package/dist/protocol/pages/properties/selectOption.d.ts +13 -0
- package/dist/protocol/pages/properties/selectOption.js +16 -0
- package/dist/protocol/pages/properties/userInput.d.ts +10 -0
- package/dist/protocol/pages/properties/userInput.js +13 -0
- package/dist/protocol/users/bridgeUser.d.ts +12 -0
- package/dist/protocol/users/bridgeUser.js +12 -0
- package/dist/protocol/users/{user.d.ts → bridgeUserList.d.ts} +2 -15
- package/dist/protocol/users/bridgeUserList.js +10 -0
- package/dist/protocol/users/makeBridgeUser.d.ts +4 -0
- package/dist/protocol/users/makeBridgeUser.js +11 -0
- package/dist/protocol/{messages → users/messages}/currentUserChanged.js +2 -2
- package/dist/protocol/{messages → users/messages}/getUser.d.ts +2 -2
- package/dist/protocol/{messages → users/messages}/getUser.js +3 -2
- package/dist/protocol/{messages → users/messages}/listUsers.d.ts +2 -2
- package/dist/protocol/{messages → users/messages}/listUsers.js +2 -2
- package/dist/protocol/users/userId.d.ts +3 -0
- package/dist/protocol/users/userId.js +2 -0
- package/dist/protocol/{errors.d.ts → utils/errors.d.ts} +6 -0
- package/dist/protocol/utils/errors.js +11 -0
- package/dist/protocol/utils/isLocalBlockServerUrl.d.ts +2 -0
- package/dist/protocol/utils/isLocalBlockServerUrl.js +9 -0
- package/dist/protocol/utils/nullableStringSchema.d.ts +2 -0
- package/dist/protocol/utils/nullableStringSchema.js +2 -0
- package/dist/protocol/{protocolVersion.d.ts → utils/protocolVersion.d.ts} +2 -2
- package/dist/protocol/{protocolVersion.js → utils/protocolVersion.js} +2 -2
- package/dist/react/DebugMessageLog.d.ts.map +1 -1
- package/dist/react/DebugMessageLog.js +3 -2
- package/dist/react/InitializationErrorDetails.d.ts +7 -0
- package/dist/react/InitializationErrorDetails.d.ts.map +1 -0
- package/dist/react/InitializationErrorDetails.js +9 -0
- package/dist/react/{NotionCustomBlock.css → InitializationErrorScreen.css} +0 -20
- package/dist/react/MissingHostCommand.d.ts +2 -0
- package/dist/react/MissingHostCommand.d.ts.map +1 -0
- package/dist/react/MissingHostCommand.js +20 -0
- package/dist/react/MissingHostScreen.css +85 -0
- package/dist/react/MissingHostScreen.d.ts +7 -0
- package/dist/react/MissingHostScreen.d.ts.map +1 -0
- package/dist/react/MissingHostScreen.js +7 -0
- package/dist/react/NotionCustomBlock.d.ts +2 -2
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +14 -35
- package/dist/react/NotionTokenScope.d.ts.map +1 -1
- package/dist/react/NotionTokenScope.js +2 -1
- package/dist/react/index.d.ts +14 -5
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +11 -5
- package/dist/users/bridge/toNotionUserFromBridgeUser.d.ts +4 -0
- package/dist/users/bridge/toNotionUserFromBridgeUser.d.ts.map +1 -0
- package/dist/users/bridge/toNotionUserFromBridgeUser.js +10 -0
- package/dist/users/getCurrentUser.d.ts +7 -0
- package/dist/users/getCurrentUser.d.ts.map +1 -0
- package/dist/users/getCurrentUser.js +8 -0
- package/dist/users/getUser.d.ts +7 -0
- package/dist/users/getUser.d.ts.map +1 -0
- package/dist/users/getUser.js +11 -0
- package/dist/users/index.d.ts +7 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +6 -0
- package/dist/users/listUsers.d.ts +6 -0
- package/dist/users/listUsers.d.ts.map +1 -0
- package/dist/users/listUsers.js +19 -0
- package/dist/users/react/useCurrentUser.d.ts +12 -0
- package/dist/users/react/useCurrentUser.d.ts.map +1 -0
- package/dist/users/react/useCurrentUser.js +15 -0
- package/dist/users/subscribeToCurrentUser.d.ts +8 -0
- package/dist/users/subscribeToCurrentUser.d.ts.map +1 -0
- package/dist/users/subscribeToCurrentUser.js +8 -0
- package/dist/users/types.d.ts +41 -0
- package/dist/users/types.d.ts.map +1 -0
- package/dist/users/types.js +1 -0
- package/dist/utils/notifyListener.d.ts.map +1 -0
- package/dist/utils/typeUtils.d.ts.map +1 -0
- package/dist/utils/typeUtils.js +1 -0
- package/dist/{utils.d.ts → utils/unreachable.d.ts} +1 -1
- package/dist/utils/unreachable.d.ts.map +1 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/{version.js → utils/version.js} +1 -1
- package/docs/block-location.md +9 -6
- package/docs/bridge-interceptors.md +4 -0
- package/docs/build-tools.md +5 -2
- package/docs/capabilities.md +111 -0
- package/docs/data-sources.md +27 -19
- package/docs/deployment.md +18 -12
- package/docs/errors.md +20 -1
- package/docs/lifecycle.md +16 -9
- package/docs/pages.md +6 -5
- package/docs/users.md +7 -4
- package/package.json +3 -2
- package/src/bridge/SandboxBridge.ts +159 -904
- package/src/bridge/getBridge.ts +10 -0
- package/src/bridge/{SandboxInitialization.ts → initialization/SandboxInitialization.ts} +24 -40
- package/src/bridge.ts +2 -2
- package/src/context/applyContextMessage.ts +55 -0
- package/src/context/backgroundColors.ts +6 -0
- package/src/context/getBlockId.ts +10 -0
- package/src/context/getContrastMode.ts +10 -0
- package/src/context/getInitializedHostState.ts +14 -0
- package/src/context/getPage.ts +10 -0
- package/src/context/getParent.ts +10 -0
- package/src/context/getTheme.ts +10 -0
- package/src/context/hostState.ts +17 -0
- package/src/context/index.ts +42 -0
- package/src/context/react/useBlockId.ts +16 -0
- package/src/context/react/useContrastMode.ts +16 -0
- package/src/context/react/usePage.ts +17 -0
- package/src/context/react/useParent.ts +17 -0
- package/src/context/react/useTheme.ts +16 -0
- package/src/context/subscribeToBlockId.ts +13 -0
- package/src/context/subscribeToContext.ts +42 -0
- package/src/context/subscribeToContrastMode.ts +13 -0
- package/src/context/subscribeToPage.ts +13 -0
- package/src/context/subscribeToParent.ts +13 -0
- package/src/context/subscribeToTheme.ts +13 -0
- package/src/context/syncDocumentAppearance.ts +31 -0
- package/src/dataSources/bridge/applyDataSourceBindings.ts +25 -0
- package/src/dataSources/bridge/resolveDataSourceQuery.ts +243 -0
- package/src/dataSources/bridge/resolveDataSources.ts +44 -0
- package/src/dataSources/bridge/resolveSorts.ts +105 -0
- package/src/dataSources/bridge/reuseDataSourcesForUnchangedBindings.ts +32 -0
- package/src/dataSources/createDataSourcePage.ts +46 -0
- package/src/dataSources/dataSourceInaccessibleError.ts +13 -0
- package/src/dataSources/filters/resolveFilter.ts +179 -0
- package/src/dataSources/filters/types.ts +77 -0
- package/src/dataSources/getDataSourcePage.ts +24 -0
- package/src/dataSources/index.ts +9 -0
- package/src/dataSources/properties/resolvePropertyAddress.ts +62 -0
- package/src/{bridge/dataSources/resolveProperty.ts → dataSources/properties/resolvePropertyWriteMapForDataSource.ts} +5 -5
- package/src/dataSources/queryDataSource.ts +62 -0
- package/src/{react → dataSources/react}/useDataSource.ts +4 -4
- package/src/dataSources/resolvePageDataSource.ts +57 -0
- package/src/dataSources/subscribeToDataSource.ts +143 -0
- package/src/dataSources/types.ts +53 -0
- package/src/index.ts +70 -68
- package/src/initialization/NotInIframeError.ts +23 -0
- package/src/initialization/getInitBindingError.ts +39 -0
- package/src/initialization/initCustomBlock.ts +10 -0
- package/src/{react → initialization/react}/useCustomBlockInit.ts +3 -2
- package/src/initialization/resolveInitialState.ts +37 -0
- package/src/initialization/types.ts +20 -0
- package/src/{autoResize.ts → layout/autoResize.ts} +2 -2
- package/src/layout/getInitialContentHeight.ts +10 -0
- package/src/layout/postResize.ts +15 -0
- package/src/manifest/getManifest.ts +10 -0
- package/src/manifest/react/useManifest.ts +20 -0
- package/src/manifest/readLocalManifest.ts +58 -0
- package/src/manifest/subscribeToManifest.ts +13 -0
- package/src/manifest/types.ts +7 -0
- package/src/navigation/index.ts +5 -0
- package/src/navigation/openExternalUrl.ts +9 -0
- package/src/navigation/types.ts +10 -0
- package/src/pages/bridge/buildCreatePageRequest.ts +49 -0
- package/src/pages/bridge/getPageForDataSource.ts +25 -0
- package/src/pages/bridge/makeUpdatePageByKey.ts +25 -0
- package/src/pages/bridge/resolveCreatePageDestination.ts +75 -0
- package/src/pages/bridge/sendCreatePageRequest.ts +22 -0
- package/src/pages/bridge/toNotionPageFieldsFromBridgePage.ts +28 -0
- package/src/pages/bridge/toNotionPageFromBridgePage.ts +22 -0
- package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +97 -0
- package/src/pages/bridge/updateNotionPageFromBridgePage.ts +10 -0
- package/src/pages/bridge/updatePage.ts +90 -0
- package/src/pages/createPage.ts +31 -0
- package/src/pages/getPage.ts +14 -0
- package/src/pages/index.ts +9 -0
- package/src/pages/makeNotionPage.ts +55 -0
- package/src/pages/openPage.ts +13 -0
- package/src/pages/parent.ts +14 -0
- package/src/pages/properties/getPropertyById.ts +12 -0
- package/src/pages/properties/getPropertyByKey.ts +30 -0
- package/src/pages/types.ts +189 -0
- package/src/react/DebugMessageLog.tsx +6 -2
- package/src/react/InitializationErrorDetails.tsx +30 -0
- package/src/react/{NotionCustomBlock.css → InitializationErrorScreen.css} +0 -20
- package/src/react/MissingHostCommand.tsx +49 -0
- package/src/react/MissingHostScreen.css +85 -0
- package/src/react/MissingHostScreen.tsx +34 -0
- package/src/react/NotionCustomBlock.tsx +17 -55
- package/src/react/NotionTokenScope.tsx +2 -1
- package/src/react/index.ts +14 -22
- package/src/users/bridge/toNotionUserFromBridgeUser.ts +13 -0
- package/src/users/getCurrentUser.ts +10 -0
- package/src/users/getUser.ts +14 -0
- package/src/users/index.ts +7 -0
- package/src/users/listUsers.ts +23 -0
- package/src/users/react/useCurrentUser.ts +17 -0
- package/src/users/subscribeToCurrentUser.ts +13 -0
- package/src/users/types.ts +36 -0
- package/dist/autoResize.d.ts.map +0 -1
- package/dist/bridge/SandboxInitialization.d.ts.map +0 -1
- package/dist/bridge/appearance.d.ts +0 -15
- package/dist/bridge/appearance.d.ts.map +0 -1
- package/dist/bridge/appearance.js +0 -14
- package/dist/bridge/dataSources/query.d.ts +0 -28
- package/dist/bridge/dataSources/query.d.ts.map +0 -1
- package/dist/bridge/dataSources/query.js +0 -575
- package/dist/bridge/dataSources/resolve.d.ts +0 -14
- package/dist/bridge/dataSources/resolve.d.ts.map +0 -1
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +0 -1
- package/dist/bridge/dataSources/subscribe.d.ts.map +0 -1
- package/dist/bridge/dataSources/subscribe.js +0 -76
- package/dist/bridge/hostState.d.ts +0 -46
- package/dist/bridge/hostState.d.ts.map +0 -1
- package/dist/bridge/hostState.js +0 -32
- package/dist/bridge/loadManifest.d.ts +0 -21
- package/dist/bridge/loadManifest.d.ts.map +0 -1
- package/dist/bridge/loadManifest.js +0 -85
- package/dist/bridge/notifyListener.d.ts.map +0 -1
- package/dist/bridge/page.d.ts +0 -18
- package/dist/bridge/page.d.ts.map +0 -1
- package/dist/bridge/sandboxClient.d.ts +0 -68
- package/dist/bridge/sandboxClient.d.ts.map +0 -1
- package/dist/bridge/sandboxClient.js +0 -135
- package/dist/customBlock.d.ts +0 -97
- package/dist/customBlock.d.ts.map +0 -1
- package/dist/customBlock.js +0 -157
- package/dist/dataSources.d.ts +0 -8
- package/dist/dataSources.d.ts.map +0 -1
- package/dist/dataSources.js +0 -105
- package/dist/init.d.ts.map +0 -1
- package/dist/initTypes.d.ts +0 -31
- package/dist/initTypes.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 -1446
- package/dist/protocol/messages/queryDataSource.js +0 -252
- package/dist/protocol/messages/queryDataSourceResult.js +0 -44
- package/dist/protocol/messages/updatePage.js +0 -23
- package/dist/protocol/messages/updatePageResult.js +0 -41
- package/dist/protocol/pages/page.d.ts +0 -1422
- package/dist/protocol/pages/page.js +0 -318
- package/dist/protocol/parent.js +0 -13
- package/dist/protocol/users/user.js +0 -20
- package/dist/react/standalonePreview.d.ts +0 -2
- package/dist/react/standalonePreview.d.ts.map +0 -1
- package/dist/react/standalonePreview.js +0 -36
- package/dist/react/useCustomBlockInit.d.ts.map +0 -1
- package/dist/react/useDataSource.d.ts.map +0 -1
- package/dist/react/useHostState.d.ts +0 -2
- package/dist/react/useHostState.d.ts.map +0 -1
- package/dist/react/useHostState.js +0 -5
- package/dist/react/useRuntimeState.d.ts +0 -78
- package/dist/react/useRuntimeState.d.ts.map +0 -1
- package/dist/react/useRuntimeState.js +0 -86
- package/dist/typeUtils.d.ts.map +0 -1
- package/dist/types.d.ts +0 -204
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/src/bridge/appearance.ts +0 -14
- package/src/bridge/dataSources/query.ts +0 -771
- package/src/bridge/dataSources/resolve.ts +0 -50
- package/src/bridge/dataSources/subscribe.ts +0 -124
- package/src/bridge/hostState.ts +0 -99
- package/src/bridge/loadManifest.ts +0 -114
- package/src/bridge/page.ts +0 -47
- package/src/bridge/sandboxClient.ts +0 -203
- package/src/customBlock.ts +0 -193
- package/src/dataSources.ts +0 -136
- package/src/init.ts +0 -15
- package/src/initTypes.ts +0 -43
- package/src/react/standalonePreview.ts +0 -41
- package/src/react/useHostState.ts +0 -9
- package/src/react/useRuntimeState.ts +0 -118
- package/src/types.ts +0 -284
- /package/dist/{typeUtils.js → context/hostState.js} +0 -0
- /package/dist/{types.js → dataSources/filters/types.js} +0 -0
- /package/dist/{autoResize.d.ts → layout/autoResize.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/{dataSources → utils}/recordPointer.d.ts +0 -0
- /package/dist/protocol/{dataSources → utils}/recordPointer.js +0 -0
- /package/dist/{bridge → utils}/notifyListener.d.ts +0 -0
- /package/dist/{bridge → utils}/notifyListener.js +0 -0
- /package/dist/{typeUtils.d.ts → utils/typeUtils.d.ts} +0 -0
- /package/dist/{utils.js → utils/unreachable.js} +0 -0
- /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
- /package/src/{bridge → utils}/notifyListener.ts +0 -0
- /package/src/{typeUtils.ts → utils/typeUtils.ts} +0 -0
- /package/src/{utils.ts → utils/unreachable.ts} +0 -0
- /package/src/{version.ts → utils/version.ts} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { CustomBlockCheckboxFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/checkboxFilterOperator.js"
|
|
2
|
+
import type { CustomBlockContainsFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/containsFilterOperator.js"
|
|
3
|
+
import type { CustomBlockCreatedByFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/createdByFilterOperator.js"
|
|
4
|
+
import type { CustomBlockDateFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/dateFilterOperator.js"
|
|
5
|
+
import type { CustomBlockNumberFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/numberFilterOperator.js"
|
|
6
|
+
import type { CustomBlockOptionFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/optionFilterOperator.js"
|
|
7
|
+
import type {
|
|
8
|
+
CustomBlockPeopleFilterOperator,
|
|
9
|
+
CustomBlockPersonFilterValue,
|
|
10
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/filters/peopleFilterOperator.js"
|
|
11
|
+
import type { CustomBlockRelationFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/relationFilterOperator.js"
|
|
12
|
+
import type { CustomBlockStatusFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/statusFilterOperator.js"
|
|
13
|
+
import type { CustomBlockTextFilterOperator } from "@notionhq/custom-blocks-protocol/dataSources/filters/textFilterOperator.js"
|
|
14
|
+
import type { NotionSortDirection } from "@notionhq/custom-blocks-protocol/dataSources/sortDirection.js"
|
|
15
|
+
import type { ExclusiveUnion } from "../../utils/typeUtils.js"
|
|
16
|
+
|
|
17
|
+
export type NotionDataSourceTextFilterOperator =
|
|
18
|
+
ExclusiveUnion<CustomBlockTextFilterOperator>
|
|
19
|
+
|
|
20
|
+
export type NotionDataSourceNumberFilterOperator =
|
|
21
|
+
ExclusiveUnion<CustomBlockNumberFilterOperator>
|
|
22
|
+
|
|
23
|
+
export type NotionDataSourceCheckboxFilterOperator =
|
|
24
|
+
ExclusiveUnion<CustomBlockCheckboxFilterOperator>
|
|
25
|
+
|
|
26
|
+
export type NotionDataSourceOptionFilterOperator =
|
|
27
|
+
ExclusiveUnion<CustomBlockOptionFilterOperator>
|
|
28
|
+
|
|
29
|
+
export type NotionDataSourceStatusFilterOperator =
|
|
30
|
+
ExclusiveUnion<CustomBlockStatusFilterOperator>
|
|
31
|
+
|
|
32
|
+
export type NotionDataSourceContainsFilterOperator =
|
|
33
|
+
ExclusiveUnion<CustomBlockContainsFilterOperator>
|
|
34
|
+
|
|
35
|
+
export type NotionDataSourceDateFilterOperator =
|
|
36
|
+
ExclusiveUnion<CustomBlockDateFilterOperator>
|
|
37
|
+
|
|
38
|
+
export type NotionDataSourceCreatedByFilterOperator =
|
|
39
|
+
ExclusiveUnion<CustomBlockCreatedByFilterOperator>
|
|
40
|
+
|
|
41
|
+
export type NotionDataSourcePersonFilterValue = CustomBlockPersonFilterValue
|
|
42
|
+
|
|
43
|
+
export type NotionDataSourcePeopleFilterOperator =
|
|
44
|
+
ExclusiveUnion<CustomBlockPeopleFilterOperator>
|
|
45
|
+
|
|
46
|
+
export type NotionDataSourceRelationFilterOperator =
|
|
47
|
+
ExclusiveUnion<CustomBlockRelationFilterOperator>
|
|
48
|
+
|
|
49
|
+
export type NotionDataSourcePropertyAddress =
|
|
50
|
+
| { key: string; propertyId?: never }
|
|
51
|
+
| { propertyId: string; key?: never }
|
|
52
|
+
|
|
53
|
+
export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress &
|
|
54
|
+
ExclusiveUnion<
|
|
55
|
+
| { title: NotionDataSourceTextFilterOperator }
|
|
56
|
+
| { rich_text: NotionDataSourceTextFilterOperator }
|
|
57
|
+
| { url: NotionDataSourceTextFilterOperator }
|
|
58
|
+
| { email: NotionDataSourceTextFilterOperator }
|
|
59
|
+
| { phone_number: NotionDataSourceTextFilterOperator }
|
|
60
|
+
| { number: NotionDataSourceNumberFilterOperator }
|
|
61
|
+
| { checkbox: NotionDataSourceCheckboxFilterOperator }
|
|
62
|
+
| { select: NotionDataSourceOptionFilterOperator }
|
|
63
|
+
| { multi_select: NotionDataSourceContainsFilterOperator }
|
|
64
|
+
| { status: NotionDataSourceStatusFilterOperator }
|
|
65
|
+
| { date: NotionDataSourceDateFilterOperator }
|
|
66
|
+
| { people: NotionDataSourcePeopleFilterOperator }
|
|
67
|
+
| { relation: NotionDataSourceRelationFilterOperator }
|
|
68
|
+
| { created_by: NotionDataSourceCreatedByFilterOperator }
|
|
69
|
+
>
|
|
70
|
+
|
|
71
|
+
export type NotionDataSourceSort = NotionDataSourcePropertyAddress & {
|
|
72
|
+
direction: NotionSortDirection
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type NotionDataSourceFilter = ExclusiveUnion<
|
|
76
|
+
NotionDataSourcePropertyFilter | { and: NotionDataSourcePropertyFilter[] }
|
|
77
|
+
>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NotionPageId } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
2
|
+
import { getBridge } from "../bridge/getBridge.js"
|
|
3
|
+
import { getPageForDataSource } from "../pages/bridge/getPageForDataSource.js"
|
|
4
|
+
import { resolvePageDataSource } from "./resolvePageDataSource.js"
|
|
5
|
+
import type { DataSourcesPageResult } from "./types.js"
|
|
6
|
+
|
|
7
|
+
export async function getDataSourcePage(
|
|
8
|
+
key: string,
|
|
9
|
+
pageId: NotionPageId,
|
|
10
|
+
): Promise<DataSourcesPageResult> {
|
|
11
|
+
const bridge = getBridge()
|
|
12
|
+
const resolved = resolvePageDataSource({
|
|
13
|
+
hostState: bridge.getHostState(),
|
|
14
|
+
key,
|
|
15
|
+
})
|
|
16
|
+
if (resolved.status === "error") {
|
|
17
|
+
return resolved
|
|
18
|
+
}
|
|
19
|
+
const { dataSource } = resolved
|
|
20
|
+
const result = await getPageForDataSource(bridge, { pageId, dataSource })
|
|
21
|
+
return result.status === "error"
|
|
22
|
+
? result
|
|
23
|
+
: { ...result, propertyIdsByKey: dataSource.propertyIdsByKey }
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createDataSourcePage } from "./createDataSourcePage.js"
|
|
2
|
+
import { getDataSourcePage } from "./getDataSourcePage.js"
|
|
3
|
+
import { queryDataSource } from "./queryDataSource.js"
|
|
4
|
+
|
|
5
|
+
export const dataSources = {
|
|
6
|
+
getPage: getDataSourcePage,
|
|
7
|
+
create: createDataSourcePage,
|
|
8
|
+
query: queryDataSource,
|
|
9
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/notionDataSource.js"
|
|
2
|
+
|
|
3
|
+
export function resolvePropertyAddress(
|
|
4
|
+
value: Record<string, unknown>,
|
|
5
|
+
dataSource: NotionDataSource,
|
|
6
|
+
):
|
|
7
|
+
| { status: "ok"; propertyId: string; propertyType: string }
|
|
8
|
+
| { status: "error"; error: string } {
|
|
9
|
+
const hasKey = Object.hasOwn(value, "key")
|
|
10
|
+
const hasPropertyId = Object.hasOwn(value, "propertyId")
|
|
11
|
+
if (hasKey === hasPropertyId) {
|
|
12
|
+
return {
|
|
13
|
+
status: "error",
|
|
14
|
+
error:
|
|
15
|
+
"Data source query filters and sorts must use exactly one of key or propertyId.",
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
let propertyId: string
|
|
19
|
+
if (hasKey) {
|
|
20
|
+
if (typeof value.key !== "string") {
|
|
21
|
+
return {
|
|
22
|
+
status: "error",
|
|
23
|
+
error: "Data source query property key must be a string.",
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (!Object.hasOwn(dataSource.propertyIdsByKey, value.key)) {
|
|
27
|
+
return {
|
|
28
|
+
status: "error",
|
|
29
|
+
error: `Unknown property key "${value.key}" for data source "${dataSource.key}".`,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const resolvedPropertyId = dataSource.propertyIdsByKey[value.key]
|
|
33
|
+
if (resolvedPropertyId === undefined) {
|
|
34
|
+
return {
|
|
35
|
+
status: "error",
|
|
36
|
+
error: `Property key "${value.key}" for data source "${dataSource.key}" is not bound.`,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
propertyId = resolvedPropertyId
|
|
40
|
+
} else {
|
|
41
|
+
if (typeof value.propertyId !== "string") {
|
|
42
|
+
return {
|
|
43
|
+
status: "error",
|
|
44
|
+
error: "Data source query propertyId must be a string.",
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
propertyId = value.propertyId
|
|
48
|
+
}
|
|
49
|
+
const properties = dataSource.collectionSchema?.propertiesById ?? {}
|
|
50
|
+
if (!Object.hasOwn(properties, propertyId)) {
|
|
51
|
+
return {
|
|
52
|
+
status: "error",
|
|
53
|
+
error: `Unknown property ID "${propertyId}" for data source "${dataSource.key}".`,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const propertySchema = properties[propertyId]
|
|
57
|
+
return {
|
|
58
|
+
status: "ok",
|
|
59
|
+
propertyId,
|
|
60
|
+
propertyType: propertySchema.type,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
2
1
|
import type {
|
|
3
2
|
CustomBlockPropertyErrorCode,
|
|
4
3
|
CustomBlockPropertyErrorInfo,
|
|
5
4
|
} from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
5
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/notionDataSource.js"
|
|
6
|
+
import type { CreatePageMessage } from "@notionhq/custom-blocks-protocol/pages/messages/createPage.js"
|
|
7
|
+
import { bridgePagePropertyValueSchema } from "@notionhq/custom-blocks-protocol/pages/properties/bridgePagePropertyValue.js"
|
|
8
8
|
import * as v from "valibot"
|
|
9
|
-
import type { NotionPagePropertyInputMap } from "../../types.js"
|
|
9
|
+
import type { NotionPagePropertyInputMap } from "../../pages/types.js"
|
|
10
10
|
|
|
11
11
|
export type PropertyWriteMapResolutionResult =
|
|
12
12
|
| { status: "success"; properties: CreatePageMessage["properties"] }
|
|
@@ -79,7 +79,7 @@ export function resolvePropertyWriteMapForDataSource(args: {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const parsedValue = v.safeParse(
|
|
82
|
+
const parsedValue = v.safeParse(bridgePagePropertyValueSchema, {
|
|
83
83
|
...value,
|
|
84
84
|
id: propertyId,
|
|
85
85
|
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
2
|
+
import { getBridge } from "../bridge/getBridge.js"
|
|
3
|
+
import { subscribeToDataSource } from "./subscribeToDataSource.js"
|
|
4
|
+
import type { DataSourceQueryOptions, DataSourcesQueryResult } from "./types.js"
|
|
5
|
+
|
|
6
|
+
export async function queryDataSource(
|
|
7
|
+
key: string,
|
|
8
|
+
options?: DataSourceQueryOptions,
|
|
9
|
+
): Promise<DataSourcesQueryResult> {
|
|
10
|
+
const bridge = getBridge()
|
|
11
|
+
if (bridge.getHostState().status !== "initialized") {
|
|
12
|
+
try {
|
|
13
|
+
await bridge.initialize()
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (bridge.getHostState().status !== "initialized") {
|
|
16
|
+
return {
|
|
17
|
+
status: "error",
|
|
18
|
+
error:
|
|
19
|
+
error instanceof CustomBlockInitializationError
|
|
20
|
+
? {
|
|
21
|
+
code: error.code,
|
|
22
|
+
message: error.message,
|
|
23
|
+
isRetryable: error.isRetryable,
|
|
24
|
+
}
|
|
25
|
+
: {
|
|
26
|
+
code: "unknown_error",
|
|
27
|
+
message:
|
|
28
|
+
error instanceof Error ? error.message : String(error),
|
|
29
|
+
isRetryable: false,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return new Promise(resolve => {
|
|
36
|
+
let completed = false
|
|
37
|
+
let unsubscribe = () => {}
|
|
38
|
+
unsubscribe = subscribeToDataSource({
|
|
39
|
+
key,
|
|
40
|
+
options,
|
|
41
|
+
onSnapshot: snapshot => {
|
|
42
|
+
if (snapshot.isLoading || completed) {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
completed = true
|
|
46
|
+
unsubscribe()
|
|
47
|
+
resolve({ status: "success", ...snapshot })
|
|
48
|
+
},
|
|
49
|
+
onError: error => {
|
|
50
|
+
if (completed) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
completed = true
|
|
54
|
+
unsubscribe()
|
|
55
|
+
resolve({ status: "error", error })
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
if (completed) {
|
|
59
|
+
unsubscribe()
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { customBlock } from "../../context/index.js"
|
|
3
|
+
import { getDataSourceQueryOptionsIdentity } from "../bridge/resolveDataSourceQuery.js"
|
|
4
4
|
import type { UseDataSourceOptions, UseDataSourceResult } from "../types.js"
|
|
5
5
|
|
|
6
6
|
const EMPTY_DATA_SOURCE_RESULT: UseDataSourceResult = {
|
|
@@ -21,8 +21,8 @@ type DataSourceHookState = {
|
|
|
21
21
|
* Reads from the data source mapped to the given semantic `key`.
|
|
22
22
|
*
|
|
23
23
|
* @param key - The semantic data source key the block is wired to (e.g. `"people"`).
|
|
24
|
-
* @param options - Optional live snapshot options.
|
|
25
|
-
*
|
|
24
|
+
* @param options - Optional live snapshot options. The host enforces the maximum row
|
|
25
|
+
* limit. `sorts` are applied in array order.
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* const { items, propertyIdsByKey, isLoading, hasMore, error } = useDataSource("default", { limit: 25 })
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { CustomBlockDataSourceResolutionErrorInfo } from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
|
|
2
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/notionDataSource.js"
|
|
3
|
+
import type { NotionDataSourceId } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
4
|
+
import type { CustomBlockHostState } from "../context/hostState.js"
|
|
5
|
+
import { dataSourceInaccessibleError } from "./dataSourceInaccessibleError.js"
|
|
6
|
+
|
|
7
|
+
export function resolvePageDataSource(args: {
|
|
8
|
+
hostState: CustomBlockHostState
|
|
9
|
+
key: string
|
|
10
|
+
}):
|
|
11
|
+
| {
|
|
12
|
+
status: "success"
|
|
13
|
+
dataSource: NotionDataSource
|
|
14
|
+
dataSourceId: NotionDataSourceId
|
|
15
|
+
}
|
|
16
|
+
| { status: "error"; error: CustomBlockDataSourceResolutionErrorInfo } {
|
|
17
|
+
const { hostState, key } = args
|
|
18
|
+
if (hostState.status !== "initialized") {
|
|
19
|
+
return {
|
|
20
|
+
status: "error",
|
|
21
|
+
error: {
|
|
22
|
+
code: "unknown_data_source_key",
|
|
23
|
+
message: `Cannot resolve data source key "${key}" before the host has initialized the SDK.`,
|
|
24
|
+
isRetryable: false,
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const dataSource = hostState.dataSources.find(source => source.key === key)
|
|
29
|
+
if (dataSource === undefined) {
|
|
30
|
+
return {
|
|
31
|
+
status: "error",
|
|
32
|
+
error: {
|
|
33
|
+
code: "unknown_data_source_key",
|
|
34
|
+
message: `Unknown data source key "${key}". Known keys: [${hostState.dataSources.map(source => source.key).join(", ")}].`,
|
|
35
|
+
isRetryable: false,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (dataSource.inaccessible === true) {
|
|
40
|
+
return { status: "error", error: dataSourceInaccessibleError(key) }
|
|
41
|
+
}
|
|
42
|
+
if (dataSource.collectionPointer === undefined) {
|
|
43
|
+
return {
|
|
44
|
+
status: "error",
|
|
45
|
+
error: {
|
|
46
|
+
code: "unmapped_data_source",
|
|
47
|
+
message: `Data source "${key}" has not been mapped to a database yet.`,
|
|
48
|
+
isRetryable: false,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
status: "success",
|
|
54
|
+
dataSource,
|
|
55
|
+
dataSourceId: dataSource.collectionPointer.id,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomBlockQueryDataSourceErrorInfo,
|
|
3
|
+
QueryDataSourceResultMessage,
|
|
4
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
5
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/notionDataSource.js"
|
|
6
|
+
import { getBridge } from "../bridge/getBridge.js"
|
|
7
|
+
import { makeNotionPage } from "../pages/makeNotionPage.js"
|
|
8
|
+
import { notifyListener } from "../utils/notifyListener.js"
|
|
9
|
+
import { resolveDataSourceQuery } from "./bridge/resolveDataSourceQuery.js"
|
|
10
|
+
import type { SubscribeToDataSourceArgs } from "./types.js"
|
|
11
|
+
|
|
12
|
+
export function subscribeToDataSource(
|
|
13
|
+
args: SubscribeToDataSourceArgs,
|
|
14
|
+
): () => void
|
|
15
|
+
/** @deprecated Pass onError in the first argument instead. */
|
|
16
|
+
export function subscribeToDataSource(
|
|
17
|
+
args: SubscribeToDataSourceArgs,
|
|
18
|
+
onError?: (error: CustomBlockQueryDataSourceErrorInfo) => void,
|
|
19
|
+
): () => void
|
|
20
|
+
export function subscribeToDataSource(
|
|
21
|
+
{
|
|
22
|
+
key,
|
|
23
|
+
onSnapshot,
|
|
24
|
+
onError: providedOnError,
|
|
25
|
+
options: providedOptions = {},
|
|
26
|
+
}: SubscribeToDataSourceArgs,
|
|
27
|
+
legacyOnError?: (error: CustomBlockQueryDataSourceErrorInfo) => void,
|
|
28
|
+
): () => void {
|
|
29
|
+
const onError = providedOnError ?? legacyOnError
|
|
30
|
+
const options = structuredClone(providedOptions)
|
|
31
|
+
const bridge = getBridge()
|
|
32
|
+
const subscriptionId = `data-source:${globalThis.crypto.randomUUID()}`
|
|
33
|
+
let active = true
|
|
34
|
+
let dataSource: NotionDataSource | undefined
|
|
35
|
+
let result: QueryDataSourceResultMessage | undefined
|
|
36
|
+
let bindingSignature: string | null | undefined
|
|
37
|
+
|
|
38
|
+
const deliverSnapshot = (isLoading: boolean) => {
|
|
39
|
+
const source = dataSource
|
|
40
|
+
const snapshot = {
|
|
41
|
+
items:
|
|
42
|
+
result?.status === "success" && source !== undefined
|
|
43
|
+
? result.items.map(bridgePage =>
|
|
44
|
+
makeNotionPage({ bridgePage, dataSource: source, bridge }),
|
|
45
|
+
)
|
|
46
|
+
: [],
|
|
47
|
+
propertyIdsByKey: source?.propertyIdsByKey ?? {},
|
|
48
|
+
isLoading,
|
|
49
|
+
hasMore: result?.status === "success" && result.hasMore,
|
|
50
|
+
}
|
|
51
|
+
notifyListener(() => onSnapshot(snapshot))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const deliverError = (error: CustomBlockQueryDataSourceErrorInfo) => {
|
|
55
|
+
if (onError !== undefined) {
|
|
56
|
+
notifyListener(() => onError(error))
|
|
57
|
+
} else {
|
|
58
|
+
deliverSnapshot(false)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleHostChange = () => {
|
|
63
|
+
if (!active) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
const hostState = bridge.getHostState()
|
|
67
|
+
if (hostState.status !== "initialized") {
|
|
68
|
+
deliverSnapshot(false)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const nextSource = hostState.dataSources.find(source => source.key === key)
|
|
73
|
+
// Context updates and unchanged bindings preserve object identity. Skip
|
|
74
|
+
// after initial validation if the object has not changed.
|
|
75
|
+
if (bindingSignature !== undefined && nextSource === dataSource) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
const signature =
|
|
79
|
+
nextSource === undefined ? null : JSON.stringify(nextSource)
|
|
80
|
+
if (signature === bindingSignature) {
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
const backingSourceChanged =
|
|
84
|
+
bindingSignature !== undefined &&
|
|
85
|
+
dataSource?.collectionPointer?.id !== nextSource?.collectionPointer?.id
|
|
86
|
+
bindingSignature = signature
|
|
87
|
+
dataSource = nextSource
|
|
88
|
+
if (backingSourceChanged) {
|
|
89
|
+
result = undefined
|
|
90
|
+
}
|
|
91
|
+
const resolved = resolveDataSourceQuery({
|
|
92
|
+
dataSources: hostState.dataSources,
|
|
93
|
+
key,
|
|
94
|
+
options,
|
|
95
|
+
})
|
|
96
|
+
if (resolved.status === "error") {
|
|
97
|
+
// A new backing source must clear previously delivered rows even when validation fails.
|
|
98
|
+
if (backingSourceChanged && onError !== undefined) {
|
|
99
|
+
deliverSnapshot(false)
|
|
100
|
+
}
|
|
101
|
+
deliverError(resolved.error)
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
bridge.postToHost({
|
|
105
|
+
type: "queryDataSource",
|
|
106
|
+
subscriptionId,
|
|
107
|
+
...resolved.query,
|
|
108
|
+
})
|
|
109
|
+
deliverSnapshot(true)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const unsubscribeResults = bridge.subscribeToDataSourceQueryResults(
|
|
113
|
+
subscriptionId,
|
|
114
|
+
message => {
|
|
115
|
+
result = message
|
|
116
|
+
if (message.status === "error") {
|
|
117
|
+
deliverError(message.error)
|
|
118
|
+
} else {
|
|
119
|
+
deliverSnapshot(false)
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
)
|
|
123
|
+
const unsubscribeHost = bridge.subscribe(handleHostChange)
|
|
124
|
+
try {
|
|
125
|
+
handleHostChange()
|
|
126
|
+
} catch (error) {
|
|
127
|
+
unsubscribe()
|
|
128
|
+
throw error
|
|
129
|
+
}
|
|
130
|
+
return unsubscribe
|
|
131
|
+
|
|
132
|
+
function unsubscribe() {
|
|
133
|
+
if (!active) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
active = false
|
|
137
|
+
unsubscribeHost()
|
|
138
|
+
unsubscribeResults()
|
|
139
|
+
if (bindingSignature !== undefined) {
|
|
140
|
+
bridge.postToHost({ type: "unsubscribeDataSourceQuery", subscriptionId })
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/dataSources/messages/queryDataSource.js"
|
|
2
|
+
import type { CustomBlockCreatePageErrorInfo } from "@notionhq/custom-blocks-protocol/pages/messages/createPage.js"
|
|
3
|
+
import type { CustomBlockGetPageErrorInfo } from "@notionhq/custom-blocks-protocol/pages/messages/getPage.js"
|
|
4
|
+
import type { NotionPage } from "../pages/types.js"
|
|
5
|
+
import type {
|
|
6
|
+
NotionDataSourceFilter,
|
|
7
|
+
NotionDataSourceSort,
|
|
8
|
+
} from "./filters/types.js"
|
|
9
|
+
|
|
10
|
+
export type DataSourcesPageResult =
|
|
11
|
+
| {
|
|
12
|
+
status: "success"
|
|
13
|
+
page: NotionPage
|
|
14
|
+
propertyIdsByKey: Record<string, string | undefined>
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
status: "error"
|
|
18
|
+
error: CustomBlockGetPageErrorInfo | CustomBlockCreatePageErrorInfo
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type DataSourcesQueryResult =
|
|
22
|
+
| ({ status: "success" } & DataSourceSnapshot)
|
|
23
|
+
| { status: "error"; error: CustomBlockQueryDataSourceErrorInfo }
|
|
24
|
+
|
|
25
|
+
/** Latest live snapshot of a data source query. */
|
|
26
|
+
export type DataSourceSnapshot = {
|
|
27
|
+
items: NotionPage[]
|
|
28
|
+
propertyIdsByKey: { [key: string]: string | undefined }
|
|
29
|
+
isLoading: boolean
|
|
30
|
+
hasMore: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type DataSourceQueryOptions = {
|
|
34
|
+
/** Maximum number of rows to request from the host. Defaults to 20. */
|
|
35
|
+
limit?: number
|
|
36
|
+
/** Optional property filter. The SDK resolves semantic keys before it sends the query. */
|
|
37
|
+
filter?: NotionDataSourceFilter
|
|
38
|
+
/** Optional property sorts. The host applies them in array order. */
|
|
39
|
+
sorts?: NotionDataSourceSort[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type SubscribeToDataSourceArgs = {
|
|
43
|
+
key: string
|
|
44
|
+
onSnapshot: (snapshot: DataSourceSnapshot) => void
|
|
45
|
+
onError?: (error: CustomBlockQueryDataSourceErrorInfo) => void
|
|
46
|
+
options?: DataSourceQueryOptions
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type UseDataSourceResult = DataSourceSnapshot & {
|
|
50
|
+
error: CustomBlockQueryDataSourceErrorInfo | undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type UseDataSourceOptions = DataSourceQueryOptions
|