@notionhq/custom-blocks 0.0.62 → 0.0.63

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 CHANGED
@@ -66,7 +66,7 @@ The host replies with exactly one `init`, which has two statuses. On success it
66
66
 
67
67
  ```ts
68
68
  // host → sandbox
69
- { type: "init", status: "success", theme, blockId, parent, page: { id }, currentUser, dataSources: { bindings } }
69
+ { type: "init", status: "success", theme, blockId, parent, page: { id, parent }, currentUser, dataSources: { bindings } }
70
70
  ```
71
71
 
72
72
  On failure it carries `error: { code, message, isRetryable }` (`CustomBlockInitErrorInfo` / `customBlockInitErrorInfoSchema`, with `code` drawn from `CustomBlockInitErrorCode` / `customBlockInitErrorCodeSchema`). The SDK surfaces this as a `CustomBlockInitError`:
@@ -82,7 +82,7 @@ After `init`, narrower messages update live state without re-running the handsha
82
82
  // host → sandbox, any time after init
83
83
  { type: "themeChanged", theme }
84
84
  { type: "parentChanged", parent }
85
- { type: "pageChanged", page: { id } }
85
+ { type: "pageChanged", page: { id, parent } }
86
86
  { type: "dataSourcesChanged", dataSources: { bindings } }
87
87
  ```
88
88
 
@@ -112,7 +112,7 @@ Host implementers can use the API-specific aliases and schemas when shaping outb
112
112
 
113
113
  Types:
114
114
 
115
- - `CustomBlockPage` — the current page slice carried in `init.page` and `pageChanged`.
115
+ - `CustomBlockPage` — the current page slice carried in `init.page` and `pageChanged`: the containing page's `id` plus its own `parent` (a `NotionParent`), so the sandbox can tell a freestanding page from a database row. Hosts must re-send `pageChanged` when either field changes, including when the containing page moves without its ID changing.
116
116
  - `NotionDataSourceBinding` — a single binding (collection pointer + schema + property mapping).
117
117
  - `NotionDataSourceBindings` — keyed-by-semantic-key map of bindings, the shape carried in `init.dataSources` and `dataSourcesChanged`.
118
118
  - `NotionDataSourcePageBridge` — wire shape for a single page (raw property IDs in `propertiesById`). The SDK derives the consumer-facing `NotionDataSourcePage` from it.
@@ -134,7 +134,7 @@ Messages sent from the sandbox to the host. Parse `window` `message` events with
134
134
 
135
135
  | Wire type | Type / schema | Behavior |
136
136
  | -------------------- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
137
- | `ready` | `ReadyMessage` / `readyMessageSchema` | One-shot handshake; carries `bridgeProtocolVersion`, `sdkVersion`, and the manifest. |
137
+ | `ready` | `ReadyMessage` / `readyMessageSchema` | One-shot handshake; carries `bridgeProtocolVersion`, `sdkVersion`, and the manifest. |
138
138
  | `queryDataSource` | `QueryDataSourceMessage` / `queryDataSourceMessageSchema` | `requestId`-keyed request for the current rows in a raw `dataSourceId`. `snapshotId` names the SDK result slot to update, so later refreshes for the same `useDataSource` call replace the same snapshot instead of creating a new one. |
139
139
  | `createPage` | `CreatePageMessage` / `createPageMessageSchema` | `requestId`-keyed page creation; parent is `page_id` or `data_source_id`. |
140
140
  | `getPage` | `GetPageMessage` / `getPageMessageSchema` | `requestId`-keyed page fetch by page id. |
@@ -25,6 +25,22 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
25
25
  }, undefined>], undefined>;
26
26
  readonly page: v.ObjectSchema<{
27
27
  readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
28
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
29
+ readonly type: v.LiteralSchema<"page_id", undefined>;
30
+ readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
31
+ }, undefined>, v.ObjectSchema<{
32
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
33
+ readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
34
+ }, undefined>, v.ObjectSchema<{
35
+ readonly type: v.LiteralSchema<"workspace", undefined>;
36
+ readonly workspace: v.LiteralSchema<true, undefined>;
37
+ }, undefined>, v.ObjectSchema<{
38
+ readonly type: v.LiteralSchema<"block_id", undefined>;
39
+ readonly block_id: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
40
+ }, undefined>, v.ObjectSchema<{
41
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
42
+ readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
43
+ }, undefined>], undefined>;
28
44
  }, undefined>;
29
45
  readonly dataSources: v.ObjectSchema<{
30
46
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
@@ -216,6 +232,22 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
216
232
  readonly type: v.LiteralSchema<"pageChanged", undefined>;
217
233
  readonly page: v.ObjectSchema<{
218
234
  readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
235
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
236
+ readonly type: v.LiteralSchema<"page_id", undefined>;
237
+ readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
238
+ }, undefined>, v.ObjectSchema<{
239
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
240
+ readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
241
+ }, undefined>, v.ObjectSchema<{
242
+ readonly type: v.LiteralSchema<"workspace", undefined>;
243
+ readonly workspace: v.LiteralSchema<true, undefined>;
244
+ }, undefined>, v.ObjectSchema<{
245
+ readonly type: v.LiteralSchema<"block_id", undefined>;
246
+ readonly block_id: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
247
+ }, undefined>, v.ObjectSchema<{
248
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
249
+ readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
250
+ }, undefined>], undefined>;
219
251
  }, undefined>;
220
252
  }, undefined>, v.ObjectSchema<{
221
253
  readonly type: v.LiteralSchema<"currentUserChanged", undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"hostToSandbox.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/hostToSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAkB5B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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page: v.ObjectSchema<{
43
43
  readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
44
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
45
+ readonly type: v.LiteralSchema<"page_id", undefined>;
46
+ readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
47
+ }, undefined>, v.ObjectSchema<{
48
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
49
+ readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
50
+ }, undefined>, v.ObjectSchema<{
51
+ readonly type: v.LiteralSchema<"workspace", undefined>;
52
+ readonly workspace: v.LiteralSchema<true, undefined>;
53
+ }, undefined>, v.ObjectSchema<{
54
+ readonly type: v.LiteralSchema<"block_id", undefined>;
55
+ readonly block_id: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
56
+ }, undefined>, v.ObjectSchema<{
57
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
58
+ readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
59
+ }, undefined>], undefined>;
44
60
  }, undefined>;
45
61
  readonly dataSources: v.ObjectSchema<{
46
62
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AASxD,eAAO,MAAM,8BAA8B,2BAAa,CAAA;AAExD,MAAM,MAAM,wBAAwB,GACjC,UAAU,GACV,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,0BAA0B,GAC1B,8BAA8B,GAC9B,qBAAqB,GACrB,0BAA0B,GAC1B,6BAA6B,GAC7B,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,eAAe,GACf,cAAc,GACd,eAAe,GACf,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,wBAAwB,GACnC,oBAAoB,CAAC,wBAAwB,CAAC,CAAA;AAE/C,eAAO,MAAM,8BAA8B;;;;aAIzC,CAAA;AAEF,qBAAa,oBACZ,SAAQ,KACR,YAAW,oBAAoB;gBAEnB,KAAK,EAAE,wBAAwB;IAO3C,IAAI,EAAE,wBAAwB,CAAA;IAC9B,WAAW,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAkB5B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AASxD,eAAO,MAAM,8BAA8B,2BAAa,CAAA;AAExD,MAAM,MAAM,wBAAwB,GACjC,UAAU,GACV,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,0BAA0B,GAC1B,8BAA8B,GAC9B,qBAAqB,GACrB,0BAA0B,GAC1B,6BAA6B,GAC7B,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,eAAe,GACf,cAAc,GACd,eAAe,GACf,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,wBAAwB,GACnC,oBAAoB,CAAC,wBAAwB,CAAC,CAAA;AAE/C,eAAO,MAAM,8BAA8B;;;;aAIzC,CAAA;AAEF,qBAAa,oBACZ,SAAQ,KACR,YAAW,oBAAoB;gBAEnB,KAAK,EAAE,wBAAwB;IAO3C,IAAI,EAAE,wBAAwB,CAAA;IAC9B,WAAW,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAkB5B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -6,6 +6,22 @@ export declare const pageChangedMessageSchema: v.ObjectSchema<{
6
6
  readonly type: v.LiteralSchema<"pageChanged", undefined>;
7
7
  readonly page: v.ObjectSchema<{
8
8
  readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
9
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
10
+ readonly type: v.LiteralSchema<"page_id", undefined>;
11
+ readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
12
+ }, undefined>, v.ObjectSchema<{
13
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
14
+ readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
15
+ }, undefined>, v.ObjectSchema<{
16
+ readonly type: v.LiteralSchema<"workspace", undefined>;
17
+ readonly workspace: v.LiteralSchema<true, undefined>;
18
+ }, undefined>, v.ObjectSchema<{
19
+ readonly type: v.LiteralSchema<"block_id", undefined>;
20
+ readonly block_id: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
21
+ }, undefined>, v.ObjectSchema<{
22
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
23
+ readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
24
+ }, undefined>], undefined>;
9
25
  }, undefined>;
10
26
  }, undefined>;
11
27
  export type PageChangedMessage = v.InferOutput<typeof pageChangedMessageSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"pageChanged.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/pageChanged.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;aAGnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
1
+ {"version":3,"file":"pageChanged.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/pageChanged.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;aAGnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
@@ -6,8 +6,32 @@
6
6
  */
7
7
  import * as v from "valibot";
8
8
  export type { NotionPageId } from "../ids.js";
9
+ /**
10
+ * The custom block's nearest enclosing page ancestor, carried in `init.page` and `pageChanged`.
11
+ */
9
12
  export declare const customBlockPageSchema: v.ObjectSchema<{
10
13
  readonly id: v.CustomSchema<import("./page.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
14
+ /**
15
+ * The containing page's own parent. It lets a block distinguish a freestanding page from a
16
+ * database row without a round trip. Not to be confused with the top-level `parent` runtime
17
+ * value, which is the custom block's own parent.
18
+ */
19
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
20
+ readonly type: v.LiteralSchema<"page_id", undefined>;
21
+ readonly page_id: v.CustomSchema<import("./page.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
22
+ }, undefined>, v.ObjectSchema<{
23
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
24
+ readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
25
+ }, undefined>, v.ObjectSchema<{
26
+ readonly type: v.LiteralSchema<"workspace", undefined>;
27
+ readonly workspace: v.LiteralSchema<true, undefined>;
28
+ }, undefined>, v.ObjectSchema<{
29
+ readonly type: v.LiteralSchema<"block_id", undefined>;
30
+ readonly block_id: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
31
+ }, undefined>, v.ObjectSchema<{
32
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
33
+ readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
34
+ }, undefined>], undefined>;
11
35
  }, undefined>;
12
36
  export type CustomBlockPage = v.InferOutput<typeof customBlockPageSchema>;
13
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/pages/page.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAI5B,YAAY,EAAE,YAAY,EAAE,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;;;;sCAG5C,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,WAAW,CACrD,OAAO,gCAAgC,CACvC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAY3B,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/pages/page.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAI5B,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,qBAAqB;;IAEjC;;;;OAIG;;;;;;;;;;;;;;;;;aAEF,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;;;;;0BAMtC,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAChD,OAAO,2BAA2B,CAClC,CAAA;AAED,eAAO,MAAM,qBAAqB;;;aAGhC,CAAA;AACF,eAAO,MAAM,2BAA2B;;;;;;;aAOtC,CAAA;AACF,eAAO,MAAM,wBAAwB;;;;;aAGnC,CAAA;AACF,eAAO,MAAM,sBAAsB;;;;;;aAMjC,CAAA;AAGF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;0BAK/B,CAAA;AACF,MA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js";
9
9
  import { notionParentSchema } from "../parent.js";
10
+ /**
11
+ * The custom block's nearest enclosing page ancestor, carried in `init.page` and `pageChanged`.
12
+ */
10
13
  export const customBlockPageSchema = v.object({
11
14
  id: notionPageIdSchema,
15
+ /**
16
+ * The containing page's own parent. It lets a block distinguish a freestanding page from a
17
+ * database row without a round trip. Not to be confused with the top-level `parent` runtime
18
+ * value, which is the custom block's own parent.
19
+ */
20
+ parent: notionParentSchema,
12
21
  });
13
22
  /**
14
23
  * Parent reference accepted by `pages.create` / `pages.update` inputs.
package/dist/index.d.ts CHANGED
@@ -32,6 +32,6 @@ export type { NotionParent } from "./bridge/parent.js";
32
32
  export { pages, users } from "./bridge/sandboxClient.js";
33
33
  export type { NotionTheme } from "./bridge/theme.js";
34
34
  export { type CustomBlockState, customBlock } from "./customBlock.js";
35
- export { type CustomBlockInitial, type InitCustomBlockOptions, initCustomBlock, NotInIframeError, } from "./init.js";
35
+ export { type CustomBlockInitPayload, type InitCustomBlockOptions, initCustomBlock, NotInIframeError, } from "./init.js";
36
36
  export * from "./types.js";
37
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACX,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,oCAAoC,CAAA;AAC3C,YAAY,EACX,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,GAChC,MAAM,wCAAwC,CAAA;AAC/C,YAAY,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AACpF,YAAY,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,mCAAmC,CAAA;AAC1C,YAAY,EACX,wCAAwC,EACxC,wCAAwC,GACxC,MAAM,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AC1B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC1B,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,eAAe,EACf,gBAAgB,GAChB,MAAM,WAAW,CAAA;AAClB,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACX,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,oCAAoC,CAAA;AAC3C,YAAY,EACX,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,GAChC,MAAM,wCAAwC,CAAA;AAC/C,YAAY,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AACpF,YAAY,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,mCAAmC,CAAA;AAC1C,YAAY,EACX,wCAAwC,EACxC,wCAAwC,GACxC,MAAM,gCAAgC,CAAA;AACvC,YAAY,EACX,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,wCAAwC,CAAA;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,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EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,eAAe,EACf,gBAAgB,GAChB,MAAM,WAAW,CAAA;AAClB,cAAc,YAAY,CAAA"}
package/dist/init.d.ts CHANGED
@@ -8,7 +8,7 @@ import type { NotionUser } from "./bridge/users/user.js";
8
8
  /**
9
9
  * The payload sent by the host in the `init` message in response to the sandbox's `ready` message.
10
10
  */
11
- export type CustomBlockInitial = {
11
+ export type CustomBlockInitPayload = {
12
12
  theme: NotionTheme;
13
13
  blockId: NotionBlockId;
14
14
  parent: NotionParent;
@@ -49,5 +49,5 @@ export type InitCustomBlockOptions = {
49
49
  * Mount your React tree (or call any SDK hook / `customBlock.subscribe`) only after the
50
50
  * returned promise resolves.
51
51
  */
52
- export declare function initCustomBlock(opts?: InitCustomBlockOptions): Promise<CustomBlockInitial>;
52
+ export declare function initCustomBlock(opts?: InitCustomBlockOptions): Promise<CustomBlockInitPayload>;
53
53
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAEN,KAAK,wBAAwB,EAE7B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,KAAK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WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAC/B,CAAA;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC9B,OAAO,GAAE,MAA8B;IAOnD,IAAI,EAAE,wBAAwB,CAAA;IAC9B,WAAW,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AASD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE,sBAA2B,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAyDjC"}
@@ -10,7 +10,7 @@ export function seedStandalonePreviewState() {
10
10
  theme: "light",
11
11
  blockId: previewBlockId,
12
12
  parent: { type: "page_id", page_id: previewPageId },
13
- page: { id: previewPageId },
13
+ page: { id: previewPageId, parent: { type: "workspace", workspace: true } },
14
14
  dataSources: { bindings: {} },
15
15
  currentUser: {
16
16
  object: "user",
@@ -1,5 +1,5 @@
1
1
  import { CustomBlockInitError } from "../bridge/messages/init.js";
2
- import { type CustomBlockInitial, type InitCustomBlockOptions, NotInIframeError } from "../init.js";
2
+ import { type CustomBlockInitPayload, type InitCustomBlockOptions, NotInIframeError } from "../init.js";
3
3
  export type CustomBlockInitFailure = CustomBlockInitError | NotInIframeError;
4
4
  /**
5
5
  * Discriminated state returned by {@link useCustomBlockInit}.
@@ -20,7 +20,7 @@ export type UseCustomBlockInitResult = {
20
20
  } | {
21
21
  isLoaded: true;
22
22
  error: undefined;
23
- initial: CustomBlockInitial;
23
+ initial: CustomBlockInitPayload;
24
24
  };
25
25
  /**
26
26
  * React wrapper around {@link initCustomBlock}. Kicks off the SDK ↔ host
@@ -1 +1 @@
1
- {"version":3,"file":"useCustomBlockInit.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/react/useCustomBlockInit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE3B,gBAAgB,EAChB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,GAAG,gBAAgB,CAAA;AAE5E;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GACjC;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACrC;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,sBAAsB,CAAA;CAAE,GAClD;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAA;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,CAAC,EAAE,sBAAsB,GAC3B,wBAAwB,CA8B1B"}
1
+ {"version":3,"file":"useCustomBlockInit.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/react/useCustomBlockInit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAE3B,gBAAgB,EAChB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,GAAG,gBAAgB,CAAA;AAE5E;;;;;;;;;GASG;AACH,MAAM,MAAM,wBAAwB,GACjC;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GACrC;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,sBAAsB,CAAA;CAAE,GAClD;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,CAAC,EAAE,sBAAsB,GAC3B,wBAAwB,CA8B1B"}
package/dist/version.js CHANGED
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const NCBLOCK_SDK_VERSION = "0.0.62"
7
+ export const NCBLOCK_SDK_VERSION = "0.0.63"
@@ -63,12 +63,26 @@ export function AgentInstructionBadge() {
63
63
 
64
64
  Returns the nearest enclosing `page` / `collection_view_page` ancestor.
65
65
 
66
- Re-renders when the host sends a block location update.
66
+ Re-renders when the host sends a block location update — including when the containing page itself moves (its `parent` changes) without the page ID changing.
67
67
 
68
68
  ```ts
69
- function usePage(): { id: NotionPageId };
69
+ function usePage(): CustomBlockPage;
70
+
71
+ type CustomBlockPage = {
72
+ id: NotionPageId;
73
+ parent: NotionParent; // the containing page's own parent
74
+ };
70
75
  ```
71
76
 
77
+ `page.parent` allows determining if the custom block is in a freestanding page or part of a database. Don't confuse it with `useParent()`, which is the custom block's own parent.
78
+
79
+ ```tsx
80
+ const page = usePage();
81
+ const isInsideDatabaseRow = page.parent.type === "data_source_id";
82
+ ```
83
+
84
+ For anything beyond location — title, icon, properties — fetch the page through the pages API: `pages.get(page.id)`.
85
+
72
86
  For non-React renderers, use `customBlock.getPage()` after `initCustomBlock()` resolves.
73
87
 
74
88
  ### `useTheme()`
package/docs/lifecycle.md CHANGED
@@ -4,7 +4,7 @@ The SDK ↔ host handshake, the React wrapper that runs it, and the auto-resize
4
4
 
5
5
  ## Handshake
6
6
 
7
- `initCustomBlock()` posts `ready` to `window.parent` and awaits the host's `init` (theme, block ID/parent/page ID, current user, and `dataSources: { bindings }` keyed by semantic data-source key, which the SDK resolves against the manifest). The promise resolves with the normalized initial state, captured in `CustomBlockInitial` — `await` it before mounting React so hooks always see populated state.
7
+ `initCustomBlock()` posts `ready` to `window.parent` and awaits the host's `init` (theme, block ID/parent/page ID, current user, and `dataSources: { bindings }` keyed by semantic data-source key, which the SDK resolves against the manifest). The promise resolves with the normalized initial state, captured in `CustomBlockInitPayload` — `await` it before mounting React so hooks always see populated state.
8
8
 
9
9
  - Default `timeoutMs` is 15000; rejects with `CustomBlockInitError` code `init_timeout` if the host doesn't respond.
10
10
  - In a top-level browser tab (no parent frame), rejects with `NotInIframeError` code `not_in_iframe`. `<NotionCustomBlock>` catches this, seeds placeholders, and renders `children` behind a warning banner so dev-time previews still work.
@@ -45,7 +45,7 @@ function useCustomBlockInit(
45
45
  type UseCustomBlockInitResult =
46
46
  | { isLoaded: false; error: undefined }
47
47
  | { isLoaded: false; error: CustomBlockInitFailure }
48
- | { isLoaded: true; error: undefined; initial: CustomBlockInitial };
48
+ | { isLoaded: true; error: undefined; initial: CustomBlockInitPayload };
49
49
  ```
50
50
 
51
51
  React wrapper around `initCustomBlock` for templates that prefer not to use top-level `await`. Multiple components calling it share the same handshake.
@@ -64,7 +64,7 @@ function Root() {
64
64
  ```ts
65
65
  function initCustomBlock(
66
66
  opts?: InitCustomBlockOptions,
67
- ): Promise<CustomBlockInitial>;
67
+ ): Promise<CustomBlockInitPayload>;
68
68
 
69
69
  type InitCustomBlockOptions = { timeoutMs?: number };
70
70
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.0.62",
3
+ "version": "0.0.63",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -11,8 +11,17 @@ import { notionParentSchema } from "../parent.js"
11
11
 
12
12
  export type { NotionPageId } from "../ids.js"
13
13
 
14
+ /**
15
+ * The custom block's nearest enclosing page ancestor, carried in `init.page` and `pageChanged`.
16
+ */
14
17
  export const customBlockPageSchema = v.object({
15
18
  id: notionPageIdSchema,
19
+ /**
20
+ * The containing page's own parent. It lets a block distinguish a freestanding page from a
21
+ * database row without a round trip. Not to be confused with the top-level `parent` runtime
22
+ * value, which is the custom block's own parent.
23
+ */
24
+ parent: notionParentSchema,
16
25
  })
17
26
 
18
27
  export type CustomBlockPage = v.InferOutput<typeof customBlockPageSchema>
package/src/index.ts CHANGED
@@ -108,7 +108,7 @@ export { pages, users } from "./bridge/sandboxClient.js"
108
108
  export type { NotionTheme } from "./bridge/theme.js"
109
109
  export { type CustomBlockState, customBlock } from "./customBlock.js"
110
110
  export {
111
- type CustomBlockInitial,
111
+ type CustomBlockInitPayload,
112
112
  type InitCustomBlockOptions,
113
113
  initCustomBlock,
114
114
  NotInIframeError,
package/src/init.ts CHANGED
@@ -15,7 +15,7 @@ import type { NotionUser } from "./bridge/users/user.js"
15
15
  /**
16
16
  * The payload sent by the host in the `init` message in response to the sandbox's `ready` message.
17
17
  */
18
- export type CustomBlockInitial = {
18
+ export type CustomBlockInitPayload = {
19
19
  theme: NotionTheme
20
20
  blockId: NotionBlockId
21
21
  parent: NotionParent
@@ -60,7 +60,7 @@ const DEFAULT_INIT_TIMEOUT_MS = 15_000
60
60
  const NOT_IN_IFRAME_MESSAGE =
61
61
  "<NotionCustomBlock> only works inside an iframe — use the dev shell or deploy to Notion."
62
62
 
63
- let initPromise: Promise<CustomBlockInitial> | undefined
63
+ let initPromise: Promise<CustomBlockInitPayload> | undefined
64
64
 
65
65
  /**
66
66
  * Performs the SDK <-> host handshake: loads `custom_blocks.json`, posts
@@ -74,7 +74,7 @@ let initPromise: Promise<CustomBlockInitial> | undefined
74
74
  */
75
75
  export function initCustomBlock(
76
76
  opts: InitCustomBlockOptions = {},
77
- ): Promise<CustomBlockInitial> {
77
+ ): Promise<CustomBlockInitPayload> {
78
78
  if (initPromise === undefined) {
79
79
  initPromise = (async () => {
80
80
  // Fail fast with a typed error when rendered as a standalone tab and not in a parent frame.
@@ -12,7 +12,7 @@ export function seedStandalonePreviewState() {
12
12
  theme: "light",
13
13
  blockId: previewBlockId,
14
14
  parent: { type: "page_id", page_id: previewPageId },
15
- page: { id: previewPageId },
15
+ page: { id: previewPageId, parent: { type: "workspace", workspace: true } },
16
16
  dataSources: { bindings: {} },
17
17
  currentUser: {
18
18
  object: "user",
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState } from "react"
2
2
  import { CustomBlockInitError } from "../bridge/messages/init.js"
3
3
  import {
4
- type CustomBlockInitial,
4
+ type CustomBlockInitPayload,
5
5
  type InitCustomBlockOptions,
6
6
  initCustomBlock,
7
7
  NotInIframeError,
@@ -22,7 +22,7 @@ export type CustomBlockInitFailure = CustomBlockInitError | NotInIframeError
22
22
  export type UseCustomBlockInitResult =
23
23
  | { isLoaded: false; error: undefined }
24
24
  | { isLoaded: false; error: CustomBlockInitFailure }
25
- | { isLoaded: true; error: undefined; initial: CustomBlockInitial }
25
+ | { isLoaded: true; error: undefined; initial: CustomBlockInitPayload }
26
26
 
27
27
  /**
28
28
  * React wrapper around {@link initCustomBlock}. Kicks off the SDK ↔ host