@notionhq/custom-blocks 0.2.14 → 0.2.16

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 (35) hide show
  1. package/dist/bridge/SandboxBridge.d.ts +7 -8
  2. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  3. package/dist/bridge/SandboxBridge.js +49 -44
  4. package/dist/bridge/dataSources/query.d.ts +2 -1
  5. package/dist/bridge/dataSources/query.d.ts.map +1 -1
  6. package/dist/bridge/dataSources/query.js +39 -8
  7. package/dist/bridge/dataSources/resolve.d.ts +10 -10
  8. package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
  9. package/dist/bridge/dataSources/resolve.js +17 -5
  10. package/dist/protocol/dataSources/dataSource.d.ts +61 -6
  11. package/dist/protocol/dataSources/dataSource.js +35 -6
  12. package/dist/protocol/dataSources/propertySchema.d.ts +2 -0
  13. package/dist/protocol/dataSources/propertySchema.js +7 -0
  14. package/dist/protocol/messages/queryDataSource.d.ts +485 -485
  15. package/dist/protocol/messages/queryDataSource.js +43 -43
  16. package/dist/protocol/messages/queryDataSourceResult.d.ts +1 -1
  17. package/dist/protocol/messages/sandboxToHost.d.ts +178 -178
  18. package/dist/protocol/protocolVersion.d.ts +1 -1
  19. package/dist/protocol/protocolVersion.js +1 -1
  20. package/dist/typeUtils.d.ts +10 -0
  21. package/dist/typeUtils.d.ts.map +1 -0
  22. package/dist/types.d.ts +18 -15
  23. package/dist/types.d.ts.map +1 -1
  24. package/dist/version.js +1 -1
  25. package/docs/block-location.md +4 -4
  26. package/docs/data-sources.md +60 -35
  27. package/docs/errors.md +17 -1
  28. package/package.json +1 -1
  29. package/src/bridge/SandboxBridge.ts +62 -50
  30. package/src/bridge/dataSources/query.ts +47 -9
  31. package/src/bridge/dataSources/resolve.ts +30 -13
  32. package/src/typeUtils.ts +10 -0
  33. package/src/types.ts +22 -16
  34. package/bin/notion-custom-blocks/upload.test.js +0 -35
  35. /package/{bin/notion-custom-blocks/upload.test.d.ts → dist/typeUtils.js} +0 -0
@@ -5,8 +5,8 @@ import type { CreatePageArgs, CreatePageResult, DataSourceQueryOptions, GetPageR
5
5
  import { type CustomBlockHostState } from "./hostState.js";
6
6
  import type { ManifestLoadResult } from "./loadManifest.js";
7
7
  /**
8
- * A single entry in the bridge message log. Kept intentionally plain so the log
9
- * is copy-pasteable to a local coding agent without needing extra context.
8
+ * A single entry in the bridge message log. Kept intentionally plain so the log is copy-pasteable
9
+ * to a local coding agent without needing extra context.
10
10
  */
11
11
  export type MessageLogEntry = {
12
12
  timestamp: string;
@@ -60,10 +60,9 @@ export declare class SandboxBridge {
60
60
  subscribe(listener: () => void): () => boolean;
61
61
  getHostState(): CustomBlockHostState;
62
62
  /**
63
- * Apply an `init` payload as if it had arrived from the host. Lets callers
64
- * seed the bridge directly (e.g. the React provider's standalone preview
65
- * fallback) without going through `postMessage`. The bridge stays unaware
66
- * of why it's being seeded.
63
+ * Apply an `init` payload as if it had arrived from the host. Lets callers seed the bridge
64
+ * directly (e.g. the React provider's standalone preview fallback) without going through
65
+ * `postMessage`. The bridge stays unaware of why it's being seeded.
67
66
  */
68
67
  setMockState(message: InitMessage): void;
69
68
  completeInitialization(): void;
@@ -97,8 +96,8 @@ export declare class SandboxBridge {
97
96
  }): Promise<UpdatePageResult>;
98
97
  /**
99
98
  * Translates the public `CreatePageArgs["parent"]` into the bridge-native
100
- * `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against
101
- * the data source mapping the host delivered in `init` / `dataSourcesChanged`.
99
+ * `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against the
100
+ * data source mapping the host delivered in `init` / `dataSourcesChanged`.
102
101
  */
103
102
  private resolveCreatePageParent;
104
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxBridge.d.ts","sourceRoot":"","sources":["../../src/bridge/SandboxBridge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,gBAAgB,EAEhB,MAAM,4DA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P,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,cAAc,CAAC,CAWzB;IAED,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAUpD;IAED,SAAS,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAW5D;IAED,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyC1D;IAED;;;;OAIG;IACH,oBAAoB,CAAC,IAAI,EAAE;QAC1B,UAAU,EAAE,gBAAgB,CAAA;QAC5B,MAAM,EAAE,YAAY,CAAA;QACpB,cAAc,EAAE,8BAA8B,CAAA;KAC9C,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqB5B;IAED;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;CAkE/B"}
@@ -8,7 +8,7 @@ import { unreachable } from "../utils.js";
8
8
  import { CUSTOM_BLOCKS_SDK_VERSION } from "../version.js";
9
9
  import { NOTION_DARK_BACKGROUND_BASE, NOTION_LIGHT_BACKGROUND_BASE, } from "./appearance.js";
10
10
  import { resolveDataSourceQuery } from "./dataSources/query.js";
11
- import { resolveDataSources } from "./dataSources/resolve.js";
11
+ import { getDataSourceReadSchemas, resolveDataSources, } from "./dataSources/resolve.js";
12
12
  import { resolvePropertyWriteMapForDataSource } from "./dataSources/resolveProperty.js";
13
13
  import { createEmptyDataSourceQueryState, } from "./hostState.js";
14
14
  import { notifyListener } from "./notifyListener.js";
@@ -190,10 +190,9 @@ export class SandboxBridge {
190
190
  this.sendInitResultError(invalidInitPayloadError(parsed.issues));
191
191
  return;
192
192
  }
193
- // Loop guard: never NACK a NACK. Excludes both directions —
194
- // `invalidSandboxMessage` is what the host normally sends, but
195
- // a buggy host that echoes our own `invalidHostMessage` back
196
- // would otherwise spin a NACK feedback loop.
193
+ // Loop guard: never NACK a NACK. Excludes both directions — `invalidSandboxMessage` is
194
+ // what the host normally sends, but a buggy host that echoes our own
195
+ // `invalidHostMessage` back would otherwise spin a NACK feedback loop.
197
196
  if (incomingType !== "invalidSandboxMessage" &&
198
197
  incomingType !== "invalidHostMessage") {
199
198
  const nack = {
@@ -205,16 +204,16 @@ export class SandboxBridge {
205
204
  return;
206
205
  }
207
206
  const message = parsed.output;
208
- // If the host couldn't parse one of our outbound sandbox-to-host messages, it sends back
209
- // an `invalidSandboxMessage` NACK with a human-readable `reason`. Log it for developer
207
+ // If the host couldn't parse one of our outbound sandbox-to-host messages, it sends back an
208
+ // `invalidSandboxMessage` NACK with a human-readable `reason`. Log it for developer
210
209
  // visibility and stop. We don't retry as the sandbox can't recover from a host-side parse
211
210
  // failure on its own.
212
211
  if (message.type === "invalidSandboxMessage") {
213
212
  console.warn("[custom-blocks-sdk] host reported invalid sandbox message:", message.reason);
214
213
  return;
215
214
  }
216
- // `init` is the only message valid before initialization. Handle it up
217
- // front so every later case can assume `status === "initialized"`.
215
+ // `init` is the only message valid before initialization. Handle it up front so every later
216
+ // case can assume `status === "initialized"`.
218
217
  if (message.type === "init") {
219
218
  if (message.initializationId !== this.initializationId) {
220
219
  console.warn(`[custom-blocks-sdk] ignoring init for unknown initializationId ${message.initializationId}`);
@@ -228,8 +227,8 @@ export class SandboxBridge {
228
227
  this.applyInit(message, true);
229
228
  return;
230
229
  }
231
- // Alias to keep TS's narrowed `InitializedHostState` across the switch
232
- // below. Reading `this.hostState` repeatedly would re-widen it.
230
+ // Alias to keep TS's narrowed `InitializedHostState` across the switch below. Reading
231
+ // `this.hostState` repeatedly would re-widen it.
233
232
  const hostState = this.hostState;
234
233
  if (hostState.status !== "initialized") {
235
234
  console.warn(`[custom-blocks-sdk] ignoring ${message.type} before init`);
@@ -423,10 +422,9 @@ export class SandboxBridge {
423
422
  return this.hostState;
424
423
  }
425
424
  /**
426
- * Apply an `init` payload as if it had arrived from the host. Lets callers
427
- * seed the bridge directly (e.g. the React provider's standalone preview
428
- * fallback) without going through `postMessage`. The bridge stays unaware
429
- * of why it's being seeded.
425
+ * Apply an `init` payload as if it had arrived from the host. Lets callers seed the bridge
426
+ * directly (e.g. the React provider's standalone preview fallback) without going through
427
+ * `postMessage`. The bridge stays unaware of why it's being seeded.
430
428
  */
431
429
  setMockState(message) {
432
430
  this.isMockState = true;
@@ -471,12 +469,12 @@ export class SandboxBridge {
471
469
  this.isMockState = false;
472
470
  }
473
471
  if (message.status === "error") {
474
- // The host couldn't construct block location for this block (most commonly the parent record
475
- // failed to resolve). Surface the failure through the `awaitInit` promise so callers see
476
- // it through `useCustomBlockInit().error` instead of timing out. We also log here
477
- // because not every consumer renders the error UI, and we want the failure visible in
478
- // the browser console either way. We deliberately don't NACK the host or post anything
479
- // back over the bridge since the host has already given up.
472
+ // The host couldn't construct block location for this block (most commonly the parent
473
+ // record failed to resolve). Surface the failure through the `awaitInit` promise so
474
+ // callers see it through `useCustomBlockInit().error` instead of timing out. We also
475
+ // log here because not every consumer renders the error UI, and we want the failure
476
+ // visible in the browser console either way. We deliberately don't NACK the host or
477
+ // post anything back over the bridge since the host has already given up.
480
478
  console.error(`[custom-blocks-sdk] host reported init error (${message.error.code}): ${message.error.message}`);
481
479
  if (this.rejectInit) {
482
480
  this.rejectInit(new CustomBlockInitializationError(message.error));
@@ -515,9 +513,8 @@ export class SandboxBridge {
515
513
  contrastMode: message.contrastMode,
516
514
  });
517
515
  this.notify();
518
- // Resolve the awaitInit promise once. Subsequent `init` messages
519
- // (the host shouldn't send these, but be tolerant) update state but
520
- // don't re-resolve.
516
+ // Resolve the awaitInit promise once. Subsequent `init` messages (the host shouldn't send
517
+ // these, but be tolerant) update state but don't re-resolve.
521
518
  if (this.resolveInit) {
522
519
  this.resolveInit();
523
520
  this.resolveInit = undefined;
@@ -565,18 +562,26 @@ export class SandboxBridge {
565
562
  ? subscriptionState
566
563
  : createEmptyDataSourceQueryState(key);
567
564
  if (dataSource === undefined) {
568
- this.setDataSourceQueryError(subscriptionId, currentState, {
569
- code: "unknown_data_source_key",
570
- message: `Unknown data source key "${key}". Known keys: [${this.hostState.dataSources.map(entry => entry.key).join(", ")}].`,
571
- isRetryable: false,
565
+ this.setDataSourceQueryError({
566
+ subscriptionId,
567
+ currentState,
568
+ error: {
569
+ code: "unknown_data_source_key",
570
+ message: `Unknown data source key "${key}". Known keys: [${this.hostState.dataSources.map(entry => entry.key).join(", ")}].`,
571
+ isRetryable: false,
572
+ },
572
573
  });
573
574
  return;
574
575
  }
575
576
  if (dataSource.collectionPointer === undefined) {
576
- this.setDataSourceQueryError(subscriptionId, currentState, {
577
- code: "unmapped_data_source",
578
- message: `Data source "${key}" has not been mapped to a database yet.`,
579
- isRetryable: false,
577
+ this.setDataSourceQueryError({
578
+ subscriptionId,
579
+ currentState,
580
+ error: {
581
+ code: "unmapped_data_source",
582
+ message: `Data source "${key}" has not been mapped to a database yet.`,
583
+ isRetryable: false,
584
+ },
580
585
  });
581
586
  return;
582
587
  }
@@ -586,10 +591,10 @@ export class SandboxBridge {
586
591
  options,
587
592
  });
588
593
  if (resolvedQuery.status === "error") {
589
- this.setDataSourceQueryError(subscriptionId, currentState, {
590
- code: "invalid_data_source_query",
591
- message: resolvedQuery.error,
592
- isRetryable: false,
594
+ this.setDataSourceQueryError({
595
+ subscriptionId,
596
+ currentState,
597
+ error: resolvedQuery.error,
593
598
  });
594
599
  return;
595
600
  }
@@ -624,7 +629,7 @@ export class SandboxBridge {
624
629
  this.postToHost(outbound);
625
630
  this.notify();
626
631
  }
627
- setDataSourceQueryError(subscriptionId, currentState, error) {
632
+ setDataSourceQueryError({ subscriptionId, currentState, error, }) {
628
633
  if (this.hostState.status !== "initialized") {
629
634
  return;
630
635
  }
@@ -811,8 +816,8 @@ export class SandboxBridge {
811
816
  }
812
817
  /**
813
818
  * Translates the public `CreatePageArgs["parent"]` into the bridge-native
814
- * `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against
815
- * the data source mapping the host delivered in `init` / `dataSourcesChanged`.
819
+ * `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against the
820
+ * data source mapping the host delivered in `init` / `dataSourcesChanged`.
816
821
  */
817
822
  resolveCreatePageParent(parent) {
818
823
  switch (parent.type) {
@@ -902,11 +907,11 @@ function syncDocumentAppearance(args) {
902
907
  : NOTION_LIGHT_BACKGROUND_BASE;
903
908
  }
904
909
  /**
905
- * `postMessage` cloning creates new objects even for bindings that did not change.
906
- * Preserve their resolved object identity so React effects only run for changed bindings.
910
+ * `postMessage` cloning creates new objects even for bindings that did not change. Preserve their
911
+ * resolved object identity so React effects only run for changed bindings.
907
912
  *
908
- * This comparison runs when the host sends an update instead of on every component render.
909
- * Bindings are validated JSON-like bridge payloads, so serialization is sufficient here.
913
+ * This comparison runs when the host sends an update instead of on every component render. Bindings
914
+ * are validated JSON-like bridge payloads, so serialization is sufficient here.
910
915
  */
911
916
  function reuseDataSourcesForUnchangedBindings(args) {
912
917
  const previousDataSourcesByKey = new Map(args.previousDataSources.map(dataSource => [dataSource.key, dataSource]));
@@ -965,7 +970,7 @@ function resolveMockDataSources(bindings) {
965
970
  collectionPointer: binding.collectionPointer,
966
971
  collectionSchema: binding.collectionSchema,
967
972
  propertyIdsByKey: { ...(binding.propertyIdsByKey ?? {}) },
968
- propertySchemasById: binding.collectionSchema?.propertiesById ?? {},
973
+ propertySchemasById: getDataSourceReadSchemas(binding.collectionSchema),
969
974
  }));
970
975
  }
971
976
  function formatInvalidHostReason(incomingType, issues) {
@@ -1,6 +1,7 @@
1
1
  import type { NotionDataSource } from "../../protocol/dataSources/dataSource.js";
2
2
  import type { NotionDataSourceId } from "../../protocol/ids.js";
3
3
  import { type ResolvedCustomBlockDataSourceFilter, type ResolvedCustomBlockDataSourceSort } from "../../protocol/messages/queryDataSource.js";
4
+ import type { CustomBlockQueryDataSourceErrorInfo } from "../../protocol/messages/queryDataSourceResult.js";
4
5
  import type { UseDataSourceOptions } from "../../types.js";
5
6
  export type ResolvedDataSourceQuery = {
6
7
  dataSourceId: NotionDataSourceId;
@@ -11,7 +12,7 @@ export type ResolvedDataSourceQuery = {
11
12
  };
12
13
  export type ResolveDataSourceQueryResult = {
13
14
  status: "error";
14
- error: string;
15
+ error: CustomBlockQueryDataSourceErrorInfo;
15
16
  } | {
16
17
  status: "ok";
17
18
  dataSource: NotionDataSource;
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/bridge/dataSources/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAA;AAElG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,EASN,KAAK,mCAAmC,EAExC,KAAK,iCAAiC,EACtC,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAU1D,MAAM,MAAM,uBAAuB,GAAG;IACrC,YAAY,EAAE,kBAAkB,CAAA;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,mCAAmC,CAAA;IAC5C,KAAK,CAAC,EAAE,iCAAiC,EAAE,CAAA;IAC3C,QAAQ,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,4BAA4B,GACrC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IACA,MAAM,EAAE,IAAI,CAAA;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,KAAK,EAAE,uBAAuB,CAAA;CAC7B,CAAA;AAYJ,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC5C,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC,GAAG,4BAA4B,CAmD/B;AAiFD,wBAAgB,iCAAiC,CAChD,O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resolveDataSourceQuery(args) {
10
10
  const { dataSources, key, options, warn } = args;
11
11
  const resolvedOptions = resolveDataSourceQueryOptions(options);
12
12
  if (resolvedOptions.status === "error") {
13
- return resolvedOptions;
13
+ return {
14
+ status: "error",
15
+ error: getInvalidQueryError(resolvedOptions.error),
16
+ };
14
17
  }
15
18
  const queryOptions = resolvedOptions.options;
16
19
  const dataSource = dataSources.find(entry => entry.key === key);
17
20
  if (dataSource === undefined) {
18
21
  return {
19
22
  status: "error",
20
- error: `Unknown data source key "${key}". Known keys: [${dataSources.map(entry => entry.key).join(", ")}].`,
23
+ error: {
24
+ code: "unknown_data_source_key",
25
+ message: `Unknown data source key "${key}". Known keys: [${dataSources.map(entry => entry.key).join(", ")}].`,
26
+ // The query key or manifest must change before the query can succeed.
27
+ isRetryable: false,
28
+ },
21
29
  };
22
30
  }
23
31
  if (dataSource.collectionPointer === undefined) {
24
32
  return {
25
33
  status: "error",
26
- error: `Data source "${key}" has not been mapped to a database yet.`,
34
+ error: {
35
+ code: "unmapped_data_source",
36
+ message: `Data source "${key}" has not been mapped to a database yet.`,
37
+ // The host must supply a database binding before the query can succeed.
38
+ isRetryable: false,
39
+ },
40
+ };
41
+ }
42
+ if ((queryOptions?.filter !== undefined ||
43
+ (Array.isArray(queryOptions?.sorts) && queryOptions.sorts.length > 0)) &&
44
+ dataSource.collectionSchema === undefined) {
45
+ return {
46
+ status: "error",
47
+ error: {
48
+ code: "data_source_schema_unavailable",
49
+ message: `You cannot query data source "${key}" with filters or sorts because its schema is unavailable.`,
50
+ // Retrying cannot load the schema. A host binding update must supply it.
51
+ isRetryable: false,
52
+ },
27
53
  };
28
54
  }
29
55
  const limit = resolveDataSourceQueryLimit(queryOptions?.limit, warn);
30
56
  if (limit.status === "error") {
31
- return limit;
57
+ return { status: "error", error: getInvalidQueryError(limit.error) };
32
58
  }
33
59
  const filter = resolveFilter(queryOptions?.filter, dataSource);
34
60
  if (filter.status === "error") {
35
- return filter;
61
+ return { status: "error", error: getInvalidQueryError(filter.error) };
36
62
  }
37
63
  const sorts = resolveSorts(queryOptions?.sorts, dataSource);
38
64
  if (sorts.status === "error") {
39
- return sorts;
65
+ return { status: "error", error: getInvalidQueryError(sorts.error) };
40
66
  }
41
67
  const identity = stableJsonStringify({
42
68
  dataSourceId: dataSource.collectionPointer.id,
@@ -56,6 +82,10 @@ export function resolveDataSourceQuery(args) {
56
82
  },
57
83
  };
58
84
  }
85
+ function getInvalidQueryError(message) {
86
+ // The query, schema, or bindings must change before the query can succeed.
87
+ return { code: "invalid_data_source_query", message, isRetryable: false };
88
+ }
59
89
  function resolveDataSourceQueryOptions(options) {
60
90
  if (options === undefined) {
61
91
  return { status: "ok" };
@@ -449,13 +479,14 @@ function resolvePropertyAddress(value, dataSource) {
449
479
  }
450
480
  propertyId = value.propertyId;
451
481
  }
452
- if (!Object.hasOwn(dataSource.propertySchemasById, propertyId)) {
482
+ const properties = dataSource.collectionSchema?.propertiesById ?? {};
483
+ if (!Object.hasOwn(properties, propertyId)) {
453
484
  return {
454
485
  status: "error",
455
486
  error: `Unknown property ID "${propertyId}" for data source "${dataSource.key}".`,
456
487
  };
457
488
  }
458
- const propertySchema = dataSource.propertySchemasById[propertyId];
489
+ const propertySchema = properties[propertyId];
459
490
  return {
460
491
  status: "ok",
461
492
  propertyId,
@@ -1,16 +1,16 @@
1
- import type { NotionDataSource, NotionDataSourceBindings } from "../../protocol/dataSources/dataSource.js";
1
+ import type { NotionCollectionSchema, NotionDataSource, NotionDataSourceBindings } from "../../protocol/dataSources/dataSource.js";
2
+ import { type NotionPropertySchema } from "../../protocol/dataSources/propertySchema.js";
2
3
  import type { CustomBlockManifest } from "../../protocol/manifest.js";
3
- type ResolveDataSourcesArgs = {
4
- manifest: CustomBlockManifest;
5
- dataSourceBindings: NotionDataSourceBindings;
6
- };
7
4
  /**
8
5
  * Builds the public {@link NotionDataSource} list the SDK exposes to consumers.
9
6
  *
10
- * Combines the host-supplied bindings (collection pointers + schemas) with the
11
- * manifest's declared data source keys. The host owns every mapping; the SDK
12
- * validates supplied IDs but never infers omitted bindings.
7
+ * Combines the host-supplied bindings (database pointers + schemas) with the manifest's declared
8
+ * data source keys. The host owns every mapping; the SDK validates supplied IDs but never infers
9
+ * omitted bindings.
13
10
  */
14
- export declare function resolveDataSources(args: ResolveDataSourcesArgs): NotionDataSource[];
15
- export {};
11
+ export declare function resolveDataSources(args: {
12
+ manifest: CustomBlockManifest;
13
+ dataSourceBindings: NotionDataSourceBindings;
14
+ }): NotionDataSource[];
15
+ export declare function getDataSourceReadSchemas(collectionSchema: NotionCollectionSchema | undefined): Record<string, NotionPropertySchema>;
16
16
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/bridge/dataSources/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,wBAAwB,EACxB,MAAM,4DAA4D,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAEvF,KAAK,sBAAsB,GAAG;IAC7B,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,kBAAkB,EAAE,wBAAwB,CAAA;CAC5C,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,sBAAsB,GAC1B,gBAAgB,EAAE,CA+BpB"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/bridge/dataSources/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,MAAM,4DAA4D,CAAA;AACnE,OAAO,EAEN,KAAK,oBAAoB,EACzB,MAAM,gEAAgE,CAAA;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAEvF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACxC,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,kBAAkB,EAAE,wBAAwB,CAAA;CAC5C,GAAG,gBAAgB,EAAE,CAoCrB;AAED,wBAAgB,wBAAwB,CACvC,gBAAgB,EAAE,sBAAsB,GAAG,SAAS,GAClD,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAOtC"}
@@ -1,20 +1,24 @@
1
+ import { NOTION_BUILTIN_PROPERTY_SCHEMAS, } from "../../protocol/dataSources/propertySchema.js";
1
2
  /**
2
3
  * Builds the public {@link NotionDataSource} list the SDK exposes to consumers.
3
4
  *
4
- * Combines the host-supplied bindings (collection pointers + schemas) with the
5
- * manifest's declared data source keys. The host owns every mapping; the SDK
6
- * validates supplied IDs but never infers omitted bindings.
5
+ * Combines the host-supplied bindings (database pointers + schemas) with the manifest's declared
6
+ * data source keys. The host owns every mapping; the SDK validates supplied IDs but never infers
7
+ * omitted bindings.
7
8
  */
8
9
  export function resolveDataSources(args) {
9
10
  return Object.entries(args.manifest.dataSources).map(([key, manifestDataSource]) => {
10
11
  const binding = args.dataSourceBindings[key];
11
- const propertySchemasById = binding?.collectionSchema?.propertiesById ?? {};
12
+ const collectionProperties = binding?.collectionSchema?.propertiesById ?? {};
13
+ const propertySchemasById = getDataSourceReadSchemas(binding?.collectionSchema);
12
14
  const bindingPropertyIdsByKey = binding?.propertyIdsByKey ?? {};
13
15
  const propertyIdsByKey = {};
14
16
  const manifestProperties = Object.entries(manifestDataSource.properties ?? {});
15
17
  for (const [propertyKey, manifestProperty] of manifestProperties) {
16
18
  const propertyId = bindingPropertyIdsByKey[propertyKey];
17
- const propertySchema = propertyId === undefined ? undefined : propertySchemasById[propertyId];
19
+ const propertySchema = propertyId === undefined
20
+ ? undefined
21
+ : collectionProperties[propertyId];
18
22
  propertyIdsByKey[propertyKey] =
19
23
  propertySchema?.type === manifestProperty.type
20
24
  ? propertyId
@@ -29,3 +33,11 @@ export function resolveDataSources(args) {
29
33
  };
30
34
  });
31
35
  }
36
+ export function getDataSourceReadSchemas(collectionSchema) {
37
+ // Queries without filters or sorts can return metadata without a database schema. Keep
38
+ // metadata schemas available for reading those values.
39
+ return {
40
+ ...collectionSchema?.propertiesById,
41
+ ...NOTION_BUILTIN_PROPERTY_SCHEMAS,
42
+ };
43
+ }
@@ -7,6 +7,11 @@ declare const collectionPointerValidator: v.ObjectSchema<{
7
7
  export type NotionCollectionPointer = v.InferOutput<typeof collectionPointerValidator>;
8
8
  export declare const notionCollectionSchemaValidator: v.ObjectSchema<{
9
9
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
10
+ /**
11
+ * Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
12
+ * synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
13
+ * to validate filter and sort references.
14
+ */
10
15
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
11
16
  readonly name: v.StringSchema<undefined>;
12
17
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -144,8 +149,8 @@ export declare const notionCollectionSchemaValidator: v.ObjectSchema<{
144
149
  }, undefined>;
145
150
  export type NotionCollectionSchema = v.InferOutput<typeof notionCollectionSchemaValidator>;
146
151
  /**
147
- * Bridge shape for a single data source: a semantic key bound (optionally) to a collection,
148
- * its property name → ID mapping, and its column schemas.
152
+ * Describes a data source, its optional database binding, and its property schemas. The
153
+ * database schema validates query references. The read schemas describe snapshot values.
149
154
  */
150
155
  export declare const notionDataSourceSchema: v.ObjectSchema<{
151
156
  readonly key: v.StringSchema<undefined>;
@@ -154,8 +159,18 @@ export declare const notionDataSourceSchema: v.ObjectSchema<{
154
159
  readonly table: v.StringSchema<undefined>;
155
160
  readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
156
161
  }, undefined>, undefined>;
162
+ /**
163
+ * Describes database properties. Use this schema to resolve property bindings. Use this
164
+ * schema to validate filter and sort references. Undefined when the host does not provide a
165
+ * database schema.
166
+ */
157
167
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
158
168
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
169
+ /**
170
+ * Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
171
+ * synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
172
+ * to validate filter and sort references.
173
+ */
159
174
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
160
175
  readonly name: v.StringSchema<undefined>;
161
176
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -292,13 +307,21 @@ export declare const notionDataSourceSchema: v.ObjectSchema<{
292
307
  }, undefined>], undefined>, undefined>;
293
308
  }, undefined>, undefined>;
294
309
  /**
295
- * Keyed mapping of user-defined keys to a raw property ID. A key mapped to `undefined`
296
- * is a declared-but-unbound slot.
310
+ * Maps user-defined property keys to database property IDs. Use this map to resolve a key
311
+ * such as `name` to its database property ID. A value of `undefined` marks a declared
312
+ * property without a valid binding. Synthetic metadata does not add entries to this map.
297
313
  */
298
314
  readonly propertyIdsByKey: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
299
315
  /**
300
- * Keyed mapping of raw property IDs to their schema. Always includes the four built-ins
301
- * (`created_time`, `last_edited_time`, `created_by`, `last_edited_by`).
316
+ * Describes property values in query snapshots. Keys use the same property IDs as a snapshot's
317
+ * `propertiesById` map.
318
+ *
319
+ * Includes four synthetic metadata fields, even when the database schema is unavailable:
320
+ * `created_time`, `last_edited_time`, `created_by`, and `last_edited_by`. Also includes
321
+ * database properties when the host provides their schema.
322
+ *
323
+ * Use `propertiesById` to read a value. Use this map to read the value's schema. Use
324
+ * `collectionSchema` to validate filter and sort references.
302
325
  */
303
326
  readonly propertySchemasById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
304
327
  readonly name: v.StringSchema<undefined>;
@@ -442,8 +465,18 @@ export declare const notionDataSourceBindingSchema: v.ObjectSchema<{
442
465
  readonly table: v.StringSchema<undefined>;
443
466
  readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
444
467
  }, undefined>, undefined>;
468
+ /**
469
+ * Describes database properties. Use this schema to resolve property bindings. Use this
470
+ * schema to validate filter and sort references. Undefined when the host does not provide a
471
+ * database schema.
472
+ */
445
473
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
446
474
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
475
+ /**
476
+ * Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
477
+ * synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
478
+ * to validate filter and sort references.
479
+ */
447
480
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
448
481
  readonly name: v.StringSchema<undefined>;
449
482
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -579,6 +612,12 @@ export declare const notionDataSourceBindingSchema: v.ObjectSchema<{
579
612
  readonly type: v.LiteralSchema<"last_edited_by", undefined>;
580
613
  }, undefined>], undefined>, undefined>;
581
614
  }, undefined>, undefined>;
615
+ /**
616
+ * Maps user-defined property keys to database property IDs. Use this map to resolve a key
617
+ * such as `name` to its database property ID. A value of `undefined` marks a declared
618
+ * property without a binding. Omitted when the host does not provide property mappings.
619
+ * Synthetic metadata does not add entries to this map.
620
+ */
582
621
  readonly propertyIdsByKey: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
583
622
  }, undefined>;
584
623
  export type NotionDataSourceBinding = v.InferOutput<typeof notionDataSourceBindingSchema>;
@@ -588,8 +627,18 @@ export declare const notionDataSourceBindingsSchema: v.RecordSchema<v.StringSche
588
627
  readonly table: v.StringSchema<undefined>;
589
628
  readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
590
629
  }, undefined>, undefined>;
630
+ /**
631
+ * Describes database properties. Use this schema to resolve property bindings. Use this
632
+ * schema to validate filter and sort references. Undefined when the host does not provide a
633
+ * database schema.
634
+ */
591
635
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
592
636
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
637
+ /**
638
+ * Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
639
+ * synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
640
+ * to validate filter and sort references.
641
+ */
593
642
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
594
643
  readonly name: v.StringSchema<undefined>;
595
644
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -725,6 +774,12 @@ export declare const notionDataSourceBindingsSchema: v.RecordSchema<v.StringSche
725
774
  readonly type: v.LiteralSchema<"last_edited_by", undefined>;
726
775
  }, undefined>], undefined>, undefined>;
727
776
  }, undefined>, undefined>;
777
+ /**
778
+ * Maps user-defined property keys to database property IDs. Use this map to resolve a key
779
+ * such as `name` to its database property ID. A value of `undefined` marks a declared
780
+ * property without a binding. Omitted when the host does not provide property mappings.
781
+ * Synthetic metadata does not add entries to this map.
782
+ */
728
783
  readonly propertyIdsByKey: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
729
784
  }, undefined>, undefined>;
730
785
  export type NotionDataSourceBindings = v.InferOutput<typeof notionDataSourceBindingsSchema>;