@notionhq/custom-blocks 0.3.3 → 0.3.4

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.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -11
  3. package/dist/bridge/SandboxBridge.d.ts +0 -2
  4. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  5. package/dist/bridge/SandboxBridge.js +5 -8
  6. package/dist/bridge/SandboxInitialization.d.ts +1 -3
  7. package/dist/bridge/SandboxInitialization.d.ts.map +1 -1
  8. package/dist/bridge/SandboxInitialization.js +13 -15
  9. package/dist/bridge/appearance.d.ts +2 -10
  10. package/dist/bridge/appearance.d.ts.map +1 -1
  11. package/dist/bridge/appearance.js +2 -10
  12. package/dist/bridge/dataSources/query.d.ts +1 -2
  13. package/dist/bridge/dataSources/query.d.ts.map +1 -1
  14. package/dist/bridge/dataSources/query.js +15 -398
  15. package/dist/bridge/dataSources/queryFilter.d.ts +10 -0
  16. package/dist/bridge/dataSources/queryFilter.d.ts.map +1 -0
  17. package/dist/bridge/dataSources/queryFilter.js +123 -0
  18. package/dist/bridge/dataSources/resolvePropertyAddress.d.ts +10 -0
  19. package/dist/bridge/dataSources/resolvePropertyAddress.d.ts.map +1 -0
  20. package/dist/bridge/dataSources/resolvePropertyAddress.js +55 -0
  21. package/dist/bridge/dataSources/resolveSorts.d.ts +10 -0
  22. package/dist/bridge/dataSources/resolveSorts.d.ts.map +1 -0
  23. package/dist/bridge/dataSources/resolveSorts.js +80 -0
  24. package/dist/bridge/hostState.d.ts +3 -7
  25. package/dist/bridge/hostState.d.ts.map +1 -1
  26. package/dist/bridge/hostState.js +0 -24
  27. package/dist/bridge/page.d.ts +3 -3
  28. package/dist/bridge/page.d.ts.map +1 -1
  29. package/dist/bridge/page.js +2 -2
  30. package/dist/bridge/readLocalManifest.d.ts +23 -0
  31. package/dist/bridge/readLocalManifest.d.ts.map +1 -0
  32. package/dist/bridge/readLocalManifest.js +46 -0
  33. package/dist/bridge/sandboxClient.d.ts +0 -2
  34. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  35. package/dist/bridge/sandboxClient.js +50 -27
  36. package/dist/protocol/dataSources/dataSourcePage.d.ts +3 -4
  37. package/dist/protocol/dataSources/dataSourcePage.js +2 -3
  38. package/dist/protocol/index.d.ts +1 -0
  39. package/dist/protocol/index.js +1 -0
  40. package/dist/protocol/isLocalBlockServerUrl.d.ts +2 -0
  41. package/dist/protocol/isLocalBlockServerUrl.js +9 -0
  42. package/dist/protocol/messages/connect.d.ts +2 -2
  43. package/dist/protocol/messages/connect.js +2 -2
  44. package/dist/protocol/messages/createPage.d.ts +1 -1
  45. package/dist/protocol/messages/createPage.js +1 -1
  46. package/dist/protocol/messages/createPageResult.d.ts +3 -3
  47. package/dist/protocol/messages/createPageResult.js +4 -4
  48. package/dist/protocol/messages/getPage.d.ts +2 -2
  49. package/dist/protocol/messages/getPage.js +4 -4
  50. package/dist/protocol/messages/hostToSandbox.d.ts +3 -3
  51. package/dist/protocol/messages/hostToSandbox.js +10 -10
  52. package/dist/protocol/messages/init.d.ts +1 -1
  53. package/dist/protocol/messages/queryDataSource.d.ts +24 -0
  54. package/dist/protocol/messages/queryDataSource.js +2 -0
  55. package/dist/protocol/messages/queryDataSourceResult.d.ts +3 -3
  56. package/dist/protocol/messages/queryDataSourceResult.js +5 -5
  57. package/dist/protocol/messages/sandboxToHost.d.ts +8 -0
  58. package/dist/protocol/messages/updatePageResult.d.ts +3 -3
  59. package/dist/protocol/messages/updatePageResult.js +4 -4
  60. package/dist/protocol/pages/page.d.ts +4 -4
  61. package/dist/protocol/pages/page.js +2 -2
  62. package/dist/protocol/parent.d.ts +1 -1
  63. package/dist/protocol/protocolVersion.d.ts +2 -2
  64. package/dist/protocol/protocolVersion.js +2 -2
  65. package/dist/react/useDataSource.d.ts +2 -2
  66. package/dist/react/useDataSource.js +2 -2
  67. package/dist/types.d.ts +5 -5
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/version.js +1 -1
  70. package/docs/block-location.md +6 -4
  71. package/docs/bridge-interceptors.md +4 -0
  72. package/docs/build-tools.md +5 -2
  73. package/docs/data-sources.md +21 -17
  74. package/docs/deployment.md +16 -11
  75. package/docs/errors.md +11 -1
  76. package/docs/lifecycle.md +10 -3
  77. package/docs/pages.md +7 -3
  78. package/docs/users.md +4 -4
  79. package/package.json +3 -2
  80. package/src/bridge/SandboxBridge.ts +5 -10
  81. package/src/bridge/SandboxInitialization.ts +14 -20
  82. package/src/bridge/appearance.ts +2 -10
  83. package/src/bridge/dataSources/query.ts +17 -530
  84. package/src/bridge/dataSources/queryFilter.ts +181 -0
  85. package/src/bridge/dataSources/resolvePropertyAddress.ts +62 -0
  86. package/src/bridge/dataSources/resolveSorts.ts +107 -0
  87. package/src/bridge/hostState.ts +3 -43
  88. package/src/bridge/page.ts +4 -4
  89. package/src/bridge/readLocalManifest.ts +60 -0
  90. package/src/bridge/sandboxClient.ts +63 -41
  91. package/src/react/useDataSource.ts +2 -2
  92. package/src/types.ts +5 -5
  93. package/dist/bridge/loadManifest.d.ts +0 -21
  94. package/dist/bridge/loadManifest.d.ts.map +0 -1
  95. package/dist/bridge/loadManifest.js +0 -85
  96. package/src/bridge/loadManifest.ts +0 -114
@@ -0,0 +1,80 @@
1
+ import { CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES } from "../../protocol/dataSources/propertySchema.js";
2
+ import { notionSortDirectionSchema } from "../../protocol/dataSources/sortDirection.js";
3
+ import { CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS, } from "../../protocol/messages/queryDataSource.js";
4
+ import * as v from "valibot";
5
+ import { resolvePropertyAddress } from "./resolvePropertyAddress.js";
6
+ const supportedDataSourceSortPropertyTypes = new Set(CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES);
7
+ export function resolveSorts(sorts, dataSource) {
8
+ if (sorts === undefined) {
9
+ return { status: "ok" };
10
+ }
11
+ if (!Array.isArray(sorts)) {
12
+ return {
13
+ status: "error",
14
+ error: "Data source query sorts must be an array.",
15
+ };
16
+ }
17
+ if (sorts.length === 0) {
18
+ return { status: "ok" };
19
+ }
20
+ if (sorts.length > CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS) {
21
+ return {
22
+ status: "error",
23
+ error: `Data source query sorts may contain at most ${CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS} entries.`,
24
+ };
25
+ }
26
+ const resolvedSorts = [];
27
+ const seenPropertyIds = new Set();
28
+ for (const sort of sorts) {
29
+ const resolved = resolveSort(sort, dataSource);
30
+ if (resolved.status === "error") {
31
+ return resolved;
32
+ }
33
+ if (seenPropertyIds.has(resolved.sort.propertyId)) {
34
+ return {
35
+ status: "error",
36
+ error: `Data source query sorts cannot contain duplicate property ID "${resolved.sort.propertyId}".`,
37
+ };
38
+ }
39
+ seenPropertyIds.add(resolved.sort.propertyId);
40
+ resolvedSorts.push(resolved.sort);
41
+ }
42
+ return { status: "ok", sorts: resolvedSorts };
43
+ }
44
+ function resolveSort(sort, dataSource) {
45
+ if (typeof sort !== "object" || sort === null || Array.isArray(sort)) {
46
+ return {
47
+ status: "error",
48
+ error: "Data source query sort must be an object.",
49
+ };
50
+ }
51
+ const sortObject = sort;
52
+ if (Object.keys(sortObject).some(key => !["key", "propertyId", "direction"].includes(key))) {
53
+ return {
54
+ status: "error",
55
+ error: "Data source query sort contains unsupported fields.",
56
+ };
57
+ }
58
+ const property = resolvePropertyAddress(sortObject, dataSource);
59
+ if (property.status === "error") {
60
+ return property;
61
+ }
62
+ if (!supportedDataSourceSortPropertyTypes.has(property.propertyType)) {
63
+ return {
64
+ status: "error",
65
+ error: `Data source query sorts do not yet support property type "${property.propertyType}".`,
66
+ };
67
+ }
68
+ const direction = sortObject.direction;
69
+ if (!Object.hasOwn(sortObject, "direction") ||
70
+ !v.is(notionSortDirectionSchema, direction)) {
71
+ return {
72
+ status: "error",
73
+ error: 'Data source query sort direction must be "ascending" or "descending".',
74
+ };
75
+ }
76
+ return {
77
+ status: "ok",
78
+ sort: { propertyId: property.propertyId, direction },
79
+ };
80
+ }
@@ -3,12 +3,12 @@ import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
3
3
  import type { NotionBlockId } from "../protocol/ids.js";
4
4
  import type { CustomBlockManifest } from "../protocol/manifest.js";
5
5
  import type { CustomBlockQueryDataSourceErrorInfo } from "../protocol/messages/queryDataSourceResult.js";
6
- import type { CustomBlockPage, notionPageDataSchema } from "../protocol/pages/page.js";
6
+ import type { bridgePageSchema, CustomBlockPage } from "../protocol/pages/page.js";
7
7
  import type { NotionParent } from "../protocol/parent.js";
8
8
  import type { NotionTheme } from "../protocol/theme.js";
9
9
  import type { NotionUser } from "../protocol/users/user.js";
10
10
  import type { InferOutput } from "valibot";
11
- import type { DataSourceSnapshot, NotionPage } from "../types.js";
11
+ import type { DataSourceSnapshot } from "../types.js";
12
12
  export type CustomBlockHostState = UninitializedHostState | InitializedHostState;
13
13
  export type UninitializedHostState = {
14
14
  status: "uninitialized";
@@ -30,7 +30,7 @@ export type InitializedHostState = {
30
30
  export type DataSourceQueryState = {
31
31
  dataSourceKey: string;
32
32
  /** Latest pages from the host as parsed from the bridge. */
33
- items: InferOutput<typeof notionPageDataSchema>[];
33
+ items: InferOutput<typeof bridgePageSchema>[];
34
34
  isLoading: boolean;
35
35
  hasMore: boolean;
36
36
  error?: CustomBlockQueryDataSourceErrorInfo;
@@ -39,8 +39,4 @@ export type DataSourceQueryState = {
39
39
  };
40
40
  export declare function createEmptyDataSourceQueryState(dataSourceKey: string): DataSourceQueryState;
41
41
  export type DataSourceQueryView = DataSourceSnapshot;
42
- export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, subscriptionId: string, createNotionPage: (args: {
43
- page: InferOutput<typeof notionPageDataSchema>;
44
- dataSource: NotionDataSource | undefined;
45
- }) => NotionPage): DataSourceQueryView;
46
42
  //# sourceMappingURL=hostState.d.ts.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A;CAC5B,CAAA;AAED,wBAAgB,+BAA+B,CAC9C,aAAa,EAAE,MAAM,GACnB,oBAAoB,CAOtB;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAA"}
@@ -6,27 +6,3 @@ export function createEmptyDataSourceQueryState(dataSourceKey) {
6
6
  hasMore: false,
7
7
  };
8
8
  }
9
- const EMPTY_QUERY_VIEW = {
10
- items: [],
11
- propertyIdsByKey: {},
12
- isLoading: false,
13
- hasMore: false,
14
- };
15
- export function getDataSourceQueryView(hostState, key, subscriptionId, createNotionPage) {
16
- if (hostState.status !== "initialized") {
17
- return EMPTY_QUERY_VIEW;
18
- }
19
- const dataSource = hostState.dataSources.find(entry => entry.key === key);
20
- const subscriptionState = hostState.dataSourceState[subscriptionId];
21
- const queryState = subscriptionState?.dataSourceKey === key
22
- ? subscriptionState
23
- : createEmptyDataSourceQueryState(key);
24
- return {
25
- items: dataSource === undefined
26
- ? []
27
- : queryState.items.map(entry => createNotionPage({ page: entry, dataSource })),
28
- propertyIdsByKey: dataSource?.propertyIdsByKey ?? {},
29
- isLoading: queryState.isLoading,
30
- hasMore: queryState.hasMore,
31
- };
32
- }
@@ -1,9 +1,9 @@
1
1
  import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
2
- import type { notionPageDataSchema } from "../protocol/pages/page.js";
2
+ import type { bridgePageSchema } from "../protocol/pages/page.js";
3
3
  import type { InferOutput } from "valibot";
4
4
  import type { NotionPage } from "../types.js";
5
- export declare function toNotionPageFromNotionPageData(args: {
6
- page: InferOutput<typeof notionPageDataSchema>;
5
+ export declare function toNotionPageFromBridgePage(args: {
6
+ bridgePage: InferOutput<typeof bridgePageSchema>;
7
7
  dataSourceKey: string | undefined;
8
8
  getPropertyById: NotionPage["getPropertyById"];
9
9
  getPropertyByKey: NotionPage["getPropertyByKey"];
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/bridge/page.ts"],"names":[],"mappings":"AAAA,OAAO,KA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UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC9C,gBAAgB,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAA;IAChD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;IACpC,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;CACtC,GAAG,UAAU,CAWb;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACxC,MAAM,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;CACjC,GAAG,UAAU,CAAC,aAAa,CAAC,CAiB5B"}
@@ -1,6 +1,6 @@
1
- export function toNotionPageFromNotionPageData(args) {
1
+ export function toNotionPageFromBridgePage(args) {
2
2
  return {
3
- ...args.page,
3
+ ...args.bridgePage,
4
4
  dataSourceKey: args.dataSourceKey ?? null,
5
5
  getPropertyById: args.getPropertyById,
6
6
  getPropertyByKey: args.getPropertyByKey,
@@ -0,0 +1,23 @@
1
+ import type { CustomBlockErrorInfo } from "../protocol/errors.js";
2
+ import { type CustomBlockManifest } from "../protocol/manifest.js";
3
+ export type LocalManifestReadResult = {
4
+ status: "success";
5
+ manifest: CustomBlockManifest | undefined;
6
+ } | {
7
+ status: "error";
8
+ error: CustomBlockErrorInfo<"manifest_invalid">;
9
+ };
10
+ /**
11
+ * Reads and validates JSON from the script with ID `notion-custom-block-manifest`
12
+ * and type `application/json`, injected into the block HTML by dev tooling.
13
+ * The SDK sends this declaration in `connect` so the host can prepare bindings.
14
+ *
15
+ * The URL check limits this development metadata to supported local block servers.
16
+ * Deployed blocks receive their manifest from the host in `init`. Reading this
17
+ * metadata uses the current document and makes no network request.
18
+ */
19
+ export declare function readLocalManifest(args: {
20
+ document: Document;
21
+ url: URL;
22
+ }): LocalManifestReadResult;
23
+ //# sourceMappingURL=readLocalManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readLocalManifest.d.ts","sourceRoot":"","sources":["../../src/bridge/readLocalManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AAEtF,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,8CAA8C,CAAA;AAGrD,MAAM,MAAM,uBAAuB,GAChC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAAE,GAChE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,CAAA;CAAE,CAAA;AAEvE;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,QAAQ,EAAE,QAAQ,CAAA;IAClB,GAAG,EAAE,GAAG,CAAA;CACR,GAAG,uBAAuB,CAwB1B"}
@@ -0,0 +1,46 @@
1
+ import { isLocalBlockServerUrl } from "../protocol/isLocalBlockServerUrl.js";
2
+ import { manifestSchema, } from "../protocol/manifest.js";
3
+ import * as v from "valibot";
4
+ /**
5
+ * Reads and validates JSON from the script with ID `notion-custom-block-manifest`
6
+ * and type `application/json`, injected into the block HTML by dev tooling.
7
+ * The SDK sends this declaration in `connect` so the host can prepare bindings.
8
+ *
9
+ * The URL check limits this development metadata to supported local block servers.
10
+ * Deployed blocks receive their manifest from the host in `init`. Reading this
11
+ * metadata uses the current document and makes no network request.
12
+ */
13
+ export function readLocalManifest(args) {
14
+ if (!isLocalBlockServerUrl(args.url)) {
15
+ return { status: "success", manifest: undefined };
16
+ }
17
+ const metadata = args.document.getElementById("notion-custom-block-manifest");
18
+ if (metadata === null) {
19
+ return { status: "success", manifest: undefined };
20
+ }
21
+ if (metadata.tagName !== "SCRIPT" ||
22
+ metadata.getAttribute("type") !== "application/json") {
23
+ return invalidManifest();
24
+ }
25
+ let input;
26
+ try {
27
+ input = JSON.parse(metadata.textContent ?? "");
28
+ }
29
+ catch {
30
+ return invalidManifest();
31
+ }
32
+ const parsed = v.safeParse(manifestSchema, input);
33
+ return parsed.success
34
+ ? { status: "success", manifest: parsed.output }
35
+ : invalidManifest();
36
+ }
37
+ function invalidManifest() {
38
+ return {
39
+ status: "error",
40
+ error: {
41
+ code: "manifest_invalid",
42
+ message: "The local custom block metadata is not a valid manifest.",
43
+ isRetryable: false,
44
+ },
45
+ };
46
+ }
@@ -2,13 +2,11 @@ import type { NotionPageId } from "../protocol/ids.js";
2
2
  import type { InitMessage } from "../protocol/messages/init.js";
3
3
  import type { CreatePageArgs, CreatePageResult, GetPageResult, GetUserResult, ListUsersArgs, ListUsersResult, NotionUserId, OpenExternalUrlResult, OpenPageOptions, OpenPageResult } from "../types.js";
4
4
  import { type CustomBlockHostState, type DataSourceQueryView } from "./hostState.js";
5
- import type { ManifestLoadResult } from "./loadManifest.js";
6
5
  import type { MessageInterceptor } from "./messageInterceptor.js";
7
6
  import { type MessageLogEntry, type QueryDataSourceArgs, SandboxBridge } from "./SandboxBridge.js";
8
7
  export declare function getBridge(): SandboxBridge;
9
8
  export declare const customBlockHost: {
10
9
  registerMessageInterceptor: (interceptor: MessageInterceptor) => (() => void);
11
- sendConnect: (manifestResult: ManifestLoadResult) => void;
12
10
  initialize: () => Promise<import("../initTypes.js").CustomBlockInitPayload>;
13
11
  subscribe: (listener: () => void) => () => boolean;
14
12
  getState: () => CustomBlockHostState;
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAA;AACpF,OAAO,KAAK,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EAEf,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,cAAc,EAEd,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,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tB,CAAA;AAED,eAAO,MAAM,UAAU;IACtB,WAAW,QAAM,SAAS,eAAe,EAAE;IAI3C,SAAS,aAAa,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;IACH,MAAM,UAAU,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAO1D;;OAEG;IACH,GAAG,WAAW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAOnD;;OAEG;IACH,IAAI,WACK,YAAY,WACX,eAAe,KACtB,OAAO,CAAC,cAAc,CAAC;CAG1B,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,KAAK;IACjB,gEAAgE;IAChE,IAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,qBAAqB,CAAC;CAGnD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;IACH,IAAI,WAAW,aAAa,KAAG,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;IACH,GAAG,WAAW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
@@ -1,5 +1,5 @@
1
- import { getDataSourceQueryView as getDataSourceQueryViewWithBridge, } from "./hostState.js";
2
- import { makeUpdatePageByKey, toNotionPageFromNotionPageData } from "./page.js";
1
+ import { createEmptyDataSourceQueryState, } from "./hostState.js";
2
+ import { makeUpdatePageByKey, toNotionPageFromBridgePage } from "./page.js";
3
3
  import { SandboxBridge, } from "./SandboxBridge.js";
4
4
  let bridge;
5
5
  export function getBridge() {
@@ -12,9 +12,6 @@ export const customBlockHost = {
12
12
  registerMessageInterceptor: (interceptor) => {
13
13
  return getBridge().registerMessageInterceptor(interceptor);
14
14
  },
15
- sendConnect: (manifestResult) => {
16
- getBridge().sendConnect(manifestResult);
17
- },
18
15
  initialize: () => getBridge().initialize(),
19
16
  subscribe: (listener) => {
20
17
  return getBridge().subscribe(listener);
@@ -36,6 +33,12 @@ export const customBlockHost = {
36
33
  getBridge().postResize(height);
37
34
  },
38
35
  };
36
+ const EMPTY_QUERY_VIEW = {
37
+ items: [],
38
+ propertyIdsByKey: {},
39
+ isLoading: false,
40
+ hasMore: false,
41
+ };
39
42
  export const customBlockDataSources = {
40
43
  createSubscriptionId: () => {
41
44
  return getBridge().createDataSourceSubscriptionId();
@@ -47,29 +50,49 @@ export const customBlockDataSources = {
47
50
  getBridge().releaseDataSourceSubscription(subscriptionId);
48
51
  },
49
52
  getView: (hostState, key, subscriptionId) => {
50
- return getDataSourceQueryViewWithBridge(hostState, key, subscriptionId, ({ page: pageData, dataSource }) => {
51
- const bridge = getBridge();
52
- const update = async (args) => {
53
- const result = await bridge.updatePage(args);
54
- if (result.status === "error") {
55
- return result;
56
- }
57
- Object.assign(page, result.page);
58
- return { status: "success", page };
59
- };
60
- const page = toNotionPageFromNotionPageData({
61
- page: pageData,
62
- dataSourceKey: key,
63
- getPropertyById: propertyId => bridge.getPropertyById({ page, propertyId }),
64
- getPropertyByKey: propertyKey => bridge.getPropertyByKey({ page, dataSource, propertyKey }),
65
- updateById: payload => update({ ...payload, pageId: page.id, dataSource: undefined }),
66
- updateByKey: makeUpdatePageByKey({
67
- dataSource,
68
- update: payload => update({ ...payload, pageId: page.id, dataSource }),
69
- }),
53
+ if (hostState.status !== "initialized") {
54
+ return EMPTY_QUERY_VIEW;
55
+ }
56
+ const dataSource = hostState.dataSources.find(entry => entry.key === key);
57
+ const subscriptionState = hostState.dataSourceState[subscriptionId];
58
+ const queryState = subscriptionState?.dataSourceKey === key
59
+ ? subscriptionState
60
+ : createEmptyDataSourceQueryState(key);
61
+ const items = dataSource === undefined
62
+ ? []
63
+ : queryState.items.map(bridgePage => {
64
+ const bridge = getBridge();
65
+ const update = async (args) => {
66
+ const result = await bridge.updatePage(args);
67
+ if (result.status === "error") {
68
+ return result;
69
+ }
70
+ Object.assign(page, result.page);
71
+ return { status: "success", page };
72
+ };
73
+ const page = toNotionPageFromBridgePage({
74
+ bridgePage,
75
+ dataSourceKey: key,
76
+ getPropertyById: propertyId => bridge.getPropertyById({ page, propertyId }),
77
+ getPropertyByKey: propertyKey => bridge.getPropertyByKey({ page, dataSource, propertyKey }),
78
+ updateById: payload => update({
79
+ ...payload,
80
+ pageId: page.id,
81
+ dataSource: undefined,
82
+ }),
83
+ updateByKey: makeUpdatePageByKey({
84
+ dataSource,
85
+ update: payload => update({ ...payload, pageId: page.id, dataSource }),
86
+ }),
87
+ });
88
+ return page;
70
89
  });
71
- return page;
72
- });
90
+ return {
91
+ items,
92
+ propertyIdsByKey: dataSource?.propertyIdsByKey ?? {},
93
+ isLoading: queryState.isLoading,
94
+ hasMore: queryState.hasMore,
95
+ };
73
96
  },
74
97
  };
75
98
  export const messageLog = {
@@ -1,9 +1,8 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
- * Bridge shape for a data source page, as parsed from inbound host messages. The host keys
4
- * properties by raw property ID. Only actual schema properties are included.
3
+ * Query page shape for protocols 3–5, with flat values keyed by raw property ID.
5
4
  */
6
- export declare const legacyNotionDataSourcePageBridgeSchema: v.ObjectSchema<{
5
+ export declare const notionDataSourcePageForProtocol3To5Schema: v.ObjectSchema<{
7
6
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
8
7
  /** Whether the page or an ancestor is archived. */
9
8
  readonly is_archived: v.BooleanSchema<undefined>;
@@ -71,4 +70,4 @@ export declare const legacyNotionDataSourcePageBridgeSchema: v.ObjectSchema<{
71
70
  readonly table: v.StringSchema<undefined>;
72
71
  }, undefined>, undefined>], undefined>, undefined>, undefined>;
73
72
  }, undefined>;
74
- export type LegacyNotionDataSourcePageBridge = v.InferOutput<typeof legacyNotionDataSourcePageBridgeSchema>;
73
+ export type NotionDataSourcePageForProtocol3To5 = v.InferOutput<typeof notionDataSourcePageForProtocol3To5Schema>;
@@ -2,10 +2,9 @@ import * as v from "valibot";
2
2
  import { notionPageIdSchema } from "../ids.js";
3
3
  import { notionDataSourceValueSchema } from "./dataSourceValue.js";
4
4
  /**
5
- * Bridge shape for a data source page, as parsed from inbound host messages. The host keys
6
- * properties by raw property ID. Only actual schema properties are included.
5
+ * Query page shape for protocols 3–5, with flat values keyed by raw property ID.
7
6
  */
8
- export const legacyNotionDataSourcePageBridgeSchema = v.object({
7
+ export const notionDataSourcePageForProtocol3To5Schema = v.object({
9
8
  id: notionPageIdSchema,
10
9
  /** Whether the page or an ancestor is archived. */
11
10
  is_archived: v.boolean(),
@@ -16,6 +16,7 @@ export * from "./dataSources/recordPointer.js";
16
16
  export * from "./dataSources/sortDirection.js";
17
17
  export * from "./errors.js";
18
18
  export * from "./ids.js";
19
+ export { isLocalBlockServerUrl } from "./isLocalBlockServerUrl.js";
19
20
  export * from "./manifest.js";
20
21
  export * from "./messages/connect.js";
21
22
  export * from "./messages/contrastModeChanged.js";
@@ -16,6 +16,7 @@ export * from "./dataSources/recordPointer.js";
16
16
  export * from "./dataSources/sortDirection.js";
17
17
  export * from "./errors.js";
18
18
  export * from "./ids.js";
19
+ export { isLocalBlockServerUrl } from "./isLocalBlockServerUrl.js";
19
20
  export * from "./manifest.js";
20
21
  export * from "./messages/connect.js";
21
22
  export * from "./messages/contrastModeChanged.js";
@@ -0,0 +1,2 @@
1
+ /** Accepts HTTP(S) block servers on localhost, *.localhost, or 127.0.0.1 without credentials. */
2
+ export declare function isLocalBlockServerUrl(url: URL): boolean;
@@ -0,0 +1,9 @@
1
+ /** Accepts HTTP(S) block servers on localhost, *.localhost, or 127.0.0.1 without credentials. */
2
+ export function isLocalBlockServerUrl(url) {
3
+ return ((url.protocol === "http:" || url.protocol === "https:") &&
4
+ (url.hostname === "localhost" ||
5
+ url.hostname === "127.0.0.1" ||
6
+ url.hostname.endsWith(".localhost")) &&
7
+ url.username === "" &&
8
+ url.password === "");
9
+ }
@@ -10,8 +10,8 @@ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSc
10
10
  readonly sdkVersion: v.StringSchema<undefined>;
11
11
  readonly status: v.LiteralSchema<"success", undefined>;
12
12
  /**
13
- * The data sources and settings the custom block expects. Hosts may omit
14
- * this when they already have an authoritative manifest.
13
+ * The custom block manifest injected by local dev tooling. The SDK omits it on
14
+ * non-loopback origins. Initialization uses it only when manifestSource is "sandbox".
15
15
  */
16
16
  readonly manifest: v.OptionalSchema<v.ObjectSchema<{
17
17
  readonly version: v.LiteralSchema<1, undefined>;
@@ -25,8 +25,8 @@ export const connectMessageSchema = v.variant("status", [
25
25
  v.object({
26
26
  status: v.literal("success"),
27
27
  /**
28
- * The data sources and settings the custom block expects. Hosts may omit
29
- * this when they already have an authoritative manifest.
28
+ * The custom block manifest injected by local dev tooling. The SDK omits it on
29
+ * non-loopback origins. Initialization uses it only when manifestSource is "sandbox".
30
30
  */
31
31
  manifest: v.optional(manifestSchema),
32
32
  ...connectMessageCommonEntries,
@@ -23,7 +23,7 @@ export type NotionCreatePagePosition = v.InferOutput<typeof notionCreatePagePosi
23
23
  * Parent accepted by the outbound `createPage` bridge message.
24
24
  *
25
25
  * Mirrors Notion's public API `POST /v1/pages` parent shape: `page_id` for a page-parented child,
26
- * `data_source_id` for a database row. `data_source_id` is the internal collection ID.
26
+ * `data_source_id` for a database row. `data_source_id` identifies the data source.
27
27
  *
28
28
  * The SDK additionally accepts a higher-level `data_source_key` variant that resolves to
29
29
  * `data_source_id` locally, using the `dataSources` mapping.
@@ -19,7 +19,7 @@ export const notionCreatePagePositionSchema = v.variant("type", [
19
19
  * Parent accepted by the outbound `createPage` bridge message.
20
20
  *
21
21
  * Mirrors Notion's public API `POST /v1/pages` parent shape: `page_id` for a page-parented child,
22
- * `data_source_id` for a database row. `data_source_id` is the internal collection ID.
22
+ * `data_source_id` for a database row. `data_source_id` identifies the data source.
23
23
  *
24
24
  * The SDK additionally accepts a higher-level `data_source_key` variant that resolves to
25
25
  * `data_source_id` locally, using the `dataSources` mapping.
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
2
  import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
3
  export declare const customBlockCreatePageErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockCreatePageErrorCode = CustomBlockErrorCode<"create_page_failed" | "invalid_page_parent" | "page_unavailable" | "collection_access_failed" | "unknown_data_source_key" | "unmapped_data_source" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value">;
4
+ export type CustomBlockCreatePageErrorCode = CustomBlockErrorCode<"create_page_failed" | "invalid_page_parent" | "page_unavailable" | "data_source_access_failed" | "unknown_data_source_key" | "unmapped_data_source" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value">;
5
5
  export type CustomBlockCreatePageErrorInfo = CustomBlockErrorInfo<CustomBlockCreatePageErrorCode>;
6
6
  export declare const customBlockCreatePageErrorInfoSchema: v.ObjectSchema<{
7
7
  readonly code: v.StringSchema<undefined>;
@@ -314,7 +314,7 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
314
314
  readonly isRetryable: v.BooleanSchema<undefined>;
315
315
  }, undefined>;
316
316
  }, undefined>], undefined>;
317
- export declare const createPageResultMessageLegacySchema: v.VariantSchema<"status", [v.ObjectSchema<{
317
+ export declare const createPageResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
318
318
  readonly type: v.LiteralSchema<"createPageResult", undefined>;
319
319
  readonly requestId: v.StringSchema<undefined>;
320
320
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -894,4 +894,4 @@ export declare const createPageResultMessageLegacySchema: v.VariantSchema<"statu
894
894
  }, undefined>;
895
895
  }, undefined>], undefined>;
896
896
  export type CreatePageResultMessage = v.InferOutput<typeof createPageResultMessageSchema>;
897
- export type CreatePageResultMessageLegacy = v.InferOutput<typeof createPageResultMessageLegacySchema>;
897
+ export type CreatePageResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof createPageResultMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { legacyNotionPageSchema, notionPageDataSchema } from "../pages/page.js";
2
+ import { bridgePageSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
3
3
  // The schema accepts any string code. The type lists known codes for
4
4
  // autocomplete, with an open string fallback for newer senders.
5
5
  export const customBlockCreatePageErrorCodeSchema = v.string();
@@ -17,7 +17,7 @@ export const createPageResultMessageSchema = v.variant("status", [
17
17
  requestId: v.string(),
18
18
  status: v.literal("success"),
19
19
  /** The newly created page. */
20
- page: notionPageDataSchema,
20
+ page: bridgePageSchema,
21
21
  }),
22
22
  v.object({
23
23
  type: v.literal("createPageResult"),
@@ -26,13 +26,13 @@ export const createPageResultMessageSchema = v.variant("status", [
26
26
  error: customBlockCreatePageErrorInfoSchema,
27
27
  }),
28
28
  ]);
29
- export const createPageResultMessageLegacySchema = v.variant("status", [
29
+ export const createPageResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
30
30
  v.object({
31
31
  type: v.literal("createPageResult"),
32
32
  requestId: v.string(),
33
33
  status: v.literal("success"),
34
34
  /** The newly created page. */
35
- page: v.union([notionPageDataSchema, legacyNotionPageSchema]),
35
+ page: v.union([bridgePageSchema, notionPageForProtocol3To5Schema]),
36
36
  }),
37
37
  v.object({
38
38
  type: v.literal("createPageResult"),
@@ -320,7 +320,7 @@ export declare const getPageResultMessageSchema: v.VariantSchema<"status", [v.Ob
320
320
  readonly isRetryable: v.BooleanSchema<undefined>;
321
321
  }, undefined>;
322
322
  }, undefined>], undefined>;
323
- export declare const getPageResultMessageLegacySchema: v.VariantSchema<"status", [v.ObjectSchema<{
323
+ export declare const getPageResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
324
324
  readonly type: v.LiteralSchema<"getPageResult", undefined>;
325
325
  readonly requestId: v.StringSchema<undefined>;
326
326
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -899,4 +899,4 @@ export declare const getPageResultMessageLegacySchema: v.VariantSchema<"status",
899
899
  }, undefined>;
900
900
  }, undefined>], undefined>;
901
901
  export type GetPageResultMessage = v.InferOutput<typeof getPageResultMessageSchema>;
902
- export type GetPageResultMessageLegacy = v.InferOutput<typeof getPageResultMessageLegacySchema>;
902
+ export type GetPageResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof getPageResultMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
2
  import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
3
- import { legacyNotionPageSchema, notionPageDataSchema } from "../pages/page.js";
3
+ import { bridgePageSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
4
4
  // The schema accepts any string code. The type lists known codes for
5
5
  // autocomplete, with an open string fallback for newer senders.
6
6
  export const customBlockGetPageErrorCodeSchema = v.string();
@@ -23,7 +23,7 @@ export const getPageResultMessageSchema = v.variant("status", [
23
23
  type: v.literal("getPageResult"),
24
24
  requestId: v.string(),
25
25
  status: v.literal("success"),
26
- page: notionPageDataSchema,
26
+ page: bridgePageSchema,
27
27
  }),
28
28
  v.object({
29
29
  type: v.literal("getPageResult"),
@@ -32,12 +32,12 @@ export const getPageResultMessageSchema = v.variant("status", [
32
32
  error: customBlockGetPageErrorInfoSchema,
33
33
  }),
34
34
  ]);
35
- export const getPageResultMessageLegacySchema = v.variant("status", [
35
+ export const getPageResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
36
36
  v.object({
37
37
  type: v.literal("getPageResult"),
38
38
  requestId: v.string(),
39
39
  status: v.literal("success"),
40
- page: v.union([notionPageDataSchema, legacyNotionPageSchema]),
40
+ page: v.union([bridgePageSchema, notionPageForProtocol3To5Schema]),
41
41
  }),
42
42
  v.object({
43
43
  type: v.literal("getPageResult"),
@@ -1743,9 +1743,9 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
1743
1743
  }, undefined>;
1744
1744
  }, undefined>], undefined>], undefined>;
1745
1745
  /**
1746
- * Discriminated union of every message the host is allowed to send the sandbox.
1746
+ * Host messages accepting both current page shapes and protocol 3–5 page shapes.
1747
1747
  */
1748
- export declare const hostToSandboxMessageLegacySchema: v.VariantSchema<"type", [v.VariantSchema<"status", [v.ObjectSchema<{
1748
+ export declare const hostToSandboxMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"type", [v.VariantSchema<"status", [v.ObjectSchema<{
1749
1749
  readonly type: v.LiteralSchema<"init", undefined>;
1750
1750
  readonly initializationId: v.StringSchema<undefined>;
1751
1751
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -4382,4 +4382,4 @@ export declare const hostToSandboxMessageLegacySchema: v.VariantSchema<"type", [
4382
4382
  }, undefined>;
4383
4383
  }, undefined>], undefined>], undefined>;
4384
4384
  export type HostToSandboxMessage = v.InferOutput<typeof hostToSandboxMessageSchema>;
4385
- export type HostToSandboxMessageLegacy = v.InferOutput<typeof hostToSandboxMessageLegacySchema>;
4385
+ export type HostToSandboxMessageWithProtocol3To5Compatibility = v.InferOutput<typeof hostToSandboxMessageWithProtocol3To5CompatibilitySchema>;