@notionhq/custom-blocks 0.1.33 → 0.1.35

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 (36) hide show
  1. package/dist/bridge/SandboxBridge.d.ts +3 -1
  2. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  3. package/dist/bridge/SandboxBridge.js +55 -47
  4. package/dist/bridge/dataSources/query.d.ts +27 -0
  5. package/dist/bridge/dataSources/query.d.ts.map +1 -0
  6. package/dist/bridge/dataSources/query.js +512 -0
  7. package/dist/bridge/hostState.d.ts +4 -3
  8. package/dist/bridge/hostState.d.ts.map +1 -1
  9. package/dist/bridge/hostState.js +7 -3
  10. package/dist/bridge/sandboxClient.d.ts +4 -2
  11. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  12. package/dist/bridge/sandboxClient.js +10 -4
  13. package/dist/protocol/dataSources/propertySchema.d.ts +7 -0
  14. package/dist/protocol/dataSources/propertySchema.d.ts.map +1 -1
  15. package/dist/protocol/dataSources/propertySchema.js +17 -0
  16. package/dist/protocol/messages/queryDataSource.d.ts +970 -0
  17. package/dist/protocol/messages/queryDataSource.d.ts.map +1 -1
  18. package/dist/protocol/messages/queryDataSource.js +108 -0
  19. package/dist/protocol/messages/queryDataSourceResult.d.ts +1 -1
  20. package/dist/protocol/messages/queryDataSourceResult.d.ts.map +1 -1
  21. package/dist/protocol/messages/sandboxToHost.d.ts +353 -0
  22. package/dist/protocol/messages/sandboxToHost.d.ts.map +1 -1
  23. package/dist/react/useDataSource.d.ts +1 -1
  24. package/dist/react/useDataSource.d.ts.map +1 -1
  25. package/dist/react/useDataSource.js +11 -6
  26. package/dist/types.d.ts +52 -0
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/version.js +1 -1
  29. package/docs/data-sources.md +51 -3
  30. package/package.json +1 -1
  31. package/src/bridge/SandboxBridge.ts +66 -57
  32. package/src/bridge/dataSources/query.ts +694 -0
  33. package/src/bridge/hostState.ts +11 -3
  34. package/src/bridge/sandboxClient.ts +20 -4
  35. package/src/react/useDataSource.ts +17 -6
  36. package/src/types.ts +55 -0
@@ -0,0 +1,512 @@
1
+ import { CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES } from "../../protocol/dataSources/propertySchema.js";
2
+ import { CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS, customBlockCheckboxFilterOperatorSchema, customBlockContainsFilterOperatorSchema, customBlockDateFilterOperatorSchema, customBlockNumberFilterOperatorSchema, customBlockOptionFilterOperatorSchema, customBlockTextFilterOperatorSchema, } from "../../protocol/messages/queryDataSource.js";
3
+ import * as v from "valibot";
4
+ import { unreachable } from "../../utils.js";
5
+ const DEFAULT_DATA_SOURCE_QUERY_LIMIT = 20;
6
+ const MAX_DATA_SOURCE_QUERY_LIMIT = 999;
7
+ const MAX_DATA_SOURCE_QUERY_FILTER_CHILDREN = 25;
8
+ const supportedDataSourceSortPropertyTypes = new Set(CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES);
9
+ export function resolveDataSourceQuery(args) {
10
+ const { dataSources, key, options, warn } = args;
11
+ const resolvedOptions = resolveDataSourceQueryOptions(options);
12
+ if (resolvedOptions.status === "error") {
13
+ return resolvedOptions;
14
+ }
15
+ const queryOptions = resolvedOptions.options;
16
+ const dataSource = dataSources.find(entry => entry.key === key);
17
+ if (dataSource === undefined) {
18
+ return {
19
+ status: "error",
20
+ error: `Unknown data source key "${key}". Known keys: [${dataSources.map(entry => entry.key).join(", ")}].`,
21
+ };
22
+ }
23
+ if (dataSource.collectionPointer === undefined) {
24
+ return {
25
+ status: "error",
26
+ error: `Data source "${key}" has not been mapped to a database yet.`,
27
+ };
28
+ }
29
+ const limit = resolveDataSourceQueryLimit(queryOptions?.limit, warn);
30
+ if (limit.status === "error") {
31
+ return limit;
32
+ }
33
+ const filter = resolveFilter(queryOptions?.filter, dataSource);
34
+ if (filter.status === "error") {
35
+ return filter;
36
+ }
37
+ const sorts = resolveSorts(queryOptions?.sorts, dataSource);
38
+ if (sorts.status === "error") {
39
+ return sorts;
40
+ }
41
+ const identity = stableJsonStringify({
42
+ dataSourceId: dataSource.collectionPointer.id,
43
+ limit: limit.limit,
44
+ filter: filter.filter ?? null,
45
+ sorts: sorts.sorts ?? [],
46
+ });
47
+ return {
48
+ status: "ok",
49
+ dataSource,
50
+ query: {
51
+ dataSourceId: dataSource.collectionPointer.id,
52
+ limit: limit.limit,
53
+ filter: filter.filter,
54
+ sorts: sorts.sorts,
55
+ identity,
56
+ },
57
+ };
58
+ }
59
+ function resolveDataSourceQueryOptions(options) {
60
+ if (options === undefined) {
61
+ return { status: "ok" };
62
+ }
63
+ if (typeof options !== "object" ||
64
+ options === null ||
65
+ Array.isArray(options)) {
66
+ return {
67
+ status: "error",
68
+ error: "Data source query options must be an object.",
69
+ };
70
+ }
71
+ const prototype = Object.getPrototypeOf(options);
72
+ if (prototype !== Object.prototype && prototype !== null) {
73
+ return {
74
+ status: "error",
75
+ error: "Data source query options must be an object.",
76
+ };
77
+ }
78
+ const optionsObject = options;
79
+ if (Object.keys(optionsObject).some(key => !["limit", "filter", "sorts"].includes(key))) {
80
+ return {
81
+ status: "error",
82
+ error: "Data source query options contain unsupported fields.",
83
+ };
84
+ }
85
+ return {
86
+ status: "ok",
87
+ options: {
88
+ limit: Object.prototype.hasOwnProperty.call(optionsObject, "limit")
89
+ ? optionsObject.limit
90
+ : undefined,
91
+ filter: Object.prototype.hasOwnProperty.call(optionsObject, "filter")
92
+ ? optionsObject.filter
93
+ : undefined,
94
+ sorts: Object.prototype.hasOwnProperty.call(optionsObject, "sorts")
95
+ ? optionsObject.sorts
96
+ : undefined,
97
+ },
98
+ };
99
+ }
100
+ function resolveDataSourceQueryLimit(limit, warn = console.warn) {
101
+ if (limit === undefined) {
102
+ return { status: "ok", limit: DEFAULT_DATA_SOURCE_QUERY_LIMIT };
103
+ }
104
+ if (typeof limit !== "number" ||
105
+ !Number.isFinite(limit) ||
106
+ !Number.isInteger(limit) ||
107
+ limit < 1) {
108
+ return {
109
+ status: "error",
110
+ error: `Data source query limit must be a positive integer between 1 and ${MAX_DATA_SOURCE_QUERY_LIMIT}.`,
111
+ };
112
+ }
113
+ if (limit > MAX_DATA_SOURCE_QUERY_LIMIT) {
114
+ warn?.(`Data source query limit ${limit} exceeds the maximum of ${MAX_DATA_SOURCE_QUERY_LIMIT}; clamping to ${MAX_DATA_SOURCE_QUERY_LIMIT}.`);
115
+ return { status: "ok", limit: MAX_DATA_SOURCE_QUERY_LIMIT };
116
+ }
117
+ return { status: "ok", limit };
118
+ }
119
+ export function getDataSourceQueryOptionsIdentity(options) {
120
+ try {
121
+ return stableJsonStringify(options ?? {});
122
+ }
123
+ catch {
124
+ return "invalid-data-source-query-options";
125
+ }
126
+ }
127
+ function stableJsonStringify(value) {
128
+ return JSON.stringify(normalizeJsonValue(value));
129
+ }
130
+ function resolveFilter(filter, dataSource) {
131
+ if (filter === undefined) {
132
+ return { status: "ok" };
133
+ }
134
+ if (typeof filter !== "object" || filter === null || Array.isArray(filter)) {
135
+ return {
136
+ status: "error",
137
+ error: "Data source query filter must be an object.",
138
+ };
139
+ }
140
+ const filterObject = filter;
141
+ if (Object.prototype.hasOwnProperty.call(filterObject, "and")) {
142
+ if (Object.keys(filterObject).length !== 1 ||
143
+ !Array.isArray(filterObject.and)) {
144
+ return {
145
+ status: "error",
146
+ error: 'Data source query filter "and" must be an array.',
147
+ };
148
+ }
149
+ if (filterObject.and.length > MAX_DATA_SOURCE_QUERY_FILTER_CHILDREN) {
150
+ return {
151
+ status: "error",
152
+ error: `Data source query filter "and" may contain at most ${MAX_DATA_SOURCE_QUERY_FILTER_CHILDREN} children.`,
153
+ };
154
+ }
155
+ const and = [];
156
+ for (const child of filterObject.and) {
157
+ const resolved = resolvePropertyFilter(child, dataSource);
158
+ if (resolved.status === "error") {
159
+ return resolved;
160
+ }
161
+ and.push(resolved.filter);
162
+ }
163
+ return { status: "ok", filter: { and } };
164
+ }
165
+ return resolvePropertyFilter(filterObject, dataSource);
166
+ }
167
+ function resolveSorts(sorts, dataSource) {
168
+ if (sorts === undefined) {
169
+ return { status: "ok" };
170
+ }
171
+ if (!Array.isArray(sorts)) {
172
+ return {
173
+ status: "error",
174
+ error: "Data source query sorts must be an array.",
175
+ };
176
+ }
177
+ if (sorts.length === 0) {
178
+ return { status: "ok" };
179
+ }
180
+ if (sorts.length > CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS) {
181
+ return {
182
+ status: "error",
183
+ error: `Data source query sorts may contain at most ${CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS} entries.`,
184
+ };
185
+ }
186
+ const resolvedSorts = [];
187
+ const seenPropertyIds = new Set();
188
+ for (const sort of sorts) {
189
+ const resolved = resolveSort(sort, dataSource);
190
+ if (resolved.status === "error") {
191
+ return resolved;
192
+ }
193
+ if (seenPropertyIds.has(resolved.sort.propertyId)) {
194
+ return {
195
+ status: "error",
196
+ error: `Data source query sorts cannot contain duplicate property ID "${resolved.sort.propertyId}".`,
197
+ };
198
+ }
199
+ seenPropertyIds.add(resolved.sort.propertyId);
200
+ resolvedSorts.push(resolved.sort);
201
+ }
202
+ return { status: "ok", sorts: resolvedSorts };
203
+ }
204
+ function resolveSort(sort, dataSource) {
205
+ if (typeof sort !== "object" || sort === null || Array.isArray(sort)) {
206
+ return {
207
+ status: "error",
208
+ error: "Data source query sort must be an object.",
209
+ };
210
+ }
211
+ const sortObject = sort;
212
+ if (Object.keys(sortObject).some(key => !["key", "propertyId", "direction"].includes(key))) {
213
+ return {
214
+ status: "error",
215
+ error: "Data source query sort contains unsupported fields.",
216
+ };
217
+ }
218
+ const property = resolvePropertyAddress(sortObject, dataSource);
219
+ if (property.status === "error") {
220
+ return property;
221
+ }
222
+ if (!supportedDataSourceSortPropertyTypes.has(property.propertyType)) {
223
+ return {
224
+ status: "error",
225
+ error: `Data source query sorts do not yet support property type "${property.propertyType}".`,
226
+ };
227
+ }
228
+ const direction = sortObject.direction;
229
+ if (!Object.prototype.hasOwnProperty.call(sortObject, "direction") ||
230
+ (direction !== "ascending" && direction !== "descending")) {
231
+ return {
232
+ status: "error",
233
+ error: 'Data source query sort direction must be "ascending" or "descending".',
234
+ };
235
+ }
236
+ return {
237
+ status: "ok",
238
+ sort: { propertyId: property.propertyId, direction },
239
+ };
240
+ }
241
+ function resolvePropertyFilter(filter, dataSource) {
242
+ if (typeof filter !== "object" || filter === null || Array.isArray(filter)) {
243
+ return {
244
+ status: "error",
245
+ error: "Data source query property filter must be an object.",
246
+ };
247
+ }
248
+ const filterObject = filter;
249
+ const property = resolvePropertyAddress(filterObject, dataSource);
250
+ if (property.status === "error") {
251
+ return property;
252
+ }
253
+ const branchKeys = Object.keys(filterObject).filter(key => key !== "key" && key !== "propertyId");
254
+ if (branchKeys.length !== 1) {
255
+ return {
256
+ status: "error",
257
+ error: "Data source query property filter must contain exactly one property branch.",
258
+ };
259
+ }
260
+ const branch = branchKeys[0];
261
+ const value = filterObject[branch];
262
+ if (typeof value !== "object" ||
263
+ value === null ||
264
+ Array.isArray(value) ||
265
+ Object.keys(value).length !== 1) {
266
+ return invalidOperator(branch);
267
+ }
268
+ if (property.propertyType !== branch) {
269
+ return {
270
+ status: "error",
271
+ error: `Data source query filter branch "${branch}" does not match property type "${property.propertyType}".`,
272
+ };
273
+ }
274
+ return resolvePropertyFilterBranch({
275
+ propertyId: property.propertyId,
276
+ branch,
277
+ value: value,
278
+ });
279
+ }
280
+ function resolvePropertyFilterBranch(args) {
281
+ switch (args.branch) {
282
+ case "title":
283
+ case "rich_text":
284
+ case "url":
285
+ case "email":
286
+ case "phone_number":
287
+ return resolveTextPropertyFilter({
288
+ propertyId: args.propertyId,
289
+ branch: args.branch,
290
+ value: args.value,
291
+ });
292
+ case "number":
293
+ return resolveNumberPropertyFilter(args.propertyId, args.value);
294
+ case "checkbox":
295
+ return resolveCheckboxPropertyFilter(args.propertyId, args.value);
296
+ case "select":
297
+ case "status":
298
+ return resolveOptionPropertyFilter({
299
+ propertyId: args.propertyId,
300
+ branch: args.branch,
301
+ value: args.value,
302
+ });
303
+ case "multi_select":
304
+ return resolveMultiSelectPropertyFilter(args.propertyId, args.value);
305
+ case "date":
306
+ return resolveDatePropertyFilter(args.propertyId, args.value);
307
+ default:
308
+ return {
309
+ status: "error",
310
+ error: `Data source query filter branch "${args.branch}" is not supported.`,
311
+ };
312
+ }
313
+ }
314
+ function resolveTextPropertyFilter(args) {
315
+ const parsed = v.safeParse(customBlockTextFilterOperatorSchema, args.value);
316
+ if (!parsed.success) {
317
+ return invalidOperator(args.branch);
318
+ }
319
+ switch (args.branch) {
320
+ case "title":
321
+ return {
322
+ status: "ok",
323
+ filter: { propertyId: args.propertyId, title: parsed.output },
324
+ };
325
+ case "rich_text":
326
+ return {
327
+ status: "ok",
328
+ filter: { propertyId: args.propertyId, rich_text: parsed.output },
329
+ };
330
+ case "url":
331
+ return {
332
+ status: "ok",
333
+ filter: { propertyId: args.propertyId, url: parsed.output },
334
+ };
335
+ case "email":
336
+ return {
337
+ status: "ok",
338
+ filter: { propertyId: args.propertyId, email: parsed.output },
339
+ };
340
+ case "phone_number":
341
+ return {
342
+ status: "ok",
343
+ filter: { propertyId: args.propertyId, phone_number: parsed.output },
344
+ };
345
+ default:
346
+ return unreachable(args.branch);
347
+ }
348
+ }
349
+ function resolveNumberPropertyFilter(propertyId, value) {
350
+ const parsed = v.safeParse(customBlockNumberFilterOperatorSchema, value);
351
+ if (!parsed.success ||
352
+ !Object.values(parsed.output).every(entry => typeof entry !== "number" || Number.isFinite(entry))) {
353
+ return invalidOperator("number");
354
+ }
355
+ return {
356
+ status: "ok",
357
+ filter: { propertyId, number: parsed.output },
358
+ };
359
+ }
360
+ function resolveCheckboxPropertyFilter(propertyId, value) {
361
+ const parsed = v.safeParse(customBlockCheckboxFilterOperatorSchema, value);
362
+ return parsed.success
363
+ ? { status: "ok", filter: { propertyId, checkbox: parsed.output } }
364
+ : invalidOperator("checkbox");
365
+ }
366
+ function resolveOptionPropertyFilter(args) {
367
+ const parsed = v.safeParse(customBlockOptionFilterOperatorSchema, args.value);
368
+ if (!parsed.success) {
369
+ return invalidOperator(args.branch);
370
+ }
371
+ switch (args.branch) {
372
+ case "select":
373
+ return {
374
+ status: "ok",
375
+ filter: { propertyId: args.propertyId, select: parsed.output },
376
+ };
377
+ case "status":
378
+ return {
379
+ status: "ok",
380
+ filter: { propertyId: args.propertyId, status: parsed.output },
381
+ };
382
+ default:
383
+ return unreachable(args.branch);
384
+ }
385
+ }
386
+ function resolveMultiSelectPropertyFilter(propertyId, value) {
387
+ const parsed = v.safeParse(customBlockContainsFilterOperatorSchema, value);
388
+ return parsed.success
389
+ ? { status: "ok", filter: { propertyId, multi_select: parsed.output } }
390
+ : invalidOperator("multi_select");
391
+ }
392
+ function resolveDatePropertyFilter(propertyId, value) {
393
+ const parsed = v.safeParse(customBlockDateFilterOperatorSchema, value);
394
+ if (!parsed.success ||
395
+ !Object.values(parsed.output).every(entry => entry === true || isValidIsoDate(entry))) {
396
+ return invalidOperator("date");
397
+ }
398
+ return {
399
+ status: "ok",
400
+ filter: { propertyId, date: parsed.output },
401
+ };
402
+ }
403
+ function resolvePropertyAddress(value, dataSource) {
404
+ const hasKey = Object.prototype.hasOwnProperty.call(value, "key");
405
+ const hasPropertyId = Object.prototype.hasOwnProperty.call(value, "propertyId");
406
+ if (hasKey === hasPropertyId) {
407
+ return {
408
+ status: "error",
409
+ error: "Data source query filters and sorts must use exactly one of key or propertyId.",
410
+ };
411
+ }
412
+ let propertyId;
413
+ if (hasKey) {
414
+ if (typeof value.key !== "string") {
415
+ return {
416
+ status: "error",
417
+ error: "Data source query property key must be a string.",
418
+ };
419
+ }
420
+ if (!Object.prototype.hasOwnProperty.call(dataSource.propertyIdsByKey, value.key)) {
421
+ return {
422
+ status: "error",
423
+ error: `Unknown property key "${value.key}" for data source "${dataSource.key}".`,
424
+ };
425
+ }
426
+ const resolvedPropertyId = dataSource.propertyIdsByKey[value.key];
427
+ if (resolvedPropertyId === undefined) {
428
+ return {
429
+ status: "error",
430
+ error: `Property key "${value.key}" for data source "${dataSource.key}" is not bound.`,
431
+ };
432
+ }
433
+ propertyId = resolvedPropertyId;
434
+ }
435
+ else {
436
+ if (typeof value.propertyId !== "string") {
437
+ return {
438
+ status: "error",
439
+ error: "Data source query propertyId must be a string.",
440
+ };
441
+ }
442
+ propertyId = value.propertyId;
443
+ }
444
+ if (!Object.prototype.hasOwnProperty.call(dataSource.propertySchemasById, propertyId)) {
445
+ return {
446
+ status: "error",
447
+ error: `Unknown property ID "${propertyId}" for data source "${dataSource.key}".`,
448
+ };
449
+ }
450
+ const propertySchema = dataSource.propertySchemasById[propertyId];
451
+ return {
452
+ status: "ok",
453
+ propertyId,
454
+ propertyType: propertySchema.type,
455
+ };
456
+ }
457
+ function invalidOperator(branch) {
458
+ return {
459
+ status: "error",
460
+ error: `Data source query filter branch "${branch}" has an invalid operator or value.`,
461
+ };
462
+ }
463
+ function normalizeJsonValue(value) {
464
+ if (value === null ||
465
+ typeof value === "string" ||
466
+ typeof value === "boolean") {
467
+ return value;
468
+ }
469
+ if (typeof value === "number") {
470
+ return normalizeJsonNumber(value);
471
+ }
472
+ if (Array.isArray(value)) {
473
+ return value.map(entry => normalizeJsonValue(entry));
474
+ }
475
+ if (typeof value === "object") {
476
+ return normalizeJsonObject(value);
477
+ }
478
+ throw new Error("Data source query values must be JSON-compatible.");
479
+ }
480
+ function normalizeJsonNumber(value) {
481
+ if (!Number.isFinite(value)) {
482
+ throw new Error("Data source query values must be finite JSON numbers.");
483
+ }
484
+ return value;
485
+ }
486
+ function normalizeJsonObject(value) {
487
+ const prototype = Object.getPrototypeOf(value);
488
+ if (prototype !== Object.prototype && prototype !== null) {
489
+ throw new Error("Data source query values must be JSON-compatible.");
490
+ }
491
+ const objectValue = value;
492
+ const normalized = {};
493
+ for (const key of Object.keys(objectValue).sort()) {
494
+ const child = objectValue[key];
495
+ if (child !== undefined) {
496
+ normalized[key] = normalizeJsonValue(child);
497
+ }
498
+ }
499
+ return normalized;
500
+ }
501
+ function isValidIsoDate(value) {
502
+ if (typeof value !== "string") {
503
+ return false;
504
+ }
505
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
506
+ if (dateOnly !== null) {
507
+ const [, year, month, day] = dateOnly;
508
+ const date = new Date(Date.UTC(Number(year), Number(month) - 1, Number(day)));
509
+ return date.toISOString().slice(0, 10) === value;
510
+ }
511
+ return (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:\d{2})$/.test(value) && Number.isFinite(Date.parse(value)));
512
+ }
@@ -29,15 +29,16 @@ export type InitializedHostState = {
29
29
  dataSourceState: Record<string, DataSourceQueryState>;
30
30
  };
31
31
  export type DataSourceQueryState = {
32
+ dataSourceKey: string;
32
33
  /** Latest pages from the host as parsed from the bridge. `propertiesByKey` is derived lazily. */
33
34
  items: NotionDataSourcePageBridge[];
34
35
  isLoading: boolean;
35
36
  hasMore: boolean;
36
37
  error?: CustomBlockQueryDataSourceErrorInfo;
37
- subscriptionId?: string;
38
38
  latestLimit?: number;
39
+ latestQueryIdentity?: string;
39
40
  };
40
- export declare function createEmptyDataSourceQueryState(): DataSourceQueryState;
41
+ export declare function createEmptyDataSourceQueryState(dataSourceKey: string): DataSourceQueryState;
41
42
  /**
42
43
  * Resolved page + schema views for a single data source, keyed by raw property
43
44
  * ID and by user-defined key. Re-derived from `propertyIdsByKey` on every read so
@@ -69,5 +70,5 @@ export type UpdateDataSourcePageFn = (args: {
69
70
  pageId: NotionPageId;
70
71
  pageUpdateArgs: NotionDataSourcePageUpdateArgs;
71
72
  }) => Promise<UpdatePageResult>;
72
- export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, updateDataSourcePage: UpdateDataSourcePageFn): DataSourceQueryView;
73
+ export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, subscriptionId: string, updateDataSourcePage: UpdateDataSourcePageFn): DataSourceQueryView;
73
74
  //# sourceMappingURL=hostState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"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"}
@@ -1,5 +1,6 @@
1
- export function createEmptyDataSourceQueryState() {
1
+ export function createEmptyDataSourceQueryState(dataSourceKey) {
2
2
  return {
3
+ dataSourceKey,
3
4
  items: [],
4
5
  isLoading: false,
5
6
  hasMore: false,
@@ -13,12 +14,15 @@ const EMPTY_QUERY_VIEW = {
13
14
  isLoading: false,
14
15
  hasMore: false,
15
16
  };
16
- export function getDataSourceQueryView(hostState, key, updateDataSourcePage) {
17
+ export function getDataSourceQueryView(hostState, key, subscriptionId, updateDataSourcePage) {
17
18
  if (hostState.status !== "initialized") {
18
19
  return EMPTY_QUERY_VIEW;
19
20
  }
20
21
  const dataSource = hostState.dataSources.find(entry => entry.key === key);
21
- const queryState = hostState.dataSourceState[key] ?? createEmptyDataSourceQueryState();
22
+ const subscriptionState = hostState.dataSourceState[subscriptionId];
23
+ const queryState = subscriptionState?.dataSourceKey === key
24
+ ? subscriptionState
25
+ : createEmptyDataSourceQueryState(key);
22
26
  if (dataSource === undefined) {
23
27
  return {
24
28
  items: [],
@@ -19,8 +19,10 @@ export declare const customBlockHost: {
19
19
  postResize: (height: number) => void;
20
20
  };
21
21
  export declare const customBlockDataSources: {
22
- query: (key: string, options?: UseDataSourceOptions) => void;
23
- getView: (hostState: CustomBlockHostState, key: string) => DataSourceQueryView;
22
+ createSubscriptionId: () => string;
23
+ query: (subscriptionId: string, key: string, options?: UseDataSourceOptions) => void;
24
+ release: (subscriptionId: string) => void;
25
+ getView: (hostState: CustomBlockHostState, key: string, subscriptionId: string) => DataSourceQueryView;
24
26
  };
25
27
  export declare const messageLog: {
26
28
  getSnapshot: () => readonly MessageLogEntry[];
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/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,EACf,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AAWxE,eAAO,MAAM,eAAe;;kCAKG,kBAAkB;yBAI3B,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;0BAI1B,MAAM,IAAI;oBAIlB,oBAAoB;IAIlC;;;OAGG;4BACqB,WAAW;;yBAQd,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;iBACrB,MAAM,YAAY,oBAAoB;yBAKvC,oBAAoB,OAC1B,MAAM,KACT,mBAAmB;CAKtB,CAAA;AAED,eAAO,MAAM,UAAU;uBACL,SAAS,eAAe,EAAE;0BAIrB,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAInD;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;qBACc,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAAC;CAGzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;mBACY,aAAa,KAAG,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
1
+ {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/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,EACf,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AAWxE,eAAO,MAAM,eAAe;;kCAKG,kBAAkB;yBAI3B,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;0BAI1B,MAAM,IAAI;oBAIlB,oBAAoB;IAIlC;;;OAGG;4BACqB,WAAW;;yBAQd,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;;4BAMjB,MAAM,OACjB,MAAM,YACD,oBAAoB;8BAKL,MAAM;yBAKpB,oBAAoB,OAC1B,MAAM,kBACK,MAAM,KACpB,mBAAmB;CAQtB,CAAA;AAED,eAAO,MAAM,UAAU;uBACL,SAAS,eAAe,EAAE;0BAIrB,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAInD;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;qBACc,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAAC;CAGzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;mBACY,aAAa,KAAG,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
@@ -38,11 +38,17 @@ export const customBlockHost = {
38
38
  },
39
39
  };
40
40
  export const customBlockDataSources = {
41
- query: (key, options) => {
42
- getBridge().queryDataSource(key, options);
41
+ createSubscriptionId: () => {
42
+ return getBridge().createDataSourceSubscriptionId();
43
43
  },
44
- getView: (hostState, key) => {
45
- return getDataSourceQueryViewWithBridge(hostState, key, args => getBridge().updateDataSourcePage(args));
44
+ query: (subscriptionId, key, options) => {
45
+ getBridge().queryDataSource(subscriptionId, key, options);
46
+ },
47
+ release: (subscriptionId) => {
48
+ getBridge().releaseDataSourceSubscription(subscriptionId);
49
+ },
50
+ getView: (hostState, key, subscriptionId) => {
51
+ return getDataSourceQueryViewWithBridge(hostState, key, subscriptionId, args => getBridge().updateDataSourcePage(args));
46
52
  },
47
53
  };
48
54
  export const messageLog = {
@@ -43,6 +43,13 @@ export declare const notionPropertyTypeSchema: v.PicklistSchema<readonly ["title
43
43
  * payload shapes.
44
44
  */
45
45
  export type NotionPropertyType = v.InferOutput<typeof notionPropertyTypeSchema>;
46
+ /**
47
+ * Property types currently supported by the custom-block data source sort API.
48
+ * Keep this list narrower than {@link NOTION_PROPERTY_TYPES} when a property
49
+ * type is exposed but its sort value is not yet represented by every host.
50
+ */
51
+ export declare const CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES: readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "date", "created_time", "last_edited_time"];
52
+ export type CustomBlockDataSourceSortablePropertyType = (typeof CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES)[number];
46
53
  /**
47
54
  * Per-property schema as exposed by the host over the custom-block bridge.
48
55
  * The `type` discriminator must be one of {@link NOTION_PROPERTY_TYPES}.
@@ -1 +1 @@
1
- {"version":3,"file":"propertySchema.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/dataSources/propertySchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,iUAqBpC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAC9C,OAAO,yBAAyB,CAChC,CAAA;AAED,eAAO,MAAM,0BAA0B;;;;;aAKrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA;AAED,eAAO,MAAM,uBAAuB;;;;;aAKlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE7E,eAAO,MAAM,wBAAwB;;;aAGnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAO/E;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,4UA2BxB,CAAA;AAEV,eAAO,MAAM,wBAAwB,yWAAoC,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAiDrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,+EAK9B,CAAA;AAEV,MAAM,MAAM,uBAAuB,GAClC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAA"}
1
+ {"version":3,"file":"propertySchema.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/dataSources/propertySchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,iUAqBpC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAC9C,OAAO,yBAAyB,CAChC,CAAA;AAED,eAAO,MAAM,0BAA0B;;;;;aAKrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA;AAED,eAAO,MAAM,uBAAuB;;;;;aAKlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE7E,eAAO,MAAM,wBAAwB;;;aAGnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAO/E;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,4UA2BxB,CAAA;AAEV,eAAO,MAAM,wBAAwB,yWAAoC,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,gDAAgD,mIAWX,CAAA;AAElD,MAAM,MAAM,yCAAyC,GACpD,CAAC,OAAO,gDAAgD,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAiDrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,+EAK9B,CAAA;AAEV,MAAM,MAAM,uBAAuB,GAClC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAA"}
@@ -84,6 +84,23 @@ export const NOTION_PROPERTY_TYPES = [
84
84
  "last_edited_by",
85
85
  ];
86
86
  export const notionPropertyTypeSchema = v.picklist(NOTION_PROPERTY_TYPES);
87
+ /**
88
+ * Property types currently supported by the custom-block data source sort API.
89
+ * Keep this list narrower than {@link NOTION_PROPERTY_TYPES} when a property
90
+ * type is exposed but its sort value is not yet represented by every host.
91
+ */
92
+ export const CUSTOM_BLOCK_DATA_SOURCE_SORTABLE_PROPERTY_TYPES = [
93
+ "title",
94
+ "rich_text",
95
+ "number",
96
+ "checkbox",
97
+ "url",
98
+ "email",
99
+ "phone_number",
100
+ "date",
101
+ "created_time",
102
+ "last_edited_time",
103
+ ];
87
104
  /**
88
105
  * Per-property schema as exposed by the host over the custom-block bridge.
89
106
  * The `type` discriminator must be one of {@link NOTION_PROPERTY_TYPES}.