@notionhq/custom-blocks 0.0.58
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/HOST.md +171 -0
- package/README.md +57 -0
- package/bin/cli/attach.js +180 -0
- package/bin/cli/cli.js +248 -0
- package/bin/cli/create.js +106 -0
- package/bin/cli/datasources.js +255 -0
- package/bin/cli/deploy.js +109 -0
- package/bin/cli/ids.js +13 -0
- package/bin/cli/ntn.js +95 -0
- package/bin/cli/pullData.js +76 -0
- package/bin/cli/pullManifest.js +158 -0
- package/bin/cli/target.js +95 -0
- package/bin/src/bridge/dataSources/propertySchema.js +148 -0
- package/bin/src/bridge/manifest.js +40 -0
- package/dist/autoResize.d.ts +4 -0
- package/dist/autoResize.d.ts.map +1 -0
- package/dist/autoResize.js +71 -0
- package/dist/bridge/SandboxBridge.d.ts +92 -0
- package/dist/bridge/SandboxBridge.d.ts.map +1 -0
- package/dist/bridge/SandboxBridge.js +718 -0
- package/dist/bridge/dataSources/dataSource.d.ts +732 -0
- package/dist/bridge/dataSources/dataSource.d.ts.map +1 -0
- package/dist/bridge/dataSources/dataSource.js +37 -0
- package/dist/bridge/dataSources/dataSourcePage.d.ts +118 -0
- package/dist/bridge/dataSources/dataSourcePage.d.ts.map +1 -0
- package/dist/bridge/dataSources/dataSourcePage.js +14 -0
- package/dist/bridge/dataSources/dataSourceValue.d.ts +67 -0
- package/dist/bridge/dataSources/dataSourceValue.d.ts.map +1 -0
- package/dist/bridge/dataSources/dataSourceValue.js +14 -0
- package/dist/bridge/dataSources/dateValue.d.ts +158 -0
- package/dist/bridge/dataSources/dateValue.d.ts.map +1 -0
- package/dist/bridge/dataSources/dateValue.js +59 -0
- package/dist/bridge/dataSources/errors.d.ts +6 -0
- package/dist/bridge/dataSources/errors.d.ts.map +1 -0
- package/dist/bridge/dataSources/errors.js +4 -0
- package/dist/bridge/dataSources/propertySchema.d.ts +191 -0
- package/dist/bridge/dataSources/propertySchema.d.ts.map +1 -0
- package/dist/bridge/dataSources/propertySchema.js +148 -0
- package/dist/bridge/dataSources/recordPointer.d.ts +10 -0
- package/dist/bridge/dataSources/recordPointer.d.ts.map +1 -0
- package/dist/bridge/dataSources/recordPointer.js +8 -0
- package/dist/bridge/dataSources/resolve.d.ts +22 -0
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolve.js +65 -0
- package/dist/bridge/dataSources/resolveProperty.d.ts +41 -0
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolveProperty.js +73 -0
- package/dist/bridge/errors.d.ts +12 -0
- package/dist/bridge/errors.d.ts.map +1 -0
- package/dist/bridge/errors.js +6 -0
- package/dist/bridge/hostState.d.ts +65 -0
- package/dist/bridge/hostState.d.ts.map +1 -0
- package/dist/bridge/hostState.js +65 -0
- package/dist/bridge/ids.d.ts +39 -0
- package/dist/bridge/ids.d.ts.map +1 -0
- package/dist/bridge/ids.js +5 -0
- package/dist/bridge/incomingType.d.ts +10 -0
- package/dist/bridge/incomingType.d.ts.map +1 -0
- package/dist/bridge/incomingType.js +17 -0
- package/dist/bridge/loadManifest.d.ts +25 -0
- package/dist/bridge/loadManifest.d.ts.map +1 -0
- package/dist/bridge/loadManifest.js +68 -0
- package/dist/bridge/manifest.d.ts +66 -0
- package/dist/bridge/manifest.d.ts.map +1 -0
- package/dist/bridge/manifest.js +40 -0
- package/dist/bridge/messages/createPage.d.ts +225 -0
- package/dist/bridge/messages/createPage.d.ts.map +1 -0
- package/dist/bridge/messages/createPage.js +46 -0
- package/dist/bridge/messages/createPageResult.d.ts +211 -0
- package/dist/bridge/messages/createPageResult.d.ts.map +1 -0
- package/dist/bridge/messages/createPageResult.js +28 -0
- package/dist/bridge/messages/currentUserChanged.d.ts +19 -0
- package/dist/bridge/messages/currentUserChanged.d.ts.map +1 -0
- package/dist/bridge/messages/currentUserChanged.js +9 -0
- package/dist/bridge/messages/dataSourcesChanged.d.ts +158 -0
- package/dist/bridge/messages/dataSourcesChanged.d.ts.map +1 -0
- package/dist/bridge/messages/dataSourcesChanged.js +13 -0
- package/dist/bridge/messages/getPage.d.ts +216 -0
- package/dist/bridge/messages/getPage.d.ts.map +1 -0
- package/dist/bridge/messages/getPage.js +33 -0
- package/dist/bridge/messages/getUser.d.ts +45 -0
- package/dist/bridge/messages/getUser.d.ts.map +1 -0
- package/dist/bridge/messages/getUser.js +32 -0
- package/dist/bridge/messages/hostToSandbox.d.ts +1089 -0
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -0
- package/dist/bridge/messages/hostToSandbox.js +32 -0
- package/dist/bridge/messages/init.d.ts +209 -0
- package/dist/bridge/messages/init.d.ts.map +1 -0
- package/dist/bridge/messages/init.js +47 -0
- package/dist/bridge/messages/invalidHostMessage.d.ts +15 -0
- package/dist/bridge/messages/invalidHostMessage.d.ts.map +1 -0
- package/dist/bridge/messages/invalidHostMessage.js +13 -0
- package/dist/bridge/messages/invalidSandboxMessage.d.ts +15 -0
- package/dist/bridge/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/bridge/messages/invalidSandboxMessage.js +13 -0
- package/dist/bridge/messages/listUsers.d.ts +53 -0
- package/dist/bridge/messages/listUsers.d.ts.map +1 -0
- package/dist/bridge/messages/listUsers.js +33 -0
- package/dist/bridge/messages/pageChanged.d.ts +12 -0
- package/dist/bridge/messages/pageChanged.d.ts.map +1 -0
- package/dist/bridge/messages/pageChanged.js +9 -0
- package/dist/bridge/messages/parentChanged.d.ts +22 -0
- package/dist/bridge/messages/parentChanged.d.ts.map +1 -0
- package/dist/bridge/messages/parentChanged.js +9 -0
- package/dist/bridge/messages/queryDataSource.d.ts +20 -0
- package/dist/bridge/messages/queryDataSource.d.ts.map +1 -0
- package/dist/bridge/messages/queryDataSource.js +19 -0
- package/dist/bridge/messages/queryDataSourceResult.d.ts +90 -0
- package/dist/bridge/messages/queryDataSourceResult.d.ts.map +1 -0
- package/dist/bridge/messages/queryDataSourceResult.js +21 -0
- package/dist/bridge/messages/ready.d.ts +45 -0
- package/dist/bridge/messages/ready.d.ts.map +1 -0
- package/dist/bridge/messages/ready.js +37 -0
- package/dist/bridge/messages/resize.d.ts +12 -0
- package/dist/bridge/messages/resize.d.ts.map +1 -0
- package/dist/bridge/messages/resize.js +10 -0
- package/dist/bridge/messages/sandboxToHost.d.ts +410 -0
- package/dist/bridge/messages/sandboxToHost.d.ts.map +1 -0
- package/dist/bridge/messages/sandboxToHost.js +25 -0
- package/dist/bridge/messages/themeChanged.d.ts +11 -0
- package/dist/bridge/messages/themeChanged.d.ts.map +1 -0
- package/dist/bridge/messages/themeChanged.js +10 -0
- package/dist/bridge/messages/updatePage.d.ts +171 -0
- package/dist/bridge/messages/updatePage.d.ts.map +1 -0
- package/dist/bridge/messages/updatePage.js +15 -0
- package/dist/bridge/messages/updatePageResult.d.ts +210 -0
- package/dist/bridge/messages/updatePageResult.d.ts.map +1 -0
- package/dist/bridge/messages/updatePageResult.js +27 -0
- package/dist/bridge/pages/page.d.ts +600 -0
- package/dist/bridge/pages/page.d.ts.map +1 -0
- package/dist/bridge/pages/page.js +217 -0
- package/dist/bridge/parent.d.ts +25 -0
- package/dist/bridge/parent.d.ts.map +1 -0
- package/dist/bridge/parent.js +11 -0
- package/dist/bridge/pendingRequests.d.ts +14 -0
- package/dist/bridge/pendingRequests.d.ts.map +1 -0
- package/dist/bridge/pendingRequests.js +27 -0
- package/dist/bridge/sandboxClient.d.ts +63 -0
- package/dist/bridge/sandboxClient.d.ts.map +1 -0
- package/dist/bridge/sandboxClient.js +92 -0
- package/dist/bridge/theme.d.ts +4 -0
- package/dist/bridge/theme.d.ts.map +1 -0
- package/dist/bridge/theme.js +2 -0
- package/dist/bridge/users/user.d.ts +36 -0
- package/dist/bridge/users/user.d.ts.map +1 -0
- package/dist/bridge/users/user.js +19 -0
- package/dist/customBlock.d.ts +36 -0
- package/dist/customBlock.d.ts.map +1 -0
- package/dist/customBlock.js +65 -0
- package/dist/host/createCustomBlockHost.d.ts +34 -0
- package/dist/host/createCustomBlockHost.d.ts.map +1 -0
- package/dist/host/createCustomBlockHost.js +278 -0
- package/dist/host/lifecycle/initErrors.d.ts +10 -0
- package/dist/host/lifecycle/initErrors.d.ts.map +1 -0
- package/dist/host/lifecycle/initErrors.js +123 -0
- package/dist/host/lifecycle/ready.d.ts +8 -0
- package/dist/host/lifecycle/ready.d.ts.map +1 -0
- package/dist/host/lifecycle/ready.js +24 -0
- package/dist/host/lifecycle/types.d.ts +24 -0
- package/dist/host/lifecycle/types.d.ts.map +1 -0
- package/dist/host/lifecycle/types.js +1 -0
- package/dist/host/messages/invalidSandboxMessage.d.ts +7 -0
- package/dist/host/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/host/messages/invalidSandboxMessage.js +24 -0
- package/dist/host/messages/types.d.ts +60 -0
- package/dist/host/messages/types.d.ts.map +1 -0
- package/dist/host/messages/types.js +1 -0
- package/dist/host/queries/querySubscriptions.d.ts +20 -0
- package/dist/host/queries/querySubscriptions.d.ts.map +1 -0
- package/dist/host/queries/querySubscriptions.js +29 -0
- package/dist/host/queries/types.d.ts +9 -0
- package/dist/host/queries/types.d.ts.map +1 -0
- package/dist/host/queries/types.js +1 -0
- package/dist/host.d.ts +73 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +42 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/init.d.ts +53 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +87 -0
- package/dist/react/DebugMessageLog.d.ts +2 -0
- package/dist/react/DebugMessageLog.d.ts.map +1 -0
- package/dist/react/DebugMessageLog.js +22 -0
- package/dist/react/NotionCustomBlock.css +110 -0
- package/dist/react/NotionCustomBlock.d.ts +50 -0
- package/dist/react/NotionCustomBlock.d.ts.map +1 -0
- package/dist/react/NotionCustomBlock.js +81 -0
- package/dist/react/index.d.ts +14 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +13 -0
- package/dist/react/standalonePreview.d.ts +2 -0
- package/dist/react/standalonePreview.d.ts.map +1 -0
- package/dist/react/standalonePreview.js +26 -0
- package/dist/react/useCustomBlockAutoResize.d.ts +30 -0
- package/dist/react/useCustomBlockAutoResize.d.ts.map +1 -0
- package/dist/react/useCustomBlockAutoResize.js +35 -0
- package/dist/react/useCustomBlockInit.d.ts +43 -0
- package/dist/react/useCustomBlockInit.d.ts.map +1 -0
- package/dist/react/useCustomBlockInit.js +60 -0
- package/dist/react/useDataSource.d.ts +13 -0
- package/dist/react/useDataSource.d.ts.map +1 -0
- package/dist/react/useDataSource.js +37 -0
- package/dist/react/useHostState.d.ts +2 -0
- package/dist/react/useHostState.d.ts.map +1 -0
- package/dist/react/useHostState.js +5 -0
- package/dist/react/useRuntimeState.d.ts +66 -0
- package/dist/react/useRuntimeState.d.ts.map +1 -0
- package/dist/react/useRuntimeState.js +73 -0
- package/dist/types.d.ts +154 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/docs/block-location.md +83 -0
- package/docs/data-sources.md +186 -0
- package/docs/lifecycle.md +172 -0
- package/docs/manifest.md +42 -0
- package/docs/pages.md +143 -0
- package/docs/users.md +92 -0
- package/package.json +69 -0
- package/src/autoResize.ts +84 -0
- package/src/bridge/SandboxBridge.ts +921 -0
- package/src/bridge/dataSources/dataSource.ts +63 -0
- package/src/bridge/dataSources/dataSourcePage.ts +71 -0
- package/src/bridge/dataSources/dataSourceValue.ts +19 -0
- package/src/bridge/dataSources/dateValue.ts +96 -0
- package/src/bridge/dataSources/errors.ts +14 -0
- package/src/bridge/dataSources/propertySchema.ts +186 -0
- package/src/bridge/dataSources/recordPointer.ts +13 -0
- package/src/bridge/dataSources/resolve.ts +99 -0
- package/src/bridge/dataSources/resolveProperty.ts +130 -0
- package/src/bridge/errors.ts +13 -0
- package/src/bridge/hostState.ts +154 -0
- package/src/bridge/ids.ts +58 -0
- package/src/bridge/incomingType.ts +19 -0
- package/src/bridge/loadManifest.ts +89 -0
- package/src/bridge/manifest.ts +53 -0
- package/src/bridge/messages/createPage.ts +67 -0
- package/src/bridge/messages/createPageResult.ts +52 -0
- package/src/bridge/messages/currentUserChanged.ts +14 -0
- package/src/bridge/messages/dataSourcesChanged.ts +18 -0
- package/src/bridge/messages/getPage.ts +52 -0
- package/src/bridge/messages/getUser.ts +48 -0
- package/src/bridge/messages/hostToSandbox.ts +37 -0
- package/src/bridge/messages/init.ts +81 -0
- package/src/bridge/messages/invalidHostMessage.ts +16 -0
- package/src/bridge/messages/invalidSandboxMessage.ts +18 -0
- package/src/bridge/messages/listUsers.ts +49 -0
- package/src/bridge/messages/pageChanged.ts +12 -0
- package/src/bridge/messages/parentChanged.ts +14 -0
- package/src/bridge/messages/queryDataSource.ts +24 -0
- package/src/bridge/messages/queryDataSourceResult.ts +38 -0
- package/src/bridge/messages/ready.ts +41 -0
- package/src/bridge/messages/resize.ts +13 -0
- package/src/bridge/messages/sandboxToHost.ts +30 -0
- package/src/bridge/messages/themeChanged.ts +15 -0
- package/src/bridge/messages/updatePage.ts +22 -0
- package/src/bridge/messages/updatePageResult.ts +49 -0
- package/src/bridge/pages/page.ts +281 -0
- package/src/bridge/parent.ts +27 -0
- package/src/bridge/pendingRequests.ts +28 -0
- package/src/bridge/sandboxClient.ts +137 -0
- package/src/bridge/theme.ts +5 -0
- package/src/bridge/users/user.ts +31 -0
- package/src/css.d.ts +1 -0
- package/src/customBlock.ts +102 -0
- package/src/host/createCustomBlockHost.ts +392 -0
- package/src/host/lifecycle/initErrors.ts +132 -0
- package/src/host/lifecycle/ready.ts +36 -0
- package/src/host/lifecycle/types.ts +28 -0
- package/src/host/messages/invalidSandboxMessage.ts +38 -0
- package/src/host/messages/types.ts +67 -0
- package/src/host/queries/querySubscriptions.ts +52 -0
- package/src/host/queries/types.ts +16 -0
- package/src/host.ts +167 -0
- package/src/index.ts +115 -0
- package/src/init.ts +143 -0
- package/src/react/DebugMessageLog.tsx +30 -0
- package/src/react/NotionCustomBlock.css +110 -0
- package/src/react/NotionCustomBlock.tsx +151 -0
- package/src/react/index.ts +28 -0
- package/src/react/standalonePreview.ts +28 -0
- package/src/react/useCustomBlockAutoResize.ts +46 -0
- package/src/react/useCustomBlockInit.ts +91 -0
- package/src/react/useDataSource.ts +47 -0
- package/src/react/useHostState.ts +9 -0
- package/src/react/useRuntimeState.ts +85 -0
- package/src/types.ts +175 -0
- package/src/utils.ts +13 -0
- package/src/version.ts +8 -0
- package/vite-plugin/index.d.ts +46 -0
- package/vite-plugin/index.js +115 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { NotionDataSource } from "./dataSources/dataSource.js";
|
|
2
|
+
import type { NotionDataSourcePage, NotionDataSourcePageBridge, NotionDataSourcePageUpdateInput, NotionDataSourcePageUpdateResult } from "./dataSources/dataSourcePage.js";
|
|
3
|
+
import type { NotionPropertySchema } from "./dataSources/propertySchema.js";
|
|
4
|
+
import type { NotionBlockId } from "./ids.js";
|
|
5
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "./messages/queryDataSourceResult.js";
|
|
6
|
+
import type { CustomBlockPage, NotionPageId } from "./pages/page.js";
|
|
7
|
+
import type { NotionParent } from "./parent.js";
|
|
8
|
+
import type { NotionTheme } from "./theme.js";
|
|
9
|
+
import type { NotionUser } from "./users/user.js";
|
|
10
|
+
export type CustomBlockHostState = UninitializedHostState | InitializedHostState;
|
|
11
|
+
export type UninitializedHostState = {
|
|
12
|
+
status: "uninitialized";
|
|
13
|
+
theme: NotionTheme;
|
|
14
|
+
};
|
|
15
|
+
export type InitializedHostState = {
|
|
16
|
+
status: "initialized";
|
|
17
|
+
theme: NotionTheme;
|
|
18
|
+
blockId: NotionBlockId;
|
|
19
|
+
parent: NotionParent;
|
|
20
|
+
page: CustomBlockPage;
|
|
21
|
+
currentUser: NotionUser;
|
|
22
|
+
dataSources: NotionDataSource[];
|
|
23
|
+
dataSourceState: Record<string, DataSourceQueryState>;
|
|
24
|
+
};
|
|
25
|
+
export type DataSourceQueryState = {
|
|
26
|
+
/** Latest pages from the host as parsed from the bridge. `propertiesByKey` is derived lazily. */
|
|
27
|
+
items: NotionDataSourcePageBridge[];
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
hasMore: boolean;
|
|
30
|
+
error?: CustomBlockQueryDataSourceErrorInfo;
|
|
31
|
+
latestRequestId?: string;
|
|
32
|
+
latestSnapshotId?: string;
|
|
33
|
+
latestLimit?: number;
|
|
34
|
+
};
|
|
35
|
+
export declare function createEmptyDataSourceQueryState(): DataSourceQueryState;
|
|
36
|
+
/**
|
|
37
|
+
* Resolved page + schema views for a single data source, keyed by raw property
|
|
38
|
+
* ID and by user-defined key. Re-derived from `propertyIdsByKey` on every read so
|
|
39
|
+
* renames don't require a re-query.
|
|
40
|
+
*/
|
|
41
|
+
export type DataSourceQueryView = {
|
|
42
|
+
items: NotionDataSourcePage[];
|
|
43
|
+
collectionSchema?: NotionDataSource["collectionSchema"];
|
|
44
|
+
propertySchemasById: {
|
|
45
|
+
[propertyId: string]: NotionPropertySchema;
|
|
46
|
+
};
|
|
47
|
+
propertySchemasByKey: {
|
|
48
|
+
[key: string]: NotionPropertySchema | undefined;
|
|
49
|
+
};
|
|
50
|
+
isLoading: boolean;
|
|
51
|
+
hasMore: boolean;
|
|
52
|
+
error?: CustomBlockQueryDataSourceErrorInfo;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Per-row callback that resolves property keys against the data source and forwards the
|
|
56
|
+
* resulting write to the bridge. Injected by callers (typically the SDK singleton in `init.ts`)
|
|
57
|
+
* so this module stays free of bridge-instance dependencies.
|
|
58
|
+
*/
|
|
59
|
+
export type UpdateDataSourcePageFn = (args: {
|
|
60
|
+
dataSource: NotionDataSource;
|
|
61
|
+
pageId: NotionPageId;
|
|
62
|
+
input: NotionDataSourcePageUpdateInput;
|
|
63
|
+
}) => Promise<NotionDataSourcePageUpdateResult>;
|
|
64
|
+
export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, updateDataSourcePage: UpdateDataSourcePageFn): DataSourceQueryView;
|
|
65
|
+
//# sourceMappingURL=hostState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EACX,oBAAoB,EACpB,0BAA0B,EAC1B,+BAA+B,EAC/B,gCAAgC,EAChC,MAAM,iCAAiC,CAAA;AAExC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAA;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GAAG,oBAAoB,CAAA;AAEhF,MAAM,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,WAAW,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,iGAAiG;IACjG,KAAK,EAAE,0BAA0B,EAAE,CAAA;IACnC,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,mCAAmC,CAAA;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,wBAAgB,+BAA+B,IAAI,oBAAoB,CAMtE;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,oBAAoB,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;IACvD,mBAAmB,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE,CAAA;IACnE,oBAAoB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAA;KAAE,CAAA;IACzE,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,mCAAmC,CAAA;CAC3C,CAAA;AAUD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,gBAAgB,CAAA;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,KAAK,EAAE,+BAA+B,CAAA;CACtC,KAAK,OAAO,CAAC,gCAAgC,CAAC,CAAA;AAE/C,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,MAAM,EACX,oBAAoB,EAAE,sBAAsB,GAC1C,mBAAmB,CA8DrB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function createEmptyDataSourceQueryState() {
|
|
2
|
+
return {
|
|
3
|
+
items: [],
|
|
4
|
+
isLoading: false,
|
|
5
|
+
hasMore: false,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
const EMPTY_QUERY_VIEW = {
|
|
9
|
+
items: [],
|
|
10
|
+
propertySchemasById: {},
|
|
11
|
+
propertySchemasByKey: {},
|
|
12
|
+
isLoading: false,
|
|
13
|
+
hasMore: false,
|
|
14
|
+
};
|
|
15
|
+
export function getDataSourceQueryView(hostState, key, updateDataSourcePage) {
|
|
16
|
+
if (hostState.status !== "initialized") {
|
|
17
|
+
return EMPTY_QUERY_VIEW;
|
|
18
|
+
}
|
|
19
|
+
const dataSource = hostState.dataSources.find(entry => entry.key === key);
|
|
20
|
+
const queryState = hostState.dataSourceState[key] ?? createEmptyDataSourceQueryState();
|
|
21
|
+
if (dataSource === undefined) {
|
|
22
|
+
return {
|
|
23
|
+
items: [],
|
|
24
|
+
collectionSchema: undefined,
|
|
25
|
+
propertySchemasById: {},
|
|
26
|
+
propertySchemasByKey: {},
|
|
27
|
+
isLoading: queryState.isLoading,
|
|
28
|
+
hasMore: queryState.hasMore,
|
|
29
|
+
error: queryState.error,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const propertyIdsByKey = dataSource.propertyIdsByKey;
|
|
33
|
+
const propertySchemasById = dataSource.propertySchemasById;
|
|
34
|
+
const resolvedItems = queryState.items.map(entry => {
|
|
35
|
+
const propertiesByKey = {};
|
|
36
|
+
for (const [key, propertyId] of Object.entries(propertyIdsByKey)) {
|
|
37
|
+
propertiesByKey[key] =
|
|
38
|
+
propertyId === undefined ? undefined : entry.propertiesById[propertyId];
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
id: entry.id,
|
|
42
|
+
propertiesById: entry.propertiesById,
|
|
43
|
+
propertiesByKey,
|
|
44
|
+
update: input => updateDataSourcePage({
|
|
45
|
+
dataSource,
|
|
46
|
+
pageId: entry.id,
|
|
47
|
+
input,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
const propertySchemasByKey = {};
|
|
52
|
+
for (const [key, propertyId] of Object.entries(propertyIdsByKey)) {
|
|
53
|
+
propertySchemasByKey[key] =
|
|
54
|
+
propertyId === undefined ? undefined : propertySchemasById[propertyId];
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
items: resolvedItems,
|
|
58
|
+
collectionSchema: dataSource.collectionSchema,
|
|
59
|
+
propertySchemasById,
|
|
60
|
+
propertySchemasByKey,
|
|
61
|
+
isLoading: queryState.isLoading,
|
|
62
|
+
hasMore: queryState.hasMore,
|
|
63
|
+
error: queryState.error,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
declare const notionDataSourceIdBrand: unique symbol;
|
|
3
|
+
declare const notionBlockIdBrand: unique symbol;
|
|
4
|
+
declare const notionPageIdBrand: unique symbol;
|
|
5
|
+
declare const notionSpaceIdBrand: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Branded Notion block ID. Host payloads and SDK APIs use plain strings at runtime,
|
|
8
|
+
* but the brand keeps block IDs from being accidentally mixed with other IDs in TypeScript.
|
|
9
|
+
*/
|
|
10
|
+
export type NotionBlockId = string & {
|
|
11
|
+
readonly [notionBlockIdBrand]: "NotionBlockId";
|
|
12
|
+
};
|
|
13
|
+
export declare const notionBlockIdSchema: v.CustomSchema<NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Branded Notion data source ID. Host payloads and SDK APIs use plain strings at runtime,
|
|
16
|
+
* but the brand keeps data source IDs from being accidentally mixed with other IDs in TypeScript.
|
|
17
|
+
*/
|
|
18
|
+
export type NotionDataSourceId = string & {
|
|
19
|
+
readonly [notionDataSourceIdBrand]: "NotionDataSourceId";
|
|
20
|
+
};
|
|
21
|
+
export declare const notionDataSourceIdSchema: v.CustomSchema<NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Branded Notion page ID. Host payloads and SDK APIs use plain strings at runtime,
|
|
24
|
+
* but the brand keeps page IDs from being accidentally mixed with other IDs in TypeScript.
|
|
25
|
+
*/
|
|
26
|
+
export type NotionPageId = string & {
|
|
27
|
+
readonly [notionPageIdBrand]: "NotionPageId";
|
|
28
|
+
};
|
|
29
|
+
export declare const notionPageIdSchema: v.CustomSchema<NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Branded Notion workspace/space ID. Host payloads and SDK APIs use plain strings at runtime,
|
|
32
|
+
* but the brand keeps space IDs from being accidentally mixed with other IDs in TypeScript.
|
|
33
|
+
*/
|
|
34
|
+
export type NotionSpaceId = string & {
|
|
35
|
+
readonly [notionSpaceIdBrand]: "NotionSpaceId";
|
|
36
|
+
};
|
|
37
|
+
export declare const notionSpaceIdSchema: v.CustomSchema<NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,MAAM,CAAA;AACpD,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAA;AAC/C,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAA;AAC9C,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAA;AAE/C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IACpC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,EAAE,eAAe,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,mBAAmB,0EAG/B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG;IACzC,QAAQ,CAAC,CAAC,uBAAuB,CAAC,EAAE,oBAAoB,CAAA;CACxD,CAAA;AAED,eAAO,MAAM,wBAAwB,+EAGpC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IACnC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,kBAAkB,yEAG9B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IACpC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,EAAE,eAAe,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,mBAAmB,0EAG/B,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const notionBlockIdSchema = v.custom(value => typeof value === "string", "Expected a Notion block ID");
|
|
3
|
+
export const notionDataSourceIdSchema = v.custom(value => typeof value === "string", "Expected a Notion data source ID");
|
|
4
|
+
export const notionPageIdSchema = v.custom(value => typeof value === "string", "Expected a Notion page ID");
|
|
5
|
+
export const notionSpaceIdSchema = v.custom(value => typeof value === "string", "Expected a Notion space ID");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the `type` field off an inbound bridge message, if any.
|
|
3
|
+
*
|
|
4
|
+
* Used by both sides of the bridge after the canonical message schema rejects a payload. We still
|
|
5
|
+
* want to know what type the sender claimed to be sending so we can (a) avoid NACK loops on
|
|
6
|
+
* `invalidHostMessage` / `invalidSandboxMessage` and (b) include the type in the failure reason
|
|
7
|
+
* for debugging.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readIncomingType(data: unknown): string | undefined;
|
|
10
|
+
//# sourceMappingURL=incomingType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incomingType.d.ts","sourceRoot":"","sources":["../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/incomingType.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAUlE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the `type` field off an inbound bridge message, if any.
|
|
3
|
+
*
|
|
4
|
+
* Used by both sides of the bridge after the canonical message schema rejects a payload. We still
|
|
5
|
+
* want to know what type the sender claimed to be sending so we can (a) avoid NACK loops on
|
|
6
|
+
* `invalidHostMessage` / `invalidSandboxMessage` and (b) include the type in the failure reason
|
|
7
|
+
* for debugging.
|
|
8
|
+
*/
|
|
9
|
+
export function readIncomingType(data) {
|
|
10
|
+
if (typeof data === "object" &&
|
|
11
|
+
data !== null &&
|
|
12
|
+
"type" in data &&
|
|
13
|
+
typeof data.type === "string") {
|
|
14
|
+
return data.type;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { type CustomBlockManifest } from "./manifest.js";
|
|
3
|
+
export declare const customBlockReadyErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
+
export type CustomBlockReadyErrorCode = "manifest_unavailable" | "manifest_invalid" | (string & {});
|
|
5
|
+
export declare const customBlockReadyErrorSchema: v.ObjectSchema<{
|
|
6
|
+
readonly code: v.StringSchema<undefined>;
|
|
7
|
+
readonly message: v.StringSchema<undefined>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
export type CustomBlockReadyError = v.InferOutput<typeof customBlockReadyErrorSchema>;
|
|
10
|
+
export type ManifestLoadResult = {
|
|
11
|
+
manifest: CustomBlockManifest | null;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
manifest: null;
|
|
15
|
+
error: CustomBlockReadyError;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Attempts to load a `custom_blocks.json` manifest co-located with the bundle.
|
|
19
|
+
* A missing manifest means the block has no declared data requirements.
|
|
20
|
+
* Other failures return a structured error so the host can reject the manifest.
|
|
21
|
+
* The SDK validates the manifest locally for author feedback; the host still
|
|
22
|
+
* validates the ready message as the iframe trust boundary.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadManifest(): Promise<ManifestLoadResult>;
|
|
25
|
+
//# sourceMappingURL=loadManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadManifest.d.ts","sourceRoot":"","sources":["../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/loadManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,eAAe,CAAA;AAMxE,eAAO,MAAM,+BAA+B,2BAAa,CAAA;AAEzD,MAAM,MAAM,yBAAyB,GAClC,sBAAsB,GACtB,kBAAkB,GAClB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,eAAO,MAAM,2BAA2B;;;aAGtC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAChD,OAAO,2BAA2B,CAClC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAC3B;IACA,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;CAChB,GACD;IACA,QAAQ,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,qBAAqB,CAAA;CAC3B,CAAA;AAEJ;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAgDhE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { manifestSchema } from "./manifest.js";
|
|
3
|
+
const MANIFEST_URL = "custom_blocks.json";
|
|
4
|
+
// The schema accepts any string code. The type lists known codes for
|
|
5
|
+
// autocomplete, with an open string fallback for newer senders.
|
|
6
|
+
export const customBlockReadyErrorCodeSchema = v.string();
|
|
7
|
+
export const customBlockReadyErrorSchema = v.object({
|
|
8
|
+
code: customBlockReadyErrorCodeSchema,
|
|
9
|
+
message: v.string(),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Attempts to load a `custom_blocks.json` manifest co-located with the bundle.
|
|
13
|
+
* A missing manifest means the block has no declared data requirements.
|
|
14
|
+
* Other failures return a structured error so the host can reject the manifest.
|
|
15
|
+
* The SDK validates the manifest locally for author feedback; the host still
|
|
16
|
+
* validates the ready message as the iframe trust boundary.
|
|
17
|
+
*/
|
|
18
|
+
export async function loadManifest() {
|
|
19
|
+
if (typeof fetch !== "function") {
|
|
20
|
+
const message = `No fetch API available; cannot load ${MANIFEST_URL}.`;
|
|
21
|
+
console.warn(`[notion-custom-sdk] ${message}`);
|
|
22
|
+
return {
|
|
23
|
+
manifest: null,
|
|
24
|
+
error: { code: "manifest_unavailable", message },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
let response;
|
|
28
|
+
try {
|
|
29
|
+
response = await fetch(MANIFEST_URL, { credentials: "omit" });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const message = `Could not fetch ${MANIFEST_URL}.`;
|
|
33
|
+
console.warn(`[notion-custom-sdk] ${message}`, error);
|
|
34
|
+
return {
|
|
35
|
+
manifest: null,
|
|
36
|
+
error: { code: "manifest_unavailable", message },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (response.status === 404) {
|
|
40
|
+
const message = `No manifest found at ${MANIFEST_URL} (status ${response.status}).`;
|
|
41
|
+
console.warn(`[notion-custom-sdk] ${message}`);
|
|
42
|
+
return { manifest: null };
|
|
43
|
+
}
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const message = `Could not fetch ${MANIFEST_URL} (status ${response.status}).`;
|
|
46
|
+
console.warn(`[notion-custom-sdk] ${message}`);
|
|
47
|
+
return {
|
|
48
|
+
manifest: null,
|
|
49
|
+
error: { code: "manifest_unavailable", message },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
let json;
|
|
53
|
+
try {
|
|
54
|
+
json = await response.json();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = `Manifest at ${MANIFEST_URL} was not valid JSON.`;
|
|
58
|
+
console.warn(`[notion-custom-sdk] ${message}`, error);
|
|
59
|
+
return { manifest: null, error: { code: "manifest_invalid", message } };
|
|
60
|
+
}
|
|
61
|
+
const parsed = v.safeParse(manifestSchema, json);
|
|
62
|
+
if (!parsed.success) {
|
|
63
|
+
const message = `Manifest at ${MANIFEST_URL} did not match schema.`;
|
|
64
|
+
console.warn(`[notion-custom-sdk] ${message}`, parsed.issues);
|
|
65
|
+
return { manifest: null, error: { code: "manifest_invalid", message } };
|
|
66
|
+
}
|
|
67
|
+
return { manifest: parsed.output };
|
|
68
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* User-authored manifest declaring the data sources the custom block expects.
|
|
4
|
+
* Lives at `custom_blocks.json` in the project root and is forwarded to the host with
|
|
5
|
+
* the bridge `ready` message so the host can pre-bind data sources, surface
|
|
6
|
+
* configuration UI, etc. The `notionCustomBlock` Vite plugin from
|
|
7
|
+
* `@notionhq/custom-blocks/vite` wires the JSON file into the dev server and
|
|
8
|
+
* the build output.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Decorative icon attached to a manifest data source. Mirrors the
|
|
12
|
+
* `emoji` / `external` icon variants the public Notion API uses, so the host
|
|
13
|
+
* can render a recognizable affordance next to the slot in setup UI.
|
|
14
|
+
*/
|
|
15
|
+
export declare const manifestIconSchema: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
16
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
17
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
18
|
+
}, undefined>, v.ObjectSchema<{
|
|
19
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
20
|
+
readonly url: v.StringSchema<undefined>;
|
|
21
|
+
}, undefined>], undefined>;
|
|
22
|
+
export type ManifestIcon = v.InferOutput<typeof manifestIconSchema>;
|
|
23
|
+
export declare const manifestPropertySchema: v.ObjectSchema<{
|
|
24
|
+
readonly name: v.StringSchema<undefined>;
|
|
25
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
26
|
+
readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
27
|
+
}, undefined>;
|
|
28
|
+
export type ManifestProperty = v.InferOutput<typeof manifestPropertySchema>;
|
|
29
|
+
export declare const manifestDataSourceSchema: v.ObjectSchema<{
|
|
30
|
+
readonly name: v.StringSchema<undefined>;
|
|
31
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
32
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
33
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
34
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
35
|
+
}, undefined>, v.ObjectSchema<{
|
|
36
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
37
|
+
readonly url: v.StringSchema<undefined>;
|
|
38
|
+
}, undefined>], undefined>, undefined>;
|
|
39
|
+
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
40
|
+
readonly name: v.StringSchema<undefined>;
|
|
41
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
+
readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
43
|
+
}, undefined>, undefined>, {}>;
|
|
44
|
+
}, undefined>;
|
|
45
|
+
export type ManifestDataSource = v.InferOutput<typeof manifestDataSourceSchema>;
|
|
46
|
+
export declare const manifestSchema: v.ObjectSchema<{
|
|
47
|
+
readonly version: v.LiteralSchema<1, undefined>;
|
|
48
|
+
readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
49
|
+
readonly name: v.StringSchema<undefined>;
|
|
50
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
51
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
52
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
53
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
54
|
+
}, undefined>, v.ObjectSchema<{
|
|
55
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
56
|
+
readonly url: v.StringSchema<undefined>;
|
|
57
|
+
}, undefined>], undefined>, undefined>;
|
|
58
|
+
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
59
|
+
readonly name: v.StringSchema<undefined>;
|
|
60
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
|
|
62
|
+
}, undefined>, undefined>, {}>;
|
|
63
|
+
}, undefined>, undefined>;
|
|
64
|
+
}, undefined>;
|
|
65
|
+
export type CustomBlockManifest = v.InferOutput<typeof manifestSchema>;
|
|
66
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../../../../../../Users/nsarkar/work/custom-blocks/sdk/src/bridge/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B;;;;;;;GAOG;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;0BAS7B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE,eAAO,MAAM,sBAAsB;;;;aAIjC,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE3E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;aAKnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;aAGzB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionPropertyTypeSchema } from "./dataSources/propertySchema.js";
|
|
3
|
+
/**
|
|
4
|
+
* User-authored manifest declaring the data sources the custom block expects.
|
|
5
|
+
* Lives at `custom_blocks.json` in the project root and is forwarded to the host with
|
|
6
|
+
* the bridge `ready` message so the host can pre-bind data sources, surface
|
|
7
|
+
* configuration UI, etc. The `notionCustomBlock` Vite plugin from
|
|
8
|
+
* `@notionhq/custom-blocks/vite` wires the JSON file into the dev server and
|
|
9
|
+
* the build output.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Decorative icon attached to a manifest data source. Mirrors the
|
|
13
|
+
* `emoji` / `external` icon variants the public Notion API uses, so the host
|
|
14
|
+
* can render a recognizable affordance next to the slot in setup UI.
|
|
15
|
+
*/
|
|
16
|
+
export const manifestIconSchema = v.variant("type", [
|
|
17
|
+
v.object({
|
|
18
|
+
type: v.literal("emoji"),
|
|
19
|
+
emoji: v.string(),
|
|
20
|
+
}),
|
|
21
|
+
v.object({
|
|
22
|
+
type: v.literal("external"),
|
|
23
|
+
url: v.string(),
|
|
24
|
+
}),
|
|
25
|
+
]);
|
|
26
|
+
export const manifestPropertySchema = v.object({
|
|
27
|
+
name: v.string(),
|
|
28
|
+
description: v.optional(v.string()),
|
|
29
|
+
type: notionPropertyTypeSchema,
|
|
30
|
+
});
|
|
31
|
+
export const manifestDataSourceSchema = v.object({
|
|
32
|
+
name: v.string(),
|
|
33
|
+
description: v.optional(v.string()),
|
|
34
|
+
icon: v.optional(manifestIconSchema),
|
|
35
|
+
properties: v.optional(v.record(v.string(), manifestPropertySchema), {}),
|
|
36
|
+
});
|
|
37
|
+
export const manifestSchema = v.object({
|
|
38
|
+
version: v.literal(1),
|
|
39
|
+
dataSources: v.record(v.string(), manifestDataSourceSchema),
|
|
40
|
+
});
|